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