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