aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Basemenu.cc109
-rw-r--r--src/Theme.hh37
2 files changed, 42 insertions, 104 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()) {
diff --git a/src/Theme.hh b/src/Theme.hh
index bf3ccd4..f48b8c0 100644
--- a/src/Theme.hh
+++ b/src/Theme.hh
@@ -1,6 +1,9 @@
1// Theme.hh for fluxbox 1// Theme.hh for fluxbox
2// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3// 3//
4// A lot of the base code is taken from Screen.hh in Blackbox 0.61.1
5// Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6//
4// Permission is hereby granted, free of charge, to any person obtaining a 7// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 8// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 9// to deal in the Software without restriction, including without limitation
@@ -13,34 +16,13 @@
13// 16//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// 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
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21//
22// A lot of the base code is taken from Screen.hh in Blackbox 0.61.1
23// Screen.cc - Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
24//
25// Permission is hereby granted, free of charge, to any person obtaining a
26// copy of this software and associated documentation files (the "Software"),
27// to deal in the Software without restriction, including without limitation
28// the rights to use, copy, modify, merge, publish, distribute, sublicense,
29// and/or sell copies of the Software, and to permit persons to whom the
30// Software is furnished to do so, subject to the following conditions:
31//
32// The above copyright notice and this permission notice shall be included in
33// all copies or substantial portions of the Software.
34//
35// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
40// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
41// DEALINGS IN THE SOFTWARE.
42 24
43// $Id: Theme.hh,v 1.13 2002/08/04 15:55:13 fluxgen Exp $ 25// $Id: Theme.hh,v 1.14 2002/10/13 22:34:03 fluxgen Exp $
44 26
45#ifndef THEME_HH 27#ifndef THEME_HH
46#define THEME_HH 28#define THEME_HH
@@ -57,8 +39,7 @@
57 Main theme class, holds themes for 39 Main theme class, holds themes for
58 Window, toolbar, slit, menu and the rootCommand, for a specific screen. 40 Window, toolbar, slit, menu and the rootCommand, for a specific screen.
59*/ 41*/
60class Theme 42class Theme {
61{
62public: 43public:
63 44
64 Theme(Display *display, Window rootwindow, Colormap colormap, 45 Theme(Display *display, Window rootwindow, Colormap colormap,
@@ -67,8 +48,8 @@ public:
67 48
68 49
69 typedef struct MenuStyle { 50 typedef struct MenuStyle {
70 MenuStyle(Display *display):titlefont(display, "fixed"), 51 MenuStyle():titlefont("fixed"),
71 framefont(display, "fixed") { } 52 framefont("fixed") { }
72 FbTk::Color t_text, f_text, h_text, d_text; 53 FbTk::Color t_text, f_text, h_text, d_text;
73 FbTk::Texture title, frame, hilite; 54 FbTk::Texture title, frame, hilite;
74 GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; 55 GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
@@ -142,7 +123,7 @@ private:
142 void freeWindowStyle(); 123 void freeWindowStyle();
143 void freeTabStyle(); 124 void freeTabStyle();
144 void freeToolbarStyle(); 125 void freeToolbarStyle();
145 126 void loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname);
146 bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long); 127 bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long);
147 bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long); 128 bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long);
148 129