summaryrefslogtreecommitdiff
path: root/NxWidgets/nxwm/include
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-30 20:38:44 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-30 20:38:44 +0000
commit9384da7066d128ab6a0fb7616a671047c374cd4a (patch)
tree4f4f27a4c48bebaa41673da9518e25f6afc3ad2a /NxWidgets/nxwm/include
parent284cd6923b521898c0927992fab77593ad797b4a (diff)
downloadnuttx-9384da7066d128ab6a0fb7616a671047c374cd4a.tar.gz
nuttx-9384da7066d128ab6a0fb7616a671047c374cd4a.tar.bz2
nuttx-9384da7066d128ab6a0fb7616a671047c374cd4a.zip
Completes first cut at task bar
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4678 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/nxwm/include')
-rw-r--r--NxWidgets/nxwm/include/capplicationwindow.hxx13
-rw-r--r--NxWidgets/nxwm/include/cbackgroundimage.hxx88
-rw-r--r--NxWidgets/nxwm/include/cstartwindow.hxx5
-rw-r--r--NxWidgets/nxwm/include/ctaskbar.hxx142
-rw-r--r--NxWidgets/nxwm/include/iapplication.hxx61
-rw-r--r--NxWidgets/nxwm/include/nxwmconfig.hxx51
-rw-r--r--NxWidgets/nxwm/include/nxwmglyphs.hxx1
7 files changed, 239 insertions, 122 deletions
diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx
index 805df4184..3d868e576 100644
--- a/NxWidgets/nxwm/include/capplicationwindow.hxx
+++ b/NxWidgets/nxwm/include/capplicationwindow.hxx
@@ -110,24 +110,23 @@ namespace NxWM
void handleClickEvent(const NXWidgets::CWidgetEventArgs &e);
- /**
- * CApplicationWindow Destructor
- */
-
- ~CApplicationWindow(void);
-
public:
/**
* CApplicationWindow Constructor
*
- * @param taskbar. A pointer to the parent task bar instance
* @param window. The window to be used by this application.
*/
CApplicationWindow(NXWidgets::CNxTkWindow *window);
/**
+ * CApplicationWindow Destructor
+ */
+
+ ~CApplicationWindow(void);
+
+ /**
* Initialize window. Window initialization is separate from
* object instantiation so that failures can be reported.
*
diff --git a/NxWidgets/nxwm/include/cbackgroundimage.hxx b/NxWidgets/nxwm/include/cbackgroundimage.hxx
deleted file mode 100644
index 89ca469cd..000000000
--- a/NxWidgets/nxwm/include/cbackgroundimage.hxx
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
- * NxWidgets/nxwm/include/cnxbackimage.hxx
- *
- * Copyright (C) 2012 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <gnutt@nuttx.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
- * me be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#ifndef __NXWM_INCLUDE_CBACKGROUNDIMAGE_HXX
-#define __NXWM_INCLUDE_CBACKGROUNDIMAGE_HXX
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include "nxconfig.hxx"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Implementation Class Definition
- ****************************************************************************/
-
-#if defined(__cplusplus)
-
-namespace NxWM
-{
- /**
- * This class describes the NX windo manager's background image.
- */
-
- class CBackgroundImage : public NXWidgets::CImage
- {
- private:
- NXWidgets::CWidgetControl *m_widgetControl; // The controlling widget for the window
-
- public:
- /**
- * CBackgroundImage Constructor
- */
-
- CBackgroundImage(void);
-
- /**
- * CBackgroundImage Destructor
- */
-
- ~CBackgroundImage(void);
- };
-}
-
-#endif // __cplusplus
-#endif // __NXWM_INCLUDE_CBACKGROUNDIMAGE_HXX
diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx
index c47b85d83..2a1dac088 100644
--- a/NxWidgets/nxwm/include/cstartwindow.hxx
+++ b/NxWidgets/nxwm/include/cstartwindow.hxx
@@ -125,9 +125,10 @@ namespace NxWM
* setting up the start window is:
*
* 1. Call CTaskBar::openApplicationWindow to create a window for the start window,
- * 2. Call CStartMenu::addApplication numerous times to install applications
+ * 2. Use the window to instantiate CStartMenu
+ * 3. Call CStartMenu::addApplication numerous times to install applications
* in the start window.
- * 3. Call CTaskBar::startApplication (initially minimized) to start the start
+ * 4. Call CTaskBar::startApplication (initially minimized) to start the start
* window application.
*
* @param application. The new application to add to the start window
diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx
index 0c420a0e2..ef25fd563 100644
--- a/NxWidgets/nxwm/include/ctaskbar.hxx
+++ b/NxWidgets/nxwm/include/ctaskbar.hxx
@@ -44,7 +44,7 @@
#include "nxconfig.hxx"
#include "tnxarray.hxx"
-#include "inxwindow.hxx"
+#include "cnxwindow.hxx"
#include "cnxserver.hxx"
#include "cwidgeteventhandler.hxx"
#include "cwidgeteventargs.hxx"
@@ -64,15 +64,41 @@
namespace NxWM
{
/**
- * This class describes the NX window manager's task bar
+ * This class describes the NX window manager's task bar. That task bar is,
+ * of course, used to dock active applications. But in NxWM, it is also
+ * the heart of the window manager: It inherits for CNxServer and, hence,
+ * represents the NX server itself. It also then serves as the NxWM
+ * window factory.
+ *
+ * Why do it this way? The only reason is so that if you have an instance
+ * of CTaskbar, you have everything you need to manage new applications.
+ * It might have been a better decision to separate the window factory into
+ * a separate class instead of making the task bar of such central importance
+ * (and I may still do that someday)
*/
class CTaskbar : public NXWidgets::CNxServer, private NXWidgets::CWidgetEventHandler
{
private:
- NXWidgets::INxWindow *m_taskbar; /**< The toolbar window */
- NXWidgets::INxWindow *m_background; /**< The background window */
- TNxArray<IApplication*> m_applications; /**< List of apps in the task bar */
+ /**
+ * This structgure represents an application and its associated icon image
+ */
+
+ struct STaskbarSlot
+ {
+ IApplication *app; /**< A reference to the icon */
+ NXWidgets::CImage *image; /**< The icon image that goes with the application */
+ };
+
+ /**
+ * Taskbar state
+ */
+
+ NXWidgets::CNxWindow *m_taskbar; /**< The task bar window */
+ NXWidgets::CNxWindow *m_background; /**< The background window */
+ NXWidgets::CImage *m_backImage; /**< The background image */
+ IApplication *m_topapp; /**< The top application in the hierarchy */
+ TNxArray<struct STaskbarSlot> m_slots; /**< List of application slots in the task bar */
/**
* Connect to the server
@@ -120,12 +146,12 @@ namespace NxWM
void setApplicationGeometry(NXWidgets::INxWindow *window);
/**
- * Create the toolbar window.
+ * Create the task bar window.
*
* @return true on success
*/
- bool createToolbarWindow(void);
+ bool createTaskbarWindow(void);
/**
* Create the background window.
@@ -135,6 +161,38 @@ namespace NxWM
bool createBackgroundWindow(void);
+ /**
+ * Create the background image.
+ *
+ * @return true on success
+ */
+
+ bool createBackgroundImage(void);
+
+ /**
+ * (Re-)draw the task bar window.
+ *
+ * @return true on success
+ */
+
+ bool redrawTaskbarWindow(void);
+
+ /**
+ * (Re-)draw the background window.
+ *
+ * @return true on success
+ */
+
+ bool redrawBackgroundWindow(void);
+
+ /**
+ * Redraw the last application in the list of application maintained by
+ * the task bar.
+ *
+ * @return true on success
+ */
+
+ bool redrawApplicationWindow(void);
/**
* Handle a mouse button click event.
@@ -160,15 +218,45 @@ namespace NxWM
CTaskbar(void);
/**
+ * Initialize task bar. Task bar initialization is separate from
+ * object instantiation so that failures can be reported. The window
+ * manager start-up sequence is:
+ *
+ * 1. Create the CTaskbar instance,
+ * 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
+ * inherits the connect method from CNxServer),
+ * 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
+ * 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
+ * 5. Call CTaskBar::startWindowManager() to start the display with applications in place
+ *
+ * CTaskbar::initWindowManager() prepares the task bar to receive applications.
+ * CTaskBar::startWindowManager() brings the window manager up with those applications
+ * in place.
+ *
+ * @return True if the window was successfully initialized.
+ */
+
+ bool initWindowManager(void);
+
+ /**
* Start the window manager and present the initial displays. The window
* manager start-up sequence is:
*
* 1. Create the CTaskbar instance,
- * 2. Call CTaskBar::startApplication repeatedly to add applications to the task bar
- * 3. Call CTaskBar::startWindowManager to start the display with applications in place
+ * 2. Call the CTaskbar::connect() method to connect to the NX server (CTaskbar
+ * inherits the connect method from CNxServer),
+ * 3. Call the CTaskbar::initWindowManager() method to initialize the task bar.
+ * 4. Call CTaskBar::startApplication repeatedly to add applications to the task bar
+ * 5. Call CTaskBar::startWindowManager to start the display with applications in place
*
- * startWindowManager will present the taskar and the background image. The
- * initial taskbar will contain only the start window icon.
+ * CTaskbar::initWindowManager() prepares the task bar to receive applications.
+ * CTaskBar::startWindowManager() brings the window manager up with those applications
+ * in place.
+ *
+ * CTaskBar::startWindowManager() will present the task bar and the background image.
+ * The The initial taskbar will contain only the start window icon.
+ *
+ * @return true on success
*/
bool startWindowManager(void);
@@ -214,23 +302,45 @@ namespace NxWM
bool startApplication(IApplication *app, bool minimized);
/**
- * Hide an application by moving its window to the bottom.
+ * Move window to the top of the hierarchy and re-draw it. This method
+ * does nothing if the application is minimized.
*
- * @param application. The new application to add to the task bar
+ * @param app. The new application to show
+ * @return true on success
+ */
+
+ bool topApplication(IApplication *app);
+
+ /**
+ * Maximize an application by moving its window to the top of the hierarchy
+ * and re-drawing it. If the application was already maximized, then this
+ * method is equivalent to topApplication().
+ *
+ * @param app. The new application to add to the task bar
+ * @return true on success
+ */
+
+ bool maximizeApplication(IApplication *app);
+
+ /**
+ * Minimize an application by moving its window to the bottom of the
+ * and redrawing the next visible appliation.
+ *
+ * @param app. The new application to add to the task bar
* @return true on success
*/
- bool hideApplication(IApplication *application);
+ bool minimizeApplication(IApplication *app);
/**
* Destroy an application. Move its window to the bottom and remove its
* icon from the task bar.
*
- * @param application. The new application to remove from the task bar
+ * @param app. The new application to remove from the task bar
* @return true on success
*/
- bool stopApplication(IApplication *application);
+ bool stopApplication(IApplication *app);
};
}
diff --git a/NxWidgets/nxwm/include/iapplication.hxx b/NxWidgets/nxwm/include/iapplication.hxx
index 1056e18c0..88583d4c5 100644
--- a/NxWidgets/nxwm/include/iapplication.hxx
+++ b/NxWidgets/nxwm/include/iapplication.hxx
@@ -64,6 +64,14 @@ namespace NxWM
class IApplication
{
+ protected:
+ // These values (and the accessors that go with them) violate the "purity"
+ // of the base class. These are really part of the task bar implementation:
+ // Each application provides this state information needed by the taskbar.
+
+ bool m_minimized; /**< True if the application is minimized */
+ bool m_topapp; /**< True if this application is at the top in the hiearchy */
+
public:
/**
* Each implementation of IApplication must provide a method to recover
@@ -91,7 +99,7 @@ namespace NxWM
virtual NXWidgets::CNxString getName(void) = 0;
/**
- * Start the application.
+ * Start the application (pehaps in the minimized state).
*/
virtual void run(void) = 0;
@@ -101,6 +109,57 @@ namespace NxWM
*/
virtual void stop(void) = 0;
+
+ /**
+ * Re-draw the application window. This method is call from CTaskbar
+ * when the application window must be displayed
+ */
+
+ virtual void redraw(void) = 0;
+
+ /**
+ * Set the application's minimized state
+ *
+ * @param minimized. True if the application is minimized
+ */
+
+ inline void setMinimized(bool minimized)
+ {
+ m_minimized = minimized;
+ }
+
+ /**
+ * Set the application's top state
+ *
+ * @param topapp. True if the application is the new top application
+ */
+
+ inline void setTopApplication(bool topapp)
+ {
+ m_topapp = topapp;
+ }
+
+ /**
+ * Get the application's minimized state
+ *
+ * @return True if the application is minimized
+ */
+
+ inline bool isMinimized(void) const
+ {
+ return m_minimized;
+ }
+
+ /**
+ * Return true if this is the top application
+ *
+ * @return True if the application is the new top application
+ */
+
+ inline bool isTopApplication(void) const
+ {
+ return m_topapp;
+ }
};
}
diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx
index 178cc37a2..d416bf8f0 100644
--- a/NxWidgets/nxwm/include/nxwmconfig.hxx
+++ b/NxWidgets/nxwm/include/nxwmconfig.hxx
@@ -91,7 +91,7 @@
#endif
/**
- * Default selected forecround color
+ * Default selected foreground color
*/
#ifndef CONFIG_NXWM_DEFAULT_SELECTEDFOREGROUNDCOLOR
@@ -99,6 +99,18 @@
#endif
/**
+ * Border colors
+ */
+
+#ifndef CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR
+# define CONFIG_NXWM_DEFAULT_SHINEEDGECOLOR MKRGB(248,248,248)
+#endif
+
+#ifndef CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR
+# define CONFIG_NXWM_DEFAULT_SHADOWEDGECOLOR MKRGB(0,0,0)
+#endif
+
+/**
* The default font color
*/
@@ -115,15 +127,21 @@
#endif
/* Task Bar Configuation ***************************************************/
-/* At present, all icons are 25 pixels in "widgth" and, hence require a
- * task bar of at least that size.
+/**
+ * Horizontal and vertical spacing of icons in the task bar.
*/
-#ifndef CONFIG_NXWM_TASKBAR_WIDTH
-# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*2)
+#ifndef CONFIG_NXWM_TASKBAR_VSPACING
+# define CONFIG_NXWM_TASKBAR_VSPACING (2)
#endif
-/* Check task bar location */
+#ifndef CONFIG_NXWM_TASKBAR_HSPACING
+# define CONFIG_NXWM_TASKBAR_HSPACING (2)
+#endif
+
+/**
+ * Check task bar location
+ */
#if defined(CONFIG_NXWM_TASKBAR_TOP)
# if defined(CONFIG_NXWM_TASKBAR_BOTTOM) || defined (CONFIG_NXWM_TASKBAR_LEFT) || defined (CONFIG_NXWM_TASKBAR_RIGHT)
@@ -142,12 +160,29 @@
# define CONFIG_NXWM_TASKBAR_TOP 1
#endif
+/**
+ * At present, all icons are 25 pixels in "widgth" and, hence require a
+ * task bar of at least that size.
+ */
+
+#ifndef CONFIG_NXWM_TASKBAR_WIDTH
+# if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM)
+# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*CONFIG_NXWM_TASKBAR_HSPACING)
+# else
+# define CONFIG_NXWM_TASKBAR_WIDTH (25+2*CONFIG_NXWM_TASKBAR_VSPACING)
+# endif
+#endif
+
+/* Background Image **********************************************************/
+
+#ifndef CONFIG_NXWM_BACKGROUND_IMAGE
+# define CONFIG_NXWM_BACKGROUND_IMAGE NXWidgets::g_nuttxBitmap
+#endif
+
/* Tool Bar Configuration ***************************************************/
#ifndef CONFIG_NXWM_TOOLBAR_HEIGHT
# define CONFIG_NXWM_TOOLBAR_HEIGHT CONFIG_NXWM_TASKBAR_WIDTH
#endif
-/* Colors *******************************************************************/
-
#endif // __INCLUDE_NXWMCONFIG_HXX
diff --git a/NxWidgets/nxwm/include/nxwmglyphs.hxx b/NxWidgets/nxwm/include/nxwmglyphs.hxx
index bacd35891..198fe9f26 100644
--- a/NxWidgets/nxwm/include/nxwmglyphs.hxx
+++ b/NxWidgets/nxwm/include/nxwmglyphs.hxx
@@ -43,6 +43,7 @@
#include <nuttx/config.h>
#include "nxconfig.hxx"
+#include "glyphs.hxx"
/****************************************************************************
* Pre-Processor Definitions