When I design UI with emwin, I find that I can implement my interface with either frame, window or dialog, so my question is what's the difference between these three types? What is the application scenario for each type? Thank you.
What's the difference between frame,window and dialog
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
Hi,
Basically all of them (FRAMEWIN, WINDOW, and Dialog) are windows. The FRAMEWIN and WINDOW are widgets (some special kind of windows). Widgets are predefiend to some point and can make life easier (although the WINDOW widget is not that special).
A dialog is a bunch of widgets combined into "one" element. A dialog has always one main element (a FRAMEWIN or a WINDOW widget) and several child widgets like buttons, text, etc.
A dialog is pretty handy when you have a lot of different views in your application.
It is up to you or your requirements which widget you choose. A FRAMEWIN is like a window on a Desktop PC with frame and title, but to be honest it is pretty outdated on smaller devices (imagine your mobile devivce with lots of windows open..).
You could also work only with "pure" Window Manager windows (the FRAMEWIN and WINDOW widget are just derived from WM-windows) and manage everything on your own.
Regards,
SvenPlease read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail. -
Ross Lee wrote:
When I design UI with emwin, I find that I can implement my interface with either frame, window or dialog, so my question is what's the difference between these three types? What is the application scenario for each type? Thank you.
WINDOW - simple rectangle window for placing widgets or graphics on it. It has background, but does not have a border or title.
FRAMEWIN - object, that has a frame (border and on top a horizontal place for title-string, for Close-, Max-, Min- buttons, ...) and the FRAMEWIN also contains internal Client-window, which is above mentioned WINDOW. But FRAMEWIN has own API, also for manipulate its Client-window (i.e. background-coloring etc). If you create FRAMEWIN and would like to add some widgets to it, you can use for it its Client-window (function WM_GetClientWindow) if you need traversing between widgets by key "TAB". If you add the widgets directly to FRAMEWIN, they will be not traversible. If you create FRAMEWIN, you can move it by mouse, dragging it by its title-zone.
DIALOG - special API (GUI_CreateDialogBox), for simplifying the creating process through array of widgets. The tool GUIBuilder.exe simplifies this process, it makes c-file for further editing.Best regards,
Volodymyr. -
If I want to implement a mobile like interface, which has several views. Each view has a bunch of fixed widgets(like status bar) and changable widgets. According to your explaination, my idea is to design 2 windows in 1 dialog, one window is for the fixed part and the other window is for the changable part. Is it a feasible solution or is there a common solution for this scenario?
-
Hi,
If you want a fixed status bar just create 3 windows/dialogs. The status bar is at the top and never changes. The other two dialogs will change and are lower about the height of the status bar.
Here is a quick example with two views (you can change the view by pressing the buttons) and a status bar:
C Source Code
- #include "DIALOG.h"
- /*********************************************************************
- *
- * Externals
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * Types
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- //
- // View 1
- //
- #define ID_WINDOW_00 (GUI_ID_USER + 0x00)
- #define ID_BUTTON_00 (GUI_ID_USER + 0x01)
- #define ID_TEXT_00 (GUI_ID_USER + 0x02)
- //
- // View 2
- //
- #define ID_WINDOW_10 (GUI_ID_USER + 0x10)
- #define ID_BUTTON_10 (GUI_ID_USER + 0x11)
- #define ID_TEXT_10 (GUI_ID_USER + 0x12)
- //
- // Fixed status bar
- //
- #define ID_WINDOW_20 (GUI_ID_USER + 0x20)
- #define ID_TEXT_20 (GUI_ID_USER + 0x21)
- #define ID_PROGBAR_20 (GUI_ID_USER + 0x22)
- #define ID_TEXT_21 (GUI_ID_USER + 0x23)
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _aView1Create
- */
- static const GUI_WIDGET_CREATE_INFO _aView1Create[] = {
- { WINDOW_CreateIndirect, "View1", ID_WINDOW_00, 0, 0, 480, 222, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, ">", ID_BUTTON_00, 400, 81, 60, 60, 0, 0x0, 0 },
- { TEXT_CreateIndirect, "View 1", ID_TEXT_00, 20, 20, 80, 20, 0, 0x0, 0 },
- };
- /*********************************************************************
- *
- * _aView2Create
- */
- static const GUI_WIDGET_CREATE_INFO _aView2Create[] = {
- { WINDOW_CreateIndirect, "View2", ID_WINDOW_10, 0, 0, 480, 222, 0, 0x0, 0 },
- { BUTTON_CreateIndirect, "<", ID_BUTTON_10, 20, 81, 60, 60, 0, 0x0, 0 },
- { TEXT_CreateIndirect, "View 2", ID_TEXT_10, 20, 20, 80, 20, 0, 0x0, 0 },
- };
- /*********************************************************************
- *
- * _aStatusBarCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aStatusBarCreate[] = {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_20, 0, 0, 480, 50, 0, 0x0, 0 },
- { TEXT_CreateIndirect, "12:53", ID_TEXT_20, 400, 15, 80, 20, 0, 0x0, 0 },
- { PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_20, 320, 15, 80, 20, 0, 0x0, 0 },
- { TEXT_CreateIndirect, "Fixed status bar", ID_TEXT_21, 10, 15, 120, 20, 0, 0x0, 0 },
- };
- /*********************************************************************
- *
- * Forward declaration
- *
- **********************************************************************
- */
- static void _cbView1(WM_MESSAGE * pMsg);
- static void _cbView2(WM_MESSAGE * pMsg);
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _cbStatusbar
- */
- static void _cbStatusbar(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Window'
- //
- hItem = pMsg->hWin;
- WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00464655));
- //
- // Initialization of '12:53'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_20);
- TEXT_SetFont(hItem, GUI_FONT_16B_1);
- TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
- TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
- //
- // Initialization of 'Static status bar'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_21);
- TEXT_SetFont(hItem, GUI_FONT_16B_1);
- TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
- TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
- //
- // Initialization of 'Progbar'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_20);
- PROGBAR_SetValue(hItem, 93);
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * _cbView2
- */
- static void _cbView2(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- int NCode;
- int Id;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Window'
- //
- hItem = pMsg->hWin;
- WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00282B31));
- //
- // Initialization of 'View 2'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_10);
- TEXT_SetFont(hItem, GUI_FONT_20B_1);
- TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id) {
- case ID_BUTTON_10: // Notifications sent by '<'
- switch(NCode) {
- case WM_NOTIFICATION_RELEASED:
- //
- // On button press create view 1
- //
- GUI_CreateDialogBox(_aView1Create, GUI_COUNTOF(_aView1Create), _cbView1, WM_HBKWIN, 0, 50);
- //
- // Delete current view, this window
- //
- WM_DeleteWindow(pMsg->hWin);
- break;
- }
- break;
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * _cbView1
- */
- static void _cbView1(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- int NCode;
- int Id;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Window'
- //
- hItem = pMsg->hWin;
- WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00282B31));
- //
- // Initialization of 'View 1'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_00);
- TEXT_SetFont(hItem, GUI_FONT_20B_1);
- TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
- break;
- case WM_NOTIFY_PARENT:
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch(Id) {
- case ID_BUTTON_00: // Notifications sent by '>'
- switch(NCode) {
- case WM_NOTIFICATION_RELEASED:
- //
- // On button press create view 2
- //
- GUI_CreateDialogBox(_aView2Create, GUI_COUNTOF(_aView2Create), _cbView2, WM_HBKWIN, 0, 50);
- //
- // Delete current view, this window
- //
- WM_DeleteWindow(pMsg->hWin);
- break;
- }
- break;
- }
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * _cbBk
- */
- static void _cbBk(WM_MESSAGE * pMsg) {
- switch (pMsg->MsgId) {
- case WM_PAINT:
- GUI_SetBkColor(GUI_BLACK);
- GUI_Clear();
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void) {
- GUI_Init();
- WM_MULTIBUF_Enable(1);
- WM_SetCallback(WM_HBKWIN, _cbBk);
- //
- // Create a fixed status bar, never changes
- //
- GUI_CreateDialogBox(_aStatusBarCreate, GUI_COUNTOF(_aStatusBarCreate), _cbStatusbar, WM_HBKWIN, 0, 0);
- //
- // Initially create view 1
- //
- GUI_CreateDialogBox(_aView1Create, GUI_COUNTOF(_aView1Create), _cbView1, WM_HBKWIN, 0, 50);
- while (1) {
- GUI_Delay(100);
- }
- }
- /*************************** End of file ****************************/
SvenPlease read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail. -
That's great. Thanks!
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0
-
Tags