aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Theme.cc140
-rw-r--r--src/Theme.hh18
2 files changed, 15 insertions, 143 deletions
diff --git a/src/Theme.cc b/src/Theme.cc
index f98dace..b0dbf94 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.38 2002/12/01 13:42:00 rathnor Exp $ 24// $Id: Theme.cc,v 1.39 2002/12/02 20:54:30 fluxgen Exp $
25 25
26 26
27#include "Theme.hh" 27#include "Theme.hh"
@@ -134,35 +134,12 @@ Theme::Theme(Display *display, Window rootwindow, Colormap colormap,
134 m_menustyle.hilite_gc = 134 m_menustyle.hilite_gc =
135 XCreateGC(m_display, rootwindow, 135 XCreateGC(m_display, rootwindow,
136 gc_value_mask, &gcv); 136 gc_value_mask, &gcv);
137
138 gcv.foreground = m_toolbarstyle.l_text.pixel();
139
140 m_toolbarstyle.l_text_gc =
141 XCreateGC(m_display, rootwindow,
142 gc_value_mask, &gcv);
143
144 gcv.foreground = m_toolbarstyle.w_text.pixel();
145 m_toolbarstyle.w_text_gc =
146 XCreateGC(m_display, rootwindow,
147 gc_value_mask, &gcv);
148
149 gcv.foreground = m_toolbarstyle.c_text.pixel();
150 m_toolbarstyle.c_text_gc =
151 XCreateGC(m_display, rootwindow,
152 gc_value_mask, &gcv);
153
154 gcv.foreground = m_toolbarstyle.b_pic.pixel();
155 m_toolbarstyle.b_pic_gc =
156 XCreateGC(m_display, rootwindow,
157 gc_value_mask, &gcv);
158
159} 137}
160 138
161Theme::~Theme() { 139Theme::~Theme() {
162 140
163 freeMenuStyle(); 141 freeMenuStyle();
164 freeWindowStyle(); 142 freeWindowStyle();
165 freeToolbarStyle();
166 freeTabStyle(); 143 freeTabStyle();
167} 144}
168 145
@@ -197,19 +174,6 @@ void Theme::freeTabStyle() {
197 XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc); 174 XFreeGC(m_display, m_windowstyle.tab.l_text_unfocus_gc);
198} 175}
199 176
200//----- freeToolbarStyle -----
201// free memory allocated for m_toolbarstyle
202// should only be called from ~Theme
203//--------------------
204void Theme::freeToolbarStyle() {
205
206 XFreeGC(m_display, m_toolbarstyle.l_text_gc);
207 XFreeGC(m_display, m_toolbarstyle.w_text_gc);
208 XFreeGC(m_display, m_toolbarstyle.c_text_gc);
209 XFreeGC(m_display, m_toolbarstyle.b_pic_gc);
210
211}
212
213//---------- load ------------ 177//---------- load ------------
214// Loads a theme from a file 178// Loads a theme from a file
215//---------------------------- 179//----------------------------
@@ -219,7 +183,6 @@ void Theme::load(const char *filename){
219 m_database = XrmGetFileDatabase(DEFAULTSTYLE); 183 m_database = XrmGetFileDatabase(DEFAULTSTYLE);
220 184
221 loadMenuStyle(); 185 loadMenuStyle();
222 loadToolbarStyle();
223 loadWindowStyle(); 186 loadWindowStyle();
224 loadTabStyle(); 187 loadTabStyle();
225 loadRootCommand(); 188 loadRootCommand();
@@ -482,64 +445,6 @@ void Theme::loadTabStyle() {
482 445
483} 446}
484 447
485void Theme::loadToolbarStyle() {
486
487 readDatabaseTexture("toolbar", "Toolbar",
488 &m_toolbarstyle.toolbar,
489 BlackPixel(m_display, m_screennum));
490 readDatabaseTexture("toolbar.label", "Toolbar.Label",
491 &m_toolbarstyle.label,
492 BlackPixel(m_display, m_screennum));
493 readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel",
494 &m_toolbarstyle.window,
495 BlackPixel(m_display, m_screennum));
496 readDatabaseTexture("toolbar.button", "Toolbar.Button",
497 &m_toolbarstyle.button,
498 WhitePixel(m_display, m_screennum));
499 readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed",
500 &m_toolbarstyle.pressed,
501 BlackPixel(m_display, m_screennum));
502 readDatabaseTexture("toolbar.clock", "Toolbar.Clock",
503 &m_toolbarstyle.clock,
504 BlackPixel(m_display, m_screennum));
505
506 readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor",
507 &m_toolbarstyle.l_text,
508 WhitePixel(m_display, m_screennum));
509
510 readDatabaseColor("toolbar.windowLabel.textColor",
511 "Toolbar.WindowLabel.TextColor",
512 &m_toolbarstyle.w_text,
513 WhitePixel(m_display, m_screennum));
514
515 readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor",
516 &m_toolbarstyle.c_text,
517 WhitePixel(m_display, m_screennum));
518 readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor",
519 &m_toolbarstyle.b_pic,
520 BlackPixel(m_display, m_screennum));
521
522
523 // ----------- load font
524
525 loadFontFromDatabase(m_toolbarstyle.font, "toolbar.font", "Toolbar.Font");
526
527 XrmValue value;
528 char *value_type;
529
530 if (XrmGetResource(m_database, "toolbar.justify",
531 "Toolbar.Justify", &value_type, &value)) {
532 if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
533 m_toolbarstyle.justify = DrawUtil::Font::RIGHT;
534 else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
535 m_toolbarstyle.justify = DrawUtil::Font::CENTER;
536 else
537 m_toolbarstyle.justify = DrawUtil::Font::LEFT;
538 } else
539 m_toolbarstyle.justify = DrawUtil::Font::LEFT;
540
541}
542
543void Theme::loadRootCommand() { 448void Theme::loadRootCommand() {
544 XrmValue value; 449 XrmValue value;
545 char *value_type; 450 char *value_type;
@@ -627,7 +532,7 @@ void Theme::loadMisc() {
627 if (!readDatabaseTexture("slit", "Slit", 532 if (!readDatabaseTexture("slit", "Slit",
628 &m_slit_texture, 533 &m_slit_texture,
629 BlackPixel(m_display, m_screennum)) ) { 534 BlackPixel(m_display, m_screennum)) ) {
630 m_slit_texture = m_toolbarstyle.toolbar; 535 // m_slit_texture = m_toolbarstyle.toolbar; ///!!! TODO !!!
631 } 536 }
632 537
633} 538}
@@ -779,12 +684,11 @@ void Theme::readDatabaseFontSet(char *rname, char *rclass, XFontSet *fontset) {
779 *fontset = createFontSet(defaultFont); 684 *fontset = createFontSet(defaultFont);
780 685
781 if (! *fontset) { 686 if (! *fontset) {
782 fprintf(stderr, 687 throw string(
783 I18n::instance()-> 688 I18n::instance()->
784 getMessage( 689 getMessage(
785 FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail, 690 FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail,
786 "BScreen::LoadStyle(): couldn't load default font.\n")); 691 "BScreen::LoadStyle(): couldn't load default font."));
787 throw 2;
788 } 692 }
789 } 693 }
790} 694}
@@ -811,8 +715,8 @@ void Theme::readDatabaseFont(char *rname, char *rclass, XFontStruct **font) {
811 fprintf(stderr, 715 fprintf(stderr,
812 I18n::instance()-> 716 I18n::instance()->
813 getMessage( 717 getMessage(
814 FBNLS::ScreenSet, FBNLS::ScreenFontLoadFail, 718 FBNLS::ScreenSet, FBNLS::ScreenFontLoadFail,
815 "BScreen::LoadStyle(): couldn't load font '%s'\n"), 719 "BScreen::LoadStyle(): couldn't load font '%s'\n"),
816 value.addr); 720 value.addr);
817 721
818 load_default = true; 722 load_default = true;
@@ -822,12 +726,12 @@ void Theme::readDatabaseFont(char *rname, char *rclass, XFontStruct **font) {
822 726
823 if (load_default) { 727 if (load_default) {
824 if ((*font = XLoadQueryFont(m_display, defaultFont)) == 0) { 728 if ((*font = XLoadQueryFont(m_display, defaultFont)) == 0) {
825 fprintf(stderr, 729 throw string(
826 I18n::instance()-> 730 I18n::instance()->
827 getMessage( 731 getMessage(
828 FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail, 732 FBNLS::ScreenSet, FBNLS::ScreenDefaultFontLoadFail,
829 "BScreen::LoadStyle(): couldn't load default font.\n")); 733 "BScreen::LoadStyle(): couldn't load default font."));
830 throw 2; //fatal! 734
831 } 735 }
832 } 736 }
833} 737}
@@ -904,26 +808,6 @@ void Theme::reconfigure(bool antialias) {
904 XChangeGC(m_display, m_menustyle.hilite_gc, 808 XChangeGC(m_display, m_menustyle.hilite_gc,
905 gc_value_mask, &gcv); 809 gc_value_mask, &gcv);
906 810
907 // set antialias ?
908 if (m_toolbarstyle.font.isAntialias() != antialias)
909 m_toolbarstyle.font.setAntialias(antialias);
910
911 gcv.foreground = m_toolbarstyle.l_text.pixel();
912 XChangeGC(m_display, m_toolbarstyle.l_text_gc,
913 gc_value_mask, &gcv);
914
915 gcv.foreground = m_toolbarstyle.w_text.pixel();
916 XChangeGC(m_display, m_toolbarstyle.w_text_gc,
917 gc_value_mask, &gcv);
918
919 gcv.foreground = m_toolbarstyle.c_text.pixel();
920 XChangeGC(m_display, m_toolbarstyle.c_text_gc,
921 gc_value_mask, &gcv);
922
923 gcv.foreground = m_toolbarstyle.b_pic.pixel();
924 XChangeGC(m_display, m_toolbarstyle.b_pic_gc,
925 gc_value_mask, &gcv);
926
927} 811}
928 812
929XFontSet Theme::createFontSet(char *fontname) { 813XFontSet Theme::createFontSet(char *fontname) {
diff --git a/src/Theme.hh b/src/Theme.hh
index 2eae595..e31e5a5 100644
--- a/src/Theme.hh
+++ b/src/Theme.hh
@@ -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: Theme.hh,v 1.21 2002/12/01 13:42:00 rathnor Exp $ 25// $Id: Theme.hh,v 1.22 2002/12/02 20:52:50 fluxgen Exp $
26 26
27#ifndef THEME_HH 27#ifndef THEME_HH
28#define THEME_HH 28#define THEME_HH
@@ -88,19 +88,8 @@ public:
88 88
89 } WindowStyle; 89 } WindowStyle;
90 90
91
92 typedef struct ToolbarStyle {
93 ToolbarStyle():font("fixed") { } // default font 'fixed'
94 FbTk::Color l_text, w_text, c_text, b_pic;
95 FbTk::Texture toolbar, label, window, button, pressed, clock;
96 GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc;
97 FbTk::Font font;
98 DrawUtil::Font::FontJustify justify;
99 } ToolbarStyle;
100
101 inline WindowStyle &getWindowStyle() { return m_windowstyle; } 91 inline WindowStyle &getWindowStyle() { return m_windowstyle; }
102 inline MenuStyle &getMenuStyle() { return m_menustyle; } 92 inline MenuStyle &getMenuStyle() { return m_menustyle; }
103 inline ToolbarStyle &getToolbarStyle() { return m_toolbarstyle; }
104 inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; } 93 inline const FbTk::Texture &getSlitTexture() const { return m_slit_texture; }
105 inline unsigned int getBevelWidth() const { return m_bevel_width; } 94 inline unsigned int getBevelWidth() const { return m_bevel_width; }
106 inline unsigned int getBorderWidth() const { return m_border_width; } 95 inline unsigned int getBorderWidth() const { return m_border_width; }
@@ -120,13 +109,12 @@ private:
120 void loadMenuStyle(); 109 void loadMenuStyle();
121 void loadWindowStyle(); 110 void loadWindowStyle();
122 void loadTabStyle(); 111 void loadTabStyle();
123 void loadToolbarStyle();
124 void loadRootCommand(); 112 void loadRootCommand();
125 void loadMisc(); 113 void loadMisc();
126 void freeMenuStyle(); 114 void freeMenuStyle();
127 void freeWindowStyle(); 115 void freeWindowStyle();
128 void freeTabStyle(); 116 void freeTabStyle();
129 void freeToolbarStyle(); 117
130 void loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname); 118 void loadFontFromDatabase(FbTk::Font &dest, const char *name, const char *altname);
131 bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long); 119 bool readDatabaseTexture(char *, char *, FbTk::Texture *, unsigned long);
132 bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long); 120 bool readDatabaseColor(char *, char *, FbTk::Color *, unsigned long);
@@ -141,7 +129,7 @@ private:
141 129
142 WindowStyle m_windowstyle; 130 WindowStyle m_windowstyle;
143 MenuStyle m_menustyle; 131 MenuStyle m_menustyle;
144 ToolbarStyle m_toolbarstyle; 132
145 unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width; 133 unsigned int m_bevel_width, m_border_width, m_handle_width, m_frame_width;
146 FbTk::Color m_border_color; 134 FbTk::Color m_border_color;
147 GC m_opgc; 135 GC m_opgc;