]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/statbrma.cpp
added port state save class
[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
ee6b1d97
SC
9// Licence: wxWindows licence
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"
30#endif
31
ee6b1d97
SC
32// ============================================================================
33// implementation
34// ============================================================================
35
36// ----------------------------------------------------------------------------
03e11df5 37// wxStatusBarMac class
ee6b1d97
SC
38// ----------------------------------------------------------------------------
39
40wxStatusBarMac::wxStatusBarMac()
41{
42 SetParent(NULL);
43}
44
45wxStatusBarMac::~wxStatusBarMac()
46{
47}
48
49bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
e40298d5
JS
50 long style ,
51 const wxString& name)
ee6b1d97 52{
facd6764
SC
53 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
54 return FALSE ;
55
0966d1fe
SC
56 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
57 MacSetBackgroundBrush( wxNullBrush ) ;
facd6764
SC
58
59 return TRUE ;
ee6b1d97
SC
60}
61
62void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
63{
e40298d5 64 int leftMargin = 2;
facd6764
SC
65 int w, h ;
66 GetSize( &w , &h ) ;
e40298d5
JS
67 wxRect rect;
68 GetFieldRect(i, rect);
69
8ab50549 70 if ( !MacIsReallyHilited() )
e40298d5
JS
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 ;
8ab50549 82 int ypos = 1 ;
e40298d5 83
8ab50549
SC
84 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
85 ypos++ ;
86
facd6764 87 dc.SetClippingRegion(rect.x, 0, rect.width, h);
e40298d5
JS
88
89 dc.DrawText(text, xpos, ypos);
90
91 dc.DestroyClippingRegion();
ee6b1d97
SC
92}
93
94void wxStatusBarMac::DrawField(wxDC& dc, int i)
95{
96 DrawFieldText(dc, i);
97}
98
8dba8632
SC
99void wxStatusBarMac::SetStatusText(const wxString& text, int number)
100{
101 wxCHECK_RET( (number >= 0) && (number < m_nFields),
e40298d5
JS
102 _T("invalid status bar field index") );
103
8dba8632
SC
104 m_statusStrings[number] = text;
105 wxRect rect;
106 GetFieldRect(number, rect);
facd6764
SC
107 int w, h ;
108 GetSize( &w , &h ) ;
6dbc7fb4 109 rect.y=0;
facd6764 110 rect.height = h ;
8dba8632 111 Refresh( TRUE , &rect ) ;
852b1185 112 Update();
8dba8632
SC
113}
114
ee6b1d97
SC
115void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
116{
11d1adbf
SC
117 wxPaintDC dc(this);
118 dc.Clear() ;
119
120 int major,minor;
121 wxGetOsVersion( &major, &minor );
facd6764
SC
122 int w, h ;
123 GetSize( &w , &h ) ;
11d1adbf 124
8ab50549 125 if ( MacIsReallyHilited() )
11d1adbf
SC
126 {
127 wxPen white( wxWHITE , 1 , wxSOLID ) ;
0966d1fe 128 if (major >= 10 )
11d1adbf
SC
129 {
130 //Finder statusbar border color: (Project builder similar is 9B9B9B)
0966d1fe
SC
131 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
132 dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ;
133 else
134 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
11d1adbf
SC
135 }
136 else
137 {
138 wxPen black( wxBLACK , 1 , wxSOLID ) ;
139 dc.SetPen(black);
140 }
141 dc.DrawLine(0, 0 ,
facd6764 142 w , 0);
11d1adbf
SC
143 dc.SetPen(white);
144 dc.DrawLine(0, 1 ,
facd6764 145 w , 1);
11d1adbf
SC
146 }
147 else
148 {
149 if (major >= 10)
150 //Finder statusbar border color: (Project builder similar is 9B9B9B)
151 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
152 else
153 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
154
155 dc.DrawLine(0, 0 ,
facd6764 156 w , 0);
11d1adbf
SC
157 }
158
159 int i;
160 if ( GetFont().Ok() )
161 dc.SetFont(GetFont());
162 dc.SetBackgroundMode(wxTRANSPARENT);
163
164 for ( i = 0; i < m_nFields; i ++ )
165 DrawField(dc, i);
03e11df5 166}
8ab50549
SC
167
168void wxStatusBarMac::MacHiliteChanged()
169{
170 Refresh() ;
171 Update() ;
172}