]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
Removed all duplicated and complicated #ifdefs for enabling Skip and Abort in progres...
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: statbar.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 #ifdef __GNUG__
13 #pragma implementation "statbrma.h"
14 #endif
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/statusbr.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23
24 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
25 EVT_PAINT(wxStatusBarMac::OnPaint)
26 END_EVENT_TABLE()
27
28 #ifdef __WXMAC__
29 #include "wx/mac/private.h"
30 #include "wx/toplevel.h"
31 #endif
32
33 // ============================================================================
34 // implementation
35 // ============================================================================
36
37 // ----------------------------------------------------------------------------
38 // wxStatusBarMac class
39 // ----------------------------------------------------------------------------
40
41 wxStatusBarMac::wxStatusBarMac()
42 {
43 SetParent(NULL);
44 }
45
46 wxStatusBarMac::~wxStatusBarMac()
47 {
48 }
49
50 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
51 long style ,
52 const wxString& name)
53 {
54 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
55 return FALSE ;
56
57 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
58 MacSetBackgroundBrush( wxNullBrush ) ;
59
60 // normal system font is too tall for fitting into the standard height
61 SetWindowVariant( wxWINDOW_VARIANT_SMALL ) ;
62
63 return TRUE ;
64 }
65
66 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
67 {
68 int leftMargin = 2;
69 int w, h ;
70 GetSize( &w , &h ) ;
71 wxRect rect;
72 GetFieldRect(i, rect);
73
74 if ( !MacIsReallyHilited() )
75 {
76 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
77 }
78
79 wxString text(GetStatusText(i));
80
81 long x, y;
82
83 dc.GetTextExtent(text, &x, &y);
84
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 _T("invalid status bar field index") );
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,40,40) ,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 dc.DrawLine(0, 0 ,
146 w , 0);
147 dc.SetPen(white);
148 dc.DrawLine(0, 1 ,
149 w , 1);
150 }
151 else
152 {
153 if (major >= 10)
154 //Finder statusbar border color: (Project builder similar is 9B9B9B)
155 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
156 else
157 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
158
159 dc.DrawLine(0, 0 ,
160 w , 0);
161 }
162
163 int i;
164 if ( GetFont().Ok() )
165 dc.SetFont(GetFont());
166 dc.SetBackgroundMode(wxTRANSPARENT);
167
168 for ( i = 0; i < m_nFields; i ++ )
169 DrawField(dc, i);
170 }
171
172 void wxStatusBarMac::MacHiliteChanged()
173 {
174 Refresh() ;
175 Update() ;
176 }