diff options
-rw-r--r-- | docs/releases.txt | 1 | ||||
-rw-r--r-- | src/gwin/gwin_frame.c | 16 | ||||
-rw-r--r-- | src/gwin/gwin_frame.h | 7 |
3 files changed, 14 insertions, 10 deletions
diff --git a/docs/releases.txt b/docs/releases.txt index 5f0b693b..e3a2326e 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -10,6 +10,7 @@ FEATURE: Added Altera-MAX10-NEEK board support FIX: Vastly improving keyboard widget default rendering FEATURE: Added ILI9342 driver FIX: Fixing issues where wrong 'progress' color from widget style palette was used +FEATURE: Added GWIN_FRAME_KEEPONCLOSE flag to prevent destruction of a frame on close *** Release 2.4 *** diff --git a/src/gwin/gwin_frame.c b/src/gwin/gwin_frame.c index 28d7c01d..a9abbb9b 100644 --- a/src/gwin/gwin_frame.c +++ b/src/gwin/gwin_frame.c @@ -28,11 +28,11 @@ #define FRM_BORDER_B 2 // Bottom Border /* Internal state flags */ -#define GWIN_FRAME_USER_FLAGS (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN) -#define GWIN_FRAME_CLOSE_PRESSED (GWIN_FRAME_MINMAX_BTN << 1) -#define GWIN_FRAME_MIN_PRESSED (GWIN_FRAME_MINMAX_BTN << 2) -#define GWIN_FRAME_MAX_PRESSED (GWIN_FRAME_MINMAX_BTN << 3) -#define GWIN_FRAME_REDRAW_FRAME (GWIN_FRAME_MINMAX_BTN << 4) // Only redraw the frame +#define GWIN_FRAME_USER_FLAGS (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN|GWIN_FRAME_KEEPONCLOSE) +#define GWIN_FRAME_CLOSE_PRESSED (GWIN_FRAME_KEEPONCLOSE << 1) +#define GWIN_FRAME_MIN_PRESSED (GWIN_FRAME_KEEPONCLOSE << 2) +#define GWIN_FRAME_MAX_PRESSED (GWIN_FRAME_KEEPONCLOSE << 3) +#define GWIN_FRAME_REDRAW_FRAME (GWIN_FRAME_KEEPONCLOSE << 4) // Only redraw the frame #if GWIN_FRAME_CLOSE_BTN < GWIN_FIRST_CONTROL_FLAG #error "GWIN Frame: - Flag definitions don't match" #endif @@ -96,7 +96,8 @@ static void forceFrameRedraw(GWidgetObject *gw) { gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED); forceFrameRedraw(gw); _gwinSendEvent(&gw->g, GEVENT_GWIN_CLOSE); - _gwinDestroy(&gw->g, REDRAW_INSESSION); + if (!(gw->g.flags & GWIN_FRAME_KEEPONCLOSE)) + _gwinDestroy(&gw->g, REDRAW_INSESSION); return; } if ((gw->g.flags & GWIN_FRAME_MAX_PRESSED)) { @@ -129,7 +130,8 @@ static void forceFrameRedraw(GWidgetObject *gw) { gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED); forceFrameRedraw(gw); _gwinSendEvent(&gw->g, GEVENT_GWIN_CLOSE); - _gwinDestroy(&gw->g, REDRAW_INSESSION); + if (!(gw->g.flags & GWIN_FRAME_KEEPONCLOSE)) + _gwinDestroy(&gw->g, REDRAW_INSESSION); return; } pos -= FRM_BUTTON_X; diff --git a/src/gwin/gwin_frame.h b/src/gwin/gwin_frame.h index 18af2e50..45c97b53 100644 --- a/src/gwin/gwin_frame.h +++ b/src/gwin/gwin_frame.h @@ -31,9 +31,10 @@ * @brief Flags for gwinFrameCreate() * @{ */ -#define GWIN_FRAME_BORDER 0x00000000 // Deprecated. A border is always shown with a frame window now. -#define GWIN_FRAME_CLOSE_BTN 0x00000001 -#define GWIN_FRAME_MINMAX_BTN 0x00000002 +#define GWIN_FRAME_BORDER 0x00000000 /**< Deprecated. A border is always shown with a frame window now. */ +#define GWIN_FRAME_CLOSE_BTN 0x00000001 /**< Should a close button be shown? */ +#define GWIN_FRAME_MINMAX_BTN 0x00000002 /**< Should minimize and maximize buttons be shown? */ +#define GWIN_FRAME_KEEPONCLOSE 0x00000004 /**< Don't automatically destroy the frame on close */ /** @} */ typedef GContainerObject GFrameObject; |