From cb606359cccd09f00f27db93bb99fb06a3b49abd Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 10 May 2014 01:11:30 +1000 Subject: Multiple changes to GWIN to support containers. --- src/gwin/class_gwin.h | 144 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 120 insertions(+), 24 deletions(-) (limited to 'src/gwin/class_gwin.h') diff --git a/src/gwin/class_gwin.h b/src/gwin/class_gwin.h index 50dd480e..e3b5e2e3 100644 --- a/src/gwin/class_gwin.h +++ b/src/gwin/class_gwin.h @@ -27,16 +27,20 @@ * @brief The predefined flags for a Window * @{ */ -#define GWIN_FLG_DYNAMIC 0x0001 // @< The GWIN structure is allocated -#define GWIN_FLG_VISIBLE 0x0002 // @< The window is visible -#define GWIN_FLG_MINIMIZED 0x0004 // @< The window is minimized -#define GWIN_FLG_MAXIMIZED 0x0008 // @< The window is maximized -#define GWIN_FLG_ENABLED 0x0010 // @< The window is enabled -#define GWIN_FLG_WIDGET 0x0020 // @< This is a widget -#define GWIN_FLG_ALLOCTXT 0x0040 // @< The widget text is allocated -#define GWIN_FLG_MOUSECAPTURE 0x0080 // @< The widget has captured the mouse -#define GWIN_FIRST_WM_FLAG 0x0100 // @< 4 bits free for the window manager to use -#define GWIN_FIRST_CONTROL_FLAG 0x1000 // @< 4 bits free for Windows and Widgets to use +#define GWIN_FIRST_CONTROL_FLAG 0x00000001 // @< 8 bits free for the control to use +#define GWIN_FLG_VISIBLE 0x00000100 // @< The window is "visible" +#define GWIN_FLG_SYSVISIBLE 0x00000200 // @< The window is visible after parents are tested +#define GWIN_FLG_ENABLED 0x00000400 // @< The window is "enabled" +#define GWIN_FLG_SYSENABLED 0x00000800 // @< The window is enabled after parents are tested +#define GWIN_FLG_DYNAMIC 0x00001000 // @< The GWIN structure is allocated +#define GWIN_FLG_ALLOCTXT 0x00002000 // @< The text/label is allocated +#define GWIN_FLG_MOUSECAPTURE 0x00004000 // @< The window has captured the mouse +#define GWIN_FLG_SUPERMASK 0x000F0000 // @< The bit mask to leave just the window superclass type +#define GWIN_FLG_WIDGET 0x00010000 // @< This is a widget +#define GWIN_FLG_CONTAINER 0x00020000 // @< This is a container +#define GWIN_FLG_MINIMIZED 0x00100000 // @< The window is minimized +#define GWIN_FLG_MAXIMIZED 0x00200000 // @< The window is maximized +#define GWIN_FIRST_WM_FLAG 0x01000000 // @< 8 bits free for the window manager to use /* @} */ /** @@ -104,6 +108,27 @@ typedef struct gwinVMT { /* @} */ #endif +#if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__) + + /** + * @brief The Virtual Method Table for a container + * @note A container must have a destroy function. Either use @p _gcontainerDestroy() or use your own function + * which internally calls @p _gcontainerDestroy(). + * @note A container must have a gwin redraw function. Use @p _containerRedraw(). + * @note If toggleroles != 0, ToggleAssign(), ToggleGet() and one or both of ToggleOff() and ToggleOn() must be specified. + * @note If dialroles != 0, DialAssign(), DialGet() and DialMove() must be specified. + * @{ + */ + typedef struct gcontainerVMT { + gwidgetVMT gw; + void (*Pos2Screen) (GHandle gh, coord_t *px, coord_t *py); // @< Translate client coords into absolute coords (mandatory) + void (*Size2Screen) (GHandle gh, coord_t *pwidth, coord_t *pheight); // @< Ensure a window fits in the parent client area (mandatory) + void (*NotifyAdd) (GHandle gh, GHandle ghChild); // @< Notification that a child has been added (optional) + void (*NotifyDelete) (GHandle gh, GHandle ghChild); // @< Notification that a child has been deleted (optional) + } gcontainerVMT; + /* @} */ +#endif + // These flags are needed whether or not we are running a window manager. /** * @brief Flags for redrawing after a visibility change @@ -111,16 +136,11 @@ typedef struct gwinVMT { */ #define GWIN_WMFLG_PRESERVE 0x0001 // @< Preserve whatever existing contents possible if a window can't redraw #define GWIN_WMFLG_NOBGCLEAR 0x0002 // @< Don't clear the area if the window is not visible -#define GWIN_WMFLG_NOZORDER 0x0004 // @< Don't redraw higher z-order windows that overlap +#define GWIN_WMFLG_KEEPCLIP 0x0004 // @< Don't modify the preset clipping area +#define GWIN_WMFLG_NOZORDER 0x0008 // @< Don't redraw higher z-order windows that overlap /* @} */ #if GWIN_NEED_WINDOWMANAGER || defined(__DOXYGEN__) - #if 1 // When we know that wmq is the first element of the GWindowObject structure - #define QItem2GWindow(qi) ((GHandle)qi) - #else - #define QItem2GWindow(qi) ((GHandle)(((char *)(qi)) - (size_t)(&(((GWindowObject *)0)->wmq)))) - #endif - // @note There is only ever one instance of each GWindowManager type typedef struct GWindowManager { const struct gwmVMT *vmt; @@ -136,17 +156,13 @@ typedef struct gwinVMT { bool_t (*Add) (GHandle gh, const GWindowInit *pInit); // @< A window has been added void (*Delete) (GHandle gh); // @< A window has been deleted void (*Redraw) (GHandle gh, int visflags); // @< A window needs to be redraw (or undrawn) - void (*Redim) (GHandle gh, coord_t x, coord_t y, coord_t w, coord_t h); // @< A window wants to be moved or resized + void (*Size) (GHandle gh, coord_t w, coord_t h); // @< A window wants to be resized + void (*Move) (GHandle gh, coord_t x, coord_t y); // @< A window wants to be moved void (*Raise) (GHandle gh); // @< A window wants to be on top void (*MinMax) (GHandle gh, GWindowMinMax minmax); // @< A window wants to be minimized/maximised } gwmVMT; /* @} */ - /** - * @brief The list of all windows in the system - */ - extern gfxQueueASync _GWINList; - /** * @brief The current window manager */ @@ -197,13 +213,93 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit void _gwidgetDestroy(GHandle gh); /** - * @brief Redraw the Widget object + * @brief Redraw the Widget object (VMT method only) * * @param[in] gh The widget to redraw * + * @note Do not use this routine to update a widget after a status change. + * Use @p _gwidgetUpdate() instead. The difference is that this routine + * does not set the clip region. This routine should only be used in the + * VMT. + * * @notapi */ void _gwidgetRedraw(GHandle gh); + + /** + * @brief Redraw the Widget object after a widget status change. + * + * @param[in] gh The widget to redraw + * + * @note Use this routine to update a widget after a status change. + * + * @notapi + */ + void _gwidgetUpdate(GHandle gh); +#endif + +#if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__) + /** + * @brief Initialise (and allocate if necessary) the base Container object + * + * @param[in] g The GDisplay to display this window on + * @param[in] pgw The GContainerObject structure. If NULL one is allocated from the heap + * @param[in] pInit The user initialization parameters + * @param[in] vmt The virtual method table for the Container object + * + * @return The GHandle of the created widget + * + * @notapi + */ + GHandle _gcontainerCreate(GDisplay *g, GContainerObject *pgw, const GWidgetInit *pInit, const gcontainerVMT *vmt); + + /** + * @brief Destroy the Container object + * + * @param[in] gh The container to destroy + * + * @notapi + */ + void _gcontainerDestroy(GHandle gh); + + /** + * @brief Redraw the Container object (VMT method only) + * + * @param[in] gh The container to redraw + * + * @note Do not use this routine to update a container after a status change. + * Use @p _gcontainerUpdate() instead. The difference is that this routine + * does not set the clip region. This routine should only be used in the + * VMT. + * + * @notapi + */ + #define _gcontainerRedraw(gh) _gwidgetRedraw(gh) + + /** + * @brief Redraw the Container object after a container status change. + * + * @param[in] gh The container to redraw + * + * @note Use this routine to update a container after a status change. + * + * @notapi + */ + #define _gcontainerUpdate(gh) _gwidgetUpdate(gh) + + /** + * @brief Apply the specified action to a window and its children. + * @note The action is applied to the parent first and then its children. + * @note This routine is built to keep stack usage from recursing to a minimum. + * + * @param[in] gh The window to recurse through + * @param[in] fn The function to apply. If it returns TRUE any children it has should also have the function applied + * + * @notapi + */ + void _gwinRecurse(GHandle gh, bool_t (*fn)(GHandle gh)); +#else + #define _gwinRecurse(gh, fn) fn(gh) #endif #ifdef __cplusplus -- cgit v1.2.3