]> git.saurik.com Git - wxWidgets.git/blame - src/mac/classic/statbrma.cpp
COW cleanup patch (1583966):
[wxWidgets.git] / src / mac / classic / statbrma.cpp
CommitLineData
2646f485 1///////////////////////////////////////////////////////////////////////////////
da80ae71 2// Name: src/mac/classic/statbar.cpp
2646f485
SC
3// Purpose: native implementation of wxStatusBar (optional)
4// Author: Stefan Csomor
da80ae71 5// Modified by:
2646f485
SC
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Stefan Csomor
65571936 9// Licence: wxWindows licence
2646f485
SC
10///////////////////////////////////////////////////////////////////////////////
11
3304646d
WS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
2646f485
SC
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#include "wx/statusbr.h"
da80ae71
WS
20
21#ifndef WX_PRECOMP
22 #include "wx/dc.h"
ed4b0fdc 23 #include "wx/dcclient.h"
da80ae71
WS
24#endif
25
2646f485
SC
26BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
27 EVT_PAINT(wxStatusBarMac::OnPaint)
28END_EVENT_TABLE()
29
30#ifdef __WXMAC__
ed4b0fdc 31 #include "wx/mac/private.h"
2646f485
SC
32#endif
33
34// ============================================================================
35// implementation
36// ============================================================================
37
38// ----------------------------------------------------------------------------
39// wxStatusBarMac class
40// ----------------------------------------------------------------------------
41
42wxStatusBarMac::wxStatusBarMac()
43{
44 SetParent(NULL);
45}
46
47wxStatusBarMac::~wxStatusBarMac()
48{
49}
50
51bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
52 long style ,
53 const wxString& name)
54{
55 return wxStatusBarGeneric::Create( parent , id , style , name ) ;
56}
57
58void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
59{
60 int leftMargin = 2;
da80ae71 61
2646f485
SC
62 wxRect rect;
63 GetFieldRect(i, rect);
da80ae71 64
2646f485
SC
65 if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
66 {
67 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
68 }
da80ae71 69
2646f485 70 wxString text(GetStatusText(i));
da80ae71 71
2646f485 72 long x, y;
da80ae71 73
2646f485 74 dc.GetTextExtent(text, &x, &y);
da80ae71 75
2646f485
SC
76 int xpos = rect.x + leftMargin + 1 ;
77 int ypos = 1 ;
da80ae71 78
2646f485 79 dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
da80ae71 80
2646f485 81 dc.DrawText(text, xpos, ypos);
da80ae71 82
2646f485
SC
83 dc.DestroyClippingRegion();
84}
85
86void wxStatusBarMac::DrawField(wxDC& dc, int i)
87{
88 DrawFieldText(dc, i);
89}
90
91void wxStatusBarMac::SetStatusText(const wxString& text, int number)
92{
93 wxCHECK_RET( (number >= 0) && (number < m_nFields),
3304646d 94 _T("invalid status bar field index") );
da80ae71 95
2646f485
SC
96 m_statusStrings[number] = text;
97 wxRect rect;
98 GetFieldRect(number, rect);
99 rect.y=0;
100 rect.height = m_height ;
3304646d 101 Refresh( true , &rect ) ;
2646f485
SC
102 Update();
103}
104
105void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
106{
da80ae71
WS
107 wxPaintDC dc(this);
108 dc.Clear() ;
2646f485
SC
109
110 int major,minor;
111 wxGetOsVersion( &major, &minor );
112
da80ae71
WS
113 if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
114 {
115 wxPen white( wxWHITE , 1 , wxSOLID ) ;
116 if (major >= 10)
2646f485
SC
117 {
118 //Finder statusbar border color: (Project builder similar is 9B9B9B)
da80ae71 119 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
2646f485
SC
120 }
121 else
122 {
123 wxPen black( wxBLACK , 1 , wxSOLID ) ;
124 dc.SetPen(black);
da80ae71
WS
125 }
126 dc.DrawLine(0, 0 ,
127 m_width , 0);
128 dc.SetPen(white);
129 dc.DrawLine(0, 1 ,
130 m_width , 1);
131 }
132 else
133 {
134 if (major >= 10)
2646f485 135 //Finder statusbar border color: (Project builder similar is 9B9B9B)
da80ae71 136 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
2646f485
SC
137 else
138 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
139
da80ae71
WS
140 dc.DrawLine(0, 0 ,
141 m_width , 0);
142 }
2646f485 143
da80ae71
WS
144 int i;
145 if ( GetFont().Ok() )
146 dc.SetFont(GetFont());
147 dc.SetBackgroundMode(wxTRANSPARENT);
2646f485 148
da80ae71
WS
149 for ( i = 0; i < m_nFields; i ++ )
150 DrawField(dc, i);
2646f485
SC
151}
152
da80ae71 153void wxStatusBarMac::MacSuperEnabled( bool enabled )
2646f485 154{
3304646d 155 Refresh(false) ;
2646f485
SC
156 wxWindow::MacSuperEnabled( enabled ) ;
157}