struct tab_t *tab_select_effect_init(struct tab_select_effect_t* opaque){ uint32_t i; GWidgetInit wi; /* SelectStageTab */ for(i = 0; i < EFFECT_NUM; i++){ gwinWidgetClearInit(&wi); wi.g.show = FALSE; wi.g.x = 5; wi.g.y = 5 + 25 * i; wi.g.width = 230; wi.g.height = 20; wi.text = cvtToEffectName(i); opaque->btn_effectTypes[i] = gwinButtonCreate(NULL, &wi); } gwinWidgetClearInit(&wi); wi.g.show = FALSE; wi.g.x = 5; wi.g.y = 290; wi.g.width = 230; wi.g.height = 20; wi.text = "Back"; opaque->btn_back = gwinButtonCreate(NULL, &wi); opaque->parent.show = tab_select_effect_show; opaque->parent.hide = tab_select_effect_hide; opaque->parent.refresh = tab_select_effect_refresh; opaque->parent.bHandle = tab_select_effect_bHandle; return (struct tab_t*)opaque; }
static void createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN gwinWidgetClearInit(&wi); // Apply the container parameters wi.g.show = FALSE; wi.g.width = 200; wi.g.height = 150; wi.g.y = 10; wi.g.x = 10; wi.text = "Container"; ghContainer = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); wi.g.show = TRUE; // Apply the button parameters wi.g.width = 120; wi.g.height = 30; wi.g.y = 10; wi.g.x = 10; wi.text = "Button"; wi.g.parent = ghContainer; ghButton = gwinButtonCreate(0, &wi); // Make the container become visible - therefore all its children // become visible as well gwinShow(ghContainer); }
/** * Create all the widgets. * With the exception of the Pages they are all initially visible. * * This routine is complicated by the fact that we want a dynamic * layout so it looks good on small and large displays. * It is tested to work on 320x272 as a minimum LCD size. */ static void createWidgets(void) { GWidgetInit wi; coord_t border, pagewidth; gwinWidgetClearInit(&wi); // Calculate page borders based on screen size border = ScrWidth < 450 ? 1 : 5; // Create the Tabs #if GWIN_NEED_TABSET wi.g.show = TRUE; wi.g.x = border; wi.g.y = 0; wi.g.width = ScrWidth - 2*border; wi.g.height = ScrHeight-wi.g.y-border; ghTabset = gwinTabsetCreate(0, &wi, GWIN_TABSET_BORDER); ghPgButtons = gwinTabsetAddTab(ghTabset, "Buttons", FALSE); ghPgSliders = gwinTabsetAddTab(ghTabset, "Sliders", FALSE); ghPgCheckboxes = gwinTabsetAddTab(ghTabset, "Checkbox", FALSE); ghPgRadios = gwinTabsetAddTab(ghTabset, "Radios", FALSE); ghPgLists = gwinTabsetAddTab(ghTabset, "Lists", FALSE); ghPgLabels = gwinTabsetAddTab(ghTabset, "Labels", FALSE); ghPgImages = gwinTabsetAddTab(ghTabset, "Images", FALSE); ghPgProgressbars = gwinTabsetAddTab(ghTabset, "Progressbar", FALSE); pagewidth = gwinGetInnerWidth(ghTabset)/2; // Console - we apply some special colors before making it visible // We put the console on the tabset itself rather than a tab-page. // This makes it appear on every page :) wi.g.parent = ghTabset; wi.g.x = pagewidth; wi.g.width = pagewidth; ghConsole = gwinConsoleCreate(0, &wi.g); gwinSetColor(ghConsole, Black); gwinSetBgColor(ghConsole, HTML2COLOR(0xF0F0F0)); #else wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab; wi.g.height = TAB_HEIGHT; wi.g.y = 0; wi.g.x = 0; setbtntext(&wi, ScrWidth, "Buttons"); ghTabButtons = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Sliders"); ghTabSliders = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Checkbox"); ghTabCheckboxes = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Radios"); ghTabRadios = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Lists"); ghTabLists = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Labels"); ghTabLabels = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Images"); ghTabImages = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.x += wi.g.width; settabtext(&wi, "Progressbar"); ghTabProgressbar = gwinRadioCreate(0, &wi, GROUP_TABS); wi.g.y += wi.g.height; wi.customDraw = 0; // Create the Pages wi.g.show = FALSE; wi.g.x = border; wi.g.y += border; wi.g.width = ScrWidth/2 - border; wi.g.height = ScrHeight-wi.g.y-border; ghPgButtons = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgSliders = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgCheckboxes = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgRadios = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgLists = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgLabels = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgImages = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); ghPgProgressbars = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER); wi.g.show = TRUE; // Console - we apply some special colors before making it visible wi.g.x = ScrWidth/2+border; wi.g.width = ScrWidth/2 - 2*border; ghConsole = gwinConsoleCreate(0, &wi.g); gwinSetColor(ghConsole, Black); gwinSetBgColor(ghConsole, HTML2COLOR(0xF0F0F0)); pagewidth = gwinGetInnerWidth(ghPgButtons); #endif // Buttons wi.g.parent = ghPgButtons; wi.g.width = BUTTON_WIDTH; wi.g.height = BUTTON_HEIGHT; wi.g.y = 5; wi.g.x = 5; setbtntext(&wi, pagewidth, "Button 1"); ghButton1 = gwinButtonCreate(0, &wi); wi.g.x += wi.g.width+3; setbtntext(&wi, pagewidth, "Button 2"); ghButton2 = gwinButtonCreate(0, &wi); wi.g.x += wi.g.width+3; setbtntext(&wi, pagewidth, "Button 3"); ghButton3 = gwinButtonCreate(0, &wi); wi.g.x += wi.g.width+3; setbtntext(&wi, pagewidth, "Button 4"); ghButton4 = gwinButtonCreate(0, &wi); // Horizontal Sliders wi.g.parent = ghPgSliders; wi.g.width = pagewidth - 10; wi.g.height = SLIDER_WIDTH; wi.g.x = 5; wi.g.y = 5; wi.text = "S1"; ghSlider1 = gwinSliderCreate(0, &wi); gwinSliderSetPosition(ghSlider1, 33); wi.g.y += wi.g.height + 1; wi.text = "S2"; ghSlider2 = gwinSliderCreate(0, &wi); gwinSliderSetPosition(ghSlider2, 86); // Vertical Sliders wi.g.y += wi.g.height + 5; wi.g.width = SLIDER_WIDTH; wi.g.height = gwinGetInnerHeight(ghPgSliders) - 5 - wi.g.y; wi.g.x = 5; wi.text = "S3"; ghSlider3 = gwinSliderCreate(0, &wi); gwinSliderSetPosition(ghSlider3, 13); wi.g.x += wi.g.width+1; wi.text = "S4"; ghSlider4 = gwinSliderCreate(0, &wi); gwinSliderSetPosition(ghSlider4, 76); // Checkboxes - for the 2nd and 3rd checkbox we apply special drawing before making it visible wi.g.parent = ghPgCheckboxes; wi.g.width = CHECKBOX_WIDTH; wi.g.height = CHECKBOX_HEIGHT; wi.g.x = 5; wi.g.y = 5; wi.text = "C1"; ghCheckbox1 = gwinCheckboxCreate(0, &wi); wi.customDraw = gwinCheckboxDraw_CheckOnRight; wi.g.y += wi.g.height+1; wi.text = "C2"; ghCheckbox2 = gwinCheckboxCreate(0, &wi); wi.customDraw = gwinCheckboxDraw_Button; wi.g.y += wi.g.height+1; wi.text = "C3"; wi.g.width = BUTTON_WIDTH; wi.g.height = BUTTON_HEIGHT; ghCheckbox3 = gwinCheckboxCreate(0, &wi); wi.g.y += wi.g.height+1; wi.text = "Disable All"; wi.customDraw = 0; wi.g.width = DISABLEALL_WIDTH; wi.g.height = CHECKBOX_HEIGHT; ghCheckDisableAll = gwinCheckboxCreate(0, &wi); // Labels wi.g.parent = ghPgLabels; wi.g.width = pagewidth-10; wi.g.height = LABEL_HEIGHT; wi.g.x = wi.g.y = 5; wi.text = "N/A"; ghLabelSlider1 = gwinLabelCreate(0, &wi); gwinLabelSetAttribute(ghLabelSlider1, 100, "Slider 1:"); wi.g.y += LABEL_HEIGHT + 2; ghLabelSlider2 = gwinLabelCreate(0, &wi); gwinLabelSetAttribute(ghLabelSlider2, 100, "Slider 2:"); wi.g.y += LABEL_HEIGHT + 2; ghLabelSlider3 = gwinLabelCreate(0, &wi); gwinLabelSetAttribute(ghLabelSlider3, 100, "Slider 3:"); wi.g.y += LABEL_HEIGHT + 2; ghLabelSlider4 = gwinLabelCreate(0, &wi); gwinLabelSetAttribute(ghLabelSlider4, 100, "Slider 4:"); wi.g.y += LABEL_HEIGHT + 2; ghLabelRadio1 = gwinLabelCreate(0, &wi); gwinLabelSetAttribute(ghLabelRadio1, 100, "RadioButton 1:"); // Radio Buttons wi.g.parent = ghPgRadios; wi.g.width = RADIO_WIDTH; wi.g.height = RADIO_HEIGHT; wi.g.y = 5; wi.g.x = 5; wi.text = "Yes"; ghRadio1 = gwinRadioCreate(0, &wi, GROUP_YESNO); wi.g.x += wi.g.width; wi.text = "No"; if (wi.g.x + wi.g.width > pagewidth) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; } ghRadio2 = gwinRadioCreate(0, &wi, GROUP_YESNO); gwinRadioPress(ghRadio1); wi.g.width = COLOR_WIDTH; wi.g.y += RADIO_HEIGHT+5; wi.g.x = 5; wi.text = "Black"; ghRadioBlack = gwinRadioCreate(0, &wi, GROUP_COLORS); wi.g.x += wi.g.width; wi.text = "White"; if (wi.g.x + wi.g.width > pagewidth) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; } ghRadioWhite = gwinRadioCreate(0, &wi, GROUP_COLORS); wi.g.x += wi.g.width; wi.text = "Yellow"; if (wi.g.x + wi.g.width > pagewidth) { wi.g.x = 5; wi.g.y += RADIO_HEIGHT; } ghRadioYellow = gwinRadioCreate(0, &wi, GROUP_COLORS); gwinRadioPress(ghRadioWhite); // Lists border = pagewidth < 10+2*LIST_WIDTH ? 2 : 5; wi.g.parent = ghPgLists; wi.g.width = LIST_WIDTH; wi.g.height = LIST_HEIGHT; wi.g.y = border; wi.g.x = border; wi.text = "L1"; ghList1 = gwinListCreate(0, &wi, FALSE); gwinListAddItem(ghList1, "Item 0", FALSE); gwinListAddItem(ghList1, "Item 1", FALSE); gwinListAddItem(ghList1, "Item 2", FALSE); gwinListAddItem(ghList1, "Item 3", FALSE); gwinListAddItem(ghList1, "Item 4", FALSE); gwinListAddItem(ghList1, "Item 5", FALSE); gwinListAddItem(ghList1, "Item 6", FALSE); gwinListAddItem(ghList1, "Item 7", FALSE); gwinListAddItem(ghList1, "Item 8", FALSE); gwinListAddItem(ghList1, "Item 9", FALSE); gwinListAddItem(ghList1, "Item 10", FALSE); gwinListAddItem(ghList1, "Item 11", FALSE); gwinListAddItem(ghList1, "Item 12", FALSE); gwinListAddItem(ghList1, "Item 13", FALSE); wi.text = "L2"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > pagewidth) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; } ghList2 = gwinListCreate(0, &wi, TRUE); gwinListAddItem(ghList2, "Item 0", FALSE); gwinListAddItem(ghList2, "Item 1", FALSE); gwinListAddItem(ghList2, "Item 2", FALSE); gwinListAddItem(ghList2, "Item 3", FALSE); gwinListAddItem(ghList2, "Item 4", FALSE); gwinListAddItem(ghList2, "Item 5", FALSE); gwinListAddItem(ghList2, "Item 6", FALSE); gwinListAddItem(ghList2, "Item 7", FALSE); gwinListAddItem(ghList2, "Item 8", FALSE); gwinListAddItem(ghList2, "Item 9", FALSE); gwinListAddItem(ghList2, "Item 10", FALSE); gwinListAddItem(ghList2, "Item 11", FALSE); gwinListAddItem(ghList2, "Item 12", FALSE); gwinListAddItem(ghList2, "Item 13", FALSE); wi.text = "L3"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > pagewidth) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; } ghList3 = gwinListCreate(0, &wi, TRUE); gwinListAddItem(ghList3, "Item 0", FALSE); gwinListAddItem(ghList3, "Item 1", FALSE); gwinListAddItem(ghList3, "Item 2", FALSE); gwinListAddItem(ghList3, "Item 3", FALSE); gdispImageOpenFile(&imgYesNo, "image_yesno.gif"); gwinListItemSetImage(ghList3, 1, &imgYesNo); gwinListItemSetImage(ghList3, 3, &imgYesNo); wi.text = "L4"; wi.g.x += LIST_WIDTH+border; if (wi.g.x + LIST_WIDTH > pagewidth) { wi.g.x = border; wi.g.y += LIST_HEIGHT+border; } ghList4 = gwinListCreate(0, &wi, TRUE); gwinListAddItem(ghList4, "Item 0", FALSE); gwinListAddItem(ghList4, "Item 1", FALSE); gwinListAddItem(ghList4, "Item 2", FALSE); gwinListAddItem(ghList4, "Item 3", FALSE); gwinListAddItem(ghList4, "Item 4", FALSE); gwinListAddItem(ghList4, "Item 5", FALSE); gwinListAddItem(ghList4, "Item 6", FALSE); gwinListAddItem(ghList4, "Item 7", FALSE); gwinListAddItem(ghList4, "Item 8", FALSE); gwinListAddItem(ghList4, "Item 9", FALSE); gwinListAddItem(ghList4, "Item 10", FALSE); gwinListAddItem(ghList4, "Item 11", FALSE); gwinListAddItem(ghList4, "Item 12", FALSE); gwinListAddItem(ghList4, "Item 13", FALSE); gwinListSetScroll(ghList4, scrollSmooth); // Image wi.g.parent = ghPgImages; wi.g.x = wi.g.y = 0; wi.g.width = pagewidth; wi.g.height = gwinGetInnerHeight(ghPgImages); ghImage1 = gwinImageCreate(0, &wi.g); gwinImageOpenFile(ghImage1, "romfs_img_ugfx.gif"); // Progressbar wi.g.parent = ghPgProgressbars; wi.g.width = pagewidth-10; wi.g.height = SLIDER_WIDTH; wi.g.y = 5; wi.g.x = 5; wi.text = "Progressbar 1"; ghProgressbar1 = gwinProgressbarCreate(0, &wi); gwinProgressbarSetResolution(ghProgressbar1, 10); }
static void _createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN gwinWidgetClearInit(&wi); wi.g.show = TRUE; // Create a surprise label behind the frame window wi.g.width = 100; wi.g.height = 20; wi.g.y = 100; wi.g.x = 150; wi.text = "Surprise!"; gwinLabelCreate(0, &wi); // Apply the frame parameters wi.g.width = 300; wi.g.height = 200; wi.g.y = 10; wi.g.x = 10; wi.text = "Colorpicker"; ghFrame1 = gwinFrameCreate(0, &wi, GWIN_FRAME_BORDER | GWIN_FRAME_CLOSE_BTN | GWIN_FRAME_MINMAX_BTN); // Apply the button parameters wi.g.width = 60; wi.g.height = 20; wi.g.x = 10; wi.g.y = 10; wi.text = "Random"; wi.g.parent = ghFrame1; ghButton1 = gwinButtonCreate(0, &wi); // Apply the slider parameters wi.g.width = 200; wi.g.height = 20; wi.g.x = 80; wi.g.y += 0; wi.text = "Red"; wi.g.parent = ghFrame1; ghSliderR = gwinSliderCreate(0, &wi); gwinSliderSetRange(ghSliderR, 0, 255); gwinSliderSetPosition(ghSliderR, 180); // Apply the button parameters wi.g.width = 60; wi.g.height = 20; wi.g.x = 10; wi.g.y += 25; wi.text = "Random"; wi.g.parent = ghFrame1; ghButton2 = gwinButtonCreate(0, &wi); // Apply the slider parameters wi.g.width = 200; wi.g.height = 20; wi.g.x = 80; wi.g.y += 0; wi.text = "Green"; wi.g.parent = ghFrame1; ghSliderG = gwinSliderCreate(0, &wi); gwinSliderSetRange(ghSliderG, 0, 255); gwinSliderSetPosition(ghSliderG, 60); // Apply the button parameters wi.g.width = 60; wi.g.height = 20; wi.g.x = 10; wi.g.y += 25; wi.text = "Random"; wi.g.parent = ghFrame1; ghButton3 = gwinButtonCreate(0, &wi); // Apply the slider parameters wi.g.width = 200; wi.g.height = 20; wi.g.x = 80; wi.g.y += 0; wi.text = "Blue"; wi.g.parent = ghFrame1; ghSliderB = gwinSliderCreate(0, &wi); gwinSliderSetRange(ghSliderB, 0, 255); gwinSliderSetPosition(ghSliderB, 235); // Color Preview wi.g.width = 270; wi.g.height = 65; wi.g.x = 10; wi.g.y = 90; ghWindow1 = gwinWindowCreate(0, &wi.g); _updateColor(); }
static void createSettingsFrame(void) { GWidgetInit wi; gwinWidgetClearInit(&wi); wi.g.show = FALSE; wi.g.width = 320; wi.g.height = 190; wi.g.y = 25; wi.g.x = 0; wi.text = "Settings"; ghFrame1 = gwinFrameCreate(0, &wi, GWIN_FRAME_CLOSE_BTN);// | GWIN_FRAME_MINMAX_BTN); // Apply some default values for GWIN wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; wi.g.show = true; // Apply the list parameters wi.g.width = 65; wi.g.height = 50; wi.g.y = 10; wi.g.x = 10; wi.text = "Month"; wi.g.parent = ghFrame1; // Create the actual list ghListMonth = gwinListCreate(NULL, &wi, FALSE); char item[20]; int i = 0; for (i = 0; i < 12; i++) { sprintf(item, "%s", months[i]); gwinListAddItem(ghListMonth, item, true); } gwinListSetScroll(ghListMonth, scrollSmooth); // Apply some default values for GWIN wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; wi.g.show = true; // Apply the list parameters wi.g.width = 25; wi.g.height = 50; wi.g.y = 10; wi.g.x = 80; wi.text = "Day"; wi.g.parent = ghFrame1; // Create the actual list ghListDay = gwinListCreate(NULL, &wi, FALSE); for (i = 1; i <= 31; i++) { sprintf(item, "%i", i); gwinListAddItem(ghListDay, item, true); } gwinListSetScroll(ghListDay, scrollSmooth); // Apply some default values for GWIN wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; wi.g.show = true; // Apply the list parameters wi.g.width = 45; wi.g.height = 50; wi.g.y = 10; wi.g.x = 110; wi.text = "Year"; wi.g.parent = ghFrame1; // Create the actual list ghListYear = gwinListCreate(NULL, &wi, FALSE); for (i = 2016; i <= 2030; i++) { sprintf(item, "%i", i); gwinListAddItem(ghListYear, item, true); } gwinListSetScroll(ghListYear, scrollSmooth); wi.g.width = 25; wi.g.height = 50; wi.g.y = 10; wi.g.x = 160; wi.text = "Hour"; wi.g.parent = ghFrame1; // Create the actual list ghListHour = gwinListCreate(NULL, &wi, FALSE); for (i = 1; i <= 24; i++) { sprintf(item, "%i", i); gwinListAddItem(ghListHour, item, true); } gwinListSetScroll(ghListHour, scrollSmooth); wi.g.width = 25; wi.g.height = 50; wi.g.y = 10; wi.g.x = 190; wi.text = "Min"; wi.g.parent = ghFrame1; // Create the actual list ghListMin = gwinListCreate(NULL, &wi, FALSE); for (i = 1; i <= 60; i++) { sprintf(item, "%i", i); gwinListAddItem(ghListMin, item, true); } gwinListSetScroll(ghListMin, scrollSmooth); // create Slider1 wi.g.y = 10; wi.g.x = 235; wi.g.width = 20; wi.g.height = 100; wi.text = "B"; wi.g.parent = ghFrame1; ghSliderBl = gwinSliderCreate(NULL, &wi); // create Slider2 wi.g.y = 10; wi.g.x = 260; wi.g.width = 20; wi.g.height = 100; wi.text = "C"; wi.g.parent = ghFrame1; ghSliderCt = gwinSliderCreate(NULL, &wi); // Apply the checkbox parameters wi.g.width = 60; // includes text wi.g.height = 20; wi.g.y = 75; wi.g.x = 10; wi.text = " 12 Hr"; ghCheckBoxHR = gwinCheckboxCreate(NULL, &wi); // create button widget: ghBtnSettings wi.g.show = TRUE; wi.g.x = 235; wi.g.y = 130; wi.g.width = 50; wi.g.height = 27; wi.g.parent = ghFrame1; wi.text = "Save"; wi.customDraw = gwinButtonDraw_Rounded; //wi.customParam = &iconSettings; //wi.customStyle = &WhiteWidgetStyle; ghBtnSave = gwinButtonCreate(0, &wi); gwinSetFont(ghBtnSave, dejavu_sans_16_anti_aliased_u); // Create label widget: ghlblDateTime wi.g.show = TRUE; wi.g.x = 75; wi.g.y = 75; wi.g.width = 150; wi.g.height = 17; wi.g.parent = ghFrame1; wi.text = "00/00/00 00:00:00"; wi.customDraw = gwinLabelDrawJustifiedLeft; wi.customParam = 0; //wi.customStyle = &syBar; ghlblDateTime = gwinLabelCreate(0, &wi); gwinLabelSetBorder(ghlblDateTime, FALSE); gwinSetFont(ghlblDateTime, dejavu_sans_16_anti_aliased_u); gwinRedraw(ghlblDateTime); }
/** * Create all the widgets. * With the exception of the Tabs they are all created invisible. */ static void createWidgets(void) { GWidgetInit wi; wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; // Create the Tabs wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab; wi.g.width = ScrWidth/7; wi.g.height = TAB_HEIGHT; wi.g.y = 0; wi.g.x = 0*wi.g.width; wi.text = "Buttons"; ghTabButtons = gwinRadioCreate(NULL, &wi, GROUP_TABS); wi.g.x = 1*wi.g.width; wi.text = "Sliders"; ghTabSliders = gwinRadioCreate(NULL, &wi, GROUP_TABS); wi.g.x = 2*wi.g.width; wi.text = "Checkbox"; ghTabCheckboxes = gwinRadioCreate(NULL, &wi, GROUP_TABS); wi.g.x = 3*wi.g.width; wi.text = "Radios"; ghTabRadios = gwinRadioCreate(NULL, &wi, GROUP_TABS); wi.g.x = 4*wi.g.width; wi.text = "Lists"; ghTabLists = gwinRadioCreate(NULL, &wi, GROUP_TABS); wi.g.x = 5*wi.g.width; wi.text = "Labels"; ghTabLabels = gwinRadioCreate(NULL, &wi, GROUP_TABS); wi.g.x = 6*wi.g.width; wi.text = "Images"; ghTabImages = gwinRadioCreate(NULL, &wi, GROUP_TABS); // Buttons wi.g.show = FALSE; wi.customDraw = 0; wi.g.width = BUTTON_WIDTH; wi.g.height = BUTTON_HEIGHT; wi.g.y = TAB_HEIGHT+5; wi.g.x = 0+0*(BUTTON_WIDTH+1); wi.text = "B1"; ghButton1 = gwinButtonCreate(NULL, &wi); wi.g.x = 0+1*(BUTTON_WIDTH+1); wi.text = "B2"; ghButton2 = gwinButtonCreate(NULL, &wi); wi.g.x = 0+2*(BUTTON_WIDTH+1); wi.text = "B3"; ghButton3 = gwinButtonCreate(NULL, &wi); wi.g.x = 0+3*(BUTTON_WIDTH+1); wi.text = "B4"; ghButton4 = gwinButtonCreate(NULL, &wi); // Horizontal Sliders wi.g.width = ScrWidth/2-2; wi.g.height = SLIDER_WIDTH; wi.g.x = ScrWidth/2+1; wi.g.y = ScrHeight/2-2*(SLIDER_WIDTH+1); wi.text = "S1"; ghSlider1 = gwinSliderCreate(NULL, &wi); wi.g.y = ScrHeight/2-1*(SLIDER_WIDTH+1); wi.text = "S2"; ghSlider2 = gwinSliderCreate(NULL, &wi); // Vertical Sliders wi.g.width = SLIDER_WIDTH; wi.g.height = ScrHeight/2-2; wi.g.y = ScrHeight/2+1; wi.g.x = 0+0*(SLIDER_WIDTH+1); wi.text = "S3"; ghSlider3 = gwinSliderCreate(NULL, &wi); wi.g.x = 0+1*(SLIDER_WIDTH+1); wi.text = "S4"; ghSlider4 = gwinSliderCreate(NULL, &wi); // Checkboxes - for the 2nd checkbox we apply special drawing before making it visible wi.g.width = CHECKBOX_WIDTH; wi.g.height = CHECKBOX_HEIGHT; wi.g.x = 0; wi.g.y = TAB_HEIGHT+5+0*(CHECKBOX_HEIGHT+1); wi.text = "C1"; ghCheckbox1 = gwinCheckboxCreate(NULL, &wi); wi.customDraw = gwinCheckboxDraw_CheckOnRight; wi.g.y = TAB_HEIGHT+5+1*(CHECKBOX_HEIGHT+1); wi.text = "C2"; ghCheckbox2 = gwinCheckboxCreate(NULL, &wi); wi.customDraw = 0; wi.g.width = DISABLEALL_WIDTH; wi.g.y = TAB_HEIGHT+5+2*(CHECKBOX_HEIGHT+1); wi.text = "Disable All"; ghCheckDisableAll = gwinCheckboxCreate(NULL, &wi); // Labels wi.g.width = 0; wi.g.height = LABEL_HEIGHT; // dynamic width, fixed height wi.g.y = TAB_HEIGHT+5+2*(CHECKBOX_HEIGHT+1); wi.text = "Label"; ghLabel1 = gwinLabelCreate(NULL, &wi); // Radio Buttons wi.g.width = RADIO_WIDTH; wi.g.height = RADIO_HEIGHT; wi.g.y = TAB_HEIGHT+5; wi.g.x = 0*wi.g.width; wi.text = "Yes"; ghRadio1 = gwinRadioCreate(NULL, &wi, GROUP_YESNO); wi.g.x = 1*wi.g.width; wi.text = "No"; ghRadio2 = gwinRadioCreate(NULL, &wi, GROUP_YESNO); wi.g.width = COLOR_WIDTH; wi.g.y += RADIO_HEIGHT+5; wi.g.x = 0*wi.g.width; wi.text = "Black"; ghRadioBlack = gwinRadioCreate(NULL, &wi, GROUP_COLORS); wi.g.x = 1*wi.g.width; wi.text = "White"; ghRadioWhite = gwinRadioCreate(NULL, &wi, GROUP_COLORS); wi.g.x = 2*wi.g.width; wi.text = "Yellow"; ghRadioYellow = gwinRadioCreate(NULL, &wi, GROUP_COLORS); gwinRadioPress(ghRadioWhite); // Lists wi.g.show = FALSE; wi.customDraw = 0; wi.g.width = LIST_WIDTH; wi.g.height = LIST_HEIGHT; wi.g.y = TAB_HEIGHT+5; wi.g.x = 0+0*(LIST_WIDTH+1); wi.text = "L1"; ghList1 = gwinListCreate(NULL, &wi, FALSE); gwinListAddItem(ghList1, "Item 0", FALSE); gwinListAddItem(ghList1, "Item 1", FALSE); gwinListAddItem(ghList1, "Item 2", FALSE); gwinListAddItem(ghList1, "Item 3", FALSE); gwinListAddItem(ghList1, "Item 4", FALSE); gwinListAddItem(ghList1, "Item 5", FALSE); gwinListAddItem(ghList1, "Item 6", FALSE); gwinListAddItem(ghList1, "Item 7", FALSE); gwinListAddItem(ghList1, "Item 8", FALSE); gwinListAddItem(ghList1, "Item 9", FALSE); gwinListAddItem(ghList1, "Item 10", FALSE); gwinListAddItem(ghList1, "Item 11", FALSE); gwinListAddItem(ghList1, "Item 12", FALSE); gwinListAddItem(ghList1, "Item 13", FALSE); wi.g.x = 0+1*(LIST_WIDTH+1); wi.text = "L2"; ghList2 = gwinListCreate(NULL, &wi, TRUE); gwinListAddItem(ghList2, "Item 0", FALSE); gwinListAddItem(ghList2, "Item 1", FALSE); gwinListAddItem(ghList2, "Item 2", FALSE); gwinListAddItem(ghList2, "Item 3", FALSE); gwinListAddItem(ghList2, "Item 4", FALSE); gwinListAddItem(ghList2, "Item 5", FALSE); gwinListAddItem(ghList2, "Item 6", FALSE); gwinListAddItem(ghList2, "Item 7", FALSE); gwinListAddItem(ghList2, "Item 8", FALSE); gwinListAddItem(ghList2, "Item 9", FALSE); gwinListAddItem(ghList2, "Item 10", FALSE); gwinListAddItem(ghList2, "Item 11", FALSE); gwinListAddItem(ghList2, "Item 12", FALSE); gwinListAddItem(ghList2, "Item 13", FALSE); wi.g.x = 0+2*(LIST_WIDTH+1); wi.text = "L3"; ghList3 = gwinListCreate(NULL, &wi, TRUE); gwinListAddItem(ghList3, "Item 0", FALSE); gwinListAddItem(ghList3, "Item 1", FALSE); gwinListAddItem(ghList3, "Item 2", FALSE); gwinListAddItem(ghList3, "Item 3", FALSE); gdispImageSetMemoryReader(&imgYesNo, image_yesno); gdispImageOpen(&imgYesNo); gwinListItemSetImage(ghList3, 1, &imgYesNo); gwinListItemSetImage(ghList3, 3, &imgYesNo); // Image wi.g.x = ScrWidth-210; wi.g.y = TAB_HEIGHT + 10; wi.g.width = 200; wi.g.height = 200; ghImage1 = gwinImageCreate(NULL, &wi.g); gwinImageOpenMemory(ghImage1, image_chibios); gwinImageCache(ghImage1); // Console - we apply some special colors before making it visible wi.g.width = ScrWidth/2-1; wi.g.height = ScrHeight/2-1; wi.g.x = ScrWidth/2+1; wi.g.y = ScrHeight/2+1; ghConsole = gwinConsoleCreate(NULL, &wi.g); gwinSetColor(ghConsole, Yellow); gwinSetBgColor(ghConsole, Black); }
static void createWidgets(void) { gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); gdispClear(White); bHeight = gdispGetFontMetric(font, fontHeight)+2; // apply default settings GWidgetInit wi; wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; wi.g.show = TRUE; // create ICU1label wi.g.y = bHeight*2; wi.g.x = 0; wi.g.width = 160; wi.g.height = bHeight; wi.text = "ICU1:"; ICU1label = gwinLabelCreate(NULL, &wi); // ICU1vaule wi.g.y = bHeight*2; wi.g.x = 40; wi.g.width = 160; wi.g.height = bHeight; wi.text = "Status2"; ICU1value = gwinLabelCreate(NULL, &wi); // create ICU2label wi.g.y = bHeight*3; wi.g.x = 0; wi.g.width = 160; wi.g.height = bHeight; wi.text = "ICU2:"; ICU2label = gwinLabelCreate(NULL, &wi); // ICU2vaule wi.g.y = bHeight*3; wi.g.x = 40; wi.g.width = 160; wi.g.height = bHeight; wi.text = "000"; ICU2value = gwinLabelCreate(NULL, &wi); // create two status label //status 1 wi.g.y = sheight-bHeight; wi.g.x = 0; wi.g.width = 50; wi.g.height = bHeight; wi.text = "Status1"; ghStatus1 = gwinLabelCreate(NULL, &wi); // status 2 wi.g.y = sheight-bHeight; wi.g.x = 160; wi.g.width = 50; wi.g.height = bHeight; wi.text = "Status2"; ghStatus2 = gwinLabelCreate(NULL, &wi); // Brightness wi.g.y = sheight-(bHeight*2); wi.g.x = 0; wi.g.width = swidth; wi.g.height = bHeight; wi.text = "Brightness"; ghBrightness = gwinSliderCreate(NULL, &wi); gwinSliderSetRange(ghBrightness, 0, 100); gwinSliderSetPosition(ghBrightness, 50); gdispSetBacklight(50); // create ADC label // ADClabel1 wi.g.y = 0; wi.g.x = 0; wi.g.width = 50; wi.g.height = bHeight; wi.text = "ADC1:"; ADClabel = gwinLabelCreate(NULL, &wi); // ADClabel1 wi.g.y = 0; wi.g.x = 40; wi.g.width = 50; wi.g.height = bHeight; wi.text = "ADC value"; ADCvalue = gwinLabelCreate(NULL, &wi); // create ADC label // ADClabel1 wi.g.y = bHeight; wi.g.x = 0; wi.g.width = 70; wi.g.height = bHeight; wi.text = "Core temp:"; ADClabel2 = gwinLabelCreate(NULL, &wi); // ADClabel1 wi.g.y = bHeight; wi.g.x = 75; wi.g.width = 50; wi.g.height = bHeight; wi.text = "ADC value2"; ADCvalue2 = gwinLabelCreate(NULL, &wi); //create console button bWidth = gdispGetStringWidth("Console", font); wi.g.y = 10; //sheight-(bHeight*4); wi.g.x = swidth-70; wi.g.width = 50; wi.g.height = bHeight+4; wi.text = "Console"; ghConsole = gwinButtonCreate(NULL, &wi); //create console BMP button /* wi.g.x = swidth-85; wi.g.y = 40; wi.g.width = 84; wi.g.height = 23; ghbConsole = gwinImageCreate(NULL, &wi.g); gwinImageOpenMemory(ghbConsole, Console); gwinImageCache(ghbConsole); */ }