]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
great copy ctor/assignment operators cleanup by Paul Cornett (patch 1307665)
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/statbarma.cpp
3 // Purpose: native implementation of wxStatusBar (optional)
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/statusbr.h"
15 #include "wx/dc.h"
16 #include "wx/dcclient.h"
17
18 #include "wx/mac/private.h"
19 #include "wx/toplevel.h"
20
21
22 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
23 EVT_PAINT(wxStatusBarMac::OnPaint)
24 END_EVENT_TABLE()
25
26
27 wxStatusBarMac::wxStatusBarMac(wxWindow *parent,
28 wxWindowID id,
29 long style,
30 const wxString& name)
31 :
32 wxStatusBarGeneric()
33 {
34 SetParent( NULL );
35 Create( parent, id, style, name );
36 }
37
38 wxStatusBarMac::wxStatusBarMac()
39 :
40 wxStatusBarGeneric()
41 {
42 SetParent( NULL );
43 }
44
45 wxStatusBarMac::~wxStatusBarMac()
46 {
47 }
48
49 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
50 long style ,
51 const wxString& name)
52 {
53 if ( !wxStatusBarGeneric::Create( parent, id, style, name ) )
54 return false;
55
56 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
57 MacSetBackgroundBrush( wxNullBrush );
58
59 // normal system font is too tall for fitting into the standard height
60 SetWindowVariant( wxWINDOW_VARIANT_SMALL );
61
62 return true;
63 }
64
65 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
66 {
67 int w, h;
68 GetSize( &w , &h );
69 wxRect rect;
70 GetFieldRect( i, rect );
71
72 if ( !MacIsReallyHilited() )
73 dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
74
75 wxString text(GetStatusText( i ));
76
77 long x, y;
78
79 dc.GetTextExtent(text, &x, &y);
80
81 int leftMargin = 2;
82 int xpos = rect.x + leftMargin + 1;
83 int ypos = 1;
84
85 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
86 ypos++;
87
88 dc.SetClippingRegion(rect.x, 0, rect.width, h);
89
90 dc.DrawText(text, xpos, ypos);
91
92 dc.DestroyClippingRegion();
93 }
94
95 void wxStatusBarMac::DrawField(wxDC& dc, int i)
96 {
97 DrawFieldText(dc, i);
98 }
99
100 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
101 {
102 wxCHECK_RET( (number >= 0) && (number < m_nFields),
103 wxT("invalid status bar field index") );
104
105 if ( m_statusStrings[number] == text )
106 return ;
107
108 m_statusStrings[number] = text;
109 wxRect rect;
110 GetFieldRect(number, rect);
111 int w, h;
112 GetSize( &w, &h );
113 rect.y = 0;
114 rect.height = h ;
115 Refresh( true, &rect );
116 Update();
117 }
118
119 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
120 {
121 wxPaintDC dc(this);
122 dc.Clear();
123
124 int major, minor;
125 wxGetOsVersion( &major, &minor );
126 int w, h;
127 GetSize( &w, &h );
128
129 if ( MacIsReallyHilited() )
130 {
131 wxPen white( *wxWHITE , 1 , wxSOLID );
132 if (major >= 10)
133 {
134 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
135 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
136 dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID));
137 else
138 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
139 }
140 else
141 {
142 wxPen black( *wxBLACK , 1 , wxSOLID );
143 dc.SetPen(black);
144 }
145
146 dc.DrawLine(0, 0, w, 0);
147 dc.SetPen(white);
148 dc.DrawLine(0, 1, w, 1);
149 }
150 else
151 {
152 if (major >= 10)
153 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
154 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
155 else
156 dc.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID));
157
158 dc.DrawLine(0, 0, w, 0);
159 }
160
161 int i;
162 if ( GetFont().Ok() )
163 dc.SetFont(GetFont());
164 dc.SetBackgroundMode(wxTRANSPARENT);
165
166 for ( i = 0; i < m_nFields; i ++ )
167 DrawField(dc, i);
168 }
169
170 void wxStatusBarMac::MacHiliteChanged()
171 {
172 Refresh();
173 Update();
174 }