news download themes documentation links










FbWinFrame.hh

00001 // FbWinFrame.hh for Fluxbox Window Manager
00002 // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00003 //
00004 // Permission is hereby granted, free of charge, to any person obtaining a
00005 // copy of this software and associated documentation files (the "Software"),
00006 // to deal in the Software without restriction, including without limitation
00007 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008 // and/or sell copies of the Software, and to permit persons to whom the
00009 // Software is furnished to do so, subject to the following conditions:
00010 //
00011 // The above copyright notice and this permission notice shall be included in
00012 // all copies or substantial portions of the Software.
00013 //
00014 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00019 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00020 // DEALINGS IN THE SOFTWARE.
00021 
00022 // $Id: FbWinFrame.hh,v 1.28 2004/01/02 13:25:55 fluxgen Exp $
00023 
00024 #ifndef FBWINFRAME_HH
00025 #define FBWINFRAME_HH
00026 
00027 #include "FbTk/FbWindow.hh"
00028 #include "FbTk/EventHandler.hh"
00029 #include "FbTk/RefCount.hh"
00030 #include "FbTk/Observer.hh"
00031 #include "FbTk/Color.hh"
00032 #include "FbTk/FbPixmap.hh"
00033 #include "FbTk/Timer.hh"
00034 
00035 #include <vector>
00036 #include <list>
00037 #include <string>
00038 #include <memory>
00039 
00040 class Shape;
00041 class FbWinFrameTheme;
00042 
00043 namespace FbTk {
00044 class TextButton;
00045 class ImageControl;
00046 class Command;
00047 class Button;
00048 class Texture;
00049 }
00050 
00053 class FbWinFrame:public FbTk::EventHandler {
00054 public:
00055 
00057     FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl,
00058                int x, int y,
00059                unsigned int width, unsigned int height);
00060 
00062     FbWinFrame(FbWinFrameTheme &theme, FbTk::ImageControl &imgctrl, 
00063                const FbTk::FbWindow &parent,
00064                int x, int y, 
00065                unsigned int width, unsigned int height);
00066 
00068     ~FbWinFrame();
00069 
00071     bool setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &cmd, int button_num,
00072                             bool double_click=false, bool pressed=false);
00073 
00074     void hide();
00075     void show();
00076     inline bool isVisible() const { return m_visible; }
00078     void shade();
00079     void move(int x, int y);
00080     void resize(unsigned int width, unsigned int height);
00082     void resizeForClient(unsigned int width, unsigned int height);
00083 
00084     // for when there needs to be an atomic move+resize operation
00085     void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true);
00086 
00087     // can elect to ignore move or resize (mainly for use of move/resize individual functions
00088     void moveResize(int x, int y, unsigned int width, unsigned int height, bool move = true, bool resize = true);
00089 
00091     void setFocus(bool newvalue);
00092     void setDoubleClickTime(unsigned int time);
00093 
00095     void addLeftButton(FbTk::Button *btn);
00097     void addRightButton(FbTk::Button *btn);
00099     void removeAllButtons();
00101     void addLabelButton(FbTk::TextButton &btn);
00103     void removeLabelButton(FbTk::TextButton &btn);
00105     void moveLabelButtonLeft(const FbTk::TextButton &btn);
00107     void moveLabelButtonRight(const FbTk::TextButton &btn);
00109     void setLabelButtonFocus(FbTk::TextButton &btn);
00111     void setClientWindow(FbTk::FbWindow &win);
00113     void removeClient();
00115     void setEventHandler(FbTk::EventHandler &evh);
00117     void removeEventHandler();
00118 
00119     // these return true/false for if something changed
00120     bool hideTitlebar();
00121     bool showTitlebar();
00122     bool hideHandle();
00123     bool showHandle();
00124     bool hideAllDecorations();
00125     bool showAllDecorations();
00126 
00127     // this function translates its arguments according to win_gravity
00128     // if win_gravity is negative, it does an inverse translation
00129     void gravityTranslate(int &x, int &y, int win_gravity, bool move_frame = false);
00130 
00131     void setBorderWidth(unsigned int borderW);
00132 
00137     void buttonPressEvent(XButtonEvent &event);
00138     void buttonReleaseEvent(XButtonEvent &event);
00139     void exposeEvent(XExposeEvent &event);
00140     void configureNotifyEvent(XConfigureEvent &event);
00141     void handleEvent(XEvent &event);
00143  
00144     void reconfigure();
00145     void setUseShape(bool value);
00146 
00147     void setUpdateDelayTime(long t) { m_update_timer.setTimeout(t); }
00148 
00153     inline int x() const { return m_window.x(); }
00154     inline int y() const { return m_window.y(); }
00155     inline unsigned int width() const { return m_window.width(); }
00156     inline unsigned int height() const { return m_window.height(); }
00157     inline const FbTk::FbWindow &window() const { return m_window; }
00158     inline FbTk::FbWindow &window() { return m_window; }
00160     inline const FbTk::FbWindow &titlebar() const { return m_titlebar; }
00161     inline FbTk::FbWindow &titlebar() { return m_titlebar; }
00162     inline const FbTk::FbWindow &label() const { return m_label; }
00163     inline FbTk::FbWindow &label() { return m_label; }
00165     inline const FbTk::FbWindow &clientArea() const { return m_clientarea; }
00166     inline FbTk::FbWindow &clientArea() { return m_clientarea; }
00168     inline const FbTk::FbWindow &handle() const { return m_handle; }
00169     inline FbTk::FbWindow &handle() { return m_handle; }
00170     inline const FbTk::FbWindow &gripLeft() const { return m_grip_left; }
00171     inline FbTk::FbWindow &gripLeft() { return m_grip_left; }
00172     inline const FbTk::FbWindow &gripRight() const { return m_grip_right; }
00173     inline FbTk::FbWindow &gripRight() { return m_grip_right; }
00174     inline const FbTk::TextButton *currentLabel() const { return m_current_label; }
00175     inline bool focused() const { return m_focused; }
00176     inline bool isShaded() const { return m_shaded; }
00177     inline const FbWinFrameTheme &theme() const { return m_theme; }
00179     unsigned int titlebarHeight() const { return m_titlebar.height(); }
00181     unsigned int buttonHeight() const;
00182 
00184 
00185 private:
00186     void redrawTitlebar();
00187     void redrawTitle();
00188 
00190     void reconfigureTitlebar();
00195     void renderTitlebar();
00196     void renderHandles();
00197     void renderButtons();
00198     // focused => has focus
00199     void renderButtonFocus(FbTk::TextButton &button);
00200     // unfocus => has no focus, label not the active one
00201     void renderButtonUnfocus(FbTk::TextButton &button);
00202     // active => doesn't have keybaord focus, but is the active tab
00203     void renderButtonActive(FbTk::TextButton &button);
00204     void renderLabel();
00206     void render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,
00207                 unsigned int width, unsigned int height);
00208     void getActiveLabelPixmap(Pixmap &label_pm, Pixmap &title_pm,
00209                               FbTk::Color &label_color, FbTk::Color &title_color);
00210     void getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm,
00211                                FbTk::Color &label_color, FbTk::Color &title_color);
00212     void renderLabelButtons();
00214 
00216     void init();
00218     void setupButton(FbTk::Button &btn);
00219     void updateTransparent();
00220 
00221     FbWinFrameTheme &m_theme; 
00222     FbTk::ImageControl &m_imagectrl; 
00223 
00227     FbTk::FbWindow m_window; 
00228     FbTk::FbWindow m_titlebar; 
00229     FbTk::FbWindow m_label; 
00230     FbTk::FbWindow m_handle; 
00231     FbTk::FbWindow m_grip_right,  
00232         m_grip_left; 
00233     FbTk::FbWindow m_clientarea; 
00234 
00235     typedef std::vector<FbTk::Button *> ButtonList;
00236     ButtonList m_buttons_left, 
00237         m_buttons_right; 
00238     typedef std::list<FbTk::TextButton *> LabelList;
00239     LabelList m_labelbuttons; 
00240     FbTk::TextButton *m_current_label; 
00241     std::string m_titletext; 
00242     int m_bevel;  
00243     bool m_use_titlebar; 
00244     bool m_use_handle; 
00245     bool m_focused; 
00246     bool m_visible; 
00247 
00252     Pixmap m_title_focused_pm; 
00253     FbTk::Color m_title_focused_color; 
00254     Pixmap m_title_unfocused_pm; 
00255     FbTk::Color m_title_unfocused_color; 
00256 
00257     Pixmap m_label_focused_pm; 
00258     FbTk::Color m_label_focused_color; 
00259     Pixmap m_label_unfocused_pm; 
00260     FbTk::Color m_label_unfocused_color; 
00261     Pixmap m_label_active_pm; 
00262     FbTk::Color m_label_active_color; 
00263     
00264     FbTk::Color m_handle_focused_color, m_handle_unfocused_color;
00265     Pixmap m_handle_focused_pm, m_handle_unfocused_pm;
00266     
00267 
00268     Pixmap m_button_pm;  
00269     FbTk::Color m_button_color; 
00270     Pixmap m_button_unfocused_pm; 
00271     FbTk::Color m_button_unfocused_color; 
00272     Pixmap m_button_pressed_pm; 
00273     FbTk::Color m_button_pressed_color; 
00274 
00275     Pixmap m_grip_focused_pm;
00276     FbTk::Color m_grip_focused_color; 
00277     Pixmap m_grip_unfocused_pm; 
00278     FbTk::Color m_grip_unfocused_color; 
00279 
00280 
00281     int m_button_size; 
00282     unsigned int m_width_before_shade,  
00283         m_height_before_shade; 
00284     bool m_shaded; 
00285     unsigned int m_double_click_time; 
00286     struct MouseButtonAction {
00287         FbTk::RefCount<FbTk::Command> click; 
00288         FbTk::RefCount<FbTk::Command> click_pressed; 
00289         FbTk::RefCount<FbTk::Command> double_click; 
00290     };
00291     MouseButtonAction m_commands[5]; 
00292 
00293     class ThemeListener: public FbTk::Observer {
00294     public:
00295         ThemeListener(FbWinFrame &frame):m_frame(frame) { }
00296         void update(FbTk::Subject *) {
00297             m_frame.reconfigure();
00298         }
00299     private:
00300         FbWinFrame &m_frame;
00301     };
00302     ThemeListener m_themelistener;
00303     std::auto_ptr<Shape> m_shape;
00304     bool m_disable_shape;
00305     FbTk::Timer m_update_timer;
00306 };
00307 
00308 #endif // FBWINFRAME_HH

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA