diff options
Diffstat (limited to 'src/Basemenu.cc')
-rw-r--r-- | src/Basemenu.cc | 88 |
1 files changed, 41 insertions, 47 deletions
diff --git a/src/Basemenu.cc b/src/Basemenu.cc index 559bb97..f78b47e 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Basemenu.cc,v 1.13 2002/03/20 14:10:03 fluxgen Exp $ | 25 | // $Id: Basemenu.cc,v 1.14 2002/03/21 10:54:29 fluxgen Exp $ |
26 | 26 | ||
27 | // stupid macros needed to access some functions in version 2 of the GNU C | 27 | // stupid macros needed to access some functions in version 2 of the GNU C |
28 | // library | 28 | // library |
@@ -49,7 +49,10 @@ | |||
49 | # include <string.h> | 49 | # include <string.h> |
50 | #endif // STDC_HEADERS | 50 | #endif // STDC_HEADERS |
51 | 51 | ||
52 | #ifdef DEBUG | ||
52 | #include <iostream> | 53 | #include <iostream> |
54 | using namespace std; | ||
55 | #endif //DEBUG | ||
53 | 56 | ||
54 | static Basemenu *shown = (Basemenu *) 0; | 57 | static Basemenu *shown = (Basemenu *) 0; |
55 | 58 | ||
@@ -93,12 +96,12 @@ Basemenu::Basemenu(BScreen *scrn) { | |||
93 | 96 | ||
94 | if (i18n->multibyte()) { | 97 | if (i18n->multibyte()) { |
95 | menu.width = menu.title_h = menu.item_w = menu.frame_h = | 98 | menu.width = menu.title_h = menu.item_w = menu.frame_h = |
96 | screen->getMenuStyle()->titlefont.set_extents->max_ink_extent.height + | 99 | screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height + |
97 | (menu.bevel_w * 2); | 100 | (menu.bevel_w * 2); |
98 | } else { | 101 | } else { |
99 | menu.width = menu.title_h = menu.item_w = menu.frame_h = | 102 | menu.width = menu.title_h = menu.item_w = menu.frame_h = |
100 | screen->getMenuStyle()->titlefont.fontstruct->ascent + | 103 | screen->getMenuStyle()->titlefont->getFontStruct()->ascent + |
101 | screen->getMenuStyle()->titlefont.fontstruct->descent + | 104 | screen->getMenuStyle()->titlefont->getFontStruct()->descent + |
102 | (menu.bevel_w * 2); | 105 | (menu.bevel_w * 2); |
103 | } | 106 | } |
104 | menu.label = 0; | 107 | menu.label = 0; |
@@ -108,11 +111,11 @@ Basemenu::Basemenu(BScreen *scrn) { | |||
108 | menu.minsub = 0; | 111 | menu.minsub = 0; |
109 | 112 | ||
110 | if (i18n->multibyte()) { | 113 | if (i18n->multibyte()) { |
111 | menu.item_h = screen->getMenuStyle()->framefont.set_extents->max_ink_extent.height + | 114 | menu.item_h = screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height + |
112 | (menu.bevel_w); | 115 | (menu.bevel_w); |
113 | } else { | 116 | } else { |
114 | menu.item_h = screen->getMenuStyle()->framefont.fontstruct->ascent + | 117 | menu.item_h = screen->getMenuStyle()->framefont->getFontStruct()->ascent + |
115 | screen->getMenuStyle()->framefont.fontstruct->descent + | 118 | screen->getMenuStyle()->framefont->getFontStruct()->descent + |
116 | (menu.bevel_w); | 119 | (menu.bevel_w); |
117 | } | 120 | } |
118 | menu.height = menu.title_h + screen->getBorderWidth() + menu.frame_h; | 121 | menu.height = menu.title_h + screen->getBorderWidth() + menu.frame_h; |
@@ -277,37 +280,33 @@ void Basemenu::update(void) { | |||
277 | I18n *i18n = I18n::instance(); | 280 | I18n *i18n = I18n::instance(); |
278 | 281 | ||
279 | if (i18n->multibyte()) { | 282 | if (i18n->multibyte()) { |
280 | menu.item_h = screen->getMenuStyle()->framefont.set_extents->max_ink_extent.height + | 283 | menu.item_h = screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height + |
281 | menu.bevel_w; | 284 | menu.bevel_w; |
282 | menu.title_h = screen->getMenuStyle()->titlefont.set_extents->max_ink_extent.height + | 285 | menu.title_h = screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height + |
283 | (menu.bevel_w * 2); | 286 | (menu.bevel_w * 2); |
284 | } else { | 287 | } else { |
285 | menu.item_h = screen->getMenuStyle()->framefont.fontstruct->ascent + | 288 | menu.item_h = screen->getMenuStyle()->framefont->getFontStruct()->ascent + |
286 | screen->getMenuStyle()->framefont.fontstruct->descent + | 289 | screen->getMenuStyle()->framefont->getFontStruct()->descent + |
287 | menu.bevel_w; | 290 | menu.bevel_w; |
288 | menu.title_h = screen->getMenuStyle()->titlefont.fontstruct->ascent + | 291 | menu.title_h = screen->getMenuStyle()->titlefont->getFontStruct()->ascent + |
289 | screen->getMenuStyle()->titlefont.fontstruct->descent + | 292 | screen->getMenuStyle()->titlefont->getFontStruct()->descent + |
290 | (menu.bevel_w * 2); | 293 | (menu.bevel_w * 2); |
291 | } | 294 | } |
292 | 295 | ||
293 | if (title_vis) { | 296 | if (title_vis) { |
294 | const char *s = (menu.label) ? menu.label : | 297 | const char *s = (menu.label) ? menu.label : |
295 | i18n->getMessage( | 298 | i18n->getMessage( |
296 | #ifdef NLS | 299 | BasemenuSet, BasemenuBlackboxMenu, |
297 | BasemenuSet, BasemenuBlackboxMenu, | 300 | "fluxbox Menu"); |
298 | #else // !NLS | ||
299 | 0, 0, | ||
300 | #endif // NLS | ||
301 | "fluxbox Menu"); | ||
302 | int l = strlen(s); | 301 | int l = strlen(s); |
303 | 302 | ||
304 | 303 | ||
305 | if (i18n->multibyte()) { | 304 | if (i18n->multibyte()) { |
306 | XRectangle ink, logical; | 305 | XRectangle ink, logical; |
307 | XmbTextExtents(screen->getMenuStyle()->titlefont.set, s, l, &ink, &logical); | 306 | XmbTextExtents(screen->getMenuStyle()->titlefont->getFontSet(), s, l, &ink, &logical); |
308 | menu.item_w = logical.width; | 307 | menu.item_w = logical.width; |
309 | } else | 308 | } else |
310 | menu.item_w = XTextWidth(screen->getMenuStyle()->titlefont.fontstruct, s, l); | 309 | menu.item_w = XTextWidth(screen->getMenuStyle()->titlefont->getFontStruct(), s, l); |
311 | 310 | ||
312 | menu.item_w += (menu.bevel_w * 2); | 311 | menu.item_w += (menu.bevel_w * 2); |
313 | } else | 312 | } else |
@@ -324,10 +323,10 @@ void Basemenu::update(void) { | |||
324 | 323 | ||
325 | if (i18n->multibyte()) { | 324 | if (i18n->multibyte()) { |
326 | XRectangle ink, logical; | 325 | XRectangle ink, logical; |
327 | XmbTextExtents(screen->getMenuStyle()->framefont.set, s, l, &ink, &logical); | 326 | XmbTextExtents(screen->getMenuStyle()->framefont->getFontSet(), s, l, &ink, &logical); |
328 | ii = logical.width; | 327 | ii = logical.width; |
329 | } else | 328 | } else |
330 | ii = XTextWidth(screen->getMenuStyle()->framefont.fontstruct, s, l); | 329 | ii = XTextWidth(screen->getMenuStyle()->framefont->getFontStruct(), s, l); |
331 | 330 | ||
332 | ii += (menu.bevel_w * 2) + (menu.item_h * 2); | 331 | ii += (menu.bevel_w * 2) + (menu.item_h * 2); |
333 | 332 | ||
@@ -509,16 +508,12 @@ void Basemenu::redrawTitle(void) { | |||
509 | int dx = menu.bevel_w, len = strlen(text); | 508 | int dx = menu.bevel_w, len = strlen(text); |
510 | unsigned int l; | 509 | unsigned int l; |
511 | 510 | ||
512 | if (i18n->multibyte()) { | 511 | l = screen->getMenuStyle()->titlefont->getTextWidth(text, len); |
513 | XRectangle ink, logical; | ||
514 | XmbTextExtents(screen->getMenuStyle()->titlefont.set, text, len, &ink, &logical); | ||
515 | l = logical.width; | ||
516 | } else | ||
517 | l = XTextWidth(screen->getMenuStyle()->titlefont.fontstruct, text, len); | ||
518 | 512 | ||
519 | l += (menu.bevel_w * 2); | 513 | l += (menu.bevel_w * 2); |
520 | 514 | ||
521 | switch (screen->getMenuStyle()->titlefont.justify) { | 515 | //titlefont.justify |
516 | switch (screen->getMenuStyle()->titlefont_justify) { | ||
522 | case DrawUtil::Font::RIGHT: | 517 | case DrawUtil::Font::RIGHT: |
523 | dx += menu.width - l; | 518 | dx += menu.width - l; |
524 | break; | 519 | break; |
@@ -531,13 +526,13 @@ void Basemenu::redrawTitle(void) { | |||
531 | } | 526 | } |
532 | 527 | ||
533 | if (i18n->multibyte()) | 528 | if (i18n->multibyte()) |
534 | XmbDrawString(display, menu.title, screen->getMenuStyle()->titlefont.set, | 529 | XmbDrawString(display, menu.title, screen->getMenuStyle()->titlefont->getFontSet(), |
535 | screen->getMenuStyle()->t_text_gc, dx, menu.bevel_w - | 530 | screen->getMenuStyle()->t_text_gc, dx, menu.bevel_w - |
536 | screen->getMenuStyle()->titlefont.set_extents->max_ink_extent.y, | 531 | screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.y, |
537 | text, len); | 532 | text, len); |
538 | else | 533 | else |
539 | XDrawString(display, menu.title, screen->getMenuStyle()->t_text_gc, dx, | 534 | XDrawString(display, menu.title, screen->getMenuStyle()->t_text_gc, dx, |
540 | screen->getMenuStyle()->titlefont.fontstruct->ascent + menu.bevel_w, | 535 | screen->getMenuStyle()->titlefont->getFontStruct()->ascent + menu.bevel_w, |
541 | text, len); | 536 | text, len); |
542 | } | 537 | } |
543 | 538 | ||
@@ -681,20 +676,19 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, | |||
681 | I18n *i18n = I18n::instance(); | 676 | I18n *i18n = I18n::instance(); |
682 | 677 | ||
683 | if (text) { | 678 | if (text) { |
684 | if (i18n->multibyte()) { | 679 | text_w = screen->getMenuStyle()->framefont->getTextWidth(text, len); |
685 | XRectangle ink, logical; | 680 | |
686 | XmbTextExtents(screen->getMenuStyle()->framefont.set, text, len, &ink, &logical); | 681 | if (screen->getMenuStyle()->framefont->multibyte()) { |
687 | text_w = logical.width; | ||
688 | text_y = item_y + (menu.bevel_w / 2) - | 682 | text_y = item_y + (menu.bevel_w / 2) - |
689 | screen->getMenuStyle()->framefont.set_extents->max_ink_extent.y; | 683 | screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.y; |
690 | } else { | 684 | } else { |
691 | text_w = XTextWidth(screen->getMenuStyle()->framefont.fontstruct, text, len); | 685 | text_y = item_y + |
692 | text_y = item_y + | 686 | screen->getMenuStyle()->framefont->getFontStruct()->ascent + |
693 | screen->getMenuStyle()->framefont.fontstruct->ascent + | ||
694 | (menu.bevel_w / 2); | 687 | (menu.bevel_w / 2); |
695 | } | 688 | } |
696 | 689 | ||
697 | switch(screen->getMenuStyle()->framefont.justify) { | 690 | // framfont.justify |
691 | switch(screen->getMenuStyle()->framefont_justify) { | ||
698 | case DrawUtil::Font::LEFT: | 692 | case DrawUtil::Font::LEFT: |
699 | text_x = item_x + menu.bevel_w + menu.item_h + 1; | 693 | text_x = item_x + menu.bevel_w + menu.item_h + 1; |
700 | break; | 694 | break; |
@@ -706,7 +700,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, | |||
706 | text_x = item_x + ((menu.item_w + 1 - text_w) / 2); | 700 | text_x = item_x + ((menu.item_w + 1 - text_w) / 2); |
707 | break; | 701 | break; |
708 | } | 702 | } |
709 | 703 | ||
710 | text_h = menu.item_h - menu.bevel_w; | 704 | text_h = menu.item_h - menu.bevel_w; |
711 | } | 705 | } |
712 | 706 | ||
@@ -781,7 +775,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, | |||
781 | 775 | ||
782 | if (dotext && text) { | 776 | if (dotext && text) { |
783 | if (i18n->multibyte()) { | 777 | if (i18n->multibyte()) { |
784 | XmbDrawString(display, menu.frame, screen->getMenuStyle()->framefont.set, | 778 | XmbDrawString(display, menu.frame, screen->getMenuStyle()->framefont->getFontSet(), |
785 | tgc, text_x, text_y, text, len); | 779 | tgc, text_x, text_y, text, len); |
786 | } else | 780 | } else |
787 | XDrawString(display, menu.frame, tgc, text_x, text_y, text, len); | 781 | XDrawString(display, menu.frame, tgc, text_x, text_y, text, len); |