]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
29131affcd0bef46111b659e081dae41ec346a42
[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 #endif
31
32 // ============================================================================
33 // implementation
34 // ============================================================================
35
36 // ----------------------------------------------------------------------------
37 // wxStatusBarMac class
38 // ----------------------------------------------------------------------------
39
40 wxStatusBarMac::wxStatusBarMac()
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 return TRUE ;
60 }
61
62 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
63 {
64 int leftMargin = 2;
65 int w, h ;
66 GetSize( &w , &h ) ;
67 wxRect rect;
68 GetFieldRect(i, rect);
69
70 if ( !MacGetTopLevelWindow()->MacGetMetalAppearance() && !IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
71 {
72 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
73 }
74
75 wxString text(GetStatusText(i));
76
77 long x, y;
78
79 dc.GetTextExtent(text, &x, &y);
80
81 int xpos = rect.x + leftMargin + 1 ;
82 int ypos = 2 ;
83
84 dc.SetClippingRegion(rect.x, 0, rect.width, h);
85
86 dc.DrawText(text, xpos, ypos);
87
88 dc.DestroyClippingRegion();
89 }
90
91 void wxStatusBarMac::DrawField(wxDC& dc, int i)
92 {
93 DrawFieldText(dc, i);
94 }
95
96 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
97 {
98 wxCHECK_RET( (number >= 0) && (number < m_nFields),
99 _T("invalid status bar field index") );
100
101 m_statusStrings[number] = text;
102 wxRect rect;
103 GetFieldRect(number, rect);
104 int w, h ;
105 GetSize( &w , &h ) ;
106 rect.y=0;
107 rect.height = h ;
108 Refresh( TRUE , &rect ) ;
109 Update();
110 }
111
112 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
113 {
114 wxPaintDC dc(this);
115 dc.Clear() ;
116
117 int major,minor;
118 wxGetOsVersion( &major, &minor );
119 int w, h ;
120 GetSize( &w , &h ) ;
121
122 if ( IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) || MacGetTopLevelWindow()->MacGetMetalAppearance() )
123 {
124 wxPen white( wxWHITE , 1 , wxSOLID ) ;
125 if (major >= 10 )
126 {
127 //Finder statusbar border color: (Project builder similar is 9B9B9B)
128 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
129 dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ;
130 else
131 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
132 }
133 else
134 {
135 wxPen black( wxBLACK , 1 , wxSOLID ) ;
136 dc.SetPen(black);
137 }
138 dc.DrawLine(0, 0 ,
139 w , 0);
140 dc.SetPen(white);
141 dc.DrawLine(0, 1 ,
142 w , 1);
143 }
144 else
145 {
146 if (major >= 10)
147 //Finder statusbar border color: (Project builder similar is 9B9B9B)
148 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
149 else
150 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
151
152 dc.DrawLine(0, 0 ,
153 w , 0);
154 }
155
156 int i;
157 if ( GetFont().Ok() )
158 dc.SetFont(GetFont());
159 dc.SetBackgroundMode(wxTRANSPARENT);
160
161 for ( i = 0; i < m_nFields; i ++ )
162 DrawField(dc, i);
163 }