]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
1. more borland work
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #ifdef __GNUG__
13 #pragma implementation "statbrma.h"
14 #endif
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/statusbr.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23
24 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
25 EVT_PAINT(wxStatusBarMac::OnPaint)
26 END_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
40 wxStatusBarMac::wxStatusBarMac()
41 {
42 SetParent(NULL);
43 }
44
45 wxStatusBarMac::~wxStatusBarMac()
46 {
47 }
48
49 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
50 long style ,
51 const wxString& name)
52 {
53 return wxStatusBarGeneric::Create( parent , id , style , name ) ;
54 }
55
56 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
57 {
58 int leftMargin = 2;
59
60 wxRect rect;
61 GetFieldRect(i, rect);
62
63 if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
64 {
65 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
66 }
67
68 wxString text(GetStatusText(i));
69
70 long x, y;
71
72 dc.GetTextExtent(text, &x, &y);
73
74 int xpos = rect.x + leftMargin + 1 ;
75 int ypos = 2 ;
76
77 dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
78
79 dc.DrawText(text, xpos, ypos);
80
81 dc.DestroyClippingRegion();
82 }
83
84 void wxStatusBarMac::DrawField(wxDC& dc, int i)
85 {
86 DrawFieldText(dc, i);
87 }
88
89 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
90 {
91 wxCHECK_RET( (number >= 0) && (number < m_nFields),
92 _T("invalid status bar field index") );
93
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 }
101
102 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
103 {
104 wxPaintDC dc(this);
105 dc.Clear() ;
106
107 if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
108 {
109 wxPen black( wxBLACK , 1 , wxSOLID ) ;
110 wxPen white( wxWHITE , 1 , wxSOLID ) ;
111
112 dc.SetPen(black);
113 dc.DrawLine(0, 0 ,
114 m_width , 0);
115 dc.SetPen(white);
116 dc.DrawLine(0, 1 ,
117 m_width , 1);
118 }
119 else
120 {
121 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
122 dc.DrawLine(0, 0 ,
123 m_width , 0);
124 }
125
126 int i;
127 if ( GetFont().Ok() )
128 dc.SetFont(GetFont());
129 dc.SetBackgroundMode(wxTRANSPARENT);
130
131 for ( i = 0; i < m_nFields; i ++ )
132 DrawField(dc, i);
133 }
134
135 void wxStatusBarMac::MacSuperEnabled( bool enabled )
136 {
137 Refresh(FALSE) ;
138 wxWindow::MacSuperEnabled( enabled ) ;
139 }