diff options
author | fluxgen <fluxgen> | 2002-10-15 17:17:00 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-10-15 17:17:00 (GMT) |
commit | 3e972e83bd2716f7e5941f4ef8edcb67f4f2a3b5 (patch) | |
tree | 570346082cf5339b76767e62d205ab980245064b /src/Theme.cc | |
parent | 715f363016995cbe188e7c47d9c389c8581b9fb1 (diff) | |
download | fluxbox-3e972e83bd2716f7e5941f4ef8edcb67f4f2a3b5.zip fluxbox-3e972e83bd2716f7e5941f4ef8edcb67f4f2a3b5.tar.bz2 |
using new font system for labelstyle, windowstyle
Diffstat (limited to 'src/Theme.cc')
-rw-r--r-- | src/Theme.cc | 101 |
1 files changed, 25 insertions, 76 deletions
diff --git a/src/Theme.cc b/src/Theme.cc index be660d6..a6ea86c 100644 --- a/src/Theme.cc +++ b/src/Theme.cc | |||
@@ -21,7 +21,7 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: Theme.cc,v 1.30 2002/10/15 10:53:01 fluxgen Exp $ | 24 | // $Id: Theme.cc,v 1.31 2002/10/15 17:08:45 fluxgen Exp $ |
25 | 25 | ||
26 | #ifndef _GNU_SOURCE | 26 | #ifndef _GNU_SOURCE |
27 | #define _GNU_SOURCE | 27 | #define _GNU_SOURCE |
@@ -62,10 +62,8 @@ m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointe | |||
62 | #endif //DEBUG | 62 | #endif //DEBUG |
63 | //default settings | 63 | //default settings |
64 | 64 | ||
65 | m_windowstyle.font.set = m_toolbarstyle.font.set = m_windowstyle.tab.font.set = 0; | 65 | m_toolbarstyle.font.set = 0; |
66 | 66 | m_toolbarstyle.font.fontstruct = 0; | |
67 | m_toolbarstyle.font.fontstruct = m_windowstyle.font.fontstruct = m_windowstyle.tab.font.fontstruct = 0; | ||
68 | m_windowstyle.tab.rot_font = 0; | ||
69 | 67 | ||
70 | load(filename); | 68 | load(filename); |
71 | //-------- create gc for the styles ------------ | 69 | //-------- create gc for the styles ------------ |
@@ -74,9 +72,6 @@ m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointe | |||
74 | XGCValues gcv; | 72 | XGCValues gcv; |
75 | unsigned long gc_value_mask = GCForeground; | 73 | unsigned long gc_value_mask = GCForeground; |
76 | 74 | ||
77 | if (! I18n::instance()->multibyte()) | ||
78 | gc_value_mask |= GCFont; | ||
79 | |||
80 | gcv.foreground = WhitePixel(m_display, screennum)^BlackPixel(m_display, screennum); | 75 | gcv.foreground = WhitePixel(m_display, screennum)^BlackPixel(m_display, screennum); |
81 | gcv.function = GXxor; | 76 | gcv.function = GXxor; |
82 | gcv.subwindow_mode = IncludeInferiors; | 77 | gcv.subwindow_mode = IncludeInferiors; |
@@ -84,24 +79,17 @@ m_rootcommand(rootcommand==0 ? "" : rootcommand) //we dont want to send 0-pointe | |||
84 | GCForeground | GCFunction | GCSubwindowMode, &gcv); | 79 | GCForeground | GCFunction | GCSubwindowMode, &gcv); |
85 | 80 | ||
86 | gcv.foreground = m_windowstyle.l_text_focus.pixel(); | 81 | gcv.foreground = m_windowstyle.l_text_focus.pixel(); |
87 | if (m_windowstyle.font.fontstruct) | ||
88 | gcv.font = m_windowstyle.font.fontstruct->fid; | ||
89 | |||
90 | m_windowstyle.l_text_focus_gc = | 82 | m_windowstyle.l_text_focus_gc = |
91 | XCreateGC(m_display, rootwindow, | 83 | XCreateGC(m_display, rootwindow, |
92 | gc_value_mask, &gcv); | 84 | gc_value_mask, &gcv); |
93 | 85 | ||
94 | gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); | 86 | gcv.foreground = m_windowstyle.l_text_unfocus.pixel(); |
95 | if (m_windowstyle.font.fontstruct) | ||
96 | gcv.font = m_windowstyle.font.fontstruct->fid; | ||
97 | m_windowstyle.l_text_unfocus_gc = | 87 | m_windowstyle.l_text_unfocus_gc = |
98 | XCreateGC(m_display, rootwindow, | 88 | XCreateGC(m_display, rootwindow, |
99 | gc_value_mask, &gcv); | 89 | gc_value_mask, &gcv); |
100 | 90 | ||
101 | //---- Tab | 91 | //---- Tab |
102 | gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); | 92 | gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); |
103 | if (m_windowstyle.tab.font.fontstruct) | ||
104 | gcv.font = m_windowstyle.tab.font.fontstruct->fid; | ||
105 | 93 | ||
106 | m_windowstyle.tab.l_text_focus_gc = | 94 | m_windowstyle.tab.l_text_focus_gc = |
107 | XCreateGC(m_display, rootwindow, | 95 | XCreateGC(m_display, rootwindow, |
@@ -202,15 +190,8 @@ void Theme::freeMenuStyle() { | |||
202 | 190 | ||
203 | //----- freeWindowStyle ----- | 191 | //----- freeWindowStyle ----- |
204 | // free memory allocated for m_windowstyle | 192 | // free memory allocated for m_windowstyle |
205 | // should only be called from ~Theme | ||
206 | //-------------------- | 193 | //-------------------- |
207 | void Theme::freeWindowStyle() { | 194 | void Theme::freeWindowStyle() { |
208 | if (m_windowstyle.font.set) | ||
209 | XFreeFontSet(m_display, m_windowstyle.font.set); | ||
210 | |||
211 | if (m_windowstyle.font.fontstruct) | ||
212 | XFreeFont(m_display, m_windowstyle.font.fontstruct); | ||
213 | |||
214 | XFreeGC(m_display, m_windowstyle.l_text_focus_gc); | 195 | XFreeGC(m_display, m_windowstyle.l_text_focus_gc); |
215 | XFreeGC(m_display, m_windowstyle.l_text_unfocus_gc); | 196 | XFreeGC(m_display, m_windowstyle.l_text_unfocus_gc); |
216 | XFreeGC(m_display, m_windowstyle.b_pic_focus_gc); | 197 | XFreeGC(m_display, m_windowstyle.b_pic_focus_gc); |
@@ -219,20 +200,8 @@ void Theme::freeWindowStyle() { | |||
219 | 200 | ||
220 | //----- freeTabStyle ----- | 201 | //----- freeTabStyle ----- |
221 | // free memory allocated for m_windowstyle.tab | 202 | // free memory allocated for m_windowstyle.tab |
222 | // should only be called from ~Theme | ||
223 | //-------------------- | 203 | //-------------------- |
224 | void Theme::freeTabStyle() { | 204 | void Theme::freeTabStyle() { |
225 | |||
226 | if (m_windowstyle.tab.font.set) | ||
227 | XFreeFontSet(m_display, m_windowstyle.tab.font.set); | ||
228 | |||
229 | if (m_windowstyle.tab.font.fontstruct) | ||
230 | XFreeFont(m_display, m_windowstyle.tab.font.fontstruct); | ||
231 | |||
232 | if (m_windowstyle.tab.rot_font) | ||
233 | DrawUtil::XRotUnloadFont(m_display, m_windowstyle.tab.rot_font); | ||
234 | |||
235 | |||
236 | XFreeGC(m_display, m_windowstyle.tab.l_text_focus_gc); | 205 | XFreeGC(m_display, m_windowstyle.tab.l_text_focus_gc); |
237 | XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc); | 206 | XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc); |
238 | } | 207 | } |
@@ -445,17 +414,7 @@ void Theme::loadWindowStyle() { | |||
445 | WhitePixel(m_display, m_screennum)); | 414 | WhitePixel(m_display, m_screennum)); |
446 | 415 | ||
447 | //----- font | 416 | //----- font |
448 | 417 | loadFontFromDatabase(m_windowstyle.font, "window.font", "Window.Font"); | |
449 | if (I18n::instance()->multibyte()) { | ||
450 | readDatabaseFontSet("window.font", "Window.Font", | ||
451 | &m_windowstyle.font.set); | ||
452 | |||
453 | m_windowstyle.font.set_extents = | ||
454 | XExtentsOfFontSet(m_windowstyle.font.set); | ||
455 | } else { | ||
456 | readDatabaseFont("window.font", "Window.Font", | ||
457 | &m_windowstyle.font.fontstruct); | ||
458 | } | ||
459 | 418 | ||
460 | XrmValue value; | 419 | XrmValue value; |
461 | char *value_type; | 420 | char *value_type; |
@@ -463,13 +422,13 @@ void Theme::loadWindowStyle() { | |||
463 | if (XrmGetResource(m_database, "window.justify", "Window.Justify", | 422 | if (XrmGetResource(m_database, "window.justify", "Window.Justify", |
464 | &value_type, &value)) { | 423 | &value_type, &value)) { |
465 | if (strstr(value.addr, "right") || strstr(value.addr, "Right")) | 424 | if (strstr(value.addr, "right") || strstr(value.addr, "Right")) |
466 | m_windowstyle.font.justify = DrawUtil::Font::RIGHT; | 425 | m_windowstyle.justify = DrawUtil::Font::RIGHT; |
467 | else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) | 426 | else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) |
468 | m_windowstyle.font.justify = DrawUtil::Font::CENTER; | 427 | m_windowstyle.justify = DrawUtil::Font::CENTER; |
469 | else | 428 | else |
470 | m_windowstyle.font.justify = DrawUtil::Font::LEFT; | 429 | m_windowstyle.justify = DrawUtil::Font::LEFT; |
471 | } else | 430 | } else |
472 | m_windowstyle.font.justify = DrawUtil::Font::LEFT; | 431 | m_windowstyle.justify = DrawUtil::Font::LEFT; |
473 | 432 | ||
474 | } | 433 | } |
475 | 434 | ||
@@ -523,38 +482,29 @@ void Theme::loadTabStyle() { | |||
523 | 482 | ||
524 | m_windowstyle.tab.border_width_2x = m_windowstyle.tab.border_width*2; | 483 | m_windowstyle.tab.border_width_2x = m_windowstyle.tab.border_width*2; |
525 | 484 | ||
526 | //---------- font | 485 | loadFontFromDatabase(m_windowstyle.tab.font, "window.tab.font", "Window.Tab.Font"); |
527 | |||
528 | if (I18n::instance()->multibyte()) { | ||
529 | readDatabaseFontSet("window.tab.font", "Window.Tab.Font", | ||
530 | &m_windowstyle.tab.font.set); | ||
531 | |||
532 | m_windowstyle.tab.font.set_extents = | ||
533 | XExtentsOfFontSet(m_windowstyle.tab.font.set); | ||
534 | } else { | ||
535 | readDatabaseFont("window.tab.font", "Window.Tab.Font", | ||
536 | &m_windowstyle.tab.font.fontstruct); | ||
537 | } | ||
538 | 486 | ||
487 | //TODO: fix rotated font | ||
539 | //--------- rotated font for left and right tabs | 488 | //--------- rotated font for left and right tabs |
540 | // TODO: add extra checking | 489 | // TODO: add extra checking |
541 | if (XrmGetResource(m_database, "window.tab.font", "Window.Tab.Font", | 490 | /*if (XrmGetResource(m_database, "window.tab.font", "Window.Tab.Font", |
542 | &value_type, &value)) { | 491 | &value_type, &value)) { |
543 | if (! (m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, value.addr, 90.0)) ) | 492 | if (! (m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, value.addr, 90.0)) ) |
544 | m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90); | 493 | m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90); |
545 | } else | 494 | } else |
546 | m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90); | 495 | m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90); |
496 | */ | ||
547 | 497 | ||
548 | if (XrmGetResource(m_database, "window.tab.justify", "Window.Tab.Justify", | 498 | if (XrmGetResource(m_database, "window.tab.justify", "Window.Tab.Justify", |
549 | &value_type, &value)) { | 499 | &value_type, &value)) { |
550 | if (strstr(value.addr, "right") || strstr(value.addr, "Right")) | 500 | if (strstr(value.addr, "right") || strstr(value.addr, "Right")) |
551 | m_windowstyle.tab.font.justify = DrawUtil::Font::RIGHT; | 501 | m_windowstyle.tab.justify = DrawUtil::Font::RIGHT; |
552 | else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) | 502 | else if (strstr(value.addr, "center") || strstr(value.addr, "Center")) |
553 | m_windowstyle.tab.font.justify = DrawUtil::Font::CENTER; | 503 | m_windowstyle.tab.justify = DrawUtil::Font::CENTER; |
554 | else | 504 | else |
555 | m_windowstyle.tab.font.justify = DrawUtil::Font::LEFT; | 505 | m_windowstyle.tab.justify = DrawUtil::Font::LEFT; |
556 | } else | 506 | } else |
557 | m_windowstyle.tab.font.justify = DrawUtil::Font::LEFT; | 507 | m_windowstyle.tab.justify = DrawUtil::Font::LEFT; |
558 | 508 | ||
559 | } | 509 | } |
560 | 510 | ||
@@ -920,8 +870,6 @@ void Theme::reconfigure(bool antialias) { | |||
920 | 870 | ||
921 | XGCValues gcv; | 871 | XGCValues gcv; |
922 | unsigned long gc_value_mask = GCForeground; | 872 | unsigned long gc_value_mask = GCForeground; |
923 | if (! I18n::instance()->multibyte()) | ||
924 | gc_value_mask |= GCFont; | ||
925 | 873 | ||
926 | XChangeGC(m_display, m_opgc, | 874 | XChangeGC(m_display, m_opgc, |
927 | GCForeground | GCFunction | GCSubwindowMode, &gcv); | 875 | GCForeground | GCFunction | GCSubwindowMode, &gcv); |
@@ -933,8 +881,8 @@ void Theme::reconfigure(bool antialias) { | |||
933 | GCForeground | GCFunction | GCSubwindowMode, &gcv); | 881 | GCForeground | GCFunction | GCSubwindowMode, &gcv); |
934 | 882 | ||
935 | gcv.foreground = m_windowstyle.l_text_focus.pixel(); | 883 | gcv.foreground = m_windowstyle.l_text_focus.pixel(); |
936 | if (m_windowstyle.font.fontstruct) | 884 | if (m_windowstyle.font.isAntialias() != antialias) |
937 | gcv.font = m_windowstyle.font.fontstruct->fid; | 885 | m_windowstyle.font.setAntialias(antialias); |
938 | 886 | ||
939 | XChangeGC(m_display, m_windowstyle.l_text_focus_gc, | 887 | XChangeGC(m_display, m_windowstyle.l_text_focus_gc, |
940 | gc_value_mask, &gcv); | 888 | gc_value_mask, &gcv); |
@@ -945,9 +893,8 @@ void Theme::reconfigure(bool antialias) { | |||
945 | 893 | ||
946 | //---- Tab | 894 | //---- Tab |
947 | gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); | 895 | gcv.foreground = m_windowstyle.tab.l_text_focus.pixel(); |
948 | if (m_windowstyle.tab.font.fontstruct) | 896 | if (m_windowstyle.tab.font.isAntialias() != antialias) |
949 | gcv.font = m_windowstyle.tab.font.fontstruct->fid; | 897 | m_windowstyle.tab.font.setAntialias(antialias); |
950 | |||
951 | XChangeGC(m_display, m_windowstyle.tab.l_text_focus_gc, | 898 | XChangeGC(m_display, m_windowstyle.tab.l_text_focus_gc, |
952 | gc_value_mask, &gcv); | 899 | gc_value_mask, &gcv); |
953 | 900 | ||
@@ -970,7 +917,7 @@ void Theme::reconfigure(bool antialias) { | |||
970 | m_menustyle.titlefont.setAntialias(antialias); | 917 | m_menustyle.titlefont.setAntialias(antialias); |
971 | 918 | ||
972 | XChangeGC(m_display, m_menustyle.t_text_gc, | 919 | XChangeGC(m_display, m_menustyle.t_text_gc, |
973 | gc_value_mask, &gcv); | 920 | gc_value_mask|GCForeground, &gcv); |
974 | 921 | ||
975 | gcv.foreground = m_menustyle.f_text.pixel(); | 922 | gcv.foreground = m_menustyle.f_text.pixel(); |
976 | if (m_menustyle.framefont.isAntialias() != antialias) | 923 | if (m_menustyle.framefont.isAntialias() != antialias) |
@@ -994,7 +941,8 @@ void Theme::reconfigure(bool antialias) { | |||
994 | gcv.foreground = m_toolbarstyle.l_text.pixel(); | 941 | gcv.foreground = m_toolbarstyle.l_text.pixel(); |
995 | if (m_toolbarstyle.font.fontstruct) | 942 | if (m_toolbarstyle.font.fontstruct) |
996 | gcv.font = m_toolbarstyle.font.fontstruct->fid; | 943 | gcv.font = m_toolbarstyle.font.fontstruct->fid; |
997 | 944 | ||
945 | gc_value_mask |= GCFont; | ||
998 | XChangeGC(m_display, m_toolbarstyle.l_text_gc, | 946 | XChangeGC(m_display, m_toolbarstyle.l_text_gc, |
999 | gc_value_mask, &gcv); | 947 | gc_value_mask, &gcv); |
1000 | 948 | ||
@@ -1138,7 +1086,8 @@ void Theme::loadFontFromDatabase(FbTk::Font &dest, const char *name, const char | |||
1138 | #ifdef DEBUG | 1086 | #ifdef DEBUG |
1139 | std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<std::endl; | 1087 | std::cerr<<__FILE__<<"("<<__LINE__<<"): Load font:"<<value.addr<<std::endl; |
1140 | #endif // DEBUG | 1088 | #endif // DEBUG |
1141 | dest.load(value.addr); | 1089 | if (!dest.load(value.addr)) |
1090 | cerr<<"Failed to load font: "<<value.addr<<endl; | ||
1142 | } | 1091 | } |
1143 | 1092 | ||
1144 | 1093 | ||