1 /*******************************************************
2  Copyright (C) 2006 Madhan Kanagavel
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  ********************************************************/
18 
19 #ifndef MM_EX_CATEGDIALOG_H_
20 #define MM_EX_CATEGDIALOG_H_
21 
22 
23 #include "defs.h"
24 #include "model/Model_Category.h"
25 
26 class mmTreeItemCateg : public wxTreeItemData
27 {
28 public:
mmTreeItemCateg(const Model_Category::Data & categData,const Model_Subcategory::Data & subcategData)29     mmTreeItemCateg(const Model_Category::Data& categData, const Model_Subcategory::Data& subcategData)
30         : categData_(categData)
31         , subcategData_(subcategData)
32     {}
getCategData()33     Model_Category::Data* getCategData() { return &categData_; }
getSubCategData()34     Model_Subcategory::Data* getSubCategData() { return &subcategData_; }
35 
36 private:
37     Model_Category::Data categData_;
38     Model_Subcategory::Data subcategData_;
39 };
40 
41 class mmCategDialog : public wxDialog
42 {
43     wxDECLARE_DYNAMIC_CLASS(mmCategDialog);
44     wxDECLARE_EVENT_TABLE();
45 
46 public:
47     mmCategDialog();
48     mmCategDialog(wxWindow* parent
49         , bool bEnableSelect = true
50         , bool bEnableRelocate = true);
51 
52     bool Create(wxWindow* parent
53         , wxWindowID id
54         , const wxString& caption
55         , const wxPoint& pos
56         , const wxSize& size
57         , long style);
58 
59     void setTreeSelection(const wxString& catName, const wxString& subCatName);
60     void setTreeSelection(int &category_id, int &subcategory_id);
getCategId()61     int getCategId()
62     {
63         return categID_;
64     }
getSubCategId()65     int getSubCategId()
66     {
67         return subcategID_;
68     }
getRefreshRequested()69     bool getRefreshRequested()
70     {
71         return refreshRequested_;
72     }
73     wxString getFullCategName();
74 
75 private:
76     void CreateControls();
77     void fillControls();
78 
79     void OnOk(wxCommandEvent& event);
80     void OnCancel(wxCommandEvent& event);
81     void OnAdd(wxCommandEvent& event);
82     void OnDelete(wxCommandEvent& event);
83     void OnBSelect(wxCommandEvent& event);
84     void OnEdit(wxCommandEvent& event);
85     void OnSelChanged(wxTreeEvent& event);
86     void OnDoubleClicked(wxTreeEvent& event);
87     void showCategDialogDeleteError(wxString deleteCategoryErrMsg, bool category = true);
88     void OnCategoryRelocation(wxCommandEvent& /*event*/);
89     void OnExpandChbClick(wxCommandEvent& /*event*/);
90     void OnShowHiddenChbClick(wxCommandEvent& /*event*/);
91     void OnMenuSelected(wxCommandEvent& event);
92     void OnItemRightClick(wxTreeEvent& event);
93     bool categShowStatus(int categId, int subCategId);
94 
95     wxTreeCtrl* m_treeCtrl;
96     wxTextCtrl* m_textCtrl;
97     wxButton* m_buttonAdd;
98     wxButton* m_buttonEdit;
99     wxButton* m_buttonSelect;
100     wxButton* m_buttonDelete;
101     wxBitmapButton* m_buttonRelocate;
102     wxCheckBox* m_cbExpand;
103     wxCheckBox* m_cbShowAll;
104     wxTreeItemId selectedItemId_;
105     wxTreeItemId root_;
106     wxTreeItemId getTreeItemFor(const wxTreeItemId& itemID, const wxString& itemText);
107     bool bEnableSelect_;
108     bool bEnableRelocate_;
109     int categID_;
110     int subcategID_;
111     wxColour NormalColor_;
112     wxArrayString hidden_categs_;
113     bool refreshRequested_;
114 
115     enum
116     {
117         MENU_ITEM_HIDE = wxID_HIGHEST + 1500,
118         MENU_ITEM_UNHIDE,
119         MENU_ITEM_CLEAR,
120         ID_DIALOG_CATEGORY
121     };
122 };
123 
124 #endif
125