]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/statbrma.cpp
Quit application menu item needs special handling like the Preferences item. [ patch...
[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
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
b142515e 13#pragma implementation "statbrma.h"
ee6b1d97
SC
14#endif
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
3d1a4878
SC
20#include "wx/wxprec.h"
21
03e11df5
GD
22#include "wx/statusbr.h"
23#include "wx/dc.h"
24#include "wx/dcclient.h"
ee6b1d97 25
ee6b1d97 26BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
e40298d5 27 EVT_PAINT(wxStatusBarMac::OnPaint)
ee6b1d97 28END_EVENT_TABLE()
ee6b1d97 29
76a5e5d2
SC
30#ifdef __WXMAC__
31#include "wx/mac/private.h"
3a72b6a4 32#include "wx/toplevel.h"
76a5e5d2
SC
33#endif
34
ee6b1d97
SC
35// ============================================================================
36// implementation
37// ============================================================================
38
39// ----------------------------------------------------------------------------
03e11df5 40// wxStatusBarMac class
ee6b1d97
SC
41// ----------------------------------------------------------------------------
42
43wxStatusBarMac::wxStatusBarMac()
44{
45 SetParent(NULL);
46}
47
48wxStatusBarMac::~wxStatusBarMac()
49{
50}
51
52bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
e40298d5
JS
53 long style ,
54 const wxString& name)
ee6b1d97 55{
facd6764
SC
56 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
57 return FALSE ;
58
0966d1fe
SC
59 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
60 MacSetBackgroundBrush( wxNullBrush ) ;
facd6764 61
70aaa701
SC
62 // normal system font is too tall for fitting into the standard height
63 SetWindowVariant( wxWINDOW_VARIANT_SMALL ) ;
64
facd6764 65 return TRUE ;
ee6b1d97
SC
66}
67
68void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
69{
e40298d5 70 int leftMargin = 2;
facd6764
SC
71 int w, h ;
72 GetSize( &w , &h ) ;
e40298d5
JS
73 wxRect rect;
74 GetFieldRect(i, rect);
75
8ab50549 76 if ( !MacIsReallyHilited() )
e40298d5
JS
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 ;
8ab50549 88 int ypos = 1 ;
e40298d5 89
8ab50549
SC
90 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
91 ypos++ ;
92
facd6764 93 dc.SetClippingRegion(rect.x, 0, rect.width, h);
e40298d5
JS
94
95 dc.DrawText(text, xpos, ypos);
96
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),
e40298d5
JS
108 _T("invalid status bar field index") );
109
b610b1db
SC
110 if ( m_statusStrings[number] == text )
111 return ;
112
8dba8632
SC
113 m_statusStrings[number] = text;
114 wxRect rect;
115 GetFieldRect(number, rect);
facd6764
SC
116 int w, h ;
117 GetSize( &w , &h ) ;
6dbc7fb4 118 rect.y=0;
facd6764 119 rect.height = h ;
8dba8632 120 Refresh( TRUE , &rect ) ;
852b1185 121 Update();
8dba8632
SC
122}
123
ee6b1d97
SC
124void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
125{
11d1adbf
SC
126 wxPaintDC dc(this);
127 dc.Clear() ;
128
129 int major,minor;
130 wxGetOsVersion( &major, &minor );
facd6764
SC
131 int w, h ;
132 GetSize( &w , &h ) ;
11d1adbf 133
8ab50549 134 if ( MacIsReallyHilited() )
11d1adbf
SC
135 {
136 wxPen white( wxWHITE , 1 , wxSOLID ) ;
0966d1fe 137 if (major >= 10 )
11d1adbf
SC
138 {
139 //Finder statusbar border color: (Project builder similar is 9B9B9B)
0966d1fe
SC
140 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
141 dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ;
142 else
143 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
11d1adbf
SC
144 }
145 else
146 {
147 wxPen black( wxBLACK , 1 , wxSOLID ) ;
148 dc.SetPen(black);
149 }
150 dc.DrawLine(0, 0 ,
facd6764 151 w , 0);
11d1adbf
SC
152 dc.SetPen(white);
153 dc.DrawLine(0, 1 ,
facd6764 154 w , 1);
11d1adbf
SC
155 }
156 else
157 {
158 if (major >= 10)
159 //Finder statusbar border color: (Project builder similar is 9B9B9B)
160 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
161 else
162 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
163
164 dc.DrawLine(0, 0 ,
facd6764 165 w , 0);
11d1adbf
SC
166 }
167
168 int i;
169 if ( GetFont().Ok() )
170 dc.SetFont(GetFont());
171 dc.SetBackgroundMode(wxTRANSPARENT);
172
173 for ( i = 0; i < m_nFields; i ++ )
174 DrawField(dc, i);
03e11df5 175}
8ab50549
SC
176
177void wxStatusBarMac::MacHiliteChanged()
178{
179 Refresh() ;
180 Update() ;
181}