/** * @brief Callback function of the Settings frame * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbSettingsDialog(WM_MESSAGE * pMsg) { int Id, NCode; WM_HWIN hItem; switch (pMsg->MsgId) { case WM_INIT_DIALOG: /* Settings frame initialization */ hItem = pMsg->hWin; FRAMEWIN_AddCloseButton(hItem, FRAMEWIN_BUTTON_RIGHT, 0); /* Create and attache the MULTIPAGE dialog windows */ hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIPAGE); hDialogCameraSettings = GUI_CreateDialogBox(_aDialogCameraSettings, GUI_COUNTOF(_aDialogCameraSettings), &_cbCameraSettings, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialogCameraSettings, "Camera Settings"); hDialogFileControl = GUI_CreateDialogBox(_aDialogFileControl, GUI_COUNTOF(_aDialogFileControl), &_cbFileControl, WM_UNATTACHED, 0, 0); MULTIPAGE_AddPage(hItem, hDialogFileControl, "File Settings"); MULTIPAGE_SelectPage(hItem, 0); /* 'OK' button initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK); BUTTON_SetFont(hItem, GUI_FONT_13B_1); /* 'Cancel' button initialization */ hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_CANCEL); BUTTON_SetFont(hItem, GUI_FONT_13B_1); break; case WM_DELETE: camera_disabled = 0; hSettings = 0; if(SD_Configured == 1) { BSP_CAMERA_Init(RESOLUTION_R160x120); CAMERA_Configured = 1; /* Apply new settings*/ SD_Configured = 0; } /* Delete choosfile window */ WM_DeleteWindow(chooser_select_folder); break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case ID_BUTTON_OK: /* Notification sent by "OK" button */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* Save camera settings before delete settings frame */ hItem = WM_GetDialogItem(hDialogCameraSettings, ID_SLIDER_0); CameraSettings.b.brightness = SLIDER_GetValue(hItem); hItem = WM_GetDialogItem(hDialogCameraSettings, ID_SLIDER_1); CameraSettings.b.contrast = SLIDER_GetValue(hItem); /* Back to normal mode (no effects) */ hItem = WM_GetDialogItem(CAMERA_hWin, ID_RADIO); RADIO_SetValue(hItem, 0); if(CAMERA_GetState() != CAMERA_ERROR) { /* Apply new settings*/ CAMERA_Set_ContrastBrightness(CameraSettings.b.contrast, CameraSettings.b.brightness); BSP_CAMERA_BlackWhiteConfig(CAMERA_BLACK_WHITE_NORMAL); } GUI_EndDialog(pMsg->hWin, 0); break; } break; case ID_BUTTON_CANCEL: /* Notification sent by "Cancel" button */ switch (NCode) { case WM_NOTIFICATION_RELEASED: GUI_EndDialog(pMsg->hWin, 0); break; } break; } break; } }
/********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hScrollbar, hDlgOptions; GUI_RECT RectDlg, RectClient; int Cnt = 0, IndexEffect = 0, ButtonState = 0, DropdownState = 0; int ProgbarValue = 0, ProgbarInc = 1; int SliderValue = 0, SliderInc = 1; int ScrollbarValue = 0, ScrollbarInc = 1; int ListViewInc = 1; int ListBoxInc = 1; int MultiEditInc = 1; int Vz = 1; const WIDGET_EFFECT * _apEffect[] = {&WIDGET_Effect_3D, /* Array of effects */ &WIDGET_Effect_Simple, &WIDGET_Effect_None}; const char * _apEffects[] = {"Widget effect: 3D", "Widget effect: Simple", "Widget effect: None"}; GUI_Init(); GUI_CURSOR_Show(); WM_SetCallback(WM_HBKWIN, _cbBkWindow); WM_SetCreateFlags(WM_CF_MEMDEV); /* Use memory devices on all windows to avoid flicker */ WM_EnableMemdev(WM_HBKWIN); /* Enable use of memory devices for desktop windows */ /* Create framewindow and set its properties */ _hFrameWin = FRAMEWIN_CreateEx(0, 0, 640, 480, 0, WM_CF_SHOW, 0, 0, "", &_cbCallbackFramewin); FRAMEWIN_SetMoveable(_hFrameWin, 1); FRAMEWIN_SetText(_hFrameWin, _apEffects[0]); FRAMEWIN_SetFont(_hFrameWin, &GUI_Font13B_ASCII); /* Create main dialog window as child from framewindows client window */ _hDlg = GUI_CreateDialogBox(_aDlgWidgets, GUI_COUNTOF(_aDlgWidgets), &_cbCallbackWidgets, WM_GetClientWindow(_hFrameWin), 0, 0); /* Attach scrollbar to framewindows client window and set its properties */ hScrollbar = SCROLLBAR_CreateAttached(WM_GetClientWindow(_hFrameWin), 0); WM_GetWindowRectEx(_hDlg, &RectDlg); WM_GetClientRectEx(WM_GetClientWindow(_hFrameWin), &RectClient); SCROLLBAR_SetNumItems(hScrollbar, RectDlg.x1); SCROLLBAR_SetPageSize(hScrollbar, RectClient.x1); /* Create options dialog with 'stay on top' and 'moveable' attribute */ hDlgOptions = GUI_CreateDialogBox(_aDlgOptions, GUI_COUNTOF(_aDlgOptions), &_cbCallbackOptions, WM_HBKWIN, 0, 0); FRAMEWIN_SetMoveable(hDlgOptions, 1); WM_SetStayOnTop(hDlgOptions, 1); /* Main loop for modifying the widgets */ while (1) { if (_AutoMode) { Cnt++; /* Modify progbar */ if ((Cnt % 2) == 0) { ProgbarValue += ProgbarInc; if ((ProgbarValue == 110) || (ProgbarValue == -10)) { ProgbarInc *= -1; } PROGBAR_SetValue(_ahWin[PROGBAR0], ProgbarValue); } /* Modify slider */ if ((Cnt % 2) == 0) { int j; SliderValue += SliderInc; if ((SliderValue == 100) || (SliderValue == 0)) { SliderInc *= -1; } for (j = 0; j < 3; j++) { SLIDER_SetValue(_ahWin[SLIDER0 + j], SliderValue); } } /* Modify scrollbar */ if ((Cnt % 3) == 0) { int j; ScrollbarValue += ScrollbarInc; if ((ScrollbarValue == 90) || (ScrollbarValue == 0)) { ScrollbarInc *= -1; } for (j = 0; j < 3; j++) { SCROLLBAR_SetValue(_ahWin[SCROLLBAR0 + j], ScrollbarValue); } } /* Modify multipage */ if ((Cnt % 120) == 0) { MULTIPAGE_SelectPage(_ahWin[MULTIPAGE0], MULTIPAGE_GetSelection(_ahWin[MULTIPAGE0]) ^ 1); } /* Modify dropdown */ if ((Cnt % 120) == 0) { DropdownState ^= 1; if (DropdownState) { DROPDOWN_Expand(_ahWin[DROPDOWN0]); } else { DROPDOWN_Collapse(_ahWin[DROPDOWN0]); } } /* Modify button */ if ((Cnt % 40) == 0) { ButtonState ^= 1; BUTTON_SetPressed(_ahWin[BUTTON0], ButtonState); } /* Modify listbox */ if ((Cnt % 30) == 0) { int Sel; Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if (Sel < 0) { Sel = 0; } LISTBOX_SetSel(_ahWin[LISTBOX0], Sel + ListBoxInc); Sel = LISTBOX_GetSel(_ahWin[LISTBOX0]); if ((Sel == (int)LISTBOX_GetNumItems(_ahWin[LISTBOX0]) - 1) || (Sel == 0)) { ListBoxInc *= -1; } } /* Modify listview */ if ((Cnt % 50) == 0) { int Sel; Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if (Sel < 0) { Sel = 0; } LISTVIEW_SetSel(_ahWin[LISTVIEW0], Sel + ListViewInc); Sel = LISTVIEW_GetSel(_ahWin[LISTVIEW0]); if ((Sel == (int)LISTVIEW_GetNumRows(_ahWin[LISTVIEW0]) - 1) || (Sel == 0)) { ListViewInc *= -1; } } /* Modify multiedit */ if ((Cnt % 5) == 0) { int Sel, Len; char acBuffer[100]; MULTIEDIT_SetCursorOffset(_ahWin[MULTIEDIT0], MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]) + MultiEditInc); MULTIEDIT_GetText(_ahWin[MULTIEDIT0], acBuffer, sizeof(acBuffer)); Sel = MULTIEDIT_GetCursorCharPos(_ahWin[MULTIEDIT0]); Len = strlen(acBuffer); if ((Sel == (Len - 1)) || (Sel == 0)) { MultiEditInc *= -1; } if (!DropdownState) { WM_SetFocus(_ahWin[MULTIEDIT0]); } } /* Modify graph */ _AddValues(_ahWin[GRAPH0], 95); /* Move window */ if ((Cnt % 1200) == 0) { int Inc; WM_HWIN hScroll; WM_SCROLL_STATE ScrollState; hScroll = WM_GetScrollbarH(WM_GetClientWindow(_hFrameWin)); WM_GetScrollState(hScroll, &ScrollState); Inc = (ScrollState.NumItems - ScrollState.PageSize) / 2; ScrollState.v += Inc * Vz; if ((ScrollState.v >= Inc * 2) || (ScrollState.v <= 0)) { Vz *= -1; } SCROLLBAR_SetValue(hScroll, ScrollState.v); } /* Change effect */ if ((Cnt % 400) == 0) { int Index; WM_HWIN hWin; IndexEffect++; Index = IndexEffect % GUI_COUNTOF(_apEffect); _SetEffect(Index); hWin = WM_GetDialogItem(hDlgOptions, GUI_ID_RADIO0); RADIO_SetValue(hWin, Index); } } /* Wait a while */ GUI_Delay(10); } }