Update of /cvsroot/audacity/audacity-src/src/commands
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv24105/src/commands

Modified Files:
        CommandManager.cpp CommandManager.h 
Log Message:
Keyboard shortcut categories try-out.

Index: CommandManager.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/commands/CommandManager.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- CommandManager.h    30 May 2009 19:54:12 -0000      1.26
+++ CommandManager.h    4 Jun 2009 15:51:21 -0000       1.27
@@ -48,6 +48,7 @@
    wxString defaultKey;
    wxString label;
    wxString labelPrefix;
+   wxString labelTop;
    wxMenu *menu;
    CommandFunctor *callback;
    bool multi;
@@ -178,10 +179,12 @@
    // Accessing
    //
 
+   void GetCategories(wxArrayString &cats);
    void GetAllCommandNames(wxArrayString &names, bool includeMultis);
 
    wxString GetLabelFromName(wxString name);
    wxString GetPrefixedLabelFromName(wxString name);
+   wxString CommandManager::GetCategoryFromName(wxString name);
    wxString GetKeyFromName(wxString name);
    wxString GetDefaultKeyFromName(wxString name);
 
@@ -232,6 +235,7 @@
    bool mbSeparatorAllowed; // false at the start of a menu and immediately 
after a separator.
    int mHidingLevel;
 
+   wxString mCurrentMenuName;
    wxMenu * mCurrentMenu;
    wxMenu * mOpenMenu;
 

Index: CommandManager.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/commands/CommandManager.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- CommandManager.cpp  31 May 2009 21:09:14 -0000      1.72
+++ CommandManager.cpp  4 Jun 2009 15:51:21 -0000       1.73
@@ -105,6 +105,7 @@
 #define MAX_SUBMENU_LEN 1000
 #endif
 
+#define COMMAND _("Command")
 ///
 ///  Standard Constructor
 ///
@@ -112,6 +113,7 @@
    mCurrentID(0),
    mHiddenID(0),
    mCurrentMenu(NULL),
+   mCurrentMenuName(COMMAND),
    mOpenMenu(NULL),
    mDefaultFlags(0),
    mDefaultMask(0)
@@ -161,6 +163,7 @@
    mCommandIDHash.clear();
 
    mCurrentMenu = NULL;
+   mCurrentMenuName = COMMAND;
    mCurrentID = 0;
 }
 
@@ -234,6 +237,7 @@
    wxMenu *tmpMenu = new wxMenu();
 
    mCurrentMenu = tmpMenu;
+   mCurrentMenuName = tName;
 
    CurrentMenuBar()->Append(mCurrentMenu, tName);
 }
@@ -248,10 +252,10 @@
       mHidingLevel--;
 
    mCurrentMenu = NULL;
+   mCurrentMenuName = COMMAND;
 }
 
 
-
 ///
 /// This starts a new submenu, and names it according to
 /// the function's argument.
@@ -654,6 +658,7 @@
    tmpEntry->name = name;
    tmpEntry->label = label;
    tmpEntry->labelPrefix = labelPrefix;
+   tmpEntry->labelTop = wxMenuItem::GetLabelFromText(mCurrentMenuName);
    tmpEntry->menu = menu;
    tmpEntry->callback = callback;
    tmpEntry->multi = multi;
@@ -1033,6 +1038,39 @@
    return false;
 }
 
+void CommandManager::GetCategories(wxArrayString &cats)
+{
+   cats.Clear();
+
+   size_t cnt = mCommandList.GetCount();
+
+   for (size_t i = 0; i < cnt; i++) {
+      wxString cat = mCommandList[i]->labelTop;
+      if (cats.Index(cat) == wxNOT_FOUND) {
+         cats.Add(cat);
+      }
+   }
+#if 0
+   mCommandList.GetCount(); i++) {
+      if (includeMultis || !mCommandList[i]->multi)
+         names.Add(mCommandList[i]->name);
+   }
+
+   AudacityProject *p = GetActiveProject();
+   if (p == NULL) {
+      return;
+   }
+
+   wxMenuBar *bar = p->GetMenuBar();
+   size_t cnt = bar->GetMenuCount();
+   for (size_t i = 0; i < cnt; i++) {
+      cats.Add(bar->GetMenuLabelText(i));
+   }
+
+   cats.Add(COMMAND);
+#endif
+}
+
 void CommandManager::GetAllCommandNames(wxArrayString &names,
                                         bool includeMultis)
 {
@@ -1062,6 +1100,15 @@
    return wxString(entry->labelPrefix + wxT(" ") + 
entry->label).Trim(false).Trim(true);
 }
 
+wxString CommandManager::GetCategoryFromName(wxString name)
+{
+   CommandListEntry *entry = mCommandNameHash[name];
+   if (!entry)
+      return wxT("");
+
+   return entry->labelTop;
+}
+
 wxString CommandManager::GetKeyFromName(wxString name)
 {
    CommandListEntry *entry = mCommandNameHash[name];


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to