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