]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
corrections to includes for compilation under Mac OS X
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
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__
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 // ============================================================================
29 // implementation
30 // ============================================================================
31
32 // ----------------------------------------------------------------------------
33 // wxStatusBarMac class
34 // ----------------------------------------------------------------------------
35
36 wxStatusBarMac::wxStatusBarMac()
37 {
38 SetParent(NULL);
39 }
40
41 wxStatusBarMac::~wxStatusBarMac()
42 {
43 }
44
45 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
46 long style ,
47 const wxString& name)
48 {
49 return wxStatusBarGeneric::Create( parent , id , style , name ) ;
50 }
51
52 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
53 {
54 int leftMargin = 2;
55
56 wxRect rect;
57 GetFieldRect(i, rect);
58
59 wxString text(GetStatusText(i));
60
61 long x, y;
62
63 dc.GetTextExtent(text, &x, &y);
64
65 int xpos = rect.x + leftMargin + 1 ;
66 int ypos = 2 ;
67
68 dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
69
70 dc.DrawText(text, xpos, ypos);
71
72 dc.DestroyClippingRegion();
73 }
74
75 void wxStatusBarMac::DrawField(wxDC& dc, int i)
76 {
77 DrawFieldText(dc, i);
78 }
79
80 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
81 {
82 wxCHECK_RET( (number >= 0) && (number < m_nFields),
83 _T("invalid status bar field index") );
84
85 m_statusStrings[number] = text;
86 wxRect rect;
87 GetFieldRect(number, rect);
88 Refresh( TRUE , &rect ) ;
89 /*
90 // TODO make clear work again also when using themes
91 wxClientDC dc(this);
92 dc.SetBackground( wxBrush(GetBackgroundColour(), wxSOLID) );
93 dc.SetClippingRegion( rect.x+1, rect.y+1, rect.width-1, rect.height-1 );
94 dc.Clear();
95 dc.DestroyClippingRegion();
96 DrawFieldText( dc, number );
97 */
98
99 }
100
101 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
102 {
103 wxPaintDC dc(this);
104 wxPen black( wxBLACK , 1 , wxSOLID ) ;
105 wxPen white( wxWHITE , 1 , wxSOLID ) ;
106
107 dc.SetPen(black);
108 dc.DrawLine(0, 0 ,
109 m_width , 0);
110 dc.SetPen(white);
111 dc.DrawLine(0, 1 ,
112 m_width , 1);
113
114
115 int i;
116 if ( GetFont().Ok() )
117 dc.SetFont(GetFont());
118 dc.SetBackgroundMode(wxTRANSPARENT);
119
120 for ( i = 0; i < m_nFields; i ++ )
121 DrawField(dc, i);
122
123 # ifdef __WXMSW__
124 dc.SetFont(wxNullFont);
125 # endif // MSW
126 }