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.

    • What's the difference between frame,window and dialog

      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.
    • 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,
      Sven
      Please 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.
      From my own experience:

      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

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Types
      11. *
      12. **********************************************************************
      13. */
      14. /*********************************************************************
      15. *
      16. * Defines
      17. *
      18. **********************************************************************
      19. */
      20. //
      21. // View 1
      22. //
      23. #define ID_WINDOW_00 (GUI_ID_USER + 0x00)
      24. #define ID_BUTTON_00 (GUI_ID_USER + 0x01)
      25. #define ID_TEXT_00 (GUI_ID_USER + 0x02)
      26. //
      27. // View 2
      28. //
      29. #define ID_WINDOW_10 (GUI_ID_USER + 0x10)
      30. #define ID_BUTTON_10 (GUI_ID_USER + 0x11)
      31. #define ID_TEXT_10 (GUI_ID_USER + 0x12)
      32. //
      33. // Fixed status bar
      34. //
      35. #define ID_WINDOW_20 (GUI_ID_USER + 0x20)
      36. #define ID_TEXT_20 (GUI_ID_USER + 0x21)
      37. #define ID_PROGBAR_20 (GUI_ID_USER + 0x22)
      38. #define ID_TEXT_21 (GUI_ID_USER + 0x23)
      39. /*********************************************************************
      40. *
      41. * Static data
      42. *
      43. **********************************************************************
      44. */
      45. /*********************************************************************
      46. *
      47. * _aView1Create
      48. */
      49. static const GUI_WIDGET_CREATE_INFO _aView1Create[] = {
      50. { WINDOW_CreateIndirect, "View1", ID_WINDOW_00, 0, 0, 480, 222, 0, 0x0, 0 },
      51. { BUTTON_CreateIndirect, ">", ID_BUTTON_00, 400, 81, 60, 60, 0, 0x0, 0 },
      52. { TEXT_CreateIndirect, "View 1", ID_TEXT_00, 20, 20, 80, 20, 0, 0x0, 0 },
      53. };
      54. /*********************************************************************
      55. *
      56. * _aView2Create
      57. */
      58. static const GUI_WIDGET_CREATE_INFO _aView2Create[] = {
      59. { WINDOW_CreateIndirect, "View2", ID_WINDOW_10, 0, 0, 480, 222, 0, 0x0, 0 },
      60. { BUTTON_CreateIndirect, "<", ID_BUTTON_10, 20, 81, 60, 60, 0, 0x0, 0 },
      61. { TEXT_CreateIndirect, "View 2", ID_TEXT_10, 20, 20, 80, 20, 0, 0x0, 0 },
      62. };
      63. /*********************************************************************
      64. *
      65. * _aStatusBarCreate
      66. */
      67. static const GUI_WIDGET_CREATE_INFO _aStatusBarCreate[] = {
      68. { WINDOW_CreateIndirect, "Window", ID_WINDOW_20, 0, 0, 480, 50, 0, 0x0, 0 },
      69. { TEXT_CreateIndirect, "12:53", ID_TEXT_20, 400, 15, 80, 20, 0, 0x0, 0 },
      70. { PROGBAR_CreateIndirect, "Progbar", ID_PROGBAR_20, 320, 15, 80, 20, 0, 0x0, 0 },
      71. { TEXT_CreateIndirect, "Fixed status bar", ID_TEXT_21, 10, 15, 120, 20, 0, 0x0, 0 },
      72. };
      73. /*********************************************************************
      74. *
      75. * Forward declaration
      76. *
      77. **********************************************************************
      78. */
      79. static void _cbView1(WM_MESSAGE * pMsg);
      80. static void _cbView2(WM_MESSAGE * pMsg);
      81. /*********************************************************************
      82. *
      83. * Static code
      84. *
      85. **********************************************************************
      86. */
      87. /*********************************************************************
      88. *
      89. * _cbStatusbar
      90. */
      91. static void _cbStatusbar(WM_MESSAGE * pMsg) {
      92. WM_HWIN hItem;
      93. switch (pMsg->MsgId) {
      94. case WM_INIT_DIALOG:
      95. //
      96. // Initialization of 'Window'
      97. //
      98. hItem = pMsg->hWin;
      99. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00464655));
      100. //
      101. // Initialization of '12:53'
      102. //
      103. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_20);
      104. TEXT_SetFont(hItem, GUI_FONT_16B_1);
      105. TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
      106. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
      107. //
      108. // Initialization of 'Static status bar'
      109. //
      110. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_21);
      111. TEXT_SetFont(hItem, GUI_FONT_16B_1);
      112. TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
      113. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
      114. //
      115. // Initialization of 'Progbar'
      116. //
      117. hItem = WM_GetDialogItem(pMsg->hWin, ID_PROGBAR_20);
      118. PROGBAR_SetValue(hItem, 93);
      119. break;
      120. default:
      121. WM_DefaultProc(pMsg);
      122. break;
      123. }
      124. }
      125. /*********************************************************************
      126. *
      127. * _cbView2
      128. */
      129. static void _cbView2(WM_MESSAGE * pMsg) {
      130. WM_HWIN hItem;
      131. int NCode;
      132. int Id;
      133. switch (pMsg->MsgId) {
      134. case WM_INIT_DIALOG:
      135. //
      136. // Initialization of 'Window'
      137. //
      138. hItem = pMsg->hWin;
      139. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00282B31));
      140. //
      141. // Initialization of 'View 2'
      142. //
      143. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_10);
      144. TEXT_SetFont(hItem, GUI_FONT_20B_1);
      145. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
      146. break;
      147. case WM_NOTIFY_PARENT:
      148. Id = WM_GetId(pMsg->hWinSrc);
      149. NCode = pMsg->Data.v;
      150. switch(Id) {
      151. case ID_BUTTON_10: // Notifications sent by '<'
      152. switch(NCode) {
      153. case WM_NOTIFICATION_RELEASED:
      154. //
      155. // On button press create view 1
      156. //
      157. GUI_CreateDialogBox(_aView1Create, GUI_COUNTOF(_aView1Create), _cbView1, WM_HBKWIN, 0, 50);
      158. //
      159. // Delete current view, this window
      160. //
      161. WM_DeleteWindow(pMsg->hWin);
      162. break;
      163. }
      164. break;
      165. }
      166. break;
      167. default:
      168. WM_DefaultProc(pMsg);
      169. break;
      170. }
      171. }
      172. /*********************************************************************
      173. *
      174. * _cbView1
      175. */
      176. static void _cbView1(WM_MESSAGE * pMsg) {
      177. WM_HWIN hItem;
      178. int NCode;
      179. int Id;
      180. switch (pMsg->MsgId) {
      181. case WM_INIT_DIALOG:
      182. //
      183. // Initialization of 'Window'
      184. //
      185. hItem = pMsg->hWin;
      186. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00282B31));
      187. //
      188. // Initialization of 'View 1'
      189. //
      190. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_00);
      191. TEXT_SetFont(hItem, GUI_FONT_20B_1);
      192. TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00FFFFFF));
      193. break;
      194. case WM_NOTIFY_PARENT:
      195. Id = WM_GetId(pMsg->hWinSrc);
      196. NCode = pMsg->Data.v;
      197. switch(Id) {
      198. case ID_BUTTON_00: // Notifications sent by '>'
      199. switch(NCode) {
      200. case WM_NOTIFICATION_RELEASED:
      201. //
      202. // On button press create view 2
      203. //
      204. GUI_CreateDialogBox(_aView2Create, GUI_COUNTOF(_aView2Create), _cbView2, WM_HBKWIN, 0, 50);
      205. //
      206. // Delete current view, this window
      207. //
      208. WM_DeleteWindow(pMsg->hWin);
      209. break;
      210. }
      211. break;
      212. }
      213. break;
      214. default:
      215. WM_DefaultProc(pMsg);
      216. break;
      217. }
      218. }
      219. /*********************************************************************
      220. *
      221. * _cbBk
      222. */
      223. static void _cbBk(WM_MESSAGE * pMsg) {
      224. switch (pMsg->MsgId) {
      225. case WM_PAINT:
      226. GUI_SetBkColor(GUI_BLACK);
      227. GUI_Clear();
      228. break;
      229. default:
      230. WM_DefaultProc(pMsg);
      231. break;
      232. }
      233. }
      234. /*********************************************************************
      235. *
      236. * Public code
      237. *
      238. **********************************************************************
      239. */
      240. /*********************************************************************
      241. *
      242. * MainTask
      243. */
      244. void MainTask(void) {
      245. GUI_Init();
      246. WM_MULTIBUF_Enable(1);
      247. WM_SetCallback(WM_HBKWIN, _cbBk);
      248. //
      249. // Create a fixed status bar, never changes
      250. //
      251. GUI_CreateDialogBox(_aStatusBarCreate, GUI_COUNTOF(_aStatusBarCreate), _cbStatusbar, WM_HBKWIN, 0, 0);
      252. //
      253. // Initially create view 1
      254. //
      255. GUI_CreateDialogBox(_aView1Create, GUI_COUNTOF(_aView1Create), _cbView1, WM_HBKWIN, 0, 50);
      256. while (1) {
      257. GUI_Delay(100);
      258. }
      259. }
      260. /*************************** End of file ****************************/
      Display All
      Regards,
      Sven
      Please 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.