]>
Commit | Line | Data |
---|---|---|
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 | if ( !IsWindowHilited( MacGetRootWindow() ) ) | |
60 | { | |
61 | dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; | |
62 | } | |
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::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 | ||
106 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
107 | { | |
108 | wxPaintDC dc(this); | |
109 | ||
110 | if ( IsWindowHilited( MacGetRootWindow() ) ) | |
111 | { | |
112 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
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); | |
121 | } | |
122 | else | |
123 | { | |
124 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
125 | dc.DrawLine(0, 0 , | |
126 | m_width , 0); | |
127 | } | |
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 | |
140 | } | |
141 | ||
142 | void wxStatusBarMac::MacSuperEnabled( bool enabled ) | |
143 | { | |
144 | Refresh(FALSE) ; | |
145 | wxWindow::MacSuperEnabled( enabled ) ; | |
146 | } |