]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/statusbr.cpp
OGL: misc.cpp clashes with misc.c frim iODBC, therefore
[wxWidgets.git] / src / mac / statusbr.cpp
... / ...
CommitLineData
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/mac/statusbr.h"
21
22IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar);
23
24BEGIN_EVENT_TABLE(wxStatusBarXX, wxStatusBar)
25 EVT_SIZE(wxStatusBarXX::OnSize)
26END_EVENT_TABLE()
27
28
29// ============================================================================
30// implementation
31// ============================================================================
32
33// ----------------------------------------------------------------------------
34// wxStatusBarXX class
35// ----------------------------------------------------------------------------
36
37wxStatusBarXX::wxStatusBarXX()
38{
39 SetParent(NULL);
40}
41
42wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style)
43{
44 Create(parent, id, style);
45}
46
47bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
48{
49 SetParent(parent);
50
51 if (id == -1)
52 m_windowId = NewControlId();
53 else
54 m_windowId = id;
55
56 // TODO: create status bar
57 return FALSE;
58}
59
60void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
61{
62 wxASSERT( (nFields > 0) && (nFields < 255) );
63
64 m_nFields = nFields;
65
66 CopyFieldsWidth(widths);
67 SetFieldsWidth();
68}
69
70void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
71{
72 wxASSERT( n == m_nFields );
73
74 CopyFieldsWidth(widths);
75 SetFieldsWidth();
76}
77
78void wxStatusBarXX::CopyFieldsWidth(const int widths[])
79{
80 if (widths && !m_statusWidths)
81 m_statusWidths = new int[m_nFields];
82
83 if ( widths != NULL ) {
84 for ( int i = 0; i < m_nFields; i++ )
85 m_statusWidths[i] = widths[i];
86 }
87 else {
88 delete [] m_statusWidths;
89 m_statusWidths = NULL;
90 }
91}
92
93void wxStatusBarXX::SetFieldsWidth()
94{
95 int *pWidths = new int[m_nFields];
96
97 int nWindowWidth, y;
98 GetClientSize(&nWindowWidth, &y);
99
100 if ( m_statusWidths == NULL ) {
101 // default: all fields have the same width
102 int nWidth = nWindowWidth / m_nFields;
103 for ( int i = 0; i < m_nFields; i++ )
104 pWidths[i] = (i + 1) * nWidth;
105 }
106 else {
107 // -1 doesn't mean the same thing for wxWindows and Win32, recalc
108 int nTotalWidth = 0,
109 nVarCount = 0,
110 i;
111 for ( i = 0; i < m_nFields; i++ ) {
112 if ( m_statusWidths[i] == -1 )
113 nVarCount++;
114 else
115 nTotalWidth += m_statusWidths[i];
116 }
117
118 if ( nVarCount == 0 ) {
119 // wrong! at least one field must be of variable width
120 wxFAIL;
121
122 nVarCount++;
123 }
124
125 int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
126
127 // do fill the array
128 int nCurPos = 0;
129 for ( i = 0; i < m_nFields; i++ ) {
130 if ( m_statusWidths[i] == -1 )
131 nCurPos += nVarWidth;
132 else
133 nCurPos += m_statusWidths[i];
134 pWidths[i] = nCurPos;
135 }
136 }
137
138 // TODO: set widths
139
140 delete [] pWidths;
141}
142
143void wxStatusBarXX::SetStatusText(const wxString& strText, int nField)
144{
145 // TODO
146}
147
148wxString wxStatusBarXX::GetStatusText(int nField) const
149{
150 wxASSERT( (nField > -1) && (nField < m_nFields) );
151
152 // TODO
153 return wxString("");
154}
155
156void wxStatusBarXX::OnSize(wxSizeEvent& event)
157{
158 // adjust fields widths to the new size
159 SetFieldsWidth();
160}