From 2aef1e67c3fa06157b7607462463f796e881c215 Mon Sep 17 00:00:00 2001 From: fluxgen <fluxgen> Date: Mon, 13 Oct 2003 23:43:11 +0000 Subject: added pressed color --- src/FbTk/Button.cc | 11 ++++++++++- src/FbTk/Button.hh | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc index bcbde70..03e1386 100644 --- a/src/FbTk/Button.cc +++ b/src/FbTk/Button.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Button.cc,v 1.15 2003/09/10 21:24:36 fluxgen Exp $ +// $Id: Button.cc,v 1.16 2003/10/13 23:43:11 fluxgen Exp $ #include "Button.hh" @@ -36,6 +36,7 @@ Button::Button(int screen_num, int x, int y, m_foreground_pm(0), m_background_pm(0), m_pressed_pm(0), + m_pressed_color("black", screen_num), m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)), m_pressed(false) { @@ -50,6 +51,7 @@ Button::Button(const FbWindow &parent, int x, int y, m_foreground_pm(0), m_background_pm(0), m_pressed_pm(0), + m_pressed_color("black", parent.screenNumber()), m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())), m_pressed(false) { // add this to eventmanager @@ -76,6 +78,10 @@ void Button::setPressedPixmap(Pixmap pm) { m_pressed_pm = pm; } +void Button::setPressedColor(const FbTk::Color &color) { + m_pressed_color = color; +} + void Button::setBackgroundColor(const Color &color) { m_background_pm = 0; // we're using background color now m_background_color = color; @@ -90,6 +96,9 @@ void Button::setBackgroundPixmap(Pixmap pm) { void Button::buttonPressEvent(XButtonEvent &event) { if (m_pressed_pm != 0) FbWindow::setBackgroundPixmap(m_pressed_pm); + else if (m_pressed_color.isAllocated()) + FbWindow::setBackgroundColor(m_pressed_color); + m_pressed = true; clear(); updateTransparent(); diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh index 2bbe74b..dbbdeda 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.6 2003/09/10 21:23:36 fluxgen Exp $ +// $Id: Button.hh,v 1.7 2003/10/13 23:43:11 fluxgen Exp $ #ifndef FBTK_BUTTON_HH #define FBTK_BUTTON_HH @@ -50,6 +50,7 @@ public: void setPixmap(Pixmap pm); /// sets the pixmap to be viewed when the button is pressed void setPressedPixmap(Pixmap pm); + void setPressedColor(const FbTk::Color &color); /// sets graphic context for drawing void setGC(GC gc) { m_gc = gc; } /// sets background pixmap, this will override background color @@ -78,6 +79,7 @@ private: Pixmap m_background_pm; ///< background pixmap Color m_background_color; ///< background color Pixmap m_pressed_pm; ///< pressed pixmap + Color m_pressed_color; GC m_gc; ///< graphic context for button bool m_pressed; ///< if the button is pressed RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num -- cgit v0.11.2