NxWidgets: Remove modal loops, Add CWindowEventHandler*. NxWM: Add support for full screen applications
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4716 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
ef0d5cd9e4
commit
5804c3ce77
@ -40,4 +40,15 @@
|
||||
two-dimensional space and should not overlap. This should greatly
|
||||
reduce the memory requirements and, since, NuttX already supports
|
||||
a hierarchical windowing system, does not result in loss of functionality.
|
||||
* CNxWidgets and CWidgetControl. Remove specific built-in support for
|
||||
modal loops. There are too many different control mechanisms that might
|
||||
be needed. Replace with hooks to control widget events from totally
|
||||
external logic.
|
||||
* CWindowEventHandler, CWindowEventHandlerList, CWidgetControl: New
|
||||
callback classes to receive notifications about window events.
|
||||
* CFullScreenWindow and CTaskbar: Add support in NxWM for full screen
|
||||
window applications.
|
||||
* All application windows now use CWindowEventHandler and CWindowEventHandlerList
|
||||
to get notifications about mouse and keyboard events. These class will
|
||||
then automatically handle polling (with no need for a modal loop).
|
||||
|
||||
|
@ -307,7 +307,7 @@ void CButtonTest::release(void)
|
||||
(void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_NOBUTTONS);
|
||||
}
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be press and release
|
||||
// events so we don't have to poll. We can just perform a one pass poll
|
||||
// then check if the event was processed corredly.
|
||||
|
@ -287,7 +287,7 @@ void CButtonArrayTest::release(CButtonArray *buttonArray, int column, int row)
|
||||
(void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_NOBUTTONS);
|
||||
}
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be press and release
|
||||
// events so we don't have to poll. We can just perform a one pass poll
|
||||
// then check if the event was processed corredly.
|
||||
|
@ -253,7 +253,7 @@ void CCheckBoxTest::clickCheckBox(void)
|
||||
|
||||
// Poll for mouse events
|
||||
//
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know that we just pressed the mouse button
|
||||
// so we don't have to poll. We can just perform a one pass poll then
|
||||
// then check if the mouse event was processed corredly.
|
||||
|
@ -289,7 +289,7 @@ void CGlyphButtonTest::release(void)
|
||||
(void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_NOBUTTONS);
|
||||
}
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be press and release
|
||||
// events so we don't have to poll. We can just perform a one pass poll
|
||||
// then check if the event was processed corredly.
|
||||
|
@ -401,7 +401,7 @@ void CKeypadTest::release(CKeypad *keypad, int column, int row)
|
||||
(void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_NOBUTTONS);
|
||||
}
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be press and release
|
||||
// events so we don't have to poll. We can just perform a one pass poll
|
||||
// then check if the event was processed corredly.
|
||||
|
@ -308,7 +308,7 @@ void CLatchButtonTest::release(void)
|
||||
(void)nx_mousein(handle, m_center.x, m_center.y, NX_MOUSE_NOBUTTONS);
|
||||
}
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be press and release
|
||||
// events so we don't have to poll. We can just perform a one pass poll.
|
||||
|
||||
|
@ -287,7 +287,7 @@ void CLatchButtonArrayTest::release(CLatchButtonArray *buttonArray, int column,
|
||||
(void)nx_mousein(handle, buttonX, buttonY, NX_MOUSE_NOBUTTONS);
|
||||
}
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be press and release
|
||||
// events so we don't have to poll. We can just perform a one pass poll
|
||||
// then check if the event was processed corredly.
|
||||
|
@ -268,7 +268,7 @@ void CRadioButtonTest::pushButton(CRadioButton *button)
|
||||
|
||||
// Poll for mouse events
|
||||
//
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know that we just pressed the mouse button
|
||||
// so we don't have to poll. We can just perform a one pass poll then
|
||||
// then check if the mouse event was processed corredly.
|
||||
|
@ -272,7 +272,7 @@ void CTextBoxTest::injectChars(CTextBox *textbox, int nCh, FAR const uint8_t *st
|
||||
|
||||
(void)nx_kbdchin(handle, string[i]);
|
||||
|
||||
// Widget events are normally handled in a modal loop (by calling goModal()).
|
||||
// Widget events are normally handled in a modal loop.
|
||||
// However, for this case we know when there should be keyboard events pending,
|
||||
// events so we don't have to poll repeatedly. We can just perform a one pass
|
||||
// poll
|
||||
|
@ -434,7 +434,6 @@ nocalculator:
|
||||
showTestCaseMemory("After starting the start window application");
|
||||
|
||||
// Call CTaskBar::startWindowManager to start the display with applications in place.
|
||||
// This method will not return but will enter the task bar's modal loop.
|
||||
|
||||
printf(MAIN_STRING "Start the window manager\n");
|
||||
if (!g_nxwmtest.taskbar->startWindowManager())
|
||||
|
@ -46,7 +46,7 @@ CXXSRCS += clistdata.cxx clistdataitem.cxx cnxfont.cxx
|
||||
CXXSRCS += cnxserver.cxx cnxstring.cxx cnxtimer.cxx cnxwidget.cxx cnxwindow.cxx
|
||||
CXXSRCS += cnxtkwindow.cxx cnxtoolbar.cxx crect.cxx crlepalettebitmap.cxx
|
||||
CXXSRCS += cstringiterator.cxx ctext.cxx cwidgetcontrol.cxx cwidgeteventhandlerlist.cxx
|
||||
CXXSRCS += singletons.cxx
|
||||
CXXSRCS += cwindoweventhandlerlist.cxx singletons.cxx
|
||||
# Widget APIs
|
||||
CXXSRCS += cbutton.cxx cbuttonarray.cxx ccheckbox.cxx ccyclebutton.cxx
|
||||
CXXSRCS += cglyphbutton.cxx cimage.cxx ckeypad.cxx clabel.cxx clatchbutton.cxx
|
||||
|
@ -154,7 +154,6 @@ namespace NXWidgets
|
||||
uint8_t visibleRegionCacheInvalid : 1; /**< True if the region cache is invalid. */
|
||||
uint8_t hidden : 1; /**< True if the widget is hidden. */
|
||||
uint8_t doubleClickable : 1; /**< True if the widget can be double-clicked. */
|
||||
uint8_t modal : 1; /**< True if the widget is modal. */
|
||||
} Flags;
|
||||
|
||||
/**
|
||||
@ -564,14 +563,6 @@ namespace NXWidgets
|
||||
return m_flags.dragging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the widget modal? Only true if the Widget singleton is also modal.
|
||||
*
|
||||
* @return True if the widget is modal.
|
||||
*/
|
||||
|
||||
const bool isModal(void) const;
|
||||
|
||||
/**
|
||||
* Get the width of the widget.
|
||||
*
|
||||
@ -1297,21 +1288,6 @@ namespace NXWidgets
|
||||
|
||||
bool removeChild(CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Run the widget modally.
|
||||
*/
|
||||
|
||||
void goModal(void);
|
||||
|
||||
/**
|
||||
* Stop the widget running modally.
|
||||
*/
|
||||
|
||||
inline void stopModal(void)
|
||||
{
|
||||
m_flags.modal = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the child widget at the specified index.
|
||||
*
|
||||
|
@ -52,6 +52,8 @@
|
||||
#include "cnxwidget.hxx"
|
||||
#include "crect.hxx"
|
||||
#include "cwidgetstyle.hxx"
|
||||
#include "cwindoweventhandler.hxx"
|
||||
#include "cwindoweventhandlerlist.hxx"
|
||||
#include "tnxarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
@ -165,11 +167,15 @@ namespace NXWidgets
|
||||
awaiting deletion. */
|
||||
TNxArray<CNxWidget*> m_widgets; /**< List of controlled
|
||||
widgets. */
|
||||
bool m_modal; /**< True: in modal loop */
|
||||
bool m_haveGeometry; /**< True: indicates that we
|
||||
have valid geometry data. */
|
||||
sem_t m_modalSem; /**< Modal loops waits for
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
bool m_waiting; /**< True: Extternal logic waiting for
|
||||
window event */
|
||||
sem_t m_waitSem; /**< External loops waits for
|
||||
events on this semaphore */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* I/O
|
||||
*/
|
||||
@ -198,6 +204,7 @@ namespace NXWidgets
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
sem_t m_geoSem; /**< Posted when geometry is valid */
|
||||
#endif
|
||||
CWindowEventHandlerList m_eventHandlers; /**< List of event handlers. */
|
||||
|
||||
/**
|
||||
* Style
|
||||
@ -227,15 +234,15 @@ namespace NXWidgets
|
||||
/**
|
||||
* Pass clicks to the widget hierarchy. Closes the context menu if
|
||||
* the clicked widget is not the context menu. If a single widget
|
||||
* is supplied, only that widget is sent the click. That widget
|
||||
* should be running modally.
|
||||
* is supplied, only that widget is sent the click.
|
||||
*
|
||||
* @param x Click xcoordinate.
|
||||
* @param y Click ycoordinate.
|
||||
* @param widget Pointer to a modally-running widget or NULL.
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
*/
|
||||
|
||||
void handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget* widget);
|
||||
void handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget *widget);
|
||||
|
||||
/**
|
||||
* Get the index of the specified controlled widget.
|
||||
@ -255,8 +262,8 @@ namespace NXWidgets
|
||||
/**
|
||||
* Process mouse/touchscreen events and send throughout the hierarchy.
|
||||
*
|
||||
* @param widget to process, used for modal widgets; omit this parameter
|
||||
* to run the whole system.
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
* @return True means a mouse event occurred
|
||||
*/
|
||||
|
||||
@ -279,10 +286,12 @@ namespace NXWidgets
|
||||
bool pollCursorControlEvents(void);
|
||||
|
||||
/**
|
||||
* Wake up the modal loop
|
||||
* Wake up and external logic that is waiting for a window event.
|
||||
*/
|
||||
|
||||
void wakeupModalLoop(void);
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
void postWindowEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Take the geometry semaphore (handling signal interruptions)
|
||||
@ -340,42 +349,62 @@ namespace NXWidgets
|
||||
~CWidgetControl(void);
|
||||
|
||||
/**
|
||||
* Run the widget modally. This will run the CWidgetControl
|
||||
* application until stopModal() is called.
|
||||
*/
|
||||
|
||||
void goModal(void);
|
||||
|
||||
/**
|
||||
* Wait for an interesting modal event to occur (like a mouse or keyboard event)
|
||||
*/
|
||||
|
||||
void waitForModalEvent(void);
|
||||
|
||||
/**
|
||||
* Is the widget modal? Only true if the Widget singleton is also modal.
|
||||
* Wait for an interesting window event to occur (like a mouse or keyboard event)
|
||||
* Caller's should exercise care to assure that the test for waiting and this
|
||||
* call are "atomic" .. perhaps by locking the scheduler like:
|
||||
*
|
||||
* @return True if the widget is modal.
|
||||
* sched_lock();
|
||||
* <check for events>
|
||||
* if (<no interesting events>)
|
||||
* {
|
||||
* window->waitForWindowEvent();
|
||||
* }
|
||||
* sched_unlock();
|
||||
*/
|
||||
|
||||
inline const bool isModal(void) const
|
||||
{
|
||||
return m_modal;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
void waitForWindowEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Stop the widget running modally.
|
||||
* Is external logic awaiting for a window event?
|
||||
*
|
||||
* @return True if the widget if external logic is waiting.
|
||||
*/
|
||||
|
||||
void stopModal(void);
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
inline const bool isWaiting(void) const
|
||||
{
|
||||
return m_waiting;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Run all code that needs to take place on a periodic basis.
|
||||
* This is normally called from and is the main body of goModal()
|
||||
* with widget == NULL.
|
||||
* This method normally called externally... either periodically
|
||||
* or when a window event is detected. If CONFIG_NXWIDGET_EVENTWAIT
|
||||
* is defined, then external logic want call waitWindow event and
|
||||
* when awakened, they chould call this function. As an example:
|
||||
*
|
||||
* @param widget Sub-widget to run, used for modal widgets; omit
|
||||
* this parameter to run the whole system.
|
||||
* for (;;)
|
||||
* {
|
||||
* sched_lock(); // Make the sequence atomic
|
||||
* if (!window->pollEvents(0))
|
||||
* {
|
||||
* window->waitWindowEvent();
|
||||
* }
|
||||
* sched_unlock();
|
||||
* }
|
||||
*
|
||||
* This method is just a wrapper simply calls the followi.
|
||||
*
|
||||
* processDeleteQueue()
|
||||
* pollMouseEvents(widget)
|
||||
* pollKeyboardEvents()
|
||||
* pollCursorControlEvents()
|
||||
*
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
* @return True means some interesting event occurred
|
||||
*/
|
||||
|
||||
@ -551,8 +580,10 @@ namespace NXWidgets
|
||||
* @param nCh The number of characters that are available in pStr[].
|
||||
* @param pStr The array of characters.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This event means that cursor control data is available for the window.
|
||||
@ -673,6 +704,29 @@ namespace NXWidgets
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a window event handler. The window handler will receive
|
||||
* notification all NX events received by this window\.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler.
|
||||
*/
|
||||
|
||||
inline void addWindowEventHandler(CWindowEventHandler *eventHandler)
|
||||
{
|
||||
m_eventHandlers.addWindowEventHandler(eventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a window event handler.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler to remove.
|
||||
*/
|
||||
|
||||
inline void removeWindowEventHandler(CWindowEventHandler *eventHandler)
|
||||
{
|
||||
m_eventHandlers.removeWindowEventHandler(eventHandler);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
113
libnxwidgets/include/cwindoweventhandler.hxx
Normal file
113
libnxwidgets/include/cwindoweventhandler.hxx
Normal file
@ -0,0 +1,113 @@
|
||||
/****************************************************************************
|
||||
* NxWidgets/libnxwidgets/include/cwindoweventhandler.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 __INCLUDE_CWINDOWEVENTHANDLER_HXX
|
||||
#define __INCLUDE_CWINDOWEVENTHANDLER_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "nxconfig.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CNxWidget;
|
||||
|
||||
/**
|
||||
* Base CWindowEventHandler class, intended to be subclassed. Any class that
|
||||
* needs to listen for window events should inherit from this class.
|
||||
*/
|
||||
|
||||
class CWindowEventHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
||||
inline CWindowEventHandler() { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
virtual inline ~CWindowEventHandler() { }
|
||||
|
||||
/**
|
||||
* Handle a NX window redraw request event
|
||||
*/
|
||||
|
||||
virtual void handleRedrawEvent(void) { }
|
||||
|
||||
/**
|
||||
* Handle a NX window position/size change event
|
||||
*/
|
||||
|
||||
virtual void handleGeometryEvent(void) { }
|
||||
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
virtual void handleMouseEvent(void) { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
virtual void handleKeyboardEvent(void) { }
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __INCLUDE_CWINDOWEVENTHANDLER_HXX
|
168
libnxwidgets/include/cwindoweventhandlerlist.hxx
Normal file
168
libnxwidgets/include/cwindoweventhandlerlist.hxx
Normal file
@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
* NxWidgets/libnxwidgets/include/cwindoweventhandlerlist.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 __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
|
||||
#define __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "cwindoweventhandler.hxx"
|
||||
#include "tnxarray.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NXWidgets
|
||||
{
|
||||
class CListDataItem;
|
||||
|
||||
/**
|
||||
* List of window event handlers.
|
||||
*/
|
||||
class CWindowEventHandlerList
|
||||
{
|
||||
protected:
|
||||
TNxArray<CWindowEventHandler*> m_eventHandlers; /**< List of event handlers */
|
||||
|
||||
/**
|
||||
* Return the index to the window event handler.
|
||||
*/
|
||||
|
||||
bool findWindowEventHandler(CWindowEventHandler *eventHandler, int &index);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param widget The owning widget.
|
||||
*/
|
||||
|
||||
CWindowEventHandlerList(void) { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
|
||||
inline ~CWindowEventHandlerList(void) { }
|
||||
|
||||
/**
|
||||
* Get the event handler at the specified index.
|
||||
*
|
||||
* @param index The index of the event handler.
|
||||
* @return The event handler at the specified index.
|
||||
*/
|
||||
|
||||
inline CWindowEventHandler *at(const int index) const
|
||||
{
|
||||
return m_eventHandlers.at(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the array.
|
||||
*
|
||||
* @return The size of the array.
|
||||
*/
|
||||
|
||||
inline const nxgl_coord_t size(void) const
|
||||
{
|
||||
return m_eventHandlers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a window event handler. The event handler will receive
|
||||
* all events raised by this object.
|
||||
* @param eventHandler A pointer to the event handler.
|
||||
*/
|
||||
|
||||
void addWindowEventHandler(CWindowEventHandler *eventHandler);
|
||||
|
||||
/**
|
||||
* Remove a window event handler.
|
||||
*
|
||||
* @param eventHandler A pointer to the event handler to remove.
|
||||
*/
|
||||
|
||||
void removeWindowEventHandler(CWindowEventHandler *eventHandler);
|
||||
|
||||
/**
|
||||
* Raise the NX window redraw event.
|
||||
*/
|
||||
|
||||
void raiseRedrawEvent(void);
|
||||
|
||||
/**
|
||||
* Raise an NX window position/size change event.
|
||||
*/
|
||||
|
||||
void raiseGeometryEvent(void);
|
||||
|
||||
/**
|
||||
* Raise an NX mouse window input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
void raiseMouseEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Raise an NX keybord input event
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void raiseKeyboardEvent(void);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __INCLUDE_CWINDOWEVENTHANDLERLIST_HXX
|
@ -85,6 +85,10 @@
|
||||
* mode). Default 2048
|
||||
* CONFIG_NXWIDGETS_LISTENERSTACK - NX listener thread stack size (in multi-user
|
||||
* mode). Default 2048
|
||||
* CONFIG_NXWIDGET_EVENTWAIT - Build in support for external window event, modal
|
||||
* loop management logic. This includes methods to wait for windows events
|
||||
* to occur so that looping logic can sleep until something interesting
|
||||
* happens with the window.
|
||||
*
|
||||
* NXWidget Configuration
|
||||
*
|
||||
|
@ -215,7 +215,7 @@ bool CNxServer::connect(void)
|
||||
// Start the server task
|
||||
|
||||
gvdbg("NxServer::connect: Starting server task\n");
|
||||
serverId = task_create("NX Server", CONFIG_NXWIDGETS_SERVERPRIO,
|
||||
serverId = TASK_CREATE("NX Server", CONFIG_NXWIDGETS_SERVERPRIO,
|
||||
CONFIG_NXWIDGETS_SERVERSTACK, server, (FAR const char **)0);
|
||||
if (serverId < 0)
|
||||
{
|
||||
@ -291,7 +291,7 @@ bool CNxServer::connect(void)
|
||||
#ifndef CONFIG_NX_MULTIUSER
|
||||
void CNxServer::disconnect(void)
|
||||
{
|
||||
/* Close the server */
|
||||
// Close the server
|
||||
|
||||
if (m_hNxServer)
|
||||
{
|
||||
@ -324,7 +324,7 @@ void CNxServer::disconnect(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Disconnect from the server */
|
||||
// Disconnect from the server
|
||||
|
||||
if (m_hNxServer)
|
||||
{
|
||||
@ -346,7 +346,7 @@ int CNxServer::server(int argc, char *argv[])
|
||||
int ret;
|
||||
|
||||
#if defined(CONFIG_NXWIDGETS_EXTERNINIT)
|
||||
/* Use external graphics driver initialization */
|
||||
// Use external graphics driver initialization
|
||||
|
||||
dev = up_nxdrvinit(CONFIG_NXWIDGETS_DEVNO);
|
||||
if (!dev)
|
||||
@ -356,7 +356,7 @@ int CNxServer::server(int argc, char *argv[])
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_NX_LCDDRIVER)
|
||||
/* Initialize the LCD device */
|
||||
// Initialize the LCD device
|
||||
|
||||
ret = up_lcdinitialize();
|
||||
if (ret < 0)
|
||||
@ -365,7 +365,7 @@ int CNxServer::server(int argc, char *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Get the device instance */
|
||||
// Get the device instance
|
||||
|
||||
dev = up_lcdgetdev(CONFIG_NXWIDGETS_DEVNO);
|
||||
if (!dev)
|
||||
@ -374,11 +374,11 @@ int CNxServer::server(int argc, char *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Turn the LCD on at 75% power */
|
||||
// Turn the LCD on at 75% power
|
||||
|
||||
(void)dev->setpower(dev, ((3*CONFIG_LCD_MAXPOWER + 3)/4));
|
||||
#else
|
||||
/* Initialize the frame buffer device */
|
||||
// Initialize the frame buffer device
|
||||
|
||||
ret = up_fbinitialize();
|
||||
if (ret < 0)
|
||||
@ -395,7 +395,7 @@ int CNxServer::server(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Then start the server */
|
||||
// Then start the server
|
||||
|
||||
ret = nx_run(dev);
|
||||
gvdbg("nx_run returned: %d\n", errno);
|
||||
@ -436,7 +436,7 @@ FAR void *CNxServer::listener(FAR void *arg)
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we received a message, we must be connected */
|
||||
// If we received a message, we must be connected
|
||||
|
||||
if (!This->m_connected)
|
||||
{
|
||||
|
@ -174,7 +174,6 @@ CNxWidget::CNxWidget(CWidgetControl *pWidgetControl,
|
||||
m_flags.erased = true;
|
||||
m_flags.visibleRegionCacheInvalid = true;
|
||||
m_flags.hidden = false;
|
||||
m_flags.modal = false;
|
||||
|
||||
// Set hierarchy pointers
|
||||
|
||||
@ -397,17 +396,6 @@ const bool CNxWidget::isEnabled() const
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the widget modal? Only true if the Widget singleton is also modal.
|
||||
*
|
||||
* @return True if the widget is modal.
|
||||
*/
|
||||
|
||||
const bool CNxWidget::isModal(void) const
|
||||
{
|
||||
return m_widgetControl->isModal() & m_flags.modal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the dimensions that this widget wants to have into the rect
|
||||
* passed in as a parameter. All coordinates are relative to the widget's
|
||||
@ -576,10 +564,6 @@ void CNxWidget::close(void)
|
||||
release(clickedWidget->getX(), clickedWidget->getY());
|
||||
}
|
||||
|
||||
// Ensure the widget isn't running modally
|
||||
|
||||
stopModal();
|
||||
|
||||
if (m_parent != (CNxWidget *)NULL)
|
||||
{
|
||||
m_parent->closeChild(this);
|
||||
@ -622,10 +606,6 @@ bool CNxWidget::hide(void)
|
||||
if (!m_flags.hidden)
|
||||
{
|
||||
m_flags.hidden = true;
|
||||
|
||||
// Ensure the widget isn't running modally
|
||||
|
||||
stopModal();
|
||||
m_widgetEventHandlers->raiseHideEvent();
|
||||
return true;
|
||||
}
|
||||
@ -1398,39 +1378,6 @@ bool CNxWidget::removeChild(CNxWidget *widget)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the widget modally.
|
||||
*/
|
||||
|
||||
void CNxWidget::goModal(void)
|
||||
{
|
||||
// Remember that we're running modally
|
||||
|
||||
m_flags.modal = true;
|
||||
|
||||
// Steal focus
|
||||
|
||||
focus();
|
||||
|
||||
// Loop until no longer modal
|
||||
|
||||
while (isModal())
|
||||
{
|
||||
// Process pending events
|
||||
|
||||
bool interestingEvent = m_widgetControl->pollEvents(this);
|
||||
|
||||
// Did any interesting events occur?
|
||||
|
||||
if (!interestingEvent)
|
||||
{
|
||||
// No, give up the CPU until something interesting happens.
|
||||
|
||||
m_widgetControl->waitForModalEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the child widget at the specified index.
|
||||
*
|
||||
|
@ -83,7 +83,6 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
|
||||
// Initialize state
|
||||
|
||||
m_port = (CGraphicsPort *)NULL;
|
||||
m_modal = false;
|
||||
m_haveGeometry = false;
|
||||
m_clickedWidget = (CNxWidget *)NULL;
|
||||
m_focusedWidget = (CNxWidget *)NULL;
|
||||
@ -108,12 +107,15 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
|
||||
|
||||
// Intialize semaphores:
|
||||
//
|
||||
// m_modalSem. The semaphore that will wake up the modal loop on mouse or
|
||||
// keypress events
|
||||
// m_waitSem. The semaphore that will wake up the external logic on mouse events,
|
||||
// keypress events, or widget deletion events.
|
||||
// m_geoSem. The semaphore that will synchronize window size and position
|
||||
// informatin.
|
||||
// information.
|
||||
|
||||
sem_init(&m_modalSem, 0, 0);
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
m_waiting = false;
|
||||
sem_init(&m_waitSem, 0, 0);
|
||||
#endif
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
sem_init(&m_geoSem, 0, 0);
|
||||
#endif
|
||||
@ -141,9 +143,12 @@ CWidgetControl::CWidgetControl(FAR const CWidgetStyle *style)
|
||||
|
||||
CWidgetControl::~CWidgetControl(void)
|
||||
{
|
||||
// Stop any ongoing modal operation
|
||||
// Notify any external waiters... this should not happen becaue it
|
||||
// it is probably already too late
|
||||
|
||||
stopModal();
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
postWindowEvent();
|
||||
#endif
|
||||
|
||||
// Delete any contained instances
|
||||
|
||||
@ -165,88 +170,69 @@ CWidgetControl::~CWidgetControl(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the widget modally. This will run the CWidgetControl
|
||||
* application until stopModal() is called.
|
||||
* Wait for an interesting window event to occur (like a mouse or keyboard event).
|
||||
* Caller's should exercise care to assure that the test for waiting and this
|
||||
* call are "atomic" .. perhaps by locking the scheduler like:
|
||||
*
|
||||
* sched_lock();
|
||||
* ...
|
||||
* if (no interesting events)
|
||||
* {
|
||||
* window->waitForWindowEvent();
|
||||
* }
|
||||
* sched_unlock();
|
||||
*/
|
||||
|
||||
void CWidgetControl::goModal(void)
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
void CWidgetControl::waitForWindowEvent(void)
|
||||
{
|
||||
// Enter modal
|
||||
|
||||
m_modal = true;
|
||||
|
||||
// Loop until stopModal() is called
|
||||
|
||||
while (m_modal)
|
||||
{
|
||||
// Process pending events
|
||||
|
||||
bool interestingEvent = pollEvents();
|
||||
|
||||
// Did any interesting events occur?
|
||||
|
||||
if (!interestingEvent)
|
||||
{
|
||||
// No, give up the CPU until something interesting happens.
|
||||
|
||||
waitForModalEvent();
|
||||
}
|
||||
}
|
||||
m_waiting = true;
|
||||
(void)sem_wait(&m_waitSem);
|
||||
m_waiting = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Wait for an interesting modal event to occur (like a mouse or keyboard event)
|
||||
* Wake up external logic waiting for a window event
|
||||
*/
|
||||
|
||||
void CWidgetControl::waitForModalEvent(void)
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
void CWidgetControl::postWindowEvent(void)
|
||||
{
|
||||
// It would be an error if this were called outside of a modal loop
|
||||
|
||||
if (m_modal)
|
||||
if (m_waiting)
|
||||
{
|
||||
// Wait for an interesting event (like a mouse or keyboard event)
|
||||
|
||||
(void)sem_wait(&m_modalSem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wake up the modal loop
|
||||
*/
|
||||
|
||||
void CWidgetControl::wakeupModalLoop(void)
|
||||
{
|
||||
if (m_modal)
|
||||
{
|
||||
(void)sem_post(&m_modalSem);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the widget running modally.
|
||||
*/
|
||||
|
||||
void CWidgetControl::stopModal(void)
|
||||
{
|
||||
if (m_modal)
|
||||
{
|
||||
// No longer modal
|
||||
|
||||
m_modal = false;
|
||||
|
||||
// Wake up the modal loop so that it can terminate properly
|
||||
|
||||
(void)sem_post(&m_modalSem);
|
||||
(void)sem_post(&m_waitSem);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Run all code that needs to take place on a periodic basis.
|
||||
* This is normally called from and is the main body of goModal()
|
||||
* with widget == NULL.
|
||||
* This method normally called externally... either periodically
|
||||
* or when a window event is detected. If CONFIG_NXWIDGET_EVENTWAIT
|
||||
* is defined, then external logic want call waitWindow event and
|
||||
* when awakened, they chould call this function. As an example:
|
||||
*
|
||||
* @param widget Sub-widget to run, used for modal widgets; omit
|
||||
* this parameter to run the whole system.
|
||||
* for (;;)
|
||||
* {
|
||||
* sched_lock(); // Make the sequence atomic
|
||||
* if (!window->pollEvents(0))
|
||||
* {
|
||||
* window->waitWindowEvent();
|
||||
* }
|
||||
* sched_unlock();
|
||||
* }
|
||||
*
|
||||
* This method is just a wrapper simply calls the following methods.
|
||||
* It can easily be replace with custom, external logic.
|
||||
*
|
||||
* processDeleteQueue()
|
||||
* pollMouseEvents(widget)
|
||||
* pollKeyboardEvents()
|
||||
* pollCursorControlEvents()
|
||||
*
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
* @return True means some interesting event occurred
|
||||
*/
|
||||
|
||||
@ -316,7 +302,15 @@ void CWidgetControl::removeControlledWidget(CNxWidget *widget)
|
||||
|
||||
void CWidgetControl::addToDeleteQueue(CNxWidget *widget)
|
||||
{
|
||||
// Add the widget to the delete queue
|
||||
|
||||
m_deleteQueue.push_back(widget);
|
||||
|
||||
// Then wake up logic that may be waiting for a window event
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
postWindowEvent();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -422,6 +416,7 @@ void CWidgetControl::geometryEvent(NXHANDLE hWindow,
|
||||
giveGeoSem();
|
||||
}
|
||||
|
||||
m_eventHandlers.raiseGeometryEvent();
|
||||
sched_unlock();
|
||||
}
|
||||
|
||||
@ -439,6 +434,7 @@ void CWidgetControl::redrawEvent(FAR const struct nxgl_rect_s *nxRect, bool more
|
||||
{
|
||||
CRect rect;
|
||||
rect.setNxRect(nxRect);
|
||||
m_eventHandlers.raiseRedrawEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -449,7 +445,8 @@ void CWidgetControl::redrawEvent(FAR const struct nxgl_rect_s *nxRect, bool more
|
||||
* @param pos The (x,y) position of the mouse.
|
||||
* @param buttons See NX_MOUSE_* definitions.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t buttons)
|
||||
{
|
||||
// Save the mouse X/Y position
|
||||
@ -569,10 +566,17 @@ void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t b
|
||||
}
|
||||
#endif
|
||||
|
||||
// Then wake up the modal loop
|
||||
// Notify any external logic that a keyboard event has occurred
|
||||
|
||||
wakeupModalLoop();
|
||||
m_eventHandlers.raiseMouseEvent();
|
||||
|
||||
// Then wake up logic that may be waiting for a window event
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
postWindowEvent();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This event is called from CCallback instance to provide notifications of
|
||||
@ -582,7 +586,8 @@ void CWidgetControl::newMouseEvent(FAR const struct nxgl_point_s *pos, uint8_t b
|
||||
* @param nCh The number of characters that are available in pStr[].
|
||||
* @param pStr The array of characters.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void CWidgetControl::newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr)
|
||||
{
|
||||
FAR uint8_t *pBuffer = &m_kbdbuf[m_nCh];
|
||||
@ -596,10 +601,17 @@ void CWidgetControl::newKeyboardEvent(uint8_t nCh, FAR const uint8_t *pStr)
|
||||
*pBuffer++ = *pStr++;
|
||||
}
|
||||
|
||||
// Then wake up the modal loop
|
||||
// Notify any external logic that a keyboard event has occurred
|
||||
|
||||
wakeupModalLoop();
|
||||
m_eventHandlers.raiseKeyboardEvent();
|
||||
|
||||
// Then wake up logic that may be waiting for a window event
|
||||
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
postWindowEvent();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This event means that cursor control data is available for the window.
|
||||
@ -617,9 +629,11 @@ void CWidgetControl::newCursorControlEvent(ECursorControl cursorControl)
|
||||
m_nCc++;
|
||||
}
|
||||
|
||||
// Then wake up the modal loop
|
||||
// Then wake up logic that may be waiting for a window event
|
||||
|
||||
wakeupModalLoop();
|
||||
#ifdef CONFIG_NXWIDGET_EVENTWAIT
|
||||
postWindowEvent();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -718,17 +732,16 @@ uint32_t CWidgetControl::elapsedTime(FAR const struct timespec *startTime)
|
||||
|
||||
/**
|
||||
* Pass clicks to the widget hierarchy. If a single widget
|
||||
* is supplied, only that widget is sent the click. That widget
|
||||
* should be running modally.
|
||||
* is supplied, only that widget is sent the click.
|
||||
*
|
||||
* @param x Click xcoordinate.
|
||||
* @param y Click ycoordinate.
|
||||
* @param widget Pointer to a modally-running widget or NULL.
|
||||
* @param widget Pointer to a specific widget or NULL.
|
||||
*/
|
||||
|
||||
void CWidgetControl::handleLeftClick(nxgl_coord_t x, nxgl_coord_t y, CNxWidget *widget)
|
||||
{
|
||||
// Working with a modal widget or the whole structure?
|
||||
// Working with a specific widget or the whole structure?
|
||||
|
||||
if (widget == (CNxWidget *)NULL)
|
||||
{
|
||||
@ -769,8 +782,8 @@ void CWidgetControl::processDeleteQueue(void)
|
||||
/**
|
||||
* Process mouse/touchscreen events and send throughout the hierarchy.
|
||||
*
|
||||
* @param widget to process, used for modal widgets; omit this parameter
|
||||
* to run the whole system.
|
||||
* @param widget. Specific widget to poll. Use NULL to run the
|
||||
* all widgets in the window.
|
||||
* @return True means a mouse event occurred
|
||||
*/
|
||||
|
||||
|
@ -42,7 +42,7 @@ NXWIDGETDIR := $(NXWMDIR)/../libnxwidgets
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
# Window Manager
|
||||
CXXSRCS = capplicationwindow.cxx cnxconsole.cxx cstartwindow.cxx ctaskbar.cxx
|
||||
CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx cnxconsole.cxx cstartwindow.cxx ctaskbar.cxx
|
||||
# Images
|
||||
CXXSRCS += glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx glyph_play.cxx glyph_start.cxx glyph_stop.cxx
|
||||
|
||||
|
@ -49,6 +49,9 @@
|
||||
#include "cimage.hxx"
|
||||
#include "clabel.hxx"
|
||||
#include "crlepalettebitmap.hxx"
|
||||
#include "cwindoweventhandler.hxx"
|
||||
|
||||
#include "iapplicationwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
@ -62,34 +65,15 @@
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This callback class is used by the application to get notification of toolbar
|
||||
* related events.
|
||||
*/
|
||||
|
||||
class IApplicationCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Called when the window minimize button is pressed.
|
||||
*/
|
||||
|
||||
virtual void minimize(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when the window minimize close is pressed.
|
||||
*/
|
||||
|
||||
virtual void close(void) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents that application window. This class contains that the
|
||||
* framed window and its toolbar. It manages callbacks from the toolbar minimize
|
||||
* and close buttions and passes these to the application via callbacks.
|
||||
*/
|
||||
|
||||
class CApplicationWindow : private NXWidgets::CWidgetEventHandler
|
||||
class CApplicationWindow : public IApplicationWindow,
|
||||
private NXWidgets::CWidgetEventHandler,
|
||||
private NXWidgets::CWindowEventHandler
|
||||
{
|
||||
protected:
|
||||
NXWidgets::CNxTkWindow *m_window; /**< The framed window used by the application */
|
||||
@ -102,6 +86,24 @@ namespace NxWM
|
||||
NXWidgets::CNxFont *m_windowFont; /**< The font used to rend the window label */
|
||||
IApplicationCallback *m_callback; /**< Toolbar action callbacks */
|
||||
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
void handleMouseEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void handleKeyboardEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a mouse button click event.
|
||||
*
|
||||
@ -154,10 +156,7 @@ namespace NxWM
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
inline NXWidgets::CNxTkWindow *getWindow(void) const
|
||||
{
|
||||
return m_window;
|
||||
}
|
||||
NXWidgets::INxWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
@ -165,40 +164,21 @@ namespace NxWM
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
inline void setWindowLabel(NXWidgets::CNxString &appname)
|
||||
{
|
||||
m_windowLabel->setText(appname);
|
||||
}
|
||||
void setWindowLabel(NXWidgets::CNxString &appname);
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
void registerCallbacks(IApplicationCallback *callback)
|
||||
{
|
||||
m_callback = callback;
|
||||
}
|
||||
void registerCallbacks(IApplicationCallback *callback);
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the minimize icon. This inline method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXWM_UNITTEST
|
||||
inline void clickMinimizeIcon(int index)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void clickMinimizeIcon(int index);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -206,21 +186,8 @@ namespace NxWM
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NXWM_UNITTEST
|
||||
inline void clickStopIcon(int index)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void clickStopIcon(int index);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
172
nxwm/include/cfullscreenwindow.hxx
Normal file
172
nxwm/include/cfullscreenwindow.hxx
Normal file
@ -0,0 +1,172 @@
|
||||
/****************************************************************************
|
||||
* NxWidgets/nxwm/include/cfullscreenwindow.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 __INCLUDE_CFULLSCREENWINDOW_NXX
|
||||
#define __INCLUDE_CFULLSCREENWINDOW_NXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cnxwindow.hxx"
|
||||
|
||||
#include "iapplicationwindow.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Implementation Classes
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This class represents a generic window. This bland window is used,
|
||||
* for example, to support full screen displays.
|
||||
*/
|
||||
|
||||
class CFullScreenWindow : public IApplicationWindow,
|
||||
private NXWidgets::CWindowEventHandler
|
||||
{
|
||||
protected:
|
||||
NXWidgets::CNxWindow *m_window; /**< The generic window used by the application */
|
||||
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
void handleMouseEvent(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void handleKeyboardEvent(void);
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* CFullScreenWindow Constructor
|
||||
*
|
||||
* @param window. The raw window to be used by this full screen application.
|
||||
*/
|
||||
|
||||
CFullScreenWindow(NXWidgets::CNxWindow *window);
|
||||
|
||||
/**
|
||||
* CFullScreenWindow Destructor
|
||||
*/
|
||||
|
||||
~CFullScreenWindow(void);
|
||||
|
||||
/**
|
||||
* Initialize window. Window initialization is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully initialized.
|
||||
*/
|
||||
|
||||
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
|
||||
*
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::INxWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
*
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
void setWindowLabel(NXWidgets::CNxString &appname);
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
void registerCallbacks(IApplicationCallback *callback);
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the minimize icon. This inline method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void clickMinimizeIcon(int index);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the stop applicaiton icon. This inline method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void clickStopIcon(int index);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __INCLUDE_CFULLSCREENWINDOW_NXX
|
@ -125,7 +125,7 @@ namespace NxWM
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
CApplicationWindow *getWindow(void) const;
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
|
@ -138,7 +138,7 @@ namespace NxWM
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
CApplicationWindow *getWindow(void) const;
|
||||
IApplicationWindow *getWindow(void) const;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
|
@ -49,6 +49,11 @@
|
||||
#include "cwidgeteventhandler.hxx"
|
||||
#include "cwidgeteventargs.hxx"
|
||||
|
||||
#include "nxwmconfig.hxx"
|
||||
#include "nxwmglyphs.hxx"
|
||||
|
||||
#include "capplicationwindow.hxx"
|
||||
#include "cfullscreenwindow.hxx"
|
||||
#include "iapplication.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
@ -130,9 +135,10 @@ namespace NxWM
|
||||
* Set size and position of a window in the application area.
|
||||
*
|
||||
* @param window. The window to be resized and repositioned
|
||||
* @param fullscreen. True: Use full screen
|
||||
*/
|
||||
|
||||
void setApplicationGeometry(NXWidgets::INxWindow *window);
|
||||
void setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen);
|
||||
|
||||
/**
|
||||
* Create the task bar window.
|
||||
@ -281,8 +287,8 @@ namespace NxWM
|
||||
bool startWindowManager(void);
|
||||
|
||||
/**
|
||||
* Create an application window. Creating a new application in the start
|
||||
* window requires three steps:
|
||||
* Create an normal application window. Creating a normal application in the
|
||||
* start window requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::openApplicationWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
@ -298,6 +304,24 @@ namespace NxWM
|
||||
|
||||
CApplicationWindow *openApplicationWindow(void);
|
||||
|
||||
/**
|
||||
* Create a full screen application window. Creating a new full screen application
|
||||
* requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::FullScreenWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
* constructor,
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the
|
||||
* start window.
|
||||
*
|
||||
* When the application is selected from the start window:
|
||||
*
|
||||
* 4. Call CTaskBar::startApplication start the application and bring its window to
|
||||
* the top.
|
||||
*/
|
||||
|
||||
CFullScreenWindow *openFullScreenWindow(void);
|
||||
|
||||
/**
|
||||
* Start an application and add its icon to the taskbar. The applications's
|
||||
* window is brought to the top. Creating a new application in the start
|
||||
|
@ -78,7 +78,7 @@ namespace NxWM
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
virtual CApplicationWindow *getWindow(void) const = 0;
|
||||
virtual IApplicationWindow *getWindow(void) const = 0;
|
||||
|
||||
/**
|
||||
* Get the icon associated with the application
|
||||
|
160
nxwm/include/iapplicationwindow.hxx
Normal file
160
nxwm/include/iapplicationwindow.hxx
Normal file
@ -0,0 +1,160 @@
|
||||
/****************************************************************************
|
||||
* NxWidgets/nxwm/include/iapplicationwindow.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 __INCLUDE_IAPPLICATIONWINDOW_NXX
|
||||
#define __INCLUDE_IAPPLICATIONWINDOW_NXX
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cnxtkwindow.hxx"
|
||||
#include "cnxtoolbar.hxx"
|
||||
#include "cwidgeteventargs.hxx"
|
||||
#include "cwidgeteventhandler.hxx"
|
||||
#include "cimage.hxx"
|
||||
#include "clabel.hxx"
|
||||
#include "crlepalettebitmap.hxx"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Abstract Base Class
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
namespace NxWM
|
||||
{
|
||||
/**
|
||||
* This callback class is used by the application to get notification of toolbar
|
||||
* related events.
|
||||
*/
|
||||
|
||||
class IApplicationCallback
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Called when the window minimize button is pressed.
|
||||
*/
|
||||
|
||||
virtual void minimize(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when the window minimize close is pressed.
|
||||
*/
|
||||
|
||||
virtual void close(void) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents the general application window. The actual window
|
||||
* may be a contained, framed window or and unframed, fullscreen window.
|
||||
*/
|
||||
|
||||
class IApplicationWindow
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initialize window. Window initialization is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully initialized.
|
||||
*/
|
||||
|
||||
virtual bool open(void) = 0;
|
||||
|
||||
/**
|
||||
* Re-draw the application window
|
||||
*/
|
||||
|
||||
virtual void redraw(void) = 0;
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy)
|
||||
*/
|
||||
|
||||
virtual void hide(void) = 0;
|
||||
|
||||
/**
|
||||
* Recover the contained window instance
|
||||
*
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
virtual NXWidgets::INxWindow *getWindow(void) const = 0;
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
*
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
virtual void setWindowLabel(NXWidgets::CNxString &appname) = 0;
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
virtual void registerCallbacks(IApplicationCallback *callback) = 0;
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the minimize icon. This inline method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
virtual void clickMinimizeIcon(int index) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the stop applicaiton icon. This inline method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
virtual void clickStopIcon(int index) = 0;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __INCLUDE_IAPPLICATIONWINDOW_NXX
|
@ -61,6 +61,7 @@
|
||||
*
|
||||
* CONFIG_NXWM_DEFAULT_FONTID - the NxWM default font ID. Default:
|
||||
* NXFONT_DEFAULT
|
||||
* CONFIG_NXWM_TOUCHSCREEN - Define to build in touchscreen support.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HAVE_CXX
|
||||
|
@ -62,8 +62,7 @@
|
||||
/**
|
||||
* CApplicationWindow Constructor
|
||||
*
|
||||
* @param taskbar. A pointer to the parent task bar instance
|
||||
* @param window. The window to be used by this application.
|
||||
* @param taskbar. A pointer to the parent task bar instance.
|
||||
*/
|
||||
|
||||
CApplicationWindow::CApplicationWindow(NXWidgets::CNxTkWindow *window)
|
||||
@ -134,7 +133,7 @@ CApplicationWindow::~CApplicationWindow(void)
|
||||
}
|
||||
|
||||
// We didn't create the window. That was done by the task bar,
|
||||
// Be we will handle destruction of with window as a courtesy.
|
||||
// But we will handle destruction of with window as a courtesy.
|
||||
|
||||
if (m_window)
|
||||
{
|
||||
@ -314,6 +313,14 @@ bool CApplicationWindow::open(void)
|
||||
m_windowLabel->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_LEFT);
|
||||
m_windowLabel->setTextAlignmentVert(NXWidgets::CLabel::TEXT_ALIGNMENT_VERT_CENTER);
|
||||
m_windowLabel->setRaisesEvents(false);
|
||||
|
||||
// Get the window control
|
||||
|
||||
NXWidgets::CWidgetControl *windowControl = m_window->getWidgetControl();
|
||||
|
||||
// Register to receive callbacks on a few select window events
|
||||
|
||||
windowControl->addWindowEventHandler(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -380,6 +387,151 @@ void CApplicationWindow::hide(void)
|
||||
m_windowLabel->disableDrawing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover the contained NXTK window instance
|
||||
*
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::INxWindow *CApplicationWindow::getWindow(void) const
|
||||
{
|
||||
return static_cast<NXWidgets::INxWindow*>(m_window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
*
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
void CApplicationWindow::setWindowLabel(NXWidgets::CNxString &appname)
|
||||
{
|
||||
m_windowLabel->setText(appname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
void CApplicationWindow::registerCallbacks(IApplicationCallback *callback)
|
||||
{
|
||||
m_callback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the minimize icon. This method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void CApplicationWindow::clickMinimizeIcon(int index)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the stop applicaiton icon. This method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void CApplicationWindow::clickStopIcon(int index)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
void CApplicationWindow::handleMouseEvent(void)
|
||||
{
|
||||
// The logic path here is tortuous but flexible:
|
||||
//
|
||||
// 1. A listener thread receives mouse input and injects that into NX
|
||||
// 2. In the multi-user mode, this will send a message to the NX server
|
||||
// 3. The NX server will determine which window gets the mouse input
|
||||
// and send a message to the listener.
|
||||
// 4. The listener will call the NX message dispatcher will will do the
|
||||
// message callback.
|
||||
// 5. The callback goes into an instance of NXWidgets::CCallback that is
|
||||
// part of the CWidget control.
|
||||
// 6. That callback will update mouse information then raise the
|
||||
// mouse event,
|
||||
// 7. Which will finally call this function -- still running deep on the
|
||||
// stack in the listener thread.
|
||||
// 8. This function will then call back into the wiget control to process
|
||||
// the mouse input.
|
||||
|
||||
// Get the CWidgetControl associated with the window
|
||||
|
||||
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
|
||||
|
||||
// And perform a poll
|
||||
|
||||
control->pollEvents();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void CApplicationWindow::handleKeyboardEvent(void)
|
||||
{
|
||||
// The logic path here is tortuous but flexible:
|
||||
//
|
||||
// 1. A listener thread receives keyboard input and injects that into NX
|
||||
// 2. In the multi-user mode, this will send a message to the NX server
|
||||
// 3. The NX server will determine which window gets the keyboard input
|
||||
// and send a message to the listener.
|
||||
// 4. The listener will call the NX message dispatcher will will do the
|
||||
// message callback.
|
||||
// 5. The callback goes into an instance of NXWidgets::CCallback that is
|
||||
// part of the CWidget control.
|
||||
// 6. That callback will update keyboard information then raise the
|
||||
// keyboard event,
|
||||
// 7. Which will finally call this function -- still running deep on the
|
||||
// stack in the listener thread.
|
||||
// 8. This function will then call back into the wiget control to process
|
||||
// the keyboard input.
|
||||
|
||||
// Get the CWidgetControl associated with the window
|
||||
|
||||
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
|
||||
|
||||
// And perform a poll
|
||||
|
||||
control->pollEvents();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a mouse button click event.
|
||||
*
|
||||
|
247
nxwm/src/cfullscreenwindow.cxx
Normal file
247
nxwm/src/cfullscreenwindow.cxx
Normal file
@ -0,0 +1,247 @@
|
||||
/********************************************************************************************
|
||||
* NxWidgets/nxwm/src/cfullscreen.cxx
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
* Included Files
|
||||
********************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
#include "nxconfig.hxx"
|
||||
#include "cwidgetcontrol.hxx"
|
||||
#include "cgraphicsport.hxx"
|
||||
|
||||
#include "nxwmconfig.hxx"
|
||||
#include "nxwmglyphs.hxx"
|
||||
#include "cfullscreenwindow.hxx"
|
||||
|
||||
/********************************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
********************************************************************************************/
|
||||
|
||||
/********************************************************************************************
|
||||
* CFullScreenWindow Method Implementations
|
||||
********************************************************************************************/
|
||||
|
||||
using namespace NxWM;
|
||||
|
||||
/**
|
||||
* CFullScreenWindow Constructor
|
||||
*
|
||||
* @param window. The raw window to be used by this application.
|
||||
*/
|
||||
|
||||
CFullScreenWindow::CFullScreenWindow(NXWidgets::CNxWindow *window)
|
||||
{
|
||||
// Save the window for later use
|
||||
|
||||
m_window = window;
|
||||
}
|
||||
|
||||
/**
|
||||
* CFullScreenWindow Destructor
|
||||
*/
|
||||
|
||||
CFullScreenWindow::~CFullScreenWindow(void)
|
||||
{
|
||||
// We didn't create the window. That was done by the task bar,
|
||||
// But we will handle destruction of with window as a courtesy.
|
||||
|
||||
if (m_window)
|
||||
{
|
||||
delete m_window;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize window. Window initialization is separate from
|
||||
* object instantiation so that failures can be reported.
|
||||
*
|
||||
* @return True if the window was successfully initialized.
|
||||
*/
|
||||
|
||||
bool CFullScreenWindow::open(void)
|
||||
{
|
||||
// Get the window control
|
||||
|
||||
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
|
||||
|
||||
// Register to receive callbacks on a few select window events
|
||||
|
||||
control->addWindowEventHandler(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-draw the application window
|
||||
*/
|
||||
|
||||
void CFullScreenWindow::redraw(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The application window is hidden (either it is minimized or it is
|
||||
* maximized, but not at the top of the hierarchy)
|
||||
*/
|
||||
|
||||
void CFullScreenWindow::hide(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover the contained raw window instance
|
||||
*
|
||||
* @return. The window used by this application
|
||||
*/
|
||||
|
||||
NXWidgets::INxWindow *CFullScreenWindow::getWindow(void) const
|
||||
{
|
||||
return static_cast<NXWidgets::INxWindow*>(m_window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the window label
|
||||
*
|
||||
* @param appname. The name of the application to place on the window
|
||||
*/
|
||||
|
||||
void CFullScreenWindow::setWindowLabel(NXWidgets::CNxString &appname)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register to receive callbacks when toolbar icons are selected
|
||||
*/
|
||||
|
||||
void CFullScreenWindow::registerCallbacks(IApplicationCallback *callback)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the minimize icon. This method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void CFullScreenWindow::clickMinimizeIcon(int index)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Simulate a mouse click on the stop applicaiton icon. This method is only
|
||||
* used during automated testing of NxWM.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
|
||||
void CFullScreenWindow::clickStopIcon(int index)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle an NX window mouse input event.
|
||||
*
|
||||
* @param e The event data.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_MOUSE
|
||||
void CFullScreenWindow::handleMouseEvent(void)
|
||||
{
|
||||
// The logic path here is tortuous but flexible:
|
||||
//
|
||||
// 1. A listener thread receives mouse input and injects that into NX
|
||||
// 2. In the multi-user mode, this will send a message to the NX server
|
||||
// 3. The NX server will determine which window gets the mouse input
|
||||
// and send a message to the listener.
|
||||
// 4. The listener will call the NX message dispatcher will will do the
|
||||
// message callback.
|
||||
// 5. The callback goes into an instance of NXWidgets::CCallback that is
|
||||
// part of the CWidget control.
|
||||
// 6. That callback will update mouse information then raise the
|
||||
// mouse event,
|
||||
// 7. Which will finally call this function -- still running deep on the
|
||||
// stack in the listener thread.
|
||||
// 8. This function will then call back into the wiget control to process
|
||||
// the mouse input.
|
||||
|
||||
// Get the CWidgetControl associated with the window
|
||||
|
||||
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
|
||||
|
||||
// And perform a poll
|
||||
|
||||
control->pollEvents();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Handle a NX window keyboard input event.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NX_KBD
|
||||
void CFullScreenWindow::handleKeyboardEvent(void)
|
||||
{
|
||||
// The logic path here is tortuous but flexible:
|
||||
//
|
||||
// 1. A listener thread receives keyboard input and injects that into NX
|
||||
// 2. In the multi-user mode, this will send a message to the NX server
|
||||
// 3. The NX server will determine which window gets the keyboard input
|
||||
// and send a message to the listener.
|
||||
// 4. The listener will call the NX message dispatcher will will do the
|
||||
// message callback.
|
||||
// 5. The callback goes into an instance of NXWidgets::CCallback that is
|
||||
// part of the CWidget control.
|
||||
// 6. That callback will update keyboard information then raise the
|
||||
// keyboard event,
|
||||
// 7. Which will finally call this function -- still running deep on the
|
||||
// stack in the listener thread.
|
||||
// 8. This function will then call back into the wiget control to process
|
||||
// the keyboard input.
|
||||
|
||||
// Get the CWidgetControl associated with the window
|
||||
|
||||
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
|
||||
|
||||
// And perform a poll
|
||||
|
||||
control->pollEvents();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -153,9 +153,9 @@ CNxConsole::~CNxConsole(void)
|
||||
* the contained CApplicationWindow instance.
|
||||
*/
|
||||
|
||||
CApplicationWindow *CNxConsole::getWindow(void) const
|
||||
IApplicationWindow *CNxConsole::getWindow(void) const
|
||||
{
|
||||
return m_window;
|
||||
return static_cast<IApplicationWindow*>(m_window);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,7 +202,7 @@ bool CNxConsole::run(void)
|
||||
|
||||
// Recover the NXTK window instance contained in the application window
|
||||
|
||||
NXWidgets::CNxTkWindow *window = m_window->getWindow();
|
||||
NXWidgets::INxWindow *window = m_window->getWindow();
|
||||
|
||||
// Get the widget control associated with the NXTK window
|
||||
|
||||
@ -308,7 +308,7 @@ void CNxConsole::redraw(void)
|
||||
{
|
||||
// Recover the NXTK window instance contained in the application window
|
||||
|
||||
NXWidgets::CNxTkWindow *window = m_window->getWindow();
|
||||
NXWidgets::INxWindow *window = m_window->getWindow();
|
||||
|
||||
// Get the size of the window
|
||||
|
||||
|
@ -101,12 +101,12 @@ CStartWindow::~CStartWindow(void)
|
||||
|
||||
/**
|
||||
* Each implementation of IApplication must provide a method to recover
|
||||
* the contained CApplicationWindow instance.
|
||||
* the contained IApplicationWindow instance.
|
||||
*/
|
||||
|
||||
CApplicationWindow *CStartWindow::getWindow(void) const
|
||||
IApplicationWindow *CStartWindow::getWindow(void) const
|
||||
{
|
||||
return m_window;
|
||||
return static_cast<IApplicationWindow*>(m_window);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +184,7 @@ void CStartWindow::redraw(void)
|
||||
{
|
||||
// Recover the NXTK window instance contained in the application window
|
||||
|
||||
NXWidgets::CNxTkWindow *window = m_window->getWindow();
|
||||
NXWidgets::INxWindow *window = m_window->getWindow();
|
||||
|
||||
// Get the widget control associated with the NXTK window
|
||||
|
||||
@ -298,7 +298,7 @@ bool CStartWindow::addApplication(IApplication *app)
|
||||
{
|
||||
// Recover the NXTK window instance contained in the application window
|
||||
|
||||
NXWidgets::CNxTkWindow *window = m_window->getWindow();
|
||||
NXWidgets::INxWindow *window = m_window->getWindow();
|
||||
|
||||
// Get the widget control associated with the NXTK window
|
||||
|
||||
|
@ -45,8 +45,6 @@
|
||||
#include "cwidgetcontrol.hxx"
|
||||
#include "cnxtkwindow.hxx"
|
||||
|
||||
#include "nxwmconfig.hxx"
|
||||
#include "nxwmglyphs.hxx"
|
||||
#include "ctaskbar.hxx"
|
||||
|
||||
/********************************************************************************************
|
||||
@ -250,13 +248,14 @@ bool CTaskbar::startWindowManager(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an application window. Creating a new application in the start
|
||||
* window requires three steps:
|
||||
* Create an normal application window. Creating a normal application in the
|
||||
* start window requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::openApplicationWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
* constructor,
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the start window.
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the
|
||||
* start window.
|
||||
*
|
||||
* When the application is selected from the start window:
|
||||
*
|
||||
@ -266,7 +265,7 @@ bool CTaskbar::startWindowManager(void)
|
||||
|
||||
CApplicationWindow *CTaskbar::openApplicationWindow(void)
|
||||
{
|
||||
// Create a framed window for the application
|
||||
// Get a framed window for the application
|
||||
|
||||
NXWidgets::CNxTkWindow *window = openFramedWindow();
|
||||
if (!window)
|
||||
@ -276,17 +275,58 @@ CApplicationWindow *CTaskbar::openApplicationWindow(void)
|
||||
|
||||
// Set size and position of a window in the application area.
|
||||
|
||||
setApplicationGeometry(window);
|
||||
setApplicationGeometry(window, false);
|
||||
|
||||
// Use this window to instantiate the application window
|
||||
|
||||
CApplicationWindow *appwindow = new CApplicationWindow(window);
|
||||
if (!appwindow)
|
||||
CApplicationWindow *appWindow = new CApplicationWindow(window);
|
||||
if (!appWindow)
|
||||
{
|
||||
delete window;
|
||||
}
|
||||
|
||||
return appwindow;
|
||||
return appWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a full screen application window. Creating a new full screen application
|
||||
* requires three steps:
|
||||
*
|
||||
* 1. Call CTaskBar::FullScreenWindow to create a window for the application,
|
||||
* 2. Instantiate the application, providing the window to the application's
|
||||
* constructor,
|
||||
* 3. Then call CStartWindow::addApplication to add the application to the
|
||||
* start window.
|
||||
*
|
||||
* When the application is selected from the start window:
|
||||
*
|
||||
* 4. Call CTaskBar::startApplication start the application and bring its window to
|
||||
* the top.
|
||||
*/
|
||||
|
||||
CFullScreenWindow *CTaskbar::openFullScreenWindow(void)
|
||||
{
|
||||
// Get a raw window for the application
|
||||
|
||||
NXWidgets::CNxWindow *window = openRawWindow();
|
||||
if (!window)
|
||||
{
|
||||
return (CFullScreenWindow *)0;
|
||||
}
|
||||
|
||||
// Set size and position of a window in the application area.
|
||||
|
||||
setApplicationGeometry(window, true);
|
||||
|
||||
// Use this window to instantiate the generia application window
|
||||
|
||||
CFullScreenWindow *appWindow = new CFullScreenWindow(window);
|
||||
if (!appWindow)
|
||||
{
|
||||
delete window;
|
||||
}
|
||||
|
||||
return appWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -561,7 +601,7 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
|
||||
|
||||
NXWidgets::CWidgetControl *widgetControl = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL);
|
||||
|
||||
// Get an (uninitialized) instance of the background window as a class
|
||||
// Get an (uninitialized) instance of the framed window as a class
|
||||
// that derives from INxWindow.
|
||||
|
||||
NXWidgets::CNxTkWindow *window = createFramedWindow(widgetControl);
|
||||
@ -588,11 +628,12 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
|
||||
* Set size and position of a window in the application area.
|
||||
*
|
||||
* @param window. The window to be resized and repositioned
|
||||
* @param fullscreen. True: Use full screen
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
|
||||
void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window)
|
||||
void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen)
|
||||
{
|
||||
// Get the widget control from the task bar window. The physical window geometry
|
||||
// should be the same for all windows.
|
||||
@ -609,31 +650,44 @@ void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window)
|
||||
struct nxgl_point_s pos;
|
||||
struct nxgl_size_s size;
|
||||
|
||||
// In fullscreen mode, the application window gets everything
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
|
||||
size.w = rect.getWidth();
|
||||
size.h = rect.getHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(CONFIG_NXWM_TASKBAR_TOP)
|
||||
pos.x = 0;
|
||||
pos.y = CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
pos.x = 0;
|
||||
pos.y = CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
|
||||
size.w = rect.getWidth();
|
||||
size.h = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
size.w = rect.getWidth();
|
||||
size.h = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
|
||||
size.w = rect.getWidth();
|
||||
size.h = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
size.w = rect.getWidth();
|
||||
size.h = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
|
||||
pos.x = CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
pos.y = 0;
|
||||
pos.x = CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
pos.y = 0;
|
||||
|
||||
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
size.h = rect.getHeight();
|
||||
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
size.h = rect.getHeight();
|
||||
#else
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
pos.x = 0;
|
||||
pos.y = 0;
|
||||
|
||||
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
size.h = rect.getHeight();
|
||||
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
|
||||
size.h = rect.getHeight();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set the size and position the window.
|
||||
*
|
||||
@ -730,7 +784,7 @@ bool CTaskbar::createBackgroundWindow(void)
|
||||
|
||||
// Set the geometry to fit in the application window space
|
||||
|
||||
setApplicationGeometry(static_cast<NXWidgets::INxWindow*>(m_background));
|
||||
setApplicationGeometry(static_cast<NXWidgets::INxWindow*>(m_background), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1034,11 +1088,11 @@ bool CTaskbar::redrawApplicationWindow(IApplication *app)
|
||||
|
||||
// Every application provides a method to obtain its application window
|
||||
|
||||
CApplicationWindow *appWindow = app->getWindow();
|
||||
IApplicationWindow *appWindow = app->getWindow();
|
||||
|
||||
// Each application window provides a method to get the underlying NX window
|
||||
|
||||
NXWidgets::CNxTkWindow *window = appWindow->getWindow();
|
||||
NXWidgets::INxWindow *window = appWindow->getWindow();
|
||||
|
||||
// Raise the application window to the top of the hierarchy
|
||||
|
||||
@ -1085,7 +1139,7 @@ void CTaskbar::hideApplicationWindow(IApplication *app)
|
||||
|
||||
// Every application provides a method to obtain its application window
|
||||
|
||||
CApplicationWindow *appWindow = app->getWindow();
|
||||
IApplicationWindow *appWindow = app->getWindow();
|
||||
|
||||
// Hide the application window toolbar
|
||||
|
||||
|
@ -60,6 +60,8 @@
|
||||
#define BITMAP_NCOLUMNS 25
|
||||
#define BITMAP_NLUTCODES 6
|
||||
|
||||
#define DARK_PLAY_ICON 1
|
||||
|
||||
/********************************************************************************************
|
||||
* Private Bitmap Data
|
||||
********************************************************************************************/
|
||||
@ -69,6 +71,21 @@ using namespace NxWM;
|
||||
/* RGB24 (8-8-8) Colors */
|
||||
|
||||
#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
|
||||
# ifdef DARK_PLAY_ICON
|
||||
|
||||
static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x00a200, 0x006300, 0x004e00, 0x008100, 0x003600 /* Codes 1-5 */
|
||||
};
|
||||
|
||||
static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x00d800, 0x008400, 0x006800, 0x00ac00, 0x004800, /* Codes 1-5 */
|
||||
};
|
||||
|
||||
# else /* DARK_PLAY_ICON */
|
||||
|
||||
static const uint32_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
@ -81,9 +98,26 @@ static const uint32_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x3fe13f, 0x3fa23f, 0x3f8d3f, 0x3fc03f, 0x3f753f /* Codes 1-5 */
|
||||
};
|
||||
# endif /* DARK_PLAY_ICON */
|
||||
|
||||
/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
|
||||
|
||||
#elif CONFIG_NXWIDGETS_BPP == 16
|
||||
# ifdef DARK_PLAY_ICON
|
||||
|
||||
static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x0500, 0x0300, 0x0260, 0x0400, 0x01a0 /* Codes 1-5 */
|
||||
};
|
||||
|
||||
static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x06c0, 0x0420, 0x0340, 0x0560, 0x0240, /* Codes 1-5 */
|
||||
};
|
||||
|
||||
# else /* DARK_PLAY_ICON */
|
||||
|
||||
static const uint16_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
@ -97,6 +131,8 @@ static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
0x3f07, 0x3d07, 0x3c67, 0x3e07, 0x3ba7, /* Codes 0-5 */
|
||||
};
|
||||
|
||||
# endif /* DARK_PLAY_ICON */
|
||||
|
||||
/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
|
||||
* to lookup an 8-bit value. There is no savings in that! It would be better to just put
|
||||
* the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
|
||||
@ -109,6 +145,22 @@ static const uint16_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
|
||||
/* 8-bit Greyscale */
|
||||
|
||||
# ifdef DARK_PLAY_ICON
|
||||
|
||||
static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x5f, 0x3a, 0x2d, 0x4b, 0x1f /* Codes 1-5 */
|
||||
};
|
||||
|
||||
static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x7e, 0x4d, 0x3d, 0x64, 0x2a /* Codes 1-5 */
|
||||
};
|
||||
|
||||
# else /* DARK_PLAY_ICON */
|
||||
|
||||
static const uint8_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
@ -121,10 +173,26 @@ static const uint8_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
0x9e, 0x79, 0x6c, 0x8a, 0x5e /* Codes 1-5 */
|
||||
};
|
||||
|
||||
# endif /* DARK_PLAY_ICON */
|
||||
# else /* CONFIG_NXWIDGETS_GREYSCALE */
|
||||
|
||||
/* RGB8 (332) Colors */
|
||||
|
||||
# ifdef DARK_PLAY_ICON
|
||||
static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x14, 0x0c, 0x08, 0x10, 0x04 /* Codes 1-5 */
|
||||
};
|
||||
|
||||
static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
0x18, 0x10, 0x0c, 0x14, 0x08 /* Codes 1-5 */
|
||||
};
|
||||
|
||||
# else /* DARK_PLAY_ICON */
|
||||
|
||||
static const nxgl_mxpixel_t g_playNormalLut[BITMAP_NLUTCODES] =
|
||||
{
|
||||
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR, /* Code 0 */
|
||||
@ -137,7 +205,8 @@ static const nxgl_mxpixel_t g_playBrightlLut[BITMAP_NLUTCODES] =
|
||||
0x3c, 0x34, 0x30, 0x38, 0x2c /* Codes 0-5 */
|
||||
};
|
||||
|
||||
# endif
|
||||
# endif /* DARK_PLAY_ICON */
|
||||
# endif /* CONFIG_NXWIDGETS_GREYSCALE */
|
||||
#else
|
||||
# error "Unsupport pixel format"
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user