Changeset 109
- Timestamp:
- Mar 15, 2008, 10:19:47 PM (14 years ago)
- Location:
- abuse/trunk/src/imlib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/input.cpp
r107 r109 88 88 { 89 89 return ; 90 } 91 92 void button_box::move(int newx, int newy) 93 { 94 for(button * b = buttons; b; b = (button *)b->next) 95 b->move(newx + b->x, newy + b->y); 96 x = newx; 97 y = newy; 90 98 } 91 99 -
abuse/trunk/src/imlib/input.hpp
r106 r109 43 43 button *buttons; 44 44 int maxdown; 45 45 public : 46 46 button_box(int X, int Y, int ID, int MaxDown, button *Buttons, ifield *Next); 47 47 void add_button(button *b); 48 48 void press_button(int id); // if button box doesn't contain id, nothing happens 49 49 virtual void remap(filter *f); 50 virtual void move(int newx, int newy); 50 51 virtual void area(int &x1, int &y1, int &x2, int &y2); 51 52 virtual void draw_first(image *screen); -
abuse/trunk/src/imlib/jwindow.cpp
r106 r109 25 25 int frame_right() { return jw_right; } 26 26 27 ifield::~ifield() { ; }28 29 27 void set_frame_size(int x) 30 28 { … … 79 77 for (p=first;p;p=p->next) 80 78 { 81 if (!p-> property.hidden)82 { 83 p-> property.hidden=1;79 if (!p->is_hidden()) 80 { 81 p->hide(); 84 82 screen->add_dirty(p->x,p->y,p->x+p->l-1,p->y+p->h-1); 85 83 } … … 91 89 jwindow *p; 92 90 for (p=first;p;p=p->next) 93 if (p-> property.hidden)91 if (p->is_hidden()) 94 92 show_window(p); 95 93 } … … 110 108 } 111 109 screen->add_dirty(j->x,j->y,j->x+j->l-1,j->y+j->h-1); 112 j-> property.hidden=1;110 j->hide(); 113 111 } 114 112 115 113 void window_manager::show_window(jwindow *j) 116 114 { 117 if (j-> property.hidden)118 { 119 j-> property.hidden=0;115 if (j->is_hidden()) 116 { 117 j->show(); 120 118 j->screen->add_dirty(0,0,j->l-1,j->h-1); 121 119 } … … 134 132 { 135 133 for (ev.window=NULL,j=first;j;j=j->next) 136 if (!j-> property.hidden&& ev.mouse_move.x>=j->x && ev.mouse_move.y>=j->y &&134 if (!j->is_hidden() && ev.mouse_move.x>=j->x && ev.mouse_move.y>=j->y && 137 135 ev.mouse_move.x<j->x+j->l && ev.mouse_move.y<j->y+j->h) 138 136 ev.window=j; … … 149 147 { 150 148 if (ev.mouse_move.x-ev.window->x<11) closew=1; 151 else if (ev.window-> property.moveable) movew=1;149 else if (ev.window->is_moveable()) movew=1; 152 150 } else if (grab) 153 151 ev.window=grab; … … 276 274 277 275 jwindow *j=new jwindow(x,y,l,h,fields,Name),*k; 278 j-> property.hidden=0;276 j->show(); 279 277 if (!first) 280 278 first=j; … … 310 308 311 309 for (p=first;p;p=p->next) 312 if (!p-> property.hidden)310 if (!p->is_hidden()) 313 311 screen->delete_dirty(p->x,p->y,p->x+p->l-1,p->y+p->h-1); 314 312 update_dirty(screen); … … 320 318 for (p=first;p;p=p->next) 321 319 { 322 if (!p-> property.hidden)320 if (!p->is_hidden()) 323 321 { 324 322 if (has_mouse()) … … 334 332 // screen->delete_dirty(p->x,p->y,p->x+p->l-1,p->y+p->h-1); 335 333 for (q=p->next;q;q=q->next) 336 if (!q-> property.hidden)334 if (!q->is_hidden()) 337 335 p->screen->delete_dirty(q->x-p->x, 338 336 q->y-p->y, … … 346 344 } 347 345 348 void jwindow::set_moveability(int x)349 {350 property.moveable=x;351 }352 353 346 jwindow::jwindow(int X, int Y, int L, int H, ifield *fields, char const *Name) 354 347 { 355 ifield *i; 356 int x1,y1,x2,y2; 357 l=0; h=0; 358 property.moveable=1; 359 if (fields) 360 for (i=fields;i;i=i->next) 361 { 362 i->area(x1,y1,x2,y2); 363 if ((int)y2>(int)h) 364 h=y2+1; 365 if ((int)x2>(int)l) 366 l=x2+1; 367 } 368 else { l=2; h=2; } 369 370 if (L<=0) { l=l-L; } else l=L+jw_left; 371 if (H<=0) { h=h-H; } else h=H+jw_top; 372 373 if (Y<0) y=yres-h+Y-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM-1; else y=Y; 374 if (X<0) x=xres-l+X-WINDOW_FRAME_LEFT-WINDOW_FRAME_RIGHT-1; else x=X; 375 376 backg=wm->medium_color(); 377 l+=WINDOW_FRAME_RIGHT; h+=WINDOW_FRAME_BOTTOM; 378 // if (!fields) { l+=WINDOW_FRAME_LEFT; h+=WINDOW_FRAME_TOP; } 379 380 if (l<18) l=18; 381 if (h<12) h=12; 382 screen=new image(l,h,NULL,2); 383 l=screen->width(); 384 h=screen->height(); 385 screen->clear(backg); 386 next=NULL; 387 inm=new input_manager(screen,fields); 388 if (Name==NULL) 389 name=strcpy((char *)jmalloc(strlen(" ")+1,"jwindow::window name")," "); 390 else 391 name=strcpy((char *)jmalloc(strlen(Name)+1,"jwindow::window name"),Name); 392 } 393 394 void jwindow::local_close() { ; } 348 ifield *i; 349 int x1, y1, x2, y2; 350 351 l = 0; h = 0; 352 hidden = false; 353 moveable = true; 354 if(fields) 355 for(i = fields; i; i = i->next) 356 { 357 i->area(x1, y1, x2, y2); 358 if ((int)y2 > (int)h) 359 h = y2 + 1; 360 if ((int)x2 > (int)l) 361 l = x2 + 1; 362 } 363 else 364 { 365 l = 2; 366 h = 2; 367 } 368 369 l = L > 0 ? L + jw_left : l - L; 370 l += WINDOW_FRAME_RIGHT; 371 if(l < 18) 372 l = 18; 373 h = H > 0 ? H + jw_top : h - h; 374 h += WINDOW_FRAME_BOTTOM; 375 if(h < 12) 376 h = 12; 377 //if (!fields) { l+=WINDOW_FRAME_LEFT; h+=WINDOW_FRAME_TOP; } 378 y = Y >= 0 ? Y : yres - h + Y - WINDOW_FRAME_TOP - WINDOW_FRAME_BOTTOM - 1; 379 x = X >= 0 ? X : xres - l + X - WINDOW_FRAME_LEFT - WINDOW_FRAME_RIGHT - 1; 380 381 backg = wm->medium_color(); 382 383 screen=new image(l,h,NULL,2); 384 l = screen->width(); 385 h = screen->height(); 386 screen->clear(backg); 387 next = NULL; 388 inm = new input_manager(screen, fields); 389 if(Name == NULL) 390 name = strcpy((char *)jmalloc(strlen(" ") + 1, "jwindow::window name"), " "); 391 else 392 name = strcpy((char *)jmalloc(strlen(Name) + 1, "jwindow::window name"), Name); 393 } 394 395 void jwindow::local_close() 396 { 397 ; 398 } 395 399 396 400 void jwindow::redraw(int hi, int med, int low, JCFont *fnt) … … 469 473 void input_manager::clear_current() 470 474 { 471 if (active) 472 active->draw(0,screen); 473 474 active=NULL; 475 if(owner) 476 screen = owner->screen; 477 if(active) 478 active->draw(0, screen); 479 active = NULL; 475 480 } 476 481 … … 479 484 ifield *i,*in_area=NULL; 480 485 int x1,y1,x2,y2; 486 487 if(owner) 488 screen = owner->screen; 489 481 490 if (j) 482 491 { … … 551 560 void input_manager::redraw() 552 561 { 553 ifield *i; 554 for (i=first;i;i=i->next) 555 i->draw_first(screen); 556 if (active) 557 active->draw(1,screen); 562 ifield *i; 563 if(owner) 564 screen = owner->screen; 565 for(i = first; i; i = i->next) 566 i->draw_first(screen); 567 if(active) 568 active->draw(1, screen); 558 569 } 559 570 560 571 input_manager::input_manager(image *Screen, ifield *First) 561 572 { 562 no_selections_allowed=0; 563 cur=NULL; 564 grab=NULL; 565 screen=Screen; 566 active=first=First; 567 while (active && !active->selectable()) active=active->next; 568 redraw(); 573 no_selections_allowed = 0; 574 cur = NULL; 575 grab = NULL; 576 owner = NULL; 577 screen = Screen; 578 active = first = First; 579 while(active && !active->selectable()) 580 active = active->next; 581 if(screen) 582 redraw(); 583 } 584 585 input_manager::input_manager(jwindow *Owner, ifield *First) 586 { 587 no_selections_allowed = 0; 588 cur = NULL; 589 grab = NULL; 590 owner = Owner; 591 screen = NULL; 592 active = first = First; 593 while(active && !active->selectable()) 594 active = active->next; 569 595 } 570 596 … … 613 639 } 614 640 615 616 641 ifield::ifield() 642 { 643 owner = NULL; 644 x = 0; 645 y = 0; 646 next = NULL; 647 id = 0; 648 } 649 650 ifield::~ifield() 651 { 652 ; 653 } 654 655 /* re-position the control with respect to the "client" area of the window */ 656 void ifield::set_owner(jwindow * newowner) 657 { 658 if(owner) 659 move(x - owner->x1(), y - owner->y1()); 660 owner = newowner; 661 if(owner) 662 move(x + owner->x1(), y + owner->y1()); 663 } 664 -
abuse/trunk/src/imlib/jwindow.hpp
r106 r109 33 33 #define WINDOW_FRAME_RIGHT frame_right() 34 34 35 36 35 class input_manager 37 36 { 37 friend class jwindow; 38 39 private: 38 40 image *screen; 39 ifield *first, *active,*grab;40 jwindow *cur ;41 ifield *first, *active, *grab; 42 jwindow *cur, *owner; 41 43 int no_selections_allowed; 42 public : 44 45 public: 43 46 input_manager(image *Screen, ifield *First); 47 input_manager(jwindow *owner, ifield *First); 44 48 void handle_event(event &ev, jwindow *j); 45 49 ifield *get(int id); … … 58 62 class ifield 59 63 { 64 friend class jwindow; 65 friend class input_manager; 66 67 protected: 68 jwindow *owner; 69 60 70 public : 61 int x,y; 71 ifield(); 72 int x, y; 62 73 63 int id; 64 ifield *next; 65 virtual void area(int &x1, int &y1, int &x2, int &y2) = 0; 66 virtual void draw_first(image *screen) = 0; 67 virtual void draw(int active, image *screen) = 0; 68 virtual void handle_event(event &ev, image *screen, input_manager *im) = 0; 69 virtual int selectable() { return 1; } 70 virtual void remap(filter *f) { ; } 71 virtual char *read() = 0; 72 virtual ifield *find(int search_id) { if (id==search_id) return this; else return NULL; } 73 virtual ifield *unlink(int id) { return NULL; } 74 virtual ~ifield(); 74 int id; 75 ifield *next; 76 virtual void set_owner(jwindow *owner); 77 virtual void move(int newx, int newy) { x = newx; y = newy; } 78 virtual void area(int &x1, int &y1, int &x2, int &y2) = 0; 79 virtual void draw_first(image *screen) = 0; 80 virtual void draw(int active, image *screen) = 0; 81 virtual void handle_event(event &ev, image *screen, input_manager *im) = 0; 82 virtual int selectable() { return 1; } 83 virtual void remap(filter *f) { ; } 84 virtual char *read() = 0; 85 virtual ifield *find(int search_id) { if (id==search_id) return this; else return NULL; } 86 virtual ifield *unlink(int id) { return NULL; } 87 virtual ~ifield(); 75 88 } ; 76 89 77 90 struct jwindow_properties 78 91 { 79 uint8_t moveable, 80 hidden; 81 } ; 82 92 bool moveable, hidden; 93 }; 83 94 84 95 class jwindow 85 96 { 86 public : 87 jwindow_properties property; 88 jwindow *next; 89 char *name; 90 int x,y,l,h,backg; 91 image *screen; 92 input_manager *inm; 93 void *local_info; // pointer to info block for local system (may support windows) 94 jwindow(int X, int Y, int L, int H, ifield *fields, char const *Name=NULL); 95 void redraw(int hi, int med, int low, JCFont *fnt); 96 void resize(int L, int H); 97 void clear(int color=0) { screen->bar(x1(),y1(),x2(),y2(),color); } 98 int x1() { return WINDOW_FRAME_LEFT; } 99 int y1() { return WINDOW_FRAME_TOP; } 100 int x2() { return l-WINDOW_FRAME_RIGHT-1; } 101 int y2() { return h-WINDOW_FRAME_BOTTOM-1; } 102 void clip_in() { screen->set_clip(x1(),y1(),x2(),y2()); } 103 void clip_out() { screen->set_clip(0,0,l-1,h-1); } 104 char *read(int id) { return inm->get(id)->read(); } 105 void local_close(); 106 void set_moveability(int x); 107 ~jwindow() { local_close(); delete screen; delete inm; jfree(name); } 97 friend class input_manager; 98 99 private: 100 bool hidden; 101 bool moveable; 102 103 protected: 104 jwindow *owner; 105 106 public: 107 jwindow *next; 108 char *name; 109 int x, y, l, h, backg; 110 image *screen; 111 input_manager *inm; 112 void *local_info; // pointer to info block for local system (may support windows) 113 jwindow(int X, int Y, int L, int H, ifield *fields, char const *Name = NULL); 114 void redraw(int hi, int med, int low, JCFont *fnt); 115 void resize(int L, int H); 116 void clear(int color = 0) { screen->bar(x1(), y1(), x2(), y2(), color); } 117 void show() { hidden = false; } 118 void hide() { hidden = true; } 119 bool is_hidden() { return hidden; } 120 void freeze() { moveable = false; } 121 void thaw() { moveable = true; } 122 bool is_moveable() { return moveable; } 123 int x1() { return WINDOW_FRAME_LEFT; } 124 int y1() { return WINDOW_FRAME_TOP; } 125 int x2() { return l-WINDOW_FRAME_RIGHT-1; } 126 int y2() { return h-WINDOW_FRAME_BOTTOM-1; } 127 void clip_in() { screen->set_clip(x1(),y1(),x2(),y2()); } 128 void clip_out() { screen->set_clip(0,0,l-1,h-1); } 129 char *read(int id) { return inm->get(id)->read(); } 130 void local_close(); 131 ~jwindow() { local_close(); delete screen; delete inm; jfree(name); } 108 132 } ; 109 133 110 134 class window_manager 111 135 { 112 public : 136 friend class jwindow; 137 138 public: 113 139 event_handler *eh; 114 140 jwindow *first,*grab; -
abuse/trunk/src/imlib/pmenu.cpp
r106 r109 31 31 bar=wm->new_window(X,Y,w-WINDOW_FRAME_LEFT-WINDOW_FRAME_RIGHT, 32 32 h-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM,NULL); 33 bar-> set_moveability(0); // can't drag this window33 bar->freeze(); // can't drag this window 34 34 bar->screen->wiget_bar(0,0,w-1,h-1,wm->bright_color(),wm->medium_color(), 35 35 wm->dark_color()); … … 197 197 w-WINDOW_FRAME_LEFT-WINDOW_FRAME_RIGHT, 198 198 h-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM,NULL); 199 win-> set_moveability(0);199 win->freeze(); 200 200 win->screen->wiget_bar(0,0,w-1,h-1,wm->bright_color(),wm->medium_color(),wm->dark_color()); 201 201
Note: See TracChangeset
for help on using the changeset viewer.