]>
Commit | Line | Data |
---|---|---|
2646f485 SC |
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 | |
65571936 | 9 | // Licence: wxWindows licence |
2646f485 SC |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
2646f485 SC |
12 | // ---------------------------------------------------------------------------- |
13 | // headers | |
14 | // ---------------------------------------------------------------------------- | |
15 | ||
16 | #include "wx/statusbr.h" | |
17 | #include "wx/dc.h" | |
18 | #include "wx/dcclient.h" | |
19 | ||
20 | BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) | |
21 | EVT_PAINT(wxStatusBarMac::OnPaint) | |
22 | END_EVENT_TABLE() | |
23 | ||
24 | #ifdef __WXMAC__ | |
25 | #include "wx/mac/private.h" | |
26 | #endif | |
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( MAC_WXHWND( 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 = 1 ; | |
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 | rect.y=0; | |
94 | rect.height = m_height ; | |
95 | Refresh( TRUE , &rect ) ; | |
96 | Update(); | |
97 | } | |
98 | ||
99 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
100 | { | |
101 | wxPaintDC dc(this); | |
102 | dc.Clear() ; | |
103 | ||
104 | int major,minor; | |
105 | wxGetOsVersion( &major, &minor ); | |
106 | ||
107 | if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) | |
108 | { | |
109 | wxPen white( wxWHITE , 1 , wxSOLID ) ; | |
110 | if (major >= 10) | |
111 | { | |
112 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
113 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
114 | } | |
115 | else | |
116 | { | |
117 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
118 | dc.SetPen(black); | |
119 | } | |
120 | dc.DrawLine(0, 0 , | |
121 | m_width , 0); | |
122 | dc.SetPen(white); | |
123 | dc.DrawLine(0, 1 , | |
124 | m_width , 1); | |
125 | } | |
126 | else | |
127 | { | |
128 | if (major >= 10) | |
129 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
130 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
131 | else | |
132 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
133 | ||
134 | dc.DrawLine(0, 0 , | |
135 | m_width , 0); | |
136 | } | |
137 | ||
138 | int i; | |
139 | if ( GetFont().Ok() ) | |
140 | dc.SetFont(GetFont()); | |
141 | dc.SetBackgroundMode(wxTRANSPARENT); | |
142 | ||
143 | for ( i = 0; i < m_nFields; i ++ ) | |
144 | DrawField(dc, i); | |
145 | } | |
146 | ||
147 | void wxStatusBarMac::MacSuperEnabled( bool enabled ) | |
148 | { | |
149 | Refresh(FALSE) ; | |
150 | wxWindow::MacSuperEnabled( enabled ) ; | |
151 | } |