aboutsummaryrefslogtreecommitdiffstats
path: root/include/gwin
diff options
context:
space:
mode:
Diffstat (limited to 'include/gwin')
-rw-r--r--include/gwin/frame.h68
-rw-r--r--include/gwin/gwidget.h6
-rw-r--r--include/gwin/gwin.h69
-rw-r--r--include/gwin/options.h14
4 files changed, 155 insertions, 2 deletions
diff --git a/include/gwin/frame.h b/include/gwin/frame.h
new file mode 100644
index 00000000..2f1b93db
--- /dev/null
+++ b/include/gwin/frame.h
@@ -0,0 +1,68 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+/**
+ * @file include/gwin/frame.h
+ * @brief GWIN Graphic window subsystem header file.
+ *
+ * @defgroup Frame Frame
+ * @ingroup GWIN
+ *
+ * @details A frame is a rectangular window that can have optional border as well as buttons to
+ * close, maximize and minimize it. The main purpose of this widget is to contain children.
+ *
+ * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
+ * @pre GWIN_NEED_FRAME must be set to TRUE in your gfxconf.h
+ * @{
+ */
+
+#ifndef _GWIN_FRAME_H
+#define _GWIN_FRAME_H
+
+#include "gwin/class_gwin.h"
+
+// Flags for gwinFrameCreate()
+#define GWIN_FRAME_BORDER (GWIN_FIRST_CONTROL_FLAG << 0)
+#define GWIN_FRAME_CLOSE_BTN (GWIN_FIRST_CONTROL_FLAG << 1)
+#define GWIN_FRAME_MINMAX_BTN (GWIN_FIRST_CONTROL_FLAG << 2)
+
+typedef struct GFrameObject {
+ GWidgetObject w;
+
+ GListener gl; // internal listener for the buttons
+ // These could probably be removed... I have to think harder later
+ GHandle btnClose;
+ GHandle btnMin;
+ GHandle btnMax;
+} GFrameObject;
+
+/**
+ * @brief Create a frame widget
+ *
+ * @details This widget provides a window like we know it from desktop systems. You usually use this together with
+ * gwinAddChild().
+ *
+ * @param[in] g The GDisplay to display this window on
+ * @param[in] fo The GFrameObject structure to initialize. If this is NULL the structure is dynamically allocated.
+ * @param[in] pInit The initialization parameters
+ * @param[in] flags Some flags, see notes.
+ *
+ * @note Possible flags are: GWIN_FRAME_BORDER, GWIN_FRAME_CLOSE_BTN, GWIN_FRAME_MINMAX_BTN.
+ * Whether the close or the minimize maximize buttons are used, the boarder is automatically invoked.
+ * @note These frame buttons are processed internally. The close button will invoke a gwinDestroy() which will
+ * destroy the window itself and EVERY child it contains (also children of children).
+ *
+ * @return NULL if there is no resulting widget. A valid GHandle otherwise.
+ *
+ * @api
+ */
+GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint16_t flags);
+#define gwinFrameCreate(fo, pInit, flags) gwinGFrameCreate(GDISP, fo, pInit, flags);
+
+#endif /* _GWIN_FRAME_H */
+/** @} */
+
diff --git a/include/gwin/gwidget.h b/include/gwin/gwidget.h
index a18d69b6..8697ca92 100644
--- a/include/gwin/gwidget.h
+++ b/include/gwin/gwidget.h
@@ -27,7 +27,7 @@
* @{
*/
-// Forward definition
+/* Forward definition */
struct GWidgetObject;
/**
@@ -304,5 +304,9 @@ bool_t gwinAttachListener(GListener *pl);
#include "gwin/progressbar.h"
#endif
+#if GWIN_NEED_FRAME || defined(__DOXYGEN__)
+ #include "gwin/frame.h"
+#endif
+
#endif /* _GWIDGET_H */
/** @} */
diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h
index f97919e5..8385fe92 100644
--- a/include/gwin/gwin.h
+++ b/include/gwin/gwin.h
@@ -27,6 +27,9 @@
#if GFX_USE_GWIN || defined(__DOXYGEN__)
+/* Forward declaration */
+typedef struct GWindowObject *GHandle;
+
/**
* @brief A window object structure
* @note Do not access the members directly. Treat it as a black-box and use the method functions.
@@ -39,13 +42,18 @@ typedef struct GWindowObject {
#endif
const struct gwinVMT *vmt; // @< The VMT for this GWIN
GDisplay * display; // @< The display this window is on.
- coord_t x, y; // @< Screen relative position
+ coord_t x, y; // @< Position relative to parent
coord_t width, height; // @< Dimensions of this window
color_t color, bgcolor; // @< The current drawing colors
uint32_t flags; // @< Window flags (the meaning is private to the GWIN class)
#if GDISP_NEED_TEXT
font_t font; // @< The current font
#endif
+ #if GWIN_NEED_HIERARCHY
+ GHandle parent; // @< The parent widget
+ GHandle sibling; // @< The widget to its left (add right later as well)
+ GHandle child; // @< The child widget
+ #endif
} GWindowObject, * GHandle;
/* @} */
@@ -395,6 +403,65 @@ extern "C" {
*/
void gwinRedraw(GHandle gh);
+ #if GWIN_NEED_HIERARCHY
+ /**
+ * @brief Add a child widget to a parent one
+ *
+ * @param[in] parent The parent window (does not need to be parent yet)
+ * @param[in] child The child window
+ * @param[in] last Should the child window be added to the front or the back of the list?
+ *
+ * @api
+ */
+ void gwinAddChild(GHandle parent, GHandle child, bool_t last);
+
+ /**
+ * @brief Remove a child from a parent
+ *
+ * @note Other children of the same parent stay
+ * @note Children of the child are lost, they have to be reassigned manually if necessary.
+ *
+ * @param[in] child The child window
+ *
+ * @api
+ */
+ void gwinRemoveChild(GHandle child);
+
+ /**
+ * @brief Redraw only the children of a parent but not the parent itself
+ *
+ * @details This routine does exactly the same as @p gwinRedraw() but does not
+ * issue a redraw of the passed widget but only of it's children.
+ *
+ * @param[in] gh The widget
+ *
+ * @api
+ */
+ void gwinRedrawChildren(GHandle gh);
+
+ /**
+ * @brief Get first child of a widget
+ *
+ * @return The first child or NULL if the widget has no children
+ *
+ * @param[in] gh The parent widget
+ *
+ * @api
+ */
+ GHandle gwinGetFirstChild(GHandle gh);
+
+ /**
+ * @brief Get the next child of a widget
+ *
+ * @return The next child or NULL if no more childs
+ *
+ * @param[in] gh The parent widget
+ *
+ * @api
+ */
+ GHandle gwinGetNextChild(GHandle gh);
+ #endif
+
#if GWIN_NEED_WINDOWMANAGER || defined (__DOXYGEN__)
/**
* @brief Redraw a window
diff --git a/include/gwin/options.h b/include/gwin/options.h
index 882db572..c29814be 100644
--- a/include/gwin/options.h
+++ b/include/gwin/options.h
@@ -30,6 +30,13 @@
#define GWIN_NEED_WIDGET FALSE
#endif
/**
+ * @brief Should the widget hierarchy be included. This provides parent-child features.
+ * @details Defaults to FALSE
+ */
+ #ifndef GWIN_NEED_HIERARCHY
+ #define GWIN_NEED_HIERARCHY FALSE
+ #endif
+ /**
* @brief Should widget functions be included. Needed for any widget (eg Buttons, Sliders etc)
* @details Defaults to FALSE
*/
@@ -37,6 +44,13 @@
#define GWIN_NEED_WIDGET FALSE
#endif
/**
+ * @brief Should the frame widget be included.
+ * @details Defaults to FALSE
+ */
+ #ifndef GWIN_NEED_FRAME
+ #define GWIN_NEED_FRAME FALSE
+ #endif
+ /**
* @brief Should console functions be included.
* @details Defaults to FALSE
*/