13 #include "../../gfx.h" 15 #if GFX_USE_GWIN && GWIN_NEED_TABSET 17 #include "gwin_class.h" 22 #define GTABSET_BORDER 2 23 #define GTABSET_TXT_PAD 5 26 #define GTABSET_TAB_CNR 8 // Diagonal corner on active tab 27 #define GTABSET_TOP_FADE 50 // (GTABSET_TOP_FADE/255)% fade to white for top of tab/button 28 #define GTABSET_BOTTOM_FADE 25 // (GTABSET_BOTTOM_FADE/255)% fade to black for bottom of tab/button 29 #define GTABSET_OUTLINE_FADE 128 // (GTABSET_OUTLINE_FADE/255)% fade to background for active tab edge 32 #define GWIN_TABSET_USER_FLAGS (GWIN_TABSET_BORDER) 33 #if GWIN_TABSET_BORDER < GWIN_FIRST_CONTROL_FLAG 34 #error "GWIN Tabset: - Flag definitions don't match" 36 #if GWIN_TABSET_BORDER > GWIN_LAST_CONTROL_FLAG 37 #error "GWIN Tabset: - Flag definitions don't match" 44 static void FixTabSizePos(
GHandle gh);
48 static coord_t TabpageBorderSize(
GHandle gh) { (void)gh;
return 0; }
50 static void gwinTabpageDraw_Std(
GWidgetObject *gw,
void *param) {
57 static void TabpageDestroy(
GHandle gh) {
58 _gcontainerDestroy(gh);
60 FixTabSizePos(gh->parent);
67 sizeof(GTabpageObject),
80 #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD 85 #if GINPUT_NEED_TOGGLE 116 FixTabSizePos(gh->parent);
143 static void FixTabSizePos(
GHandle gh) {
147 oldth = ((GTabsetObject *)gh)->border_top;
148 ((GTabsetObject *)gh)->border_top = CalcTabHeight(gh);
149 oldth -= ((GTabsetObject *)gh)->border_top;
158 if (!vis || (ph->
flags & GWIN_FLG_VISIBLE))
166 if (vis && !(vis->
flags & GWIN_FLG_VISIBLE)) {
167 vis->
flags |= GWIN_FLG_VISIBLE;
168 _gwinRippleVisibility();
173 static coord_t TabSetBorderTop(
GHandle gh) {
return ((GTabsetObject *)gh)->border_top; }
175 #if GINPUT_NEED_MOUSE 180 if (my < 0 || my > ((GTabsetObject *)gw)->border_top)
199 if (my < y && mx < x) {
206 if (!gh || (gh->
flags & GWIN_FLG_VISIBLE))
212 if (ph->
vmt == (
gwinVMT *)&tabpageVMT && (ph->
flags & GWIN_FLG_VISIBLE)) {
214 ph->
flags &= ~GWIN_FLG_VISIBLE;
220 gh->
flags |= GWIN_FLG_VISIBLE;
221 _gwinRippleVisibility();
228 GSourceListener * psl;
252 sizeof(GTabsetObject),
265 #if GINPUT_NEED_TOGGLE 292 if (!(fo = (GTabsetObject *)_gcontainerCreate(g, (
GContainerObject *)fo, pInit, &tabsetVMT)))
296 fo->c.g.
flags |= flags & GWIN_TABSET_USER_FLAGS;
323 if (!(gh = _gcontainerCreate(gh->
display, 0, &wi, &tabpageVMT)))
328 FixTabSizePos(gh->parent);
353 if (gh->
vmt == (
gwinVMT *)&tabpageVMT && !index--)
373 if (gh->
vmt != (
gwinVMT *)&tabpageVMT || (gh->
flags & GWIN_FLG_VISIBLE))
378 if (ph->
vmt == (
gwinVMT *)&tabpageVMT && (ph->
flags & GWIN_FLG_VISIBLE)) {
380 ph->
flags &= ~GWIN_FLG_VISIBLE;
386 gh->
flags |= GWIN_FLG_VISIBLE;
387 _gwinRippleVisibility();
397 #if GWIN_FLAT_STYLING 401 pcol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? &gw->pstyle->pressed : &gw->pstyle->disabled;
409 pcol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled;
418 pcol = (gw->g.flags & GWIN_FLG_SYSENABLED) ? &gw->pstyle->pressed : &gw->pstyle->disabled;
474 ntarea(gw, y, x, gw->
g.
width - x);
478 if (ph->
flags & GWIN_FLG_VISIBLE)
486 ntarea(gw, y, x, gw->
g.
width - x);
510 drawborder(gw, drawtabs(gw));
535 #define gi ((gdispImage *)param) 552 for(y = gw->
g.
y+y, ih = gi->height; y < my; y += ih) {
558 for(iw = gi->width; x < mx; x += iw) {
void gdispGFillStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char *str, font_t font, color_t color, color_t bgColor, justify_t justify)
Draw a text string vertically centered within the specified box. The box background is filled with th...
coord_t gwinGetInnerHeight(GHandle gh)
Get the inner height of a container window.
color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha)
Blend 2 colors according to the alpha.
void gwinTabsetDraw_Image(GWidgetObject *gw, void *param)
Renders the tabset and uses the specified image for the client area.
const struct gwinVMT * vmt
void gwinRedraw(GHandle gh)
Redraw a window.
GEvent * geventGetEventBuffer(GSourceListener *psl)
Get the event buffer from the GSourceListener.
int16_t coord_t
The type for a coordinate or length on the screen.
The Virtual Method Table for a container.
int32_t fixed
The type for a fixed point type.
GHandle gwinTabsetAddTab(GHandle gh, const char *title, bool_t useAlloc)
Add a tab-page to the tabset.
void gwinResize(GHandle gh, coord_t width, coord_t height)
Resize a window.
#define GWIN_CONTAINER_BORDER
Flags for gwinContainerCreate()
#define GINPUT_NEED_MOUSE
Should mouse/touch functions be included.
coord_t gdispGetStringWidth(const char *str, font_t font)
Get the pixel width of an entire string.
#define GWIN_TABSET_TABHEIGHT
The height in pixels of a row of tabs in a tabset.
void gdispGDrawLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color)
Draw a line.
void gdispGFillArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color)
Fill an area with a color.
void gwinSetVisible(GHandle gh, bool_t visible)
Sets whether a window is visible or not.
#define GWIN_TABSET_BORDER
Flags for gwinTabsetCreate()
void gdispGDrawStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char *str, font_t font, color_t color, justify_t justify)
Draw a text string vertically centered within the specified box.
void gwinTabsetDraw_Transparent(GWidgetObject *gw, void *param)
Renders the tabset but leaves the client area transparent.
GHandle gwinGetFirstChild(GHandle gh)
Get the first child window.
GHandle gwinTabsetGetTabByTitle(GHandle gh, const char *title)
Get the GHandle of a tab based on its title.
void geventSendEvent(GSourceListener *psl)
Called by a source to indicate the listener's event buffer has been filled.
GHandle gwinGetSibling(GHandle gh)
Get the next child window in the z-order.
GHandle gwinGTabsetCreate(GDisplay *g, GTabsetObject *fo, GWidgetInit *pInit, uint32_t flags)
Create a tabset widget.
int gwinTabsetCountTabs(GHandle gh)
Count the number of tabs in the tabset.
#define FIXED(x)
Macros to convert to and from a fixed point.
#define GEVENT_GWIN_TABSET
The Event Type for a Tabset Event.
GHandle gwinTabsetGetTabByIndex(GHandle gh, int index)
Get the GHandle of a tab based on its position.
gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy)
Draw the image.
void gwinTabsetSetTab(GHandle gh)
Set the active tab in a tabset.
coord_t gwinGetInnerWidth(GHandle gh)
Get the inner width of a container window.
void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color)
Draw a rectangular box.
The Virtual Method Table for a GWIN window.
A window object structure.
void gwinTabsetDraw_Std(GWidgetObject *gw, void *param)
The default rendering function for the tabset widget.
COLOR_TYPE color_t
The color type definition.
void gwinTabsetSetTitle(GHandle gh, const char *title, bool_t useAlloc)
Set the title of a tab-page.
void gwinMove(GHandle gh, coord_t x, coord_t y)
Move a window.
GSourceListener * geventGetSourceListener(GSourceHandle gsh, GSourceListener *lastlr)
Called by a source with a possible event to get a listener record.