changeset 1305:18a31ab94e3d

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.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 03 Nov 2011 10:09:11 +0000
parents 68f18dccfb8f
children dbd507f42947
files dw.h os2/dw.c win/dw.c
diffstat 3 files changed, 57 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)
 
--- 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;
--- 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;