]> git.saurik.com Git - wxWidgets.git/blob - src/os2/statbrpm.cpp
OnEnter/OnDragOver API update (compiles, links, somewhat runs under wxGTK)
[wxWidgets.git] / src / os2 / statbrpm.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: statbar.cpp
3 // Purpose: native implementation of wxStatusBar (optional)
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/17/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/setup.h"
17 #include "wx/frame.h"
18 #include "wx/settings.h"
19 #include "wx/dcclient.h"
20 #endif
21
22 #include "wx/log.h"
23 #include "wx/generic/statusbr.h"
24 #include "wx/os2/statusbr.h"
25
26 #include "wx/os2/private.h"
27
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarPM, wxStatusBar);
30
31 BEGIN_EVENT_TABLE(wxStatusBarPM, wxStatusBar)
32 EVT_SIZE(wxStatusBarPM::OnSize)
33 END_EVENT_TABLE()
34 #endif //USE_SHARED_LIBRARY
35
36
37 // ============================================================================
38 // implementation
39 // ============================================================================
40
41 // ----------------------------------------------------------------------------
42 // wxStatusBarPM class
43 // ----------------------------------------------------------------------------
44
45 wxStatusBarPM::wxStatusBarPM()
46 {
47 SetParent(NULL);
48 m_hWnd = 0;
49 m_windowId = 0;
50 }
51
52 wxStatusBarPM::wxStatusBarPM(wxWindow *parent, wxWindowID id, long style)
53 {
54 Create(parent, id, style);
55 }
56
57 bool wxStatusBarPM::Create(wxWindow *parent, wxWindowID id, long style)
58 {
59 SetParent(parent);
60
61 if (id == -1)
62 m_windowId = NewControlId();
63 else
64 m_windowId = id;
65
66 // TODO: create status bar
67 return FALSE;
68 }
69
70 void wxStatusBarPM::CopyFieldsWidth(const int widths[])
71 {
72 if (widths && !m_statusWidths)
73 m_statusWidths = new int[m_nFields];
74
75 if ( widths != NULL ) {
76 for ( int i = 0; i < m_nFields; i++ )
77 m_statusWidths[i] = widths[i];
78 }
79 else {
80 delete [] m_statusWidths;
81 m_statusWidths = NULL;
82 }
83 }
84
85 void wxStatusBarPM::SetFieldsCount(int nFields, const int widths[])
86 {
87 wxASSERT( (nFields > 0) && (nFields < 255) );
88
89 m_nFields = nFields;
90
91 CopyFieldsWidth(widths);
92 SetFieldsWidth();
93 }
94
95 void wxStatusBarPM::SetStatusWidths(int n, const int widths[])
96 {
97 wxASSERT( n == m_nFields );
98
99 CopyFieldsWidth(widths);
100 SetFieldsWidth();
101 }
102
103 void wxStatusBarPM::SetFieldsWidth()
104 {
105 int *pWidths = new int[m_nFields];
106
107 int nWindowWidth, y;
108 GetClientSize(&nWindowWidth, &y);
109
110 if ( m_statusWidths == NULL ) {
111 // default: all fields have the same width
112 int nWidth = nWindowWidth / m_nFields;
113 for ( int i = 0; i < m_nFields; i++ )
114 pWidths[i] = (i + 1) * nWidth;
115 }
116 else {
117 // -1 doesn't mean the same thing for wxWindows and Win32, recalc
118 int nTotalWidth = 0,
119 nVarCount = 0,
120 i;
121 for ( i = 0; i < m_nFields; i++ ) {
122 if ( m_statusWidths[i] == -1 )
123 nVarCount++;
124 else
125 nTotalWidth += m_statusWidths[i];
126 }
127
128 if ( nVarCount == 0 ) {
129 // wrong! at least one field must be of variable width
130 wxFAIL;
131
132 nVarCount++;
133 }
134
135 int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
136
137 // do fill the array
138 int nCurPos = 0;
139 for ( i = 0; i < m_nFields; i++ ) {
140 if ( m_statusWidths[i] == -1 )
141 nCurPos += nVarWidth;
142 else
143 nCurPos += m_statusWidths[i];
144 pWidths[i] = nCurPos;
145 }
146 }
147
148 // TODO: set widths
149
150 delete [] pWidths;
151 }
152
153 void wxStatusBarPM::SetStatusText(const wxString& strText, int nField)
154 {
155 // TODO
156 }
157
158 wxString wxStatusBarPM::GetStatusText(int nField) const
159 {
160 wxASSERT( (nField > -1) && (nField < m_nFields) );
161
162 // TODO
163 return wxString("");
164 }
165
166 void wxStatusBarPM::OnSize(wxSizeEvent& event)
167 {
168 // adjust fields widths to the new size
169 SetFieldsWidth();
170 }
171