]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/univ/renderer.h | |
3 | // Purpose: wxRenderer class declaration | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 06.08.00 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_UNIV_RENDERER_H_ | |
13 | #define _WX_UNIV_RENDERER_H_ | |
14 | ||
15 | /* | |
16 | wxRenderer class is used to draw all wxWidgets controls. This is an ABC and | |
17 | the look of the application is determined by the concrete derivation of | |
18 | wxRenderer used in the program. | |
19 | ||
20 | It also contains a few static methods which may be used by the concrete | |
21 | renderers and provide the functionality which is often similar or identical | |
22 | in all renderers (using inheritance here would be more restrictive as the | |
23 | given concrete renderer may need an arbitrary subset of the base class | |
24 | methods). | |
25 | ||
26 | Finally note that wxRenderer supersedes wxRendererNative in wxUniv build and | |
27 | includes the latters functionality (which it may delegate to the generic | |
28 | implementation of the latter or reimplement itself). | |
29 | */ | |
30 | ||
31 | #include "wx/renderer.h" | |
32 | ||
33 | class WXDLLEXPORT wxWindow; | |
34 | class WXDLLEXPORT wxDC; | |
35 | class WXDLLEXPORT wxCheckListBox; | |
36 | ||
37 | #if wxUSE_LISTBOX | |
38 | class WXDLLEXPORT wxListBox; | |
39 | #endif // wxUSE_LISTBOX | |
40 | ||
41 | #if wxUSE_MENUS | |
42 | class WXDLLEXPORT wxMenu; | |
43 | class WXDLLEXPORT wxMenuGeometryInfo; | |
44 | #endif // wxUSE_MENUS | |
45 | ||
46 | class WXDLLEXPORT wxScrollBar; | |
47 | ||
48 | #if wxUSE_TEXTCTRL | |
49 | class WXDLLEXPORT wxTextCtrl; | |
50 | #endif | |
51 | ||
52 | #if wxUSE_GAUGE | |
53 | class WXDLLEXPORT wxGauge; | |
54 | #endif // wxUSE_GAUGE | |
55 | ||
56 | #include "wx/string.h" | |
57 | #include "wx/gdicmn.h" | |
58 | #include "wx/icon.h" | |
59 | ||
60 | // helper class used by wxMenu-related functions | |
61 | class WXDLLEXPORT wxMenuGeometryInfo | |
62 | { | |
63 | public: | |
64 | // get the total size of the menu | |
65 | virtual wxSize GetSize() const = 0; | |
66 | ||
67 | virtual ~wxMenuGeometryInfo(); | |
68 | }; | |
69 | ||
70 | // ---------------------------------------------------------------------------- | |
71 | // wxRenderer: abstract renderers interface | |
72 | // ---------------------------------------------------------------------------- | |
73 | ||
74 | class WXDLLEXPORT wxRenderer : public wxDelegateRendererNative | |
75 | { | |
76 | public: | |
77 | // drawing functions | |
78 | // ----------------- | |
79 | ||
80 | // draw the controls background | |
81 | virtual void DrawBackground(wxDC& dc, | |
82 | const wxColour& col, | |
83 | const wxRect& rect, | |
84 | int flags, | |
85 | wxWindow *window = NULL) = 0; | |
86 | ||
87 | // draw the button surface | |
88 | virtual void DrawButtonSurface(wxDC& dc, | |
89 | const wxColour& col, | |
90 | const wxRect& rect, | |
91 | int flags) = 0; | |
92 | ||
93 | ||
94 | // draw the focus rectangle around the label contained in the given rect | |
95 | // | |
96 | // only wxCONTROL_SELECTED makes sense in flags here | |
97 | virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0) = 0; | |
98 | ||
99 | // draw the label inside the given rectangle with the specified alignment | |
100 | // and optionally emphasize the character with the given index | |
101 | virtual void DrawLabel(wxDC& dc, | |
102 | const wxString& label, | |
103 | const wxRect& rect, | |
104 | int flags = 0, | |
105 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
106 | int indexAccel = -1, | |
107 | wxRect *rectBounds = NULL) = 0; | |
108 | ||
109 | // same but also draw a bitmap if it is valid | |
110 | virtual void DrawButtonLabel(wxDC& dc, | |
111 | const wxString& label, | |
112 | const wxBitmap& image, | |
113 | const wxRect& rect, | |
114 | int flags = 0, | |
115 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
116 | int indexAccel = -1, | |
117 | wxRect *rectBounds = NULL) = 0; | |
118 | ||
119 | ||
120 | // draw the border and optionally return the rectangle containing the | |
121 | // region inside the border | |
122 | virtual void DrawBorder(wxDC& dc, | |
123 | wxBorder border, | |
124 | const wxRect& rect, | |
125 | int flags = 0, | |
126 | wxRect *rectIn = (wxRect *)NULL) = 0; | |
127 | ||
128 | // draw text control border (I hate to have a separate method for this but | |
129 | // it is needed to accommodate GTK+) | |
130 | virtual void DrawTextBorder(wxDC& dc, | |
131 | wxBorder border, | |
132 | const wxRect& rect, | |
133 | int flags = 0, | |
134 | wxRect *rectIn = (wxRect *)NULL) = 0; | |
135 | ||
136 | // draw push button border and return the rectangle left for the label | |
137 | virtual void DrawButtonBorder(wxDC& dc, | |
138 | const wxRect& rect, | |
139 | int flags = 0, | |
140 | wxRect *rectIn = (wxRect *)NULL) = 0; | |
141 | ||
142 | // draw a horizontal line | |
143 | virtual void DrawHorizontalLine(wxDC& dc, | |
144 | wxCoord y, wxCoord x1, wxCoord x2) = 0; | |
145 | ||
146 | // draw a vertical line | |
147 | virtual void DrawVerticalLine(wxDC& dc, | |
148 | wxCoord x, wxCoord y1, wxCoord y2) = 0; | |
149 | ||
150 | // draw a frame with the label (horizontal alignment can be specified) | |
151 | virtual void DrawFrame(wxDC& dc, | |
152 | const wxString& label, | |
153 | const wxRect& rect, | |
154 | int flags = 0, | |
155 | int alignment = wxALIGN_LEFT, | |
156 | int indexAccel = -1) = 0; | |
157 | ||
158 | // draw an arrow in the given direction | |
159 | virtual void DrawArrow(wxDC& dc, | |
160 | wxDirection dir, | |
161 | const wxRect& rect, | |
162 | int flags = 0) = 0; | |
163 | ||
164 | // draw a scrollbar arrow (may be the same as arrow but may be not) | |
165 | virtual void DrawScrollbarArrow(wxDC& dc, | |
166 | wxDirection dir, | |
167 | const wxRect& rect, | |
168 | int flags = 0) = 0; | |
169 | ||
170 | // draw the scrollbar thumb | |
171 | virtual void DrawScrollbarThumb(wxDC& dc, | |
172 | wxOrientation orient, | |
173 | const wxRect& rect, | |
174 | int flags = 0) = 0; | |
175 | ||
176 | // draw a (part of) scrollbar shaft | |
177 | virtual void DrawScrollbarShaft(wxDC& dc, | |
178 | wxOrientation orient, | |
179 | const wxRect& rect, | |
180 | int flags = 0) = 0; | |
181 | ||
182 | // draw the rectangle in the corner between two scrollbars | |
183 | virtual void DrawScrollCorner(wxDC& dc, | |
184 | const wxRect& rect) = 0; | |
185 | ||
186 | // draw an item of a wxListBox | |
187 | virtual void DrawItem(wxDC& dc, | |
188 | const wxString& label, | |
189 | const wxRect& rect, | |
190 | int flags = 0) = 0; | |
191 | ||
192 | // draw an item of a wxCheckListBox | |
193 | virtual void DrawCheckItem(wxDC& dc, | |
194 | const wxString& label, | |
195 | const wxBitmap& bitmap, | |
196 | const wxRect& rect, | |
197 | int flags = 0) = 0; | |
198 | ||
199 | // draw a checkbutton (bitmap may be invalid to use default one) | |
200 | virtual void DrawCheckButton(wxDC& dc, | |
201 | const wxString& label, | |
202 | const wxBitmap& bitmap, | |
203 | const wxRect& rect, | |
204 | int flags = 0, | |
205 | wxAlignment align = wxALIGN_LEFT, | |
206 | int indexAccel = -1) = 0; | |
207 | ||
208 | // draw a radio button | |
209 | virtual void DrawRadioButton(wxDC& dc, | |
210 | const wxString& label, | |
211 | const wxBitmap& bitmap, | |
212 | const wxRect& rect, | |
213 | int flags = 0, | |
214 | wxAlignment align = wxALIGN_LEFT, | |
215 | int indexAccel = -1) = 0; | |
216 | ||
217 | #if wxUSE_TOOLBAR | |
218 | // draw a toolbar button (label may be empty, bitmap may be invalid, if | |
219 | // both conditions are true this function draws a separator) | |
220 | virtual void DrawToolBarButton(wxDC& dc, | |
221 | const wxString& label, | |
222 | const wxBitmap& bitmap, | |
223 | const wxRect& rect, | |
224 | int flags = 0, | |
225 | long style = 0, | |
226 | int tbarStyle = 0) = 0; | |
227 | #endif // wxUSE_TOOLBAR | |
228 | ||
229 | #if wxUSE_TEXTCTRL | |
230 | // draw a (part of) line in the text control | |
231 | virtual void DrawTextLine(wxDC& dc, | |
232 | const wxString& text, | |
233 | const wxRect& rect, | |
234 | int selStart = -1, | |
235 | int selEnd = -1, | |
236 | int flags = 0) = 0; | |
237 | ||
238 | // draw a line wrap indicator | |
239 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) = 0; | |
240 | #endif // wxUSE_TEXTCTRL | |
241 | ||
242 | #if wxUSE_NOTEBOOK | |
243 | // draw a notebook tab | |
244 | virtual void DrawTab(wxDC& dc, | |
245 | const wxRect& rect, | |
246 | wxDirection dir, | |
247 | const wxString& label, | |
248 | const wxBitmap& bitmap = wxNullBitmap, | |
249 | int flags = 0, | |
250 | int indexAccel = -1) = 0; | |
251 | #endif // wxUSE_NOTEBOOK | |
252 | ||
253 | #if wxUSE_SLIDER | |
254 | ||
255 | // draw the slider shaft | |
256 | virtual void DrawSliderShaft(wxDC& dc, | |
257 | const wxRect& rect, | |
258 | int lenThumb, | |
259 | wxOrientation orient, | |
260 | int flags = 0, | |
261 | long style = 0, | |
262 | wxRect *rectShaft = NULL) = 0; | |
263 | ||
264 | // draw the slider thumb | |
265 | virtual void DrawSliderThumb(wxDC& dc, | |
266 | const wxRect& rect, | |
267 | wxOrientation orient, | |
268 | int flags = 0, | |
269 | long style = 0) = 0; | |
270 | ||
271 | // draw the slider ticks | |
272 | virtual void DrawSliderTicks(wxDC& dc, | |
273 | const wxRect& rect, | |
274 | int lenThumb, | |
275 | wxOrientation orient, | |
276 | int start, | |
277 | int end, | |
278 | int step = 1, | |
279 | int flags = 0, | |
280 | long style = 0) = 0; | |
281 | #endif // wxUSE_SLIDER | |
282 | ||
283 | #if wxUSE_MENUS | |
284 | // draw a menu bar item | |
285 | virtual void DrawMenuBarItem(wxDC& dc, | |
286 | const wxRect& rect, | |
287 | const wxString& label, | |
288 | int flags = 0, | |
289 | int indexAccel = -1) = 0; | |
290 | ||
291 | // draw a menu item (also used for submenus if flags has ISSUBMENU flag) | |
292 | // | |
293 | // the geometryInfo is calculated by GetMenuGeometry() function from below | |
294 | virtual void DrawMenuItem(wxDC& dc, | |
295 | wxCoord y, | |
296 | const wxMenuGeometryInfo& geometryInfo, | |
297 | const wxString& label, | |
298 | const wxString& accel, | |
299 | const wxBitmap& bitmap = wxNullBitmap, | |
300 | int flags = 0, | |
301 | int indexAccel = -1) = 0; | |
302 | ||
303 | // draw a menu bar separator | |
304 | virtual void DrawMenuSeparator(wxDC& dc, | |
305 | wxCoord y, | |
306 | const wxMenuGeometryInfo& geomInfo) = 0; | |
307 | #endif // wxUSE_MENUS | |
308 | ||
309 | #if wxUSE_STATUSBAR | |
310 | // draw a status bar field: wxCONTROL_ISDEFAULT bit in the flags is | |
311 | // interpreted specially and means "draw the status bar grip" here | |
312 | virtual void DrawStatusField(wxDC& dc, | |
313 | const wxRect& rect, | |
314 | const wxString& label, | |
315 | int flags = 0, int style = 0) = 0; | |
316 | #endif // wxUSE_STATUSBAR | |
317 | ||
318 | // draw complete frame/dialog titlebar | |
319 | virtual void DrawFrameTitleBar(wxDC& dc, | |
320 | const wxRect& rect, | |
321 | const wxString& title, | |
322 | const wxIcon& icon, | |
323 | int flags, | |
324 | int specialButton = 0, | |
325 | int specialButtonFlags = 0) = 0; | |
326 | ||
327 | // draw frame borders | |
328 | virtual void DrawFrameBorder(wxDC& dc, | |
329 | const wxRect& rect, | |
330 | int flags) = 0; | |
331 | ||
332 | // draw frame titlebar background | |
333 | virtual void DrawFrameBackground(wxDC& dc, | |
334 | const wxRect& rect, | |
335 | int flags) = 0; | |
336 | ||
337 | // draw frame title | |
338 | virtual void DrawFrameTitle(wxDC& dc, | |
339 | const wxRect& rect, | |
340 | const wxString& title, | |
341 | int flags) = 0; | |
342 | ||
343 | // draw frame icon | |
344 | virtual void DrawFrameIcon(wxDC& dc, | |
345 | const wxRect& rect, | |
346 | const wxIcon& icon, | |
347 | int flags) = 0; | |
348 | ||
349 | // draw frame buttons | |
350 | virtual void DrawFrameButton(wxDC& dc, | |
351 | wxCoord x, wxCoord y, | |
352 | int button, | |
353 | int flags = 0) = 0; | |
354 | ||
355 | // misc functions | |
356 | // -------------- | |
357 | ||
358 | #if wxUSE_COMBOBOX | |
359 | // return the bitmaps to use for combobox button | |
360 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, | |
361 | wxBitmap *bmpFocus, | |
362 | wxBitmap *bmpPressed, | |
363 | wxBitmap *bmpDisabled) = 0; | |
364 | #endif // wxUSE_COMBOBOX | |
365 | ||
366 | // geometry functions | |
367 | // ------------------ | |
368 | ||
369 | // get the dimensions of the border: rect.x/y contain the width/height of | |
370 | // the left/top side, width/heigh - of the right/bottom one | |
371 | virtual wxRect GetBorderDimensions(wxBorder border) const = 0; | |
372 | ||
373 | // the scrollbars may be drawn either inside the window border or outside | |
374 | // it - this function is used to decide how to draw them | |
375 | virtual bool AreScrollbarsInsideBorder() const = 0; | |
376 | ||
377 | // adjust the size of the control of the given class: for most controls, | |
378 | // this just takes into account the border, but for some (buttons, for | |
379 | // example) it is more complicated - the result being, in any case, that | |
380 | // the control looks "nice" if it uses the adjusted rectangle | |
381 | virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0; | |
382 | ||
383 | #if wxUSE_SCROLLBAR | |
384 | // get the size of a scrollbar arrow | |
385 | virtual wxSize GetScrollbarArrowSize() const = 0; | |
386 | #endif // wxUSE_SCROLLBAR | |
387 | ||
388 | // get the height of a listbox item from the base font height | |
389 | virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) = 0; | |
390 | ||
391 | // get the size of a checkbox/radio button bitmap | |
392 | virtual wxSize GetCheckBitmapSize() const = 0; | |
393 | virtual wxSize GetRadioBitmapSize() const = 0; | |
394 | virtual wxCoord GetCheckItemMargin() const = 0; | |
395 | ||
396 | #if wxUSE_TOOLBAR | |
397 | // get the standard size of a toolbar button and also return the size of | |
398 | // a toolbar separator in the provided pointer | |
399 | virtual wxSize GetToolBarButtonSize(wxCoord *separator) const = 0; | |
400 | ||
401 | // get the margins between/around the toolbar buttons | |
402 | virtual wxSize GetToolBarMargin() const = 0; | |
403 | #endif // wxUSE_TOOLBAR | |
404 | ||
405 | #if wxUSE_TEXTCTRL | |
406 | // convert between text rectangle and client rectangle for text controls: | |
407 | // the former is typicall smaller to leave margins around text | |
408 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, | |
409 | const wxRect& rectText) const = 0; | |
410 | ||
411 | // extra space is for line indicators | |
412 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
413 | const wxRect& rectTotal, | |
414 | wxCoord *extraSpaceBeyond) const = 0; | |
415 | #endif // wxUSE_TEXTCTRL | |
416 | ||
417 | #if wxUSE_NOTEBOOK | |
418 | // get the overhang of a selected tab | |
419 | virtual wxSize GetTabIndent() const = 0; | |
420 | ||
421 | // get the padding around the text in a tab | |
422 | virtual wxSize GetTabPadding() const = 0; | |
423 | #endif // wxUSE_NOTEBOOK | |
424 | ||
425 | #if wxUSE_SLIDER | |
426 | // get the default size of the slider in lesser dimension (i.e. height of a | |
427 | // horizontal slider or width of a vertical one) | |
428 | virtual wxCoord GetSliderDim() const = 0; | |
429 | ||
430 | // get the length of the slider ticks displayed along side slider | |
431 | virtual wxCoord GetSliderTickLen() const = 0; | |
432 | ||
433 | // get the slider shaft rect from the total slider rect | |
434 | virtual wxRect GetSliderShaftRect(const wxRect& rect, | |
435 | int lenThumb, | |
436 | wxOrientation orient, | |
437 | long style = 0) const = 0; | |
438 | ||
439 | // get the size of the slider thumb for the given total slider rect | |
440 | virtual wxSize GetSliderThumbSize(const wxRect& rect, | |
441 | int lenThumb, | |
442 | wxOrientation orient) const = 0; | |
443 | #endif // wxUSE_SLIDER | |
444 | ||
445 | // get the size of one progress bar step (in horz and vertical directions) | |
446 | virtual wxSize GetProgressBarStep() const = 0; | |
447 | ||
448 | #if wxUSE_MENUS | |
449 | // get the size of rectangle to use in the menubar for the given text rect | |
450 | virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const = 0; | |
451 | ||
452 | // get the struct storing all layout info needed to draw all menu items | |
453 | // (this can't be calculated for each item separately as they should be | |
454 | // aligned) | |
455 | // | |
456 | // the returned pointer must be deleted by the caller | |
457 | virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, | |
458 | const wxMenu& menu) const = 0; | |
459 | #endif // wxUSE_MENUS | |
460 | ||
461 | #if wxUSE_STATUSBAR | |
462 | // get the borders around the status bar fields (x and y fields of the | |
463 | // return value) | |
464 | virtual wxSize GetStatusBarBorders() const = 0; | |
465 | ||
466 | // get the border between the status bar fields | |
467 | virtual wxCoord GetStatusBarBorderBetweenFields() const = 0; | |
468 | ||
469 | // get the mergin between a field and its border | |
470 | virtual wxSize GetStatusBarFieldMargins() const = 0; | |
471 | #endif // wxUSE_STATUSBAR | |
472 | ||
473 | // get client area rectangle of top level window (i.e. subtract | |
474 | // decorations from given rectangle) | |
475 | virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const = 0; | |
476 | ||
477 | // get size of whole top level window, given size of its client area size | |
478 | virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const = 0; | |
479 | ||
480 | // get the minimal size of top level window | |
481 | virtual wxSize GetFrameMinSize(int flags) const = 0; | |
482 | ||
483 | // get titlebar icon size | |
484 | virtual wxSize GetFrameIconSize() const = 0; | |
485 | ||
486 | // returns one of wxHT_TOPLEVEL_XXX constants | |
487 | virtual int HitTestFrame(const wxRect& rect, | |
488 | const wxPoint& pt, | |
489 | int flags = 0) const = 0; | |
490 | ||
491 | // virtual dtor for any base class | |
492 | virtual ~wxRenderer(); | |
493 | }; | |
494 | ||
495 | // ---------------------------------------------------------------------------- | |
496 | // wxDelegateRenderer: it is impossible to inherit from any of standard | |
497 | // renderers as their declarations are in private code, but you can use this | |
498 | // class to override only some of the Draw() functions - all the other ones | |
499 | // will be left to the original renderer | |
500 | // ---------------------------------------------------------------------------- | |
501 | ||
502 | class WXDLLEXPORT wxDelegateRenderer : public wxRenderer | |
503 | { | |
504 | public: | |
505 | wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { } | |
506 | ||
507 | virtual void DrawBackground(wxDC& dc, | |
508 | const wxColour& col, | |
509 | const wxRect& rect, | |
510 | int flags, | |
511 | wxWindow *window = NULL ) | |
512 | { m_renderer->DrawBackground(dc, col, rect, flags, window ); } | |
513 | virtual void DrawButtonSurface(wxDC& dc, | |
514 | const wxColour& col, | |
515 | const wxRect& rect, | |
516 | int flags) | |
517 | { m_renderer->DrawButtonSurface(dc, col, rect, flags); } | |
518 | virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0) | |
519 | { m_renderer->DrawFocusRect(dc, rect, flags); } | |
520 | virtual void DrawLabel(wxDC& dc, | |
521 | const wxString& label, | |
522 | const wxRect& rect, | |
523 | int flags = 0, | |
524 | int align = wxALIGN_LEFT | wxALIGN_TOP, | |
525 | int indexAccel = -1, | |
526 | wxRect *rectBounds = NULL) | |
527 | { m_renderer->DrawLabel(dc, label, rect, | |
528 | flags, align, indexAccel, rectBounds); } | |
529 | virtual void DrawButtonLabel(wxDC& dc, | |
530 | const wxString& label, | |
531 | const wxBitmap& image, | |
532 | const wxRect& rect, | |
533 | int flags = 0, | |
534 | int align = wxALIGN_LEFT | wxALIGN_TOP, | |
535 | int indexAccel = -1, | |
536 | wxRect *rectBounds = NULL) | |
537 | { m_renderer->DrawButtonLabel(dc, label, image, rect, | |
538 | flags, align, indexAccel, rectBounds); } | |
539 | virtual void DrawBorder(wxDC& dc, | |
540 | wxBorder border, | |
541 | const wxRect& rect, | |
542 | int flags = 0, | |
543 | wxRect *rectIn = (wxRect *)NULL) | |
544 | { m_renderer->DrawBorder(dc, border, rect, flags, rectIn); } | |
545 | virtual void DrawTextBorder(wxDC& dc, | |
546 | wxBorder border, | |
547 | const wxRect& rect, | |
548 | int flags = 0, | |
549 | wxRect *rectIn = (wxRect *)NULL) | |
550 | { m_renderer->DrawTextBorder(dc, border, rect, flags, rectIn); } | |
551 | virtual void DrawButtonBorder(wxDC& dc, | |
552 | const wxRect& rect, | |
553 | int flags = 0, | |
554 | wxRect *rectIn = (wxRect *)NULL) | |
555 | { m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); } | |
556 | virtual void DrawFrame(wxDC& dc, | |
557 | const wxString& label, | |
558 | const wxRect& rect, | |
559 | int flags = 0, | |
560 | int align = wxALIGN_LEFT, | |
561 | int indexAccel = -1) | |
562 | { m_renderer->DrawFrame(dc, label, rect, flags, align, indexAccel); } | |
563 | virtual void DrawHorizontalLine(wxDC& dc, | |
564 | wxCoord y, wxCoord x1, wxCoord x2) | |
565 | { m_renderer->DrawHorizontalLine(dc, y, x1, x2); } | |
566 | virtual void DrawVerticalLine(wxDC& dc, | |
567 | wxCoord x, wxCoord y1, wxCoord y2) | |
568 | { m_renderer->DrawVerticalLine(dc, x, y1, y2); } | |
569 | virtual void DrawArrow(wxDC& dc, | |
570 | wxDirection dir, | |
571 | const wxRect& rect, | |
572 | int flags = 0) | |
573 | { m_renderer->DrawArrow(dc, dir, rect, flags); } | |
574 | virtual void DrawScrollbarArrow(wxDC& dc, | |
575 | wxDirection dir, | |
576 | const wxRect& rect, | |
577 | int flags = 0) | |
578 | { m_renderer->DrawScrollbarArrow(dc, dir, rect, flags); } | |
579 | virtual void DrawScrollbarThumb(wxDC& dc, | |
580 | wxOrientation orient, | |
581 | const wxRect& rect, | |
582 | int flags = 0) | |
583 | { m_renderer->DrawScrollbarThumb(dc, orient, rect, flags); } | |
584 | virtual void DrawScrollbarShaft(wxDC& dc, | |
585 | wxOrientation orient, | |
586 | const wxRect& rect, | |
587 | int flags = 0) | |
588 | { m_renderer->DrawScrollbarShaft(dc, orient, rect, flags); } | |
589 | virtual void DrawScrollCorner(wxDC& dc, | |
590 | const wxRect& rect) | |
591 | { m_renderer->DrawScrollCorner(dc, rect); } | |
592 | virtual void DrawItem(wxDC& dc, | |
593 | const wxString& label, | |
594 | const wxRect& rect, | |
595 | int flags = 0) | |
596 | { m_renderer->DrawItem(dc, label, rect, flags); } | |
597 | virtual void DrawCheckItem(wxDC& dc, | |
598 | const wxString& label, | |
599 | const wxBitmap& bitmap, | |
600 | const wxRect& rect, | |
601 | int flags = 0) | |
602 | { m_renderer->DrawCheckItem(dc, label, bitmap, rect, flags); } | |
603 | virtual void DrawCheckButton(wxDC& dc, | |
604 | const wxString& label, | |
605 | const wxBitmap& bitmap, | |
606 | const wxRect& rect, | |
607 | int flags = 0, | |
608 | wxAlignment align = wxALIGN_LEFT, | |
609 | int indexAccel = -1) | |
610 | { m_renderer->DrawCheckButton(dc, label, bitmap, rect, | |
611 | flags, align, indexAccel); } | |
612 | virtual void DrawRadioButton(wxDC& dc, | |
613 | const wxString& label, | |
614 | const wxBitmap& bitmap, | |
615 | const wxRect& rect, | |
616 | int flags = 0, | |
617 | wxAlignment align = wxALIGN_LEFT, | |
618 | int indexAccel = -1) | |
619 | { m_renderer->DrawRadioButton(dc, label, bitmap, rect, | |
620 | flags, align, indexAccel); } | |
621 | #if wxUSE_TOOLBAR | |
622 | virtual void DrawToolBarButton(wxDC& dc, | |
623 | const wxString& label, | |
624 | const wxBitmap& bitmap, | |
625 | const wxRect& rect, | |
626 | int flags = 0, | |
627 | long style = 0, | |
628 | int tbarStyle = 0) | |
629 | { m_renderer->DrawToolBarButton(dc, label, bitmap, rect, flags, style, tbarStyle); } | |
630 | #endif // wxUSE_TOOLBAR | |
631 | ||
632 | #if wxUSE_TEXTCTRL | |
633 | virtual void DrawTextLine(wxDC& dc, | |
634 | const wxString& text, | |
635 | const wxRect& rect, | |
636 | int selStart = -1, | |
637 | int selEnd = -1, | |
638 | int flags = 0) | |
639 | { m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd, flags); } | |
640 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) | |
641 | { m_renderer->DrawLineWrapMark(dc, rect); } | |
642 | #endif // wxUSE_TEXTCTRL | |
643 | ||
644 | #if wxUSE_NOTEBOOK | |
645 | virtual void DrawTab(wxDC& dc, | |
646 | const wxRect& rect, | |
647 | wxDirection dir, | |
648 | const wxString& label, | |
649 | const wxBitmap& bitmap = wxNullBitmap, | |
650 | int flags = 0, | |
651 | int accel = -1) | |
652 | { m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); } | |
653 | #endif // wxUSE_NOTEBOOK | |
654 | ||
655 | #if wxUSE_SLIDER | |
656 | ||
657 | virtual void DrawSliderShaft(wxDC& dc, | |
658 | const wxRect& rect, | |
659 | int lenThumb, | |
660 | wxOrientation orient, | |
661 | int flags = 0, | |
662 | long style = 0, | |
663 | wxRect *rectShaft = NULL) | |
664 | { m_renderer->DrawSliderShaft(dc, rect, lenThumb, orient, flags, style, rectShaft); } | |
665 | virtual void DrawSliderThumb(wxDC& dc, | |
666 | const wxRect& rect, | |
667 | wxOrientation orient, | |
668 | int flags = 0, | |
669 | long style = 0) | |
670 | { m_renderer->DrawSliderThumb(dc, rect, orient, flags, style); } | |
671 | virtual void DrawSliderTicks(wxDC& dc, | |
672 | const wxRect& rect, | |
673 | int lenThumb, | |
674 | wxOrientation orient, | |
675 | int start, | |
676 | int end, | |
677 | int WXUNUSED(step) = 1, | |
678 | int flags = 0, | |
679 | long style = 0) | |
680 | { m_renderer->DrawSliderTicks(dc, rect, lenThumb, orient, | |
681 | start, end, start, flags, style); } | |
682 | #endif // wxUSE_SLIDER | |
683 | ||
684 | #if wxUSE_MENUS | |
685 | virtual void DrawMenuBarItem(wxDC& dc, | |
686 | const wxRect& rect, | |
687 | const wxString& label, | |
688 | int flags = 0, | |
689 | int indexAccel = -1) | |
690 | { m_renderer->DrawMenuBarItem(dc, rect, label, flags, indexAccel); } | |
691 | virtual void DrawMenuItem(wxDC& dc, | |
692 | wxCoord y, | |
693 | const wxMenuGeometryInfo& gi, | |
694 | const wxString& label, | |
695 | const wxString& accel, | |
696 | const wxBitmap& bitmap = wxNullBitmap, | |
697 | int flags = 0, | |
698 | int indexAccel = -1) | |
699 | { m_renderer->DrawMenuItem(dc, y, gi, label, accel, | |
700 | bitmap, flags, indexAccel); } | |
701 | virtual void DrawMenuSeparator(wxDC& dc, | |
702 | wxCoord y, | |
703 | const wxMenuGeometryInfo& geomInfo) | |
704 | { m_renderer->DrawMenuSeparator(dc, y, geomInfo); } | |
705 | #endif // wxUSE_MENUS | |
706 | ||
707 | #if wxUSE_STATUSBAR | |
708 | virtual void DrawStatusField(wxDC& dc, | |
709 | const wxRect& rect, | |
710 | const wxString& label, | |
711 | int flags = 0, int style = 0) | |
712 | { m_renderer->DrawStatusField(dc, rect, label, flags, style); } | |
713 | #endif // wxUSE_STATUSBAR | |
714 | ||
715 | virtual void DrawFrameTitleBar(wxDC& dc, | |
716 | const wxRect& rect, | |
717 | const wxString& title, | |
718 | const wxIcon& icon, | |
719 | int flags, | |
720 | int specialButton = 0, | |
721 | int specialButtonFlag = 0) | |
722 | { m_renderer->DrawFrameTitleBar(dc, rect, title, icon, flags, | |
723 | specialButton, specialButtonFlag); } | |
724 | virtual void DrawFrameBorder(wxDC& dc, | |
725 | const wxRect& rect, | |
726 | int flags) | |
727 | { m_renderer->DrawFrameBorder(dc, rect, flags); } | |
728 | virtual void DrawFrameBackground(wxDC& dc, | |
729 | const wxRect& rect, | |
730 | int flags) | |
731 | { m_renderer->DrawFrameBackground(dc, rect, flags); } | |
732 | virtual void DrawFrameTitle(wxDC& dc, | |
733 | const wxRect& rect, | |
734 | const wxString& title, | |
735 | int flags) | |
736 | { m_renderer->DrawFrameTitle(dc, rect, title, flags); } | |
737 | virtual void DrawFrameIcon(wxDC& dc, | |
738 | const wxRect& rect, | |
739 | const wxIcon& icon, | |
740 | int flags) | |
741 | { m_renderer->DrawFrameIcon(dc, rect, icon, flags); } | |
742 | virtual void DrawFrameButton(wxDC& dc, | |
743 | wxCoord x, wxCoord y, | |
744 | int button, | |
745 | int flags = 0) | |
746 | { m_renderer->DrawFrameButton(dc, x, y, button, flags); } | |
747 | ||
748 | #if wxUSE_COMBOBOX | |
749 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, | |
750 | wxBitmap *bmpFocus, | |
751 | wxBitmap *bmpPressed, | |
752 | wxBitmap *bmpDisabled) | |
753 | { m_renderer->GetComboBitmaps(bmpNormal, bmpFocus, | |
754 | bmpPressed, bmpDisabled); } | |
755 | #endif // wxUSE_COMBOBOX | |
756 | ||
757 | virtual void AdjustSize(wxSize *size, const wxWindow *window) | |
758 | { m_renderer->AdjustSize(size, window); } | |
759 | virtual wxRect GetBorderDimensions(wxBorder border) const | |
760 | { return m_renderer->GetBorderDimensions(border); } | |
761 | virtual bool AreScrollbarsInsideBorder() const | |
762 | { return m_renderer->AreScrollbarsInsideBorder(); } | |
763 | ||
764 | #if wxUSE_SCROLLBAR | |
765 | virtual wxSize GetScrollbarArrowSize() const | |
766 | { return m_renderer->GetScrollbarArrowSize(); } | |
767 | #endif // wxUSE_SCROLLBAR | |
768 | ||
769 | virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) | |
770 | { return m_renderer->GetListboxItemHeight(fontHeight); } | |
771 | virtual wxSize GetCheckBitmapSize() const | |
772 | { return m_renderer->GetCheckBitmapSize(); } | |
773 | virtual wxSize GetRadioBitmapSize() const | |
774 | { return m_renderer->GetRadioBitmapSize(); } | |
775 | virtual wxCoord GetCheckItemMargin() const | |
776 | { return m_renderer->GetCheckItemMargin(); } | |
777 | ||
778 | #if wxUSE_TOOLBAR | |
779 | virtual wxSize GetToolBarButtonSize(wxCoord *separator) const | |
780 | { return m_renderer->GetToolBarButtonSize(separator); } | |
781 | virtual wxSize GetToolBarMargin() const | |
782 | { return m_renderer->GetToolBarMargin(); } | |
783 | #endif // wxUSE_TOOLBAR | |
784 | ||
785 | #if wxUSE_TEXTCTRL | |
786 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, | |
787 | const wxRect& rect) const | |
788 | { return m_renderer->GetTextTotalArea(text, rect); } | |
789 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
790 | const wxRect& rect, | |
791 | wxCoord *extraSpaceBeyond) const | |
792 | { return m_renderer->GetTextClientArea(text, rect, extraSpaceBeyond); } | |
793 | #endif // wxUSE_TEXTCTRL | |
794 | ||
795 | #if wxUSE_NOTEBOOK | |
796 | virtual wxSize GetTabIndent() const { return m_renderer->GetTabIndent(); } | |
797 | virtual wxSize GetTabPadding() const { return m_renderer->GetTabPadding(); } | |
798 | #endif // wxUSE_NOTEBOOK | |
799 | ||
800 | #if wxUSE_SLIDER | |
801 | virtual wxCoord GetSliderDim() const | |
802 | { return m_renderer->GetSliderDim(); } | |
803 | virtual wxCoord GetSliderTickLen() const | |
804 | { return m_renderer->GetSliderTickLen(); } | |
805 | ||
806 | virtual wxRect GetSliderShaftRect(const wxRect& rect, | |
807 | int lenThumb, | |
808 | wxOrientation orient, | |
809 | long style = 0) const | |
810 | { return m_renderer->GetSliderShaftRect(rect, lenThumb, orient, style); } | |
811 | virtual wxSize GetSliderThumbSize(const wxRect& rect, | |
812 | int lenThumb, | |
813 | wxOrientation orient) const | |
814 | { return m_renderer->GetSliderThumbSize(rect, lenThumb, orient); } | |
815 | #endif // wxUSE_SLIDER | |
816 | ||
817 | virtual wxSize GetProgressBarStep() const | |
818 | { return m_renderer->GetProgressBarStep(); } | |
819 | ||
820 | #if wxUSE_MENUS | |
821 | virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const | |
822 | { return m_renderer->GetMenuBarItemSize(sizeText); } | |
823 | virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, | |
824 | const wxMenu& menu) const | |
825 | { return m_renderer->GetMenuGeometry(win, menu); } | |
826 | #endif // wxUSE_MENUS | |
827 | ||
828 | #if wxUSE_STATUSBAR | |
829 | virtual wxSize GetStatusBarBorders() const | |
830 | { return m_renderer->GetStatusBarBorders(); } | |
831 | virtual wxCoord GetStatusBarBorderBetweenFields() const | |
832 | { return m_renderer->GetStatusBarBorderBetweenFields(); } | |
833 | virtual wxSize GetStatusBarFieldMargins() const | |
834 | { return m_renderer->GetStatusBarFieldMargins(); } | |
835 | #endif // wxUSE_STATUSBAR | |
836 | ||
837 | virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const | |
838 | { return m_renderer->GetFrameClientArea(rect, flags); } | |
839 | virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const | |
840 | { return m_renderer->GetFrameTotalSize(clientSize, flags); } | |
841 | virtual wxSize GetFrameMinSize(int flags) const | |
842 | { return m_renderer->GetFrameMinSize(flags); } | |
843 | virtual wxSize GetFrameIconSize() const | |
844 | { return m_renderer->GetFrameIconSize(); } | |
845 | virtual int HitTestFrame(const wxRect& rect, | |
846 | const wxPoint& pt, | |
847 | int flags) const | |
848 | { return m_renderer->HitTestFrame(rect, pt, flags); } | |
849 | ||
850 | virtual void DrawHeaderButton(wxWindow *win, | |
851 | wxDC& dc, | |
852 | const wxRect& rect, | |
853 | int flags = 0, | |
854 | wxHeaderSortIconType sortIcon = wxHDR_SORT_ICON_NONE, | |
855 | wxHeaderButtonParams* params = NULL) | |
856 | { m_renderer->DrawHeaderButton(win, dc, rect, flags, sortIcon, params); } | |
857 | virtual void DrawTreeItemButton(wxWindow *win, | |
858 | wxDC& dc, | |
859 | const wxRect& rect, | |
860 | int flags = 0) | |
861 | { m_renderer->DrawTreeItemButton(win, dc, rect, flags); } | |
862 | ||
863 | protected: | |
864 | wxRenderer *m_renderer; | |
865 | }; | |
866 | ||
867 | // ---------------------------------------------------------------------------- | |
868 | // wxControlRenderer: wraps the wxRenderer functions in a form easy to use from | |
869 | // OnPaint() | |
870 | // ---------------------------------------------------------------------------- | |
871 | ||
872 | class WXDLLEXPORT wxControlRenderer | |
873 | { | |
874 | public: | |
875 | // create a renderer for this dc with this "fundamental" renderer | |
876 | wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer); | |
877 | ||
878 | // operations | |
879 | void DrawLabel(const wxBitmap& bitmap = wxNullBitmap, | |
880 | wxCoord marginX = 0, wxCoord marginY = 0); | |
881 | #if wxUSE_LISTBOX | |
882 | void DrawItems(const wxListBox *listbox, | |
883 | size_t itemFirst, size_t itemLast); | |
884 | #endif // wxUSE_LISTBOX | |
885 | #if wxUSE_CHECKLISTBOX | |
886 | void DrawCheckItems(const wxCheckListBox *listbox, | |
887 | size_t itemFirst, size_t itemLast); | |
888 | #endif // wxUSE_CHECKLISTBOX | |
889 | void DrawButtonBorder(); | |
890 | // the line must be either horizontal or vertical | |
891 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
892 | void DrawFrame(); | |
893 | void DrawBitmap(const wxBitmap& bitmap); | |
894 | void DrawBackgroundBitmap(); | |
895 | void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld); | |
896 | #if wxUSE_GAUGE | |
897 | void DrawProgressBar(const wxGauge *gauge); | |
898 | #endif // wxUSE_GAUGE | |
899 | ||
900 | // accessors | |
901 | wxWindow *GetWindow() const { return m_window; } | |
902 | wxRenderer *GetRenderer() const { return m_renderer; } | |
903 | ||
904 | wxDC& GetDC() { return m_dc; } | |
905 | ||
906 | const wxRect& GetRect() const { return m_rect; } | |
907 | wxRect& GetRect() { return m_rect; } | |
908 | ||
909 | // static helpers | |
910 | static void DrawBitmap(wxDC &dc, | |
911 | const wxBitmap& bitmap, | |
912 | const wxRect& rect, | |
913 | int alignment = wxALIGN_CENTRE | | |
914 | wxALIGN_CENTRE_VERTICAL, | |
915 | wxStretch stretch = wxSTRETCH_NOT); | |
916 | ||
917 | private: | |
918 | ||
919 | #if wxUSE_LISTBOX | |
920 | // common part of DrawItems() and DrawCheckItems() | |
921 | void DoDrawItems(const wxListBox *listbox, | |
922 | size_t itemFirst, size_t itemLast, | |
923 | bool isCheckLbox = false); | |
924 | #endif // wxUSE_LISTBOX | |
925 | ||
926 | wxWindow *m_window; | |
927 | wxRenderer *m_renderer; | |
928 | wxDC& m_dc; | |
929 | wxRect m_rect; | |
930 | }; | |
931 | ||
932 | #endif // _WX_UNIV_RENDERER_H_ |