]> git.saurik.com Git - wxWidgets.git/blame - utils/dialoged/src/winstyle.cpp
more files to ignore in cvs commands (setup.h, lex_yy.c, y_tab.c)
[wxWidgets.git] / utils / dialoged / src / winstyle.cpp
CommitLineData
7c23a0b0
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: winstyle.cpp
3// Purpose: Window styles
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "winstyle.h"
14#endif
15
16// For compilers that support precompilation, includes "wx/wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include "wx/wx.h"
25#endif
26
27#include <ctype.h>
28#include <stdlib.h>
29#include <math.h>
30#include <string.h>
31
32#include "winstyle.h"
33
34/*
35 * Styles
36 */
37
38 /* wxListBox */
39static wxWindowStylePair g_WindowStylesListBox[] = {
40 { "wxLB_SINGLE", wxLB_SINGLE },
41 { "wxLB_MULTIPLE", wxLB_MULTIPLE },
42 { "wxLB_EXTENDED", wxLB_EXTENDED },
43 { "wxLB_NEEDED_SB", wxLB_NEEDED_SB },
44 { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB },
45 { "wxLB_SORT", wxLB_SORT },
46 { "wxLB_OWNERDRAW", wxLB_OWNERDRAW },
47 { "wxLB_HSCROLL", wxLB_HSCROLL }
48};
49
50int g_WindowStylesListBoxCount = sizeof(g_WindowStylesListBox)/sizeof(wxWindowStylePair) ;
51
52 /* wxComboxBox */
53static wxWindowStylePair g_WindowStylesComboBox[] = {
54 { "wxCB_SIMPLE", wxCB_SIMPLE },
55 { "wxCB_DROPDOWN", wxCB_DROPDOWN },
56 { "wxCB_READONLY", wxCB_READONLY },
57 { "wxCB_SORT", wxCB_SORT }
58};
59
60int g_WindowStylesComboBoxCount = sizeof(g_WindowStylesComboBox)/sizeof(wxWindowStylePair) ;
61
62#if 0
63 /* wxChoice */
64static wxWindowStylePair g_WindowStylesChoice[] = {
65};
66
67int g_WindowStylesChoiceCount = sizeof(g_WindowStylesChoice)/sizeof(wxWindowStylePair) ;
68#endif
69
70 /* wxGauge */
71static wxWindowStylePair g_WindowStylesGauge[] = {
72 { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR },
73 { "wxGA_HORIZONTAL", wxGA_HORIZONTAL },
74 { "wxGA_VERTICAL", wxGA_VERTICAL }
75};
76
77int g_WindowStylesGaugeCount = sizeof(g_WindowStylesGauge)/sizeof(wxWindowStylePair) ;
78
79 /* wxTextCtrl */
80static wxWindowStylePair g_WindowStylesTextCtrl[] = {
81 { "wxPASSWORD", wxPASSWORD},
82 { "wxPROCESS_ENTER", wxPROCESS_ENTER},
83 { "wxTE_PASSWORD", wxTE_PASSWORD},
84 { "wxTE_READONLY", wxTE_READONLY},
85 { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER},
86 { "wxTE_MULTILINE", wxTE_MULTILINE}
87};
88
89int g_WindowStylesTextCtrlCount = sizeof(g_WindowStylesTextCtrl)/sizeof(wxWindowStylePair) ;
90
91 /* wxRadioButton */
92static wxWindowStylePair g_WindowStylesRadioButton[] = {
93 { "wxRB_GROUP", wxRB_GROUP }
94};
95
96int g_WindowStylesRadioButtonCount = sizeof(g_WindowStylesRadioButton)/sizeof(wxWindowStylePair) ;
97
98 /* wxRadioBox */
99static wxWindowStylePair g_WindowStylesRadioBox[] = {
94b49b93
JS
100 { "wxRA_SPECIFY_COLS", wxRA_SPECIFY_COLS },
101 { "wxRA_SPECIFY_ROWS", wxRA_SPECIFY_ROWS },
7c23a0b0
JS
102 { "wxRA_HORIZONTAL", wxRA_HORIZONTAL },
103 { "wxRA_VERTICAL", wxRA_VERTICAL }
104};
105
106int g_WindowStylesRadioBoxCount = sizeof(g_WindowStylesRadioBox)/sizeof(wxWindowStylePair) ;
107
108 /* wxSlider */
109static wxWindowStylePair g_WindowStylesSlider[] = {
110 { "wxSL_HORIZONTAL", wxSL_HORIZONTAL },
111 { "wxSL_VERTICAL", wxSL_VERTICAL },
112 { "wxSL_AUTOTICKS", wxSL_AUTOTICKS },
113 { "wxSL_LABELS", wxSL_LABELS },
114 { "wxSL_LEFT", wxSL_LEFT },
115 { "wxSL_TOP", wxSL_TOP },
116 { "wxSL_RIGHT", wxSL_RIGHT },
117 { "wxSL_BOTTOM", wxSL_BOTTOM },
118 { "wxSL_BOTH", wxSL_BOTH },
119 { "wxSL_SELRANGE", wxSL_SELRANGE }
120};
121
122int g_WindowStylesSliderCount = sizeof(g_WindowStylesSlider)/sizeof(wxWindowStylePair) ;
123
124 /* wxScrollBar */
125static wxWindowStylePair g_WindowStylesScrollBar[] = {
126 { "wxSB_HORIZONTAL", wxSB_HORIZONTAL },
127 { "wxSB_VERTICAL", wxSB_VERTICAL }
128};
129
130int g_WindowStylesScrollBarCount = sizeof(g_WindowStylesScrollBar)/sizeof(wxWindowStylePair) ;
131
132 /* wxButton */
133static wxWindowStylePair g_WindowStylesButton[] = {
134 { "wxBU_AUTODRAW", wxBU_AUTODRAW },
135 { "wxBU_NOAUTODRAW", wxBU_NOAUTODRAW }
136};
137
138int g_WindowStylesButtonCount = sizeof(g_WindowStylesButton)/sizeof(wxWindowStylePair) ;
139
140 /* wxTreeCtrl */
141static wxWindowStylePair g_WindowStylesTreeCtrl[] = {
142 { "wxTR_HAS_BUTTONS", wxTR_HAS_BUTTONS },
143 { "wxTR_EDIT_LABELS", wxTR_EDIT_LABELS },
144 { "wxTR_LINES_AT_ROOT", wxTR_LINES_AT_ROOT }
145};
146
147int g_WindowStylesTreeCtrlCount = sizeof(g_WindowStylesTreeCtrl)/sizeof(wxWindowStylePair) ;
148
149 /* wxListCtrl */
150static wxWindowStylePair g_WindowStylesListCtrl[] = {
151 { "wxLC_ICON", wxLC_ICON },
152 { "wxLC_SMALL_ICON", wxLC_SMALL_ICON },
153 { "wxLC_LIST", wxLC_LIST },
154 { "wxLC_REPORT", wxLC_REPORT },
155 { "wxLC_ALIGN_TOP", wxLC_ALIGN_TOP },
156 { "wxLC_ALIGN_LEFT", wxLC_ALIGN_LEFT },
157 { "wxLC_AUTOARRANGE", wxLC_AUTOARRANGE },
158 { "wxLC_USER_TEXT", wxLC_USER_TEXT },
159 { "wxLC_EDIT_LABELS", wxLC_EDIT_LABELS },
160 { "wxLC_NO_HEADER", wxLC_NO_HEADER },
161 { "wxLC_NO_SORT_HEADER", wxLC_NO_SORT_HEADER },
162 { "wxLC_SINGLE_SEL", wxLC_SINGLE_SEL },
163 { "wxLC_SORT_ASCENDING", wxLC_SORT_ASCENDING },
164 { "wxLC_SORT_DESCENDING", wxLC_SORT_DESCENDING }
165};
166
167int g_WindowStylesListCtrlCount = sizeof(g_WindowStylesListCtrl)/sizeof(wxWindowStylePair) ;
168
169 /* wxSpinButton */
170static wxWindowStylePair g_WindowStylesSpinButton[] = {
171 { "wxSP_VERTICAL", wxSP_VERTICAL},
172 { "wxSP_HORIZONTAL", wxSP_HORIZONTAL},
173 { "wxSP_ARROW_KEYS", wxSP_ARROW_KEYS},
174 { "wxSP_WRAP", wxSP_WRAP}
175};
176
177int g_WindowStylesSpinButtonCount = sizeof(g_WindowStylesSpinButton)/sizeof(wxWindowStylePair) ;
178
179 /* wxSplitterWindow */
180static wxWindowStylePair g_WindowStylesSplitterWindow[] = {
181 { "wxSP_NOBORDER", wxSP_NOBORDER},
182 { "wxSP_3D", wxSP_3D},
183 { "wxSP_BORDER", wxSP_BORDER}
184};
185
186int g_WindowStylesSplitterWindowCount = sizeof(g_WindowStylesSplitterWindow)/sizeof(wxWindowStylePair) ;
187
188 /* wxTabCtrl */
189static wxWindowStylePair g_WindowStylesTabCtrl[] = {
190 { "wxTC_MULTILINE", wxTC_MULTILINE},
191 { "wxTC_RIGHTJUSTIFY", wxTC_RIGHTJUSTIFY},
192 { "wxTC_FIXEDWIDTH", wxTC_FIXEDWIDTH},
193 { "wxTC_OWNERDRAW", wxTC_OWNERDRAW}
194};
195
196int g_WindowStylesTabCtrlCount = sizeof(g_WindowStylesTabCtrl)/sizeof(wxWindowStylePair) ;
197
198 /* wxStatusBar95 */
199static wxWindowStylePair g_WindowStylesStatusBar[] = {
200 { "wxST_SIZEGRIP", wxST_SIZEGRIP}
201};
202
203int g_WindowStylesStatusBarCount = sizeof(g_WindowStylesStatusBar)/sizeof(wxWindowStylePair) ;
204
205 /* wxControl */
206static wxWindowStylePair g_WindowStylesControl[] = {
207 { "wxFIXED_LENGTH", wxFIXED_LENGTH},
208 { "wxALIGN_LEFT", wxALIGN_LEFT},
209 { "wxALIGN_CENTRE", wxALIGN_CENTRE},
210 { "wxALIGN_RIGHT", wxALIGN_RIGHT},
211 { "wxCOLOURED", wxCOLOURED}
212};
213
214int g_WindowStylesControlCount = sizeof(g_WindowStylesControl)/sizeof(wxWindowStylePair) ;
215
216 /* wxToolBar */
217static wxWindowStylePair g_WindowStylesToolBar[] = {
218 { "wxTB_3DBUTTONS", wxTB_3DBUTTONS},
219 { "wxTB_HORIZONTAL", wxTB_HORIZONTAL},
220 { "wxTB_VERTICAL", wxTB_VERTICAL},
221 { "wxTB_FLAT", wxTB_FLAT}
222};
223
224int g_WindowStylesToolBarCount = sizeof(g_WindowStylesToolBar)/sizeof(wxWindowStylePair) ;
225
226 /* Frame/dialog */
227static wxWindowStylePair g_WindowStylesDialog[] = {
228 { "wxSTAY_ON_TOP", wxSTAY_ON_TOP},
229 { "wxCAPTION", wxCAPTION},
230 { "wxICONIZE", wxICONIZE},
231 { "wxMINIMIZE", wxICONIZE},
232 { "wxMAXIMIZE", wxMAXIMIZE},
233 { "wxTHICK_FRAME", wxTHICK_FRAME},
234 { "wxRESIZE_BORDER", wxRESIZE_BORDER},
235 { "wxSYSTEM_MENU", wxSYSTEM_MENU},
236 { "wxMINIMIZE_BOX", wxMINIMIZE_BOX},
237 { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX},
238 { "wxRESIZE_BOX", wxRESIZE_BOX}
239};
240
241int g_WindowStylesDialogCount = sizeof(g_WindowStylesDialog)/sizeof(wxWindowStylePair) ;
242
243 /* Generic */
244static wxWindowStylePair g_WindowStylesWindow[] = {
245 { "wxBORDER", wxBORDER},
246 { "wxDOUBLE_BORDER", wxDOUBLE_BORDER},
247 { "wxSUNKEN_BORDER", wxSUNKEN_BORDER},
248 { "wxRAISED_BORDER", wxRAISED_BORDER},
249 { "wxSIMPLE_BORDER", wxSIMPLE_BORDER},
250 { "wxSTATIC_BORDER", wxSTATIC_BORDER},
251 { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW},
252 { "wxNO_BORDER", wxNO_BORDER},
9c331ded
JS
253 { "wxCLIP_CHILDREN", wxCLIP_CHILDREN}
254
255/* Would be duplicated with e.g. wxLB_HSCROLL
7c23a0b0
JS
256 { "wxVSCROLL", wxVSCROLL },
257 { "wxHSCROLL", wxHSCROLL }
9c331ded 258*/
7c23a0b0
JS
259};
260
261int g_WindowStylesWindowCount = sizeof(g_WindowStylesWindow)/sizeof(wxWindowStylePair) ;
262
263/*
264 * A table holding all class style objects
265 */
266
267
268wxWindowStyleTable::wxWindowStyleTable():
269 m_classes(wxKEY_STRING)
270{
271}
272
273wxWindowStyleTable::~wxWindowStyleTable()
274{
275 ClearTable();
276}
277
278void wxWindowStyleTable::Init()
279{
280 AddStyles("wxWindow", g_WindowStylesWindowCount, g_WindowStylesWindow);
281 AddStyles("wxDialog", g_WindowStylesDialogCount, g_WindowStylesDialog);
282 AddStyles("wxButton", g_WindowStylesButtonCount, g_WindowStylesButton);
283 AddStyles("wxTextCtrl", g_WindowStylesTextCtrlCount, g_WindowStylesTextCtrl);
284 AddStyles("wxSpinButton", g_WindowStylesSpinButtonCount, g_WindowStylesSpinButton);
285 AddStyles("wxListBox", g_WindowStylesListBoxCount, g_WindowStylesListBox);
286 AddStyles("wxRadioButton", g_WindowStylesRadioButtonCount, g_WindowStylesRadioButton);
287 AddStyles("wxRadioBox", g_WindowStylesRadioBoxCount, g_WindowStylesRadioBox);
288 AddStyles("wxControl", g_WindowStylesControlCount, g_WindowStylesControl);
289 AddStyles("wxListCtrl", g_WindowStylesListCtrlCount, g_WindowStylesListCtrl);
290 AddStyles("wxTreeCtrl", g_WindowStylesTreeCtrlCount, g_WindowStylesTreeCtrl);
291 AddStyles("wxSlider", g_WindowStylesSliderCount, g_WindowStylesSlider);
292 AddStyles("wxGauge", g_WindowStylesGaugeCount, g_WindowStylesGauge);
293 AddStyles("wxComboBox", g_WindowStylesComboBoxCount, g_WindowStylesComboBox);
294// AddStyles("wxChoice", g_WindowStylesChoice, g_WindowStylesChoice);
295 AddStyles("wxScrollBar", g_WindowStylesScrollBarCount, g_WindowStylesScrollBar);
296}
297
298// Operations
299void wxWindowStyleTable::ClearTable()
300{
301 wxNode* node = m_classes.First();
302 while (node)
303 {
304 wxWindowStyleClass* styleClass = (wxWindowStyleClass*) node->Data();
305 delete styleClass;
306 node = node->Next();
307 }
308 m_classes.Clear();
309}
310
311void wxWindowStyleTable::AddStyles(const wxString& className, int n, wxWindowStylePair *styles)
312{
313 wxWindowStyleClass* styleClass = new wxWindowStyleClass(n, styles);
314 m_classes.Append(className, styleClass);
315}
316
317wxWindowStyleClass* wxWindowStyleTable::FindClass(const wxString& className)
318{
319 wxNode* node = m_classes.Find(className);
320 if (node)
321 {
322 wxWindowStyleClass* styleClass = (wxWindowStyleClass*) node->Data();
323 return styleClass;
324 }
325 else
326 return NULL;
327}
328
329bool wxWindowStyleTable::GenerateStyleStrings(const wxString& className, long windowStyle, char *buf)
330{
331 wxWindowStyleClass* styleClass = FindClass(className);
332 if (!styleClass)
333 return FALSE;
334
335 styleClass->GenerateStyleStrings(windowStyle, buf);
336 return TRUE;
337}
338
339/*
340 * Holds all the styles for a particular class
341 */
342
343wxWindowStyleClass::wxWindowStyleClass(int n, wxWindowStylePair *styles)
344{
345 m_styleCount = n;
346 m_styles = styles;
347/*
348 m_styles = new wxWindowStylePair[n];
349 int i;
350 for (i = 0; i < n; i++)
351 m_styles[i] = styles[i];
352*/
353}
354
355wxWindowStyleClass::~wxWindowStyleClass()
356{
357}
358
359void wxWindowStyleClass::GenerateStyleStrings(long windowStyle, char *buf)
360{
361 int i;
362 for (i = 0; i < m_styleCount; i++)
363 GenerateStyle(buf, windowStyle, m_styles[i].m_styleId, m_styles[i].m_styleName);
364}
365
366bool wxWindowStyleClass::GenerateStyle(char *buf, long windowStyle, long flag, const wxString& strStyle)
367{
368 // Ignore zero flags
369 if (flag == 0)
370 return TRUE;
371
372 if ((windowStyle & flag) == flag)
373 {
374 if (strlen(buf) > 0)
375 strcat(buf, " | ");
376 strcat(buf, (const char*) strStyle);
377 return TRUE;
378 }
379 else
380 return FALSE;
381}
382