1 /*=========================================================================
3 Program: WXDialog - wxWidgets X-platform GUI Front-End for CMake
4 Module: $RCSfile: PropertyList.h,v $
6 Date: $Date: 2005/06/30 19:54:14 $
7 Version: $Revision: 1.1 $
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
28 #include <wx/dynarray.h>
31 #include "../cmStandardIncludes.h"
34 #define MC_DEFAULT_WILDCARD "*"
36 #define MC_DEFAULT_WILDCARD "*.*"
41 // the editor for string/text data
42 class wxGridCellPathEditor
: public wxGridCellEditor
45 wxGridCellPathEditor();
47 virtual void Create(wxWindow
* parent
,
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
);
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
; }
69 // added GetValue so we can get the value which is in the control
70 virtual wxString
GetValue() const;
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
);
79 size_t m_maxChars
; // max number of chars allowed
80 wxString m_startValue
;
82 DECLARE_NO_COPY_CLASS(wxGridCellPathEditor
)
87 /////////////////////////////////////////////////////////////////////////////
88 //wxPropertyItem Items
92 wxPropertyItem(const wxString
&propName
, const wxString
&curValue
,
93 const wxString
&helpString
, int nItemType
, const wxString
&cmbItems
)
95 , m_HelpString(helpString
)
97 , m_propName(propName
)
98 , m_curValue(curValue
)
99 , m_nItemType(nItemType
)
100 , m_cmbItems(cmbItems
)
104 //m_HelpString = helpString;
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 {
117 const wxString
&GetPropName() const {
121 void SetCurValue(const char *str
) {
125 void SetPropName(const char *str
) {
129 void SetAdvanced(bool value
) {
133 void SetHelpString(const char *str
) {
137 bool GetAdvanced() const {
141 void SetNewValue(bool value
) {
145 bool GetNewValue() const {
149 int GetItemType() const {
153 const wxString
&GetHelpString() const {
157 // returns true when this property item is a filepath
160 // returns true when this property item is a dir path
164 wxString m_HelpString
;
174 WX_DEFINE_ARRAY(wxPropertyItem
*, wxPropertyItems
);
176 /////////////////////////////////////////////////////////////////////////////
177 // wxPropertyList Grid
178 class wxPropertyList
: public wxGrid
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
)
200 virtual ~wxPropertyList();
203 bool GetShowAdvanced() const {
204 return m_ShowAdvanced
;
207 void SetProjectGenerated(bool value
) {
208 m_generatedProjects
= value
;
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
);
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())
262 // return flag if generated cache or not
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
) {
279 /** Returns the last used query. */
280 const wxString
&GetQuery() {
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
289 bool IsSelectedItemBrowsable(int row
= -1);
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
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
);
330 // flag to indicate the last cache load has resulted
331 // in generating a valid project
332 bool m_generatedProjects
;
334 wxPropertyItems m_PropertyItems
;
336 DECLARE_EVENT_TABLE()