Squashed commit of the following:

graphics/twm4nx/src/ciconmgr.cxx:  Integrate use of CButtonArray; implement first cut at event handling.

    graphics/nxwidgets/src/cbuttonarray.cxx:  Add a method to CButtonArray that will allow us to dynamically resize the array (at the cost of losing all button labels).

    graphics/twm4nx/src/ciconmgr.cxx:  Add some fragments of CButtonArray logic.

    graphics/twm4nx/src/cwindow.cxx:  Finishes first cut at window event management.
This commit is contained in:
Gregory Nutt 2019-04-26 12:50:35 -06:00
parent 27194275a5
commit 601659ff59
12 changed files with 592 additions and 328 deletions

View file

@ -214,6 +214,19 @@ namespace NXWidgets
~CButtonArray(void);
/**
* Resize the array of buttons. Button labels will be removed and will
* have to be reapplied in the new geometry.
*
* @param buttonColumns The number of buttons in one row of the button array
* @param buttonRows The number of buttons in one column of the button array
* @param buttonWidth The width of one button
* @param buttonHeight The height of one button
*/
bool resizeArray(uint8_t buttonColumns, uint8_t buttonRows,
nxgl_coord_t buttonWidth, nxgl_coord_t buttonHeight);
/**
* Returns the string shown in the label.
*

View file

@ -465,7 +465,7 @@ namespace NXWidgets
* @return This string.
*/
CNxString &operator=(const char *string);
CNxString &operator=(FAR const char *string);
/**
* Overloaded assignment operator. Copies the data from the argument
@ -509,6 +509,7 @@ namespace NXWidgets
*/
int compareTo(const CNxString &string) const;
int compareTo(FAR const char *string) const;
/**
* snprintf()-style string formatting. Automatically allocates correct

View file

@ -57,6 +57,8 @@
namespace NXWidgets
{
class CNxTkWindow; // Forward reference
class CButtonArray; // Forward reference
class CWidgetEventArgs; // Forward reference
struct SRlePaletteBitmap; // Forward reference
}
@ -72,12 +74,11 @@ namespace Twm4Nx
nxgl_size_s size;
int row;
int col;
int me;
bool active;
bool down;
};
class CIconMgr
class CIconMgr : protected NXWidgets::CWidgetEventHandler
{
private:
@ -86,10 +87,19 @@ namespace Twm4Nx
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;
FAR NXWidgets::CButtonArray *m_buttons; /**< The cotained button array */
uint8_t m_maxColumns; /**< Max columns per row */
uint8_t m_nrows; /**< Number of rows in the button array */
uint8_t m_ncolumns; /**< Number of columns in the button array */
unsigned int m_nWindows; /**< The number of windows in the icon mgr. */
/**
* Return the height of one row
*
* @return The height of one row
*/
nxgl_coord_t getRowHeight(void);
/**
* Create and initialize the icon manager window
@ -144,6 +154,14 @@ namespace Twm4Nx
void freeWEntry(FAR struct SWindowEntry *wentry);
/**
* Handle a widget action event. This will be a button pre-release event.
*
* @param e The event data.
*/
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
public:
/**
@ -153,7 +171,7 @@ namespace Twm4Nx
* @param ncolumns The number of columns this icon manager has
*/
CIconMgr(CTwm4Nx *twm4nx, int ncolumns);
CIconMgr(CTwm4Nx *twm4nx, uint8_t ncolumns);
/**
* CIconMgr Destructor
@ -177,6 +195,14 @@ namespace Twm4Nx
bool add(FAR CWindow *win);
/**
* Remove a window from the icon manager
*
* @param win the TWM window structure
*/
void remove(FAR struct SWindow *win);
/**
* Hide the icon manager
*/
@ -189,30 +215,22 @@ namespace Twm4Nx
}
}
/**
* 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)
inline unsigned int getDisplayColumns(void)
{
return m_columns;
return m_maxColumns;
}
/**
* Get the current column
*/
inline unsigned int getCurrColumn(void)
inline unsigned int getNumberOfColumns(void)
{
return m_curcolumns;
return m_ncolumns;
}
/**
@ -224,20 +242,6 @@ namespace Twm4Nx
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
*/

View file

@ -98,7 +98,6 @@ namespace Twm4Nx
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.
@ -198,6 +197,19 @@ namespace Twm4Nx
bool enableWidgets(void);
/**
* After the toolbar was grabbed, it may be dragged then dropped, or it
* may be simply "un-grabbed". Both cases are handled here.
*
* NOTE: Unlike the other event handlers, this does NOT override any
* virtual event handling methods. It just combines some common event-
* handling logic.
*
* @param e The event data.
*/
void handleUngrabEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Override the mouse button drag event.
*
@ -222,6 +234,16 @@ namespace Twm4Nx
void handleKeyPressEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Override the virtual CWidgetEventHandler::handleReleaseEvent. This
* event will fire when the title widget is released. isClicked()
* will return false for the title widget.
*
* @param e The event data.
*/
void handleReleaseEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Override the virtual CWidgetEventHandler::handleActionEvent. This
* event will fire when the image is released but before it has been
@ -337,7 +359,7 @@ namespace Twm4Nx
/**
* Get the size of the primary window. This is useful only
* for applications that need to know the drawing area.
* for applications that need to know about the drawing area.
*
* @param size Location to return the primary window size
*/
@ -347,6 +369,18 @@ namespace Twm4Nx
return m_nxWin->getSize(size);
}
/**
* Get the position of the primary window. This is useful only
* for applications that need to know about the drawing area.
*
* @param pos Location to return the primary window position
*/
inline bool getWindowPosition(FAR struct nxgl_point_s *pos)
{
return m_nxWin->getPosition(pos);
}
/**
* Set the size of the primary window. This is useful only
* for oapplications that need to control the drawing area.

View file

@ -109,22 +109,12 @@ namespace Twm4Nx
// Recipient == ICONWIN
EVENT_ICONWIN_GRAB = 0x2000, /**< Click on toolbar (not toolbar buttons) */
EVENT_ICONWIN_GRAB = 0x2000, /**< Click on toolbar title */
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 */
@ -173,9 +163,8 @@ namespace Twm4Nx
enum EButtonContext
{
EVENT_CONTEXT_WINDOW = 0,
EVENT_CONTEXT_TITLE,
EVENT_CONTEXT_TOOLBAR,
EVENT_CONTEXT_ICON,
EVENT_CONTEXT_ROOT,
EVENT_CONTEXT_FRAME,
EVENT_CONTEXT_ICONMGR,
EVENT_CONTEXT_NAME,
@ -192,10 +181,8 @@ namespace Twm4Nx
{
uint16_t eventID; /**< Encoded event ID */
struct nxgl_point_s pos; /**< X/Y position */
struct nxgl_point_s delta; /**< X/Y change (for dragging only) */
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) */
};
@ -208,7 +195,7 @@ namespace Twm4Nx
{
uint16_t eventID; /**< Encoded event ID */
FAR CWindowEvent *instance; /**< X/Y position */
FAR struct SWindow *win; /**< Twm4NX window reference */
FAR struct SWindow *win; /**< Twm4NX window reference */
};
}