From 7298f23b0de460c219abac56dcf2fcba08928ec1 Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Tue, 6 May 2003 23:58:08 +0000
Subject: added stuck pixmap, and unfocus pixmaps

---
 src/WinButton.cc      | 125 +++++++++++++++++++++++++++++++++++++++-----------
 src/WinButtonTheme.cc |  11 ++++-
 src/WinButtonTheme.hh |  26 ++++++-----
 3 files changed, 123 insertions(+), 39 deletions(-)

diff --git a/src/WinButton.cc b/src/WinButton.cc
index 650f312..17ad179 100644
--- a/src/WinButton.cc
+++ b/src/WinButton.cc
@@ -19,16 +19,13 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-/// $Id: WinButton.cc,v 1.4 2003/04/28 22:41:28 fluxgen Exp $
+/// $Id: WinButton.cc,v 1.5 2003/05/06 23:58:08 fluxgen Exp $
 
 #include "WinButton.hh"
 #include "App.hh"
 #include "Window.hh"
 #include "WinButtonTheme.hh"
 
-#include <iostream>
-using namespace std;
-
 namespace {
 
 inline void scale(const FbTk::Button &btn, WinButtonTheme::PixmapWithMask &pm) {
@@ -46,15 +43,27 @@ void updateScale(const FbTk::Button &btn, WinButtonTheme &theme) {
 
     // we need to scale our pixmaps to right size
     scale(btn, theme.closePixmap());
+    scale(btn, theme.closeUnfocusPixmap());
     scale(btn, theme.closePressedPixmap());
+
     scale(btn, theme.maximizePixmap());
+    scale(btn, theme.maximizeUnfocusPixmap());
     scale(btn, theme.maximizePressedPixmap());
+
     scale(btn, theme.iconifyPixmap());
+    scale(btn, theme.iconifyUnfocusPixmap());
     scale(btn, theme.iconifyPressedPixmap());
+
     scale(btn, theme.shadePixmap());
+    scale(btn, theme.shadeUnfocusPixmap());
     scale(btn, theme.shadePressedPixmap());
+
     scale(btn, theme.stickPixmap());
+    scale(btn, theme.stickUnfocusPixmap());
     scale(btn, theme.stickPressedPixmap());
+
+    scale(btn, theme.stuckPixmap());
+    scale(btn, theme.stuckUnfocusPixmap());
 }
 
 };
@@ -91,9 +100,18 @@ void WinButton::drawType() {
                                              maximizePressedPixmap().
                                              pixmap_scaled.drawable());
             } else if (m_theme.maximizePixmap().pixmap_scaled.drawable()) {
-                window().setBackgroundPixmap(m_theme.
-                                             maximizePixmap().
-                                             pixmap_scaled.drawable());
+                // check focus 
+                if (!m_listen_to.isFocused() && 
+                    m_theme.maximizeUnfocusPixmap().pixmap_scaled.drawable() != 0) {
+                    // not focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 maximizeUnfocusPixmap().
+                                                 pixmap_scaled.drawable());
+                } else { // focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 maximizePixmap().
+                                                 pixmap_scaled.drawable());
+                }
             }
             
             window().clear();
@@ -114,9 +132,18 @@ void WinButton::drawType() {
                                              iconifyPressedPixmap().
                                              pixmap_scaled.drawable());
             } else if (m_theme.iconifyPixmap().pixmap_scaled.drawable()){
-                window().setBackgroundPixmap(m_theme.
-                                             iconifyPixmap().
-                                             pixmap_scaled.drawable());
+                // check focus 
+                if (!m_listen_to.isFocused() && 
+                    m_theme.iconifyUnfocusPixmap().pixmap_scaled.drawable() != 0) {
+                    // not focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 iconifyUnfocusPixmap().
+                                                 pixmap_scaled.drawable());
+                } else { // focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 iconifyPixmap().
+                                                 pixmap_scaled.drawable());
+                }
             }
             
             window().clear();
