Adding TextEdit dummy widget (not implemented yet)
This commit is contained in:
parent
213013e68e
commit
46ba0420c3
8 changed files with 191 additions and 2 deletions
|
@ -186,6 +186,7 @@
|
|||
// #define GWIN_NEED_KEYBOARD FALSE
|
||||
// #define GWIN_KEYBOARD_DEFAULT_LAYOUT VirtualKeyboard_English1
|
||||
// #define GWIN_NEED_KEYBOARD_ENGLISH1 TRUE
|
||||
// #define GWIN_NEED_TEXTEDIT FALSE
|
||||
// #define GWIN_FLAT_STYLING FALSE
|
||||
// #define GWIN_WIDGET_TAGS FALSE
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ GFXSRC += $(GFXLIB)/src/gwin/gwin.c \
|
|||
$(GFXLIB)/src/gwin/gwin_tabset.c \
|
||||
$(GFXLIB)/src/gwin/gwin_gl3d.c \
|
||||
$(GFXLIB)/src/gwin/gwin_keyboard.c \
|
||||
$(GFXLIB)/src/gwin/gwin_keyboard_layout.c
|
||||
$(GFXLIB)/src/gwin/gwin_keyboard_layout.c \
|
||||
$(GFXLIB)/src/gwin/gwin_textedit.c
|
||||
|
||||
GFXINC += $(GFXLIB)/3rdparty/tinygl-0.4-ugfx/include
|
||||
|
|
|
@ -24,3 +24,4 @@
|
|||
#include "gwin_gl3d.c"
|
||||
#include "gwin_keyboard.c"
|
||||
#include "gwin_keyboard_layout.c"
|
||||
#include "gwin_textedit.c"
|
||||
|
|
|
@ -142,6 +142,13 @@
|
|||
#ifndef GWIN_NEED_KEYBOARD
|
||||
#define GWIN_NEED_KEYBOARD FALSE
|
||||
#endif
|
||||
/**
|
||||
* @brief Should the textedit widget be included.
|
||||
* @details Defaults to FALSE
|
||||
*/
|
||||
#ifndef GWIN_NEED_TEXTEDIT
|
||||
#define GWIN_NEED_TEXTEDIT FALSE
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#endif
|
||||
#endif
|
||||
#if GWIN_NEED_BUTTON || GWIN_NEED_SLIDER || GWIN_NEED_CHECKBOX || GWIN_NEED_LABEL || GWIN_NEED_RADIO || GWIN_NEED_LIST || \
|
||||
GWIN_NEED_IMAGE || GWIN_NEED_CHECKBOX || GWIN_NEED_PROGRESSBAR || GWIN_NEED_KEYBOARD
|
||||
GWIN_NEED_IMAGE || GWIN_NEED_CHECKBOX || GWIN_NEED_PROGRESSBAR || GWIN_NEED_KEYBOARD || GWIN_NEED_TEXTEDIT
|
||||
#if !GWIN_NEED_WIDGET
|
||||
#if GFX_DISPLAY_RULE_WARNINGS
|
||||
#warning "GWIN: GWIN_NEED_WIDGET is required when a widget is used. It has been turned on for you."
|
||||
|
|
113
src/gwin/gwin_textedit.c
Normal file
113
src/gwin/gwin_textedit.c
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* 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 src/gwin/gwin_textedit.c
|
||||
* @brief GWIN TextEdit widget header file
|
||||
*/
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
#if GFX_USE_GWIN && GWIN_NEED_TEXTEDIT
|
||||
|
||||
#include "gwin_class.h"
|
||||
|
||||
// Text padding (between edge and text) in pixels
|
||||
const int TEXT_PADDING = 3;
|
||||
|
||||
// macros to assist in data type conversions
|
||||
#define gh2obj ((GTexteditObject *)gh)
|
||||
#define gw2obj ((GTexteditObject *)gw)
|
||||
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke)
|
||||
{
|
||||
if (pke->bytecount = 1) {
|
||||
//gw->text = pke->c[0];
|
||||
gwinSetText((GHandle)gw, &(pke->c[0]), TRUE);
|
||||
}
|
||||
|
||||
_gwinUpdate(&gw);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param);
|
||||
|
||||
static const gwidgetVMT texteditVMT = {
|
||||
{
|
||||
"TextEdit", // The class name
|
||||
sizeof(GTexteditObject), // The object size
|
||||
_gwidgetDestroy, // The destroy routine
|
||||
_gwidgetRedraw, // The redraw routine
|
||||
0, // The after-clear routine
|
||||
},
|
||||
gwinTexteditDefaultDraw, // default drawing routine
|
||||
#if GINPUT_NEED_MOUSE
|
||||
{
|
||||
0, // Process mose down events (NOT USED)
|
||||
0, // Process mouse up events (NOT USED)
|
||||
0, // Process mouse move events (NOT USED)
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_KEYBOARD
|
||||
{
|
||||
_keyboardEvent, // Process keyboard key down events
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_TOGGLE
|
||||
{
|
||||
0, // No toggle role
|
||||
0, // Assign Toggles (NOT USED)
|
||||
0, // Get Toggles (NOT USED)
|
||||
0, // Process toggle off event (NOT USED)
|
||||
0, // Process toggle on event (NOT USED)
|
||||
},
|
||||
#endif
|
||||
#if GINPUT_NEED_DIAL
|
||||
{
|
||||
0, // No dial roles
|
||||
0, // Assign Dials (NOT USED)
|
||||
0, // Get Dials (NOT USED)
|
||||
0, // Procees dial move events (NOT USED)
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* widget, GWidgetInit* pInit)
|
||||
{
|
||||
uint16_t flags = 0;
|
||||
|
||||
if (!(widget = (GTexteditObject*)_gwidgetCreate(g, &widget->w, pInit, &texteditVMT))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
widget->w.g.flags |= flags;
|
||||
gwinSetVisible(&widget->w.g, pInit->g.show);
|
||||
|
||||
return (GHandle)widget;
|
||||
}
|
||||
|
||||
static void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param)
|
||||
{
|
||||
color_t textColor;
|
||||
(void) param;
|
||||
|
||||
// Is it a valid handle?
|
||||
if (gw->g.vmt != (gwinVMT*)&texteditVMT) {
|
||||
return;
|
||||
}
|
||||
|
||||
textColor = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text;
|
||||
|
||||
|
||||
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, textColor, gw->pstyle->background, justifyLeft);
|
||||
}
|
||||
|
||||
#undef gh2obj
|
||||
#undef gw2obj
|
||||
|
||||
#endif // GFX_USE_GWIN && GWIN_NEED_TEXTEDIT
|
62
src/gwin/gwin_textedit.h
Normal file
62
src/gwin/gwin_textedit.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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 src/gwin/gwin_textedit.h
|
||||
* @brief GWIN textedit widget header file
|
||||
*
|
||||
* @defgroup TextEdit TextEdit
|
||||
* @ingroup Widgets
|
||||
*
|
||||
* @details A GWIN TextEdit widget allows user input.
|
||||
*
|
||||
* @pre GFX_USE_GDISP must be set to TRUE in your gfxconf.h
|
||||
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
||||
* @pre GDISP_NEED_TEXT must be set to TRUE in your gfxconf.h
|
||||
* @pre GWIN_NEED_TEXTEDIT must be set to TRUE in your gfxconf.h
|
||||
* @pre The fonts you want to use must be enabled in your gfxconf.h
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _GWIN_TEXTEDIT_H
|
||||
#define _GWIN_TEXTEDIT_H
|
||||
|
||||
// This file is included within "src/gwin/gwin_widget.h"
|
||||
|
||||
// A TextEdit widget
|
||||
typedef struct GTexteditObject {
|
||||
GWidgetObject w;
|
||||
} GTexteditObject;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Create a TextEdit widget.
|
||||
* @details A TextEdit widget is a rectangular box which allows the user to input data through a keyboard.
|
||||
* The keyboard can either be a physical one or a virtual on-screen keyboard as the keyboard driver
|
||||
* is abstracted through the GINPUT module.
|
||||
*
|
||||
* @param[in] g The GDisplay on which the textedit should be displayed
|
||||
* @param[in] widget The TextEdit structure to initialise. If this is NULL, the structure is dynamically allocated.
|
||||
* @param[in] pInit The initialisation parameters to use.
|
||||
*
|
||||
* @return NULL if there is no resultat drawing area, otherwise the widget handle.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* widget, GWidgetInit* pInit);
|
||||
#define gwinTexteditCreate(w, pInit) gwinGTexteditCreate(GDISP, w, pInit)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _GWIN_TEXTEDIT_H
|
||||
/** @} */
|
|
@ -381,5 +381,9 @@ bool_t gwinAttachListener(GListener *pl);
|
|||
#include "gwin_keyboard.h"
|
||||
#endif
|
||||
|
||||
#if GWIN_NEED_TEXTEDIT || defined(__DOXYGEN__)
|
||||
#include "gwin_textedit.h"
|
||||
#endif
|
||||
|
||||
#endif /* _GWIDGET_H */
|
||||
/** @} */
|
||||
|
|
Loading…
Add table
Reference in a new issue