summaryrefslogtreecommitdiff
path: root/win/Mainfrm.cpp
diff options
context:
space:
mode:
authorleo2005-10-14 17:01:15 +0000
committerleo2005-10-14 17:01:15 +0000
commit8a9d55e37404c121d7ba0f29440e280a7cd1c3ec (patch)
treef2adbf554e0fbac14d2fa77b269f726ed2af8842 /win/Mainfrm.cpp
parente628ac83ce745362b4e1bb719cc2db0a1ce74a76 (diff)
Added commands to edit/add/remove categories from the pieces tree context menu.
git-svn-id: http://svn.leocad.org/trunk@427 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/Mainfrm.cpp')
-rw-r--r--win/Mainfrm.cpp73
1 files changed, 72 insertions, 1 deletions
diff --git a/win/Mainfrm.cpp b/win/Mainfrm.cpp
index 4cf8901..a1cb1fc 100644
--- a/win/Mainfrm.cpp
+++ b/win/Mainfrm.cpp
@@ -14,6 +14,8 @@
#include "cadview.h"
#include "console.h"
#include "keyboard.h"
+#include "system.h"
+#include "library.h"
#include "Print.h"
@@ -984,7 +986,76 @@ BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam)
project->HandleCommand(LC_HELP_ABOUT, 0);
} break;
- default: return CFrameWnd::OnCommand(wParam, lParam);
+ case ID_PIECEBAR_EDITCATEGORY:
+ {
+ HTREEITEM Item = m_wndPiecesBar.m_PiecesTree.GetSelectedItem();
+
+ if (Item == NULL)
+ break;
+
+ PiecesLibrary* Lib = project->GetPiecesLibrary();
+ CString CategoryName = m_wndPiecesBar.m_PiecesTree.GetItemText(Item);
+ int Index = Lib->FindCategoryIndex((const char*)CategoryName);
+
+ if (Index == -1)
+ break;
+
+ LC_CATEGORYDLG_OPTS Opts;
+ Opts.Name = Lib->GetCategoryName(Index);
+ Opts.Keywords = Lib->GetCategoryKeywords(Index);
+
+ if (SystemDoDialog(LC_DLG_EDITCATEGORY, &Opts))
+ {
+ String OldName = Lib->GetCategoryName(Index);
+ Lib->SetCategory(Index, Opts.Name, Opts.Keywords);
+ m_wndPiecesBar.UpdatePiecesTree(OldName, Opts.Name);
+ }
+
+ } break;
+
+ case ID_PIECEBAR_NEWCATEGORY:
+ {
+ LC_CATEGORYDLG_OPTS Opts;
+ Opts.Name = "New Category";
+ Opts.Keywords = "";
+
+ if (SystemDoDialog(LC_DLG_EDITCATEGORY, &Opts))
+ {
+ PiecesLibrary* Lib = project->GetPiecesLibrary();
+ Lib->AddCategory(Opts.Name, Opts.Keywords);
+ m_wndPiecesBar.UpdatePiecesTree(NULL, Opts.Name);
+ }
+
+ } break;
+
+ case ID_PIECEBAR_REMOVECATEGORY:
+ {
+ HTREEITEM Item = m_wndPiecesBar.m_PiecesTree.GetSelectedItem();
+
+ if (Item == NULL)
+ break;
+
+ PiecesLibrary* Lib = project->GetPiecesLibrary();
+ CString CategoryName = m_wndPiecesBar.m_PiecesTree.GetItemText(Item);
+ int Index = Lib->FindCategoryIndex((const char*)CategoryName);
+
+ if (Index == -1)
+ break;
+
+ char Msg[1024];
+ String Name = Lib->GetCategoryName(Index);
+ sprintf(Msg, "Are you sure you want to remove the %s category?", Name);
+
+ if (SystemDoMessageBox(Msg, LC_MB_YESNO | LC_MB_ICONQUESTION) == LC_YES)
+ {
+ Lib->RemoveCategory(Index);
+ m_wndPiecesBar.UpdatePiecesTree(Name, NULL);
+ }
+
+ } break;
+
+ default:
+ return CFrameWnd::OnCommand(wParam, lParam);
}
return TRUE;