@@ -130,17 +157,45 @@ void WinButton::drawType() {
         break;
     case STICK:
         if (m_theme.stickPixmap().pixmap_scaled.drawable() != 0) {
-            if (pressed()) { 
-                window().setBackgroundPixmap(m_theme.
-                                             stickPressedPixmap().
-                                             pixmap_scaled.drawable());
+            if (m_listen_to.isStuck() && 
+                m_theme.stuckPixmap().pixmap_scaled.drawable() &&
+                ! pressed()) { // we're using the same pixmap for pressed as in not stuck
+                // check focus 
+                if (!m_listen_to.isFocused() && 
+                    m_theme.stuckUnfocusPixmap().pixmap_scaled.drawable() != 0) {
+                    // not focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 stuckUnfocusPixmap().
+                                                 pixmap_scaled.drawable());
+                } else { // focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 stuckPixmap().
+                                                 pixmap_scaled.drawable());
+                }
+            } else { // not stuck
+
+                if (pressed()) { 
+                    window().setBackgroundPixmap(m_theme.
+                                                 stickPressedPixmap().
+                                                 pixmap_scaled.drawable());
+
+                } else if (m_theme.stickPixmap().pixmap_scaled.drawable()) {
+                    // check focus 
+                    if (!m_listen_to.isFocused() && 
+                        m_theme.stickUnfocusPixmap().pixmap_scaled.drawable() != 0) {
+                        // not focused
+                        window().setBackgroundPixmap(m_theme.
+                                                     stickUnfocusPixmap().
+                                                     pixmap_scaled.drawable());
+                    } else { // focused
+                        window().setBackgroundPixmap(m_theme.
+                                                     stickPixmap().
+                                                     pixmap_scaled.drawable());
+                    }
+
+                }
+            } // end if stuck
 
-            } else if (m_theme.closePixmap().pixmap_scaled.drawable()) {
-                window().setBackgroundPixmap(m_theme.
-                                             stickPixmap().
-                                             pixmap_scaled.drawable());
-            }
-            
             window().clear();
             
         } else {
@@ -166,9 +221,18 @@ void WinButton::drawType() {
                                              pixmap_scaled.drawable());
 
             } else if (m_theme.closePixmap().pixmap_scaled.drawable()) {
-                window().setBackgroundPixmap(m_theme.
-                                             closePixmap().
-                                             pixmap_scaled.drawable());
+                // check focus 
+                if (!m_listen_to.isFocused() && 
+                    m_theme.closeUnfocusPixmap().pixmap_scaled.drawable() != 0) {
+                    // not focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 closeUnfocusPixmap().
+                                                 pixmap_scaled.drawable());
+                } else { // focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 closePixmap().
+                                                 pixmap_scaled.drawable());
+                }
             }
             
             window().clear();
@@ -191,9 +255,18 @@ void WinButton::drawType() {
                                              shadePressedPixmap().
                                              pixmap_scaled.drawable());
             } else if (m_theme.shadePixmap().pixmap_scaled.drawable()) {
-                window().setBackgroundPixmap(m_theme.
-                                             shadePixmap().
-                                             pixmap_scaled.drawable());
+                // check focus 
+                if (!m_listen_to.isFocused() && 
+                    m_theme.shadeUnfocusPixmap().pixmap_scaled.drawable() != 0) {
+                    // not focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 shadeUnfocusPixmap().
+                                                 pixmap_scaled.drawable());
+                } else { // focused
+                    window().setBackgroundPixmap(m_theme.
+                                                 shadePixmap().
+                                                 pixmap_scaled.drawable());
+                }
             }
             
             window().clear();            
diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc
index c67675e..d90d4c8 100644
--- a/src/WinButtonTheme.cc
+++ b/src/WinButtonTheme.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: WinButtonTheme.cc,v 1.2 2003/04/28 22:33:19 fluxgen Exp $
+// $Id: WinButtonTheme.cc,v 1.3 2003/05/06 23:56:46 fluxgen Exp $
 
 #include "WinButtonTheme.hh"
 
