From ce899439c9c26a767bcfc39aab8d5ea94fa9dacc Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 16 Dec 2002 11:02:41 +0000 Subject: two more commans for right and middle click --- src/FbTk/Button.hh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh index 5d0842d..c49815d 100644 --- a/src/FbTk/Button.hh +++ b/src/FbTk/Button.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Button.hh,v 1.1 2002/12/13 20:24:33 fluxgen Exp $ +// $Id: Button.hh,v 1.2 2002/12/16 11:02:41 fluxgen Exp $ #ifndef FBTK_BUTTON_HH #define FBTK_BUTTON_HH @@ -29,29 +29,35 @@ #include "RefCount.hh" #include "FbWindow.hh" #include "Command.hh" +#include "Color.hh" #include #include namespace FbTk { -class Color; - class Button:public EventHandler, private NotCopyable { public: Button(int screen_num, int x, int y, unsigned int width, unsigned int height); - Button(FbWindow &parent, int x, int y, unsigned int width, unsigned int height); + Button(const FbWindow &parent, int x, int y, unsigned int width, unsigned int height); virtual ~Button(); - /// sets action when the button is clicked - void setOnClick(RefCount &com) { m_onclick = com; } + /// sets action when the button is clicked with left mouse btn + void setOnClick(RefCount &com) { m_onclick_left = com; } + /// sets action when the button is clicked with middle mouse btn + void setOnClickMiddle(RefCount &com) { m_onclick_middle = com; } + /// sets action when the button is clicked with right mouse btn + void setOnClickRight(RefCount &com) { m_onclick_right = com; } + void move(int x, int y); void resize(unsigned int width, unsigned int height); void moveResize(int x, int y, unsigned int width, unsigned int height); - /// sets the pixmap to be viewd when the button is in normal state (ie not pressed) + + /// sets foreground pixmap void setPixmap(Pixmap pm); /// sets the pixmap to be viewed when the button is pressed void setPressedPixmap(Pixmap pm); + /// sets graphic context for drawing void setGC(GC gc) { m_gc = gc; } /// sets background pixmap, this will override background color void setBackgroundPixmap(Pixmap pm); @@ -70,6 +76,7 @@ public: virtual void buttonReleaseEvent(XButtonEvent &event); virtual void exposeEvent(XExposeEvent &event); //@} + /// @return true if the button is pressed, else false bool pressed() const { return m_pressed; } /** @@ -84,13 +91,18 @@ public: FbWindow &window() { return m_win; } const FbWindow &window() const { return m_win; } GC gc() const { return m_gc; } + private: FbTk::FbWindow m_win; ///< window for button Pixmap m_foreground_pm; ///< foreground pixmap + Pixmap m_background_pm; ///< background pixmap + Color m_background_color; ///< background color Pixmap m_pressed_pm; ///< pressed pixmap GC m_gc; ///< graphic context for button bool m_pressed; ///< if the button is pressed - RefCount m_onclick; ///< what to do when this button is clicked + RefCount m_onclick_left; ///< what to do when this button is clicked with lmb + RefCount m_onclick_middle; ///< what to do when this button is clicked with mmb + RefCount m_onclick_right; ///< what to do when this button is clicked with rmb }; }; -- cgit v0.11.2