two more commans for right and middle click
fluxgen fluxgen
1 files changed,
20 insertions(+),
8 deletions(-)
jump to
M
src/FbTk/Button.hh
→
src/FbTk/Button.hh
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 "NotCopyable.hh"
#include "RefCount.hh" #include "FbWindow.hh" #include "Command.hh" +#include "Color.hh" #include <X11/Xlib.h> #include <memory> 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<Command> &com) { m_onclick = com; } + /// sets action when the button is clicked with left mouse btn + void setOnClick(RefCount<Command> &com) { m_onclick_left = com; } + /// sets action when the button is clicked with middle mouse btn + void setOnClickMiddle(RefCount<Command> &com) { m_onclick_middle = com; } + /// sets action when the button is clicked with right mouse btn + void setOnClickRight(RefCount<Command> &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 @@ virtual void buttonPressEvent(XButtonEvent &event);
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 @@ //@}
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<Command> m_onclick; ///< what to do when this button is clicked + RefCount<Command> m_onclick_left; ///< what to do when this button is clicked with lmb + RefCount<Command> m_onclick_middle; ///< what to do when this button is clicked with mmb + RefCount<Command> m_onclick_right; ///< what to do when this button is clicked with rmb }; };