]> git.saurik.com Git - wxWidgets.git/blob - samples/render/renddll.cpp
Make storing non-trivial data in wxThreadSpecificInfo possible.
[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 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #include "wx/renderer.h"
18
19 #ifndef WX_PRECOMP
20 #include "wx/dc.h"
21 #endif
22
23 // derive from wxDelegateRendererNative and not wxRendererNative itself to be
24 // able to only reimplement the methods we want to show and not all of them
25 class MyDllRenderer : public wxDelegateRendererNative
26 {
27 public:
28 // draw the header control button (used by wxListCtrl)
29 virtual int DrawHeaderButton(wxWindow * WXUNUSED(win),
30 wxDC& dc,
31 const wxRect& rect,
32 int WXUNUSED(flags) = 0,
33 wxHeaderSortIconType WXUNUSED(sortArrow) = wxHDR_SORT_ICON_NONE,
34 wxHeaderButtonParams* WXUNUSED(params) = NULL)
35 {
36 dc.SetBrush(*wxCYAN_BRUSH);
37 dc.SetTextForeground(*wxRED);
38 dc.DrawRoundedRectangle(rect, 10);
39 dc.DrawLabel("MyDllRenderer", wxNullBitmap, rect, wxALIGN_CENTER);
40
41 return dc.GetTextExtent("MyDllRenderer").x;
42 }
43
44 virtual wxRendererVersion GetVersion() const
45 {
46 return wxRendererVersion(wxRendererVersion::Current_Version,
47 wxRendererVersion::Current_Age);
48 }
49
50 #if 0 // just for debugging
51 MyDllRenderer()
52 {
53 wxMessageBox(wxT("Creating MyDllRenderer"), wxT("Renderer Sample"));
54 }
55
56 virtual ~MyDllRenderer()
57 {
58 wxMessageBox(wxT("Deleting MyDllRenderer"), wxT("Renderer Sample"));
59 }
60 #endif // 0
61 };
62
63 extern "C"
64 WXEXPORT wxRendererNative *wxCreateRenderer()
65 {
66 return new MyDllRenderer;
67 }