]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/statbrma.cpp
removed IsShown guards, allowing now for manipulation of hidden toolbars
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
CommitLineData
ee6b1d97
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: statbar.cpp
3// Purpose: native implementation of wxStatusBar (optional)
a31a5f85 4// Author: Stefan Csomor
ee6b1d97 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
12#ifdef __GNUG__
b142515e 13#pragma implementation "statbrma.h"
ee6b1d97
SC
14#endif
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
03e11df5
GD
20#include "wx/statusbr.h"
21#include "wx/dc.h"
22#include "wx/dcclient.h"
ee6b1d97 23
ee6b1d97 24BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
e40298d5 25 EVT_PAINT(wxStatusBarMac::OnPaint)
ee6b1d97 26END_EVENT_TABLE()
ee6b1d97 27
76a5e5d2
SC
28#ifdef __WXMAC__
29#include "wx/mac/private.h"
3a72b6a4 30#include "wx/toplevel.h"
76a5e5d2
SC
31#endif
32
ee6b1d97
SC
33// ============================================================================
34// implementation
35// ============================================================================
36
37// ----------------------------------------------------------------------------
03e11df5 38// wxStatusBarMac class
ee6b1d97
SC
39// ----------------------------------------------------------------------------
40
41wxStatusBarMac::wxStatusBarMac()
42{
43 SetParent(NULL);
44}
45
46wxStatusBarMac::~wxStatusBarMac()
47{
48}
49
50bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
e40298d5
JS
51 long style ,
52 const wxString& name)
ee6b1d97 53{
facd6764
SC
54 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
55 return FALSE ;
56
0966d1fe
SC
57 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
58 MacSetBackgroundBrush( wxNullBrush ) ;
facd6764 59
70aaa701
SC
60 // normal system font is too tall for fitting into the standard height
61 SetWindowVariant( wxWINDOW_VARIANT_SMALL ) ;
62
facd6764 63 return TRUE ;
ee6b1d97
SC
64}
65
66void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
67{
e40298d5 68 int leftMargin = 2;
facd6764
SC
69 int w, h ;
70 GetSize( &w , &h ) ;
e40298d5
JS
71 wxRect rect;
72 GetFieldRect(i, rect);
73
8ab50549 74 if ( !MacIsReallyHilited() )
e40298d5
JS
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 ;
8ab50549 86 int ypos = 1 ;
e40298d5 87
8ab50549
SC
88 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
89 ypos++ ;
90
facd6764 91 dc.SetClippingRegion(rect.x, 0, rect.width, h);
e40298d5
JS
92
93 dc.DrawText(text, xpos, ypos);
94
95 dc.DestroyClippingRegion();
ee6b1d97
SC
96}
97
98void wxStatusBarMac::DrawField(wxDC& dc, int i)
99{
100 DrawFieldText(dc, i);
101}
102
8dba8632
SC
103void wxStatusBarMac::SetStatusText(const wxString& text, int number)
104{
105 wxCHECK_RET( (number >= 0) && (number < m_nFields),
e40298d5
JS
106 _T("invalid status bar field index") );
107
8dba8632
SC
108 m_statusStrings[number] = text;
109 wxRect rect;
110 GetFieldRect(number, rect);
facd6764
SC
111 int w, h ;
112 GetSize( &w , &h ) ;
6dbc7fb4 113 rect.y=0;
facd6764 114 rect.height = h ;
8dba8632 115 Refresh( TRUE , &rect ) ;
852b1185 116 Update();
8dba8632
SC
117}
118
ee6b1d97
SC
119void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
120{
11d1adbf
SC
121 wxPaintDC dc(this);
122 dc.Clear() ;
123
124 int major,minor;
125 wxGetOsVersion( &major, &minor );
facd6764
SC
126 int w, h ;
127 GetSize( &w , &h ) ;
11d1adbf 128
8ab50549 129 if ( MacIsReallyHilited() )
11d1adbf
SC
130 {
131 wxPen white( wxWHITE , 1 , wxSOLID ) ;
0966d1fe 132 if (major >= 10 )
11d1adbf
SC
133 {
134 //Finder statusbar border color: (Project builder similar is 9B9B9B)
0966d1fe
SC
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));
11d1adbf
SC
139 }
140 else
141 {
142 wxPen black( wxBLACK , 1 , wxSOLID ) ;
143 dc.SetPen(black);
144 }
145 dc.DrawLine(0, 0 ,
facd6764 146 w , 0);
11d1adbf
SC
147 dc.SetPen(white);
148 dc.DrawLine(0, 1 ,
facd6764 149 w , 1);
11d1adbf
SC
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 ,
facd6764 160 w , 0);
11d1adbf
SC
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);
03e11df5 170}
8ab50549
SC
171
172void wxStatusBarMac::MacHiliteChanged()
173{
174 Refresh() ;
175 Update() ;
176}