]>
Commit | Line | Data |
---|---|---|
ee6b1d97 SC |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbar.cpp | |
3 | // Purpose: native implementation of wxStatusBar (optional) | |
a31a5f85 | 4 | // Author: Stefan Csomor |
ee6b1d97 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
ee6b1d97 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) 1998 Stefan Csomor |
ee6b1d97 SC |
9 | // Licence: wxWindows licence |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
b142515e | 13 | #pragma implementation "statbrma.h" |
ee6b1d97 SC |
14 | #endif |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
03e11df5 GD |
20 | #include "wx/statusbr.h" |
21 | #include "wx/dc.h" | |
22 | #include "wx/dcclient.h" | |
ee6b1d97 | 23 | |
ee6b1d97 | 24 | BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) |
e40298d5 | 25 | EVT_PAINT(wxStatusBarMac::OnPaint) |
ee6b1d97 | 26 | END_EVENT_TABLE() |
ee6b1d97 | 27 | |
76a5e5d2 SC |
28 | #ifdef __WXMAC__ |
29 | #include "wx/mac/private.h" | |
30 | #endif | |
31 | ||
ee6b1d97 SC |
32 | // ============================================================================ |
33 | // implementation | |
34 | // ============================================================================ | |
35 | ||
36 | // ---------------------------------------------------------------------------- | |
03e11df5 | 37 | // wxStatusBarMac class |
ee6b1d97 SC |
38 | // ---------------------------------------------------------------------------- |
39 | ||
40 | wxStatusBarMac::wxStatusBarMac() | |
41 | { | |
42 | SetParent(NULL); | |
43 | } | |
44 | ||
45 | wxStatusBarMac::~wxStatusBarMac() | |
46 | { | |
47 | } | |
48 | ||
49 | bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, | |
e40298d5 JS |
50 | long style , |
51 | const wxString& name) | |
ee6b1d97 | 52 | { |
e40298d5 | 53 | return wxStatusBarGeneric::Create( parent , id , style , name ) ; |
ee6b1d97 SC |
54 | } |
55 | ||
56 | void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) | |
57 | { | |
e40298d5 JS |
58 | int leftMargin = 2; |
59 | ||
60 | wxRect rect; | |
61 | GetFieldRect(i, rect); | |
62 | ||
63 | if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) | |
64 | { | |
65 | dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; | |
66 | } | |
67 | ||
68 | wxString text(GetStatusText(i)); | |
69 | ||
70 | long x, y; | |
71 | ||
72 | dc.GetTextExtent(text, &x, &y); | |
73 | ||
74 | int xpos = rect.x + leftMargin + 1 ; | |
852b1185 | 75 | int ypos = 1 ; |
e40298d5 JS |
76 | |
77 | dc.SetClippingRegion(rect.x, 0, rect.width, m_height); | |
78 | ||
79 | dc.DrawText(text, xpos, ypos); | |
80 | ||
81 | dc.DestroyClippingRegion(); | |
ee6b1d97 SC |
82 | } |
83 | ||
84 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
85 | { | |
86 | DrawFieldText(dc, i); | |
87 | } | |
88 | ||
8dba8632 SC |
89 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) |
90 | { | |
91 | wxCHECK_RET( (number >= 0) && (number < m_nFields), | |
e40298d5 JS |
92 | _T("invalid status bar field index") ); |
93 | ||
8dba8632 SC |
94 | m_statusStrings[number] = text; |
95 | wxRect rect; | |
96 | GetFieldRect(number, rect); | |
6dbc7fb4 SC |
97 | rect.y=0; |
98 | rect.height = m_height ; | |
8dba8632 | 99 | Refresh( TRUE , &rect ) ; |
852b1185 | 100 | Update(); |
8dba8632 SC |
101 | } |
102 | ||
ee6b1d97 SC |
103 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) |
104 | { | |
11d1adbf SC |
105 | wxPaintDC dc(this); |
106 | dc.Clear() ; | |
107 | ||
108 | int major,minor; | |
109 | wxGetOsVersion( &major, &minor ); | |
110 | ||
111 | if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) | |
112 | { | |
113 | wxPen white( wxWHITE , 1 , wxSOLID ) ; | |
114 | if (major >= 10) | |
115 | { | |
116 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
117 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
118 | } | |
119 | else | |
120 | { | |
121 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
122 | dc.SetPen(black); | |
123 | } | |
124 | dc.DrawLine(0, 0 , | |
125 | m_width , 0); | |
126 | dc.SetPen(white); | |
127 | dc.DrawLine(0, 1 , | |
128 | m_width , 1); | |
129 | } | |
130 | else | |
131 | { | |
132 | if (major >= 10) | |
133 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
134 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
135 | else | |
136 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
137 | ||
138 | dc.DrawLine(0, 0 , | |
139 | m_width , 0); | |
140 | } | |
141 | ||
142 | int i; | |
143 | if ( GetFont().Ok() ) | |
144 | dc.SetFont(GetFont()); | |
145 | dc.SetBackgroundMode(wxTRANSPARENT); | |
146 | ||
147 | for ( i = 0; i < m_nFields; i ++ ) | |
148 | DrawField(dc, i); | |
03e11df5 | 149 | } |
1c469f7f SC |
150 | |
151 | void wxStatusBarMac::MacSuperEnabled( bool enabled ) | |
152 | { | |
153 | Refresh(FALSE) ; | |
154 | wxWindow::MacSuperEnabled( enabled ) ; | |
d84afea9 | 155 | } |