1 // MenuTheme.hh for FbTk 2 // Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // 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 18 // 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 20 // DEALINGS IN THE SOFTWARE. 21 22 // $Id: MenuTheme.hh 4199 2006-02-16 06:53:05Z mathias $ 23 24 #ifndef FBTK_MENUTHEME_HH 25 #define FBTK_MENUTHEME_HH 26 27 #include "Theme.hh" 28 #include "Color.hh" 29 #include "Font.hh" 30 #include "Texture.hh" 31 #include "Text.hh" 32 #include "Subject.hh" 33 #include "PixmapWithMask.hh" 34 #include "GContext.hh" 35 36 namespace FbTk { 37 38 class MenuTheme:public FbTk::Theme { 39 public: 40 //!! TODO 41 // this isn't actually used with a theme item 42 // see setMenuMode() for more info 43 enum MenuMode {CLICK_OPEN, DELAY_OPEN}; 44 45 enum BulletType { EMPTY, SQUARE, TRIANGLE, DIAMOND}; 46 MenuTheme(int screen_num); 47 virtual ~MenuTheme(); 48 49 void reconfigTheme(); 50 51 bool fallback(ThemeItem_base &item); 52 53 /** 54 @name text colors 55 */ 56 ///@{ titleTextColor() const57 inline const FbTk::Color &titleTextColor() const { return *t_text; } frameTextColor() const58 inline const FbTk::Color &frameTextColor() const { return *f_text; } highlightTextColor() const59 inline const FbTk::Color &highlightTextColor() const { return *h_text; } disableTextColor() const60 inline const FbTk::Color &disableTextColor() const { return *d_text; } 61 ///@} 62 /** 63 @name textures 64 */ 65 ///@{ titleTexture() const66 inline const FbTk::Texture &titleTexture() const { return *title; } frameTexture() const67 inline const FbTk::Texture &frameTexture() const { return *frame; } hiliteTexture() const68 inline const FbTk::Texture &hiliteTexture() const { return *hilite; } 69 ///@} 70 bulletPixmap() const71 inline const FbTk::PixmapWithMask &bulletPixmap() const { return *m_bullet_pixmap; } selectedPixmap() const72 inline const FbTk::PixmapWithMask &selectedPixmap() const { return *m_selected_pixmap; } unselectedPixmap() const73 inline const FbTk::PixmapWithMask &unselectedPixmap() const { return *m_unselected_pixmap; } 74 highlightBulletPixmap() const75 inline const FbTk::PixmapWithMask &highlightBulletPixmap() const { return *m_hl_bullet_pixmap; } highlightSelectedPixmap() const76 inline const FbTk::PixmapWithMask &highlightSelectedPixmap() const { return *m_hl_selected_pixmap; } highlightUnselectedPixmap() const77 inline const FbTk::PixmapWithMask &highlightUnselectedPixmap() const { return *m_hl_unselected_pixmap; } 78 /** 79 @name fonts 80 */ 81 ///@{ titleFont() const82 inline const FbTk::Font &titleFont() const { return *titlefont; } titleFont()83 inline FbTk::Font &titleFont() { return *titlefont; } frameFont() const84 inline const FbTk::Font &frameFont() const { return *framefont; } frameFont()85 inline FbTk::Font &frameFont() { return *framefont; } 86 ///@} 87 frameFontJustify() const88 inline FbTk::Justify frameFontJustify() const { return *framefont_justify; } titleFontJustify() const89 inline FbTk::Justify titleFontJustify() const { return *titlefont_justify; } 90 91 /** 92 @name graphic contexts 93 */ 94 ///@{ titleTextGC() const95 inline const GContext &titleTextGC() const { return t_text_gc; } frameTextGC() const96 inline const GContext &frameTextGC() const { return f_text_gc; } hiliteTextGC() const97 inline const GContext &hiliteTextGC() const { return h_text_gc; } disableTextGC() const98 inline const GContext &disableTextGC() const { return d_text_gc; } hiliteGC() const99 inline const GContext &hiliteGC() const { return hilite_gc; } titleTextGC()100 inline GContext &titleTextGC() { return t_text_gc; } frameTextGC()101 inline GContext &frameTextGC() { return f_text_gc; } hiliteTextGC()102 inline GContext &hiliteTextGC() { return h_text_gc; } disableTextGC()103 inline GContext &disableTextGC() { return d_text_gc; } hiliteGC()104 inline GContext &hiliteGC() { return hilite_gc; } 105 ///@} bullet() const106 inline BulletType bullet() const { return *m_bullet; } bulletPos() const107 inline FbTk::Justify bulletPos() const { return *bullet_pos; } 108 titleHeight() const109 inline unsigned int titleHeight() const { return m_real_title_height; } itemHeight() const110 inline unsigned int itemHeight() const { return m_real_item_height; } borderWidth() const111 inline unsigned int borderWidth() const { return *m_border_width; } bevelWidth() const112 inline unsigned int bevelWidth() const { return *m_bevel_width; } 113 alpha() const114 inline unsigned char alpha() const { return m_alpha; } setAlpha(unsigned char alpha)115 inline void setAlpha(unsigned char alpha) { m_alpha = alpha; } 116 // this isn't actually a theme item 117 // but we'll let it be here for now, until there's a better way to 118 // get resources into menu setMenuMode(MenuMode mode)119 inline void setMenuMode(MenuMode mode) { m_menumode = mode; } menuMode() const120 inline MenuMode menuMode() const { return m_menumode; } setDelayOpen(int msec)121 inline void setDelayOpen(int msec) { m_delayopen = msec; } setDelayClose(int msec)122 inline void setDelayClose(int msec) { m_delayclose = msec; } delayOpen() const123 inline int delayOpen() const { return m_delayopen; } delayClose() const124 inline int delayClose() const { return m_delayclose; } 125 borderColor() const126 inline const FbTk::Color &borderColor() const { return *m_border_color; } 127 128 // special override setSelectedPixmap(Pixmap pm)129 inline void setSelectedPixmap(Pixmap pm) { m_selected_pixmap->pixmap() = pm; } setHighlightSelectedPixmap(Pixmap pm)130 inline void setHighlightSelectedPixmap(Pixmap pm) { m_hl_selected_pixmap->pixmap() = pm; } 131 132 private: 133 FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text; 134 FbTk::ThemeItem<FbTk::Texture> title, frame, hilite; 135 FbTk::ThemeItem<FbTk::Font> titlefont, framefont; 136 FbTk::ThemeItem<FbTk::Justify> framefont_justify, titlefont_justify; 137 FbTk::ThemeItem<FbTk::Justify> bullet_pos; 138 FbTk::ThemeItem<BulletType> m_bullet; 139 FbTk::ThemeItem<unsigned int> m_title_height, m_item_height; 140 FbTk::ThemeItem<unsigned int> m_border_width; 141 FbTk::ThemeItem<unsigned int> m_bevel_width; 142 FbTk::ThemeItem<FbTk::Color> m_border_color; 143 FbTk::ThemeItem<FbTk::PixmapWithMask> m_bullet_pixmap, m_selected_pixmap, m_unselected_pixmap; 144 FbTk::ThemeItem<FbTk::PixmapWithMask> m_hl_bullet_pixmap, m_hl_selected_pixmap, m_hl_unselected_pixmap; 145 146 Display *m_display; 147 FbTk::GContext t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; 148 149 unsigned char m_alpha; 150 MenuMode m_menumode; 151 unsigned int m_delayopen; ///< in msec 152 unsigned int m_delayclose; ///< in msec 153 unsigned int m_real_title_height; ///< the calculated item height (from font and menu.titleHeight) 154 unsigned int m_real_item_height; ///< the calculated item height (from font and menu.itemHeight) 155 }; 156 157 } // end namespace FbTk 158 159 #endif // FBTK_MENUTHEME_HH 160