+ return sz ;
+ }
+
+private:
+ wxComboBox *m_cb;
+
+ friend class wxComboBox;
+
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxComboBoxChoice, wxChoice)
+ EVT_CHOICE(wxID_ANY, wxComboBoxChoice::OnChoice)
+END_EVENT_TABLE()
+
+wxComboBox::~wxComboBox()
+{
+ // delete client objects
+ FreeData();
+
+ // delete the controls now, don't leave them alive even though they would
+ // still be eventually deleted by our parent - but it will be too late, the
+ // user code expects them to be gone now
+ if (m_text != NULL)
+ {
+ delete m_text;
+ m_text = NULL;
+ }
+
+ if (m_choice != NULL)
+ {
+ delete m_choice;
+ m_choice = NULL;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// geometry
+// ----------------------------------------------------------------------------
+
+wxSize wxComboBox::DoGetBestSize() const
+{
+ if (!m_choice && !m_text)
+ return GetSize();
+
+ wxSize size = m_choice->GetBestSize();
+
+ if ( m_text != NULL )
+ {
+ wxSize sizeText = m_text->GetBestSize();
+ if (sizeText.y > size.y)
+ size.y = sizeText.y;
+
+ size.x = m_choice->GetPopupWidth() + sizeText.x + MARGIN;
+ size.x += TEXTFOCUSBORDER ;
+ size.y += 2 * TEXTFOCUSBORDER ;
+ }
+ else
+ {
+ // clipping is too tight
+ size.y += 1 ;
+ }
+
+ return size;
+}
+
+void wxComboBox::DoMoveWindow(int x, int y, int width, int height)
+{
+ wxControl::DoMoveWindow( x, y, width , height );
+
+ if ( m_text == NULL )
+ {
+ // we might not be fully constructed yet, therefore watch out...
+ if ( m_choice )
+ m_choice->SetSize(0, 0 , width, -1);
+ }
+ else
+ {
+ wxCoord wText = width - m_choice->GetPopupWidth() - MARGIN;
+ m_text->SetSize(TEXTFOCUSBORDER, TEXTFOCUSBORDER, wText, -1);
+
+ // put it at an inset of 1 to have outer area shadows drawn as well
+ m_choice->SetSize(TEXTFOCUSBORDER + wText + MARGIN - 1 , TEXTFOCUSBORDER, m_choice->GetPopupWidth() , -1);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// operations forwarded to the subcontrols
+// ----------------------------------------------------------------------------
+
+bool wxComboBox::Enable(bool enable)
+{
+ if ( !wxControl::Enable(enable) )
+ return false;
+
+ if (m_text)
+ m_text->Enable(enable);
+
+ return true;
+}
+
+bool wxComboBox::Show(bool show)
+{
+ if ( !wxControl::Show(show) )
+ return false;
+
+ return true;
+}
+
+void wxComboBox::DelegateTextChanged( const wxString& value )
+{
+ SetStringSelection( value );
+}
+
+void wxComboBox::DelegateChoice( const wxString& value )
+{
+ SetStringSelection( value );
+}
+
+void wxComboBox::Init()
+{
+ WX_INIT_CONTROL_CONTAINER();
+}
+
+bool wxComboBox::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ const wxArrayString& choices,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+{
+ wxCArrayString chs( choices );
+
+ return Create( parent, id, value, pos, size, chs.GetCount(),
+ chs.GetStrings(), style, validator, name );
+}
+
+bool wxComboBox::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n,
+ const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
+{
+ if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
+ validator, name) )
+ {
+ return false;
+ }
+
+ m_choice = new wxComboBoxChoice(this, style );
+ wxSize csize = size;
+ if ( style & wxCB_READONLY )
+ {
+ m_text = NULL;
+ }
+ else
+ {
+ m_text = new wxComboBoxText(this);
+ if ( size.y == -1 )
+ {
+ csize.y = m_text->GetSize().y ;
+ csize.y += 2 * TEXTFOCUSBORDER ;
+ }
+ }
+
+ DoSetSize(pos.x, pos.y, csize.x, csize.y);
+
+ for ( int i = 0 ; i < n ; i++ )
+ {
+ m_choice->DoAppend( choices[ i ] );
+ }
+
+ // Needed because it is a wxControlWithItems
+ SetInitialSize(size);
+ SetStringSelection(value);
+
+ return true;