]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/statbrma.cpp
add wxTLW::UseNativeDecorations[ByDefault]() to allow the programmer to control wheth...
[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
03e11df5 14#include "wx/statusbr.h"
da80ae71
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/dc.h"
ed4b0fdc 18 #include "wx/dcclient.h"
1832043f 19 #include "wx/toplevel.h"
da80ae71
WS
20#endif
21
76a5e5d2 22#include "wx/mac/private.h"
76a5e5d2 23
ee6b1d97 24
61fa2e39
DS
25BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
26 EVT_PAINT(wxStatusBarMac::OnPaint)
27END_EVENT_TABLE()
28
ee6b1d97 29
71786e29
DS
30wxStatusBarMac::wxStatusBarMac(wxWindow *parent,
31 wxWindowID id,
32 long style,
33 const wxString& name)
34 :
35 wxStatusBarGeneric()
36{
37 SetParent( NULL );
38 Create( parent, id, style, name );
39}
40
ee6b1d97 41wxStatusBarMac::wxStatusBarMac()
71786e29
DS
42 :
43 wxStatusBarGeneric()
ee6b1d97 44{
61fa2e39 45 SetParent( NULL );
ee6b1d97
SC
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{
71786e29 56 if ( !wxStatusBarGeneric::Create( parent, id, style, name ) )
61fa2e39
DS
57 return false;
58
0966d1fe 59 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
61fa2e39
DS
60 MacSetBackgroundBrush( wxNullBrush );
61
70aaa701 62 // normal system font is too tall for fitting into the standard height
61fa2e39
DS
63 SetWindowVariant( wxWINDOW_VARIANT_SMALL );
64
71786e29 65 return true;
ee6b1d97
SC
66}
67
68void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
69{
71786e29
DS
70 int w, h;
71 GetSize( &w , &h );
e40298d5 72 wxRect rect;
71786e29 73 GetFieldRect( i, rect );
61fa2e39
DS
74
75 if ( !MacIsReallyHilited() )
71786e29 76 dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
61fa2e39 77
71786e29 78 wxString text(GetStatusText( i ));
61fa2e39 79
e40298d5 80 long x, y;
61fa2e39 81
e40298d5 82 dc.GetTextExtent(text, &x, &y);
61fa2e39 83
71786e29
DS
84 int leftMargin = 2;
85 int xpos = rect.x + leftMargin + 1;
86 int ypos = 1;
61fa2e39
DS
87
88 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
71786e29 89 ypos++;
61fa2e39 90
facd6764 91 dc.SetClippingRegion(rect.x, 0, rect.width, h);
61fa2e39 92
e40298d5 93 dc.DrawText(text, xpos, ypos);
61fa2e39 94
e40298d5 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),
61fa2e39
DS
106 wxT("invalid status bar field index") );
107
b610b1db
SC
108 if ( m_statusStrings[number] == text )
109 return ;
61fa2e39 110
8dba8632
SC
111 m_statusStrings[number] = text;
112 wxRect rect;
113 GetFieldRect(number, rect);
61fa2e39
DS
114 int w, h;
115 GetSize( &w, &h );
116 rect.y = 0;
facd6764 117 rect.height = h ;
61fa2e39 118 Refresh( true, &rect );
852b1185 119 Update();
8dba8632
SC
120}
121
61fa2e39 122void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
ee6b1d97 123{
61fa2e39
DS
124 wxPaintDC dc(this);
125 dc.Clear();
11d1adbf 126
61fa2e39 127 int major, minor;
11d1adbf 128 wxGetOsVersion( &major, &minor );
61fa2e39
DS
129 int w, h;
130 GetSize( &w, &h );
11d1adbf 131
61fa2e39
DS
132 if ( MacIsReallyHilited() )
133 {
134 wxPen white( *wxWHITE , 1 , wxSOLID );
135 if (major >= 10)
11d1adbf 136 {
61fa2e39 137 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
0966d1fe 138 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
61fa2e39 139 dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID));
0966d1fe 140 else
61fa2e39 141 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
11d1adbf
SC
142 }
143 else
144 {
61fa2e39 145 wxPen black( *wxBLACK , 1 , wxSOLID );
11d1adbf 146 dc.SetPen(black);
61fa2e39
DS
147 }
148
149 dc.DrawLine(0, 0, w, 0);
150 dc.SetPen(white);
151 dc.DrawLine(0, 1, w, 1);
152 }
153 else
154 {
155 if (major >= 10)
156 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
157 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
11d1adbf 158 else
61fa2e39 159 dc.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID));
11d1adbf 160
61fa2e39
DS
161 dc.DrawLine(0, 0, w, 0);
162 }
11d1adbf 163
61fa2e39
DS
164 int i;
165 if ( GetFont().Ok() )
166 dc.SetFont(GetFont());
167 dc.SetBackgroundMode(wxTRANSPARENT);
11d1adbf 168
61fa2e39
DS
169 for ( i = 0; i < m_nFields; i ++ )
170 DrawField(dc, i);
03e11df5 171}
8ab50549
SC
172
173void wxStatusBarMac::MacHiliteChanged()
174{
61fa2e39
DS
175 Refresh();
176 Update();
8ab50549 177}