/************************************************************************ Function: WORD JPEGMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) Overview: This function is called by GOLMsg() function when in this particular demo each time the valid message is received for the objects in the demo. Input: objMsg - translated message for the object, pObj - pointer to the object, pMsg - pointer to the non-translated, raw GOL message Output: If the function returns non-zero the message will be processed by the object directly affected by the message. Default action on the object based on the message will be performed. ************************************************************************/ WORD JPEGMsgCallback(WORD objMsg, OBJ_HEADER *pObj, GOL_MSG *pMsg) { LISTITEM *pItemSel; // check if an image is being shown if((blImageOnScreen == 1) || (blSlideShowOn == 1)) { // this is the routine to go back and show the list when an // image is being shown on the screen or the slide show is // currently ongoing if(pMsg->uiEvent == EVENT_RELEASE) { blImageOnScreen = 0; blSlideShowOn = 0; GOLRedrawRec(0, 0, GetMaxX(), GetMaxY()); } return (0); } switch(GetObjID(pObj)) { case ID_BUTTON_A: if(objMsg == BTN_MSG_RELEASED) { // check if button is pressed // do not process if user moved the touch away from the button // returning 1 wil update the button if(pMsg->uiEvent == EVENT_MOVE) return (1); screenState = CREATE_DEMOSELECTION; } return (1); case ID_BUTTON_D: if(objMsg == BTN_MSG_RELEASED) { // check if button is pressed // do not process if user moved the touch away from the button // returning 1 wil update the button if(pMsg->uiEvent == EVENT_MOVE) return (1); // enable the slide show blSlideShowOn = 1; // initialize the screen SetColor(BLACK); ClearDevice(); ClrState(pObj, BTN_PRESSED); // clear the pressed state, will be shown only when redrawn blSlideShowDelay = 0; // force slide show to immediately start return (0); } return (1); case ID_JPGLISTBOX: if(pMsg->uiEvent == EVENT_MOVE) { pMsg->uiEvent = EVENT_PRESS; // change event for listbox // Process message by default LbMsgDefault(objMsg, (LISTBOX *)pObj, pMsg); // Set new list box position SldSetPos(pSlider, LbGetCount(pListBox) - LbGetFocusedItem(pListBox) - 1); SetState(pSlider, SLD_DRAW_THUMB); pMsg->uiEvent = EVENT_MOVE; // restore event for listbox } else if(pMsg->uiEvent == EVENT_PRESS) { // call the message default processing of the list box to select the item LbMsgDefault(objMsg, (LISTBOX *)pObj, pMsg); } else if(pMsg->uiEvent == EVENT_RELEASE) { // check which item was selected and display appropriate screen pItemSel = LbGetSel(pListBox, NULL); // get the selected item if(aFolderElement[pItemSel->data].blFolder == 1) { if(FSchdir(aFolderElement[pItemSel->data].Name) == 0) { FillNewElements(); return (1); } } else if(aFolderElement[pItemSel->data].blText == 0) { IMG_FILE *pImgFile = IMG_FOPEN(aFolderElement[pItemSel->data].Name, "rb"); if(pImgFile != NULL) { blImageOnScreen = 1; // initialize the screen SetColor(BLACK); ClearDevice(); if ( ImageDecode ( pImgFile, aFolderElement[pItemSel->data].ImgType, 0, 0, IMG_SCREEN_WIDTH, IMG_SCREEN_HEIGHT, (IMG_DOWN_SCALE | IMG_ALIGN_CENTER), NULL, NULL ) ) { DisplayErrorInfo(); } IMG_FCLOSE(pImgFile); } } } // The message was processed. To avoid other objects processing the // processed message reset the message. pMsg->uiEvent = EVENT_INVALID; return (0); case ID_SLD4LB: if((objMsg == SLD_MSG_INC) || (objMsg == SLD_MSG_DEC)) { // check slider was touched. // Process message by default SldMsgDefault(objMsg, (SLIDER *)pObj, pMsg); // Set new list box position if(LbGetFocusedItem(pListBox) != LbGetCount(pListBox) - SldGetPos(pSlider)) { LbSetFocusedItem(pListBox, LbGetCount(pListBox) - SldGetPos(pSlider)); SetState(pListBox, LB_DRAW_ITEMS); } } // The message was processed return (0); case ID_BTNUP4LB: // slider up button was pressed if(objMsg == BTN_MSG_RELEASED) { // check if we have reached the very first then stay there. if (LbGetFocusedItem(pListBox) == 0) LbSetFocusedItem(pListBox,0); else LbSetFocusedItem(pListBox,LbGetFocusedItem(pListBox)-1); SetState(pListBox, LB_DRAW_ITEMS); SldSetPos(pSlider, SldGetPos(pSlider) + 1); SetState(pSlider, SLD_DRAW_THUMB); } return (1); case ID_BTNDN4LB: // slider down button was pressed if(objMsg == BTN_MSG_RELEASED) { // set all items to be not displayed pItemSel = pListBox->pItemList; while(pItemSel != NULL) { pItemSel->status = 0; pItemSel = pItemSel->pNextItem; } LbSetFocusedItem(pListBox, LbGetFocusedItem(pListBox) + 1); SetState(pListBox, LB_DRAW_ITEMS); SldSetPos(pSlider, SldGetPos(pSlider) - 1); SetState(pSlider, SLD_DRAW_THUMB); } return (1); } return (1); }
/********************************************************************* * Function: void GOLMsg(GOL_MSG *pMsg) * * PreCondition: none * * Input: pointer to the message * * Output: none * * Side Effects: none * * Overview: processes message for all objects in the liked list * * Note: none * ********************************************************************/ void GOLMsg(GOL_MSG *pMsg){ OBJ_HEADER *pCurrentObj; WORD translatedMsg; if(pMsg->uiEvent == EVENT_INVALID) return; pCurrentObj = _pGolObjects; while(pCurrentObj != NULL){ switch(pCurrentObj->type){ #ifdef USE_BUTTON case OBJ_BUTTON: translatedMsg = BtnTranslateMsg((BUTTON*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) BtnMsgDefault(translatedMsg,(BUTTON*)pCurrentObj, pMsg); break; #endif #ifdef USE_WINDOW case OBJ_WINDOW: translatedMsg = WndTranslateMsg((WINDOW*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; GOLMsgCallback(translatedMsg,pCurrentObj,pMsg); break; #endif #ifdef USE_CHECKBOX case OBJ_CHECKBOX: translatedMsg = CbTranslateMsg((CHECKBOX*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) CbMsgDefault(translatedMsg,(CHECKBOX*)pCurrentObj, pMsg); break; #endif #ifdef USE_RADIOBUTTON case OBJ_RADIOBUTTON: translatedMsg = RbTranslateMsg((RADIOBUTTON*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) RbMsgDefault(translatedMsg,(RADIOBUTTON*)pCurrentObj, pMsg); break; #endif #ifdef USE_EDITBOX case OBJ_EDITBOX: translatedMsg = EbTranslateMsg((EDITBOX*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) EbMsgDefault(translatedMsg,(EDITBOX*)pCurrentObj, pMsg); break; #endif #ifdef USE_LISTBOX case OBJ_LISTBOX: translatedMsg = LbTranslateMsg((LISTBOX*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) LbMsgDefault(translatedMsg,(LISTBOX*)pCurrentObj, pMsg); break; #endif #ifdef USE_SLIDER case OBJ_SLIDER: translatedMsg = SldTranslateMsg((SLIDER*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) SldMsgDefault(translatedMsg,(SLIDER*)pCurrentObj, pMsg); break; #endif #ifdef USE_GROUPBOX case OBJ_GROUPBOX: translatedMsg = GbTranslateMsg((GROUPBOX*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; GOLMsgCallback(translatedMsg,pCurrentObj,pMsg); break; #endif #ifdef USE_PROGRESSBAR case OBJ_PROGRESSBAR: break; #endif #ifdef USE_STATICTEXT case OBJ_STATICTEXT: translatedMsg = StTranslateMsg((STATICTEXT*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; GOLMsgCallback(translatedMsg,pCurrentObj,pMsg); break; #endif #ifdef USE_PICTURE case OBJ_PICTURE: translatedMsg = PictTranslateMsg((PICTURE*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; GOLMsgCallback(translatedMsg,pCurrentObj,pMsg); break; #endif #ifdef USE_ROUNDDIAL case OBJ_ROUNDDIAL: translatedMsg = RdiaTranslateMsg((ROUNDDIAL*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) RdiaMsgDefault(translatedMsg,(ROUNDDIAL*)pCurrentObj, pMsg); break; #endif #ifdef USE_METER case OBJ_METER: translatedMsg = MtrTranslateMsg((METER*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) MtrMsgDefault(translatedMsg,(METER*)pCurrentObj, pMsg); break; #endif #ifdef USE_CUSTOM case OBJ_CUSTOM: translatedMsg = CcTranslateMsg((CUSTOM*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) CcMsgDefault((CUSTOM*)pCurrentObj,pMsg); break; #endif #ifdef USE_GRID case OBJ_GRID: translatedMsg = GridTranslateMsg((GRID*)pCurrentObj, pMsg); if(translatedMsg == OBJ_MSG_INVALID) break; if(GOLMsgCallback(translatedMsg,pCurrentObj,pMsg)) GridMsgDefault( translatedMsg, (GRID*)pCurrentObj, pMsg ); break; #endif default: break; } pCurrentObj = pCurrentObj->pNxtObj; } }