- Timestamp:
- Mar 16, 2008, 2:17:43 AM (15 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/automap.cpp
r106 r111 151 151 void automap::toggle_window() 152 152 { 153 if (automap_window) 154 { 155 wm->close_window(automap_window); 156 automap_window=NULL; 157 } 158 else 159 { 160 old_dx=-1000; // make sure the map gets drawn the first time 161 old_dy=-1000; 162 163 automap_window=wm->new_window(0,0,w*AUTOTILE_WIDTH,h*AUTOTILE_HEIGHT); 164 automap_window->screen->bar(17,1,17+8*6+3,6,wm->medium_color()); 165 wm->font()->put_string(automap_window->screen,20,2,"AUTOMAP"); 166 draw(); 167 } 153 if (automap_window) 154 { 155 wm->close_window(automap_window); 156 automap_window = NULL; 157 } 158 else 159 { 160 old_dx = -1000; // make sure the map gets drawn the first time 161 old_dy = -1000; 162 163 automap_window = wm->new_window(0, 0, w * AUTOTILE_WIDTH, 164 h * AUTOTILE_HEIGHT, NULL, "Map"); 165 automap_window->screen->bar(17, 1, 17 + 8 * 6 + 3, 6, 166 wm->medium_color()); 167 wm->font()->put_string(automap_window->screen, 20, 2, "Automap", 168 wm->dark_color()); 169 draw(); 170 } 168 171 } 169 172 -
abuse/trunk/src/chat.cpp
r106 r111 13 13 #include "dev.hpp" 14 14 15 chat_console *chat = NULL; 16 15 17 chat_console::chat_console(JCFont *font, int width, int height) : 16 18 console(font,width,height<4 ? 4 : height,symbol_str("CHAT")) 17 19 { 18 clear(); 19 cx=0; 20 cy=h-1; 21 lastx=xres/2-screen_w()/2; 22 lasty=yres-screen_h()-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM; 20 hide(); 21 clear(); 22 cx = 0; 23 cy = h - 1; 24 lastx = xres / 2 - screen_w() / 2; 25 lasty = yres - h; 23 26 } 24 25 chat_console *chat=NULL;26 27 27 28 void chat_console::clear() -
abuse/trunk/src/dev.cpp
r107 r111 32 32 #include "compiled.hpp" 33 33 #include "chat.hpp" 34 35 /* FIXME: get rid of this */ 36 #define WINDOW_FRAME_LEFT 0 37 #define WINDOW_FRAME_TOP 0 34 38 35 39 #define make_above_tile(x) ((x)|0x4000) -
abuse/trunk/src/game.cpp
r106 r111 107 107 } 108 108 109 info_field *inf = new info_field(WINDOW_FRAME_LEFT, WINDOW_FRAME_TOP + 110 wm->font()->height() * 2, ID_NULL, 109 info_field *inf = new info_field(0, wm->font()->height() * 2, ID_NULL, 111 110 no_space_msg, NULL); 112 button *b = new button(WINDOW_FRAME_LEFT, WINDOW_FRAME_TOP, 113 ID_QUIT_OK, "Quit", inf); 111 button *b = new button(0, 0, ID_QUIT_OK, "Quit", inf); 114 112 jwindow *no_space = wm->new_window(0, 0, -1, -1, b, "ERROR"); 115 113 … … 471 469 if(y > 0) y = 1; else if(y < 0) y = -1; 472 470 if(but) but = 1; 473 int dx = WINDOW_FRAME_LEFT + 20, dy = WINDOW_FRAME_TOP +5;471 int dx = 20, dy = 5; 474 472 image *jim = cash.img(joy_picts[but * 9+(y + 1)*3 + x + 1]); 475 473 joy_win->screen->bar(dx, dy, dx + jim->width()+6, dy + jim->height()+6, wm->black()); … … 1779 1777 if(!joy_win) 1780 1778 { 1781 int wx = WINDOW_FRAME_LEFT, wy = WINDOW_FRAME_TOP;1782 1783 1779 joy_win = wm->new_window(80, 50, -1, -1, 1784 new button( wx + 70, wy +9, JOY_OK, "OK",1785 new info_field( wx, wy +30, DEV_NULL,1780 new button(70, 9, JOY_OK, "OK", 1781 new info_field(0, 30, DEV_NULL, 1786 1782 " Center joystick and\n" 1787 1783 "press the fire button", NULL)), -
abuse/trunk/src/gamma.cpp
r110 r111 130 130 gray_pal->find_closest(dr_r, dr_g, dr_b)); 131 131 132 int wl = WINDOW_FRAME_LEFT, wh = WINDOW_FRAME_TOP;133 132 int sh = wm->font()->height() + 35; 134 button *but = new button( wl + 5, wh +5 + sh * 3, ID_GAMMA_OK, cash.img(ok_button),135 new info_field( wl + 35, wh +10 + sh * 3, ID_NULL, lang_string("gamma_msg"), 0));136 137 gray_picker *gp = new gray_picker( wl + 2, wh + 5 + sh * 1, ID_GREEN_PICKER, 0, dg / 4, but);133 button *but = new button(5, 5 + sh * 3, ID_GAMMA_OK, cash.img(ok_button), 134 new info_field(35, 10 + sh * 3, ID_NULL, lang_string("gamma_msg"), 0)); 135 136 gray_picker *gp = new gray_picker(2, 5 + sh, ID_GREEN_PICKER, 0, dg / 4, but); 138 137 gp->set_pos(dg / 4); 139 138 -
abuse/trunk/src/imlib/filesel.cpp
r106 r111 121 121 int filename_id) 122 122 { 123 int wl=WINDOW_FRAME_LEFT,wh=WINDOW_FRAME_TOP; 124 int wh2=wh+5+wm->font()->height()+5; 125 int wh3=wh2+wm->font()->height()+12; 123 int wh2 = 5 + wm->font()->height() + 5; 124 int wh3 = wh2 + wm->font()->height() + 12; 126 125 jwindow *j=wm->new_window(0,0,-1,-1, 127 new info_field( wl+5,wh+5,0,prompt,128 new text_field( wl,wh2,filename_id,126 new info_field(5, 5, 0, prompt, 127 new text_field(0, wh2, filename_id, 129 128 ">","****************************************",def, 130 new button( wl+50,wh3,ok_id,ok_name,131 new button( wl+100,wh3,cancel_id,cancel_name,132 new file_picker( wl+15,wh3+wm->font()->height()+10,filename_id,8,129 new button(50, wh3, ok_id, ok_name, 130 new button(100, wh3, cancel_id, cancel_name, 131 new file_picker(15, wh3 + wm->font()->height() + 10, filename_id, 8, 133 132 NULL))))), 134 133 -
abuse/trunk/src/imlib/guistat.cpp
r107 r111 96 96 if (p) wy=p->stat_win->y+p->stat_win->y2()+5; 97 97 98 int mx=WINDOW_FRAME_LEFT,my=WINDOW_FRAME_TOP; 99 first->stat_win=wm->new_window(wx,wy,len3, h1*2+h2,NULL,"status"); 100 wm->font()->put_string(first->stat_win->screen,mx+1,my+1,first->name,wm->black()); 101 wm->font()->put_string(first->stat_win->screen,mx,my,first->name,wm->bright_color()); 98 int mx = first->stat_win->x1() + 1; 99 int my = first->stat_win->y1() + wm->font()->height() / 2; 100 first->stat_win=wm->new_window(wx, wy, len3, h1*2+h2, NULL, "status"); 101 wm->font()->put_string(first->stat_win->screen, mx, my, first->name, wm->black()); 102 wm->font()->put_string(first->stat_win->screen, mx, my, first->name, wm->bright_color()); 102 103 if (first->show) 103 first->show->draw(first->stat_win->screen, (first->stat_win->x2()-first->stat_win->x1())/2-104 first->show->width()/2, my+h1,NULL);104 first->show->draw(first->stat_win->screen, (first->stat_win->x2()-first->stat_win->x1())/2- 105 first->show->width()/2, my+h1, NULL); 105 106 106 107 draw_bar(first,percentage); -
abuse/trunk/src/imlib/jwindow.cpp
r109 r111 18 18 #include "jwindow.hpp" 19 19 20 int jw_left=5,jw_right=5,jw_top=15,jw_bottom=5;20 static int jw_left = 3, jw_right = 3, jw_top = 2, jw_bottom = 3; 21 21 22 22 int frame_top() { return jw_top; } … … 25 25 int frame_right() { return jw_right; } 26 26 27 // 28 // Sets the size of the border around each window 29 // 27 30 void set_frame_size(int x) 28 31 { 29 if (x<1) x=1; 30 jw_left=x; 31 jw_right=x; 32 jw_top=10+x; 33 jw_bottom=x; 32 if(x < 1) 33 x = 1; 34 jw_left = x; 35 jw_right = x; 36 jw_top = 2; 37 jw_bottom = x; 34 38 } 35 39 … … 52 56 void window_manager::close_window(jwindow *j) 53 57 { 54 jwindow *k; 55 if (grab==j) grab=NULL; 56 if (state==dragging && j==drag_window) // close the window we were dragging 57 state=inputing; 58 59 if (j==first) 60 first=first->next; 61 else 62 { 63 for (k=first;k->next!=j;k=k->next) 64 k->screen->add_dirty(j->x-k->x,j->y-k->y, 65 j->x+j->l-1-k->x,j->y+j->h-1-k->y); 66 k->screen->add_dirty(j->x-k->x,j->y-k->y, 67 j->x+j->l-1-k->x,j->y+j->h-1-k->y); 68 k->next=j->next; 69 } 70 screen->add_dirty(j->x,j->y,j->x+j->l-1,j->y+j->h-1); 71 delete j; 58 delete j; 72 59 } 73 60 … … 243 230 j->resize(l,h); 244 231 if (!frame_suppress) 245 j->redraw( hi,med,low,frame_font());232 j->redraw(); 246 233 } 247 234 … … 260 247 int Med, int Low, JCFont *Font) 261 248 { 262 screen=Screen; hi=Hi; low=Low; med=Med; first=NULL; pal=Pal; grab=NULL; 263 bk=pal->find_closest(0,0,0); 264 state=inputing; fnt=Font; wframe_fnt=Font; 265 memset(key_state,0,sizeof(key_state)); 266 eh=new event_handler(screen,pal); 267 frame_suppress=0; 268 } 269 270 jwindow *window_manager::new_window(int x, int y, int l, int h, ifield *fields, char const *Name) 271 { 272 if (x>screen->width()-4) x=screen->width()-25; 273 if (y>screen->height()-4) y=screen->height()-10; 274 275 jwindow *j=new jwindow(x,y,l,h,fields,Name),*k; 276 j->show(); 277 if (!first) 278 first=j; 279 else 280 { 281 k=first; 282 while (k->next) k=k->next; 283 k->next=j; 284 j->next=NULL; 285 } 286 if (!frame_suppress) 287 j->redraw(hi,med,low,frame_font()); 288 return j; 249 wm = this; 250 screen = Screen; 251 hi = Hi; low = Low; med = Med; first = NULL; pal = Pal; grab = NULL; 252 bk = pal->find_closest(0, 0, 0); 253 state = inputing; fnt = Font; wframe_fnt = Font; 254 memset(key_state, 0, sizeof(key_state)); 255 eh = new event_handler(screen, pal); 256 frame_suppress = 0; 257 } 258 259 window_manager::~window_manager() 260 { 261 delete eh; 262 while(first) 263 close_window(first); 264 wm = NULL; 265 } 266 267 void window_manager::add_window(jwindow *win) 268 { 269 if(!first) 270 first = win; 271 else 272 { 273 jwindow *tmp = first; 274 while(tmp->next) 275 tmp = tmp->next; 276 tmp->next = win; 277 win->next = NULL; 278 } 279 } 280 281 void window_manager::remove_window(jwindow *win) 282 { 283 if(grab == win) 284 grab = NULL; 285 286 // close the window we were dragging 287 if(state == dragging && win == drag_window) 288 state = inputing; 289 290 if(first == win) 291 first = first->next; 292 else 293 { 294 jwindow * search; 295 for(search = first; search->next != win; search = search->next) 296 search->screen->add_dirty(win->x - search->x, 297 win->y - search->y, 298 win->x + win->l - 1 - search->x, 299 win->y + win->h - 1 - search->y); 300 search->screen->add_dirty(win->x - search->x, win->y - search->y, 301 win->x + win->l - 1 - search->x, 302 win->y + win->h - 1 - search->y); 303 search->next = win->next; 304 } 305 306 screen->add_dirty(win->x, win->y, win->x + win->l - 1, 307 win->y + win->h - 1); 308 } 309 310 jwindow * window_manager::new_window(int x, int y, int l, int h, 311 ifield * fields, char const *name) 312 { 313 if(x > screen->width () - 4) 314 x = screen->width () - 25; 315 if(y > screen->height () - 4) 316 y = screen->height () - 10; 317 318 jwindow * j = new jwindow (x, y, l, h, fields, name); 319 j->show(); 320 321 return j; 289 322 } 290 323 … … 344 377 } 345 378 346 jwindow::jwindow(int X, int Y, int L, int H, ifield *fields, char const *Name) 347 { 379 jwindow::jwindow() 380 { 381 _x1 = _y1 = _x2 = _y2 = 0; 382 _hidden = true; 383 _moveable = true; 384 // property.flags = JWINDOW_NOAUTOHIDE_FLAG; 385 inm = new input_manager (this, NULL); 386 screen = NULL; 387 _name = NULL; 388 wm->add_window(this); 389 } 390 391 jwindow::jwindow(int X, int Y, int L, int H, ifield *f, char const *name) 392 { 393 l = 0; 394 h = 0; 395 _hidden = false; 396 _moveable = true; 397 398 _x1 = left_border(); 399 _y1 = name ? top_border() : jw_top + 5; 400 401 screen = NULL; 402 inm = new input_manager(screen, f); 403 reconfigure(); /* FIXME: TODO */ 404 405 l = L >= 0 ? L + left_border() : l - L; 406 h = H >= 0 ? H + top_border() : h - H; 407 //if (!f) { l+=WINDOW_FRAME_LEFT; h+=WINDOW_FRAME_TOP; } 408 y = Y >= 0 ? Y : yres - h + Y - top_border() - bottom_border() - 1; 409 x = X >= 0 ? X : xres - l + X - left_border() - right_border() - 1; 410 411 backg = wm->medium_color(); 412 413 _x2 = l - 1; 414 _y2 = h - 1; 415 l += right_border(); 416 h += bottom_border(); 417 418 if(L == -1) 419 if(l < 15 + left_border() + right_border()) 420 l = 15 + left_border() + right_border(); 421 if(H == -1) 422 if(h < top_border() + bottom_border()) 423 h = top_border() + bottom_border(); 424 screen = new image(l, h, NULL, 2); 425 screen->clear(backg); 426 // Keep this from getting destroyed when image list is cleared 427 image_list.unlink(screen); 428 429 inm->screen = screen; 430 next = NULL; 431 432 _name = NULL; 433 if(name) 434 _name = strcpy((char *)jmalloc(strlen(name) + 1, 435 "jwindow::window name"), name); 436 437 wm->add_window(this); 438 if(!wm->frame_suppress) 439 redraw(); 440 } 441 442 jwindow::~jwindow() 443 { 444 wm->remove_window(this); 445 local_close(); 446 delete screen; 447 delete inm; 448 if(_name) 449 jfree(_name); 450 } 451 452 void jwindow::reconfigure() 453 { 454 int x1, y1, x2, y2; 348 455 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) 456 l = 2; 457 h = 2; 458 for(i = inm->first; i; i = i->next) 459 { 460 i->set_owner(this); 461 i->area(x1, y1, x2, y2); 462 if ((int)y2 > (int)h) 463 h = y2; 464 if ((int)x2 > (int)l) 465 l = x2; 466 } 467 } 468 469 void jwindow::local_close() 470 { 471 ; 472 } 473 474 void jwindow::redraw() 475 { 476 int hi = wm->bright_color (); 477 int med = wm->medium_color (); 478 int low = wm->dark_color (); 479 JCFont * fnt = wm->frame_font (); 480 481 if(_name) 482 { 483 if (right_border() >= 1) 356 484 { 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; 485 screen->wiget_bar (0, 0, l - 1, h - 1, hi, med, low); 486 if (right_border() >= 3) 487 screen->wiget_bar (right_border() - 1, top_border() - 1, 488 l - left_border(), h - bottom_border(), low, 489 med, hi); 490 491 else 492 screen->line (left_border() - 1, top_border() - 1, 493 right_border() - 1, top_border() - 1, low); 362 494 } 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 } 399 400 void jwindow::redraw(int hi, int med, int low, JCFont *fnt) 401 { 402 if (jw_right>=3) 403 screen->rectangle(0,0,l-3,h-3,low); 404 if (jw_right>=2) 405 screen->rectangle(1,1,l-2,h-2,med); 406 if (jw_right>=1) 407 screen->rectangle(2,2,l-1,h-1,hi); 408 409 495 screen->rectangle (2, 2, top_border() - 2, top_border() - 3, 496 wm->black ()); 497 screen->wiget_bar (3, 3, top_border() - 3, top_border() - 4, hi, med, low); // draws the 'close' button 498 } 410 499 411 screen->wiget_bar(0,0,l-1,8,hi,med,low); 412 screen->line(1,1,l-2,1,low); 413 screen->line(1,3,l-2,3,low); 414 screen->line(1,5,l-2,5,low); 415 screen->line(1,7,l-2,7,low); 416 417 screen->wiget_bar(4,3,10,5,hi,med,low); 418 screen->rectangle(3,2,11,6,0); 419 420 screen->line(0,8,l-1,8,0); 421 if (jw_right>=1) 422 screen->wiget_bar(0,9,l-1,h-1,hi,med,low); 423 screen->wiget_bar(0,9,l-1,h-1,hi,med,low); 424 if (jw_right>=2) 425 screen->wiget_bar(4,13,l-jw_right,h-jw_right,low,med,hi); 426 427 428 if (name && name[0] && (name[0]!=' ' || name[1])) 429 { 430 short cx1,cy1,cx2,cy2; 431 screen->get_clip(cx1,cy1,cx2,cy2); 432 screen->set_clip(14,1,l-2,WINDOW_FRAME_TOP-4); 433 screen->bar(14,1,14+fnt->width()*strlen(name),15-8,med); 434 fnt->put_string(screen,14,1,name,low); 435 screen->set_clip(cx1,cy1,cx2,cy2); 436 } 437 438 screen->bar(x1(),y1(),x2(),y2(),backg); 439 inm->redraw(); 500 else 501 { 502 if (right_border() >= 1) 503 { 504 screen->wiget_bar (0, 0, l - 1, h - 1, hi, med, low); 505 if (right_border() >= 3) 506 screen->wiget_bar (right_border() - 1, jw_top + 4, 507 l - left_border(), h - bottom_border(), low, 508 med, hi); 509 510 else 511 screen->line (left_border() - 1, jw_top + 4, right_border() - 1, 512 jw_top + 4, low); 513 } 514 screen->rectangle (1, 1, 4, 4, wm->black ()); 515 screen->wiget_bar (2, 2, 3, 3, hi, med, low); // draws the 'close' button 516 } 517 if (_name && _name[0]) 518 { 519 screen->bar (top_border(), 1, 520 top_border() + fnt->width () * strlen (_name) + 1, 521 top_border() - 2, med); 522 fnt->put_string (screen, top_border() + 1, 1, _name, low); 523 } 524 screen->bar (x1 (), y1 (), x2 (), y2 (), backg); // clear 'client' region 525 inm->redraw (); 526 } 527 528 int jwindow::left_border() 529 { 530 return frame_left(); 531 } 532 533 int jwindow::right_border() 534 { 535 return frame_right(); 536 } 537 538 int jwindow::top_border() 539 { 540 return wm->font()->height() + frame_top(); 541 } 542 543 int jwindow::bottom_border() 544 { 545 return frame_bottom(); 440 546 } 441 547 -
abuse/trunk/src/imlib/jwindow.hpp
r109 r111 21 21 class jwindow; 22 22 23 int frame_top();24 int frame_bottom();25 int frame_left();26 int frame_right();23 extern int frame_top(); 24 extern int frame_bottom(); 25 extern int frame_left(); 26 extern int frame_right(); 27 27 28 28 void set_frame_size(int x); 29 30 #define WINDOW_FRAME_TOP frame_top()31 #define WINDOW_FRAME_BOTTOM frame_bottom()32 #define WINDOW_FRAME_LEFT frame_left()33 #define WINDOW_FRAME_RIGHT frame_right()34 29 35 30 class input_manager … … 88 83 } ; 89 84 90 struct jwindow_properties91 {92 bool moveable, hidden;93 };94 95 85 class jwindow 96 86 { … … 98 88 99 89 private: 100 bool hidden; 101 bool moveable; 90 char *_name; 91 bool _hidden; 92 bool _moveable; 93 94 void reconfigure(); 102 95 103 96 protected: 104 97 jwindow *owner; 98 int _x1, _y1, _x2, _y2; 105 99 106 100 public: 107 101 jwindow *next; 108 char *name;109 102 int x, y, l, h, backg; 110 103 image *screen; 111 104 input_manager *inm; 112 105 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); 106 107 jwindow(); 108 jwindow(int X, int Y, int L, int H, ifield *f, char const *name = NULL); 109 ~jwindow(); 110 111 void redraw(); 115 112 void resize(int L, int H); 116 113 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); }114 void show() { _hidden = false; } 115 void hide() { _hidden = true; } 116 bool is_hidden() { return _hidden; } 117 void freeze() { _moveable = false; } 118 void thaw() { _moveable = true; } 119 bool is_moveable() { return _moveable; } 120 int x1() { return _x1; } 121 int y1() { return _y1; } 122 int x2() { return _x2; } 123 int y2() { return _y2; } 124 void clip_in() { screen->set_clip(x1(), y1(), x2(), y2()); } 125 void clip_out() { screen->set_clip(0, 0, l - 1, h - 1); } 129 126 char *read(int id) { return inm->get(id)->read(); } 130 127 void local_close(); 131 ~jwindow() { local_close(); delete screen; delete inm; jfree(name); } 132 } ; 128 129 static int left_border(); 130 static int right_border(); 131 static int top_border(); 132 static int bottom_border(); 133 }; 133 134 134 135 class window_manager 135 136 { 136 friend class jwindow; 137 friend class jwindow; 138 139 protected: 140 void add_window(jwindow *); 141 void remove_window(jwindow *); 137 142 138 143 public: 139 event_handler *eh;140 jwindow *first,*grab;141 image *screen,*mouse_pic,*mouse_save;142 palette *pal;143 int hi,med,low,bk;// bright, medium, dark and black colors144 int key_state[512];145 enum { inputing,dragging } state;146 int drag_mousex, drag_mousey,frame_suppress;147 jwindow *drag_window;148 JCFont *fnt,*wframe_fnt;144 event_handler *eh; 145 jwindow *first, *grab; 146 image *screen, *mouse_pic, *mouse_save; 147 palette *pal; 148 int hi, med, low, bk; // bright, medium, dark and black colors 149 int key_state[512]; 150 enum { inputing, dragging } state; 151 int drag_mousex, drag_mousey, frame_suppress; 152 jwindow *drag_window; 153 JCFont *fnt, *wframe_fnt; 149 154 150 window_manager(image *Screen, palette *Pal, int Hi, int Med, int Low, JCFont *Font); 155 window_manager(image *, palette *, int hi, int med, int low, JCFont *); 156 ~window_manager(); 151 157 152 jwindow *new_window(int x, int y, int l, int h, ifield *fields=NULL, char const *Name=NULL); 153 void set_frame_font(JCFont *fnt) { wframe_fnt=fnt; } 154 JCFont *frame_font() { return wframe_fnt; } 155 void close_window(jwindow *j); 156 void resize_window(jwindow *j, int l, int h); 157 void move_window(jwindow *j, int x, int y); 158 void get_event(event &ev); 159 void push_event(event *ev) { eh->push_event(ev); } 160 int event_waiting() { return eh->event_waiting(); } 161 void flush_screen(); 162 int bright_color() { return hi; } 163 int medium_color() { return med; } 164 int dark_color() { return low; } 165 int black() { return bk; } 166 void set_colors(int Hi, int Med, int Low) { hi=Hi; med=Med; low=Low; } 167 JCFont *font() { return fnt; } 168 int has_mouse() { return eh->has_mouse(); } 169 void mouse_status(int &x, int &y, int &button) {eh->mouse_status(x,y,button); } 170 void set_mouse_shape(image *im, int centerx, int centery) 171 { eh->set_mouse_shape(im,centerx,centery); } 158 jwindow *new_window(int x, int y, int l, int h, 159 ifield *fields = NULL, char const *Name = NULL); 172 160 173 void set_mouse_position(int mx, int my) 174 { eh->set_mouse_position(mx,my); } 161 void set_frame_font(JCFont *fnt) { wframe_fnt = fnt; } 162 JCFont *frame_font() { return wframe_fnt; } 163 void close_window(jwindow *j); 164 void resize_window(jwindow *j, int l, int h); 165 void move_window(jwindow *j, int x, int y); 166 void get_event(event &ev); 167 void push_event(event *ev) { eh->push_event(ev); } 168 int event_waiting() { return eh->event_waiting(); } 169 void flush_screen(); 170 int bright_color() { return hi; } 171 int medium_color() { return med; } 172 int dark_color() { return low; } 173 int black() { return bk; } 174 void set_colors(int Hi, int Med, int Low) { hi=Hi; med=Med; low=Low; } 175 JCFont *font() { return fnt; } 176 int has_mouse() { return eh->has_mouse(); } 177 void mouse_status(int &x, int &y, int &button) {eh->mouse_status(x,y,button); } 178 void set_mouse_shape(image *im, int centerx, int centery) 179 { eh->set_mouse_shape(im,centerx,centery); } 175 180 176 int key_pressed(int x) { return key_state[x]; } 177 ~window_manager() { delete eh; while (first) close_window(first); } 178 void hide_windows(); 179 void show_windows(); 180 void hide_window(jwindow *j); 181 void show_window(jwindow *j); 182 void set_frame_suppress(int x) { frame_suppress=x; } 183 void grab_focus(jwindow *j); 184 void release_focus(); 185 int window_in_area(int x1, int y1, int x2, int y2); // true if a window lies in this area 186 } ; 181 void set_mouse_position(int mx, int my) 182 { eh->set_mouse_position(mx,my); } 183 184 int key_pressed(int x) { return key_state[x]; } 185 void hide_windows(); 186 void show_windows(); 187 void hide_window(jwindow *j); 188 void show_window(jwindow *j); 189 void set_frame_suppress(int x) { frame_suppress=x; } 190 void grab_focus(jwindow *j); 191 void release_focus(); 192 int window_in_area(int x1, int y1, int x2, int y2); // true if a window lies in this area 193 }; 187 194 188 195 #endif -
abuse/trunk/src/imlib/pmenu.cpp
r109 r111 25 25 screen->get_clip(cx1,cy1,cx2,cy2); 26 26 if (cx1<X) cx1=X; 27 int w=cx2-cx1+1; 28 int h=wm->font()->height()+4; 29 30 31 bar=wm->new_window(X,Y,w-WINDOW_FRAME_LEFT-WINDOW_FRAME_RIGHT, 32 h-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM,NULL); 27 int w = cx2 - cx1 - jwindow::left_border() - jwindow::right_border() + 1; 28 int h = jwindow::top_border() + jwindow::bottom_border(); 29 30 bar=wm->new_window(X, Y, w, 0, NULL); 33 31 bar->freeze(); // can't drag this window 34 32 bar->screen->wiget_bar(0,0,w-1,h-1,wm->bright_color(),wm->medium_color(), … … 195 193 196 194 win=wm->new_window(parent->x+x,parent->y+y, 197 w-WINDOW_FRAME_LEFT-WINDOW_FRAME_RIGHT, 198 h-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM,NULL); 195 w - jwindow::left_border() - jwindow::right_border(), 196 h - jwindow::top_border() - jwindow::bottom_border(), 197 NULL); 199 198 win->freeze(); 200 199 win->screen->wiget_bar(0,0,w-1,h-1,wm->bright_color(),wm->medium_color(),wm->dark_color()); -
abuse/trunk/src/innet.cpp
r106 r111 542 542 543 543 544 jwindow *j=wm->new_window(0,yres/2,-1,-1,new info_field(WINDOW_FRAME_LEFT, 545 WINDOW_FRAME_TOP, 546 0,symbol_str("resync"), 547 new button(WINDOW_FRAME_LEFT, 548 WINDOW_FRAME_TOP+wm->font()->height()+5,ID_NET_DISCONNECT, 544 jwindow *j=wm->new_window(0,yres/2,-1,-1,new info_field(0, 0, 0, symbol_str("resync"), 545 new button(0, wm->font()->height() + 5, ID_NET_DISCONNECT, 549 546 symbol_str("slack"),NULL)),symbol_str("hold!")) 550 547 ; … … 652 649 { 653 650 abort=wm->new_window(0,yres/2,-1,wm->font()->height()*4, 654 new info_field(WINDOW_FRAME_LEFT, 655 WINDOW_FRAME_TOP, 656 0,symbol_str("waiting"), 657 new button(WINDOW_FRAME_LEFT, 658 WINDOW_FRAME_TOP+wm->font()->height()+5,ID_NET_DISCONNECT, 651 new info_field(0, 0, 0, symbol_str("waiting"), 652 new button(0, wm->font()->height() + 5, ID_NET_DISCONNECT, 659 653 symbol_str("slack"),NULL)),symbol_str("Error")); 660 654 wm->flush_screen(); -
abuse/trunk/src/loadgame.cpp
r106 r111 58 58 { 59 59 ico_button *buts[MAX_SAVE_GAMES]; 60 int y =WINDOW_FRAME_TOP,i;60 int y = 0, i; 61 61 int ih=cash.img(save_buts[0])->height(); 62 62 int x=0; … … 64 64 { 65 65 if (thumb_nails) { while (!thumb_nails[x]) x++; } 66 buts[i]=new ico_button( WINDOW_FRAME_LEFT,y,ID_LOAD_GAME_NUMBER+x,66 buts[i]=new ico_button(0, y, ID_LOAD_GAME_NUMBER + x, 67 67 save_buts[x*3+0],save_buts[x*3+0],save_buts[x*3+1],save_buts[x*3+2],NULL); 68 68 buts[i]->set_act_id(ID_LOAD_GAME_PREVIEW+x); … … 73 73 buts[i]->next=buts[i+1]; 74 74 75 return wm->new_window(mx,yres/2-( WINDOW_FRAME_TOP+ih*5)/2,-1,-1,buts[0]);75 return wm->new_window(mx,yres/2-(jwindow::top_border()+ih*5)/2,-1,-1,buts[0]); 76 76 } 77 77 -
abuse/trunk/src/menu.cpp
r106 r111 322 322 volume_window=wm->new_window(prop->getd("volume_x",xres/2-20), 323 323 prop->getd("volume_y",yres/2-50), 324 41-WINDOW_FRAME_LEFT-WINDOW_FRAME_RIGHT-2, 325 101-WINDOW_FRAME_TOP-WINDOW_FRAME_BOTTOM, 324 39, 101, 326 325 new ico_button(10,27,ID_SFX_DOWN,d_u,d_d,d_ua,d_da, 327 326 new ico_button(21,27,ID_SFX_UP,u_u,u_d,u_ua,u_da, -
abuse/trunk/src/net/gserver.cpp
r106 r111 69 69 char msg[100]; 70 70 sprintf(msg,symbol_str("min_wait"),main_net_cfg->min_players-total_players()); 71 stat=wm->new_window(100,50,-1,-1,new info_field(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP,ID_NULL,msg, 72 new button(WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+wm->font()->height()*2, 73 ID_CANCEL,symbol_str("cancel_button"),NULL) )); 71 stat=wm->new_window(100,50,-1,-1,new info_field(0, 0, ID_NULL,msg, 72 new button(0, wm->font()->height()*2, ID_CANCEL,symbol_str("cancel_button"),NULL) )); 74 73 wm->flush_screen(); 75 74 last_count=total_players(); -
abuse/trunk/src/netcfg.cpp
r106 r111 53 53 void net_configuration::cfg_error(char const *msg) 54 54 { 55 jwindow *j=wm->new_window(-1,0,-1,-1,new info_field( WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP,0,msg,56 new button( WINDOW_FRAME_LEFT,WINDOW_FRAME_TOP+30,CFG_ERR_OK,symbol_str("ok_button"),NULL)),symbol_str("input_error"));55 jwindow *j=wm->new_window(-1,0,-1,-1,new info_field(0, 0, 0, msg, 56 new button(0, 30,CFG_ERR_OK,symbol_str("ok_button"),NULL)),symbol_str("input_error")); 57 57 event ev; 58 58 do -
abuse/trunk/src/profile.cpp
r106 r111 119 119 120 120 prof_win->screen->bar(0,prof_win->y1(),prof_win->screen->width()-1,prof_win->screen->height(),0); 121 int dy =WINDOW_FRAME_TOP;121 int dy = 0; 122 122 for (;i<prof_height;i++) 123 123 {
Note: See TracChangeset
for help on using the changeset viewer.