diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-02 22:03:05 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-05-02 22:03:05 +0000 |
commit | 4b489525b44d49fa0f8cb95733dd0fdf4553c884 (patch) | |
tree | 8773aca5097c9c4fd1006bf1e35685c55619ce17 /NxWidgets/nxwm/src | |
parent | 5ebf11ee63f1baaf070fd8484d99362810cd5bcc (diff) | |
download | nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.tar.gz nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.tar.bz2 nuttx-4b489525b44d49fa0f8cb95733dd0fdf4553c884.zip |
NxWM updates (with some NX and NxWidget fixes too)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4689 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/nxwm/src')
-rw-r--r-- | NxWidgets/nxwm/src/capplicationwindow.cxx | 69 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/cnxconsole.cxx | 5 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/cstartwindow.cxx | 5 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/ctaskbar.cxx | 130 |
4 files changed, 160 insertions, 49 deletions
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx index c11f40090..8395c93ab 100644 --- a/NxWidgets/nxwm/src/capplicationwindow.cxx +++ b/NxWidgets/nxwm/src/capplicationwindow.cxx @@ -41,6 +41,10 @@ #include <nuttx/nx/nxglib.h> +#include "nxconfig.hxx" +#include "cwidgetcontrol.hxx" +#include "cgraphicsport.hxx" + #include "nxwmconfig.hxx" #include "nxwmglyphs.hxx" #include "capplicationwindow.hxx" @@ -224,6 +228,7 @@ bool CApplicationWindow::open(void) // Configure 'this' to receive mouse click inputs from the image + m_stopImage->setBorderless(true); m_stopImage->addWidgetEventHandler(this); // Create MINIMIZE application bitmap container @@ -272,6 +277,7 @@ bool CApplicationWindow::open(void) // Configure 'this' to receive mouse click inputs from the image + m_minimizeImage->setBorderless(true); m_minimizeImage->addWidgetEventHandler(this); // The rest of the toolbar will hold the left-justified application label @@ -312,6 +318,69 @@ bool CApplicationWindow::open(void) } /** + * Re-draw the application window + */ + +void CApplicationWindow::redraw(void) +{ + // Get the widget control from the task bar + + NXWidgets::CWidgetControl *control = m_toolbar->getWidgetControl(); + + // Get the graphics port for drawing on the background window + + NXWidgets::CGraphicsPort *port = control->getGraphicsPort(); + + // Get the size of the window + + struct nxgl_size_s windowSize; + if (!m_toolbar->getSize(&windowSize)) + { + return; + } + + // Fill the entire tool bar with the non-shadowed border color + + port->drawFilledRect(0, 0, windowSize.w, windowSize.h, + CONFIG_NXTK_BORDERCOLOR1); + + // Then draw the images + + m_stopImage->enableDrawing(); + m_stopImage->redraw(); + m_stopImage->setRaisesEvents(true); + + m_minimizeImage->enableDrawing(); + m_minimizeImage->redraw(); + m_minimizeImage->setRaisesEvents(true); + + // And draw the window label + + m_windowLabel->enableDrawing(); + m_windowLabel->redraw(); +} + +/** + * The application window is hidden (either it is minimized or it is + * maximized, but not at the top of the hierarchy) + */ + +void CApplicationWindow::hide(void) +{ + // Disable the images + + m_stopImage->disableDrawing(); + m_stopImage->setRaisesEvents(false); + + m_minimizeImage->disableDrawing(); + m_minimizeImage->setRaisesEvents(false); + + // Disable the window label + + m_windowLabel->disableDrawing(); +} + +/** * Handle a mouse button click event. * * @param e The event data. diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx index 3652364c7..3cf5e13b9 100644 --- a/NxWidgets/nxwm/src/cnxconsole.cxx +++ b/NxWidgets/nxwm/src/cnxconsole.cxx @@ -120,6 +120,11 @@ CNxConsole::CNxConsole(CTaskbar *taskbar, CApplicationWindow *window) m_pid = -1; m_nxcon = 0; + // Add our personalized window label + + NXWidgets::CNxString myName = getName(); + window->setWindowLabel(myName); + // Add our callbacks to the application window window->registerCallbacks(static_cast<IApplicationCallback *>(this)); diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx index c7a3b27f8..3190f50d9 100644 --- a/NxWidgets/nxwm/src/cstartwindow.cxx +++ b/NxWidgets/nxwm/src/cstartwindow.cxx @@ -70,6 +70,11 @@ CStartWindow::CStartWindow(CTaskbar *taskbar, CApplicationWindow *window) m_taskbar = taskbar; m_window = window; + // Add our personalized window label + + NXWidgets::CNxString myName = getName(); + window->setWindowLabel(myName); + // Add our callbacks to the application window window->registerCallbacks(static_cast<IApplicationCallback *>(this)); diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx index 7630a29b5..1d754c0d5 100644 --- a/NxWidgets/nxwm/src/ctaskbar.cxx +++ b/NxWidgets/nxwm/src/ctaskbar.cxx @@ -70,7 +70,7 @@ CTaskbar::CTaskbar(void) m_taskbar = (NXWidgets::CNxWindow *)0; m_background = (NXWidgets::CNxWindow *)0; m_backImage = (NXWidgets::CImage *)0; - m_topapp = (IApplication *)0; + m_topApp = (IApplication *)0; } /** @@ -279,7 +279,7 @@ CApplicationWindow *CTaskbar::openApplicationWindow(void) /** * Start an application and add its icon to the taskbar. The applications's - * window is brought to the top. Creating a new applicatino in the start + * window is brought to the top. Creating a new application in the start * window requires three steps: * * 1. Create the CTaskbar instance, @@ -334,14 +334,9 @@ bool CTaskbar::startApplication(IApplication *app, bool minimized) slot.image = image; m_slots.push_back(slot); - // Mark the application as minimized (or not) + // Assume for now that this is not the top application - app->setMinimized(minimized); - - // Assume for now that this is not the top application (we will - // know when drawApplicationWindow() runs. - - app->setTopApplication(false); + hideApplicationWindow(app); // Then start the application (whatever that means) @@ -366,9 +361,19 @@ bool CTaskbar::topApplication(IApplication *app) { // Verify that the application is not minimized - if (!app->isMinimized()) + if (!app->isMinimized() && !app->isTopApplication()) { - // It is not... Make the application the top application and redraw it + // It is not minimized. We are going to bring it to the top of the display. + // Is there already a top application? + + if (m_topApp) + { + // Yes.. then disable it + + hideApplicationWindow(m_topApp); + } + + // Make the application the top application and redraw it return redrawApplicationWindow(app); } @@ -410,32 +415,12 @@ bool CTaskbar::minimizeApplication(IApplication *app) if (!app->isMinimized()) { - // Every application provides a method to obtain its application window - - CApplicationWindow *appWindow = app->getWindow(); - - // Each application window provides a method to get the underlying NX window - - NXWidgets::CNxTkWindow *window = appWindow->getWindow(); + // No, then we are going to minimize it but disabling its components, + // marking it as minized, then raising a new window to the top window. - // Mark the window as minimized + hideApplicationWindow(app); - app->setMinimized(true); - - // And it certainly is no longer the top application. If it was before - // then redrawTopWindow() will pick a new one (rather arbitrarily). - - if (app->isTopApplication()) - { - m_topapp = (IApplication *)0; - app->setTopApplication(false); - } - - // Lower the window to the bottom of the hierarchy - - window->lower(); - - // And re-draw the new top, non-minimized application + // Re-draw the new top, non-minimized application return redrawTopWindow(); } @@ -882,7 +867,8 @@ bool CTaskbar::redrawTaskbarWindow(void) // Do we add icons left-to-right? Or top-to-bottom? - bool moveTo(nxgl_coord_t x, nxgl_coord_t y); + bool moveTo(nxgl_coord_t x, nxgl_coord_t y); + #if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM) // left-to-right ... increment the X display position @@ -915,7 +901,7 @@ bool CTaskbar::redrawTopWindow(void) { // Check if there is already a top application - IApplication *app = m_topapp; + IApplication *app = m_topApp; if (!app) { // No.. Search for that last, non-minimized application @@ -944,7 +930,7 @@ bool CTaskbar::redrawTopWindow(void) { // Otherwise, there is no top application. Re-draw the background image. - m_topapp = (IApplication *)0; + m_topApp = (IApplication *)0; return redrawBackgroundWindow(); } } @@ -973,7 +959,7 @@ bool CTaskbar::redrawBackgroundWindow(void) return false; } - // Raise the background window to the top of the display + // Raise the background window to the top of the hierarchy m_background->raise(); @@ -1005,6 +991,15 @@ bool CTaskbar::redrawBackgroundWindow(void) bool CTaskbar::redrawApplicationWindow(IApplication *app) { + // Mark the window as the top application + + m_topApp = app; + app->setTopApplication(true); + + // Disable drawing of the background image. + + m_backImage->disableDrawing(); + // Every application provides a method to obtain its application window CApplicationWindow *appWindow = app->getWindow(); @@ -1013,26 +1008,63 @@ bool CTaskbar::redrawApplicationWindow(IApplication *app) NXWidgets::CNxTkWindow *window = appWindow->getWindow(); - // Mark the window as the top application - - m_topapp = app; - app->setTopApplication(true); - - // Disable drawing of the background image. + // Raise the application window to the top of the hierarchy - m_backImage->disableDrawing(); + window->raise(); - // Raise the window to the top of the hierarchy + // Re-draw the application window toolbar - window->raise(); + appWindow->redraw(); - // And re-draw it + // And re-draw the application window itself app->redraw(); return true; } /** + * The application window is hidden (either it is minimized or it is + * maximized, but not at the top of the hierarchy) + * + * @param app. The application to hide + */ + +void CTaskbar::hideApplicationWindow(IApplication *app) +{ + // The hidden window is certainly not the top application any longer + // If it was before then redrawTopWindow() will pick a new one (rather + // arbitrarily). + + if (app->isTopApplication()) + { + m_topApp = (IApplication *)0; + app->setTopApplication(false); + } + + // Make sure that the application is marked as minimized. + + app->setMinimized(true); + + // We do not need to lower the application to the back.. the new top + // window will be raised instead. + // + // So all that we really have to do is to make sure that all of the + // components of the hidden window are inactive. + + // Every application provides a method to obtain its application window + + CApplicationWindow *appWindow = app->getWindow(); + + // Hide the application window toolbar + + appWindow->hide(); + + // The hide the application window itself + + app->hide(); +} + +/** * Handle a mouse button click event. * * @param e The event data. |