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