added sample showing how to use custom renderers and load them from DLL
[wxWidgets.git] / samples / render / renddll.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: renddll.cpp
3 // Purpose: Example of a renderer implemented in a DLL
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 04.08.03
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/renderer.h"
15
16 class MyDllRenderer : public wxRendererNative
17 {
18 public:
19 // draw the header control button (used by wxListCtrl)
20 virtual void DrawHeaderButton(wxWindow *win,
21 wxDC& dc,
22 const wxRect& rect,
23 int flags = 0)
24 {
25 dc.SetBrush(*wxCYAN_BRUSH);
26 dc.SetTextForeground(*wxRED);
27 dc.DrawRoundedRectangle(rect, 10);
28 dc.DrawLabel(_T("MyDllRenderer"), wxNullBitmap, rect, wxALIGN_CENTER);
29 }
30
31 // draw the expanded/collapsed icon for a tree control item
32 virtual void DrawTreeItemButton(wxWindow *win,
33 wxDC& dc,
34 const wxRect& rect,
35 int flags = 0)
36 {
37 }
38
39 // draw the border for sash window: this border must be such that the sash
40 // drawn by DrawSash() blends into it well
41 virtual void DrawSplitterBorder(wxWindow *win,
42 wxDC& dc,
43 const wxRect& rect,
44 int flags = 0)
45 {
46 }
47
48 // draw a (vertical) sash
49 virtual void DrawSplitterSash(wxWindow *win,
50 wxDC& dc,
51 const wxSize& size,
52 wxCoord position,
53 wxOrientation orient,
54 int flags = 0)
55 {
56 }
57
58 // get the splitter parameters: the x field of the returned point is the
59 // sash width and the y field is the border width
60 virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win)
61 {
62 return wxSplitterRenderParams(0, 0, 0);
63 }
64
65 #if 0 // just for debugging
66 MyDllRenderer()
67 {
68 wxMessageBox(_T("Creating MyDllRenderer"), _T("Renderer Sample"));
69 }
70
71 virtual ~MyDllRenderer()
72 {
73 wxMessageBox(_T("Deleting MyDllRenderer"), _T("Renderer Sample"));
74 }
75 #endif // 0
76 };
77
78 extern "C"
79 WXEXPORT wxRendererNative *wxCreateRenderer()
80 {
81 return new MyDllRenderer;
82 }
83