aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/gwin_frame.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gwin/gwin_frame.c')
-rw-r--r--src/gwin/gwin_frame.c118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/gwin/gwin_frame.c b/src/gwin/gwin_frame.c
index 2586fa98..b29c4ffc 100644
--- a/src/gwin/gwin_frame.c
+++ b/src/gwin/gwin_frame.c
@@ -17,15 +17,15 @@
#include "gwin_class.h"
/* Some position values */
-#define BUTTON_X 18 // Button Width
-#define BUTTON_Y 18 // Button Height
-#define BUTTON_I 3 // Button inner margin
-#define BUTTON_T 2 // Gap from top of window to button
-#define BUTTON_B 2 // Gap from button to the bottom of the frame title area
-#define BORDER_L 2 // Left Border
-#define BORDER_R 2 // Right Border
-#define BORDER_T (BUTTON_Y+BUTTON_T+BUTTON_B) // Top Border (Title area)
-#define BORDER_B 2 // Bottom Border
+#define FRM_BUTTON_X 18 // Button Width
+#define FRM_BUTTON_Y 18 // Button Height
+#define FRM_BUTTON_I 3 // Button inner margin
+#define FRM_BUTTON_T 2 // Gap from top of window to button
+#define FRM_BUTTON_B 2 // Gap from button to the bottom of the frame title area
+#define FRM_BORDER_L 2 // Left Border
+#define FRM_BORDER_R 2 // Right Border
+#define FRM_BORDER_T (FRM_BUTTON_Y+FRM_BUTTON_T+FRM_BUTTON_B) // Top Border (Title area)
+#define FRM_BORDER_B 2 // Bottom Border
/* Internal state flags */
#define GWIN_FRAME_USER_FLAGS (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN)
@@ -40,10 +40,10 @@
#error "GWIN Frame: - Flag definitions don't match"
#endif
-static coord_t BorderSizeL(GHandle gh) { (void)gh; return BORDER_L; }
-static coord_t BorderSizeR(GHandle gh) { (void)gh; return BORDER_R; }
-static coord_t BorderSizeT(GHandle gh) { (void)gh; return BORDER_T; }
-static coord_t BorderSizeB(GHandle gh) { (void)gh; return BORDER_B; }
+static coord_t FrameBorderSizeL(GHandle gh) { (void)gh; return FRM_BORDER_L; }
+static coord_t FrameBorderSizeR(GHandle gh) { (void)gh; return FRM_BORDER_R; }
+static coord_t FrameBorderSizeT(GHandle gh) { (void)gh; return FRM_BORDER_T; }
+static coord_t FrameBorderSizeB(GHandle gh) { (void)gh; return FRM_BORDER_B; }
static void forceFrameRedraw(GWidgetObject *gw) {
// Force a redraw of just the frame.
@@ -54,42 +54,42 @@ static void forceFrameRedraw(GWidgetObject *gw) {
}
#if GINPUT_NEED_MOUSE
- static void mouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
+ static void FrameMouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
coord_t pos;
// We must be clicking on the frame button area to be of interest
- if (y < BUTTON_T || y >= BUTTON_T+BUTTON_Y)
+ if (y < FRM_BUTTON_T || y >= FRM_BUTTON_T+FRM_BUTTON_Y)
return;
- pos = gw->g.width - (BORDER_R+BUTTON_X);
+ pos = gw->g.width - (FRM_BORDER_R+FRM_BUTTON_X);
if ((gw->g.flags & GWIN_FRAME_CLOSE_BTN)) {
- if (x >= pos && x < pos+BUTTON_X) {
+ if (x >= pos && x < pos+FRM_BUTTON_X) {
// Close is pressed - force redraw the frame only
gw->g.flags |= GWIN_FRAME_CLOSE_PRESSED;
forceFrameRedraw(gw);
return;
}
- pos -= BUTTON_X;
+ pos -= FRM_BUTTON_X;
}
if ((gw->g.flags & GWIN_FRAME_MINMAX_BTN)) {
- if (x >= pos && x < pos+BUTTON_X) {
+ if (x >= pos && x < pos+FRM_BUTTON_X) {
// Close is pressed - force redraw the frame only
gw->g.flags |= GWIN_FRAME_MAX_PRESSED;
forceFrameRedraw(gw);
return;
}
- pos -= BUTTON_X;
- if (x >= pos && x < pos+BUTTON_X) {
+ pos -= FRM_BUTTON_X;
+ if (x >= pos && x < pos+FRM_BUTTON_X) {
// Close is pressed - force redraw the frame only
gw->g.flags |= GWIN_FRAME_MIN_PRESSED;
forceFrameRedraw(gw);
return;
}
- pos -= BUTTON_X;
+ pos -= FRM_BUTTON_X;
}
}
- static void mouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
+ static void FrameMouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
#if GWIN_BUTTON_LAZY_RELEASE
if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED)) {
// Close is released - destroy the window
@@ -119,12 +119,12 @@ static void forceFrameRedraw(GWidgetObject *gw) {
return;
// We must be releasing over the button
- if (y >= BUTTON_T && y < BUTTON_T+BUTTON_Y) {
+ if (y >= FRM_BUTTON_T && y < FRM_BUTTON_T+FRM_BUTTON_Y) {
coord_t pos;
- pos = gw->g.width - (BORDER_R+BUTTON_X);
+ pos = gw->g.width - (FRM_BORDER_R+FRM_BUTTON_X);
if ((gw->g.flags & GWIN_FRAME_CLOSE_BTN)) {
- if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED) && x >= pos && x <= pos+BUTTON_X) {
+ if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED) && x >= pos && x <= pos+FRM_BUTTON_X) {
// Close is released - destroy the window. This is tricky as we already have the drawing lock.
gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED);
forceFrameRedraw(gw);
@@ -132,25 +132,25 @@ static void forceFrameRedraw(GWidgetObject *gw) {
_gwinDestroy(&gw->g, REDRAW_INSESSION);
return;
}
- pos -= BUTTON_X;
+ pos -= FRM_BUTTON_X;
}
if ((gw->g.flags & GWIN_FRAME_MINMAX_BTN)) {
- if ((gw->g.flags & GWIN_FRAME_MAX_PRESSED) && x >= pos && x <= pos+BUTTON_X) {
+ if ((gw->g.flags & GWIN_FRAME_MAX_PRESSED) && x >= pos && x <= pos+FRM_BUTTON_X) {
// Max is released - maximize the window
gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED);
forceFrameRedraw(gw);
gwinSetMinMax(&gw->g, GWIN_MAXIMIZE);
return;
}
- pos -= BUTTON_X;
- if ((gw->g.flags & GWIN_FRAME_MIN_PRESSED) && x >= pos && x <= pos+BUTTON_X) {
+ pos -= FRM_BUTTON_X;
+ if ((gw->g.flags & GWIN_FRAME_MIN_PRESSED) && x >= pos && x <= pos+FRM_BUTTON_X) {
// Min is released - minimize the window
gw->g.flags &= ~(GWIN_FRAME_CLOSE_PRESSED|GWIN_FRAME_MAX_PRESSED|GWIN_FRAME_MIN_PRESSED);
forceFrameRedraw(gw);
gwinSetMinMax(&gw->g, GWIN_MINIMIZE);
return;
}
- pos -= BUTTON_X;
+ pos -= FRM_BUTTON_X;
}
}
@@ -173,8 +173,8 @@ static const gcontainerVMT frameVMT = {
gwinFrameDraw_Std, // The default drawing routine
#if GINPUT_NEED_MOUSE
{
- mouseDown, // Process mouse down event
- mouseUp, // Process mouse up events
+ FrameMouseDown, // Process mouse down event
+ FrameMouseUp, // Process mouse up events
0, // Process mouse move events
},
#endif
@@ -196,10 +196,10 @@ static const gcontainerVMT frameVMT = {
},
#endif
},
- BorderSizeL, // The size of the left border (mandatory)
- BorderSizeT, // The size of the top border (mandatory)
- BorderSizeR, // The size of the right border (mandatory)
- BorderSizeB, // The size of the bottom border (mandatory)
+ FrameBorderSizeL, // The size of the left border (mandatory)
+ FrameBorderSizeT, // The size of the top border (mandatory)
+ FrameBorderSizeR, // The size of the right border (mandatory)
+ FrameBorderSizeB, // The size of the bottom border (mandatory)
0, // A child has been added (optional)
0, // A child has been deleted (optional)
};
@@ -238,34 +238,34 @@ void gwinFrameDraw_Transparent(GWidgetObject *gw, void *param) {
btn = gdispBlendColor(pcol->edge, contrast, 128);
// Render the frame
- gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, BORDER_T, gw->text, gw->g.font, contrast, pcol->edge, justifyCenter);
- gdispGFillArea(gw->g.display, gw->g.x, gw->g.y+BORDER_T, BORDER_L, gw->g.height-(BORDER_T+BORDER_B), pcol->edge);
- gdispGFillArea(gw->g.display, gw->g.x+gw->g.width-BORDER_R, gw->g.y+BORDER_T, BORDER_R, gw->g.height-(BORDER_T+BORDER_B), pcol->edge);
- gdispGFillArea(gw->g.display, gw->g.x, gw->g.y+gw->g.height-BORDER_B, gw->g.width, BORDER_B, pcol->edge);
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, FRM_BORDER_T, gw->text, gw->g.font, contrast, pcol->edge, justifyCenter);
+ gdispGFillArea(gw->g.display, gw->g.x, gw->g.y+FRM_BORDER_T, FRM_BORDER_L, gw->g.height-(FRM_BORDER_T+FRM_BORDER_B), pcol->edge);
+ gdispGFillArea(gw->g.display, gw->g.x+gw->g.width-FRM_BORDER_R, gw->g.y+FRM_BORDER_T, FRM_BORDER_R, gw->g.height-(FRM_BORDER_T+FRM_BORDER_B), pcol->edge);
+ gdispGFillArea(gw->g.display, gw->g.x, gw->g.y+gw->g.height-FRM_BORDER_B, gw->g.width, FRM_BORDER_B, pcol->edge);
// Add the buttons
- pos = gw->g.x+gw->g.width - (BORDER_R+BUTTON_X);
+ pos = gw->g.x+gw->g.width - (FRM_BORDER_R+FRM_BUTTON_X);
if ((gw->g.flags & GWIN_FRAME_CLOSE_BTN)) {
if ((gw->g.flags & GWIN_FRAME_CLOSE_PRESSED))
- gdispFillArea(pos, gw->g.y+BUTTON_T, BUTTON_X, BUTTON_Y, btn);
- gdispDrawLine(pos+BUTTON_I, gw->g.y+(BUTTON_T+BUTTON_I), pos+(BUTTON_X-BUTTON_I-1), gw->g.y+(BUTTON_T+BUTTON_Y-BUTTON_I-1), contrast);
- gdispDrawLine(pos+(BUTTON_X-BUTTON_I-1), gw->g.y+(BUTTON_T+BUTTON_I), pos+BUTTON_I, gw->g.y+(BUTTON_T+BUTTON_Y-BUTTON_I-1), contrast);
- pos -= BUTTON_X;
+ gdispFillArea(pos, gw->g.y+FRM_BUTTON_T, FRM_BUTTON_X, FRM_BUTTON_Y, btn);
+ gdispDrawLine(pos+FRM_BUTTON_I, gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I), pos+(FRM_BUTTON_X-FRM_BUTTON_I-1), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_Y-FRM_BUTTON_I-1), contrast);
+ gdispDrawLine(pos+(FRM_BUTTON_X-FRM_BUTTON_I-1), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I), pos+FRM_BUTTON_I, gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_Y-FRM_BUTTON_I-1), contrast);
+ pos -= FRM_BUTTON_X;
}
if ((gw->g.flags & GWIN_FRAME_MINMAX_BTN)) {
if ((gw->g.flags & GWIN_FRAME_MAX_PRESSED))
- gdispFillArea(pos, gw->g.y+BUTTON_T, BUTTON_X, BUTTON_Y, btn);
+ gdispFillArea(pos, gw->g.y+FRM_BUTTON_T, FRM_BUTTON_X, FRM_BUTTON_Y, btn);
// the symbol
- gdispDrawBox(pos+BUTTON_I, gw->g.y+(BUTTON_T+BUTTON_I), BUTTON_X-2*BUTTON_I, BUTTON_Y-2*BUTTON_I, contrast);
- gdispDrawLine(pos+(BUTTON_I+1), gw->g.y+(BUTTON_T+BUTTON_I+1), pos+(BUTTON_X-BUTTON_I-2), gw->g.y+(BUTTON_T+BUTTON_I+1), contrast);
- gdispDrawLine(pos+(BUTTON_I+1), gw->g.y+(BUTTON_T+BUTTON_I+2), pos+(BUTTON_X-BUTTON_I-2), gw->g.y+(BUTTON_T+BUTTON_I+2), contrast);
- pos -= BUTTON_X;
+ gdispDrawBox(pos+FRM_BUTTON_I, gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I), FRM_BUTTON_X-2*FRM_BUTTON_I, FRM_BUTTON_Y-2*FRM_BUTTON_I, contrast);
+ gdispDrawLine(pos+(FRM_BUTTON_I+1), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I+1), pos+(FRM_BUTTON_X-FRM_BUTTON_I-2), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I+1), contrast);
+ gdispDrawLine(pos+(FRM_BUTTON_I+1), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I+2), pos+(FRM_BUTTON_X-FRM_BUTTON_I-2), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_I+2), contrast);
+ pos -= FRM_BUTTON_X;
if ((gw->g.flags & GWIN_FRAME_MIN_PRESSED))
- gdispFillArea(pos, gw->g.y+BUTTON_T, BUTTON_X, BUTTON_Y, btn);
- gdispDrawLine(pos+BUTTON_I, gw->g.y+(BUTTON_T+BUTTON_Y-BUTTON_I-1), pos+(BUTTON_X-BUTTON_I-1), gw->g.y+(BUTTON_T+BUTTON_Y-BUTTON_I-1), contrast);
- pos -= BUTTON_X;
+ gdispFillArea(pos, gw->g.y+FRM_BUTTON_T, FRM_BUTTON_X, FRM_BUTTON_Y, btn);
+ gdispDrawLine(pos+FRM_BUTTON_I, gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_Y-FRM_BUTTON_I-1), pos+(FRM_BUTTON_X-FRM_BUTTON_I-1), gw->g.y+(FRM_BUTTON_T+FRM_BUTTON_Y-FRM_BUTTON_I-1), contrast);
+ pos -= FRM_BUTTON_X;
}
// Don't touch the client area
@@ -285,7 +285,7 @@ void gwinFrameDraw_Std(GWidgetObject *gw, void *param) {
return;
// Draw the client area
- gdispGFillArea(gw->g.display, gw->g.x + BORDER_L, gw->g.y + BORDER_T, gw->g.width - (BORDER_L+BORDER_R), gw->g.height - (BORDER_T+BORDER_B), gw->pstyle->background);
+ gdispGFillArea(gw->g.display, gw->g.x + FRM_BORDER_L, gw->g.y + FRM_BORDER_T, gw->g.width - (FRM_BORDER_L+FRM_BORDER_R), gw->g.height - (FRM_BORDER_T+FRM_BORDER_B), gw->pstyle->background);
}
#if GDISP_NEED_IMAGE
@@ -304,12 +304,12 @@ void gwinFrameDraw_Std(GWidgetObject *gw, void *param) {
return;
// Draw the client area by tiling the image
- mx = gw->g.x+gw->g.width - BORDER_R;
- my = gw->g.y+gw->g.height - BORDER_B;
- for(y = gw->g.y+BORDER_T, ih = gi->height; y < my; y += ih) {
+ mx = gw->g.x+gw->g.width - FRM_BORDER_R;
+ my = gw->g.y+gw->g.height - FRM_BORDER_B;
+ for(y = gw->g.y+FRM_BORDER_T, ih = gi->height; y < my; y += ih) {
if (ih > my - y)
ih = my - y;
- for(x = gw->g.x+BORDER_L, iw = gi->width; x < mx; x += iw) {
+ for(x = gw->g.x+FRM_BORDER_L, iw = gi->width; x < mx; x += iw) {
if (iw > mx - x)
iw = mx - x;
gdispGImageDraw(gw->g.display, gi, x, y, iw, ih, 0, 0);