Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / WXDialog / PropertyList.h
blob3c0bdb95e0245488cec2ea72d510101d1d51d67e
1 /*=========================================================================
3 Program: WXDialog - wxWidgets X-platform GUI Front-End for CMake
4 Module: $RCSfile: PropertyList.h,v $
5 Language: C++
6 Date: $Date: 2005/06/30 19:54:14 $
7 Version: $Revision: 1.1 $
9 Author: Jorgen Bodde
11 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
12 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
14 This software is distributed WITHOUT ANY WARRANTY; without even
15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 PURPOSE. See the above copyright notices for more information.
18 =========================================================================*/
20 #ifndef __WXPROPERTYLIST_H
21 #define __WXPROPERTYLIST_H
24 #ifndef WX_PRECOMP
25 #include "wx/wx.h"
26 #endif
28 #include <wx/dynarray.h>
29 #include <wx/grid.h>
31 #include "../cmStandardIncludes.h"
33 #ifdef __LINUX__
34 #define MC_DEFAULT_WILDCARD "*"
35 #else
36 #define MC_DEFAULT_WILDCARD "*.*"
37 #endif
39 #if 0
41 // the editor for string/text data
42 class wxGridCellPathEditor : public wxGridCellEditor
44 public:
45 wxGridCellPathEditor();
47 virtual void Create(wxWindow* parent,
48 wxWindowID id,
49 wxEvtHandler* evtHandler);
50 virtual void SetSize(const wxRect& rect);
52 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
54 virtual bool IsAcceptedKey(wxKeyEvent& event);
55 virtual void BeginEdit(int row, int col, wxGrid* grid);
56 virtual bool EndEdit(int row, int col, wxGrid* grid);
58 virtual void Reset();
59 virtual void StartingKey(wxKeyEvent& event);
60 virtual void HandleReturn(wxKeyEvent& event);
62 // parameters string format is "max_width"
63 virtual void SetParameters(const wxString& params);
65 virtual wxGridCellEditor *Clone() const
66 { return new wxGridCellPathEditor; }
68 // DJC MAPTEK
69 // added GetValue so we can get the value which is in the control
70 virtual wxString GetValue() const;
71 protected:
72 wxTextCtrl *Text() const { return (wxTextCtrl *)m_control; }
74 // parts of our virtual functions reused by the derived classes
75 void DoBeginEdit(const wxString& startValue);
76 void DoReset(const wxString& startValue);
78 private:
79 size_t m_maxChars; // max number of chars allowed
80 wxString m_startValue;
82 DECLARE_NO_COPY_CLASS(wxGridCellPathEditor)
85 #endif
87 /////////////////////////////////////////////////////////////////////////////
88 //wxPropertyItem Items
89 class wxPropertyItem
91 public:
92 wxPropertyItem(const wxString &propName, const wxString &curValue,
93 const wxString &helpString, int nItemType, const wxString &cmbItems)
94 : m_NewValue(true)
95 , m_HelpString(helpString)
96 , m_Removed(false)
97 , m_propName(propName)
98 , m_curValue(curValue)
99 , m_nItemType(nItemType)
100 , m_cmbItems(cmbItems)
101 , m_Advanced(false)
103 //m_NewValue = true;
104 //m_HelpString = helpString;
105 //m_Removed = false;
106 //m_propName = propName;
107 //m_curValue = curValue;
108 //m_nItemType = nItemType;
109 //m_cmbItems = cmbItems;
110 //m_Advanced = false;
113 const wxString &GetCurValue() const {
114 return m_curValue;
117 const wxString &GetPropName() const {
118 return m_propName;
121 void SetCurValue(const char *str) {
122 m_curValue = str;
125 void SetPropName(const char *str) {
126 m_propName = str;
129 void SetAdvanced(bool value) {
130 m_Advanced = value;
133 void SetHelpString(const char *str) {
134 m_HelpString = str;
137 bool GetAdvanced() const {
138 return m_Advanced;
141 void SetNewValue(bool value) {
142 m_NewValue = value;
145 bool GetNewValue() const {
146 return m_NewValue;
149 int GetItemType() const {
150 return m_nItemType;
153 const wxString &GetHelpString() const {
154 return m_HelpString;
157 // returns true when this property item is a filepath
158 bool IsFilePath();
160 // returns true when this property item is a dir path
161 bool IsDirPath();
163 private:
164 wxString m_HelpString;
165 wxString m_propName;
166 wxString m_curValue;
167 int m_nItemType;
168 wxString m_cmbItems;
169 bool m_NewValue;
170 bool m_Removed;
171 bool m_Advanced;
174 WX_DEFINE_ARRAY(wxPropertyItem *, wxPropertyItems);
176 /////////////////////////////////////////////////////////////////////////////
177 // wxPropertyList Grid
178 class wxPropertyList : public wxGrid
180 // Construction
181 public:
182 wxPropertyList(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
183 const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS,
184 const wxString& name = wxPanelNameStr)
185 : wxGrid(parent, id, pos, size, style, name)
189 enum ItemType
191 COMBO = 0,
192 EDIT,
193 COLOR,
194 FONT,
195 FILE,
196 CHECKBOX,
197 PATH
200 virtual ~wxPropertyList();
202 public:
203 bool GetShowAdvanced() const {
204 return m_ShowAdvanced;
207 void SetProjectGenerated(bool value) {
208 m_generatedProjects = value;
211 bool IsGenerated() {
212 return m_generatedProjects;
215 int AddItem(const wxString &txt);
217 void AddProperty(const char* name, const char* value, const char* helpString, int type,
218 const char* comboItems, bool reverseOrder, bool advanced);
220 void RemoveProperty(wxPropertyItem *pItem);
222 void HideControls();
223 void ShowAdvanced();
224 void HideAdvanced();
226 void RemoveAll();
228 wxPropertyItem* GetItem(size_t index) {
229 wxCHECK(index < GetCount(), 0);
230 return m_PropertyItems[index];
233 size_t GetCount() const {
234 return m_PropertyItems.Count();
237 const wxPropertyItems &GetItems() {
238 return m_PropertyItems;
241 void SetShowAdvanced(bool value) {
242 m_ShowAdvanced = value;
245 bool UpdatePropertyItem(wxPropertyItem *pItem, int row);
247 /** Returns the row of the grid on which the item is found. -1 is returned when not found */
248 int FindProperty(wxPropertyItem *pItem);
250 /** Returns true when the cache is still dirty, which means
251 after a configuration run, there are still new items */
252 bool IsCacheDirty() {
253 // check if we have items that are new
254 for(size_t i = 0; i < m_PropertyItems.Count(); i++)
256 //if((m_PropertyItems[i]->GetNewValue() && m_ShowAdvanced && m_PropertyItems[i]->GetAdvanced()) ||
257 // (m_PropertyItems[i]->GetNewValue() && !m_ShowAdvanced))
258 if(m_PropertyItems[i]->GetNewValue())
259 return true;
262 // return flag if generated cache or not
263 return false;
266 /** Returns the property item from the current row. 0 if no property item found */
267 wxPropertyItem *GetPropertyItemFromRow(int row);
269 /** Finds the property by name and returns the property item */
270 wxPropertyItem *FindPropertyByName(const wxString &name);
272 /** Sets the search filter. Making sure that the items currently displayed
273 match this substring query */
274 void SetQuery(const wxString &query) {
275 m_strQuery = query;
276 UpdateGridView();
279 /** Returns the last used query. */
280 const wxString &GetQuery() {
281 return m_strQuery;
284 /** Function that tries to browse for the item that is selected */
285 void BrowseSelectedItem();
287 /** Returns true when the item is browsable (file or path) and only one item is
288 selected */
289 bool IsSelectedItemBrowsable(int row = -1);
291 private:
292 // order = 0 sorted
293 // order = 1 add to top
294 // order = 2 add to bottom
295 int AddPropItem(wxPropertyItem* pItem, int order);
297 /** Adds the property item to the grid. */
298 int AddPropertyToGrid(wxPropertyItem *pItem, int order) ;
300 /** Adds / removes all the items that are currently (not) matching the
301 query filter */
302 void UpdateGridView();
304 void OnSelectCell( wxGridEvent& event );
306 void OnCellChange( wxGridEvent& event );
308 void OnCellPopup( wxGridEvent& event );
310 void OnIgnoreCache( wxCommandEvent& event );
312 void OnDeleteCache( wxCommandEvent& event );
314 void OnSizeGrid( wxSizeEvent &event );
316 void OnBrowseItem( wxCommandEvent& event );
318 void OnKeyPressed( wxKeyEvent &event );
320 int m_curSel;
321 int m_prevSel;
322 int m_nDivider;
323 int m_nDivTop;
324 int m_nDivBtm;
325 int m_nOldDivX;
326 int m_nLastBox;
327 bool m_bTracking;
328 bool m_bDivIsSet;
329 bool m_ShowAdvanced;
330 // flag to indicate the last cache load has resulted
331 // in generating a valid project
332 bool m_generatedProjects;
333 wxString m_strQuery;
334 wxPropertyItems m_PropertyItems;
336 DECLARE_EVENT_TABLE()
339 #endif