]> git.saurik.com Git - wxWidgets.git/blame - src/mac/renderer.cpp
initialize ICONINFO to avoid Purify warnings
[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
38c4cb6a 37class WXDLLEXPORT wxRendererMac : public wxRendererNative
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
52private:
53 // the tree buttons
54 wxBitmap m_bmpTreeExpanded,
55 m_bmpTreeCollapsed;
56};
57
58// ----------------------------------------------------------------------------
59// Aqua arrows
60// ----------------------------------------------------------------------------
61
62/* XPM */
63static const char *aqua_arrow_right_xpm[] = {
64/* columns rows colors chars-per-pixel */
65"13 11 4 1",
66" c None",
67"b c #C0C0C0",
68"c c #707070",
69"d c #A0A0A0",
70/* pixels */
71" b ",
72" ddb ",
73" cccdb ",
74" cccccd ",
75" ccccccdb ",
76" ccccccccd",
77" ccccccdb ",
78" cccccb ",
79" cccdb ",
80" ddb ",
81" b "
82};
83
84/* XPM */
85static const char *aqua_arrow_down_xpm[] = {
86/* columns rows colors chars-per-pixel */
87"13 11 4 1",
88" c None",
89"b c #C0C0C0",
90"c c #707070",
91"d c #A0A0A0",
92/* pixels */
93" ",
94" ",
95" bdcccccccdb ",
96" dcccccccd ",
97" bcccccccb ",
98" dcccccd ",
99" bcccccb ",
100" bcccd ",
101" dcd ",
102" bcb ",
103" d "
104};
105
106// ============================================================================
107// implementation
108// ============================================================================
109
110/* static */
111wxRendererNative& wxRendererMac::Get()
112{
113 static wxRendererMac s_rendererMac;
114
115 return s_rendererMac;
116}
117
118void
119wxRendererMac::DrawHeaderButton(wxWindow *win,
120 wxDC& dc,
121 const wxRect& rect,
122 int WXUNUSED(flags))
123{
124 const int CORNER = 1;
125
126 const wxCoord x = rect.x,
127 y = rect.y,
128 w = rect.width,
129 h = rect.height;
130
131 dc.SetBrush( *wxTRANSPARENT_BRUSH );
132
133 dc.SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) );
134 dc.DrawLine( x+w-CORNER+1, y, x+w, y+h ); // right (outer)
135 dc.DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
136
137 wxPen pen( wxColour( 0x88 , 0x88 , 0x88 ), 1, wxSOLID );
138
139 dc.SetPen( pen );
140 dc.DrawLine( x+w-CORNER, y, x+w-1, y+h ); // right (inner)
141 dc.DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner)
142
143 dc.SetPen( *wxWHITE_PEN );
144 dc.DrawRectangle( x, y, w-CORNER+1, 1 ); // top (outer)
145 dc.DrawRectangle( x, y, 1, h ); // left (outer)
146 dc.DrawLine( x, y+h-1, x+1, y+h-1 );
147 dc.DrawLine( x+w-1, y, x+w-1, y+1 );
148}
149
150void
151wxRendererMac::DrawTreeItemButton(wxWindow *win,
152 wxDC& dc,
153 const wxRect& rect,
154 int flags)
155{
156 // init the buttons on demand
157 if ( !m_bmpTreeExpanded.Ok() )
158 {
159 m_bmpTreeExpanded = wxBitmap(aqua_arrow_down_xpm);
160 m_bmpTreeCollapsed = wxBitmap(aqua_arrow_right_xpm);
161 }
162
163 // draw them
164
165 // VZ: this is the old code from treectlg.cpp which apparently doesn't work
166 // but I kept it here just in case it is needed -- if not, please
167 // remove it
168#if 0 // def __WXMAC__
169 wxMacPortSetter helper(&dc) ;
170 wxMacWindowClipper clipper(this) ;
171 wxDC::MacSetupBackgroundForCurrentPort( MacGetBackgroundBrush() ) ;
172
173 int loc_x = x - 5 ;
174 int loc_y = y_mid - 6 ;
175 MacWindowToRootWindow( & loc_x , & loc_y ) ;
176 Rect bounds = { loc_y , loc_x , loc_y + 18 , loc_x + 12 } ;
177 ThemeButtonDrawInfo info = { kThemeStateActive , item->IsExpanded() ? kThemeDisclosureDown : kThemeDisclosureRight ,
178 kThemeAdornmentNone };
179 DrawThemeButton( &bounds, kThemeDisclosureButton ,
180 &info , NULL , NULL , NULL , NULL ) ;
181#else // 1
182 dc.DrawBitmap(flags & wxCONTROL_EXPANDED ? m_bmpTreeExpanded
183 : m_bmpTreeCollapsed,
184 rect.x, rect.y, true /* use mask */);
185#endif // 0/1
186}
187