]> git.saurik.com Git - wxWidgets.git/blame - utils/configtool/src/propeditor.h
regenerated with DESTDIR fixes
[wxWidgets.git] / utils / configtool / src / propeditor.h
CommitLineData
d7463f75
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: propeditor.cpp
3// Purpose: Property editor for wxWindows configuration tool
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);
38 ~ctPropertyEditor();
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
78 bool DisplayProperty(int row, ctProperty* prop, bool valueOnly = FALSE);
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:
142 ctPropertyEditorGrid* m_attributeEditorGrid;
143 wxHtmlWindow* m_propertyDescriptionWindow;
144 wxSplitterWindow* m_splitterWindow;
145
146 // Displays the title of the element being edited
147 wxTextCtrl* m_elementTitleTextCtrl;
148
149 // The config item object being edited
150 ctConfigItem* m_item;
151};
152
153#define ctID_ATTRIBUTE_EDITOR_INSERT 2001
154#define ctID_ATTRIBUTE_EDITOR_GRID 2002
155#define ctID_ATTRIBUTE_EDITOR_DESCRIPTION 2003
156#define ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS 2004
157
158/*!
159 * Attribute editor grid
160 */
161
162class ctPropertyEditorGrid: public wxGrid
163{
164DECLARE_CLASS(ctPropertyEditorGrid)
165public:
166 ctPropertyEditorGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
167 const wxSize& sz = wxDefaultSize, long style = wxWANTS_CHARS);
168
169 /// Intercept size event.
170 void OnSize(wxSizeEvent& event);
171
172 void SetStretchableColumn(int which) { m_stretchableColumn = which; }
173 int GetStretchableColumn() const { return m_stretchableColumn; }
174
175 /// An array denoting which columns to display,
176 /// and in what order.
177 void SetColumnsToDisplay(wxArrayString& columns) { m_columnsToDisplay = columns; }
178 wxArrayString& GetColumnsToDisplay() { return m_columnsToDisplay; }
179
180 /// Use m_columnsToDisplay to set the label strings
181 void DisplayLabels();
182
183 /// Clear attributes
184 bool ClearAttributes();
185
186DECLARE_EVENT_TABLE()
187
188private:
189 int m_stretchableColumn;
190 wxArrayString m_columnsToDisplay;
191};
192
193// Utility functions
194
195/// Translate the value to one which can be edited in a single-line
196/// text control
197wxString ctConvertToSingleText(const wxString& value);
198
199/// Translate back to 'real' characters, i.e. newlines are real
200/// newlines.
201wxString ctConvertToMultilineText(const wxString& value);
202
203//----------------------------------------------------------------------------
204// ctMultiLineTextEditor
205//----------------------------------------------------------------------------
206
207class ctMultiLineTextEditor: public wxDialog
208{
209public:
210 // constructors and destructors
211 ctMultiLineTextEditor( wxWindow *parent, wxWindowID id, const wxString &title,
212 const wxString& msg,
213 const wxString& value,
214 const wxPoint& pos = wxDefaultPosition,
215 const wxSize& size = wxDefaultSize,
216 long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
217
218 bool AddControls(wxWindow* parent, const wxString& msg);
219
220 wxString GetText() const { return m_text; }
221 void SetText(const wxString& text) { m_text = text; }
222
223private:
224 DECLARE_EVENT_TABLE()
225 wxString m_text;
226};
227
228/*
229 * Special-purpose splitter window for changing sash look and
230 * also saving sash width
231 */
232
233class ctSplitterWindow: public wxSplitterWindow
234{
235public:
236 ctSplitterWindow(wxWindow* parent, wxWindowID id,
237 const wxPoint& pos, const wxSize& size, long style);
238
239 // Draws the sash
240 //virtual void DrawSash(wxDC& dc);
241
242 void OnChangeSash(wxSplitterEvent& event);
243
244 void UpdateSettings(bool updateSettings) { m_updateSettings = updateSettings; }
245
246 int GetLastPosition() const { return m_position; }
247 void SetLastPosition(int pos) { m_position = pos; }
248
249protected:
250 // Don't update settings if the window is still being created,
251 // since it could override the saved settings
252 bool m_updateSettings;
253 int m_position;
254
255DECLARE_EVENT_TABLE()
256};
257
258/*!
259 * Use a single-line text control.
260 */
261
262class ctGridCellTextEditor: public wxGridCellTextEditor
263{
264public:
265 virtual void Create(wxWindow* parent, wxWindowID id,
266 wxEvtHandler* evtHandler);
267};
268
269#define ctGRID_VALUE_STRING wxT("singlelinestring")
270
271#define ctID_PROPERTY_EDITOR_SPLITTER 1600
272
273#endif
274 // _WB_PROPEDITOR_H_
275