static void ScrMain_DrawStatus( void ) { snprintf( szStatusText, sizeof( szStatusText ), "%02u/%02u/%02u %02u:%02u:%02u", g_demo_parameters.dwMonth, g_demo_parameters.dwDay, g_demo_parameters.dwYear-2000, g_demo_parameters.dwHour, g_demo_parameters.dwMin, g_demo_parameters.dwSec ) ; WGT_SetText( &g_wgt_Status, szStatusText ) ; WGT_Draw( &g_wgt_Status, g_WGT_CoreData.pBE ) ; }
static uint32_t _ScrSettings_Date_ProcessMessage( SWGTScreen* pScreen, SWGTCoreMessage* pMsg ) { // printf( "ScrSettings_Date - msg id %x\r\n", pMsg->dwID ) ; switch ( pMsg->dwID ) { case WGT_MSG_WIDGET_SELECTED : /* * Handle Back button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnBack ) { g_demo_parameters.dwDay=gs_dwDay ; g_demo_parameters.dwMonth=gs_dwMonth ; g_demo_parameters.dwYear=gs_dwYear ; Demo_Parameters_CommitChanges() ; WGT_SetCurrentScreen( &ScrSettings ) ; } /* * Handle UP/Day button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnUpDay ) { if ( gs_dwDay == 31 ) { gs_dwDay=1 ; } else { gs_dwDay++ ; } _ScrSettings_Date_SetDay() ; WGT_Draw( &g_wgt_Day, g_WGT_CoreData.pBE ) ; } /* * Handle DOWN/Day button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnDownDay ) { if ( gs_dwDay == 1 ) { gs_dwDay=31 ; } else { gs_dwDay-- ; } _ScrSettings_Date_SetDay() ; WGT_Draw( &g_wgt_Day, g_WGT_CoreData.pBE ) ; } /* * Handle UP/Month button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnUpMonth ) { if ( gs_dwMonth == 12 ) { gs_dwMonth=1 ; } else { gs_dwMonth++ ; } _ScrSettings_Date_SetMonth() ; WGT_Draw( &g_wgt_Month, g_WGT_CoreData.pBE ) ; } /* * Handle DOWN/Month button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnDownMonth ) { if ( gs_dwMonth == 1 ) { gs_dwMonth=12 ; } else { gs_dwMonth-- ; } _ScrSettings_Date_SetMonth() ; WGT_Draw( &g_wgt_Month, g_WGT_CoreData.pBE ) ; } /* * Handle UP/Year button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnUpYear ) { if ( gs_dwYear == 2020 ) { gs_dwYear=2000 ; } else { gs_dwYear++ ; } _ScrSettings_Date_SetYear() ; WGT_Draw( &g_wgt_Year, g_WGT_CoreData.pBE ) ; } /* * Handle DOWN/Year button */ if ( pMsg->dwParam1 == (uint32_t)&g_btnDownYear ) { if ( gs_dwYear == 2000 ) { gs_dwYear=2020 ; } else { gs_dwYear-- ; } _ScrSettings_Date_SetYear() ; WGT_Draw( &g_wgt_Year, g_WGT_CoreData.pBE ) ; } break ; case WGT_MSG_TIMER : break ; } return SAMGUI_E_OK ; }
extern uint32_t WGT_Screen_SetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) { uint32_t dw ; SGUIColor clrSelection={ .u.dwRGBA=GUICLR_ATMEL_BLUE } ; if ( pScreen == NULL ) { return SAMGUI_E_BAD_PARAMETER ; } for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) { if ( pScreen->apWidgets[dw] == pWidget ) { pScreen->pWidgetCurrent=pWidget ; if ( pScreen->pWidgetOld != pScreen->pWidgetCurrent ) { printf( "Widget changed\r\n" ) ; // Selected widget changed, repaint previous one if ( pScreen->pWidgetOld != NULL ) { WGT_Draw( pScreen->pWidgetOld, g_WGT_CoreData.pBE ) ; } g_WGT_CoreData.pBE->DrawRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth-1, pWidget->dwY+pWidget->dwHeight-1, &clrSelection ) ; pScreen->pWidgetOld=pScreen->pWidgetCurrent ; } return SAMGUI_E_OK ; } } return SAMGUI_E_INVALID_WIDGET ; } //extern uint32_t WGT_Screen_SelectNextWidget( SWGTScreen* pScreen ) //{ // uint32_t dw ; // uint32_t dwIndex=WGT_MAX_WIDGETS ; // uint32_t dwIndexNext=WGT_MAX_WIDGETS ; // // SGUIColor clrSelection={ .u.dwRGBA=GUICLR_ATMEL_BLUE } ; // // if ( pScreen == NULL ) // { // return SAMGUI_E_BAD_PARAMETER ; // } // // for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) // { // if ( pScreen->apWidgets[dw] == pScreen->pWidgetCurrent ) // { // // Got selected // dwIndex=dw ; // break ; // } // } // // // Did we find the current selected button? // if ( dwIndex != WGT_MAX_WIDGETS ) // { // // Find next button // for ( dw=dwIndex ; dw < pScreen->dwWidgets ; dw++ ) // { // if ( pScreen->apWidgets[dw]->dwType == WGT_TYPE_BUTTON ) // { // // Got selected // dwIndexNext=dw ; // break ; // } // } // // } // // return SAMGUI_E_OK ; //} // //extern uint32_t WGT_Screen_SelectPreviousWidget( SWGTScreen* pScreen ) //{ // return SAMGUI_E_OK ; //} extern uint32_t WGT_Screen_OnPaint( SWGTScreen* pScreen ) { uint32_t dw ; for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ ) { if ( pScreen->apWidgets[dw] ) { WGT_Draw( pScreen->apWidgets[dw], g_WGT_CoreData.pBE ) ; } } return SAMGUI_E_OK ; }