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