From a701166db0e534b25018b5168d7a107955645bed Mon Sep 17 00:00:00 2001 From: toshinagata1964 Date: Tue, 11 Mar 2014 11:22:25 +0000 Subject: [PATCH] MyListCtrl now allows use of popup menus including separator items and disabled items git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@455 a2be9bc6-48de-4e38-9406-05402d4bc13c --- wxSources/MyListCtrl.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/wxSources/MyListCtrl.cpp b/wxSources/MyListCtrl.cpp index 33af8b0..ec0fd2f 100644 --- a/wxSources/MyListCtrl.cpp +++ b/wxSources/MyListCtrl.cpp @@ -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; } -- 2.11.0