Mercurial > hg > xemacs-beta
comparison src/toolbar-msw.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 501cfd01ee6d |
children | da8ed4261e83 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
44 #define TOOLBAR_ITEM_ID_MAX 0x7FFF | 44 #define TOOLBAR_ITEM_ID_MAX 0x7FFF |
45 #define TOOLBAR_ITEM_ID_BITS(x) (((x) & 0x3FFF) | 0x4000) | 45 #define TOOLBAR_ITEM_ID_BITS(x) (((x) & 0x3FFF) | 0x4000) |
46 #define TOOLBAR_ID_BIAS 16 | 46 #define TOOLBAR_ID_BIAS 16 |
47 #define TOOLBAR_HANDLE(f,p) \ | 47 #define TOOLBAR_HANDLE(f,p) \ |
48 GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + p) | 48 GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + p) |
49 | 49 #ifndef TB_SETIMAGELIST |
50 #define TB_SETIMAGELIST (WM_USER + 48) | |
51 #define TB_GETIMAGELIST (WM_USER + 49) | |
52 #define TB_SETDISABLEDIMAGELIST (WM_USER + 54) | |
53 #define TB_GETDISABLEDIMAGELIST (WM_USER + 55) | |
54 #endif | |
55 #ifndef TB_SETPADDING | |
56 #define TB_SETPADDING (WM_USER + 87) | |
57 #endif | |
50 #define MSWINDOWS_BUTTON_SHADOW_THICKNESS 2 | 58 #define MSWINDOWS_BUTTON_SHADOW_THICKNESS 2 |
51 #define MSWINDOWS_BLANK_SIZE 5 | 59 #define MSWINDOWS_BLANK_SIZE 5 |
52 #define MSWINDOWS_MINIMUM_TOOLBAR_SIZE 8 | 60 #define MSWINDOWS_MINIMUM_TOOLBAR_SIZE 8 |
53 | |
54 static void | |
55 mswindows_move_toolbar (struct frame *f, enum toolbar_pos pos); | |
56 | 61 |
57 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \ | 62 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \ |
58 do { \ | 63 do { \ |
59 switch (pos) \ | 64 switch (pos) \ |
60 { \ | 65 { \ |
121 SendMessage (toolbarwnd, TB_SETIMAGELIST, 0, (LPARAM)NULL); | 126 SendMessage (toolbarwnd, TB_SETIMAGELIST, 0, (LPARAM)NULL); |
122 | 127 |
123 ShowWindow(toolbarwnd, SW_HIDE); | 128 ShowWindow(toolbarwnd, SW_HIDE); |
124 } | 129 } |
125 | 130 |
126 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos) = 0; | 131 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)=0; |
127 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0); | 132 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0); |
128 } | 133 } |
129 | 134 |
130 static void | 135 static void |
131 mswindows_output_toolbar (struct frame *f, enum toolbar_pos pos) | 136 mswindows_output_toolbar (struct frame *f, enum toolbar_pos pos) |
202 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | 207 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); |
203 checksum = HASH5 (checksum, | 208 checksum = HASH5 (checksum, |
204 internal_hash (get_toolbar_button_glyph(w, tb), 0), | 209 internal_hash (get_toolbar_button_glyph(w, tb), 0), |
205 internal_hash (tb->callback, 0), | 210 internal_hash (tb->callback, 0), |
206 width, | 211 width, |
207 LISP_HASH (w->toolbar_buttons_captioned_p)); | 212 w->toolbar_buttons_captioned_p); |
208 button = tb->next; | 213 button = tb->next; |
209 nbuttons++; | 214 nbuttons++; |
210 } | 215 } |
211 | 216 |
212 /* only rebuild if something has changed */ | 217 /* only rebuild if something has changed */ |
213 if (!toolbarwnd || FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)!=checksum) | 218 if (!toolbarwnd || FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)!=checksum) |
214 { | 219 { |
215 /* remove the old one */ | 220 /* remove the old one */ |
216 mswindows_clear_toolbar (f, pos, 0); | 221 mswindows_clear_toolbar (f, pos, 0); |
217 | 222 |
218 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM (f, pos)=checksum; | 223 FRAME_MSWINDOWS_TOOLBAR_CHECKSUM(f,pos)=checksum; |
219 | 224 |
220 /* build up the data required by win32 fns. */ | 225 /* build up the data required by win32 fns. */ |
221 button_tbl = xnew_array_and_zero (TBBUTTON, nbuttons); | 226 button_tbl = xnew_array_and_zero (TBBUTTON, nbuttons); |
222 button = FRAME_TOOLBAR_BUTTONS (f, pos); | 227 button = FRAME_TOOLBAR_BUTTONS (f, pos); |
223 tbbutton = button_tbl; | 228 tbbutton = button_tbl; |
252 else | 257 else |
253 instance = Qnil; | 258 instance = Qnil; |
254 | 259 |
255 if (IMAGE_INSTANCEP (instance)) | 260 if (IMAGE_INSTANCEP (instance)) |
256 { | 261 { |
257 Lisp_Image_Instance* p = XIMAGE_INSTANCE (instance); | 262 struct Lisp_Image_Instance* p = XIMAGE_INSTANCE (instance); |
258 | 263 |
259 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p)) | 264 if (IMAGE_INSTANCE_PIXMAP_TYPE_P (p)) |
260 { | 265 { |
261 /* we are going to honor the toolbar settings | 266 /* we are going to honor the toolbar settings |
262 and resize the bitmaps accordingly if they are | 267 and resize the bitmaps accordingly if they are |
374 && | 379 && |
375 (toolbarwnd = | 380 (toolbarwnd = |
376 CreateWindowEx ( WS_EX_WINDOWEDGE, | 381 CreateWindowEx ( WS_EX_WINDOWEDGE, |
377 TOOLBARCLASSNAME, | 382 TOOLBARCLASSNAME, |
378 NULL, | 383 NULL, |
379 WS_CHILD | 384 WS_CHILD | WS_VISIBLE |
380 | (style_3d ? WS_DLGFRAME : 0) | 385 | (style_3d ? WS_DLGFRAME : 0) |
381 | TBSTYLE_TOOLTIPS | 386 | TBSTYLE_TOOLTIPS | CCS_NORESIZE |
382 | CCS_NORESIZE | 387 | CCS_NOPARENTALIGN | CCS_NODIVIDER, |
383 | CCS_NOPARENTALIGN | CCS_NODIVIDER | |
384 | CCS_ADJUSTABLE, | |
385 x, y, bar_width, bar_height, | 388 x, y, bar_width, bar_height, |
386 FRAME_MSWINDOWS_HANDLE (f), | 389 FRAME_MSWINDOWS_HANDLE (f), |
387 (HMENU)(TOOLBAR_ID_BIAS + pos), | 390 (HMENU)(TOOLBAR_ID_BIAS + pos), |
388 NULL, | 391 NULL, |
389 NULL))==NULL) | 392 NULL))==NULL) |
455 error ("couldn't add image list to toolbar"); | 458 error ("couldn't add image list to toolbar"); |
456 } | 459 } |
457 | 460 |
458 /* now display the window */ | 461 /* now display the window */ |
459 ShowWindow (toolbarwnd, SW_SHOW); | 462 ShowWindow (toolbarwnd, SW_SHOW); |
460 /* no idea why this is necessary but initial display will not | |
461 happen otherwise. */ | |
462 mswindows_move_toolbar (f, pos); | |
463 | 463 |
464 if (button_tbl) xfree (button_tbl); | 464 if (button_tbl) xfree (button_tbl); |
465 | 465 |
466 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1); | 466 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1); |
467 } | 467 } |
523 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f)) | 523 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f)) |
524 mswindows_move_toolbar (f, RIGHT_TOOLBAR); | 524 mswindows_move_toolbar (f, RIGHT_TOOLBAR); |
525 } | 525 } |
526 | 526 |
527 static void | 527 static void |
528 mswindows_redraw_frame_toolbars (struct frame *f) | |
529 { | |
530 mswindows_redraw_exposed_toolbars (f, 0, 0, FRAME_PIXWIDTH (f), | |
531 FRAME_PIXHEIGHT (f)); | |
532 } | |
533 | |
534 static void | |
535 mswindows_initialize_frame_toolbars (struct frame *f) | 528 mswindows_initialize_frame_toolbars (struct frame *f) |
536 { | 529 { |
537 | 530 |
538 } | 531 } |
539 | 532 |
565 | 558 |
566 static void | 559 static void |
567 mswindows_free_frame_toolbars (struct frame *f) | 560 mswindows_free_frame_toolbars (struct frame *f) |
568 { | 561 { |
569 HWND twnd=NULL; | 562 HWND twnd=NULL; |
570 #define DELETE_TOOLBAR(pos) \ | 563 #define DELETE_TOOLBAR(pos) \ |
571 mswindows_clear_toolbar(f, pos, 0); \ | 564 mswindows_clear_toolbar(f, 0, pos); \ |
572 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), \ | 565 if ((twnd=GetDlgItem(FRAME_MSWINDOWS_HANDLE(f), TOOLBAR_ID_BIAS + pos))) \ |
573 TOOLBAR_ID_BIAS + pos))) \ | |
574 DestroyWindow(twnd) | 566 DestroyWindow(twnd) |
575 | 567 |
576 DELETE_TOOLBAR(TOP_TOOLBAR); | 568 DELETE_TOOLBAR(TOP_TOOLBAR); |
577 DELETE_TOOLBAR(BOTTOM_TOOLBAR); | 569 DELETE_TOOLBAR(BOTTOM_TOOLBAR); |
578 DELETE_TOOLBAR(LEFT_TOOLBAR); | 570 DELETE_TOOLBAR(LEFT_TOOLBAR); |
579 DELETE_TOOLBAR(RIGHT_TOOLBAR); | 571 DELETE_TOOLBAR(RIGHT_TOOLBAR); |
580 #undef DELETE_TOOLBAR | 572 #undef DELETE_TOOLBAR |
581 } | 573 } |
582 | 574 |
583 /* map toolbar hwnd to pos*/ | 575 /* map toolbar hwnd to pos*/ |
584 static int mswindows_find_toolbar_pos(struct frame* f, HWND ctrl) | 576 int mswindows_find_toolbar_pos(struct frame* f, HWND ctrl) |
585 { | 577 { |
586 int id = GetDlgCtrlID(ctrl); | 578 int id = GetDlgCtrlID(ctrl); |
587 return id ? id - TOOLBAR_ID_BIAS : -1; | 579 return id ? id - TOOLBAR_ID_BIAS : -1; |
588 } | 580 } |
589 | 581 |
642 { | 634 { |
643 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars); | 635 CONSOLE_HAS_METHOD (mswindows, output_frame_toolbars); |
644 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars); | 636 CONSOLE_HAS_METHOD (mswindows, initialize_frame_toolbars); |
645 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars); | 637 CONSOLE_HAS_METHOD (mswindows, free_frame_toolbars); |
646 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars); | 638 CONSOLE_HAS_METHOD (mswindows, redraw_exposed_toolbars); |
647 CONSOLE_HAS_METHOD (mswindows, redraw_frame_toolbars); | 639 } |
648 } | 640 |
649 |