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