NxWM updates (with some NX and NxWidget fixes too)

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4689 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-05-02 22:03:05 +00:00
parent 882448de92
commit 2b6180f48e
17 changed files with 359 additions and 75 deletions

View File

@ -13,3 +13,6 @@
* CImage: Add logic to hightlight an CImage (using the selected LUT).
* nxwm: The tiny NX window manager (NxWM) is being developed in this directory.
* UnitTests/nxwm: A unit test for the NX window manager.
* During integration of NxWM, corrected numerous problems with NxWidgets
running on toolbars and framed windows. That capability was commented
out in the 1.0 release but is verfied functional in 1.1.

View File

@ -42,6 +42,7 @@
#include <cstdio>
#include <cstdlib>
#include <cunistd>
#include "ctaskbar.hxx"
#include "cstartwindow.hxx"
@ -308,6 +309,21 @@ nocalculator:
return EXIT_FAILURE;
}
// Wait a little bit for the display to stabilize. The simulation pressing of
// the 'start window' icon in the task bar
sleep(2);
g_nxwmtest.taskbar->clickIcon(0);
// Wait bit to see the result of the button press. The press the first icon
// in the start menu. That should be the NxConsole icon.
sleep(2);
g_nxwmtest.startwindow->clickIcon(0);
// Wait bit to see the result of the button press.
sleep(2);
return EXIT_SUCCESS;
}

View File

@ -139,8 +139,9 @@ namespace NXWidgets
CWidgetControl *getWidgetControl(void) const;
/**
* Open a toolbar on the framed window. Toolbar creation is separate
* from object instantion so that errors can be reported
* Open a toolbar on the framed window. This method both instantiates
* the toolbar object AND calls the INxWindow::open() method to
* create the toolbar. The toolbar is ready for use upon return.
*
* @return True if the toolbar was successfully created.
*/

View File

@ -695,6 +695,41 @@ namespace NXWidgets
return m_rect.getHeight();
}
/**
* Get the size of the widget
*
* @return The widgets's size
*/
inline void getSize(struct nxgl_size_s &size) const
{
size.h = m_rect.getHeight();
size.w = m_rect.getWidth();
}
/**
* Get the position of the widget
*
* @return The widgets's position
*/
inline void getPos(struct nxgl_point_s &pos) const
{
pos.x = m_rect.getX();
pos.y = m_rect.getY();
}
/**
* Get the window bounding box in physical display coordinated.
*
* @return This function returns the window handle.
*/
inline CRect getBoundingBox(void)
{
return CRect(m_rect);
}
/**
* Get the dimensions of the border
*

View File

@ -124,7 +124,9 @@ CWidgetControl *CNxTkWindow::getWidgetControl(void) const
}
/**
* Open a toolbar on the framed window
* Open a toolbar on the framed window. This method both instantiates
* the toolbar object AND calls the INxWindow::open() method to
* create the toolbar. The toolbar is ready for use upon return.
*
* @param height Height of the toolbar
*/
@ -133,13 +135,42 @@ CNxToolbar *CNxTkWindow::openToolbar(nxgl_coord_t height)
{
if (m_hNxTkWindow && !m_toolbar)
{
// Create the toolbar. Note that we use the SAME underlying
// widget control. That is because the tool bar really resides
// in the same "physical" window.
// Get current window style from the widget control
CWidgetStyle style;
m_widgetControl->getWidgetStyle(&style);
// Set the background color to the color of the toolbar
style.colors.background = CONFIG_NXTK_BORDERCOLOR1;
// Create a new controlling widget for the window
CWidgetControl *widgetControl = new CWidgetControl(&style);
// And create the toolbar
m_toolbar = new CNxToolbar(this, m_hNxTkWindow,
m_widgetControl, height);
widgetControl, height);
if (!m_toolbar)
{
delete widgetControl;
return (CNxToolbar *)0;
}
// Create the new toolbar. Toolbar creation is separate from
// object instantiation so that failures can be reported.
if (!m_toolbar->open())
{
// Failed to create the toolbar. Clean-up and return NULL
delete m_toolbar;
delete widgetControl;
return (CNxToolbar *)0;
}
}
return m_toolbar;
}

View File

