wm4Nx is a port of twm, Tab Window Manager (or Tom's Window Manager)

version 1.0.10 to NuttX NX windows server.  No, a port is not the right
word.  It is a re-design of TWM from the inside out to work with the NuttX
NX server.  The name Twm4Nx reflects this legacy.  But Twm4Nx is more a
homage to TWM than a port of TWM.

The original TWM was based on X11 which provides a rich set of features.
TWM provided titlebars, shaped windows, several forms of icon management,
user-defined macro functions, click-to-type and pointer-driven keyboard
focus, graphic contexts, and user-specified key and pointer button bindings,
etc.

Twm4Nx, on the other hand is based on the NuttX NX server which provides
comparatively minimal support.  Additional drawing support comes from
the NuttX NxWidgets library (which necessitated the change to C++).

Twm4Nx is greatly stripped down and targeted on small embedded systems
with minimal resources.  For example, no assumption is made about the
availability of a file system; no .twmrc file is used.  Bitmaps are not
used (other than for fonts).

The TWM license is, I believe compatible with the BSD license used by NuttX.
The origin TWM license required notice of copyrights within each file and
a full copy of the original license which you can find in the COPYING file.
within this directory.

STATUS:

This port was brutal.  Much TWM logic was removed because it depending on X11 features (or just because I could not understand how to use it).  The logic is partial.  A lot more needs to be done to have a complete system (hence, it is marked EXPERIMENTAL).  The kinds of things that need to done are:

1. Update some logic that is only fragmentary for how like resizing, and menus.
2. Integrate NxWidgets into the windows:  The resize menu needs a CLabel, the menus are CListBox'es, but not completely integrated, the Icon Manager needs to be a button array.
3. Resit Icons.  They are windows now, but need to be compound widgets lying on the background.
4. Widget events are only partially integrated.  A lot more needs to be done.  A partial change to thoe event system that hints at the redesign is in place but it is far from complete.
This commit is contained in:
Gregory Nutt 2019-04-25 16:54:17 -06:00
parent 04a05b3e7b
commit 950b4cb604
56 changed files with 13204 additions and 6 deletions

View file

@ -129,12 +129,15 @@ namespace NXWidgets
extern const struct SBitmap g_capslock;
extern const struct SBitmap g_control;
// Bitmaps used by NxWM
// Bitmaps used by NxWM and Twm4Nx
// Global RLE Paletted Bitmaps
extern const struct SRlePaletteBitmap g_calculatorBitmap;
extern const struct SRlePaletteBitmap g_calibrationBitmap;
extern const struct SRlePaletteBitmap g_cmdBitmap;
extern const struct SRlePaletteBitmap g_menuBitmap;
extern const struct SRlePaletteBitmap g_resizeBitmap;
extern const struct SRlePaletteBitmap g_nxiconBitmap;
// Used by NxWM meda player

View file

@ -48,6 +48,8 @@
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxfonts.h>
#include "graphics/nxwidgets/nxconfig.hxx"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/

View file

@ -437,8 +437,8 @@ namespace NXWidgets
* pollKeyboardEvents()
* pollCursorControlEvents()
*
* @param widget. Specific widget to poll. Use NULL to run the
* all widgets in the window.
* @param widget. Specific widget to poll. Use NULL to run through
* of the widgets in the window.
* @return True means some interesting event occurred
*/

View file

@ -0,0 +1,141 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cbackground.hxx
// Manage background image
//
// Copyright (C) 2019 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CBACKGROUND_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CBACKGROUND_HXX
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "graphics/nxwidgets/nxconfig.hxx"
#include "graphics/nxwidgets/cnxwindow.hxx"
#include "graphics/nxwidgets/cnxserver.hxx"
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Implementation Class Definition
****************************************************************************/
namespace NXWidgets
{
class CBgWindow; // Forward reference
class CImage; // Forward reference
struct SRlePaletteBitmap; // Forward reference
}
namespace Twm4Nx
{
class CTwm4Nx; // Forward reference
/**
* Background management
*/
class CBackground
{
protected:
FAR CTwm4Nx *m_twm4nx; /**< Cached CTwm4Nx instance */
FAR NXWidgets::CBgWindow *m_backWindow; /**< The background window */
FAR NXWidgets::CImage *m_backImage; /**< The background image */
/**
* Create the background window.
*
* @return true on success
*/
bool createBackgroundWindow(void);
/**
* Create the background image.
*
* @param sbitmap. Identifies the bitmap to paint on background
* @return true on success
*/
bool createBackgroundImage(FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap);
/**
* (Re-)draw the background window.
*
* @return true on success
*/
bool redrawBackgroundWindow(void);
public:
/**
* CBackground Constructor
*
* @param twm4nx The Twm4Nx session object
*/
CBackground(FAR CTwm4Nx *twm4nx);
/**
* CBackground Destructor
*/
~CBackground(void);
/**
* Set the background image
*
* @param sbitmap. Identifies the bitmap to paint on background
* @return true on success
*/
bool setBackgroundImage(FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap);
/**
* Get the size of the physical display device which is equivalent to
* size of the background window.
*
* @return The size of the display
*/
void getDisplaySize(FAR struct nxgl_size_s &size);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CBACKGROUND_HXX

View file

@ -0,0 +1,182 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cfonts.hxx
// Font support for twm4nx
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
// Copyright 1988 by Evans & Sutherland Computer Corporation,
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CFONTS_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CFONTS_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <stdint.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxfonts.h>
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
class CNxFont; // Forward reference
}
namespace Twm4Nx
{
class CTwm4Nx; // Forward reference
/**
* The CFonts class encapsulates font support.
*/
class CFonts
{
private:
FAR CTwm4Nx *m_twm4nx; /**< The Twm4Nx session */
FAR NXWidgets::CNxFont *m_titleFont; /**< Title bar font */
FAR NXWidgets::CNxFont *m_menuFont; /**< Menu font */
FAR NXWidgets::CNxFont *m_iconFont; /**< Icon font */
FAR NXWidgets::CNxFont *m_sizeFont; /**< Resize font */
FAR NXWidgets::CNxFont *m_iconManagerFont; /**< Window list font */
FAR NXWidgets::CNxFont *m_defaultFont; /**< The default found */
public:
/**
* CFonts Constructor
*
* @param twm4nx. An instance of the Twm4Nx session.
*/
CFonts(FAR CTwm4Nx *twm4nx);
/**
* CFonts Destructor
*/
~CFonts(void);
/**
* Initialize fonts
*
* @return True is returned if the fonts were correctly initialized;
* false is returned in the event of an error.
*/
bool initialize(void);
/**
* Return the Title font
*
* @return A reference to the initialized title font.
*/
FAR NXWidgets::CNxFont *getTitleFont(void)
{
return m_titleFont;
}
/**
* Return the Menu font
*
* @return A reference to the initialized menu font.
*/
FAR NXWidgets::CNxFont *getMenuFont(void)
{
return m_menuFont;
}
/**
* Return the Icon font
*
* @return A reference to the initialized menu font.
*/
FAR NXWidgets::CNxFont *getIconFont(void)
{
return m_iconFont;
}
/**
* Return the Size font
*
* @return A reference to the initialized menu font.
*/
FAR NXWidgets::CNxFont *getSizeFont(void)
{
return m_sizeFont;
}
/**
* Return the IconManager font
*
* @return A reference to the initialized menu font.
*/
FAR NXWidgets::CNxFont *getIconManagerFont(void)
{
return m_iconManagerFont;
}
/**
* Return the Default font
*
* @return A reference to the initialized menu font.
*/
FAR NXWidgets::CNxFont *getDefaultFont(void)
{
return m_defaultFont;
}
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CFONTS_HXX

View file

@ -0,0 +1,189 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cicon.hxx
// Icon related definitions
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CICON_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CICON_HXX
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace Twm4Nx
{
class CTwm4Nx; /* Forward reference */
struct SIconEntry; /* Forward reference */
struct SIconRegion
{
FAR struct SIconRegion *flink;
struct nxgl_point_s pos;
struct nxgl_size_s size;
struct nxgl_point_s step; // allocation granularity
FAR struct SIconEntry *entries;
};
struct SIconEntry
{
FAR struct SIconEntry *flink;
struct nxgl_point_s pos;
struct nxgl_size_s size;
FAR CWindow *cwin;
bool used;
};
/**
* The CIcon class supports a database of icons.
*/
class CIcon
{
private:
FAR CTwm4Nx *m_twm4nx; /**< The Twm4Nx session */
FAR struct SNameList *m_icons; /**< List of icon images */
FAR struct SIconRegion *m_regionHead; /**< Head of the icon region list */
FAR struct SIconRegion *m_regionTail; /**< Tail of the icon region list */
inline int roundUp(int v, int multiple)
{
return ((v + multiple - 1) / multiple) * multiple;
}
/**
* Find the icon region holding the window 'cwin'
*
* @param cwin The window whose icon region is sought
* @param irp A location in which to provide the region
*/
FAR struct SIconEntry *findEntry(FAR CWindow *cwin,
FAR struct SIconRegion **irp);
/**
* Given entry 'ie' in the list 'ir', return the entry just prior to 'ie'
*
* @param ie The entry whose predecessor is sought
* @param ir The region containing the entry
* @return The entry just before 'ie' in the list
*/
FAR struct SIconEntry *prevEntry(FAR struct SIconEntry *ie,
FAR struct SIconRegion *ir);
/**
* 'old' is being freed; and is adjacent to ie. Merge
* regions together
*/
void mergeEntries(FAR struct SIconEntry *old,
FAR struct SIconEntry *ie);
/**
* Free all of the icon entries linked to a region
*
* @param ir The region whose entries will be freed
*/
void freeIconEntries(FAR struct SIconRegion *ir);
/**
* Free all icon regions and all of the region entries linked into the
* region
*/
void freeIconRegions(void);
public:
/**
* CIcon Constructor
*/
CIcon(FAR CTwm4Nx *twm4nx);
/**
* CIcon Destructor
*/
~CIcon(void);
/**
* Create a new icon region and add it to the list of icon regions.
*
* @param pos The position of the region on the background
* @param size The size of the region
* @param step
*/
void addIconRegion(FAR nxgl_point_s *pos, FAR nxgl_size_s *size,
FAR struct nxgl_point_s *step);
/**
* Position an icon on the background
*
* @param cwin The Window whose icon will be placed
* @param pos An backup position to use is there are no available regions
* @param final A location in which to return the selection icon position
*/
void place(FAR CWindow *cwin, FAR const struct nxgl_point_s *pos,
FAR struct nxgl_point_s *final);
/**
* Bring the window up.
*
* @param cwin. The window to be brought up.
*/
void up(FAR CWindow *cwin);
/**
* Take the window down.
*
* @param cwin. The window to be taken down.
*/
void down(FAR CWindow *cwin);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CICON_HXX

View file

@ -0,0 +1,269 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/ciconmgr.hxx
// Icon Manager includes
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CICONMGR_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CICONMGR_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/nx/nxglib.h>
#include "graphics/twm4nx/cwindow.hxx"
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
class CNxTkWindow; // Forward reference
struct SRlePaletteBitmap; // Forward reference
}
namespace Twm4Nx
{
struct SWindowEntry
{
FAR struct SWindowEntry *flink;
FAR struct SWindowEntry *blink;
FAR CWindow *cwin; // Used only for the window name
FAR CIconMgr *iconmgr;
nxgl_point_s pos;
nxgl_size_s size;
int row;
int col;
int me;
bool active;
bool down;
};
class CIconMgr
{
private:
FAR CTwm4Nx *m_twm4nx; /**< Cached Twm4Nx session */
FAR struct SWindowEntry *m_head; /**< Head of the window list */
FAR struct SWindowEntry *m_tail; /**< Tail of the window list */
FAR struct SWindowEntry *m_active; /**< The active entry */
FAR struct CWindow *m_window; /**< Parent window */
unsigned int m_columns; /**< Number of columns icon manager */
unsigned int m_currows;
unsigned int m_curcolumns;
unsigned int m_count;
/**
* Create and initialize the icon manager window
*
* @param name The prefix for this icon manager name
*/
bool createWindow(FAR const char *prefix);
/**
* Create the button array widget
*/
bool createButtonArray(void);
/**
* Put an allocated entry into an icon manager
*
* @param wentry the entry to insert
*/
void insertEntry(FAR struct SWindowEntry *wentry,
FAR CWindow *cwin);
/**
* Remove an entry from an icon manager
*
* @param wentry the entry to remove
*/
void removeEntry(FAR struct SWindowEntry *wentry);
/**
* Set active window
*
* @param wentry Window to become active.
*/
void active(FAR struct SWindowEntry *wentry);
/**
* Set window inactive
*
* @param wentry windows to become inactive.
*/
void inactive(FAR struct SWindowEntry *wentry);
/**
* Free window list entry.
*/
void freeWEntry(FAR struct SWindowEntry *wentry);
public:
/**
* CIconMgr Constructor
*
* @param twm4nx The Twm4Nx session
* @param ncolumns The number of columns this icon manager has
*/
CIconMgr(CTwm4Nx *twm4nx, int ncolumns);
/**
* CIconMgr Destructor
*/
~CIconMgr(void);
/**
* Create and initialize the icon manager window
*
* @param name The prefix for this icon manager name
*/
bool initialize(FAR const char *prefix);
/**
* Add a window to an the icon manager
*
* @param win the TWM window structure
*/
bool add(FAR CWindow *win);
/**
* Hide the icon manager
*/
inline void hide(void)
{
if (m_window != (FAR CWindow *)0)
{
m_window->iconify();
}
}
/**
* Remove a window from the icon manager
*
* @param win the TWM window structure
*/
void remove(FAR struct SWindow *win);
/**
* Get the number of columns
*/
inline unsigned int getColumns(void)
{
return m_columns;
}
/**
* Get the current column
*/
inline unsigned int getCurrColumn(void)
{
return m_curcolumns;
}
/**
* Get the current size
*/
inline bool getSize(FAR struct nxgl_size_s *size)
{
return m_window->getFrameSize(size);
}
/**
* Move the pointer around in an icon manager
*
* @param dir one of the following:
* - EVENT_ICONMGR_FORWARD: Forward in the window list
* - EVENT_ICONMGR_BACK: Backward in the window list
* - EVENT_ICONMGR_UP: Up one row
* - EVENT_ICONMGR_DOWN: Down one row
* - EVENT_ICONMGR_LEFT: Left one column
* - EVENT_ICONMGR_RIGHT: Right one column
*/
void move(int dir);
/**
* Pack the icon manager windows following an addition or deletion
*/
void pack(void);
/**
* sort the windows
*/
void sort(void);
/**
* Handle ICONMGR events.
*
* @param eventmsg. The received NxWidget ICONMGR event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool event(FAR struct SEventMsg *eventmsg);
};
}
/////////////////////////////////////////////////////////////////////////////
// Public Function Prototypes
/////////////////////////////////////////////////////////////////////////////
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CICONMGR_HXX

View file

@ -0,0 +1,214 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/ciconwin.hxx
// Icon Windows
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CICONWIN_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CICONWIN_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include "graphics/nxwidgets/cnxwindow.hxx"
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
struct SRlePaletteBitmap; // Forward reference
}
namespace Twm4Nx
{
class CTwm4Nx; // Forward reference
class CWindow; // Forward reference
/**
* The CIconWin represents on icon window
*/
class CIconWin
{
private:
FAR CTwm4Nx *m_twm4nx; /**< The Twm4Nx session */
FAR NXWidgets::CNxWindow *m_nxwin; /**< The cursor "raw" window */
// Dragging
struct nxgl_point_s m_dragPos; /**< Last mouse position */
struct nxgl_point_s m_dragOffset; /**< Offset from mouse to window origin */
struct nxgl_size_s m_dragCSize; /**< The grab cursor size */
bool m_drag; /**< Drag in-progress */
/**
* Handle the ICON_GRAB event. That corresponds to a left
* mouse click on the icon
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool iconGrab(FAR struct SEventMsg *eventmsg);
/**
* Handle the ICON_DRAG event. That corresponds to a mouse
* movement when the icon is in a grabbed state.
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool iconDrag(FAR struct SEventMsg *eventmsg);
/**
* Handle the ICON_UNGRAB event. The corresponds to a mouse
* left button release while in the grabbed
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool iconUngrab(FAR struct SEventMsg *eventmsg);
/**
* Cleanup on failure or as part of the destructor
*/
void cleanup(void);
public:
/**
* CIconWin Constructor
*/
CIconWin(CTwm4Nx *twm4nx);
/**
* CIconWin Destructor
*/
~CIconWin(void);
/**
* Initialize the icon window
*
* @param parent The parent window
* @param sbitmap The Icon bitmap image
* @param pos The default position
*/
bool initialize(FAR CWindow *parent,
FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap,
FAR const struct nxgl_point_s *pos);
/**
* Get the size of the icon window on the background
*
* @param size The location to return the size of the icon window
*/
inline bool getSize(FAR struct nxgl_size_s *size)
{
return m_nxwin->getSize(size);
}
/**
* Get the icon window position on the background
*
* @param size The location to return the position of the icon window
*/
inline bool getPosition(FAR struct nxgl_point_s *pos)
{
return m_nxwin->getPosition(pos);
}
/**
* Set the icon window position on the background
*
* @param size The new position of the icon window
*/
inline bool setPosition(FAR const struct nxgl_point_s *pos)
{
return m_nxwin->setPosition(pos);
}
/**
* Raise the icon window.
*/
inline void raise(void)
{
m_nxwin->raise();
}
/**
* Lower the icon window.
*/
inline void lower(void)
{
m_nxwin->lower();
}
/**
* Handle ICON WINDOW events.
*
* @param eventmsg. The received NxWidget ICON event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool event(FAR struct SEventMsg *eventmsg);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CICONWIN_HXX

View file

@ -0,0 +1,209 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cinput.hxx
// Keyboard injection
//
// Copyright (C) 2019 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CINPUT_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CINPUT_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/nx/nxglib.h>
#include <semaphore.h>
#include <pthread.h>
#include <nuttx/input/mouse.h>
#include "graphics/nxwidgets/cnxserver.hxx"
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace Twm4Nx
{
class CTwm4Nx; // Forward reference
/**
* The CInput class provides receives raw keyboard and mouse inputs and
* injects that input into NX which it can be properly distributed to the
* window that has focus (i.e., the window at the top of the display
* hierarchy, often a modal window). In additional, the cursor is
* controlled to track the mouse position.
*/
class CInput
{
private:
/**
* The state of the listener thread.
*/
enum EListenerState
{
LISTENER_NOTRUNNING = 0, /**< The listener thread has not yet been started */
LISTENER_STARTED, /**< The listener thread has been started, but is not yet running */
LISTENER_RUNNING, /**< The listener thread is running normally */
LISTENER_STOPREQUESTED, /**< The listener thread has been requested to stop */
LISTENER_TERMINATED, /**< The listener thread terminated normally */
LISTENER_FAILED /**< The listener thread terminated abnormally */
};
/**
* CInput state data
*/
CTwm4Nx *m_twm4nx; /**< The Twm4Nx session */
int m_kbdFd; /**< File descriptor of the opened keyboard device */
int m_mouseFd; /**< File descriptor of the opened mouse device */
pthread_t m_thread; /**< The listener thread ID */
volatile enum EListenerState m_state; /**< The state of the listener thread */
sem_t m_waitSem; /**< Used to synchronize with the listener thread */
/**
* Open the keyboard device. Not very interesting for the case of
* standard device but much more interesting for a USB keyboard device
* that may disappear when the keyboard is disconnect but later reappear
* when the keyboard is reconnected. In this case, this function will
* not return until the keyboard device was successfully opened (or
* until an irrecoverable error occurs.
*
* Opens the keyboard device specified by CONFIG_TWM4NX_KEYBOARD_DEVPATH.
*
* @return On success, then method returns a valid file descriptor. A
* negated errno value is returned if an irrecoverable error occurs.
*/
inline int keyboardOpen(void);
/**
* Open the mouse input devices. Not very interesting for the
* case of standard character device but much more interesting for
* USB mouse devices that may disappear when disconnected but later
* reappear when reconnected. In this case, this function will
* not return until the input device was successfully opened (or
* until an irrecoverable error occurs).
*
* Opens the mouse input device specified by CONFIG_TWM4NX_MOUSE_DEVPATH.
*
* @return On success, then method returns a valid file descriptor. A
* negated errno value is returned if an irrecoverable error occurs.
*/
inline int mouseOpen(void);
/**
* Read data from the keyboard device and inject the keyboard data
* into NX for proper distribution.
*
* @return On success, then method returns a valid file descriptor. A
* negated errno value is returned if an irrecoverable error occurs.
*/
inline int keyboardInput(void);
/**
* Read data from the mouse device, update the cursor position, and
* inject the mouse data into NX for proper distribution.
*
* @return On success, then method returns a valid file descriptor. A
* negated errno value is returned if an irrecoverable error occurs.
*/
inline int mouseInput(void);
/**
* This is the heart of the keyboard/mouse listener thread. It
* contains the actual logic that listeners for and dispatches input
* events to the NX server.
*
* @return If the session terminates gracefully (i.e., because >m_state
* is no longer equal to LISTENER_RUNNING, then method returns OK. A
* negated errno value is returned if an error occurs while reading from
* the input device. A read error, depending upon the type of the
* error, may simply indicate that a USB device was removed and we
* should wait for the device to be connected.
*/
inline int session(void);
/**
* The keyboard/mouse listener thread. This is the entry point of a
* thread that listeners for and dispatches keyboard and mouse events
* to the NX server. It simply opens the input devices (using
* CInput::keyboardOpen() and CInput::mouseOpen()) and executes the
* session (via CInput::session()).
*
* If an errors while reading from the input device AND that device is
* configured to use a USB connection, then this function will wait for
* the USB device to be re-connected.
*
* @param arg. The CInput 'this' pointer cast to a void*.
* @return This function normally does not return but may return NULL
* on error conditions.
*/
static FAR void *listener(FAR void *arg);
public:
/**
* CInput Constructor
*
* @param twm4nx. An instance of the Twm4Nx session.
*/
CInput(CTwm4Nx *twm4nx);
/**
* CInput Destructor
*/
~CInput(void);
/**
* Start the keyboard listener thread.
*
* @return True if the keyboard listener thread was correctly started.
*/
bool start(void);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CINPUT_HXX

View file

@ -0,0 +1,289 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/Cmenus.hxx
// Twm4Nx menus definitions
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
// Copyright 1988 by Evans & Sutherland Computer Corporation,
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CMENUS_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CMENUS_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include "mqueue.h"
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
/////////////////////////////////////////////////////////////////////////////
// Pre-processor Definitions
/////////////////////////////////////////////////////////////////////////////
#define TWM_WINDOWS "TwmNxWindows" // for f.menu "TwmNxWindows"
#define SIZE_HINDENT 10
#define SIZE_VINDENT 2
#define MAXMENUDEPTH 10 // max number of nested menus
#define MOVE_NONE 0 // modes of constrained move
#define MOVE_VERT 1
#define MOVE_HORIZ 2
#define SHADOWWIDTH 5 // in pixels
// Info stings defines
#define INFO_LINES 30
#define INFO_SIZE 200
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
class CNxTkWindow; // Forward reference
class CListBox; // Forward reference
}
namespace Twm4Nx
{
struct SEventMsg; // Forward referernce
class CWindow; // Forward reference
class CMenus; // Forward reference
struct SMenuItem
{
FAR struct SMenuItem *flink; /**< Forward link to next menu item */
FAR struct SMenuItem *blink; /**< Backward link previous menu item */
FAR CMenus *subMenu; /**< Menu root of a pull right menu */
FAR char *text; /**< The text string for the menu item */
FAR const char *action; /**< Action to be performed */
short index; /**< Index of this menu item */
short func; /**< Built-in function */
};
class CMenus: protected NXWidgets::CWidgetEventHandler
{
private:
CTwm4Nx *m_twm4nx; /**< Cached Twm4Nx session */
mqd_t m_eventq; /**< NxWidget event message queue */
FAR struct SFuncKey *m_funcKeyHead; /**< Head of function key list */
FAR NXWidgets::CNxTkWindow *m_menuWindow; /**< The menu window */
FAR CMenus *m_popUpMenu; /**< Pop-up menu */
FAR NXWidgets::CListBox *m_menuListBox; /**< The menu list box */
FAR struct SMenuItem *m_activeItem; /**< The active menu item */
FAR struct SMenuItem *m_menuHead; /**< First item in menu */
FAR struct SMenuItem *m_menuTail; /**< Last item in menu */
FAR char *m_menuName; /**< The name of the menu */
nxgl_coord_t m_entryHeight; /**< Menu entry height */
uint16_t m_nMenuItems; /**< Number of items in the menu */
uint8_t m_menuDepth; /**< Number of menus up */
bool m_menuPull; /**< Is there a pull right entry? */
char m_info[INFO_LINES][INFO_SIZE];
void identify(FAR CWindow *cwin);
/**
* Convert the position of a menu window to the position of
* the containing frame.
*/
inline void menuToFramePos(FAR const struct nxgl_point_s *menupos,
FAR struct nxgl_point_s *framepos)
{
framepos->x = menupos->x - CONFIG_NXTK_BORDERWIDTH;
framepos->y = menupos->y - CONFIG_NXTK_BORDERWIDTH;
}
/**
* Convert the position of the containing frame to the position of
* the menu window.
*/
inline void frameToMenuPos(FAR const struct nxgl_point_s *framepos,
FAR struct nxgl_point_s *menupos)
{
menupos->x = framepos->x + CONFIG_NXTK_BORDERWIDTH;
menupos->y = framepos->y + CONFIG_NXTK_BORDERWIDTH;
}
/**
* Convert the size of a menu window to the size of the containing
* frame.
*/
inline void menuToFrameSize(FAR const struct nxgl_size_s *menusize,
FAR struct nxgl_size_s *framesize)
{
framesize->w = menusize->w + 2 * CONFIG_NXTK_BORDERWIDTH;
framesize->h = menusize->h + 2 * CONFIG_NXTK_BORDERWIDTH;
}
/**
* Convert the size of a containing frame to the size of the menu
* window.
*/
inline void frameToMenuSize(FAR const struct nxgl_size_s *framesize,
FAR struct nxgl_size_s *menusize)
{
menusize->w = framesize->w - 2 * CONFIG_NXTK_BORDERWIDTH;
menusize->h = framesize->h - 2 * CONFIG_NXTK_BORDERWIDTH;
}
/**
* Create the menu window
*
* @result True is returned on success
*/
bool createMenuWindow(void);
/**
* Update the menu window size
*
* @result True is returned on success
*/
bool setMenuWindowSize(void);
/**
* Set the position of the menu window. Supports positioning of a
* pop-up window.
*
* @param framePos The position of the menu window frame
* @result True is returned on success
*/
bool setMenuWindowPosition(FAR struct nxgl_point_s *framePos);
/**
* Set the position of the menu window. Supports presentation of a
* pop-up window.
*
* @param framePos The position of the menu window frame
* @result True is returned on success
*/
inline bool raiseMenuWindow()
{
return m_menuWindow->raise();
}
/**
* Create the menu list box
*
* @result True is returned on success
*/
bool createMenuListBox(void);
void paintMenu(void);
void destroyMenu(void);
/**
* Pop up a pull down menu.
*
* @param pos Location of upper left of menu
*/
bool popUpMenu(FAR struct nxgl_point_s *pos);
/**
* Cleanup or initialization error or on deconstruction.
*/
void cleanup(void);
public:
/**
* CMenus Constructor
*
* @param twm4nx. Twm4Nx session
*/
CMenus(CTwm4Nx *twm4nx);
/**
* CMenus Destructor
*/
~CMenus(void);
/**
* CMenus Initializer. Performs the parts of the CMenus construction
* that may fail.
*
* @param name The menu name
* @result True is returned on success
*/
bool initialize(FAR const char *name);
/**
* Add an item to a root menu
*
* \param text The text to appear in the menu
* \param action The string to possibly execute
* \param subMenu The menu root if it is a pull-right entry
* \param func The numeric function
*/
bool addMenuItem(FAR const char *text,
FAR const char *action,
FAR CMenus *subMenu, int func);
/**
* Handle MENU events.
*
* @param msg. The received NxWidget MENU event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool event(FAR struct SEventMsg *msg);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CMENUS_HXX

View file

@ -0,0 +1,248 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cresize.hxx
// Resize function externs
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
// Copyright 1988 by Evans & Sutherland Computer Corporation,
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CRESIZE_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CRESIZE_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include <nuttx/nx/nxglib.h>
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
class CNxTkWindow; // Forward reference
}
namespace Twm4Nx
{
class CWindow; // Forward referernce
struct SEventMsg; // Forward referernce
class CResize
{
private:
CTwm4Nx *m_twm4nx; /**< Cached Twm4Nx session */
FAR NXWidgets::CNxTkWindow *m_sizeWindow; /**< The resize dimensions window */
FAR CWindow *m_resizeWindow; /**< The window being resized */
struct nxgl_point_s m_origpos; /**< Original position */
struct nxgl_size_s m_origsize; /**< Original size */
struct nxgl_point_s m_dragpos; /**< Dragged position */
struct nxgl_size_s m_dragsize; /**< Dragged size */
struct nxgl_rect_s m_clamp;
struct nxgl_point_s m_delta;
struct nxgl_size_s m_last;
struct nxgl_point_s m_addingPos;
struct nxgl_size_s m_addingSize;
int m_stringWidth; /**< Size of current size string */
#ifdef CONFIG_TWM4NX_AUTO_RERESIZE // Resize relative to position in quad
void autoClamp(CWindow *cwin, FAR struct SEventMsg *eventmsg);
#endif
void resizeFromCenter(FAR CWindow *win);
/**
* Begin a window resize operation
* @param ev the event structure (button press)
* @param cwin the TWM window pointer
*/
void startResize(FAR struct SEventMsg *eventmsg, FAR CWindow *cwin);
void menuStartResize(FAR CWindow *cwin,
FAR struct nxgl_point_s *pos,
FAR struct nxgl_size_s *size);
/**
* Display the size in the dimensions window.
*
* @param cwin The current window
* @param size The size of the rubber band
*/
void displaySize(FAR CWindow *cwin, FAR struct nxgl_size_s *size);
public:
/**
* CResize Constructor
*
* @param twm4nx The Twm4Nx session
*/
CResize(CTwm4Nx *twm4nx);
/**
* CResize Destructor
*/
~CResize(void);
/**
* CResize Initializer. Performs the parts of the CResize construction
* that may fail.
*
* @result True is returned on success
*/
bool initialize(void);
/**
* What is this?
*/
void addingSize(FAR struct nxgl_size_s *size)
{
m_addingSize.w = size->w;
m_addingSize.h = size->h;
}
/**
* Begin a window resize operation
*
* @param cwin the Twm4Nx window pointer
*/
void addStartResize(FAR CWindow *cwin,
FAR struct nxgl_point_s *pos,
FAR struct nxgl_size_s *size);
/**
* @param cwin The current Twm4Nx window
* @param root The X position in the root window
*/
void menuDoResize(FAR CWindow *cwin,
FAR struct nxgl_point_s *root);
/**
* Move the rubberband around. This is called for each motion event when
* we are resizing
*
* @param cwin The current Twm4Nx window
* @param root The X position in the root window
*/
void doResize(FAR CWindow *cwin,
FAR struct nxgl_point_s *root);
/**
* Finish the resize operation
*/
void endResize(FAR CWindow *cwin);
void menuEndResize(FAR CWindow *cwin);
/**
* Finish the resize operation for AddWindo<w
*/
// REVISIT: Not used. Used to be used to handle prompt for window size
// vs. automatically sizing.
void addEndResize(FAR CWindow *cwin);
/**
* Adjust the given width and height to account for the constraints imposed
* by size hints.
*/
// REVISIT: Only used internally. Used to be used to handle prompt
// for window size vs. automatically sizing.
void constrainSize(FAR CWindow *cwin, FAR nxgl_size_s *size);
/**
* Set window sizes.
*
* Special Considerations:
* This routine will check to make sure the window is not completely off the
* display, if it is, it'll bring some of it back on.
*
* The cwin->frame_XXX variables should NOT be updated with the values of
* x,y,w,h prior to calling this routine, since the new values are compared
* against the old to see whether a synthetic ConfigureNotify event should be
* sent. (It should be sent if the window was moved but not resized.)
*
* @param cwin The CWiondow instance
* @param pos The position of the upper-left outer corner of the frame
* @param size The size of the frame window
*/
void setupWindow(FAR CWindow *cwin,
FAR struct nxgl_point_s *pos,
FAR struct nxgl_size_s *size);
/**
* Zooms window to full height of screen or to full height and width of screen.
* (Toggles so that it can undo the zoom - even when switching between fullZoom
* and vertical zoom.)
*
* @param cwin the TWM window pointer
*/
void fullZoom(FAR CWindow *cwin, int flag);
/**
* Handle RESIZE events.
*
* @param msg. The received NxWidget RESIZE event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool event(FAR struct SEventMsg *msg);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CRESIZE_HXX

View file

@ -0,0 +1,315 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/ctwm4nx.hxx
// twm include file
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
// Copyright 1988 by Evans & Sutherland Computer Corporation,
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CTWM4NX_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CTWM4NX_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include <cstdlib>
#include <semaphore.h>
#include <mqueue.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/nx/nxfonts.h>
#include "graphics/nxwidgets/nxconfig.hxx"
#include "graphics/nxwidgets/cnxserver.hxx"
#include "graphics/nxwidgets/cnxwindow.hxx"
#include "graphics/nxwidgets/cimage.hxx"
#include "graphics/twm4nx/cwindowevent.hxx"
#include "graphics/twm4nx/twm4nx_widgetevents.hxx"
/////////////////////////////////////////////////////////////////////////////
// Pre-processor Definitions
/////////////////////////////////////////////////////////////////////////////
// Defines for zooming/unzooming
#define ZOOM_NONE 0
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace Twm4Nx
{
class CInput; // Forward reference
class CBackground; // Forward reference
class CWidgetEvent; // Forward reference
class CIcon; // Forward reference
class CIconMgr; // Forward reference
class CFonts; // Forward reference
class CWindow; // Forward reference
class CResize; // Forward reference
class CWindowFactory; // Forward reference
class CResize; // Forward reference
struct SWindow; // Forward reference
/**
* Public Constant Data
*/
extern const char GNoName[]; /**< Name to use when there is no name */
/**
* This class provides the overall state of the window manager. It is also
* the heart of the window manager: It inherits for CNxServer and, hence,
* represents the NX server itself.
*/
class CTwm4Nx : public NXWidgets::CNxServer
{
private:
int m_display; /**< Display that we are using */
FAR char *m_queueName; /**< NxWidget event queue name */
mqd_t m_eventq; /**< NxWidget event message queue */
FAR CBackground *m_background; /**< Background window management */
FAR CInput *m_input; /**< Keyboard/mouse input injector */
FAR CIcon *m_icon; /**< The cached Cicon instance */
FAR CIconMgr *m_iconmgr; /**< The Default icon manager */
FAR CWindowFactory *m_factory; /**< The cached CWindowFactory instance */
FAR CFonts *m_fonts; /**< The cached Cfonts instance */
FAR CResize *m_resize; /**< The cached CResize instance */
/* Display properties */
FAR struct nxgl_size_s m_displaySize; /**< Size of the display */
FAR struct nxgl_size_s m_maxWindow; /**< Maximum size of a window */
/**
* Connect to the NX server
*
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool connect(void);
/**
* Generate a random message queue name. Different message queue
* names are required for each instance of Twm4Nx that is started.
*/
inline void genMqName(void);
/**
* Handle SYSTEM events.
*
* @param eventmsg. The received NxWidget SYSTEM event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
inline bool systemEvent(FAR struct SEventMsg *eventmsg);
/**
* Cleanup in preparation for termination.
*/
void cleanup(void);
public:
/**
* CTwm4Nx Constructor
*
* @param display. Indicates which display will be used. Usually zero
* except in the case wehre there of multiple displays.
*/
CTwm4Nx(int display);
/**
* CTwm4Nx Destructor
*/
~CTwm4Nx(void);
/**
* This is the main, controlling thread of the window manager. It is
* called only from the extern "C" main() entry point.
*
* NOTE: In the event of truly abnormal conditions, this function will
* not return. It will exit via the abort() method.
*
* @return True if the window manager was terminated properly. false is
* return on any failure.
*/
bool run(void);
/**
* Return a reference to the randomly generated event messageq queue
* name. Different message queue names are required for each instance
* of Twm4Nx that is started.
*/
inline FAR const char *getEventQueueName(void)
{
return m_queueName;
}
/**
* Return the size of the physical display (whichi is equivalent to the
* size of the contained background window).
*
* @return The size of the display.
*/
inline void getDisplaySize(FAR struct nxgl_size_s *size)
{
size->w = m_displaySize.w;
size->h = m_displaySize.h;
}
/**
* Return the pixel depth.
*
* REVISIT: Currently only the pixel depth configured for NxWidgets is
* supported. That is probably compatible ith support for multiple
* displays of differing resolutions.
*
* @return The number of bits-per-pixel.
*/
inline uint8_t getPixelDepth(void)
{
return CONFIG_NXWIDGETS_BPP;
}
/**
* Return the maximum size of a window.
*
* @return The maximum size of a window.
*/
inline void maxWindowSize(FAR struct nxgl_size_s *size)
{
size->w = m_maxWindow.w;
size->h = m_maxWindow.h;
}
/**
* Return the session's Icon instance.
*
* @return The contained instance of the Icon class for this session.
*/
inline FAR CIcon *getIcon(void)
{
return m_icon;
}
/**
* Return the session's Icon Manager instance.
*
* @return The contained instance of the Icon Manager for this session.
*/
inline FAR CIconMgr *getIconMgr(void)
{
return m_iconmgr;
}
/**
* Return the session's CWindowFactory instance.
*
* @return The contained instance of the CWindow instance this session.
*/
inline FAR CWindowFactory *getWindowFactory(void)
{
return m_factory;
}
/**
* Return the session's CFonts instance.
*
* @return The contained instance of the CMenus instance for this session.
*/
inline FAR CFonts *getFonts(void)
{
return m_fonts;
}
/**
* Return the session's CResize instance.
*
* @return The contained instance of the CResize instance for this
* session.
*/
inline FAR CResize *getResize(void)
{
return m_resize;
}
/**
* Dispatch NxWidget-related events. Normally used only internally
* but there is one use case where messages are injected here from
* CMenus.
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly dispatched. false is
* return on any failure.
*/
bool dispatchEvent(FAR struct SEventMsg *eventmsg);
/**
* Cleanup and exit Twm4Nx abnormally.
*/
void abort(void);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CTWM4NX_HXX

View file

@ -0,0 +1,592 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cwindow.hxx
// Represents one window instance
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
// Copyright 1988 by Evans & Sutherland Computer Corporation,
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOW_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOW_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <cstdint>
#include <nuttx/nx/nxglib.h>
#include "graphics/nxwidgets/cnxtoolbar.hxx"
#include "graphics/nxwidgets/cwidgeteventhandler.hxx"
#include "graphics/nxwidgets/cwidgeteventargs.hxx"
#include "graphics/twm4nx/ciconwin.hxx"
/////////////////////////////////////////////////////////////////////////////
// Pre-processor Definitions
/////////////////////////////////////////////////////////////////////////////
/**
* Toolbar Icons. The Title bar contains (from left to right):
*
* 1. Menu button
* 2. Window title (text)
* 3. Minimize (Iconify) button
* 4. Resize button
* 5. Delete button
*
* There is no focus indicator
*/
#define MENU_BUTTON 0 // First on left
#define DELETE_BUTTON 1 // First on right
#define RESIZE_BUTTON 2
#define MINIMIZE_BUTTON 3
#define NTOOLBAR_BUTTONS 4
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
class CImage; // Forward reference
class CLabel; // Forward reference
struct SRlePaletteBitmap; // Forward reference
}
namespace Twm4Nx
{
class CIconWin; // Forward reference
class CIconMgr; // Forward reference
class CWindow; // Forward reference
struct SMenuRoot; // Forward reference
struct SMenuItem; // Forward reference
struct SToolbarButton; // Forward reference
// The CWindow class implements a standard, framed window with a toolbar
// containing the standard buttons and the window title.
class CWindow : protected NXWidgets::CWidgetEventHandler
{
private:
CTwm4Nx *m_twm4nx; /**< Cached Twm4Nx session */
mqd_t m_eventq; /**< NxWidget event message queue */
// Primary Window
FAR char *m_name; /**< Name of the window */
FAR NXWidgets::CNxTkWindow *m_nxWin; /**< The contained NX primary window */
uint16_t m_zoom; /**< Window zoom: ZOOM_NONE or EVENT_RESIZE_* */
bool m_modal; /**< Window zoom: ZOOM_NONE or EVENT_RESIZE_* */
// Icon
FAR CIconWin *m_iconWin; /**< The icon window */
FAR CIconMgr *m_iconMgr; /**< Pointer to it if this is an icon manager */
bool m_isIconMgr; /**< This is an icon manager window */
bool m_iconMoved; /**< User explicitly moved the icon. */
bool m_iconOn; /**< Icon is visible. */
bool m_iconified; /**< Is the window an icon now ? */
// Toolbar
FAR NXWidgets::CNxToolbar *m_toolbar; /**< The tool bar sub-window */
FAR NXWidgets::CLabel *m_tbTitle; /**< Toolbar title widget */
nxgl_coord_t m_tbHeight; /**< Height of the toolbar */
nxgl_coord_t m_tbLeftX; /**< Rightmost position of left buttons */
nxgl_coord_t m_tbRightX; /**< Leftmost position of right buttons */
// List of all toolbar button images
FAR NXWidgets::CImage *m_tbButtons[NTOOLBAR_BUTTONS];
// Dragging
struct nxgl_point_s m_dragOffset; /**< Offset from mouse to window origin */
struct nxgl_size_s m_dragCSize; /**< The grab cursor size */
bool m_drag; /**< Drag in-progress */
/**
* Create the main window
*
* @param winsize The initial window size
* @param winpos The initial window position
*/
bool createMainWindow(FAR const nxgl_size_s *winsize,
FAR const nxgl_point_s *winpos);
/**
* Calculate the height of the tool bar
*/
bool getToolbarHeight(FAR const char *name);
/**
* Create all toolbar buttons
*/
bool createToolbarButtons(void);
/**
* Add buttons and title widgets to the tool bar
*
* @param name The name to use for the toolbar title
*/
bool createToolbarTitle(FAR const char *name);
/**
* Create the tool bar
*/
bool createToolbar(void);
/**
* Update the toolbar layout, resizing the title text window and
* repositioning all windows on the toolbar.
*/
bool updateToolbarLayout(void);
/**
* Disable widget drawing and widget events.
*/
bool disableWidgets(void);
/**
* Enable widget drawing and widget events.
*/
bool enableWidgets(void);
/**
* Override the mouse button drag event.
*
* @param e The event data.
*/
void handleDragEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Override a drop event, triggered when the widget has been dragged-and-dropped.
*
* @param e The event data.
*/
void handleDropEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Handle a key press event.
*
* @param e The event data.
*/
void handleKeyPressEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Override the virtual CWidgetEventHandler::handleActionEvent. This
* event will fire when the image is released but before it has been
* has been drawn. isClicked() will return true for the appropriate
* images.
*
* @param e The event data.
*/
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Handle the TOOLBAR_GRAB event. That corresponds to a left
* mouse click on the toolbar (other than on an icon)
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool toolbarGrab(FAR struct SEventMsg *eventmsg);
/**
* Handle the WINDOW_DRAG event. That corresponds to a mouse
* movement when the window is in a grabbed state.
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool windowDrag(FAR struct SEventMsg *eventmsg);
/**
* Handle the TOOLBAR_UNGRAB event. The corresponds to a mouse
* left button release while in the grabbed
*
* @param eventmsg. The received NxWidget event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool toolbarUngrab(FAR struct SEventMsg *eventmsg);
/**
* Cleanup on failure or as part of the destructor
*/
void cleanup(void);
public:
/**
* CWindow Constructor
*
* @param twm4nx. Twm4Nx session
*/
CWindow(CTwm4Nx *twm4nx);
/**
* CWindow Destructor
*/
~CWindow(void);
/**
* CWindow Initializer (unlike the constructor, this may fail)
*
* @param name The the name of the window (and its icon)
* @param pos The initial position of the window
* @param size The initial size of the window
* @param sbitmap The Icon bitmap image
* @param isIconMgr Flag to tell if this is an icon manager window
* @param iconMgr Pointer to icon manager instance
* @param noToolbar True: Don't add Title Bar
* @return True if the window was successfully initialize; false on
* any failure,
*/
bool initialize(FAR const char *name,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_size_s *size,
FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap,
bool isIconMgr, FAR CIconMgr *iconMgr, bool noToolbar);
/**
* Get the name of the window
*/
inline FAR const char *getWindowName(void)
{
return m_name;
}
/**
* Return true if this is an Icon Manager Window
*/
inline bool isIconMgr(void)
{
return m_isIconMgr;
}
/**
* Return the Icon Manager Window instance
*/
inline FAR CIconMgr *getIconMgr(void)
{
return m_iconMgr;
}
/**
* Get the size of the primary window. This is useful only
* for applications that need to know the drawing area.
*
* @param size Location to return the primary window size
*/
inline bool getWindowSize(FAR struct nxgl_size_s *size)
{
return m_nxWin->getSize(size);
}
/**
* Set the size of the primary window. This is useful only
* for oapplications that need to control the drawing area.
*
* @param size New primary window size
*/
inline bool setWindowSize(FAR const struct nxgl_size_s *size)
{
return m_nxWin->setSize(size);
}
/**
* Get the height of the tool bar
*/
inline nxgl_coord_t getToolbarHeight(void)
{
return m_tbHeight;
}
/**
* Raise the window to the top of the hierarchy.
*/
inline bool raiseWindow(void)
{
return m_nxWin->raise();
}
/**
* Lower the window to the bottom of the hierarchy.
*/
inline bool lowerWindow(void)
{
return m_nxWin->lower();
}
/**
* Convert the position of a primary window to the position of
* the containing frame.
*/
inline void windowToFramePos(FAR const struct nxgl_point_s *winpos,
FAR struct nxgl_point_s *framepos)
{
framepos->x = winpos->x - CONFIG_NXTK_BORDERWIDTH;
framepos->y = winpos->y - m_tbHeight - CONFIG_NXTK_BORDERWIDTH;
}
/**
* Convert the position of the containing frame to the position of the
* primary window.
*/
inline void frameToWindowPos(FAR const struct nxgl_point_s *framepos,
FAR struct nxgl_point_s *winpos)
{
winpos->x = framepos->x + CONFIG_NXTK_BORDERWIDTH;
winpos->y = framepos->y + m_tbHeight + CONFIG_NXTK_BORDERWIDTH;
}
/**
* Convert the size of a primary window to the size of the containing
* frame.
*/
inline void windowToFrameSize(FAR const struct nxgl_size_s *winsize,
FAR struct nxgl_size_s *framesize)
{
framesize->w = winsize->w + 2 * CONFIG_NXTK_BORDERWIDTH;
framesize->h = winsize->h + m_tbHeight + 2 * CONFIG_NXTK_BORDERWIDTH;
}
/**
* Convert the size of the containing frame to the size of the primary window to the size of the containing
* frame.
*/
inline void frameToWindowSize(FAR const struct nxgl_size_s *framesize,
FAR struct nxgl_size_s *winsize)
{
winsize->w = framesize->w - 2 * CONFIG_NXTK_BORDERWIDTH;
winsize->h = framesize->h - m_tbHeight - 2 * CONFIG_NXTK_BORDERWIDTH;
}
/**
* Get the raw window size (including toolbar and frame)
*
* @param framesize Location to return the window frame size
*/
bool getFrameSize(FAR struct nxgl_size_s *framesize);
/**
* Update the window frame after a resize operation (includes the toolbar
* and user window)
*
* @param size The new window frame size
* @param pos The frame location which may also have changed
*/
bool resizeFrame(FAR const struct nxgl_size_s *framesize,
FAR struct nxgl_point_s *framepos);
/**
* Get the raw frame position (accounting for toolbar and frame)
*
* @param framepos Location to return the window frame position
*/
bool getFramePosition(FAR struct nxgl_point_s *framepos);
/**
* Set the raw frame position (accounting for toolbar and frame)
*
* @param framepos The new raw window position
*/
bool setFramePosition(FAR const struct nxgl_point_s *framepos);
/* Minimize (iconify) the window */
void iconify(void);
/**
* De-iconify the window
*/
void deIconify(void);
/**
* Is the window iconified?
*/
inline bool isIconified(void)
{
return m_iconified;
}
/**
* Has the Icon moved?
*/
inline bool hasIconMoved(void)
{
return m_iconMoved;
}
/**
* Set Icon moved
*/
inline void setIconMoved(bool moved)
{
m_iconMoved = moved;
}
/**
* Get the size of the icon window associated with this application
* window. This is needed for placement of the icon on the background
* window.
*
* @param size Location to return the icon window size
*/
inline bool getIconWindowSize(FAR struct nxgl_size_s *size)
{
return m_iconWin->getSize(size);
}
/**
* Get the current position of the icon window associated with the
* application window. This is needed for placement of the icon on
* the background window.
*
* @param pos Location to return the icon window position
*/
inline bool getIconWindowPosition(FAR struct nxgl_point_s *pos)
{
return m_iconWin->getPosition(pos);
}
/**
* Set the new position of the icon window associated with the
* application window. This is needed for placement of the icon on the
* background window.
*
* @param pos The new location of the icon window
*/
inline bool setIconWindowPosition(FAR const struct nxgl_point_s *pos)
{
return m_iconWin->setPosition(pos);
}
/**
* Get zoom
*/
inline uint16_t getZoom(void)
{
return m_zoom;
}
/**
* Set zoom
*
* @param zoom The new zoom setting
*/
inline void setZoom(uint16_t zoom)
{
m_zoom = zoom;
}
/**
* Check for widget-related toolbar events, typically button presses.
* This is called by event handling logic for events that require
* detection of widget events.
*/
inline bool pollToolbarEvents(void)
{
NXWidgets::CWidgetControl *control = m_toolbar->getWidgetControl();
return control->pollEvents();
}
/**
* Handle WINDOW events.
*
* @param eventmsg. The received NxWidget WINDOW event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool event(FAR struct SEventMsg *eventmsg);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOW_HXX

View file

@ -0,0 +1,145 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/src/cwindowevent.hxx
// Shim to manage the interface between NX messages and NxWidgets
//
// Copyright (C) 2019 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOWEVENT_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOWEVENT_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include <sys/types.h>
#include <mqueue.h>
#include "graphics/nxwidgets/cwindoweventhandler.hxx"
#include "graphics/nxwidgets/cwidgetstyle.hxx"
#include "graphics/nxwidgets/cwidgetcontrol.hxx"
#include "graphics/twm4nx/twm4nx_widgetevents.hxx"
#include "graphics/twm4nx/ctwm4nx.hxx"
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus)
namespace Twm4Nx
{
/**
* The class CWindowEvent integrates the widget control with some special
* handling of mouse and keyboard inputs needs by NxWM. It use used
* in place of CWidgetControl whenever an NxWM window is created.
*
* CWindowEvent cohabitates with CWidgetControl only because it needs the
* CWidgetControl as an argument in its messaging.
*/
class CWindowEvent : public NXWidgets::CWindowEventHandler,
public NXWidgets::CWidgetControl
{
private:
FAR CTwm4Nx *m_twm4nx; /**< Cached instance of CTwm4Nx */
mqd_t m_eventq; /**< NxWidget event message queue */
/**
* Send the EVENT_MSG_POLL input event message to the Twm4Nx event loop.
*/
void sendInputEvent(void);
// Override CWidgetEventHandler virutal methods ///////////////////////
#ifdef CONFIG_NX_XYINPUT
/**
* Handle an NX window mouse input event.
*/
void handleMouseEvent(void);
#endif
#ifdef CONFIG_NX_KBD
/**
* Handle a NX window keyboard input event.
*/
void handleKeyboardEvent(void);
#endif
/**
* Handle a NX window blocked event
*
* @param arg - User provided argument (see nx_block or nxtk_block)
*/
void handleBlockedEvent(FAR void *arg);
public:
/**
* CWindowEvent Constructor
*
* @param twm4nx. The Twm4Nx session instance.
* @param style The default style that all widgets on this display
* should use. If this is not specified, the widget will use the
* values stored in the defaultCWidgetStyle object.
*/
CWindowEvent(FAR CTwm4Nx *twm4nx,
FAR const NXWidgets::CWidgetStyle *style =
(const NXWidgets::CWidgetStyle *)NULL);
/**
* CWindowEvent Destructor.
*/
~CWindowEvent(void);
/**
* Handle MSG events.
*
* @param msg. The received system MSG event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
static bool event(FAR struct SEventMsg *msg);
};
}
#endif // __cplusplus
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOWEVENT_HXX

View file

@ -0,0 +1,194 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/cwindowfactory.hxx
// A collection of Window Helpers: Add a new window, put the titlebar and
// other stuff around the window
//
// Copyright (C) 2019 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Largely an original work but derives from TWM 1.0.10 in many ways:
//
// Copyright 1989,1998 The Open Group
// Copyright 1988 by Evans & Sutherland Computer Corporation,
//
// Please refer to apps/twm4nx/COPYING for detailed copyright information.
//
// 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOWFACTORY_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOWFACTORY_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <cstdbool>
#include "graphics/twm4nx/cwindow.hxx"
/////////////////////////////////////////////////////////////////////////////
// Implementation Classes
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
struct SRlePaletteBitmap; // Forward reference
}
namespace Twm4Nx
{
class CWindow; // Forward reference
class CIconMgr; // Forward reference
struct SWindowEntry; // Forward reference
// For each window that is on the display, one of these structures
// is allocated and linked into a list. It is essentially just a
// container for a window.
struct SWindow
{
FAR struct SWindow *flink; /**< Foward link tonext window */
FAR struct SWindow *blink; /**< Backward link to previous window */
FAR struct SWindowEntry *wentry; /**< Icon manager list entry (for list removal) */
FAR CWindow *cwin; /**< Window object payload */
};
/**
* The CWindowFactory class creates new window instances and manages some
* things that are common to all windows.
*/
class CWindowFactory
{
private:
CTwm4Nx *m_twm4nx; /**< Cached Twm4Nx session */
struct nxgl_point_s m_winpos; /**< Position of next window created */
FAR struct SWindow *m_windowHead; /**< List of all windows on the display */
/**
* Add a window container to the window list.
*
* @param win. The window container to be added to the list.
*/
void addWindow(FAR struct SWindow *win);
/**
* Remove a window container from the window list.
*
* @param win. The window container to be removed from the list.
*/
void removeWindow(FAR struct SWindow *win);
/**
* Find the window container that contains the specified window.
*
* @param cwin. The window whose container is needed.
* @return On success, the container of the specific window is returned;
* NULL is returned on failure.
*/
FAR struct SWindow *findWindow(FAR CWindow *cwin);
public:
/**
* CWindowFactory Constructor
*
* @param twm4nx. Twm4Nx session
*/
CWindowFactory(CTwm4Nx *twm4nx);
/**
* CWindowFactory Destructor
*/
~CWindowFactory(void);
/**
* Create a new window and add it to the window list.
*
* @param name The window name
* @param sbitmap The Icon bitmap
* @param isIconMgr Flag to tell if this is an icon manager window
* @param iconMgr Pointer to icon manager instance
* @param noToolbar True: Don't add Title Bar
* @return Reference to the allocated CWindow instance
*/
FAR CWindow *
createWindow(FAR const char *name,
FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap,
bool isIconMgr, FAR CIconMgr *iconMgr, bool noToolbar);
/**
* Handle the EVENT_WINDOW_DELETE event. The logic sequence is as
* follows:
*
* 1. The TERMINATE button in pressed in the Window Toolbar
* 2. CWindowFactory::event receives the widget event,
* EVENT_WINDOW_TERMINATE and request to halt the NX Server
* messages queues.
* 3. The server responds with the EVENT_WINDOW_DELETE which is
* caught by this function.
*
* @param cwin The CWindow instance. This will be deleted and its
* associated container will be freed.
*/
void destroyWindow(FAR CWindow *cwin);
/**
* Return the head of the window list.
*
* @return The head of the window list.
*/
inline FAR struct SWindow *windowHead(void)
{
return m_windowHead;
}
/**
* Handle WINDOW events.
*
* @param msg. The received NxWidget WINDOW event message.
* @return True if the message was properly handled. false is
* return on any failure.
*/
bool event(FAR struct SEventMsg *msg);
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_CWINDOWFACTORY_HXX

View file

@ -0,0 +1,455 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/twm4nx_config.hxx
// Twm4Nx configuration settings
//
// Copyright (C) 2019 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_TWM4NX_CONFIG_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_TWM4NX_CONFIG_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include "graphics/nxglyphs.hxx"
#include "graphics/nxwidgets/nxconfig.hxx"
#include "graphics/nxwidgets/crlepalettebitmap.hxx"
/////////////////////////////////////////////////////////////////////////////
// Pre-Processor Definitions
/////////////////////////////////////////////////////////////////////////////
// General Configuration ////////////////////////////////////////////////////
/**
* Required settings:
*
* CONFIG_HAVE_CXX : C++ support is required
* CONFIG_NX : NX must enabled
* CONFIG_NXTERM=y : For NxTerm support
* CONFIG_SCHED_ONEXIT : Support for on_exit()
*/
#ifndef CONFIG_HAVE_CXX
# error "C++ support is required (CONFIG_HAVE_CXX)"
#endif
/**
* NX Multi-user support is required
*/
#ifndef CONFIG_NX
# error "NX support is required (CONFIG_NX)"
#endif
/**
* NxTerm support is (probably) required to support NxTWM terminals
*/
#if defined(CONFIG_TWM4NX_NXTERM) && !defined(CONFIG_NXTERM)
# warning "NxTerm support may be needed (CONFIG_NXTERM)"
#endif
/**
* on_exit() support is (probably) required. on_exit() is the normal
* mechanism used by Twm4Nx applications to clean-up on a application task
* exit.
*/
#ifndef CONFIG_SCHED_ONEXIT
# warning "on_exit() support may be needed (CONFIG_SCHED_ONEXIT)"
#endif
// Background ///////////////////////////////////////////////////////////////
/**
* CONFIG_TWM4NX_DEFAULT_BACKGROUNDCOLOR - Normal background color. Default:
* MKRGB(148,189,215)
* CONFIG_TWM4NX_BACKGROUND_IMAGE - The name of the image to use in the
* background window. Default:NXWidgets::g_nuttxBitmap160x160
*/
#ifndef CONFIG_TWM4NX_BACKGROUND_IMAGE
# define CONFIG_TWM4NX_BACKGROUND_IMAGE NXWidgets::g_nuttxBitmap160x160
#endif
// Windows //////////////////////////////////////////////////////////////////
// Toolbar /////////////////////////////////////////////////////////////////
/**
* Toolbar Icons. The Title bar contains (from left to right):
*
* 1. Menu button
* 2. Window title (text)
* 3. Minimize (Iconify) button
* 4. Resize button
* 5. Delete button
*
* There is no focus indicator
*/
#ifndef CONFIG_TWM4NX_MENU_IMAGE
# define CONFIG_TWM4NX_MENU_IMAGE NXWidgets::g_menuBitmap
#endif
#ifndef CONFIG_TWM4NX_MINIMIZE_IMAGE
# define CONFIG_TWM4NX_MINIMIZE_IMAGE NXWidgets::g_minimizeBitmap
#endif
#ifndef CONFIG_TWM4NX_RESIZE_IMAGE
# define CONFIG_TWM4NX_RESIZE_IMAGE NXWidgets::g_resizeBitmap
#endif
#ifndef CONFIG_TWM4NX_TERMINATE_IMAGE
# define CONFIG_TWM4NX_TERMINATE_IMAGE NXWidgets::g_stopBitmap
#endif
#ifndef CONFIG_TWM4NX_ICONMGR_IMAGE
# define CONFIG_TWM4NX_ICONMGR_IMAGE NXWidgets::g_nxiconBitmap
#endif
// Spacing. Defaults values good at 75 and 100 DPI
#ifndef CONFIG_TWM4NX_TOOLBAR_HSPACING
# define CONFIG_TWM4NX_TOOLBAR_HSPACING 8
#endif
#ifndef CONFIG_TWM4NX_ICONMGR_VSPACING
# define CONFIG_TWM4NX_FRAME_VSPACING 2
#endif
#ifndef CONFIG_TWM4NX_BUTTON_INDENT
# define CONFIG_TWM4NX_BUTTON_INDENT 1
#endif
#ifndef CONFIG_TWM4NX_ICONMGR_VSPACING
# define CONFIG_TWM4NX_ICONMGR_VSPACING 2
#endif
#ifndef CONFIG_TWM4NX_ICONMGR_HSPACING
# define CONFIG_TWM4NX_ICONMGR_HSPACING 2
#endif
// Menus ////////////////////////////////////////////////////////////////////
/**
* CONFIG_TWM4NX_MENU_IMAGE. Menu image (see toolbar icons)
*/
// Colors ///////////////////////////////////////////////////////////////////
/* Colors *******************************************************************/
/**
* Color configuration
*
* CONFIG_TWM4NX_DEFAULT_BACKGROUNDCOLOR - Normal background color. Default:
* MKRGB(148,189,215)
* CONFIG_TWM4NX_DEFAULT_SELECTEDBACKGROUNDCOLOR - Select background color.
* Default: MKRGB(206,227,241)
* CONFIG_TWM4NX_DEFAULT_SHINEEDGECOLOR - Color of the bright edge of a border.
* Default: MKRGB(255,255,255)
* CONFIG_TWM4NX_DEFAULT_SHADOWEDGECOLOR - Color of the shadowed edge of a border.
* Default: MKRGB(0,0,0)
* CONFIG_TWM4NX_DEFAULT_FONTCOLOR - Default font color. Default:
* MKRGB(0,0,0)
* CONFIG_TWM4NX_TRANSPARENT_COLOR - The "transparent" color. Default:
* MKRGB(0,0,0)
*/
/**
* Normal background color
*/
#ifndef CONFIG_TWM4NX_DEFAULT_BACKGROUNDCOLOR
# define CONFIG_TWM4NX_DEFAULT_BACKGROUNDCOLOR MKRGB(148,189,215)
#endif
/**
* Default selected background color
*/
#ifndef CONFIG_TWM4NX_DEFAULT_SELECTEDBACKGROUNDCOLOR
# define CONFIG_TWM4NX_DEFAULT_SELECTEDBACKGROUNDCOLOR MKRGB(206,227,241)
#endif
/**
* Border colors
*/
#ifndef CONFIG_TWM4NX_DEFAULT_SHINEEDGECOLOR
# define CONFIG_TWM4NX_DEFAULT_SHINEEDGECOLOR MKRGB(248,248,248)
#endif
#ifndef CONFIG_TWM4NX_DEFAULT_SHADOWEDGECOLOR
# define CONFIG_TWM4NX_DEFAULT_SHADOWEDGECOLOR MKRGB(35,58,73)
#endif
/**
* The default font color
*/
#ifndef CONFIG_TWM4NX_DEFAULT_FONTCOLOR
# define CONFIG_TWM4NX_DEFAULT_FONTCOLOR MKRGB(255,255,255)
#endif
/**
* The transparent color
*/
#ifndef CONFIG_TWM4NX_TRANSPARENT_COLOR
# define CONFIG_TWM4NX_TRANSPARENT_COLOR MKRGB(0,0,0)
#endif
// Toolbar Configuration ////////////////////////////////////////////////////
/**
* CONFIG_TWM4NX_TOOLBAR_HEIGHT. The height of the tool bar in each
* application window. At present, all icons are 21 or 42 pixels in height
* (depending on the setting of CONFIG_TWM4NX_LARGE_ICONS) and, hence require
* a task bar of at least that size.
*/
#ifndef CONFIG_TWM4NX_TOOLBAR_HEIGHT
# define CONFIG_TWM4NX_TOOLBAR_HEIGHT \
(CONFIG_TWM4NX_TASKBAR_ICONHEIGHT + 2 * CONFIG_TWM4NX_TASKBAR_HSPACING)
#endif
/* CONFIG_TWM4NX_TOOLBAR_FONTID overrides the default Twm4Nx font selection */
#ifndef CONFIG_TWM4NX_TOOLBAR_FONTID
# define CONFIG_TWM4NX_TOOLBAR_FONTID CONFIG_TWM4NX_DEFAULT_FONTID
#endif
// Background Image //////////////////////////////////////////////////////////
/**
* CONFIG_TWM4NX_BACKGROUND_IMAGE - The name of the image to use in the
* background window. Default:NXWidgets::g_nuttxBitmap160x160
*/
#ifndef CONFIG_TWM4NX_BACKGROUND_IMAGE
# define CONFIG_TWM4NX_BACKGROUND_IMAGE NXWidgets::g_nuttxBitmap160x160
#endif
// Cursor ////////////////////////////////////////////////////////////////////
// Cursor Images
#ifndef CONFIG_TWM4NX_CURSOR_IMAGE // The normal cursor image
# define CONFIG_TWM4NX_CURSOR_IMAGE g_arrow1Cursor
#endif
#ifndef CONFIG_TWM4NX_GBCURSOR_IMAGE // Grab cursor image
# define CONFIG_TWM4NX_GBCURSOR_IMAGE g_grabCursor
#endif
#ifndef CONFIG_TWM4NX_WTCURSOR_IMAGE // Wait cursor image
# define CONFIG_TWM4NX_WTCURSOR_IMAGE g_waitCursor
#endif
// Fonts /////////////////////////////////////////////////////////////////////
// Font IDs
#ifndef CONFIG_TWM4NX_TITLE_FONTID
# define CONFIG_TWM4NX_TITLE_FONTID NXFONT_DEFAULT
#endif
#ifndef CONFIG_TWM4NX_MENU_FONTID
# define CONFIG_TWM4NX_MENU_FONTID NXFONT_DEFAULT
#endif
#ifndef CONFIG_TWM4NX_ICON_FONTID
# define CONFIG_TWM4NX_ICON_FONTID NXFONT_DEFAULT
#endif
#ifndef CONFIG_TWM4NX_SIZE_FONTID
# define CONFIG_TWM4NX_SIZE_FONTID NXFONT_DEFAULT
#endif
#ifndef CONFIG_TWM4NX_ICONMGR_SIZEFONTID
# define CONFIG_TWM4NX_ICONMGR_SIZEFONTID NXFONT_DEFAULT
#endif
// Font Colors
#ifndef CONFIG_TWM4NX_TITLE_FONTCOLOR
# define CONFIG_TWM4NX_TITLE_FONTCOLOR MKRGB(0,64,0)
#endif
#ifndef CONFIG_TWM4NX_MENU_FONTCOLOR
# define CONFIG_TWM4NX_MENU_FONTCOLOR MKRGB(0,64,0)
#endif
#ifndef CONFIG_TWM4NX_ICON_FONTCOLOR
# define CONFIG_TWM4NX_ICON_FONTCOLOR MKRGB(0,64,0)
#endif
#ifndef CONFIG_TWM4NX_SIZE_FONTCOLOR
# define CONFIG_TWM4NX_SIZE_FONTCOLOR MKRGB(0,64,0)
#endif
#ifndef CONFIG_TWM4NX_ICONMGR_FONTCOLOR
# define CONFIG_TWM4NX_ICONMGR_FONTCOLOR MKRGB(0,64,0)
#endif
#ifndef CONFIG_TWM4NX_DEFAULT_FONTCOLOR
# define CONFIG_TWM4NX_DEFAULT_FONTCOLOR MKRGB(0,64,0)
#endif
// NxTerm Window /////////////////////////////////////////////////////////////
/**
* NxTerm Window Configuration
*
* CONFIG_TWM4NX_NXTERM_PRIO - Priority of the NxTerm task. Default:
* SCHED_PRIORITY_DEFAULT. NOTE: This priority should be less than
* CONFIG_NXSTART_SERVERPRIO or else there may be data overrun errors.
* Such errors would most likely appear as duplicated rows of data on the
* display.
* CONFIG_TWM4NX_NXTERM_STACKSIZE - The stack size to use when starting the
* NxTerm task. Default: 2048 bytes.
* CONFIG_TWM4NX_NXTERM_WCOLOR - The color of the NxTerm window background.
* Default: MKRGB(192,192,192)
* CONFIG_TWM4NX_NXTERM_FONTCOLOR - The color of the fonts to use in the
* NxTerm window. Default: MKRGB(0,0,0)
* CONFIG_TWM4NX_NXTERM_FONTID - The ID of the font to use in the NxTerm
* window. Default: CONFIG_TWM4NX_DEFAULT_FONTID
* CONFIG_TWM4NX_NXTERM_ICON - The glyph to use as the NxTerm icon
*/
#ifdef CONFIG_TWM4NX_NXTERM
# ifndef CONFIG_TWM4NX_NXTERM_PRIO
# define CONFIG_TWM4NX_NXTERM_PRIO SCHED_PRIORITY_DEFAULT
# endif
# if CONFIG_NXSTART_SERVERPRIO <= CONFIG_TWM4NX_NXTERM_PRIO
# warning "CONFIG_NXSTART_SERVERPRIO <= CONFIG_TWM4NX_NXTERM_PRIO"
# warning" -- This can result in data overrun errors"
# endif
# ifndef CONFIG_TWM4NX_NXTERM_STACKSIZE
# define CONFIG_TWM4NX_NXTERM_STACKSIZE 2048
# endif
# ifndef CONFIG_TWM4NX_NXTERM_WCOLOR
# define CONFIG_TWM4NX_NXTERM_WCOLOR CONFIG_TWM4NX_DEFAULT_BACKGROUNDCOLOR
# endif
# ifndef CONFIG_TWM4NX_NXTERM_FONTCOLOR
# define CONFIG_TWM4NX_NXTERM_FONTCOLOR CONFIG_TWM4NX_DEFAULT_FONTCOLOR
# endif
# ifndef CONFIG_TWM4NX_NXTERM_FONTID
# define CONFIG_TWM4NX_NXTERM_FONTID CONFIG_TWM4NX_DEFAULT_FONTID
# endif
/**
* The NxTerm window glyph
*/
# ifndef CONFIG_TWM4NX_NXTERM_ICON
# define CONFIG_TWM4NX_NXTERM_ICON NXWidgets::g_cmdBitmap
# endif
#endif
// Input Devices /////////////////////////////////////////////////////////////
/** Common input device settings
*
* CONFIG_TWM4NX_INPUT_SIGNO - The realtime signal used to wake up the
* keyboard/mouse listener thread. Default: 6
* CONFIG_TWM4NX_INPUT_LISTENERPRIO - Priority of the touchscreen listener
* thread. Default: (SCHED_PRIORITY_DEFAULT + 20)
* CONFIG_TWM4NX_INPUT_LISTENERSTACK - Input listener thread stack
* size. Default 1024
*/
#ifndef CONFIG_TWM4NX_INPUT_SIGNO
# define CONFIG_TWM4NX_INPUT_SIGNO 6
#endif
#ifndef CONFIG_TWM4NX_INPUT_LISTENERPRIO
# define CONFIG_TWM4NX_INPUT_LISTENERPRIO (SCHED_PRIORITY_DEFAULT + 20)
#endif
#ifndef CONFIG_TWM4NX_INPUT_LISTENERSTACK
# define CONFIG_TWM4NX_INPUT_LISTENERSTACK 1024
#endif
// Mouse Input Device ////////////////////////////////////////////////////////
/**
* Mouse device settings
*
* CONFIG_TWM4NX_MOUSE_DEVPATH - The full path to the mouse device.
* Default: "/dev/console"
* CONFIG_TWM4NX_MOUSE_USBHOST - Indicates the the mouse is attached via
* USB
* CONFIG_TWM4NX_MOUSE_BUFSIZE - The size of the mouse read data buffer.
* Default: sizeof(struct mouse_report_s)
*/
#ifndef CONFIG_TWM4NX_MOUSE_DEVPATH
# define CONFIG_TWM4NX_MOUSE_DEVPATH "/dev/mouse0"
#endif
#ifndef CONFIG_TWM4NX_MOUSE_BUFSIZE
# define CONFIG_TWM4NX_MOUSE_BUFSIZE sizeof(struct mouse_report_s)
#endif
// Keyboard device ///////////////////////////////////////////////////////////
/**
* Keyboard device settings
*
* CONFIG_TWM4NX_KEYBOARD_DEVPATH - The full path to the keyboard device.
* Default: "/dev/console"
* CONFIG_TWM4NX_KEYBOARD_USBHOST - Indicates the the keyboard is attached via
* USB
* CONFIG_TWM4NX_KEYBOARD_BUFSIZE - The size of the keyboard read data buffer.
* Default: 16
*/
#ifndef CONFIG_TWM4NX_KEYBOARD_DEVPATH
# define CONFIG_TWM4NX_KEYBOARD_DEVPATH "/dev/kbd0"
#endif
#ifndef CONFIG_TWM4NX_KEYBOARD_BUFSIZE
# define CONFIG_TWM4NX_KEYBOARD_BUFSIZE 6
#endif
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_TWM4NX_CONFIG_HXX

View file

@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/twm4nx_cursor.hxx
// Cursor-related definitions
//
// Copyright (C) 2019 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 nor the names of its contributors may 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 __APPS_GRAPHICS_TWM4NX_INCLUDE_TWM4NX_CURSOR_HXX
#define __APPS_GRAPHICS_TWM4NX_INCLUDE_TWM4NX_CURSOR_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include <nuttx/nx/nxcursor.h>
#include "graphics/twm4nx/twm4nx_config.hxx"
#ifdef CONFIG_NX_SWCURSOR
/////////////////////////////////////////////////////////////////////////////
// Public Constant Data
/////////////////////////////////////////////////////////////////////////////
namespace Twm4Nx
{
extern const struct nx_cursorimage_s // Normal cursor
CONFIG_TWM4NX_CURSOR_IMAGE;
extern const struct nx_cursorimage_s // Grab button
CONFIG_TWM4NX_GBCURSOR_IMAGE;
extern const struct nx_cursorimage_s // Wait cursor
CONFIG_TWM4NX_WTCURSOR_IMAGE;
}
/////////////////////////////////////////////////////////////////////////////
// Public Function Prototypes
/////////////////////////////////////////////////////////////////////////////
#endif // CONFIG_NX_SWCURSOR
#endif // __APPS_GRAPHICS_TWM4NX_INCLUDE_TWM4NX_CURSOR_HXX

View file

@ -0,0 +1,215 @@
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/twm4nx/include/twm4nx_widgetevents.hxx
// Twm4Nx Widget Event Handling
//
// Copyright (C) 2019 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 nor the names of its contributors may 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 __APPS_INCLUDE_GRAPHICS_TWM4NX_TWM4NX_WIDGETEVENTS_HXX
#define __APPS_INCLUDE_GRAPHICS_TWM4NX_TWM4NX_WIDGETEVENTS_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include <cstdint>
#include <cstdbool>
#include <nuttx/nx/nxglib.h>
#include "graphics/nxwidgets/cwindoweventhandler.hxx"
/////////////////////////////////////////////////////////////////////////////
// Preprocessor Definitions
/////////////////////////////////////////////////////////////////////////////
#define MAX_EVENT_PAYLOAD (64 - sizeof(uint16_t))
/////////////////////////////////////////////////////////////////////////////
// WidgetEvent
/////////////////////////////////////////////////////////////////////////////
namespace NXWidgets
{
class CNxTkWindow; // Forward reference
}
namespace Twm4Nx
{
class CWindow; // Forward reference
class CWindowEvent; // Forward reference
class CTwm4Nx; // Forward reference
///////////////////////////////////////////////////////////////////////////
// Public Types
///////////////////////////////////////////////////////////////////////////
/**
* This enumeration identifies the recipient of the event
*/
enum EEventRecipient
{
EVENT_RECIPIENT_MSG = 0x0000, /**< Twm4Nx messenging event */
EVENT_RECIPIENT_SYSTEM = 0x1000, /**< Twm4Nx system event */
EVENT_RECIPIENT_ICONWIN = 0x2000, /**< Icon Window event */
EVENT_RECIPIENT_ICONMGR = 0x3000, /**< Icon Manager event */
EVENT_RECIPIENT_MENU = 0x4000, /**< Menu related event */
EVENT_RECIPIENT_WINDOW = 0x5000, /**< Window related event */
EVENT_RECIPIENT_TOOLBAR = 0x6000, /**< Toolbar related event */
EVENT_RECIPIENT_BORDER = 0x7000, /**< Window border related event */
EVENT_RECIPIENT_RESIZE = 0x8000, /**< Window resize event */
EVENT_RECIPIENT_MASK = 0xf000, /**< Used to isolate recipient */
};
/**
* Specific events include the recipient as part of the event ID encoding.
*/
enum EEventID
{
// Recipient == MSG
EVENT_MSG_POLL = 0x0000, /**< Poll widgets for events */
// Recipient == SYSTEM
EVENT_SYSTEM_ERROR = 0x1000, /**< Report system error */
EVENT_SYSTEM_EXIT = 0x1001, /**< Terminate the Twm4Nx session */
// Recipient == ICONWIN
EVENT_ICONWIN_GRAB = 0x2000, /**< Click on toolbar (not toolbar buttons) */
EVENT_ICONWIN_DRAG = 0x2001, /**< Drag window */
EVENT_ICONWIN_UNGRAB = 0x2002, /**< Release click on toolbar */
// Recipient == ICONMGR
EVENT_ICONMGR_FORWARD = 0x3000, /**< Forward in the window list */
EVENT_ICONMGR_BACK = 0x3001, /**< Backward in the window list */
EVENT_ICONMGR_UP = 0x3002, /**< Up one row */
EVENT_ICONMGR_DOWN = 0x3003, /**< Down one row */
EVENT_ICONMGR_LEFT = 0x3004, /**< Left one column */
EVENT_ICONMGR_RIGHT = 0x3005, /**< Right one column */
EVENT_ICONMGR_SHOWPARENT = 0x3006, /**< Raise Icon Manager parent window */
EVENT_ICONMGR_HIDE = 0x3007, /**< Hide the Icon Manager */
EVENT_ICONMGR_SORT = 0x3008, /**< Sort the Icon Manager */
// Recipient == MENU
EVENT_MENU_IDENTIFY = 0x4001, /**< Describe the window */
EVENT_MENU_VERSION = 0x4002, /**< Show the Twm4Nx version */
EVENT_MENU_ICONIFY = 0x4003, /**< Tool bar minimize button pressed */
EVENT_MENU_DEICONIFY = 0x4004, /**< Window icon pressed */
EVENT_MENU_FUNCTION = 0x4005, /**< Perform function on unknown menu */
EVENT_MENU_TITLE = 0x4006, /**< REVISIT: Really an action not an event */
EVENT_MENU_ROOT = 0x4007, /**< REVISIT: Popup root menu */
// Recipient == WINDOW
EVENT_WINDOW_FOCUS = 0x5000, /**< Enter modal state */
EVENT_WINDOW_UNFOCUS = 0x5001, /**< Exit modal state */
EVENT_WINDOW_RAISE = 0x5002, /**< Raise window to the top of the heirarchy */
EVENT_WINDOW_LOWER = 0x5003, /**< Lower window to the bottom of the heirarchy */
EVENT_WINDOW_DRAG = 0x5004, /**< Drag window */
EVENT_WINDOW_POPUP = 0x5005, /**< De-iconify and raise window */
EVENT_WINDOW_DELETE = 0x5006, /**< Delete window */
// Recipient == TOOLBAR
EVENT_TOOLBAR_GRAB = 0x6000, /**< Click on title widget */
EVENT_TOOLBAR_UNGRAB = 0x6001, /**< Release click on title widget */
EVENT_TOOLBAR_MENU = 0x6002, /**< Toolbar menu button released */
EVENT_TOOLBAR_MINIMIZE = 0x6003, /**< Toolbar minimize button released */
EVENT_TOOLBAR_RESIZE = 0x6004, /**< Toolbar resize button released */
EVENT_TOOLBAR_TERMINATE = 0x6005, /**< Toolbar delete button released */
// Recipient == BORDER
// Recipient == RESIZE
EVENT_RESIZE_START = 0x8000, /**< Start window resize */
EVENT_RESIZE_VERTZOOM = 0x8001, /**< Zoom vertically only */
EVENT_RESIZE_HORIZOOM = 0x8002, /**< Zoom horizontally only */
EVENT_RESIZE_FULLZOOM = 0x8003, /**< Zoom both vertically and horizontally */
EVENT_RESIZE_LEFTZOOM = 0x8004, /**< Zoom left only */
EVENT_RESIZE_RIGHTZOOM = 0x8005, /**< Zoom right only */
EVENT_RESIZE_TOPZOOM = 0x8006, /**< Zoom top only */
EVENT_RESIZE_BOTTOMZOOM = 0x8007, /**< Zoom bottom only */
};
// Contexts for button press events
enum EButtonContext
{
EVENT_CONTEXT_WINDOW = 0,
EVENT_CONTEXT_TITLE,
EVENT_CONTEXT_ICON,
EVENT_CONTEXT_ROOT,
EVENT_CONTEXT_FRAME,
EVENT_CONTEXT_ICONMGR,
EVENT_CONTEXT_NAME,
EVENT_CONTEXT_IDENTIFY,
NUM_CONTEXTS
};
/**
* This type represents a generic message containing all possible,
* message-specific options (wasteful, but a lot easier).
*/
struct SEventMsg
{
uint16_t eventID; /**< Encoded event ID */
struct nxgl_point_s pos; /**< X/Y position */
uint8_t context; /**< Button press context */
bool pulldown; /**< Pull-down menu */
FAR const char *action; /**< Menu action */
FAR NXWidgets::CNxTkWindow *nxwin; /**< Raw NX window reference */
FAR void *obj; /**< Window object (CWindow or CIconWin) */
};
/**
* This is the alternative form of the message used on in
* CWindowEvent::event()
*/
struct SNxEventMsg
{
uint16_t eventID; /**< Encoded event ID */
FAR CWindowEvent *instance; /**< X/Y position */
FAR struct SWindow *win; /**< Twm4NX window reference */
};
}
#endif // __APPS_INCLUDE_GRAPHICS_TWM4NX_TWM4NX_WIDGETEVENTS_HXX