emWin submenu of submenu

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

emWin submenu of submenu

613 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pcalton on Fri May 31 13:27:30 MST 2013

I am trying out the different widgets available in emWin and as part of my testing I am attempting to make a submenu of a submenu using the following code: 


<span class="Apple-tab-span" style="white-space: pre;"> </span>hSubMenu = MENU_CreateEx(0,0,85,105,0,WM_CF_SHOW, MENU_CF_VERTICAL, ID_MENU_0_SUB_ALARM);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hItem, "Alarms", ID_MENU_0_SUB_ALARM, 0, hSubMenu);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu, "View Active", ID_MENU_ALARM_VIEW, 0, 0);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu, "Clear All", ID_MENU_ALARM_CLEAR, 0, 0);


 


<span class="Apple-tab-span" style="white-space: pre;"> </span>hSubMenu2 = MENU_CreateEx(70,15,80,55,0,WM_CF_SHOW, MENU_CF_VERTICAL, ID_MENU_ALARM_TEMP_SENSOR);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu, "Temp Sensors &gt;", ID_MENU_ALARM_TEMP_SENSOR, 0, hSubMenu2);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu2, "Temp Sensor 1", ID_ALARM_TS1, 0, 0);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu2, "Temp Sensor 2", ID_ALARM_TS2, 0, 0);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu2, "Temp Sensor 3", ID_ALARM_TS3, 0, 0);


 


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu, "Current", ID_MENU_ALARM_CURRENT, 0, 0);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu, "Voltage", ID_MENU_ALARM_VOLTAGE, 0, 0);


<span class="Apple-tab-span" style="white-space: pre;"> </span>AddMenuItem(hSubMenu, "Resistance", ID_MENU_ALARM_RESIST, 0, 0);


Unfortunately the 2nd level of submenu isnt offset correctly from the parent menu as shown in this image.


<div><span class="inline inline-left"><img class="image image-preview " src="http://lpcware.com/system/files/images/wrong%20offset.png" border="0" alt="" title="" width="129" height="138" /></span></div>

I have tried adding an offset when creating the submenu as in the code above, but this didnt seem to have any effect. Am I doing something wrong or is this just not possible with emWin?


<div>Thanks for any replies</div>
Labels (1)
0 Kudos
2 Replies

498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by pcalton on Thu Jun 06 14:17:03 MST 2013

I think I have uncovered a bug in the menu widget.


If you take the example Menu application that you posted and add the File menu last then the submenu for "Files..." shows incorrectly


Source snippet:


  // Add menu items to main menu


  _AddMenuItem(hMenu,       hMenuEdit,   "Edit",     0,                   0);


  _AddMenuItem(hMenu,       hMenuHelp,   "Help",     0,                   0);


  _AddMenuItem(hMenu,       hMenuFile,   "File",     0,                   0);


  // Attach menu to parent window


  FRAMEWIN_AddMenu(hParent, hMenu);


Result:


<span class="inline inline-left"><img class="image image-preview " src="http://lpcware.com/system/files/images/menu%20misalign.png" border="0" alt="" title="" width="120" height="156" /></span>


The left hand edge of the "Files..." submenu lines up perfectly with the righthand edge of the first submenu (now "Edit") instead of its parent submenu.


Going back to my application confirms this. The Temp Sensor submenu is aligned with the righthand edge of my File submenu when it should be aligned to the Alarms menu.


EDIT:


Futher testing shows the "Files..." submenu is offset from the start of the main menu by the width of the "File" submenu. emWin is not taking the position of the parent submenu into account, only its width.


i.e. the x coordinate for the submenu is the width of its parent and not the x coordinate of its parent plus the width of the parent

0 Kudos

498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Wouter on Wed Jun 05 15:47:03 MST 2013

Hi,


 


This indeed does not look right. You may want to have a look at Segger's example "Menu widget demo", the "File-&gt;Files..." menu uses submenus.


Executable: http://www.segger.com/admin/uploads/userfiles/file/emWin/tutorials/WIDGET_Menu.exe


Source: http://www.segger.com/admin/uploads/userfiles/file/emWin/tutorials/src/WIDGET_Menu.c


From: http://www.segger.com/emwin-samples.html


 


Regards,


Wouter

0 Kudos