@ -69,10 +69,16 @@ CNxToolbar::CNxToolbar(CNxTkWindow *pNxTkWindow, NXTKWINDOW hNxTkWindow,
CWidgetControl *pWidgetControl, nxgl_coord_t height)
: CCallback(pWidgetControl)
{
// Initialize toolbar state data
m_nxTkWindow = pNxTkWindow;
m_hNxTkWindow = hNxTkWindow;
m_widgetControl = pWidgetControl;
m_height = height;
// Create the CGraphicsPort instance for this window
m_widgetControl->createGraphicsPort(static_cast<INxWindow*>(this));
}
/**

View File

@ -135,6 +135,19 @@ namespace NxWM
bool open(void);
/**
* Re-draw the application window
*/
void redraw(void);
/**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy)
*/
void hide(void);
/**
* Recover the contained NXTK window instance
*
@ -173,7 +186,17 @@ namespace NxWM
inline void clickMinimizeIcon(int index)
{
m_minimizeImage->click(0,0);
// Get the size and position of the widget
struct nxgl_size_s imageSize;
m_minimizeImage->getSize(imageSize);
struct nxgl_point_s imagePos;
m_minimizeImage->getPos(imagePos);
// And click the image at its center
m_minimizeImage->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
}
/**
@ -183,7 +206,17 @@ namespace NxWM
inline void clickStopIcon(int index)
{
m_stopImage->click(0,0);
// Get the size and position of the widget
struct nxgl_size_s imageSize;
m_stopImage->getSize(imageSize);
struct nxgl_point_s imagePos;
m_stopImage->getPos(imagePos);
// And click the image at its center
m_stopImage->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
}
};
}

View File

@ -174,7 +174,7 @@ namespace NxWM
/**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
* maximized, but not at the top of the hierarchy)
*/
void hide(void);
@ -213,7 +213,21 @@ namespace NxWM
{
if (index < m_slots.size())
{
m_slots.at(index).image->click(0,0);
// Get the image widget at this index
NXWidgets::CImage *image = m_slots.at(index).image;
// Get the size and position of the widget
struct nxgl_size_s imageSize;
image->getSize(imageSize);
struct nxgl_point_s imagePos;
image->getPos(imagePos);
// And click the image at its center
image->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
}
}
};

View File

@ -97,7 +97,7 @@ namespace NxWM
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 */
IApplication *m_topApp; /**< The top application in the hierarchy */
TNxArray<struct STaskbarSlot> m_slots; /**< List of application slots in the task bar */
/**
@ -191,6 +191,15 @@ namespace NxWM
bool redrawApplicationWindow(IApplication *app);
/**
* 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 hideApplicationWindow(IApplication *app);
/**
* Handle a mouse button click event.
*
@ -360,7 +369,21 @@ namespace NxWM
{
if (index < m_slots.size())
{
m_slots.at(index).image->click(0,0);
// Get the image widget at this index
NXWidgets::CImage *image = m_slots.at(index).image;
// Get the size and position of the widget
struct nxgl_size_s imageSize;
image->getSize(imageSize);
struct nxgl_point_s imagePos;
image->getPos(imagePos);
// And click the image at its center
image->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
}
}
};

View File

@ -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
@ -311,6 +317,69 @@ bool CApplicationWindow::open(void)
return true;
}
/**
* 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.
*

View File

@ -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));

View File

@ -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));

View File

@ -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
// 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.
CApplicationWindow *appWindow = app->getWindow();
hideApplicationWindow(app);
// Each application window provides a method to get the underlying NX window
NXWidgets::CNxTkWindow *window = appWindow->getWindow();
// Mark the window as minimized
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();
}
@ -883,6 +868,7 @@ 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);
#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,25 +1008,62 @@ 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.
m_backImage->disableDrawing();
// Raise the window to the top of the hierarchy
// Raise the application window to the top of the hierarchy
window->raise();
// And re-draw it
// Re-draw the application window toolbar
appWindow->redraw();
// 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.
*

View File

@ -2697,3 +2697,8 @@
unistd.h is in the std:: namespace.
* configs/sim/nxwm: Added a configuration for testing the NuttX Window Manager
(NxWM)
* fs/fs_fcntl.h: On success, always returned OK. However, some fcntl commands
require returning other values on success.
* Various files. Fix warnings about variables that were initialized by not used.
* configs/sim/*/defconfig: Changes to build a 32-bit simulation on a 32-bit
platform did not make into all of the Make.defs files.

View File

@ -111,11 +111,17 @@ http://tech.groups.yahoo.com/group/nuttx/files.
Compiler differences
--------------------
operator new
operator new:
Problem: "'operator new' takes size_t ('...') as first parameter"
Workaround: Add -fpermissive to the compilation flags
Continue up_setjmp() issues:
With some newer compilers, I am now getting segmentation faults in
up_setjmp.S (even when built with the -m32 option). I have not looked into
this yet.
Stack Size Issues
-----------------
When you run the NuttX simulation, it uses stacks allocated by NuttX from the

View File

@ -524,8 +524,8 @@ CONFIG_NX_PACKEDMSFIRST=n
CONFIG_NX_MOUSE=y
CONFIG_NX_KBD=y
#CONFIG_NXTK_BORDERWIDTH=4
#CONFIG_NXTK_BORDERCOLOR1
#CONFIG_NXTK_BORDERCOLOR2
CONFIG_NXTK_BORDERCOLOR1=0x00a9a9a9
CONFIG_NXTK_BORDERCOLOR2=0x00696969
CONFIG_NXTK_AUTORAISE=n
CONFIG_NXFONT_SANS22X29=n
CONFIG_NXFONT_SANS23X27=y

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxtk/nxtk_bitmaptoolbar.c
*
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2008-2009, 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
@ -122,7 +122,7 @@ int nxtk_bitmaptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest,
* Temporarily, position the origin in absolute screen coordinates
*/
nxgl_vectoradd(&wndorigin, origin, &fwnd->fwrect.pt1);
nxgl_vectoradd(&wndorigin, origin, &fwnd->tbrect.pt1);
/* Then move the origin so that is relative to the containing window, not the
* client subwindow
@ -132,6 +132,6 @@ int nxtk_bitmaptoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_rect_s *dest,
/* Then copy the bitmap */
nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, origin, stride);
nx_bitmap((NXWINDOW)hfwnd, &clipdest, src, &wndorigin, stride);
return OK;
}