]> git.saurik.com Git - wxWidgets.git/blame - utils/configtool/src/propeditor.h
fixed previous revision: call wxControl's, not wxButton's DoGetBestSize
[wxWidgets.git] / utils / configtool / src / propeditor.h
CommitLineData
d7463f75
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: propeditor.cpp
be5a51fb 3// Purpose: Property editor for wxWidgets configuration tool
d7463f75
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 2003-06-03
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence:
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _CT_PROPEDITOR_H_
13#define _CT_PROPEDITOR_H_
14
71ada1a5 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
d7463f75
JS
16#pragma interface "propeditor.cpp"
17#endif
18
19#include "wx/splitter.h"
20#include "wx/grid.h"
21
22#include "configitem.h"
23#include "property.h"
24
25class WXDLLEXPORT wxHtmlWindow;
26
27class ctPropertyEditorGrid;
28
29/*!
30 * A container window for the property editor.
31 */
32
33class ctPropertyEditor: public wxPanel
34{
35 DECLARE_CLASS(ctPropertyEditor)
36 public:
37 ctPropertyEditor(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
254a2129 38 ~ctPropertyEditor(){};
d7463f75
JS
39
40// Event handlers
41
42 /// Handles detailed editing event.
43 void OnEditDetails(wxCommandEvent& event);
44
45 /// Handles detailed editing update event.
46 void OnUpdateEditDetails(wxUpdateUIEvent& event);
47
48 /// Intercept selection event.
49 void OnSelectCell(wxGridEvent& event);
50
51 /// Intercept cell data change event.
52 void OnChangeCell(wxGridEvent& event);
53
54 /// Double-click to show specialised editor.
55 void OnDClickCell(wxGridEvent& event);
56
57// Operations
58
59 /// Creates the controls
60 void CreateControls(wxWindow* parent);
61
62 /// Clear grid editor
63 void ClearEditor();
64
65 /// Can we edit the details of the selected property?
66 bool CanEditDetails();
67
68 /// Edit the details of this cell appropriately.
69 bool EditDetails(wxWindow* parent);
70
71 /// Shows the given config item
72 void ShowItem(ctConfigItem* configItem);
73
74 /// Updates the proxy display, assuming it was already displayed.
75 void UpdateItem();
76
77 /// Display attribute at given row
4fe30bce 78 bool DisplayProperty(int row, ctProperty* prop, bool valueOnly = false);
d7463f75
JS
79
80 /// Display attribute value
81 bool DisplayProperty(ctProperty* prop);
82
83 /// Edit the default property
84 bool EditDefaultProperty(ctConfigItem* proxy);
85
86 /// Select the default property
87 bool DisplayDefaultProperty();
88
89 /// Determine background colour for this property.
90 void DeterminePropertyColour(ctProperty* prop, wxColour& colour);
91
92 /// Update the title at the top of the property editor
93 void UpdateTitle();
94
95 /// Update the description
96 void UpdateDescription(int row = -1);
97
98 /// Wraps a description string in HTML
99 wxString WrapDescription(const wxString& str);
100
101 /// Find the selected property
102 ctProperty* FindSelectedProperty(int& row);
103
104 /// Find the nth property
105 ctProperty* FindProperty(int row);
106
107 /// Apply the cell value to the property, and notify the
108 /// proxy object.
109 void ApplyCellValueToProperty(int row, int col);
110
111 /// Apply the cell value to the property, and notify the
112 /// proxy object. This will be undoable.
113 void ApplyPropertyValue(ctConfigItem* item, ctProperty* property, const wxVariant& variant);
114
115 /// Show/hide the description control
116 void ShowDescriptionWindow(bool show);
117
118// Accessors
119
120 //// Returns the grid used as the attribute editor
121 ctPropertyEditorGrid* GetAttributeEditorGrid() const { return m_attributeEditorGrid; }
122
123 /// Returns the title text control
124 wxTextCtrl* GetElementTitleTextCtrl() const { return m_elementTitleTextCtrl; }
125
126 /// Returns the splitter window between the property grid and
127 /// the description window.
128 wxSplitterWindow* GetSplitterWindow() const { return m_splitterWindow; }
129
130 /// Returns the HTML description window
131 wxHtmlWindow* GetDescriptionWindow() const { return m_propertyDescriptionWindow; }
132
133 /// Returns the config item
134 ctConfigItem* GetItem() const { return m_item; }
135
136 /// Sets the proxy
137 void SetItem(ctConfigItem* configItem) { m_item = configItem; }
138
139DECLARE_EVENT_TABLE()
140
141protected:
d9ab621e
WS
142 // Dialog controls
143 wxButton* m_attributeEditorEditDetails;
d7463f75
JS
144 ctPropertyEditorGrid* m_attributeEditorGrid;
145 wxHtmlWindow* m_propertyDescriptionWindow;
146 wxSplitterWindow* m_splitterWindow;
147
148 // Displays the title of the element being edited
149 wxTextCtrl* m_elementTitleTextCtrl;
150
151 // The config item object being edited
152 ctConfigItem* m_item;
153};
154
155#define ctID_ATTRIBUTE_EDITOR_INSERT 2001
156#define ctID_ATTRIBUTE_EDITOR_GRID 2002
157#define ctID_ATTRIBUTE_EDITOR_DESCRIPTION 2003
158#define ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS 2004
159
160/*!
161 * Attribute editor grid
162 */
163
164class ctPropertyEditorGrid: public wxGrid
165{
166DECLARE_CLASS(ctPropertyEditorGrid)
167public:
168 ctPropertyEditorGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
169 const wxSize& sz = wxDefaultSize, long style = wxWANTS_CHARS);
170
171 /// Intercept size event.
172 void OnSize(wxSizeEvent& event);
173
174 void SetStretchableColumn(int which) { m_stretchableColumn = which; }
175 int GetStretchableColumn() const { return m_stretchableColumn; }
176
177 /// An array denoting which columns to display,
178 /// and in what order.
179 void SetColumnsToDisplay(wxArrayString& columns) { m_columnsToDisplay = columns; }
180 wxArrayString& GetColumnsToDisplay() { return m_columnsToDisplay; }
181
182 /// Use m_columnsToDisplay to set the label strings
183 void DisplayLabels();
184
185 /// Clear attributes
186 bool ClearAttributes();
187
188DECLARE_EVENT_TABLE()
189
190private:
191 int m_stretchableColumn;
192 wxArrayString m_columnsToDisplay;
193};
194
195// Utility functions
196
197/// Translate the value to one which can be edited in a single-line
198/// text control
199wxString ctConvertToSingleText(const wxString& value);
200
201/// Translate back to 'real' characters, i.e. newlines are real
202/// newlines.
203wxString ctConvertToMultilineText(const wxString& value);
204
205//----------------------------------------------------------------------------
206// ctMultiLineTextEditor
207//----------------------------------------------------------------------------
208
209class ctMultiLineTextEditor: public wxDialog
210{
211public:
212 // constructors and destructors
213 ctMultiLineTextEditor( wxWindow *parent, wxWindowID id, const wxString &title,
214 const wxString& msg,
215 const wxString& value,
216 const wxPoint& pos = wxDefaultPosition,
217 const wxSize& size = wxDefaultSize,
218 long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
254a2129 219
d7463f75
JS
220 bool AddControls(wxWindow* parent, const wxString& msg);
221
222 wxString GetText() const { return m_text; }
223 void SetText(const wxString& text) { m_text = text; }
224
225private:
226 DECLARE_EVENT_TABLE()
227 wxString m_text;
228};
229
230/*
231 * Special-purpose splitter window for changing sash look and
232 * also saving sash width
233 */
254a2129 234
d7463f75
JS
235class ctSplitterWindow: public wxSplitterWindow
236{
237public:
238 ctSplitterWindow(wxWindow* parent, wxWindowID id,
239 const wxPoint& pos, const wxSize& size, long style);
240
241 // Draws the sash
242 //virtual void DrawSash(wxDC& dc);
243
244 void OnChangeSash(wxSplitterEvent& event);
245
246 void UpdateSettings(bool updateSettings) { m_updateSettings = updateSettings; }
247
248 int GetLastPosition() const { return m_position; }
249 void SetLastPosition(int pos) { m_position = pos; }
250
251protected:
252 // Don't update settings if the window is still being created,
253 // since it could override the saved settings
254 bool m_updateSettings;
255 int m_position;
256
257DECLARE_EVENT_TABLE()
258};
259
260/*!
261 * Use a single-line text control.
262 */
263
264class ctGridCellTextEditor: public wxGridCellTextEditor
265{
266public:
267 virtual void Create(wxWindow* parent, wxWindowID id,
268 wxEvtHandler* evtHandler);
269};
270
271#define ctGRID_VALUE_STRING wxT("singlelinestring")
272
273#define ctID_PROPERTY_EDITOR_SPLITTER 1600
274
275#endif
276 // _WB_PROPEDITOR_H_
277