]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/mac/classic/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 | // For compilers that support precompilation, includes "wx.h". | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/statusbr.h" | |
20 | ||
21 | #ifndef WX_PRECOMP | |
22 | #include "wx/dc.h" | |
23 | #include "wx/dcclient.h" | |
24 | #endif | |
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 | #endif | |
33 | ||
34 | // ============================================================================ | |
35 | // implementation | |
36 | // ============================================================================ | |
37 | ||
38 | // ---------------------------------------------------------------------------- | |
39 | // wxStatusBarMac class | |
40 | // ---------------------------------------------------------------------------- | |
41 | ||
42 | wxStatusBarMac::wxStatusBarMac() | |
43 | { | |
44 | SetParent(NULL); | |
45 | } | |
46 | ||
47 | wxStatusBarMac::~wxStatusBarMac() | |
48 | { | |
49 | } | |
50 | ||
51 | bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, | |
52 | long style , | |
53 | const wxString& name) | |
54 | { | |
55 | return wxStatusBarGeneric::Create( parent , id , style , name ) ; | |
56 | } | |
57 | ||
58 | void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) | |
59 | { | |
60 | int leftMargin = 2; | |
61 | ||
62 | wxRect rect; | |
63 | GetFieldRect(i, rect); | |
64 | ||
65 | if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) | |
66 | { | |
67 | dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; | |
68 | } | |
69 | ||
70 | wxString text(GetStatusText(i)); | |
71 | ||
72 | long x, y; | |
73 | ||
74 | dc.GetTextExtent(text, &x, &y); | |
75 | ||
76 | int xpos = rect.x + leftMargin + 1 ; | |
77 | int ypos = 1 ; | |
78 | ||
79 | dc.SetClippingRegion(rect.x, 0, rect.width, m_height); | |
80 | ||
81 | dc.DrawText(text, xpos, ypos); | |
82 | ||
83 | dc.DestroyClippingRegion(); | |
84 | } | |
85 | ||
86 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
87 | { | |
88 | DrawFieldText(dc, i); | |
89 | } | |
90 | ||
91 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) | |
92 | { | |
93 | wxCHECK_RET( (number >= 0) && (number < m_nFields), | |
94 | _T("invalid status bar field index") ); | |
95 | ||
96 | m_statusStrings[number] = text; | |
97 | wxRect rect; | |
98 | GetFieldRect(number, rect); | |
99 | rect.y=0; | |
100 | rect.height = m_height ; | |
101 | Refresh( true , &rect ) ; | |
102 | Update(); | |
103 | } | |
104 | ||
105 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
106 | { | |
107 | wxPaintDC dc(this); | |
108 | dc.Clear() ; | |
109 | ||
110 | int major,minor; | |
111 | wxGetOsVersion( &major, &minor ); | |
112 | ||
113 | if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) | |
114 | { | |
115 | wxPen white( wxWHITE , 1 , wxSOLID ) ; | |
116 | if (major >= 10) | |
117 | { | |
118 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
119 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
120 | } | |
121 | else | |
122 | { | |
123 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
124 | dc.SetPen(black); | |
125 | } | |
126 | dc.DrawLine(0, 0 , | |
127 | m_width , 0); | |
128 | dc.SetPen(white); | |
129 | dc.DrawLine(0, 1 , | |
130 | m_width , 1); | |
131 | } | |
132 | else | |
133 | { | |
134 | if (major >= 10) | |
135 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
136 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
137 | else | |
138 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
139 | ||
140 | dc.DrawLine(0, 0 , | |
141 | m_width , 0); | |
142 | } | |
143 | ||
144 | int i; | |
145 | if ( GetFont().Ok() ) | |
146 | dc.SetFont(GetFont()); | |
147 | dc.SetBackgroundMode(wxTRANSPARENT); | |
148 | ||
149 | for ( i = 0; i < m_nFields; i ++ ) | |
150 | DrawField(dc, i); | |
151 | } | |
152 | ||
153 | void wxStatusBarMac::MacSuperEnabled( bool enabled ) | |
154 | { | |
155 | Refresh(false) ; | |
156 | wxWindow::MacSuperEnabled( enabled ) ; | |
157 | } |