From bdbe78a8daed85e6d794deb1f840c1ec3c3b02f1 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 11 May 2014 13:09:36 +1000 Subject: frame fixes --- src/gwin/frame.c | 20 ++++++++++---------- src/gwin/gwin.c | 2 +- src/gwin/gwm.c | 6 ++++-- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src/gwin') diff --git a/src/gwin/frame.c b/src/gwin/frame.c index ca37953a..16e16987 100644 --- a/src/gwin/frame.c +++ b/src/gwin/frame.c @@ -100,26 +100,26 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint if (!(fo = (GFrameObject *)_gcontainerCreate(g, &fo->gc, pInit, &frameVMT))) return 0; - fo->btnClose = NULL; - fo->btnMin = NULL; - fo->btnMax = NULL; + fo->btnClose = 0; + fo->btnMin = 0; + fo->btnMax = 0; /* Buttons require a border */ - if ((flags & GWIN_FRAME_CLOSE_BTN || flags & GWIN_FRAME_MINMAX_BTN) && !(flags & GWIN_FRAME_BORDER)) + if ((flags & (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN))) flags |= GWIN_FRAME_BORDER; /* apply flags */ fo->gc.g.flags |= flags; /* create and initialize the listener if any button is present. */ - if ((flags & GWIN_FRAME_CLOSE_BTN) || (flags & GWIN_FRAME_MINMAX_BTN)) { + if ((flags & (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN))) { geventListenerInit(&fo->gl); gwinAttachListener(&fo->gl); geventRegisterCallback(&fo->gl, _callbackBtn, (GHandle)fo); } /* create close button if necessary */ - if (flags & GWIN_FRAME_CLOSE_BTN) { + if ((flags & GWIN_FRAME_CLOSE_BTN)) { GWidgetInit wi; gwinWidgetClearInit(&wi); @@ -131,11 +131,11 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint wi.g.width = BUTTON_X; wi.g.height = BUTTON_Y; wi.text = "X"; - fo->btnClose = gwinButtonCreate(NULL, &wi); + fo->btnClose = gwinGButtonCreate(g, 0, &wi); } /* create minimize and maximize buttons if necessary */ - if (flags & GWIN_FRAME_MINMAX_BTN) { + if ((flags & GWIN_FRAME_MINMAX_BTN)) { GWidgetInit wi; gwinWidgetClearInit(&wi); @@ -147,14 +147,14 @@ GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint wi.g.width = BUTTON_X; wi.g.height = BUTTON_Y; wi.text = "O"; - fo->btnMin = gwinButtonCreate(NULL, &wi); + fo->btnMin = gwinGButtonCreate(g, 0, &wi); wi.g.x = (flags & GWIN_FRAME_CLOSE_BTN) ? fo->gc.g.width - 3*BORDER_X - 3*BUTTON_X : fo->gc.g.width - BORDER_X - BUTTON_X; wi.g.y = (BORDER_Y - BUTTON_Y) / 2; wi.g.width = BUTTON_X; wi.g.height = BUTTON_Y; wi.text = "_"; - fo->btnMax = gwinButtonCreate(NULL, &wi); + fo->btnMax = gwinGButtonCreate(g, 0, &wi); } gwinSetVisible(&fo->gc.g, pInit->g.show); diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index 563b7abe..dfcb8d4c 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -148,7 +148,7 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit #if GWIN_NEED_CONTAINERS if (pInit->parent) { - if (!(pInit->parent->flags & GWIN_FLG_CONTAINER) || pgw->display != pgw->parent->display) { + if (!(pInit->parent->flags & GWIN_FLG_CONTAINER) || pgw->display != pInit->parent->display) { if ((pgw->flags & GWIN_FLG_DYNAMIC)) gfxFree(pgw); return 0; diff --git a/src/gwin/gwm.c b/src/gwin/gwm.c index c5e0f956..7611bc9d 100644 --- a/src/gwin/gwm.c +++ b/src/gwin/gwm.c @@ -217,7 +217,8 @@ static void WM_Size(GHandle gh, coord_t w, coord_t h) { // Clip to the container if (gh->x+w > gh->parent->x+gh->parent->width) w = gh->parent->x + gh->parent->width - gh->x; if (gh->y+h > gh->parent->y+gh->parent->height) h = gh->parent->y + gh->parent->height - gh->y; - ((const gcontainerVMT *)gh->parent->vmt)->AdjustSize(gh, &w, &h); + if (((const gcontainerVMT *)gh->parent->vmt)->AdjustSize) + ((const gcontainerVMT *)gh->parent->vmt)->AdjustSize(gh, &w, &h); } #endif @@ -251,7 +252,8 @@ static void WM_Move(GHandle gh, coord_t x, coord_t y) { if (y > gh->parent->height-gh->height) y = gh->parent->height-gh->height; // Allow the parent to adjust it - ((const gcontainerVMT *)gh->parent->vmt)->AdjustPosition(gh, &x, &y); + if (((const gcontainerVMT *)gh->parent->vmt)->AdjustPosition) + ((const gcontainerVMT *)gh->parent->vmt)->AdjustPosition(gh, &x, &y); // Convert to absolute position x += gh->parent->x; -- cgit v1.2.3