void gwinSetDefaultStyle(const GWidgetStyle *pstyle, bool_t updateAll) { if (!pstyle) pstyle = &BlackWidgetStyle; if (updateAll) { GHandle gh; for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) { if ((gh->flags & GWIN_FLG_WIDGET) && ((GWidgetObject *)gh)->pstyle == defaultStyle) gwinSetStyle(gh, pstyle); else gwinRedraw(gh); } } gwinSetDefaultBgColor(pstyle->background); defaultStyle = pstyle; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); ADC2status = 0; //write_to_backup_sram(0, 0, 0); startBlinker(); /* initialize and clear the display */ gfxInit(); ginputGetMouse(0); //ginputSetMouseCalibrationRoutines(0, mysave, myload, FALSE); //ginputGetMouse(0); // new ugfx do not need this gwinAttachMouse(0); geventListenerInit(&gl); gwinAttachListener(&gl); //geventAttachSource(&gl, mouse, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEMETA); //mouse = ginputGetMouse(0); //get screen size width = gdispGetWidth(); height = gdispGetHeight(); swidth = gdispGetWidth(); sheight = gdispGetHeight(); font = gdispOpenFont("UI2"); //startBlinker(); myADCinit(); ICUinit(); /* * Activates the serial driver 1 using the driver default configuration. * PA2(TX) and PA3(RX) are routed to USART2. */ sdStart(&SD2, NULL); palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL); //mouse = ginputGetMouse(0); font = gdispOpenFont("UI2"); gwinSetDefaultFont(font); gwinSetDefaultBgColor(Black); gwinSetDefaultColor(White); bHeight = gdispGetFontMetric(font, fontHeight)+2; #if BOOTSCREEN bootScreen(); #endif #ifdef LOGO gdispClear(Black); CreateLogo(); #endif // create main screen createWidgets(); chprintf( (BaseSequentialStream *)&SD2, "Main loop\r\n", NULL ); while (TRUE) { //get an event pe = geventEventWait(&gl, TIME_INFINITE); switch(pe->type) { case GEVENT_TOUCH: { pem = (GEventMouse *)pe; if ((pem->type & GMETA_MOUSE_CLICK)) { //gwinSetColor(ghc, Yellow); chprintf((BaseSequentialStream *)&SD2, "\r\n-touch-click"); } } case GEVENT_GWIN_BUTTON: if (((GEventGWinButton*)pe)->button == ghConsole) { gwinSetText(ghStatus2, "Console", TRUE); chprintf( (BaseSequentialStream *)&SD2, "\r\nConsole button", NULL ); }; break; case GEVENT_GWIN_SLIDER: if (((GEventGWinSlider*)pe)->slider == ghBrightness) { gdispSetBacklight(((GEventGWinSlider *)pe)->position); chprintf((BaseSequentialStream *)&SD2,"Slider %s = %d\r\n", gwinGetText(((GEventGWinSlider *)pe)->slider), ((GEventGWinSlider *)pe)->position); } break; default: break ; } } }