]> git.saurik.com Git - wxWidgets.git/blame - src/mac/statbrma.cpp
added missing include file for Apple DevTools
[wxWidgets.git] / src / mac / statbrma.cpp
CommitLineData
ee6b1d97
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: statbar.cpp
3// Purpose: native implementation of wxStatusBar (optional)
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 AUTHOR
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
SC
24BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
25 EVT_PAINT(wxStatusBarMac::OnPaint)
26END_EVENT_TABLE()
ee6b1d97
SC
27
28// ============================================================================
29// implementation
30// ============================================================================
31
32// ----------------------------------------------------------------------------
03e11df5 33// wxStatusBarMac class
ee6b1d97
SC
34// ----------------------------------------------------------------------------
35
36wxStatusBarMac::wxStatusBarMac()
37{
38 SetParent(NULL);
39}
40
41wxStatusBarMac::~wxStatusBarMac()
42{
43}
44
45bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
46 long style ,
47 const wxString& name)
48{
49 return wxStatusBarGeneric::Create( parent , id , style , name ) ;
50}
51
52void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
53{
54 int leftMargin = 2;
55
56 wxRect rect;
57 GetFieldRect(i, rect);
1c469f7f
SC
58
59 if ( !IsWindowHilited( MacGetRootWindow() ) )
60 {
61 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
62 }
ee6b1d97
SC
63
64 wxString text(GetStatusText(i));
65
66 long x, y;
67
68 dc.GetTextExtent(text, &x, &y);
69
70 int xpos = rect.x + leftMargin + 1 ;
71 int ypos = 2 ;
72
73 dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
74
75 dc.DrawText(text, xpos, ypos);
76
77 dc.DestroyClippingRegion();
78}
79
80void wxStatusBarMac::DrawField(wxDC& dc, int i)
81{
82 DrawFieldText(dc, i);
83}
84
8dba8632
SC
85void wxStatusBarMac::SetStatusText(const wxString& text, int number)
86{
87 wxCHECK_RET( (number >= 0) && (number < m_nFields),
88 _T("invalid status bar field index") );
89
90 m_statusStrings[number] = text;
91 wxRect rect;
92 GetFieldRect(number, rect);
93 Refresh( TRUE , &rect ) ;
94 /*
95 // TODO make clear work again also when using themes
96 wxClientDC dc(this);
97 dc.SetBackground( wxBrush(GetBackgroundColour(), wxSOLID) );
98 dc.SetClippingRegion( rect.x+1, rect.y+1, rect.width-1, rect.height-1 );
99 dc.Clear();
100 dc.DestroyClippingRegion();
101 DrawFieldText( dc, number );
102 */
103
104}
105
ee6b1d97
SC
106void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
107{
108 wxPaintDC dc(this);
1c469f7f
SC
109
110 if ( IsWindowHilited( MacGetRootWindow() ) )
111 {
112 wxPen black( wxBLACK , 1 , wxSOLID ) ;
ee6b1d97
SC
113 wxPen white( wxWHITE , 1 , wxSOLID ) ;
114
115 dc.SetPen(black);
116 dc.DrawLine(0, 0 ,
117 m_width , 0);
118 dc.SetPen(white);
119 dc.DrawLine(0, 1 ,
120 m_width , 1);
1c469f7f
SC
121 }
122 else
123 {
124 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
125 dc.DrawLine(0, 0 ,
126 m_width , 0);
127 }
ee6b1d97
SC
128
129 int i;
130 if ( GetFont().Ok() )
131 dc.SetFont(GetFont());
132 dc.SetBackgroundMode(wxTRANSPARENT);
133
134 for ( i = 0; i < m_nFields; i ++ )
135 DrawField(dc, i);
136
137# ifdef __WXMSW__
138 dc.SetFont(wxNullFont);
139# endif // MSW
03e11df5 140}
1c469f7f
SC
141
142void wxStatusBarMac::MacSuperEnabled( bool enabled )
143{
144 Refresh(FALSE) ;
145 wxWindow::MacSuperEnabled( enabled ) ;
146}