1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Window styles
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "winstyle.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/listctrl.h"
28 #include "wx/treectrl.h"
42 static wxWindowStylePair g_WindowStylesListBox
[] = {
43 { "wxLB_SINGLE", wxLB_SINGLE
},
44 { "wxLB_MULTIPLE", wxLB_MULTIPLE
},
45 { "wxLB_EXTENDED", wxLB_EXTENDED
},
46 { "wxLB_NEEDED_SB", wxLB_NEEDED_SB
},
47 { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB
},
48 { "wxLB_SORT", wxLB_SORT
},
49 { "wxLB_OWNERDRAW", wxLB_OWNERDRAW
},
50 { "wxLB_HSCROLL", wxLB_HSCROLL
}
53 int g_WindowStylesListBoxCount
= sizeof(g_WindowStylesListBox
)/sizeof(wxWindowStylePair
) ;
56 static wxWindowStylePair g_WindowStylesComboBox
[] = {
57 { "wxCB_SIMPLE", wxCB_SIMPLE
},
58 { "wxCB_DROPDOWN", wxCB_DROPDOWN
},
59 { "wxCB_READONLY", wxCB_READONLY
},
60 { "wxCB_SORT", wxCB_SORT
}
63 int g_WindowStylesComboBoxCount
= sizeof(g_WindowStylesComboBox
)/sizeof(wxWindowStylePair
) ;
67 static wxWindowStylePair g_WindowStylesChoice
[] = {
70 int g_WindowStylesChoiceCount
= sizeof(g_WindowStylesChoice
)/sizeof(wxWindowStylePair
) ;
74 static wxWindowStylePair g_WindowStylesGauge
[] = {
75 { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR
},
76 { "wxGA_HORIZONTAL", wxGA_HORIZONTAL
},
77 { "wxGA_VERTICAL", wxGA_VERTICAL
}
80 int g_WindowStylesGaugeCount
= sizeof(g_WindowStylesGauge
)/sizeof(wxWindowStylePair
) ;
83 static wxWindowStylePair g_WindowStylesTextCtrl
[] = {
84 // { "wxPASSWORD", wxPASSWORD},
85 // { "wxPROCESS_ENTER", wxPROCESS_ENTER},
86 { "wxTE_PASSWORD", wxTE_PASSWORD
},
87 { "wxTE_READONLY", wxTE_READONLY
},
88 { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER
},
89 { "wxTE_MULTILINE", wxTE_MULTILINE
}
92 int g_WindowStylesTextCtrlCount
= sizeof(g_WindowStylesTextCtrl
)/sizeof(wxWindowStylePair
) ;
95 static wxWindowStylePair g_WindowStylesRadioButton
[] = {
96 { "wxRB_GROUP", wxRB_GROUP
}
99 int g_WindowStylesRadioButtonCount
= sizeof(g_WindowStylesRadioButton
)/sizeof(wxWindowStylePair
) ;
102 static wxWindowStylePair g_WindowStylesRadioBox
[] = {
103 { "wxRA_SPECIFY_COLS", wxRA_SPECIFY_COLS
},
104 { "wxRA_SPECIFY_ROWS", wxRA_SPECIFY_ROWS
}
107 { "wxRA_HORIZONTAL", wxRA_HORIZONTAL },
108 { "wxRA_VERTICAL", wxRA_VERTICAL }
112 int g_WindowStylesRadioBoxCount
= sizeof(g_WindowStylesRadioBox
)/sizeof(wxWindowStylePair
) ;
115 static wxWindowStylePair g_WindowStylesSlider
[] = {
116 { "wxSL_HORIZONTAL", wxSL_HORIZONTAL
},
117 { "wxSL_VERTICAL", wxSL_VERTICAL
},
118 { "wxSL_AUTOTICKS", wxSL_AUTOTICKS
},
119 { "wxSL_LABELS", wxSL_LABELS
},
120 { "wxSL_LEFT", wxSL_LEFT
},
121 { "wxSL_TOP", wxSL_TOP
},
122 { "wxSL_RIGHT", wxSL_RIGHT
},
123 { "wxSL_BOTTOM", wxSL_BOTTOM
},
124 { "wxSL_BOTH", wxSL_BOTH
},
125 { "wxSL_SELRANGE", wxSL_SELRANGE
}
128 int g_WindowStylesSliderCount
= sizeof(g_WindowStylesSlider
)/sizeof(wxWindowStylePair
) ;
131 static wxWindowStylePair g_WindowStylesScrollBar
[] = {
132 { "wxSB_HORIZONTAL", wxSB_HORIZONTAL
},
133 { "wxSB_VERTICAL", wxSB_VERTICAL
}
136 int g_WindowStylesScrollBarCount
= sizeof(g_WindowStylesScrollBar
)/sizeof(wxWindowStylePair
) ;
139 static wxWindowStylePair g_WindowStylesButton
[] = {
140 { "wxBU_AUTODRAW", wxBU_AUTODRAW
},
141 { "wxBU_NOAUTODRAW", wxBU_NOAUTODRAW
}
144 int g_WindowStylesButtonCount
= sizeof(g_WindowStylesButton
)/sizeof(wxWindowStylePair
) ;
147 static wxWindowStylePair g_WindowStylesTreeCtrl
[] = {
148 { "wxTR_HAS_BUTTONS", wxTR_HAS_BUTTONS
},
149 { "wxTR_EDIT_LABELS", wxTR_EDIT_LABELS
},
150 { "wxTR_LINES_AT_ROOT", wxTR_LINES_AT_ROOT
}
153 int g_WindowStylesTreeCtrlCount
= sizeof(g_WindowStylesTreeCtrl
)/sizeof(wxWindowStylePair
) ;
156 static wxWindowStylePair g_WindowStylesListCtrl
[] = {
157 { "wxLC_ICON", wxLC_ICON
},
158 { "wxLC_SMALL_ICON", wxLC_SMALL_ICON
},
159 { "wxLC_LIST", wxLC_LIST
},
160 { "wxLC_REPORT", wxLC_REPORT
},
161 { "wxLC_ALIGN_TOP", wxLC_ALIGN_TOP
},
162 { "wxLC_ALIGN_LEFT", wxLC_ALIGN_LEFT
},
163 { "wxLC_AUTOARRANGE", wxLC_AUTOARRANGE
},
164 { "wxLC_USER_TEXT", wxLC_USER_TEXT
},
165 { "wxLC_EDIT_LABELS", wxLC_EDIT_LABELS
},
166 { "wxLC_NO_HEADER", wxLC_NO_HEADER
},
167 { "wxLC_NO_SORT_HEADER", wxLC_NO_SORT_HEADER
},
168 { "wxLC_SINGLE_SEL", wxLC_SINGLE_SEL
},
169 { "wxLC_SORT_ASCENDING", wxLC_SORT_ASCENDING
},
170 { "wxLC_SORT_DESCENDING", wxLC_SORT_DESCENDING
}
173 int g_WindowStylesListCtrlCount
= sizeof(g_WindowStylesListCtrl
)/sizeof(wxWindowStylePair
) ;
176 static wxWindowStylePair g_WindowStylesSpinButton
[] = {
177 { "wxSP_VERTICAL", wxSP_VERTICAL
},
178 { "wxSP_HORIZONTAL", wxSP_HORIZONTAL
},
179 { "wxSP_ARROW_KEYS", wxSP_ARROW_KEYS
},
180 { "wxSP_WRAP", wxSP_WRAP
}
183 int g_WindowStylesSpinButtonCount
= sizeof(g_WindowStylesSpinButton
)/sizeof(wxWindowStylePair
) ;
185 /* wxSplitterWindow */
186 static wxWindowStylePair g_WindowStylesSplitterWindow
[] = {
187 { "wxSP_NOBORDER", wxSP_NOBORDER
},
188 { "wxSP_3D", wxSP_3D
},
189 { "wxSP_BORDER", wxSP_BORDER
}
192 int g_WindowStylesSplitterWindowCount
= sizeof(g_WindowStylesSplitterWindow
)/sizeof(wxWindowStylePair
) ;
195 static wxWindowStylePair g_WindowStylesTabCtrl
[] = {
196 { "wxTC_MULTILINE", wxTC_MULTILINE
},
197 { "wxTC_RIGHTJUSTIFY", wxTC_RIGHTJUSTIFY
},
198 { "wxTC_FIXEDWIDTH", wxTC_FIXEDWIDTH
},
199 { "wxTC_OWNERDRAW", wxTC_OWNERDRAW
}
202 int g_WindowStylesTabCtrlCount
= sizeof(g_WindowStylesTabCtrl
)/sizeof(wxWindowStylePair
) ;
205 static wxWindowStylePair g_WindowStylesStatusBar
[] = {
206 { "wxST_SIZEGRIP", wxST_SIZEGRIP
}
209 int g_WindowStylesStatusBarCount
= sizeof(g_WindowStylesStatusBar
)/sizeof(wxWindowStylePair
) ;
212 static wxWindowStylePair g_WindowStylesControl
[] = {
213 { "wxFIXED_LENGTH", wxFIXED_LENGTH
},
214 { "wxALIGN_LEFT", wxALIGN_LEFT
},
215 { "wxALIGN_CENTRE", wxALIGN_CENTRE
},
216 { "wxALIGN_RIGHT", wxALIGN_RIGHT
},
217 { "wxCOLOURED", wxCOLOURED
}
220 int g_WindowStylesControlCount
= sizeof(g_WindowStylesControl
)/sizeof(wxWindowStylePair
) ;
223 static wxWindowStylePair g_WindowStylesToolBar
[] = {
224 { "wxTB_3DBUTTONS", wxTB_3DBUTTONS
},
225 { "wxTB_HORIZONTAL", wxTB_HORIZONTAL
},
226 { "wxTB_VERTICAL", wxTB_VERTICAL
},
227 { "wxTB_FLAT", wxTB_FLAT
}
230 int g_WindowStylesToolBarCount
= sizeof(g_WindowStylesToolBar
)/sizeof(wxWindowStylePair
) ;
233 static wxWindowStylePair g_WindowStylesDialog
[] = {
234 { "wxSTAY_ON_TOP", wxSTAY_ON_TOP
},
235 { "wxCAPTION", wxCAPTION
},
236 { "wxICONIZE", wxICONIZE
},
237 { "wxMINIMIZE", wxICONIZE
},
238 { "wxMAXIMIZE", wxMAXIMIZE
},
239 { "wxTHICK_FRAME", wxTHICK_FRAME
},
240 { "wxRESIZE_BORDER", wxRESIZE_BORDER
},
241 { "wxSYSTEM_MENU", wxSYSTEM_MENU
},
242 { "wxMINIMIZE_BOX", wxMINIMIZE_BOX
},
243 { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX
},
244 { "wxDIALOG_MODAL", wxDIALOG_MODAL
},
245 { "wxRESIZE_BOX", wxRESIZE_BOX
}
248 int g_WindowStylesDialogCount
= sizeof(g_WindowStylesDialog
)/sizeof(wxWindowStylePair
) ;
251 static wxWindowStylePair g_WindowStylesWindow
[] = {
252 { "wxBORDER", wxBORDER
},
253 { "wxDOUBLE_BORDER", wxDOUBLE_BORDER
},
254 { "wxSUNKEN_BORDER", wxSUNKEN_BORDER
},
255 { "wxRAISED_BORDER", wxRAISED_BORDER
},
256 { "wxSIMPLE_BORDER", wxSIMPLE_BORDER
},
257 { "wxSTATIC_BORDER", wxSTATIC_BORDER
},
258 { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW
},
259 { "wxNO_BORDER", wxNO_BORDER
},
260 { "wxCLIP_CHILDREN", wxCLIP_CHILDREN
}
262 /* Would be duplicated with e.g. wxLB_HSCROLL
263 { "wxVSCROLL", wxVSCROLL },
264 { "wxHSCROLL", wxHSCROLL }
268 int g_WindowStylesWindowCount
= sizeof(g_WindowStylesWindow
)/sizeof(wxWindowStylePair
) ;
271 * A table holding all class style objects
275 wxWindowStyleTable::wxWindowStyleTable():
276 m_classes(wxKEY_STRING
)
280 wxWindowStyleTable::~wxWindowStyleTable()
285 void wxWindowStyleTable::Init()
287 AddStyles("wxWindow", g_WindowStylesWindowCount
, g_WindowStylesWindow
);
288 AddStyles("wxDialog", g_WindowStylesDialogCount
, g_WindowStylesDialog
);
289 AddStyles("wxButton", g_WindowStylesButtonCount
, g_WindowStylesButton
);
290 AddStyles("wxTextCtrl", g_WindowStylesTextCtrlCount
, g_WindowStylesTextCtrl
);
291 AddStyles("wxSpinButton", g_WindowStylesSpinButtonCount
, g_WindowStylesSpinButton
);
292 AddStyles("wxListBox", g_WindowStylesListBoxCount
, g_WindowStylesListBox
);
293 AddStyles("wxRadioButton", g_WindowStylesRadioButtonCount
, g_WindowStylesRadioButton
);
294 AddStyles("wxRadioBox", g_WindowStylesRadioBoxCount
, g_WindowStylesRadioBox
);
295 AddStyles("wxControl", g_WindowStylesControlCount
, g_WindowStylesControl
);
296 AddStyles("wxListCtrl", g_WindowStylesListCtrlCount
, g_WindowStylesListCtrl
);
297 AddStyles("wxTreeCtrl", g_WindowStylesTreeCtrlCount
, g_WindowStylesTreeCtrl
);
298 AddStyles("wxSlider", g_WindowStylesSliderCount
, g_WindowStylesSlider
);
299 AddStyles("wxGauge", g_WindowStylesGaugeCount
, g_WindowStylesGauge
);
300 AddStyles("wxComboBox", g_WindowStylesComboBoxCount
, g_WindowStylesComboBox
);
301 // AddStyles("wxChoice", g_WindowStylesChoice, g_WindowStylesChoice);
302 AddStyles("wxScrollBar", g_WindowStylesScrollBarCount
, g_WindowStylesScrollBar
);
306 void wxWindowStyleTable::ClearTable()
308 wxNode
* node
= m_classes
.First();
311 wxWindowStyleClass
* styleClass
= (wxWindowStyleClass
*) node
->Data();
318 void wxWindowStyleTable::AddStyles(const wxString
& className
, int n
, wxWindowStylePair
*styles
)
320 wxWindowStyleClass
* styleClass
= new wxWindowStyleClass(n
, styles
);
321 m_classes
.Append(className
, styleClass
);
324 wxWindowStyleClass
* wxWindowStyleTable::FindClass(const wxString
& className
)
326 wxNode
* node
= m_classes
.Find(className
);
329 wxWindowStyleClass
* styleClass
= (wxWindowStyleClass
*) node
->Data();
336 bool wxWindowStyleTable::GenerateStyleStrings(const wxString
& className
, long windowStyle
, char *buf
)
338 wxWindowStyleClass
* styleClass
= FindClass(className
);
342 styleClass
->GenerateStyleStrings(windowStyle
, buf
);
347 * Holds all the styles for a particular class
350 wxWindowStyleClass::wxWindowStyleClass(int n
, wxWindowStylePair
*styles
)
355 m_styles = new wxWindowStylePair[n];
357 for (i = 0; i < n; i++)
358 m_styles[i] = styles[i];
362 wxWindowStyleClass::~wxWindowStyleClass()
366 void wxWindowStyleClass::GenerateStyleStrings(long windowStyle
, char *buf
)
369 for (i
= 0; i
< m_styleCount
; i
++)
370 GenerateStyle(buf
, windowStyle
, m_styles
[i
].m_styleId
, m_styles
[i
].m_styleName
);
373 bool wxWindowStyleClass::GenerateStyle(char *buf
, long windowStyle
, long flag
, const wxString
& strStyle
)
379 if ((windowStyle
& flag
) == flag
)
383 strcat(buf
, (const char*) strStyle
);