Code

Cleanup on encapsulation. Addition of initial widescreen detection.
authorJon A. Cruz <jon@joncruz.org>
Tue, 1 Jun 2010 08:26:40 +0000 (01:26 -0700)
committerJon A. Cruz <jon@joncruz.org>
Tue, 1 Jun 2010 08:26:40 +0000 (01:26 -0700)
src/ui/uxmanager.cpp
src/ui/uxmanager.h

index 3c6f85b915ad9b30ef142626768108159fb1740f..ae4de62e368351c1b6b41ccc906fe3c8bcda065a 100644 (file)
@@ -20,6 +20,7 @@
 #include "widgets/toolbox.h"
 #include "widgets/desktop-widget.h"
 #include "preferences.h"
+#include "gdkmm/screen.h"
 
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
@@ -44,17 +45,45 @@ namespace UI {
 
 UXManager* instance = 0;
 
+class UXManagerImpl : public UXManager
+{
+public:
+    UXManagerImpl();
+    virtual ~UXManagerImpl();
+
+    virtual void setTask(SPDesktop* dt, gint val);
+    virtual void addTrack( SPDesktopWidget* dtw );
+    virtual void delTrack( SPDesktopWidget* dtw );
+    virtual void connectToDesktop( vector<GtkWidget *> const & toolboxes, SPDesktop *desktop );
+
+    virtual bool isFloatWindowProblem() const;
+    virtual bool isWidescreen() const;
+
+private:
+    bool _floatwindowIssues;
+    bool _widescreen;
+};
+
 UXManager* UXManager::getInstance()
 {
     if (!instance) {
-        instance = new UXManager();
+        instance = new UXManagerImpl();
     }
     return instance;
 }
 
 
-UXManager::UXManager() :
-    floatwindowIssues(false)
+UXManager::UXManager()
+{
+}
+
+UXManager::~UXManager()
+{
+}
+
+UXManagerImpl::UXManagerImpl() :
+    _floatwindowIssues(false),
+    _widescreen(false)
 {
     ege::TagSet tags;
     tags.setLang("en");
@@ -68,24 +97,39 @@ UXManager::UXManager() :
 
     //if (g_ascii_strcasecmp( wmName, UNKOWN_WINDOW_MANAGER_NAME ) == 0) {
     if (g_ascii_strcasecmp( wmName, KDE_WINDOW_MANAGER_NAME ) == 0) {
-        floatwindowIssues = true;
+        _floatwindowIssues = true;
     }
 #elif defined(GDK_WINDOWING_WIN32)
-    floatwindowIssues = true;
+    _floatwindowIssues = true;
 #endif // GDK_WINDOWING_WIN32
+
+
+    Glib::RefPtr<Gdk::Screen> defaultScreen = Gdk::Screen::get_default();
+    if (defaultScreen) {
+        int width = defaultScreen->get_width();
+        int height = defaultScreen->get_height();
+        gdouble aspect = static_cast<gdouble>(width) / static_cast<gdouble>(height);
+        if (aspect > 1.4) {
+            _widescreen = true;
+        }
+    }
 }
 
-UXManager::~UXManager()
+UXManagerImpl::~UXManagerImpl()
 {
 }
 
+bool UXManagerImpl::isFloatWindowProblem() const
+{
+    return _floatwindowIssues;
+}
 
-bool UXManager::isFloatWindowProblem() const
+bool UXManagerImpl::isWidescreen() const
 {
-    return floatwindowIssues;
+    return _widescreen;
 }
 
-void UXManager::setTask(SPDesktop* dt, gint val)
+void UXManagerImpl::setTask(SPDesktop* dt, gint val)
 {
     for (vector<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it) {
         SPDesktopWidget* dtw = *it;
@@ -124,14 +168,14 @@ void UXManager::setTask(SPDesktop* dt, gint val)
 }
 
 
-void UXManager::addTrack( SPDesktopWidget* dtw )
+void UXManagerImpl::addTrack( SPDesktopWidget* dtw )
 {
     if (std::find(dtws.begin(), dtws.end(), dtw) == dtws.end()) {
         dtws.push_back(dtw);
     }
 }
 
-void UXManager::delTrack( SPDesktopWidget* dtw )
+void UXManagerImpl::delTrack( SPDesktopWidget* dtw )
 {
     vector<SPDesktopWidget*>::iterator iter = std::find(dtws.begin(), dtws.end(), dtw);
     if (iter != dtws.end()) {
@@ -139,9 +183,9 @@ void UXManager::delTrack( SPDesktopWidget* dtw )
     }
 }
 
-void UXManager::connectToDesktop( vector<GtkWidget *> const & toolboxes, SPDesktop *desktop )
+void UXManagerImpl::connectToDesktop( vector<GtkWidget *> const & toolboxes, SPDesktop *desktop )
 {
-//static map<SPDesktop*, vector<GtkWidget*> > trackedBoxes;
+    //static map<SPDesktop*, vector<GtkWidget*> > trackedBoxes;
 
     for (vector<GtkWidget*>::const_iterator it = toolboxes.begin(); it != toolboxes.end(); ++it ) {
         GtkWidget* toolbox = *it;
index aecda2b5e7efaf68ee9b3ef63c494049f8649d91..7f7cc6ecb3a52cdabaf214b2272cc097cc10fece 100644 (file)
@@ -34,19 +34,22 @@ public:
     static UXManager* getInstance();
     virtual ~UXManager();
 
-    void addTrack( SPDesktopWidget* dtw );
-    void delTrack( SPDesktopWidget* dtw );
+    virtual void addTrack( SPDesktopWidget* dtw ) = 0;
+    virtual void delTrack( SPDesktopWidget* dtw ) = 0;
 
-    void connectToDesktop( std::vector<GtkWidget *> const & toolboxes, SPDesktop *desktop );
+    virtual void connectToDesktop( std::vector<GtkWidget *> const & toolboxes, SPDesktop *desktop ) = 0;
 
-    void setTask(SPDesktop* dt, gint val);
+    virtual void setTask(SPDesktop* dt, gint val) = 0;
 
-    bool isFloatWindowProblem() const;
+    virtual bool isFloatWindowProblem() const = 0;
+    virtual bool isWidescreen() const = 0;
 
-private:
+protected:
     UXManager();
 
-    bool floatwindowIssues;
+private:
+    UXManager( UXManager const & );
+    UXManager & operator=( UXManager const & );
 };
 
 } // namespace UI