aboutsummaryrefslogtreecommitdiff
path: root/src/Basemenu.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-10-13 22:37:14 (GMT)
committerfluxgen <fluxgen>2002-10-13 22:37:14 (GMT)
commit90efb8d2cf3f8d5e15f99c4c0044126d14a24049 (patch)
tree74e2258e18f3cf52e07309d772cc87433d5e6a54 /src/Basemenu.cc
parent25f7f0034524fea4fbd455b17fef8288ffd0aa54 (diff)
downloadfluxbox_pavel-90efb8d2cf3f8d5e15f99c4c0044126d14a24049.zip
fluxbox_pavel-90efb8d2cf3f8d5e15f99c4c0044126d14a24049.tar.bz2
updated to match new font system
Diffstat (limited to 'src/Basemenu.cc')
-rw-r--r--src/Basemenu.cc109
1 files changed, 33 insertions, 76 deletions
diff --git a/src/Basemenu.cc b/src/Basemenu.cc
index 1d1abc2..2c3cb22 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.30 2002/09/10 10:50:04 fluxgen Exp $ 25// $Id: Basemenu.cc,v 1.31 2002/10/13 22:37:14 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -39,21 +39,17 @@
39#include "Screen.hh" 39#include "Screen.hh"
40#include "StringUtil.hh" 40#include "StringUtil.hh"
41 41
42#ifdef HAVE_STDIO_H 42#include <cstdio>
43# include <stdio.h> 43#include <cstdlib>
44#endif // HAVE_STDIO_H 44#include <cstring>
45 45
46#ifdef STDC_HEADERS
47# include <stdlib.h>
48# include <string.h>
49#endif // STDC_HEADERS
50 46
51#ifdef DEBUG 47#ifdef DEBUG
52#include <iostream> 48#include <iostream>
53using namespace std; 49using namespace std;
54#endif //DEBUG 50#endif //DEBUG
55 51
56static Basemenu *shown = (Basemenu *) 0; 52static Basemenu *shown = 0;
57 53
58Basemenu::Basemenu(BScreen *screen): 54Basemenu::Basemenu(BScreen *screen):
59m_fluxbox(Fluxbox::instance()), 55m_fluxbox(Fluxbox::instance()),
@@ -91,31 +87,15 @@ m_alignment(ALIGNDONTCARE) {
91 87
92 menu.bevel_w = m_screen->getBevelWidth(); 88 menu.bevel_w = m_screen->getBevelWidth();
93 89
94 I18n *i18n = I18n::instance(); 90 menu.width = menu.title_h = menu.item_w = menu.frame_h =
95 91 m_screen->getMenuStyle()->titlefont.height() + menu.bevel_w * 2;
96 if (i18n->multibyte()) { 92
97 menu.width = menu.title_h = menu.item_w = menu.frame_h =
98 m_screen->getMenuStyle()->titlefont.fontSetExtents()->max_ink_extent.height +
99 (menu.bevel_w * 2);
100 } else {
101 menu.width = menu.title_h = menu.item_w = menu.frame_h =
102 m_screen->getMenuStyle()->titlefont.fontStruct()->ascent +
103 m_screen->getMenuStyle()->titlefont.fontStruct()->descent +
104 (menu.bevel_w * 2);
105 }
106
107 menu.sublevels = 93 menu.sublevels =
108 menu.persub = 94 menu.persub =
109 menu.minsub = 0; 95 menu.minsub = 0;
110 96
111 if (i18n->multibyte()) { 97 menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w;
112 menu.item_h = m_screen->getMenuStyle()->framefont.fontSetExtents()->max_ink_extent.height + 98
113 (menu.bevel_w);
114 } else {
115 menu.item_h = m_screen->getMenuStyle()->framefont.fontStruct()->ascent +
116 m_screen->getMenuStyle()->framefont.fontStruct()->descent +
117 (menu.bevel_w);
118 }
119 menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h; 99 menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h;
120 100
121 //set attributes for menu window 101 //set attributes for menu window
@@ -265,20 +245,9 @@ void Basemenu::lower() {
265void Basemenu::update() { 245void Basemenu::update() {
266 I18n *i18n = I18n::instance(); 246 I18n *i18n = I18n::instance();
267 247
268 if (i18n->multibyte()) { 248 menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w;
269 menu.item_h = m_screen->getMenuStyle()->framefont.fontSetExtents()->max_ink_extent.height + 249 menu.title_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w*2;
270 menu.bevel_w; 250
271 menu.title_h = m_screen->getMenuStyle()->titlefont.fontSetExtents()->max_ink_extent.height +
272 (menu.bevel_w * 2);
273 } else {
274 menu.item_h = m_screen->getMenuStyle()->framefont.fontStruct()->ascent +
275 m_screen->getMenuStyle()->framefont.fontStruct()->descent +
276 menu.bevel_w;
277 menu.title_h = m_screen->getMenuStyle()->titlefont.fontStruct()->ascent +
278 m_screen->getMenuStyle()->titlefont.fontStruct()->descent +
279 (menu.bevel_w * 2);
280 }
281
282 if (title_vis) { 251 if (title_vis) {
283 const char *s = (menu.label!="") ? menu.label.c_str() : 252 const char *s = (menu.label!="") ? menu.label.c_str() :
284 i18n->getMessage( 253 i18n->getMessage(
@@ -472,18 +441,14 @@ void Basemenu::move(int x, int y) {
472} 441}
473 442
474 443
475void Basemenu::redrawTitle(void) { 444void Basemenu::redrawTitle() {
476 I18n *i18n = I18n::instance(); 445 I18n *i18n = I18n::instance();
477 const char *text = menu.label.size() ? menu.label.c_str() : 446 const char *text = menu.label.size() ? menu.label.c_str() :
478 i18n->getMessage( 447 i18n->getMessage(
479 FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, 448 FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu,
480 "fluxbox Menu"); 449 "fluxbox Menu");
481 int dx = menu.bevel_w, len = strlen(text); 450 int dx = menu.bevel_w, len = strlen(text);
482 unsigned int l; 451 unsigned int l = m_screen->getMenuStyle()->titlefont.textWidth(text, len) + menu.bevel_w*2;
483
484 l = m_screen->getMenuStyle()->titlefont.textWidth(text, len);
485
486 l += (menu.bevel_w * 2);
487 452
488 switch (m_screen->getMenuStyle()->titlefont_justify) { 453 switch (m_screen->getMenuStyle()->titlefont_justify) {
489 case DrawUtil::Font::RIGHT: 454 case DrawUtil::Font::RIGHT:
@@ -497,15 +462,14 @@ void Basemenu::redrawTitle(void) {
497 break; 462 break;
498 } 463 }
499 464
500 if (i18n->multibyte()) 465 m_screen->getMenuStyle()->titlefont.drawText(
501 XmbDrawString(m_display, menu.title, m_screen->getMenuStyle()->titlefont.fontSet(), 466 menu.title, // drawable
502 m_screen->getMenuStyle()->t_text_gc, dx, menu.bevel_w - 467 m_screen->getScreenNumber(),
503 m_screen->getMenuStyle()->titlefont.fontSetExtents()->max_ink_extent.y, 468 m_screen->getMenuStyle()->t_text_gc, // graphic context
504 text, len); 469 text, len, // text string with lenght
505 else 470 dx, m_screen->getMenuStyle()->titlefont.height() + menu.bevel_w/2); // position
506 XDrawString(m_display, menu.title, m_screen->getMenuStyle()->t_text_gc, dx, 471
507 m_screen->getMenuStyle()->titlefont.fontStruct()->ascent + menu.bevel_w, 472
508 text, len);
509} 473}
510 474
511 475
@@ -646,19 +610,10 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
646 unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0; 610 unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0;
647 unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4; 611 unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4;
648 612
649 I18n *i18n = I18n::instance();
650
651 if (text) { 613 if (text) {
652 text_w = m_screen->getMenuStyle()->framefont.textWidth(text, len); 614 text_w = m_screen->getMenuStyle()->framefont.textWidth(text, len);
653 615
654 if (FbTk::Font::multibyte()) { 616 text_y = item_y + menu.bevel_w/4 + m_screen->getMenuStyle()->framefont.height();
655 text_y = item_y + (menu.bevel_w / 2) -
656 m_screen->getMenuStyle()->framefont.fontSetExtents()->max_ink_extent.y;
657 } else {
658 text_y = item_y +
659 m_screen->getMenuStyle()->framefont.fontStruct()->ascent +
660 (menu.bevel_w / 2);
661 }
662 617
663 switch(m_screen->getMenuStyle()->framefont_justify) { 618 switch(m_screen->getMenuStyle()->framefont_justify) {
664 case DrawUtil::Font::LEFT: 619 case DrawUtil::Font::LEFT:
@@ -748,11 +703,13 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
748 } 703 }
749 704
750 if (dotext && text) { 705 if (dotext && text) {
751 if (i18n->multibyte()) { 706 m_screen->getMenuStyle()->framefont.drawText(
752 XmbDrawString(m_display, menu.frame, m_screen->getMenuStyle()->framefont.fontSet(), 707 menu.frame, // drawable
753 tgc, text_x, text_y, text, len); 708 m_screen->getScreenNumber(),
754 } else 709 tgc,
755 XDrawString(m_display, menu.frame, tgc, text_x, text_y, text, len); 710 text, len, // text string and lenght
711 text_x, text_y); // position
712
756 } 713 }
757 714
758 if (dosel && item->submenu()) { 715 if (dosel && item->submenu()) {