@@ -80,15 +80,22 @@ setFromString(const char *str) {
 WinButtonTheme::WinButtonTheme(int screen_num):
     FbTk::Theme(screen_num),
     m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"),
+    m_close_unfocus_pm(*this, "window.close.unfocus.pixmap", "Window.Close.Unfocus.Pixmap"),
     m_close_pressed_pm(*this, "window.close.pressed.pixmap", "Window.Close.Pressed.Pixmap"),
     m_maximize_pm(*this, "window.maximize.pixmap", "Window.Maximize.Pixmap"),
+    m_maximize_unfocus_pm(*this, "window.maximize.unfocus.pixmap", "Window.Maximize.Unfocus.pixmap"),
     m_maximize_pressed_pm(*this, "window.maximize.pressed.pixmap", "Window.Maximize.Pressed.Pixmap"),
     m_iconify_pm(*this, "window.iconify.pixmap", "Window.Iconify.Pixmap"),
+    m_iconify_unfocus_pm(*this, "window.iconify.unfocus.pixmap", "Window.Iconify.Unfocus.Pixmap"),    
     m_iconify_pressed_pm(*this, "window.iconify.pressed.pixmap", "Window.Iconify.Pressed.Pixmap"),
     m_shade_pm(*this, "window.shade.pixmap", "Window.Shade.Pixmap"),
+    m_shade_unfocus_pm(*this, "window.shade.unfocus.pixmap", "Window.Shade.Unfocus.Pixmap"),
     m_shade_pressed_pm(*this, "window.shade.pressed.pixmap", "Window.Shade.Pressed.Pixmap"),
     m_stick_pm(*this, "window.stick.pixmap", "Window.Stick.Pixmap"),
-    m_stick_pressed_pm(*this, "window.stick.pressed.pixmap", "Window.Stick.Pressed.Pixmap") {
+    m_stick_unfocus_pm(*this, "window.stick.unfocus.pixmap", "Window.Stick.Unfocus.Pixmap"),
+    m_stick_pressed_pm(*this, "window.stick.pressed.pixmap", "Window.Stick.Pressed.Pixmap"),
+    m_stuck_pm(*this, "window.stuck.pixmap", "Window.Stuck.Pixmap"),
+    m_stuck_unfocus_pm(*this, "window.stuck.unfocus.pixmap", "Window.Stuck.Unfocus.Pixmap") {
 
 }
 
diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh
index 6cbe69c..af2f011 100644
--- a/src/WinButtonTheme.hh
+++ b/src/WinButtonTheme.hh
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: WinButtonTheme.hh,v 1.1 2003/04/28 22:30:34 fluxgen Exp $
+// $Id: WinButtonTheme.hh,v 1.2 2003/05/06 23:52:55 fluxgen Exp $
 
 #ifndef WINBUTTONTHEME_HH
 #define WINBUTTONTHEME_HH
@@ -44,42 +44,46 @@ public:
 
     inline const PixmapWithMask &closePixmap() const { return *m_close_pm; }
     inline PixmapWithMask &closePixmap() { return *m_close_pm; }
-
+    inline PixmapWithMask &closeUnfocusPixmap() { return *m_close_unfocus_pm; }
     inline const PixmapWithMask &closePressedPixmap() const { return *m_close_pressed_pm; }
     inline PixmapWithMask &closePressedPixmap() { return *m_close_pressed_pm; }
 
     inline const PixmapWithMask &maximizePixmap() const { return *m_maximize_pm; }
     inline PixmapWithMask &maximizePixmap() { return *m_maximize_pm; }
-
+    inline PixmapWithMask &maximizeUnfocusPixmap() { return *m_maximize_unfocus_pm; }
     inline const PixmapWithMask &maximizePressedPixmap() const { return *m_maximize_pressed_pm; }
     inline PixmapWithMask &maximizePressedPixmap() { return *m_maximize_pressed_pm; }
 
     inline const PixmapWithMask &iconifyPixmap() const { return *m_iconify_pm; }
     inline PixmapWithMask &iconifyPixmap() { return *m_iconify_pm; }
-
+    inline PixmapWithMask &iconifyUnfocusPixmap() { return *m_iconify_unfocus_pm; }
     inline const PixmapWithMask &iconifyPressedPixmap() const { return *m_iconify_pressed_pm; }
     inline PixmapWithMask &iconifyPressedPixmap() { return *m_iconify_pressed_pm; }
 
     inline const PixmapWithMask &stickPixmap() const { return *m_stick_pm; }
     inline PixmapWithMask &stickPixmap() { return *m_stick_pm; }
-
+    inline PixmapWithMask &stickUnfocusPixmap() { return *m_stick_unfocus_pm; }
     inline const PixmapWithMask &stickPressedPixmap() const { return *m_stick_pressed_pm; }
     inline PixmapWithMask &stickPressedPixmap() { return *m_stick_pressed_pm; }
 
+    inline PixmapWithMask &stuckPixmap() { return *m_stuck_pm; }
+    inline PixmapWithMask &stuckUnfocusPixmap() { return *m_stuck_unfocus_pm; }
+
     inline const PixmapWithMask &shadePixmap() const { return *m_shade_pm; }
     inline PixmapWithMask &shadePixmap() { return *m_shade_pm; }
-
+    inline PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; }
     inline const PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; }
     inline PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; }
     FbTk::Subject &reconfigSig() { return m_reconf_sig; }
 private:
     FbTk::Subject m_reconf_sig;
 
-    FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_pressed_pm;
-    FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_pressed_pm;
-    FbTk::ThemeItem<PixmapWithMask> m_iconify_pm, m_iconify_pressed_pm;
-    FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_pressed_pm;
-    FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_pressed_pm;
+    FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;
+    FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm;
+    FbTk::ThemeItem<PixmapWithMask> m_iconify_pm, m_iconify_unfocus_pm, m_iconify_pressed_pm;
+    FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm;
+    FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm;    
+    FbTk::ThemeItem<PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm; 
 };
 
 #endif // WINBUTTONTHEME_HH
-- 
cgit v0.11.2