renderer.h 39 KB

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