1 // IconButton.hh 2 // Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) 3 // and Simon Bowden (rathnor at users.sourceforge.net) 4 // 5 // Permission is hereby granted, free of charge, to any person obtaining a 6 // copy of this software and associated documentation files (the "Software"), 7 // to deal in the Software without restriction, including without limitation 8 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // and/or sell copies of the Software, and to permit persons to whom the 10 // Software is furnished to do so, subject to the following conditions: 11 // 12 // The above copyright notice and this permission notice shall be included in 13 // all copies or substantial portions of the Software. 14 // 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 // DEALINGS IN THE SOFTWARE. 22 23 #ifndef ICONBUTTON_HH 24 #define ICONBUTTON_HH 25 26 #include "FocusableTheme.hh" 27 28 #include "FbTk/CachedPixmap.hh" 29 #include "FbTk/FbPixmap.hh" 30 #include "FbTk/TextButton.hh" 31 #include "FbTk/Signal.hh" 32 33 class IconbarTheme; 34 35 namespace FbTk { 36 template <class T> class ThemeProxy; 37 } 38 39 class IconButton: public FbTk::TextButton { 40 public: 41 IconButton(const FbTk::FbWindow &parent, 42 FbTk::ThemeProxy<IconbarTheme> &focused_theme, 43 FbTk::ThemeProxy<IconbarTheme> &unfocused_theme, 44 Focusable &window); 45 virtual ~IconButton(); 46 47 void exposeEvent(XExposeEvent &event); 48 void enterNotifyEvent(XCrossingEvent &ce); 49 void leaveNotifyEvent(XCrossingEvent &ce); 50 void clear(); 51 void clearArea(int x, int y, 52 unsigned int width, unsigned int height, 53 bool exposure = false); 54 void moveResize(int x, int y, 55 unsigned int width, unsigned int height); 56 void resize(unsigned int width, unsigned int height); 57 58 void reconfigTheme(); 59 60 void setPixmap(bool use); 61 win()62 Focusable &win() { return m_win; } win() const63 const Focusable &win() const { return m_win; } 64 65 bool setOrientation(FbTk::Orientation orient); 66 67 protected: 68 void drawText(int x, int y, FbTk::FbDrawable *drawable_override); 69 private: 70 void reconfigAndClear(); 71 void setupWindow(); 72 void showTooltip(); 73 74 /// Refresh all pixmaps and windows 75 /// @param setup Wether to setup window again. 76 void refreshEverything(bool setup); 77 /// Called when client title changed. 78 void clientTitleChanged(); 79 80 Focusable &m_win; 81 FbTk::FbWindow m_icon_window; 82 FbTk::FbPixmap m_icon_pixmap; 83 FbTk::FbPixmap m_icon_mask; 84 bool m_use_pixmap; 85 /// whether or not this instance has the tooltip attention 86 /// i.e if it got enter notify 87 bool m_has_tooltip; 88 FocusableTheme<IconbarTheme> m_theme; 89 // cached pixmaps 90 FbTk::CachedPixmap m_pm; 91 FbTk::SignalTracker m_signals; 92 }; 93 94 #endif // ICONBUTTON_HH 95