Unselect all Icons on ICONVIEW

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

  • Unselect all Icons on ICONVIEW

    Hello,
    I have to draw a menu using the iconview widget.
    But now I have the problem that it looks like that the first
    icon is always selected just after the initialization of the widget.
    So if I should react on the message on_sel_changed I never react
    on a touch on the first icon before I touch on another before.


    But
    after a touch I should change the menu and there is no possibility to first
    touch another!

    I hae tried to use:

    ICONVIEW_SetSel(hWin, -1);

    But nothing changed.

    I hope there is somone who could elp me in this issue.
    regards
    markus
  • Hello Markus,

    You can make the parent window of the ICONVIEW widget react to the notifications caused by the ICONVIEW widget. Please try the following code:

    C Source Code

    1. /*********************************************************************
    2. *
    3. * _cbDialog
    4. */
    5. void _cbDialog(WM_MESSAGE * pMsg) {
    6. int NCode;
    7. int Sel;
    8. int Id;
    9. switch (pMsg->MsgId) {
    10. case WM_NOTIFY_PARENT:
    11. NCode = pMsg->Data.v;
    12. Id = WM_GetId(pMsg->hWinSrc);
    13. if (Id == GUI_ID_ICONVIEW0) {
    14. switch (NCode) {
    15. case WM_NOTIFICATION_RELEASED:
    16. Sel = ICONVIEW_GetSel(pMsg->hWinSrc);
    17. break;
    18. }
    19. }
    20. break;
    21. default:
    22. WM_DefaultProc(pMsg);
    23. }
    24. }
    Display All


    Could you please tell me if this is a help for you? Thank you in advance.

    Best regards,
    Adrian
  • Hello Adrian,

    yes this information has solved my problem. I had used the Notification "WM_NOTIFICATION_SEL_CHANGED" and this has caused the problems.

    Another Question regarding a menu using IconView:
    On My screen I have one Textfield at the TOP a Textfield in the center an the iconview at the bottom.
    At the moment I have used a "GUI_CreateDialogBox" for the Window and the textfields and then I have generated the iconview like in the following way:

    hWin = GUI_CreateDialogBox ( _aMainCreate2, GUI_COUNTOF(_aMainCreate2), &_cbMain2, WM_HBKWIN, 0, 0 );
    hIconView = ICONVIEW_CreateEx ( 0, 170, 320, 70, hWin, WM_CF_SHOW | WM_CF_HASTRANS, 0, GUI_ID_ICONVIEW0, 70, 65 );
    ICONVIEW_SetFrame ( hIconView, GUI_COORD_Y, 0 );
    ICONVIEW_SetBkColor ( hIconView, ICONVIEW_CI_SEL, GUI_GRAY );
    ICONVIEW_AddBitmapItem ( hIconView, &bmInfo_Button, NULL );
    ICONVIEW_SetSpace ( hIconView, GUI_COORD_X, 60 );
    ICONVIEW_SetFrame ( hIconView, GUI_COORD_X, 60 );
    ICONVIEW_AddBitmapItem ( hIconView, &bmInfo_Button, NULL );

    An in the ON-PAINT secton of the _cbMain2 I have used a "GUI_DrawBitmap" to draw a background picture.

    And for the whole Program I have then several different menu in the same format like I have it described above.
    Before the change from such a menu to another I have then to use a "GUI_EndDialog" to clear the old dialog before I draw the new one.

    Is there a better course for such a menu with two text field and a iconview in the buttom with a background picture (same for all menu's)?

    regards
    markus
  • Hello Adrian,
    Is there the possibility to use the iconview with "ICONVIEW_CreateIndirect" within the dialog?
    If have tried it but i was not able to draw the iconview in the right way and I have not found an example for "ICONVIEW_CreateIndirect"
    I have tried something like this:

    C Source Code

    1. static const GUI_WIDGET_CREATE_INFO _aMainCreate2 [ ] = {
    2. { WINDOW_CreateIndirect, "", ID_WINDOW_0, 0, 0, 320, 240, 0, 0, 0 },
    3. { TEXT_CreateIndirect, "", ID_TEXT_0, 0, 0, 320, 30, 0, 0, 0 },
    4. { TEXT_CreateIndirect, "", ID_TEXT_1, 0, 30, 320, 130, 0, 0, 0 },
    5. { ICONVIEW_CreateIndirect, "", GUI_ID_ICONVIEW0, 0, 170, 320, 70, WM_CF_HASTRANS, 0, 0 },
    6. };

    But then I can not see my icons and I have no file dto insert the int xSizeItems, int ySizeItem from ICONVIEW_CreateEx

    regards
    markus
  • Hello Adrian,

    at the moment I have it done like I ahve writte in my second post. So i clear the dialog and then "draw" the iconview on the dialog.
    But ist would be great that the iconview will be drawn also within the createdialog function and I can then add the icons in the INIT_DIALOG section of the callback.

    regards
    markus
  • Hello Adrian,

    I have tried to generate the iconview within the dialog as I have it written in a post above but I was not able to use it in the right way. see my privious post above.
    And of course I have read the expected lines in the manual but was also not able to use it in the right way!

    Is there an example which you could send me where I can see how you create the inconview with createindirect?

    regards
    markus
  • Hello Adrian,

    I have use other widgets with their createindirect functions without problems and I have read the chapter dialog in the manual and I have read also the description for iconview_createindirect but I was not ebale to use the iconview in the right way!

    once I have tried it in the following was:

    C Source Code

    1. static const GUI_WIDGET_CREATE_INFO _aMainCreate2 [ ] =
    2. {
    3. { WINDOW_CreateIndirect, "", ID_WINDOW_0, 0, 0, 320, 240, 0, 0, 0 },
    4. { TEXT_CreateIndirect, "", ID_TEXT_0, 0, 0, 320, 30, 0, 0, 0 },
    5. { TEXT_CreateIndirect, "", ID_TEXT_1, 0, 30, 320, 130, 0, 0, 0 },
    6. { ICONVIEW_CreateIndirect, "", GUI_ID_ICONVIEW0, 0, 170, 320, 70, WM_CF_HASTRANS, 0, 0 },
    7. };
    Display All

    But then I can't see my icons and I have no filed to insert the int xSizeItems, int ySizeItem from ICONVIEW_CreateEx.

    So maybe it is possible that you write me a short line with the corrected usage of iconview_createindirect.

    thank you
    regards
    markus
  • Hello Markus,

    I just had a look at the function ICONVIEW_CreateIndirect and found out that the parameter Para (GUI_WIDGET_CREATE_INFO) is not well described. Please note that the item sizes have to be defined as in the following code snippet:

    C Source Code

    1. #include "DIALOG.h"
    2. /*********************************************************************
    3. *
    4. * Data
    5. *
    6. **********************************************************************
    7. */
    8. typedef struct {
    9. const GUI_BITMAP * pBitmap;
    10. const char * pText;
    11. } BITMAP_ITEM;
    12. static const BITMAP_ITEM _aBitmapItem[] = {
    13. //
    14. // Insert bitmaps and text here:
    15. // { &_bmTest, "Test" },
    16. //
    17. };
    18. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    19. { FRAMEWIN_CreateIndirect, "Dialog", 0, 10, 10, 270, 150, FRAMEWIN_CF_MOVEABLE, 0, 0 },
    20. { ICONVIEW_CreateIndirect, NULL, GUI_ID_ICONVIEW0, 0, 0, 260, 140, WM_CF_HASTRANS, (60 << 16) | 50, 0 }
    21. };
    22. /*********************************************************************
    23. *
    24. * Code
    25. *
    26. **********************************************************************
    27. */
    28. /*********************************************************************
    29. *
    30. * _cbDialog
    31. */
    32. static void _cbDialog(WM_MESSAGE * pMsg) {
    33. WM_HWIN hItem;
    34. unsigned i;
    35. switch (pMsg->MsgId) {
    36. case WM_INIT_DIALOG:
    37. hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_ICONVIEW0);
    38. for (i = 0; i < GUI_COUNTOF(_aBitmapItem); i++) {
    39. ICONVIEW_AddBitmapItem(hItem, _aBitmapItem[i].pBitmap, _aBitmapItem[i].pText);
    40. }
    41. ICONVIEW_SetBkColor(hItem, ICONVIEW_CI_SEL, 0xCC800000);
    42. ICONVIEW_SetSpace(hItem, GUI_COORD_X, 17);
    43. ICONVIEW_SetIconAlign(hItem, ICONVIEW_IA_TOP);
    44. ICONVIEW_SetFont(hItem, &GUI_Font13_ASCII);
    45. ICONVIEW_SetTextColor(hItem, ICONVIEW_CI_SEL, GUI_DARKBLUE);
    46. ICONVIEW_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_DARKBLUE);
    47. ICONVIEW_SetTextColor(hItem, ICONVIEW_CI_DISABLED, GUI_DARKBLUE);
    48. }
    49. }
    50. /*********************************************************************
    51. *
    52. * MainTask
    53. */
    54. void MainTask(void) {
    55. GUI_Init();
    56. WM_EnableMemdev(WM_HBKWIN);
    57. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    58. while (1) {
    59. GUI_Delay(100);
    60. }
    61. }
    Display All

    The 16 upper bits of the parameter Para describe the ySize of the items. The lower bits describe the xSize. In this case the xSize is set to 50 and the ySize is set to 60. Please note that the code snippet does not include any bitmaps, so it will not run unchanged.

    Best regards,
    Adrian
  • Adrian, how to set the size of icons using your code. In my code specifies the size of icons in this function

    C Source Code

    1. ICONVIEW_CreateEx(0, 0, LCD_GetXSize(), LCD_GetYSize(), hWin, WM_CF_SHOW, 0, ID_ICONVIEW_MENU, 110, 110);