OSDN Git Service

MyListCtrl now allows use of popup menus including separator items and disabled items
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 11 Mar 2014 11:22:25 +0000 (11:22 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Tue, 11 Mar 2014 11:22:25 +0000 (11:22 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@455 a2be9bc6-48de-4e38-9406-05402d4bc13c

wxSources/MyListCtrl.cpp

index 33af8b0..ec0fd2f 100644 (file)
@@ -590,8 +590,25 @@ MyListCtrl::OnMouseDown(wxMouseEvent &event)
        if (FindItemAtPosition(pos, &row, &col) && dataSource != NULL && (n = dataSource->HasPopUpMenu(this, row, col, &items)) > 0) {
                wxMenu mnu;
                for (i = 0; i < n; i++) {
-                       wxString itemStr(items[i], WX_DEFAULT_CONV);
-                       mnu.Append(i + 1, itemStr);
+                       char *p = items[i];
+                       bool enabled = true;
+                       if (*p == '-') {
+                               if (p[1] == 0) {
+                                       //  Separator
+                                       mnu.AppendSeparator();
+                                       p = NULL;
+                               } else {
+                                       //  Disabled item
+                                       p++;
+                                       enabled = false;
+                               }
+                       }
+                       if (p != NULL) {
+                               wxString itemStr(p, WX_DEFAULT_CONV);
+                               mnu.Append(i + 1, itemStr);
+                               if (!enabled)
+                                       mnu.Enable(i + 1, false);
+                       }
                        free(items[i]);
                        items[i] = NULL;
                }