fix compile against newer giflib
[rofl0r-obeditor.git] / src / common__prListBox.cpp
blob223aa45572cfe2deb5bcad711bd39d01519bbb3b
1 /*
2 * prListBox.cpp
4 * Created on: 23 avr. 2009
5 * Author: pat
6 */
8 #include "wx/wxprec.h"
9 #ifndef WX_PRECOMP
10 #include "wx/wx.h"
11 #endif
13 #include "common__prListBox.h"
16 //**************************************************************************************
17 //**************************************************************************************
19 prListBox::prListBox( wxWindow* _parent, wxWindowID _id, const int _maxWidth, long style )
20 :wxListBox( _parent, _id, wxDefaultPosition,wxDefaultSize, 0, NULL, style )
22 mymaxWidth = _maxWidth;
25 //**************************************************************************************
26 //**************************************************************************************
28 prListBox::~prListBox()
32 //**************************************************************************************
33 //**************************************************************************************
34 int
35 prListBox::Append( const wxString& item)
37 int _w = GetWidth();
38 SetMinSize( wxSize( 10, wxDefaultCoord ));
39 int res = wxListBox::Append( item );
40 _SetMaxWidth( _w );
41 return res;
44 //**************************************************************************************
45 int
46 prListBox::Append( const wxString& item, void* _datas)
48 int _w = GetWidth();
49 SetMinSize( wxSize( 10, wxDefaultCoord ));
50 int res = wxListBox::Append( item, _datas );
51 _SetMaxWidth( _w );
52 return res;
55 //**************************************************************************************
56 //**************************************************************************************
58 void prListBox::Append( const wxArrayString& strings)
60 int _w = GetWidth();
61 SetMinSize( wxSize( 10, wxDefaultCoord ));
62 wxListBox::Append( strings );
63 _SetMaxWidth( _w );
67 //**************************************************************************************
68 //**************************************************************************************
70 void prListBox::Clear()
72 int _w = GetWidth();
73 SetMinSize( wxSize( 10, wxDefaultCoord ));
74 wxListBox::Clear();
75 _SetMaxWidth( _w );
79 //**************************************************************************************
80 //**************************************************************************************
82 void prListBox::Delete(unsigned int n)
84 int _w = GetWidth();
85 SetMinSize( wxSize( 10, wxDefaultCoord ));
86 wxListBox::Delete(n);
87 _SetMaxWidth( _w );
91 //**************************************************************************************
92 //**************************************************************************************
93 void
94 prListBox::Insert(const wxString& item, unsigned int pos)
96 int _w = GetWidth();
97 SetMinSize( wxSize( 10, wxDefaultCoord ));
98 wxListBox::Insert(item, pos);
99 _SetMaxWidth( _w );
102 //**************************************************************************************
103 void
104 prListBox::Insert(const wxString& item, unsigned int pos, void* _datas)
106 int _w = GetWidth();
107 SetMinSize( wxSize( 10, wxDefaultCoord ));
108 wxListBox::Insert(item, pos, _datas);
109 _SetMaxWidth( _w );
112 //**************************************************************************************
113 //**************************************************************************************
115 void prListBox::SetString(unsigned int n, const wxString& string)
117 int _w = GetWidth();
118 SetMinSize( wxSize( 10, wxDefaultCoord ));
119 wxListBox::SetString(n,string);
120 _SetMaxWidth( _w );
124 //**************************************************************************************
125 //**************************************************************************************
127 bool prListBox::SetStringSelection(const wxString& string)
129 int _w = GetWidth();
130 SetMinSize( wxSize( 10, wxDefaultCoord ));
131 bool res = wxListBox::SetStringSelection(string);
132 _SetMaxWidth( _w );
133 return res;
137 //**************************************************************************************
138 //**************************************************************************************
140 void prListBox::SetMaxWidth( const int _maxWidth )
142 int _w = GetWidth();
143 SetMinSize( wxSize( 10, wxDefaultCoord ));
144 mymaxWidth = _maxWidth;
145 _SetMaxWidth( _w );
149 //**************************************************************************************
150 //**************************************************************************************
152 int prListBox::GetMaxWidth()const
154 return mymaxWidth;
157 //**************************************************************************************
158 //**************************************************************************************
160 int prListBox::GetWidth()
162 wxSize s = GetMinSize();
163 return s.GetWidth();
166 //**************************************************************************************
167 //**************************************************************************************
169 void prListBox::_SetMaxWidth( int _w )
171 int _w0, _w1, _h;
172 GetBestSize(&_w0, &_h );
173 GetSize(&_w1, &_h );
174 if( _w0 > mymaxWidth || _w1 > mymaxWidth )
175 _w = mymaxWidth;
177 SetMinSize( wxSize( _w, wxDefaultCoord ));
178 SetMaxSize( wxSize( _w, wxDefaultCoord ));
180 if( GetContainingSizer() != NULL )
181 GetContainingSizer()->Layout();