aboutsummaryrefslogtreecommitdiffstats
path: root/include/gwin.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/gwin.h')
-rw-r--r--include/gwin.h201
1 files changed, 139 insertions, 62 deletions
diff --git a/include/gwin.h b/include/gwin.h
index 7dfa4c68..79b8371c 100644
--- a/include/gwin.h
+++ b/include/gwin.h
@@ -45,52 +45,119 @@
* @name GWIN more complex functionality to be compiled
* @{
*/
+ /**
+ * @brief Should console functions be included.
+ * @details Defaults to TRUE
+ */
+ #ifndef GWIN_NEED_CONSOLE
+ #define GWIN_NEED_CONSOLE TRUE
+ #endif
+ /**
+ * @brief Should button functions be included.
+ * @details Defaults to FALSE for now as implementation is not complete
+ */
+ #ifndef GWIN_NEED_BUTTON
+ #define GWIN_NEED_BUTTON FALSE
+ #endif
+
/** @} */
/*===========================================================================*/
/* Low Level Driver details and error checks. */
/*===========================================================================*/
-#if !GFX_USE_GDISP
+#if !defined(GFX_USE_GDISP)
#error "GWIN: GFX_USE_GDISP must also be defined"
#endif
-
#include "gdisp.h"
#if !GDISP_NEED_CLIP
#warning "GWIN: Drawing can occur outside the defined window as GDISP_NEED_CLIP is FALSE"
#endif
+#if GWIN_NEED_CONSOLE && !GDISP_NEED_TEXT
+ #error "GWIN: Text support (GDISP_NEED_TEXT) is required if GWIN_NEED_CONSOLE is defined."
+#endif
+
+#if GWIN_NEED_BUTTON && !GDISP_NEED_TEXT
+ #error "GWIN: Text support (GDISP_NEED_TEXT) is required if GWIN_NEED_BUTTON is defined."
+#endif
+
+#if GWIN_NEED_BUTTON
+ #warning "GWIN: Button support is not complete yet"
+#endif
+
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
-/**
- * @extends BaseAsynchronousChannelVMT
- *
- * @brief @p GWindow virtual methods table.
- */
-struct GWindowVMT {
- _base_asynchronous_channel_methods
-};
-
-struct GWindowText {
- const struct GWindowVMT *vmt;
- _base_asynchronous_channel_data
- font_t font; // Current font
- uint8_t fy; // Current font height
- uint8_t fp; // Current font inter-character spacing
- coord_t cx,cy; // Cursor position
-};
-
-typedef struct GWindow_t {
+typedef enum GWindowType_e {
+ GW_WINDOW, GW_CONSOLE, GW_BUTTON
+ } GWindowType;
+
+// A basic window
+typedef struct GWindowObject_t {
+ GWindowType type; // What type of window is this
+ uint16_t flags; // Internal flags
+ coord_t x, y; // Screen relative position
+ coord_t width, height; // Dimensions of this window
+ color_t color, bgcolor; // Current drawing colors
#if GDISP_NEED_TEXT
- struct GWindowText txt;
+ font_t font; // Current font
+#endif
+} GWindowObject, * GHandle;
+
+#if GWIN_NEED_CONSOLE
+ // A console window. Supports wrapped text writing and a cursor.
+ typedef struct GConsoleObject_t {
+ GWindowObject gwin;
+
+ struct GConsoleWindowStream_t {
+ const struct GConsoleWindowVMT_t *vmt;
+ _base_asynchronous_channel_data
+ } stream;
+
+ coord_t cx,cy; // Cursor position
+ uint8_t fy; // Current font height
+ uint8_t fp; // Current font inter-character spacing
+ } GConsoleObject;
+#endif
+
+#if GWIN_NEED_BUTTON
+ typedef enum GButtonShape_e {
+ GBTN_3D, GBTN_SQUARE, GBTN_ROUNDED, GBTN_ELLIPSE
+ } GButtonShape;
+
+ typedef struct GButtonStyle_t {
+ GButtonShape shape;
+ color_t color_up_edge;
+ color_t color_up_fill;
+ color_t color_up_txt;
+ color_t color_dn_edge;
+ color_t color_dn_fill;
+ color_t color_dn_txt;
+ } GButtonStyle;
+
+ typedef enum GButtonType_e {
+ GBTN_NORMAL, GBTN_TOGGLE
+ } GButtonType;
+
+ typedef enum GButtonState_e {
+ GBTN_UP, GBTN_DOWN
+ } GButtonState;
+
+ // A button window
+ typedef struct GButtonObject_t {
+ GWindowObject gwin;
+
+ GButtonStyle style;
+ GButtonState state;
+ GButtonType type;
+ const char * txt;
+ void * callback; // To be fixed
+ void * inputsrc; // To be fixed
+ } GButtonObject;
#endif
- coord_t x, y; // Screen relative position
- coord_t width, height; // Dimensions of this window
- color_t color, bgcolor; // Current drawing colors
-} GWindow;
/*===========================================================================*/
/* External declarations. */
@@ -101,70 +168,81 @@ extern "C" {
#endif
/* Base Functions */
-bool_t gwinInit(GWindow *gw, coord_t x, coord_t y, coord_t width, coord_t height);
+GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height);
+void gwinDestroyWindow(GHandle gh);
/* Status Functions */
-#define gwinGetScreenX(gw) ((gw)->x)
-#define gwinGetScreenY(gw) ((gw)->y)
-#define gwinGetWidth(gw) ((gw)->width)
-#define gwinGetHeight(gw) ((gw)->height)
+#define gwinGetScreenX(gh) ((gh)->x)
+#define gwinGetScreenY(gh) ((gh)->y)
+#define gwinGetWidth(gh) ((gh)->width)
+#define gwinGetHeight(gh) ((gh)->height)
/* Set up for drawing */
-#define gwinSetColor(gw, clr) (gw)->color = (clr)
-#define gwinSetBgColor(gw, bgclr) (gw)->bgcolor = (bgclr)
+#define gwinSetColor(gh, clr) (gh)->color = (clr)
+#define gwinSetBgColor(gh, bgclr) (gh)->bgcolor = (bgclr)
/* Set up for text */
#if GDISP_NEED_TEXT
-void gwinSetFont(GWindow *gw, font_t font);
-#define gwinGetStream(gw) ((BaseSequentialStream *)gw)
+void gwinSetFont(GHandle gh, font_t font);
#endif
/* Drawing Functions */
-void gwinClear(GWindow *gw);
-void gwinDrawPixel(GWindow *gw, coord_t x, coord_t y);
-void gwinDrawLine(GWindow *gw, coord_t x0, coord_t y0, coord_t x1, coord_t y1);
-void gwinDrawBox(GWindow *gw, coord_t x, coord_t y, coord_t cx, coord_t cy);
-void gwinFillArea(GWindow *gw, coord_t x, coord_t y, coord_t cx, coord_t cy);
-void gwinBlitArea(GWindow *gw, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
+void gwinClear(GHandle gh);
+void gwinDrawPixel(GHandle gh, coord_t x, coord_t y);
+void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1);
+void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
+void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
+void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
/* Circle Functions */
#if GDISP_NEED_CIRCLE
-void gwinDrawCircle(GWindow *gw, coord_t x, coord_t y, coord_t radius);
-void gwinFillCircle(GWindow *gw, coord_t x, coord_t y, coord_t radius);
+void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
+void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
#endif
/* Ellipse Functions */
#if GDISP_NEED_ELLIPSE
-void gwinDrawEllipse(GWindow *gw, coord_t x, coord_t y, coord_t a, coord_t b);
-void gwinFillEllipse(GWindow *gw, coord_t x, coord_t y, coord_t a, coord_t b);
+void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
+void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
#endif
/* Arc Functions */
#if GDISP_NEED_ARC
-void gwinDrawArc(GWindow *gw, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
-void gwinFillArc(GWindow *gw, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
+void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
+void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
#endif
/* Read a pixel Function */
#if GDISP_NEED_PIXELREAD
-color_t gwinGetPixelColor(GWindow *gw, coord_t x, coord_t y);
-#endif
-
-/* Scrolling Function - clears the area scrolled out */
-#if GDISP_NEED_SCROLL
-void gwinVerticalScroll(GWindow *gw, int lines);
+color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y);
#endif
/* Extra Text Functions */
#if GDISP_NEED_TEXT
-void gwinDrawChar(GWindow *gw, coord_t x, coord_t y, char c);
-void gwinFillChar(GWindow *gw, coord_t x, coord_t y, char c);
-void gwinDrawString(GWindow *gw, coord_t x, coord_t y, const char *str);
-void gwinFillString(GWindow *gw, coord_t x, coord_t y, const char *str);
-void gwinBoxString(GWindow *gw, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
-void gwinPutChar(GWindow *gw, char c);
-void gwinPutString(GWindow *gw, const char *str);
-void gwinPutCharArray(GWindow *gw, const char *str, size_t n);
+void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c);
+void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c);
+void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str);
+void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str);
+void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
+void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
+#endif
+
+#if GWIN_NEED_CONSOLE
+GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
+BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
+void gwinPutChar(GHandle gh, char c);
+void gwinPutString(GHandle gh, const char *str);
+void gwinPutCharArray(GHandle gh, const char *str, size_t n);
+#endif
+
+#if GWIN_NEED_BUTTON
+GHandle gwinCreateButton(GButtonObject *gb, coord_t x, coord_t y, coord_t width, coord_t height, font_t font, GButtonType type);
+void gwinSetButtonStyle(GHandle gh, const GButtonStyle *style);
+void gwinSetButtonText(GHandle gh, const char *txt, bool_t useAlloc);
+void gwinButtonDraw(GHandle gh);
+#define gwinGetButtonState(gh) (((GButtonObject *)(gh))->state)
+//void gwinSetButtonCallback(GHandle gh, ????);
+//void gwinSetButtonInput(GHandle gh, ????);
#endif
#ifdef __cplusplus
@@ -175,4 +253,3 @@ void gwinPutCharArray(GWindow *gw, const char *str, size_t n);
#endif /* _GWIN_H */
/** @} */
-