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