void tab_select_effect_hide(void* opaque){ struct tab_select_effect_t *tmp = (struct tab_select_effect_t*)opaque; uint32_t i; for(i = 0; i < EFFECT_NUM; i++){ gwinSetVisible(tmp->btn_effectTypes[i], FALSE); } gwinSetVisible(tmp->btn_back, FALSE); return; }
GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit, size_t maxSize) { char *p; // Create the underlying widget if (!(wt = (GTexteditObject*)_gwidgetCreate(g, &wt->w, pInit, &texteditVMT))) return 0; wt->maxSize = maxSize; // Reallocate the text (if necessary) if (!(wt->w.g.flags & GWIN_FLG_ALLOCTXT)) { if (!(p = gfxAlloc(wt->maxSize+1))) return 0; strncpy(p, wt->w.text, wt->maxSize); wt->w.text = p; wt->w.g.flags |= GWIN_FLG_ALLOCTXT; } // Set text and cursor position wt->cursorPos = strlen(wt->w.text); gwinSetVisible(&wt->w.g, pInit->g.show); return (GHandle)wt; }
GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *pInit) { if (!(gc = (GConsoleObject *)_gwindowCreate(g, &gc->g, pInit, &consoleVMT, 0))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM gc->stream.vmt = &GWindowConsoleVMT; #endif #if GWIN_CONSOLE_USE_HISTORY gc->buffer = 0; #if GWIN_CONSOLE_HISTORY_ATCREATE gwinConsoleSetBuffer(&gc->g, TRUE); #endif #endif gc->cx = 0; gc->cy = 0; #if GWIN_CONSOLE_ESCSEQ gc->startattr = gc->currattr = 0; gc->escstate = 0; #endif gwinSetVisible((GHandle)gc, pInit->show); return (GHandle)gc; }
GHandle gwinTabsetAddTab(GHandle gh, const char *title, bool_t useAlloc) { GWidgetInit wi; if (gh->vmt != (gwinVMT *)&tabsetVMT) return 0; // Set up the init structure gwinWidgetClearInit(&wi); wi.g.x = wi.g.y = 0; wi.g.width = gwinGetInnerWidth(gh); wi.g.height = gwinGetInnerHeight(gh); wi.g.show = !gwinTabsetCountTabs(gh); wi.g.parent = gh; // Create the page if (!(gh = _gcontainerCreate(gh->display, 0, &wi, &tabpageVMT))) return 0; // Set the text and visibility gwinSetText(gh, title, useAlloc); FixTabSizePos(gh->parent); gwinSetVisible(gh, wi.g.show); gwinRedraw(gh->parent); return gh; }
int main(void) { // Initialize ChibiOS halInit(); chSysInit(); // Initialize uGFX gfxInit(); // Initialize our own stuff startupInit(); // Get the command prompt (via USB) up and running cmdCreate(); // Get the SD-Card stuff done sdcardInit(); while (true) { cmdManage(); if(SDU1.config->usbp->state == USB_ACTIVE){ gwinShow(ghImageUSB); } else { gwinHide(ghImageUSB); } // Until the statusbar widget is ready... gwinSetVisible(ghImageSDC, sdcardReady()); sdCardEvent(); chThdSleepMilliseconds(500); } }
GHandle gwinGraphCreate(GGraphObject *gg, const GWindowInit *pInit) { if (!(gg = (GGraphObject *)_gwindowCreate(&gg->g, pInit, &graphVMT, 0))) return 0; gg->xorigin = gg->yorigin = 0; gg->lastx = gg->lasty = 0; gwinGraphSetStyle((GHandle)gg, &GGraphDefaultStyle); gwinSetVisible((GHandle)gg, pInit->show); return (GHandle)gg; }
GHandle gwinGButtonCreate(GDisplay *g, GButtonObject *gw, const GWidgetInit *pInit) { if (!(gw = (GButtonObject *)_gwidgetCreate(g, &gw->w, pInit, &buttonVMT))) return 0; #if GINPUT_NEED_TOGGLE gw->toggle = GWIDGET_NO_INSTANCE; #endif gwinSetVisible((GHandle)gw, pInit->g.show); return (GHandle)gw; }
GHandle gwinGGraphCreate(GDisplay *g, GGraphObject *gg, const GWindowInit *pInit) { if (!(gg = (GGraphObject *)_gwindowCreate(g, &gg->g, pInit, &graphVMT, 0))) return 0; gg->xorigin = gg->yorigin = 0; gg->lastx = gg->lasty = 0; gwinGraphSetStyle((GHandle)gg, &GGraphDefaultStyle); gwinSetVisible((GHandle)gg, pInit->show); _gwinFlushRedraws(REDRAW_WAIT); return (GHandle)gg; }
GHandle gwinGCheckboxCreate(GDisplay *g, GCheckboxObject *gb, const GWidgetInit *pInit) { if (!(gb = (GCheckboxObject *)_gwidgetCreate(g, &gb->w, pInit, &checkboxVMT))) return 0; #if GINPUT_NEED_TOGGLE gb->toggle = GWIDGET_NO_INSTANCE; #endif gwinSetVisible((GHandle)gb, pInit->g.show); return (GHandle)gb; }
GHandle gwinConsoleCreate(GConsoleObject *gc, const GWindowInit *pInit) { if (!(gc = (GConsoleObject *)_gwindowCreate(&gc->g, pInit, &consoleVMT, 0))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM gc->stream.vmt = &GWindowConsoleVMT; #endif gc->cx = 0; gc->cy = 0; gwinSetVisible((GHandle)gc, pInit->show); return (GHandle)gc; }
GHandle gwinGRadioCreate(GDisplay *g, GRadioObject *gw, const GWidgetInit *pInit, uint16_t group) { if (!(gw = (GRadioObject *)_gwidgetCreate(g, &gw->w, pInit, &radioVMT))) return 0; #if GINPUT_NEED_TOGGLE gw->toggle = GWIDGET_NO_INSTANCE; #endif gw->group = group; gwinSetVisible((GHandle)gw, pInit->g.show); return (GHandle)gw; }
GHandle gwinGTabsetCreate(GDisplay *g, GTabsetObject *fo, GWidgetInit *pInit, uint32_t flags) { if (!(fo = (GTabsetObject *)_gcontainerCreate(g, (GContainerObject *)fo, pInit, &tabsetVMT))) return 0; // Set Tabset specific stuff fo->c.g.flags |= flags & GWIN_TABSET_USER_FLAGS; fo->border_top = GWIN_TABSET_TABHEIGHT; gwinSetVisible(&fo->c.g, pInit->g.show); return &fo->c.g; }
GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint32_t flags) { if (!(fo = (GFrameObject *)_gcontainerCreate(g, (GContainerObject *)fo, pInit, &frameVMT))) return 0; // Make sure we only have "safe" flags. flags &= GWIN_FRAME_USER_FLAGS; /* Apply flags. We apply these here so the controls above are outside the child area */ fo->g.flags |= flags; gwinSetVisible(&fo->g, pInit->g.show); return &fo->g; }
GHandle gwinGImageCreate(GDisplay *g, GImageObject *gobj, GWindowInit *pInit) { if (!(gobj = (GImageObject *)_gwindowCreate(g, &gobj->g, pInit, &imageVMT, 0))) return 0; // Ensure the gdispImageIsOpen() gives valid results gdispImageInit(&gobj->image); // Initialise the timer #if GWIN_NEED_IMAGE_ANIMATION gtimerInit(&gobj->timer); #endif gwinSetVisible((GHandle)gobj, pInit->show); return (GHandle)gobj; }
GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, bool_t multiselect) { if (!(gobj = (GListObject *)_gwidgetCreate(g, &gobj->w, pInit, &listVMT))) return 0; // initialize the item queue gfxQueueASyncInit(&gobj->list_head); gobj->cnt = 0; gobj->top = 0; if (multiselect) gobj->w.g.flags |= GLIST_FLG_MULTISELECT; gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS; gobj->w.g.flags |= GLIST_FLG_ENABLERENDER; gwinSetVisible(&gobj->w.g, pInit->g.show); return (GHandle)gobj; }
GHandle gwinGProgressbarCreate(GDisplay *g, GProgressbarObject *gs, const GWidgetInit *pInit) { if (!(gs = (GProgressbarObject *)_gwidgetCreate(g, &gs->w, pInit, &progressbarVMT))) return 0; gs->min = 0; gs->max = 100; gs->res = 1; gs->pos = 0; #if GWIN_PROGRESSBAR_AUTO gtimerInit(&gs->gt); #endif PBResetDisplayPos(gs); gwinSetVisible((GHandle)gs, pInit->g.show); return (GHandle)gs; }
GHandle gwinLabelCreate(GLabelObject *widget, GWidgetInit *pInit) { uint16_t flags = 0; // auto assign width if (pInit->g.width <= 0) { flags |= GLABEL_FLG_WAUTO; pInit->g.width = getwidth(pInit->text, gwinGetDefaultFont(), gdispGetWidth() - pInit->g.x); } // auto assign height if (pInit->g.height <= 0) { flags |= GLABEL_FLG_HAUTO; pInit->g.height = getheight(pInit->text, gwinGetDefaultFont(), gdispGetWidth() - pInit->g.x); } if (!(widget = (GLabelObject *)_gwidgetCreate(&widget->w, pInit, &labelVMT))) return 0; widget->w.g.flags |= flags; gwinSetVisible(&widget->w.g, pInit->g.show); return (GHandle)widget; }
GHandle gwinGFrameCreate(GDisplay *g, GFrameObject *fo, GWidgetInit *pInit, uint32_t flags) { if (!(fo = (GFrameObject *)_gcontainerCreate(g, &fo->gc, pInit, &frameVMT))) return 0; fo->btnClose = 0; fo->btnMin = 0; fo->btnMax = 0; /* Buttons require a border */ if ((flags & (GWIN_FRAME_CLOSE_BTN|GWIN_FRAME_MINMAX_BTN))) flags |= GWIN_FRAME_BORDER; /* create and initialize the listener if any button is present. */ 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)) { GWidgetInit wi; gwinWidgetClearInit(&wi); wi.g.show = TRUE; wi.g.parent = &fo->gc.g; wi.g.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 = "X"; fo->btnClose = gwinGButtonCreate(g, 0, &wi); } /* create minimize and maximize buttons if necessary */ if ((flags & GWIN_FRAME_MINMAX_BTN)) { GWidgetInit wi; gwinWidgetClearInit(&wi); wi.g.show = TRUE; wi.g.parent = &fo->gc.g; wi.g.x = (flags & GWIN_FRAME_CLOSE_BTN) ? fo->gc.g.width - 2*BORDER_X - 2*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 = "O"; 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 = gwinGButtonCreate(g, 0, &wi); } /* Apply flags. We apply these here so the controls above are outside the child area */ fo->gc.g.flags |= flags; gwinSetVisible(&fo->gc.g, pInit->g.show); return &fo->gc.g; }
/** * Set the visibility of widgets based on which tab is selected. */ static void setTab(GHandle tab) { /* Make sure everything is invisible first */ gwinSetVisible(ghButton1, FALSE); gwinSetVisible(ghButton2, FALSE); gwinSetVisible(ghButton3, FALSE); gwinSetVisible(ghButton4, FALSE); gwinSetVisible(ghSlider1, FALSE); gwinSetVisible(ghSlider2, FALSE); gwinSetVisible(ghSlider3, FALSE); gwinSetVisible(ghSlider4, FALSE); gwinSetVisible(ghCheckbox1, FALSE); gwinSetVisible(ghCheckbox2, FALSE); gwinSetVisible(ghCheckDisableAll, FALSE); gwinSetVisible(ghLabel1, FALSE); gwinSetVisible(ghRadio1, FALSE); gwinSetVisible(ghRadio2, FALSE); gwinSetVisible(ghRadioWhite, FALSE);gwinSetVisible(ghRadioBlack, FALSE);gwinSetVisible(ghRadioYellow, FALSE); gwinSetVisible(ghList1, FALSE); gwinSetVisible(ghList2, FALSE); gwinSetVisible(ghList3, FALSE); gwinSetVisible(ghImage1, FALSE); /* Turn on widgets depending on the tab selected */ if (tab == ghTabButtons) { gwinSetVisible(ghButton1, TRUE); gwinSetVisible(ghButton2, TRUE); gwinSetVisible(ghButton3, TRUE); gwinSetVisible(ghButton4, TRUE); } else if (tab == ghTabSliders) { gwinSetVisible(ghSlider1, TRUE); gwinSetVisible(ghSlider2, TRUE); gwinSetVisible(ghSlider3, TRUE); gwinSetVisible(ghSlider4, TRUE); } else if (tab == ghTabCheckboxes) { gwinSetVisible(ghCheckbox1, TRUE); gwinSetVisible(ghCheckbox2, TRUE); gwinSetVisible(ghCheckDisableAll, TRUE); } else if (tab == ghTabLabels) { gwinSetVisible(ghLabel1, TRUE); } else if (tab == ghTabRadios) { gwinSetVisible(ghRadio1, TRUE); gwinSetVisible(ghRadio2, TRUE); gwinSetVisible(ghRadioWhite, TRUE); gwinSetVisible(ghRadioBlack, TRUE); gwinSetVisible(ghRadioYellow, TRUE); } else if (tab == ghTabLists) { gwinSetVisible(ghList1, TRUE); gwinSetVisible(ghList2, TRUE); gwinSetVisible(ghList3, TRUE); } else if (tab == ghTabImages) { gwinSetVisible(ghImage1, TRUE); } }
int main(void) { GEvent * pe; // Initialize the display gfxInit(); // Set the widget defaults gwinSetDefaultFont(gdispOpenFont("*")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); gdispClear(White); // Connect the mouse #if GINPUT_NEED_MOUSE gwinAttachMouse(0); #endif // Create the gwin windows/widgets createWidgets(); // Assign toggles and dials to specific buttons & sliders etc. #if GINPUT_NEED_TOGGLE gwinAttachToggle(ghButton1, 0, 0); gwinAttachToggle(ghButton2, 0, 1); #endif #if GINPUT_NEED_DIAL gwinAttachDial(ghSlider1, 0, 0); gwinAttachDial(ghSlider3, 0, 1); #endif // Make the console visible gwinSetVisible(ghConsole, TRUE); gwinClear(ghConsole); // We want to listen for widget events geventListenerInit(&gl); gwinAttachListener(&gl); // Press the Tab we want visible gwinRadioPress(ghTabButtons); while(1) { // Get an Event pe = geventEventWait(&gl, TIME_INFINITE); switch(pe->type) { case GEVENT_GWIN_BUTTON: gwinPrintf(ghConsole, "Button %s\n", gwinGetText(((GEventGWinButton *)pe)->button)); break; case GEVENT_GWIN_SLIDER: gwinPrintf(ghConsole, "Slider %s=%d\n", gwinGetText(((GEventGWinSlider *)pe)->slider), ((GEventGWinSlider *)pe)->position); break; case GEVENT_GWIN_CHECKBOX: gwinPrintf(ghConsole, "Checkbox %s=%s\n", gwinGetText(((GEventGWinCheckbox *)pe)->checkbox), ((GEventGWinCheckbox *)pe)->isChecked ? "Checked" : "UnChecked"); // If it is the Disable All checkbox then do that. if (((GEventGWinCheckbox *)pe)->checkbox == ghCheckDisableAll) { gwinPrintf(ghConsole, "%s All\n", ((GEventGWinCheckbox *)pe)->isChecked ? "Disable" : "Enable"); setEnabled(!((GEventGWinCheckbox *)pe)->isChecked); } break; case GEVENT_GWIN_LIST: gwinPrintf(ghConsole, "List %s Item %d %s\n", gwinGetText(((GEventGWinList *)pe)->list), ((GEventGWinList *)pe)->item, gwinListItemIsSelected(((GEventGWinList *)pe)->list, ((GEventGWinList *)pe)->item) ? "Selected" : "Unselected"); break; case GEVENT_GWIN_RADIO: gwinPrintf(ghConsole, "Radio Group %u=%s\n", ((GEventGWinRadio *)pe)->group, gwinGetText(((GEventGWinRadio *)pe)->radio)); switch(((GEventGWinRadio *)pe)->group) { case GROUP_TABS: // Set control visibility depending on the tab selected setTab(((GEventGWinRadio *)pe)->radio); // Do some special animation for Label1 to demonstrate auto width sizing if (((GEventGWinRadio *)pe)->radio == ghTabLabels) { gwinPrintf(ghConsole, "Change Label Text\n"); gfxSleepMilliseconds(1000); gwinSetText(ghLabel1, "Very Big Label", FALSE); gfxSleepMilliseconds(1000); gwinSetText(ghLabel1, "Label", FALSE); } break; case GROUP_COLORS: { const GWidgetStyle *pstyle; gwinPrintf(ghConsole, "Change Color Scheme\n"); if (((GEventGWinRadio *)pe)->radio == ghRadioYellow) pstyle = &YellowWidgetStyle; else if (((GEventGWinRadio *)pe)->radio == ghRadioBlack) pstyle = &BlackWidgetStyle; else pstyle = &WhiteWidgetStyle; // Clear the screen to the new color - we avoid the console area as it can't redraw itself #if GDISP_NEED_CLIP gdispUnsetClip(); #endif gdispFillArea(0, 0, ScrWidth, ScrHeight/2, pstyle->background); gdispFillArea(0, ScrHeight/2, ScrWidth/2, ScrHeight/2, pstyle->background); // Update the style on all controls gwinSetDefaultStyle(pstyle, TRUE); } break; } break; default: gwinPrintf(ghConsole, "Unknown %d\n", pe->type); break; } } return 0; }
GHandle gwinWindowCreate(GWindowObject *pgw, const GWindowInit *pInit) { if (!(pgw = _gwindowCreate(pgw, pInit, &basegwinVMT, 0))) return 0; gwinSetVisible(pgw, pInit->show); return pgw; }
int main(void) { uint8_t i; font_t font1, font2; /* initialize and clear the display */ gfxInit(); /* Set some fonts */ font1 = gdispOpenFont("UI2"); font2 = gdispOpenFont("DejaVu Sans 12"); gwinSetDefaultFont(font1); /* create the three console windows */ { GWindowInit wi; gwinClearInit(&wi); wi.show = TRUE; wi.x = 0; wi.y = 0; wi.width = gdispGetWidth(); wi.height = gdispGetHeight()/2; GW1 = gwinConsoleCreate(0, &wi); wi.y = gdispGetHeight()/2; wi.width = gdispGetWidth()/2; wi.height = gdispGetHeight(); GW2 = gwinConsoleCreate(0, &wi); wi.x = gdispGetWidth()/2; wi.height = gdispGetHeight(); GW3 = gwinConsoleCreate(0, &wi); } /* Use a special font for GW1 */ gwinSetFont(GW1, font2); /* Set the fore- and background colors for each console */ gwinSetColor(GW1, Green); gwinSetBgColor(GW1, Black); gwinSetColor(GW2, White); gwinSetBgColor(GW2, Blue); gwinSetColor(GW3, Black); gwinSetBgColor(GW3, Red); /* clear all console windows - to set background */ gwinClear(GW1); gwinClear(GW2); gwinClear(GW3); /* Output some data on the first console */ for(i = 0; i < 10; i++) { gwinPrintf(GW1, "Hello \033buGFX\033B!\n"); } /* Output some data on the second console - Fast */ for(i = 0; i < 32; i++) { gwinPrintf(GW2, "Message Nr.: \0331\033b%d\033B\033C\n", i+1); } /* Output some data on the third console - Slowly */ for(i = 0; i < 32; i++) { gwinPrintf(GW3, "Message Nr.: \033u%d\033U\n", i+1); gfxSleepMilliseconds(500); } /* Make console 3 invisible and then visible again to demonstrate the history buffer */ gwinPrintf(GW2, "Making red window \033uinvisible\033U\n"); gwinSetVisible(GW3, FALSE); gfxSleepMilliseconds(1000); gwinPrintf(GW2, "Making red window \033uvisible\033U\n"); gwinSetVisible(GW3, TRUE); gwinPrintf(GW3, "\033bI'm back!!!\033B\n", i+1); while(TRUE) { gfxSleepMilliseconds(500); } }
static void WM_Move(GHandle gh, coord_t x, coord_t y) { coord_t u, v; #if GWIN_NEED_CONTAINERS if (gh->parent) { // Clip to the parent size u = gh->parent->width - ((const gcontainerVMT *)gh->parent->vmt)->LeftBorder(gh->parent) - ((const gcontainerVMT *)gh->parent->vmt)->RightBorder(gh->parent); v = gh->parent->height - ((const gcontainerVMT *)gh->parent->vmt)->TopBorder(gh->parent) - ((const gcontainerVMT *)gh->parent->vmt)->BottomBorder(gh->parent); } else #endif { // Clip to the screen u = gdispGGetWidth(gh->display); v = gdispGGetHeight(gh->display); } // Make sure we are positioned in the appropriate area if (x+gh->width > u) x = u-gh->width; if (x < 0) x = 0; if (y+gh->height > v) y = v-gh->height; if (y < 0) y = 0; // Make sure we don't overflow the appropriate area u -= x; v -= y; if (gh->width < u) u = gh->width; if (gh->height < v) v = gh->height; if (u != gh->width || v != gh->height) WM_Size(gh, u, v); #if GWIN_NEED_CONTAINERS if (gh->parent) { // Convert to a screen relative position x += gh->parent->x + ((const gcontainerVMT *)gh->parent->vmt)->LeftBorder(gh->parent); y += gh->parent->y + ((const gcontainerVMT *)gh->parent->vmt)->TopBorder(gh->parent); } #endif // If there has been no move just exit if (gh->x == x && gh->y == y) return; // Clear the old area and then redraw if ((gh->flags & GWIN_FLG_SYSVISIBLE)) { // We need to make this window invisible and ensure that has been drawn gwinSetVisible(gh, FALSE); _gwinFlushRedraws(REDRAW_WAIT); // Do the move u = gh->x; gh->x = x; v = gh->y; gh->y = y; #if GWIN_NEED_CONTAINERS // Any children need to be moved if ((gh->flags & GWIN_FLG_CONTAINER)) { GHandle child; // Move to their old relative location. THe WM_Move() will adjust as necessary for(child = gwinGetFirstChild(gh); child; child = gwinGetSibling(child)) WM_Move(child, child->x-u-((const gcontainerVMT *)gh->vmt)->LeftBorder(gh), child->y-v-((const gcontainerVMT *)gh->vmt)->TopBorder(gh)); } #endif gwinSetVisible(gh, TRUE); } else { u = gh->x; gh->x = x; v = gh->y; gh->y = y; #if GWIN_NEED_CONTAINERS // Any children need to be moved if ((gh->flags & GWIN_FLG_CONTAINER)) { GHandle child; // Move to their old relative location. THe WM_Move() will adjust as necessary for(child = gwinGetFirstChild(gh); child; child = gwinGetSibling(child)) WM_Move(child, child->x-u-((const gcontainerVMT *)gh->vmt)->LeftBorder(gh), child->y-v-((const gcontainerVMT *)gh->vmt)->TopBorder(gh)); } #endif } }
static void WM_Size(GHandle gh, coord_t w, coord_t h) { coord_t v; #if GWIN_NEED_CONTAINERS if (gh->parent) { // Clip to the container v = gh->parent->x + gh->parent->width - ((const gcontainerVMT *)gh->parent->vmt)->RightBorder(gh->parent); if (gh->x+w > v) w = v - gh->x; v = gh->parent->y + gh->parent->height - ((const gcontainerVMT *)gh->parent->vmt)->BottomBorder(gh->parent); if (gh->y+h > v) h = v - gh->y; } #endif // Clip to the screen v = gdispGGetWidth(gh->display); if (gh->x+w > v) w = v - gh->x; v = gdispGGetHeight(gh->display); if (gh->y+h > v) h = v - gh->y; // Give it a minimum size if (w < MIN_WIN_WIDTH) w = MIN_WIN_WIDTH; if (h < MIN_WIN_HEIGHT) h = MIN_WIN_HEIGHT; // If there has been no resize just exit if (gh->width == w && gh->height == h) return; // Set the new size and redraw if ((gh->flags & GWIN_FLG_SYSVISIBLE)) { if (w >= gh->width && h >= gh->height) { // The new size is larger - just redraw gh->width = w; gh->height = h; _gwinUpdate(gh); } else { // We need to make this window invisible and ensure that has been drawn gwinSetVisible(gh, FALSE); _gwinFlushRedraws(REDRAW_WAIT); // Resize gh->width = w; gh->height = h; #if GWIN_NEED_CONTAINERS // Any children outside the new area need to be moved if ((gh->flags & GWIN_FLG_CONTAINER)) { GHandle child; // Move to their old relative location. THe WM_Move() will adjust as necessary for(child = gwinGetFirstChild(gh); child; child = gwinGetSibling(child)) WM_Move(child, child->x-gh->x-((const gcontainerVMT *)gh->vmt)->LeftBorder(gh), child->y-gh->y-((const gcontainerVMT *)gh->vmt)->TopBorder(gh)); } #endif // Mark it visible again in its new location gwinSetVisible(gh, TRUE); } } else { gh->width = w; gh->height = h; #if GWIN_NEED_CONTAINERS // Any children outside the new area need to be moved if ((gh->flags & GWIN_FLG_CONTAINER)) { GHandle child; // Move to their old relative location. THe WM_Move() will adjust as necessary for(child = gwinGetFirstChild(gh); child; child = gwinGetSibling(child)) WM_Move(child, child->x-gh->x-((const gcontainerVMT *)gh->vmt)->LeftBorder(gh), child->y-gh->y-((const gcontainerVMT *)gh->vmt)->TopBorder(gh)); } #endif } }