]> git.saurik.com Git - wxWidgets.git/blob - src/mac/statbrma.cpp
Copied/merged from the 2.2 branch.
[wxWidgets.git] / src / mac / 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 "statusbr.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 #if !USE_SHARED_LIBRARY
25 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarMac, wxStatusBarGeneric);
26
27 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
28 EVT_PAINT(wxStatusBarMac::OnPaint)
29 END_EVENT_TABLE()
30 #endif //USE_SHARED_LIBRARY
31
32
33 // ============================================================================
34 // implementation
35 // ============================================================================
36
37 // ----------------------------------------------------------------------------
38 // wxStatusBarMac class
39 // ----------------------------------------------------------------------------
40
41 wxStatusBarMac::wxStatusBarMac()
42 {
43 SetParent(NULL);
44 }
45
46 wxStatusBarMac::~wxStatusBarMac()
47 {
48 }
49
50 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
51 long style ,
52 const wxString& name)
53 {
54 return wxStatusBarGeneric::Create( parent , id , style , name ) ;
55 }
56
57 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
58 {
59 int leftMargin = 2;
60
61 wxRect rect;
62 GetFieldRect(i, rect);
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
80 void wxStatusBarMac::DrawField(wxDC& dc, int i)
81 {
82 DrawFieldText(dc, i);
83 }
84
85 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
86 {
87 wxPaintDC dc(this);
88 wxPen black( wxBLACK , 1 , wxSOLID ) ;
89 wxPen white( wxWHITE , 1 , wxSOLID ) ;
90
91 dc.SetPen(black);
92 dc.DrawLine(0, 0 ,
93 m_width , 0);
94 dc.SetPen(white);
95 dc.DrawLine(0, 1 ,
96 m_width , 1);
97
98
99 int i;
100 if ( GetFont().Ok() )
101 dc.SetFont(GetFont());
102 dc.SetBackgroundMode(wxTRANSPARENT);
103
104 for ( i = 0; i < m_nFields; i ++ )
105 DrawField(dc, i);
106
107 # ifdef __WXMSW__
108 dc.SetFont(wxNullFont);
109 # endif // MSW
110 }