-// wxComboControl creation
-// ----------------------------------------------------------------------------
-
-void wxComboControl::Init()
-{
- m_popup = (wxComboPopup *)NULL;
- m_winPopup = (wxPopupComboWindow *)NULL;
- m_isPopupShown = FALSE;
- m_btn = NULL;
- m_text = NULL;
-}
-
-bool wxComboControl::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- // first create our own window, i.e. the one which will contain all
- // subcontrols
- style &= ~wxBORDER_NONE;
- style |= wxBORDER_SUNKEN;
- if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
- return FALSE;
-
- // create the text control and the button as our siblings (*not* children),
- // don't care about size/position here - they will be set in DoMoveWindow()
- m_btn = new wxComboButton(this);
- m_text = new wxComboTextCtrl(this,
- value,
- style & wxCB_READONLY ? wxTE_READONLY : 0,
- validator);
-
- // for compatibility with the other ports, the height specified is the
- // combined height of the combobox itself and the popup
- if ( size.y == -1 )
- {
- // ok, use default height for popup too
- m_heightPopup = -1;
- }
- else
- {
- m_heightPopup = size.y - DoGetBestSize().y;
- }
-
- SetBestSize(size);
- Move(pos);
-
- // create the popup window immediately here to allow creating the controls
- // with parent == GetPopupWindow() from the derived class ctor
- m_winPopup = new wxPopupComboWindow(this);
-
- // have to disable this window to avoid interfering it with message
- // processing to the text and the button... but pretend it is enabled to
- // make IsEnabled() return TRUE
- wxControl::Enable(FALSE); // don't use non virtual Disable() here!
- m_isEnabled = TRUE;
-
- CreateInputHandler(wxINP_HANDLER_COMBOBOX);
-
- return TRUE;
-}
-
-wxComboControl::~wxComboControl()
-{
- // as the button and the text control are the parent's children and not
- // ours, we have to delete them manually - they are not deleted
- // automatically by wxWindows when we're deleted
- delete m_btn;
- delete m_text;
-
- delete m_winPopup;
-}
-
-// ----------------------------------------------------------------------------
-// geometry stuff
-// ----------------------------------------------------------------------------
-
-void wxComboControl::DoSetSize(int x, int y,
- int width, int height,
- int sizeFlags)
-{
- // combo height is always fixed
- wxControl::DoSetSize(x, y, width, DoGetBestSize().y, sizeFlags);
-}
-
-wxSize wxComboControl::DoGetBestClientSize() const
-{
- wxSize sizeBtn = m_btn->GetBestSize(),
- sizeText = m_text->GetBestSize();
-
- return wxSize(sizeBtn.x + sizeText.x, wxMax(sizeBtn.y, sizeText.y));
-}
-
-void wxComboControl::DoMoveWindow(int x, int y, int width, int height)
-{
- wxControl::DoMoveWindow(x, y, width, height);
-
- // position the subcontrols inside the client area
- wxRect rectBorders = GetRenderer()->GetBorderDimensions(GetBorder());
- x += rectBorders.x;
- y += rectBorders.y;
- width -= rectBorders.x + rectBorders.width;
- height -= rectBorders.y + rectBorders.height;
-
- wxSize sizeBtn = m_btn->GetBestSize();
-
- wxCoord wText = width - sizeBtn.x;
- wxPoint p = GetParent() ? GetParent()->GetClientAreaOrigin() : wxPoint(0,0);
- m_text->SetSize(x - p.x, y - p.y, wText, height);
- m_btn->SetSize(x - p.x + wText, y - p.y, sizeBtn.x, height);
-}
-
-// ----------------------------------------------------------------------------
-// operations
-// ----------------------------------------------------------------------------
-
-bool wxComboControl::Enable(bool enable)
-{
- if ( !wxControl::Enable(enable) )
- return FALSE;
-
- m_btn->Enable(enable);
- m_text->Enable(enable);
-
- return TRUE;
-}
-
-bool wxComboControl::Show(bool show)
-{
- if ( !wxControl::Show(show) )
- return FALSE;
-
- if (m_btn)
- m_btn->Show(show);
-
- if (m_text)
- m_text->Show(show);
-
- return TRUE;
-}
-
-// ----------------------------------------------------------------------------
-// popup window handling