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"
25 #include "wx/listctrl.h"
26 #include "wx/treectrl.h"
41 static wxWindowStylePair g_WindowStylesListBox
[] = {
42 { "wxLB_SINGLE", wxLB_SINGLE
},
43 { "wxLB_MULTIPLE", wxLB_MULTIPLE
},
44 { "wxLB_EXTENDED", wxLB_EXTENDED
},
45 { "wxLB_NEEDED_SB", wxLB_NEEDED_SB
},
46 { "wxLB_ALWAYS_SB", wxLB_ALWAYS_SB
},
47 { "wxLB_SORT", wxLB_SORT
},
48 { "wxLB_OWNERDRAW", wxLB_OWNERDRAW
},
49 { "wxLB_HSCROLL", wxLB_HSCROLL
}
52 int g_WindowStylesListBoxCount
= sizeof(g_WindowStylesListBox
)/sizeof(wxWindowStylePair
) ;
55 static wxWindowStylePair g_WindowStylesComboBox
[] = {
56 { "wxCB_SIMPLE", wxCB_SIMPLE
},
57 { "wxCB_DROPDOWN", wxCB_DROPDOWN
},
58 { "wxCB_READONLY", wxCB_READONLY
},
59 { "wxCB_SORT", wxCB_SORT
}
62 int g_WindowStylesComboBoxCount
= sizeof(g_WindowStylesComboBox
)/sizeof(wxWindowStylePair
) ;
66 static wxWindowStylePair g_WindowStylesChoice
[] = {
69 int g_WindowStylesChoiceCount
= sizeof(g_WindowStylesChoice
)/sizeof(wxWindowStylePair
) ;
73 static wxWindowStylePair g_WindowStylesGauge
[] = {
74 { "wxGA_PROGRESSBAR", wxGA_PROGRESSBAR
},
75 { "wxGA_HORIZONTAL", wxGA_HORIZONTAL
},
76 { "wxGA_VERTICAL", wxGA_VERTICAL
}
79 int g_WindowStylesGaugeCount
= sizeof(g_WindowStylesGauge
)/sizeof(wxWindowStylePair
) ;
82 static wxWindowStylePair g_WindowStylesTextCtrl
[] = {
83 // { "wxPASSWORD", wxPASSWORD},
84 // { "wxPROCESS_ENTER", wxPROCESS_ENTER},
85 { "wxTE_PASSWORD", wxTE_PASSWORD
},
86 { "wxTE_READONLY", wxTE_READONLY
},
87 { "wxTE_PROCESS_ENTER", wxTE_PROCESS_ENTER
},
88 { "wxTE_MULTILINE", wxTE_MULTILINE
}
91 int g_WindowStylesTextCtrlCount
= sizeof(g_WindowStylesTextCtrl
)/sizeof(wxWindowStylePair
) ;
94 static wxWindowStylePair g_WindowStylesRadioButton
[] = {
95 { "wxRB_GROUP", wxRB_GROUP
}
98 int g_WindowStylesRadioButtonCount
= sizeof(g_WindowStylesRadioButton
)/sizeof(wxWindowStylePair
) ;
101 static wxWindowStylePair g_WindowStylesRadioBox
[] = {
102 { "wxRA_SPECIFY_COLS", wxRA_SPECIFY_COLS
},
103 { "wxRA_SPECIFY_ROWS", wxRA_SPECIFY_ROWS
}
106 { "wxRA_HORIZONTAL", wxRA_HORIZONTAL },
107 { "wxRA_VERTICAL", wxRA_VERTICAL }
111 int g_WindowStylesRadioBoxCount
= sizeof(g_WindowStylesRadioBox
)/sizeof(wxWindowStylePair
) ;
114 static wxWindowStylePair g_WindowStylesSlider
[] = {
115 { "wxSL_HORIZONTAL", wxSL_HORIZONTAL
},
116 { "wxSL_VERTICAL", wxSL_VERTICAL
},
117 { "wxSL_AUTOTICKS", wxSL_AUTOTICKS
},
118 { "wxSL_LABELS", wxSL_LABELS
},
119 { "wxSL_LEFT", wxSL_LEFT
},
120 { "wxSL_TOP", wxSL_TOP
},
121 { "wxSL_RIGHT", wxSL_RIGHT
},
122 { "wxSL_BOTTOM", wxSL_BOTTOM
},
123 { "wxSL_BOTH", wxSL_BOTH
},
124 { "wxSL_SELRANGE", wxSL_SELRANGE
}
127 int g_WindowStylesSliderCount
= sizeof(g_WindowStylesSlider
)/sizeof(wxWindowStylePair
) ;
130 static wxWindowStylePair g_WindowStylesScrollBar
[] = {
131 { "wxSB_HORIZONTAL", wxSB_HORIZONTAL
},
132 { "wxSB_VERTICAL", wxSB_VERTICAL
}
135 int g_WindowStylesScrollBarCount
= sizeof(g_WindowStylesScrollBar
)/sizeof(wxWindowStylePair
) ;
138 static wxWindowStylePair g_WindowStylesButton
[] = {
139 { "wxBU_AUTODRAW", wxBU_AUTODRAW
},
140 { "wxBU_NOAUTODRAW", wxBU_NOAUTODRAW
}
143 int g_WindowStylesButtonCount
= sizeof(g_WindowStylesButton
)/sizeof(wxWindowStylePair
) ;
146 static wxWindowStylePair g_WindowStylesTreeCtrl
[] = {
147 { "wxTR_HAS_BUTTONS", wxTR_HAS_BUTTONS
},
148 { "wxTR_EDIT_LABELS", wxTR_EDIT_LABELS
},
149 { "wxTR_LINES_AT_ROOT", wxTR_LINES_AT_ROOT
}
152 int g_WindowStylesTreeCtrlCount
= sizeof(g_WindowStylesTreeCtrl
)/sizeof(wxWindowStylePair
) ;
155 static wxWindowStylePair g_WindowStylesListCtrl
[] = {
156 { "wxLC_ICON", wxLC_ICON
},
157 { "wxLC_SMALL_ICON", wxLC_SMALL_ICON
},
158 { "wxLC_LIST", wxLC_LIST
},
159 { "wxLC_REPORT", wxLC_REPORT
},
160 { "wxLC_ALIGN_TOP", wxLC_ALIGN_TOP
},
161 { "wxLC_ALIGN_LEFT", wxLC_ALIGN_LEFT
},
162 { "wxLC_AUTOARRANGE", wxLC_AUTOARRANGE
},
163 { "wxLC_USER_TEXT", wxLC_USER_TEXT
},
164 { "wxLC_EDIT_LABELS", wxLC_EDIT_LABELS
},
165 { "wxLC_NO_HEADER", wxLC_NO_HEADER
},
166 { "wxLC_NO_SORT_HEADER", wxLC_NO_SORT_HEADER
},
167 { "wxLC_SINGLE_SEL", wxLC_SINGLE_SEL
},
168 { "wxLC_SORT_ASCENDING", wxLC_SORT_ASCENDING
},
169 { "wxLC_SORT_DESCENDING", wxLC_SORT_DESCENDING
}
172 int g_WindowStylesListCtrlCount
= sizeof(g_WindowStylesListCtrl
)/sizeof(wxWindowStylePair
) ;
175 static wxWindowStylePair g_WindowStylesSpinButton
[] = {
176 { "wxSP_VERTICAL", wxSP_VERTICAL
},
177 { "wxSP_HORIZONTAL", wxSP_HORIZONTAL
},
178 { "wxSP_ARROW_KEYS", wxSP_ARROW_KEYS
},
179 { "wxSP_WRAP", wxSP_WRAP
}
182 int g_WindowStylesSpinButtonCount
= sizeof(g_WindowStylesSpinButton
)/sizeof(wxWindowStylePair
) ;
184 /* wxSplitterWindow */
185 static wxWindowStylePair g_WindowStylesSplitterWindow
[] = {
186 { "wxSP_NOBORDER", wxSP_NOBORDER
},
187 { "wxSP_3D", wxSP_3D
},
188 { "wxSP_BORDER", wxSP_BORDER
}
191 int g_WindowStylesSplitterWindowCount
= sizeof(g_WindowStylesSplitterWindow
)/sizeof(wxWindowStylePair
) ;
194 static wxWindowStylePair g_WindowStylesTabCtrl
[] = {
195 { "wxTC_MULTILINE", wxTC_MULTILINE
},
196 { "wxTC_RIGHTJUSTIFY", wxTC_RIGHTJUSTIFY
},
197 { "wxTC_FIXEDWIDTH", wxTC_FIXEDWIDTH
},
198 { "wxTC_OWNERDRAW", wxTC_OWNERDRAW
}
201 int g_WindowStylesTabCtrlCount
= sizeof(g_WindowStylesTabCtrl
)/sizeof(wxWindowStylePair
) ;
204 static wxWindowStylePair g_WindowStylesStatusBar
[] = {
205 { "wxST_SIZEGRIP", wxST_SIZEGRIP
}
208 int g_WindowStylesStatusBarCount
= sizeof(g_WindowStylesStatusBar
)/sizeof(wxWindowStylePair
) ;
211 static wxWindowStylePair g_WindowStylesControl
[] = {
212 { "wxFIXED_LENGTH", wxFIXED_LENGTH
},
213 { "wxALIGN_LEFT", wxALIGN_LEFT
},
214 { "wxALIGN_CENTRE", wxALIGN_CENTRE
},
215 { "wxALIGN_RIGHT", wxALIGN_RIGHT
},
216 { "wxCOLOURED", wxCOLOURED
}
219 int g_WindowStylesControlCount
= sizeof(g_WindowStylesControl
)/sizeof(wxWindowStylePair
) ;
222 static wxWindowStylePair g_WindowStylesToolBar
[] = {
223 { "wxTB_3DBUTTONS", wxTB_3DBUTTONS
},
224 { "wxTB_HORIZONTAL", wxTB_HORIZONTAL
},
225 { "wxTB_VERTICAL", wxTB_VERTICAL
},
226 { "wxTB_FLAT", wxTB_FLAT
}
229 int g_WindowStylesToolBarCount
= sizeof(g_WindowStylesToolBar
)/sizeof(wxWindowStylePair
) ;
232 static wxWindowStylePair g_WindowStylesDialog
[] = {
233 { "wxSTAY_ON_TOP", wxSTAY_ON_TOP
},
234 { "wxCAPTION", wxCAPTION
},
235 { "wxICONIZE", wxICONIZE
},
236 { "wxMINIMIZE", wxICONIZE
},
237 { "wxMAXIMIZE", wxMAXIMIZE
},
238 { "wxTHICK_FRAME", wxTHICK_FRAME
},
239 { "wxRESIZE_BORDER", wxRESIZE_BORDER
},
240 { "wxSYSTEM_MENU", wxSYSTEM_MENU
},
241 { "wxMINIMIZE_BOX", wxMINIMIZE_BOX
},
242 { "wxMAXIMIZE_BOX", wxMAXIMIZE_BOX
},
243 { "wxDIALOG_MODAL", wxDIALOG_MODAL
},
244 { "wxRESIZE_BOX", wxRESIZE_BOX
}
247 int g_WindowStylesDialogCount
= sizeof(g_WindowStylesDialog
)/sizeof(wxWindowStylePair
) ;
250 static wxWindowStylePair g_WindowStylesWindow
[] = {
251 { "wxBORDER", wxBORDER
},
252 { "wxDOUBLE_BORDER", wxDOUBLE_BORDER
},
253 { "wxSUNKEN_BORDER", wxSUNKEN_BORDER
},
254 { "wxRAISED_BORDER", wxRAISED_BORDER
},
255 { "wxSIMPLE_BORDER", wxSIMPLE_BORDER
},
256 { "wxSTATIC_BORDER", wxSTATIC_BORDER
},
257 { "wxTRANSPARENT_WINDOW", wxTRANSPARENT_WINDOW
},
258 { "wxNO_BORDER", wxNO_BORDER
},
259 { "wxCLIP_CHILDREN", wxCLIP_CHILDREN
}
261 /* Would be duplicated with e.g. wxLB_HSCROLL
262 { "wxVSCROLL", wxVSCROLL },
263 { "wxHSCROLL", wxHSCROLL }
267 int g_WindowStylesWindowCount
= sizeof(g_WindowStylesWindow
)/sizeof(wxWindowStylePair
) ;
270 * A table holding all class style objects
274 wxWindowStyleTable::wxWindowStyleTable():
275 m_classes(wxKEY_STRING
)
279 wxWindowStyleTable::~wxWindowStyleTable()
284 void wxWindowStyleTable::Init()
286 AddStyles("wxWindow", g_WindowStylesWindowCount
, g_WindowStylesWindow
);
287 AddStyles("wxDialog", g_WindowStylesDialogCount
, g_WindowStylesDialog
);
288 AddStyles("wxButton", g_WindowStylesButtonCount
, g_WindowStylesButton
);
289 AddStyles("wxTextCtrl", g_WindowStylesTextCtrlCount
, g_WindowStylesTextCtrl
);
290 AddStyles("wxSpinButton", g_WindowStylesSpinButtonCount
, g_WindowStylesSpinButton
);
291 AddStyles("wxListBox", g_WindowStylesListBoxCount
, g_WindowStylesListBox
);
292 AddStyles("wxRadioButton", g_WindowStylesRadioButtonCount
, g_WindowStylesRadioButton
);
293 AddStyles("wxRadioBox", g_WindowStylesRadioBoxCount
, g_WindowStylesRadioBox
);
294 AddStyles("wxControl", g_WindowStylesControlCount
, g_WindowStylesControl
);
295 AddStyles("wxListCtrl", g_WindowStylesListCtrlCount
, g_WindowStylesListCtrl
);
296 AddStyles("wxTreeCtrl", g_WindowStylesTreeCtrlCount
, g_WindowStylesTreeCtrl
);
297 AddStyles("wxSlider", g_WindowStylesSliderCount
, g_WindowStylesSlider
);
298 AddStyles("wxGauge", g_WindowStylesGaugeCount
, g_WindowStylesGauge
);
299 AddStyles("wxComboBox", g_WindowStylesComboBoxCount
, g_WindowStylesComboBox
);
300 // AddStyles("wxChoice", g_WindowStylesChoice, g_WindowStylesChoice);
301 AddStyles("wxScrollBar", g_WindowStylesScrollBarCount
, g_WindowStylesScrollBar
);
305 void wxWindowStyleTable::ClearTable()
307 wxNode
* node
= m_classes
.First();
310 wxWindowStyleClass
* styleClass
= (wxWindowStyleClass
*) node
->Data();
317 void wxWindowStyleTable::AddStyles(const wxString
& className
, int n
, wxWindowStylePair
*styles
)
319 wxWindowStyleClass
* styleClass
= new wxWindowStyleClass(n
, styles
);
320 m_classes
.Append(className
, styleClass
);
323 wxWindowStyleClass
* wxWindowStyleTable::FindClass(const wxString
& className
)
325 wxNode
* node
= m_classes
.Find(className
);
328 wxWindowStyleClass
* styleClass
= (wxWindowStyleClass
*) node
->Data();
335 bool wxWindowStyleTable::GenerateStyleStrings(const wxString
& className
, long windowStyle
, char *buf
)
337 wxWindowStyleClass
* styleClass
= FindClass(className
);
341 styleClass
->GenerateStyleStrings(windowStyle
, buf
);
346 * Holds all the styles for a particular class
349 wxWindowStyleClass::wxWindowStyleClass(int n
, wxWindowStylePair
*styles
)
354 m_styles = new wxWindowStylePair[n];
356 for (i = 0; i < n; i++)
357 m_styles[i] = styles[i];
361 wxWindowStyleClass::~wxWindowStyleClass()
365 void wxWindowStyleClass::GenerateStyleStrings(long windowStyle
, char *buf
)
368 for (i
= 0; i
< m_styleCount
; i
++)
369 GenerateStyle(buf
, windowStyle
, m_styles
[i
].m_styleId
, m_styles
[i
].m_styleName
);
372 bool wxWindowStyleClass::GenerateStyle(char *buf
, long windowStyle
, long flag
, const wxString
& strStyle
)
378 if ((windowStyle
& flag
) == flag
)
382 strcat(buf
, (const char*) strStyle
);