]>
Commit | Line | Data |
---|---|---|
9c7f49f5 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: mac/renderer.cpp | |
38c4cb6a | 3 | // Purpose: implementation of wxRendererNative for Mac |
9c7f49f5 VZ |
4 | // Author: Vadim Zeitlin |
5 | // Modified by: | |
6 | // Created: 20.07.2003 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org> | |
9 | // License: wxWindows license | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // for compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #ifndef WX_PRECOMP | |
28 | #include "wx/string.h" | |
4c948343 VZ |
29 | #include "wx/dc.h" |
30 | #include "wx/bitmap.h" | |
31 | #include "wx/settings.h" | |
9c7f49f5 VZ |
32 | #endif //WX_PRECOMP |
33 | ||
34 | #include "wx/renderer.h" | |
35 | ||
36 | // ---------------------------------------------------------------------------- | |
38c4cb6a | 37 | // wxRendererMac: our wxRendererNative implementation |
9c7f49f5 VZ |
38 | // ---------------------------------------------------------------------------- |
39 | ||
5cb80ad2 | 40 | class WXDLLEXPORT wxRendererMac : public wxDelegateRendererNative |
9c7f49f5 VZ |
41 | { |
42 | public: | |
43 | // draw the header control button (used by wxListCtrl) | |
44 | virtual void DrawHeaderButton(wxWindow *win, | |
45 | wxDC& dc, | |
46 | const wxRect& rect, | |
47 | int flags = 0); | |
48 | ||
49 | // draw the expanded/collapsed icon for a tree control item | |
50 | virtual void DrawTreeItemButton(wxWindow *win, | |
51 | wxDC& dc, | |
52 | const wxRect& rect, | |
53 | int flags = 0); | |
54 | ||
b3208e11 VZ |
55 | // draw a (vertical) sash |
56 | virtual void DrawSplitterSash(wxWindow *win, | |
57 | wxDC& dc, | |
58 | const wxSize& size, | |
62dc9cb4 VZ |
59 | wxCoord position, |
60 | wxOrientation orient); | |
b3208e11 | 61 | |
9c7f49f5 VZ |
62 | private: |
63 | // the tree buttons | |
64 | wxBitmap m_bmpTreeExpanded, | |
65 | m_bmpTreeCollapsed; | |
66 | }; | |
67 | ||
68 | // ---------------------------------------------------------------------------- | |
69 | // Aqua arrows | |
70 | // ---------------------------------------------------------------------------- | |
71 | ||
72 | /* XPM */ | |
73 | static const char *aqua_arrow_right_xpm[] = { | |
74 | /* columns rows colors chars-per-pixel */ | |
75 | "13 11 4 1", | |
76 | " c None", | |
77 | "b c #C0C0C0", | |
78 | "c c #707070", | |
79 | "d c #A0A0A0", | |
80 | /* pixels */ | |
81 | " b ", | |
82 | " ddb ", | |
83 | " cccdb ", | |
84 | " cccccd ", | |
85 | " ccccccdb ", | |
86 | " ccccccccd", | |
87 | " ccccccdb ", | |
88 | " cccccb ", | |
89 | " cccdb ", | |
90 | " ddb ", | |
91 | " b " | |
92 | }; | |
93 | ||
94 | /* XPM */ | |
95 | static const char *aqua_arrow_down_xpm[] = { | |
96 | /* columns rows colors chars-per-pixel */ | |
97 | "13 11 4 1", | |
98 | " c None", | |
99 | "b c #C0C0C0", | |
100 | "c c #707070", | |
101 | "d c #A0A0A0", | |
102 | /* pixels */ | |
103 | " ", | |
104 | " ", | |
105 | " bdcccccccdb ", | |
106 | " dcccccccd ", | |
107 | " bcccccccb ", | |
108 | " dcccccd ", | |
109 | " bcccccb ", | |
110 | " bcccd ", | |
111 | " dcd ", | |
112 | " bcb ", | |
113 | " d " | |
114 | }; | |
115 | ||
116 | // ============================================================================ | |
117 | // implementation | |
118 | // ============================================================================ | |
119 | ||
120 | /* static */ | |
f0244295 | 121 | wxRendererNative& wxRendererNative::GetDefault() |
9c7f49f5 VZ |
122 | { |
123 | static wxRendererMac s_rendererMac; | |
124 | ||
125 | return s_rendererMac; | |
126 | } | |
127 | ||
128 | void | |
129 | wxRendererMac::DrawHeaderButton(wxWindow *win, | |
130 | wxDC& dc, | |
131 | const wxRect& rect, | |
132 | int WXUNUSED(flags)) | |
133 | { | |
134 | const int CORNER = 1; | |
135 | ||
136 | const wxCoord x = rect.x, | |
137 | y = rect.y, | |
138 | w = rect.width, | |
139 | h = rect.height; | |
140 | ||
141 | dc.SetBrush( *wxTRANSPARENT_BRUSH ); | |
142 | ||
143 | dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) ); | |
144 | dc.DrawLine( x+w-CORNER+1, y, x+w, y+h ); // right (outer) | |
145 | dc.DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer) | |
146 | ||
147 | wxPen pen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID ); | |
148 | ||
149 | dc.SetPen( pen ); | |
150 | dc.DrawLine( x+w-CORNER, y, x+w-1, y+h ); // right (inner) | |
151 | dc.DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner) | |
152 | ||
153 | dc.SetPen( *wxWHITE_PEN ); | |
154 | dc.DrawRectangle( x, y, w-CORNER+1, 1 ); // top (outer) | |
155 | dc.DrawRectangle( x, y, 1, h ); // left (outer) | |
156 | dc.DrawLine( x, y+h-1, x+1, y+h-1 ); | |
157 | dc.DrawLine( x+w-1, y, x+w-1, y+1 ); | |
158 | } | |
159 | ||
160 | void | |
161 | wxRendererMac::DrawTreeItemButton(wxWindow *win, | |
162 | wxDC& dc, | |
163 | const wxRect& rect, | |
164 | int flags) | |
165 | { | |
166 | // init the buttons on demand | |
167 | if ( !m_bmpTreeExpanded.Ok() ) | |
168 | { | |
169 | m_bmpTreeExpanded = wxBitmap(aqua_arrow_down_xpm); | |
170 | m_bmpTreeCollapsed = wxBitmap(aqua_arrow_right_xpm); | |
171 | } | |
172 | ||
173 | // draw them | |
174 | ||
175 | // VZ: this is the old code from treectlg.cpp which apparently doesn't work | |
176 | // but I kept it here just in case it is needed -- if not, please | |
177 | // remove it | |
178 | #if 0 // def __WXMAC__ | |
179 | wxMacPortSetter helper(&dc) ; | |
180 | wxMacWindowClipper clipper(this) ; | |
181 | wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ; | |
182 | ||
183 | int loc_x = x - 5 ; | |
184 | int loc_y = y_mid - 6 ; | |
185 | MacWindowToRootWindow( & loc_x , & loc_y ) ; | |
186 | Rect bounds = { loc_y , loc_x , loc_y + 18 , loc_x + 12 } ; | |
187 | ThemeButtonDrawInfo info = { kThemeStateActive , item->IsExpanded() ? kThemeDisclosureDown : kThemeDisclosureRight , | |
188 | kThemeAdornmentNone }; | |
189 | DrawThemeButton( &bounds, kThemeDisclosureButton , | |
190 | &info , NULL , NULL , NULL , NULL ) ; | |
191 | #else // 1 | |
192 | dc.DrawBitmap(flags & wxCONTROL_EXPANDED ? m_bmpTreeExpanded | |
193 | : m_bmpTreeCollapsed, | |
194 | rect.x, rect.y, true /* use mask */); | |
195 | #endif // 0/1 | |
196 | } | |
197 | ||
b3208e11 | 198 | void |
e356d469 VZ |
199 | wxRendererMac::DrawSplitterSash(wxWindow *win, |
200 | wxDC& dc, | |
201 | const wxSize& size, | |
62dc9cb4 VZ |
202 | wxCoord position, |
203 | wxOrientation orient) | |
b3208e11 VZ |
204 | { |
205 | // VZ: we have to somehow determine if we're drawing a normal sash or | |
206 | // a brushed metal one as they look quite differently... this is | |
207 | // completely bogus anyhow, of course (TODO) | |
208 | ||
b3208e11 VZ |
209 | dc.SetPen(*wxLIGHT_GREY_PEN); |
210 | dc.SetBrush(*wxWHITE_BRUSH); | |
62dc9cb4 VZ |
211 | if ( orient == wxVERTICAL ) |
212 | dc.DrawRectangle(position, 0, 7, size.y); | |
213 | else | |
214 | dc.DrawRectangle(0, position, size.x, 7); | |
b3208e11 VZ |
215 | } |
216 |