]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
Common code for the same handling of wxSL_INVERSE.
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "statbrma.h"
14 #endif
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21
22 #include "wx/statusbr.h"
23 #include "wx/dc.h"
24 #include "wx/dcclient.h"
25
26 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
27 EVT_PAINT(wxStatusBarMac::OnPaint)
28 END_EVENT_TABLE()
29
30 #ifdef __WXMAC__
31 #include "wx/mac/private.h"
32 #include "wx/toplevel.h"
33 #endif
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 // ----------------------------------------------------------------------------
40 // wxStatusBarMac class
41 // ----------------------------------------------------------------------------
42
43 wxStatusBarMac::wxStatusBarMac()
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 leftMargin = 2;
71 int w, h ;
72 GetSize( &w , &h ) ;
73 wxRect rect;
74 GetFieldRect(i, rect);
75
76 if ( !MacIsReallyHilited() )
77 {
78 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
79 }
80
81 wxString text(GetStatusText(i));
82
83 long x, y;
84
85 dc.GetTextExtent(text, &x, &y);
86
87 int xpos = rect.x + leftMargin + 1 ;
88 int ypos = 1 ;
89
90 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
91 ypos++ ;
92
93 dc.SetClippingRegion(rect.x, 0, rect.width, h);
94
95 dc.DrawText(text, xpos, ypos);
96
97 dc.DestroyClippingRegion();
98 }
99
100 void wxStatusBarMac::DrawField(wxDC& dc, int i)
101 {
102 DrawFieldText(dc, i);
103 }
104
105 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
106 {
107 wxCHECK_RET( (number >= 0) && (number < m_nFields),
108 _T("invalid status bar field index") );
109
110 m_statusStrings[number] = text;
111 wxRect rect;
112 GetFieldRect(number, rect);
113 int w, h ;
114 GetSize( &w , &h ) ;
115 rect.y=0;
116 rect.height = h ;
117 Refresh( TRUE , &rect ) ;
118 Update();
119 }
120
121 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
122 {
123 wxPaintDC dc(this);
124 dc.Clear() ;
125
126 int major,minor;
127 wxGetOsVersion( &major, &minor );
128 int w, h ;
129 GetSize( &w , &h ) ;
130
131 if ( MacIsReallyHilited() )
132 {
133 wxPen white( wxWHITE , 1 , wxSOLID ) ;
134 if (major >= 10 )
135 {
136 //Finder statusbar border color: (Project builder similar is 9B9B9B)
137 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
138 dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ;
139 else
140 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
141 }
142 else
143 {
144 wxPen black( wxBLACK , 1 , wxSOLID ) ;
145 dc.SetPen(black);
146 }
147 dc.DrawLine(0, 0 ,
148 w , 0);
149 dc.SetPen(white);
150 dc.DrawLine(0, 1 ,
151 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 ,
162 w , 0);
163 }
164
165 int i;
166 if ( GetFont().Ok() )
167 dc.SetFont(GetFont());
168 dc.SetBackgroundMode(wxTRANSPARENT);
169
170 for ( i = 0; i < m_nFields; i ++ )
171 DrawField(dc, i);
172 }
173
174 void wxStatusBarMac::MacHiliteChanged()
175 {
176 Refresh() ;
177 Update() ;
178 }