# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1320314951 0 # Node ID 18a31ab94e3d2a881e1c0432ceae28600e98b67f # Parent 68f18dccfb8f1b4da70c02ed8bddf757c7835b1f Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field. On OS/2 and Windows AUTO will automatically allocate a menu ID from the larger static pool of IDs. POPUP will automatically allocate an ID from the smaller pool for transient popup menus. These flags don't do anything on the other platforms since they don't require menu IDs. diff -r 68f18dccfb8f -r 18a31ab94e3d dw.h --- a/dw.h Thu Nov 03 08:38:34 2011 +0000 +++ b/dw.h Thu Nov 03 10:09:11 2011 +0000 @@ -1391,6 +1391,8 @@ #define DW_MENU_SEPARATOR "" #define DW_NOMENU 0 +#define DW_MENU_AUTO 0 +#define DW_MENU_POPUP (unsigned long)-1 #define DW_PERCENT_INDETERMINATE ((unsigned int)-1) diff -r 68f18dccfb8f -r 18a31ab94e3d os2/dw.c --- a/os2/dw.c Thu Nov 03 08:38:34 2011 +0000 +++ b/os2/dw.c Thu Nov 03 10:09:11 2011 +0000 @@ -4700,10 +4700,36 @@ if ( is_disabled ) miSubMenu.afAttribute |= MIA_DISABLED; - if ( strlen( title ) == 0 ) + if (title && *title) + { + /* Code to autogenerate a menu ID if not specified or invalid + * First pool is smaller for transient popup menus + */ + if(id == (ULONG)-1) + { + static ULONG tempid = 61000; + + tempid++; + id = tempid; + + if(tempid > 65500) + tempid = 61000; + } + /* Second pool is larger for more static windows */ + else if(!id || id >= 30000) + { + static ULONG menuid = 30000; + + menuid++; + id = menuid; + + if(menuid > 60000) + menuid = 30000; + } + miSubMenu.afStyle = MIS_TEXT; + } + else miSubMenu.afStyle = MIS_SEPARATOR; - else - miSubMenu.afStyle = MIS_TEXT; miSubMenu.id=id; miSubMenu.hwndSubMenu = submenu; miSubMenu.hItem=NULLHANDLE; diff -r 68f18dccfb8f -r 18a31ab94e3d win/dw.c --- a/win/dw.c Thu Nov 03 08:38:34 2011 +0000 +++ b/win/dw.c Thu Nov 03 10:09:11 2011 +0000 @@ -4848,7 +4848,33 @@ } if (title && *title) + { + /* Code to autogenerate a menu ID if not specified or invalid + * First pool is smaller for transient popup menus + */ + if(id == (ULONG)-1) + { + static ULONG tempid = 61000; + + tempid++; + id = tempid; + + if(tempid > 65500) + tempid = 61000; + } + /* Second pool is larger for more static windows */ + else if(!id || id >= 30000) + { + static ULONG menuid = 30000; + + menuid++; + id = menuid; + + if(menuid > 60000) + menuid = 30000; + } mii.fType = MFT_STRING; + } else mii.fType = MFT_SEPARATOR;