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