]>
Commit | Line | Data |
---|---|---|
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 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
13 | #pragma implementation "statbrma.h" | |
14 | #endif | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #include "wx/statusbr.h" | |
23 | #include "wx/dc.h" | |
24 | #include "wx/dcclient.h" | |
25 | ||
26 | BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) | |
27 | EVT_PAINT(wxStatusBarMac::OnPaint) | |
28 | END_EVENT_TABLE() | |
29 | ||
30 | #ifdef __WXMAC__ | |
31 | #include "wx/mac/private.h" | |
32 | #include "wx/toplevel.h" | |
33 | #endif | |
34 | ||
35 | // ============================================================================ | |
36 | // implementation | |
37 | // ============================================================================ | |
38 | ||
39 | // ---------------------------------------------------------------------------- | |
40 | // wxStatusBarMac class | |
41 | // ---------------------------------------------------------------------------- | |
42 | ||
43 | wxStatusBarMac::wxStatusBarMac() | |
44 | { | |
45 | SetParent(NULL); | |
46 | } | |
47 | ||
48 | wxStatusBarMac::~wxStatusBarMac() | |
49 | { | |
50 | } | |
51 | ||
52 | bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, | |
53 | long style , | |
54 | const wxString& name) | |
55 | { | |
56 | if( !wxStatusBarGeneric::Create( parent , id , style , name ) ) | |
57 | return FALSE ; | |
58 | ||
59 | if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() ) | |
60 | MacSetBackgroundBrush( wxNullBrush ) ; | |
61 | ||
62 | // normal system font is too tall for fitting into the standard height | |
63 | SetWindowVariant( wxWINDOW_VARIANT_SMALL ) ; | |
64 | ||
65 | return TRUE ; | |
66 | } | |
67 | ||
68 | void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) | |
69 | { | |
70 | int leftMargin = 2; | |
71 | int w, h ; | |
72 | GetSize( &w , &h ) ; | |
73 | wxRect rect; | |
74 | GetFieldRect(i, rect); | |
75 | ||
76 | if ( !MacIsReallyHilited() ) | |
77 | { | |
78 | dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; | |
79 | } | |
80 | ||
81 | wxString text(GetStatusText(i)); | |
82 | ||
83 | long x, y; | |
84 | ||
85 | dc.GetTextExtent(text, &x, &y); | |
86 | ||
87 | int xpos = rect.x + leftMargin + 1 ; | |
88 | int ypos = 1 ; | |
89 | ||
90 | if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) | |
91 | ypos++ ; | |
92 | ||
93 | dc.SetClippingRegion(rect.x, 0, rect.width, h); | |
94 | ||
95 | dc.DrawText(text, xpos, ypos); | |
96 | ||
97 | dc.DestroyClippingRegion(); | |
98 | } | |
99 | ||
100 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
101 | { | |
102 | DrawFieldText(dc, i); | |
103 | } | |
104 | ||
105 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) | |
106 | { | |
107 | wxCHECK_RET( (number >= 0) && (number < m_nFields), | |
108 | _T("invalid status bar field index") ); | |
109 | ||
110 | if ( m_statusStrings[number] == text ) | |
111 | return ; | |
112 | ||
113 | m_statusStrings[number] = text; | |
114 | wxRect rect; | |
115 | GetFieldRect(number, rect); | |
116 | int w, h ; | |
117 | GetSize( &w , &h ) ; | |
118 | rect.y=0; | |
119 | rect.height = h ; | |
120 | Refresh( TRUE , &rect ) ; | |
121 | Update(); | |
122 | } | |
123 | ||
124 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
125 | { | |
126 | wxPaintDC dc(this); | |
127 | dc.Clear() ; | |
128 | ||
129 | int major,minor; | |
130 | wxGetOsVersion( &major, &minor ); | |
131 | int w, h ; | |
132 | GetSize( &w , &h ) ; | |
133 | ||
134 | if ( MacIsReallyHilited() ) | |
135 | { | |
136 | wxPen white( wxWHITE , 1 , wxSOLID ) ; | |
137 | if (major >= 10 ) | |
138 | { | |
139 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
140 | if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) | |
141 | dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ; | |
142 | else | |
143 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
144 | } | |
145 | else | |
146 | { | |
147 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
148 | dc.SetPen(black); | |
149 | } | |
150 | dc.DrawLine(0, 0 , | |
151 | w , 0); | |
152 | dc.SetPen(white); | |
153 | dc.DrawLine(0, 1 , | |
154 | w , 1); | |
155 | } | |
156 | else | |
157 | { | |
158 | if (major >= 10) | |
159 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
160 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
161 | else | |
162 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
163 | ||
164 | dc.DrawLine(0, 0 , | |
165 | w , 0); | |
166 | } | |
167 | ||
168 | int i; | |
169 | if ( GetFont().Ok() ) | |
170 | dc.SetFont(GetFont()); | |
171 | dc.SetBackgroundMode(wxTRANSPARENT); | |
172 | ||
173 | for ( i = 0; i < m_nFields; i ++ ) | |
174 | DrawField(dc, i); | |
175 | } | |
176 | ||
177 | void wxStatusBarMac::MacHiliteChanged() | |
178 | { | |
179 | Refresh() ; | |
180 | Update() ; | |
181 | } |