two more commans for right and middle click
This commit is contained in:
parent
e0ae69d0b9
commit
ce899439c9
1 changed files with 20 additions and 8 deletions
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifndef FBTK_BUTTON_HH
|
||||||
#define FBTK_BUTTON_HH
|
#define FBTK_BUTTON_HH
|
||||||
|
@ -29,29 +29,35 @@
|
||||||
#include "RefCount.hh"
|
#include "RefCount.hh"
|
||||||
#include "FbWindow.hh"
|
#include "FbWindow.hh"
|
||||||
#include "Command.hh"
|
#include "Command.hh"
|
||||||
|
#include "Color.hh"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace FbTk {
|
namespace FbTk {
|
||||||
|
|
||||||
class Color;
|
|
||||||
|
|
||||||
class Button:public EventHandler,
|
class Button:public EventHandler,
|
||||||
private NotCopyable {
|
private NotCopyable {
|
||||||
public:
|
public:
|
||||||
Button(int screen_num, int x, int y, unsigned int width, unsigned int height);
|
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();
|
virtual ~Button();
|
||||||
/// sets action when the button is clicked
|
/// sets action when the button is clicked with left mouse btn
|
||||||
void setOnClick(RefCount<Command> &com) { m_onclick = com; }
|
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 move(int x, int y);
|
||||||
void resize(unsigned int width, unsigned int height);
|
void resize(unsigned int width, unsigned int height);
|
||||||
void moveResize(int x, int y, 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);
|
void setPixmap(Pixmap pm);
|
||||||
/// sets the pixmap to be viewed when the button is pressed
|
/// sets the pixmap to be viewed when the button is pressed
|
||||||
void setPressedPixmap(Pixmap pm);
|
void setPressedPixmap(Pixmap pm);
|
||||||
|
/// sets graphic context for drawing
|
||||||
void setGC(GC gc) { m_gc = gc; }
|
void setGC(GC gc) { m_gc = gc; }
|
||||||
/// sets background pixmap, this will override background color
|
/// sets background pixmap, this will override background color
|
||||||
void setBackgroundPixmap(Pixmap pm);
|
void setBackgroundPixmap(Pixmap pm);
|
||||||
|
@ -70,6 +76,7 @@ public:
|
||||||
virtual void buttonReleaseEvent(XButtonEvent &event);
|
virtual void buttonReleaseEvent(XButtonEvent &event);
|
||||||
virtual void exposeEvent(XExposeEvent &event);
|
virtual void exposeEvent(XExposeEvent &event);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// @return true if the button is pressed, else false
|
/// @return true if the button is pressed, else false
|
||||||
bool pressed() const { return m_pressed; }
|
bool pressed() const { return m_pressed; }
|
||||||
/**
|
/**
|
||||||
|
@ -84,13 +91,18 @@ public:
|
||||||
FbWindow &window() { return m_win; }
|
FbWindow &window() { return m_win; }
|
||||||
const FbWindow &window() const { return m_win; }
|
const FbWindow &window() const { return m_win; }
|
||||||
GC gc() const { return m_gc; }
|
GC gc() const { return m_gc; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FbTk::FbWindow m_win; ///< window for button
|
FbTk::FbWindow m_win; ///< window for button
|
||||||
Pixmap m_foreground_pm; ///< foreground pixmap
|
Pixmap m_foreground_pm; ///< foreground pixmap
|
||||||
|
Pixmap m_background_pm; ///< background pixmap
|
||||||
|
Color m_background_color; ///< background color
|
||||||
Pixmap m_pressed_pm; ///< pressed pixmap
|
Pixmap m_pressed_pm; ///< pressed pixmap
|
||||||
GC m_gc; ///< graphic context for button
|
GC m_gc; ///< graphic context for button
|
||||||
bool m_pressed; ///< if the button is pressed
|
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
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue