Widget Icon view behavior

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Widget Icon view behavior

      Hello,

      When i create the Widget Icon view using resource table i don't see the text displayed under the icons. But when i use createEx function to create the widget icon view then the text under the icons is visible.

      //resource table
      { ICONVIEW_CreateIndirect, "Iconview", ID_ICONVIEW_1, 0, 227, 480, 60, WM_CF_SHOW | WM_CF_HASTRANS | ICONVIEW_CF_AUTOSCROLLBAR_V, 130, 30 },

      //createEx function
      ICONVIEW_CreateEx(0, 227, 480, 60, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, ICONVIEW_CF_AUTOSCROLLBAR_V, ID_ICONVIEW_1, 130, 30);

      what could be the issue here. all other code to initialize the icon view is same other than method to create the iconview. code below

      ICONVIEW_SetTextAlign(Iconview_Handle2,GUI_TA_HCENTER | GUI_TA_BOTTOM);
      ICONVIEW_SetFont(Iconview_Handle2, &GUI_FontEncodeSansR8pt);

      for (i = 0; i < GUI_COUNTOF(Menu_aBitmapItem_Inactive); i++) {

      //* Add icons to the widget


      ICONVIEW_SetSpace(Iconview_Handle2,GUI_COORD_X,40);
      ICONVIEW_SetSpace(Iconview_Handle2,GUI_COORD_Y,0);
      //add inactive bitmaps to iconview
      ICONVIEW_AddBitmapItem(Iconview_Handle2, Menu_aBitmapItem_Inactive.pBitmap, "Text");//Menu_aBitmapItem_Inactive[i].pText

      }
      ICONVIEW_SetIconAlign(Iconview_Handle2, ICONVIEW_IA_HCENTER | ICONVIEW_IA_TOP);
      //Set color to use if icon not selected
      ICONVIEW_SetTextColor(Iconview_Handle2,ICONVIEW_CI_UNSEL,GUI_MAKE_COLOR(0x00D7D8D7));
      //set color to use if icon selected
      //ICONVIEW_SetTextColor(Iconview_Handle2,ICONVIEW_CI_SEL,GUI_MAKE_COLOR(0x0074BA6D));

      //set back colors for icons
      //ICONVIEW_SetBkColor(Iconview_Handle2, ICONVIEW_CI_SEL, GUI_WHITE);

      Regards,

      Anuj
    • Hi,

      the problem is related to the paramters passed with the resource table.

      To set the size of the items you have to or them. like:

      { ICONVIEW_CreateIndirect, "Iconview", GUI_ID_ICONVIEW0, 0, 0, 480, 60, 0, (30 << 16) | 160, 0 },

      The last parameter is for passing the size of extra data.

      Also it is not required to pass create flags as 8th parameter, except the ICONVIEW_CF_AUTOSCROLLBAR_V.


      Unfortunately, I discovered a bug in the ICONVIEW which makes the ICONVIEW ignore the ICONVIEW_CF_AUTOSCROLLBAR_V set in the resource table.

      You can get around this by calling the following in WM_INIT_DIALOG.


      I fixed this, but it might take some time till release.

      WM_SetScrollbarV(hIconView, 1);


      Here is my code for testing:

      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. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      21. /*********************************************************************
      22. *
      23. * Static data
      24. *
      25. **********************************************************************
      26. */
      27. static GUI_CONST_STORAGE U32 _acBitmap_10x10[] = {
      28. #if (GUI_USE_ARGB == 1)
      29. 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C,
      30. 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C,
      31. 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C,
      32. 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFF22B14C, 0xFF22B14C, 0xFF22B14C,
      33. 0xFF00A2E8, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFF22B14C, 0xFF22B14C,
      34. 0xFF00A2E8, 0xFF00A2E8, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFF22B14C,
      35. 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24,
      36. 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24,
      37. 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24,
      38. 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFF00A2E8, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24, 0xFFED1C24
      39. #else
      40. 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x004CB122, 0x004CB122, 0x004CB122, 0x004CB122, 0x004CB122, 0x004CB122,
      41. 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x004CB122, 0x004CB122, 0x004CB122, 0x004CB122, 0x004CB122,
      42. 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x004CB122, 0x004CB122, 0x004CB122, 0x004CB122,
      43. 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x004CB122, 0x004CB122, 0x004CB122,
      44. 0x00E8A200, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x004CB122, 0x004CB122,
      45. 0x00E8A200, 0x00E8A200, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x004CB122,
      46. 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED,
      47. 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED,
      48. 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED,
      49. 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00E8A200, 0x00241CED, 0x00241CED, 0x00241CED, 0x00241CED
      50. #endif
      51. };
      52. GUI_CONST_STORAGE GUI_BITMAP bmBitmap_10x10 = {
      53. 10, // xSize
      54. 10, // ySize
      55. 40, // BytesPerLine
      56. 32, // BitsPerPixel
      57. (unsigned char *)_acBitmap_10x10, // Pointer to picture data
      58. NULL, // Pointer to palette
      59. #if (GUI_USE_ARGB == 1)
      60. GUI_DRAW_BMPM8888I
      61. #else
      62. GUI_DRAW_BMP8888
      63. #endif
      64. };
      65. static const GUI_BITMAP * _apBm[] = {
      66. &bmBitmap_10x10,
      67. &bmBitmap_10x10,
      68. &bmBitmap_10x10,
      69. &bmBitmap_10x10,
      70. &bmBitmap_10x10,
      71. &bmBitmap_10x10,
      72. &bmBitmap_10x10,
      73. &bmBitmap_10x10,
      74. };
      75. /*********************************************************************
      76. *
      77. * _aDialogCreate
      78. */
      79. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      80. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 60, 0, 0x0, 0 },
      81. { ICONVIEW_CreateIndirect, "Iconview", GUI_ID_ICONVIEW0, 0, 0, 480, 60, 0, (30 << 16) | 160, 0 },
      82. };
      83. /*********************************************************************
      84. *
      85. * Static code
      86. *
      87. **********************************************************************
      88. */
      89. /*********************************************************************
      90. *
      91. * _cbDialog
      92. */
      93. static void _cbDialog(WM_MESSAGE * pMsg) {
      94. int NCode;
      95. int Id;
      96. int i;
      97. WM_HWIN hIconView;
      98. switch (pMsg->MsgId) {
      99. case WM_INIT_DIALOG:
      100. WINDOW_SetBkColor(pMsg->hWin, GUI_LIGHTBLUE);
      101. hIconView = WM_GetDialogItem(pMsg->hWin, GUI_ID_ICONVIEW0);
      102. WM_SetHasTrans(hIconView);
      103. WM_SetScrollbarV(hIconView, 1);
      104. ICONVIEW_SetTextAlign(hIconView,GUI_TA_HCENTER | GUI_TA_BOTTOM);
      105. ICONVIEW_SetFont(hIconView, &GUI_Font16_1);
      106. for (i = 0; i < GUI_COUNTOF(_apBm); i++) {
      107. //* Add icons to the widget
      108. ICONVIEW_SetSpace(hIconView, GUI_COORD_X, 40);
      109. ICONVIEW_SetSpace(hIconView, GUI_COORD_Y, 0);
      110. //add inactive bitmaps to iconview
      111. ICONVIEW_AddBitmapItem(hIconView, _apBm[i], "Text");//Menu_aBitmapItem_Inactive[i].pText
      112. }
      113. ICONVIEW_SetIconAlign(hIconView, ICONVIEW_IA_HCENTER | ICONVIEW_IA_TOP);
      114. //Set color to use if icon not selected
      115. ICONVIEW_SetTextColor(hIconView,ICONVIEW_CI_UNSEL,GUI_MAKE_COLOR(0x00D7D8D7));
      116. break;
      117. case WM_NOTIFY_PARENT:
      118. Id = WM_GetId(pMsg->hWinSrc);
      119. NCode = pMsg->Data.v;
      120. switch(Id) {
      121. case GUI_ID_ICONVIEW0: // Notifications sent by 'Iconview'
      122. switch(NCode) {
      123. case WM_NOTIFICATION_CLICKED:
      124. break;
      125. case WM_NOTIFICATION_RELEASED:
      126. break;
      127. case WM_NOTIFICATION_MOVED_OUT:
      128. break;
      129. case WM_NOTIFICATION_SCROLL_CHANGED:
      130. break;
      131. case WM_NOTIFICATION_SEL_CHANGED:
      132. break;
      133. }
      134. break;
      135. }
      136. break;
      137. default:
      138. WM_DefaultProc(pMsg);
      139. break;
      140. }
      141. }
      142. /*********************************************************************
      143. *
      144. * _cbBk
      145. */
      146. static void _cbBk(WM_MESSAGE * pMsg) {
      147. switch (pMsg->MsgId) {
      148. case WM_PAINT:
      149. GUI_SetBkColor(GUI_LIGHTBLUE);
      150. GUI_Clear();
      151. break;
      152. default:
      153. WM_DefaultProc(pMsg);
      154. break;
      155. }
      156. }
      157. /*********************************************************************
      158. *
      159. * Public code
      160. *
      161. **********************************************************************
      162. */
      163. /*********************************************************************
      164. *
      165. * MainTask
      166. */
      167. void MainTask(void) {
      168. WM_HWIN hIconView;
      169. int i;
      170. GUI_Init();
      171. WM_MULTIBUF_Enable(1);
      172. WM_SetCallback(WM_HBKWIN, _cbBk);
      173. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      174. hIconView = ICONVIEW_CreateEx(0, 227, 480, 60, WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS, ICONVIEW_CF_AUTOSCROLLBAR_V, GUI_ID_ICONVIEW1, 130, 30);
      175. ICONVIEW_SetTextAlign(hIconView,GUI_TA_HCENTER | GUI_TA_BOTTOM);
      176. ICONVIEW_SetFont(hIconView, &GUI_Font16_1);
      177. for (i = 0; i < GUI_COUNTOF(_apBm); i++) {
      178. //* Add icons to the widget
      179. ICONVIEW_SetSpace(hIconView, GUI_COORD_X, 40);
      180. ICONVIEW_SetSpace(hIconView, GUI_COORD_Y, 0);
      181. //add inactive bitmaps to iconview
      182. ICONVIEW_AddBitmapItem(hIconView, _apBm[i], "Text");//Menu_aBitmapItem_Inactive[i].pText
      183. }
      184. ICONVIEW_SetIconAlign(hIconView, ICONVIEW_IA_HCENTER | ICONVIEW_IA_TOP);
      185. //Set color to use if icon not selected
      186. ICONVIEW_SetTextColor(hIconView,ICONVIEW_CI_UNSEL,GUI_MAKE_COLOR(0x00D7D8D7));
      187. //set color to use if icon selected
      188. //ICONVIEW_SetTextColor(hIconView,ICONVIEW_CI_SEL,GUI_MAKE_COLOR(0x0074BA6D));
      189. //set back colors for icons
      190. //ICONVIEW_SetBkColor(hIconView, ICONVIEW_CI_SEL, GUI_WHITE);
      191. while (1) {
      192. GUI_Delay(100);
      193. }
      194. }
      195. /*************************** 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.