OnThemeChange();
m_absIndent = GetNativeTextIndent();
+ m_iFlags |= wxCC_IFLAG_CREATED;
+
+ // If x and y indicate valid size, wxSizeEvent won't be
+ // emitted automatically, so we need to add artifical one.
+ if ( size.x > 0 && size.y > 0 )
+ {
+ wxSizeEvent evt(size,GetId());
+ GetEventHandler()->AddPendingEvent(evt);
+ }
+
return true;
}
m_toplevEvtHandler = (wxEvtHandler*) NULL;
#endif
- if ( m_popup )
- m_popup->RemoveEventHandler(m_popupExtraHandler);
-
- delete m_popupExtraHandler;
-
- HidePopup();
-
- delete m_popupInterface;
- delete m_winPopup;
+ DestroyPopup();
RemoveEventHandler(m_extraEvtHandler);
{
wxSize sz = GetClientSize();
int customBorder = m_widthCustomBorder;
- bool buttonOutside;
int btnBorder; // border for button only
// check if button should really be outside the border: we'll do it it if
m_btnSpacingX == 0 &&
m_btnHei == 0 )
{
- buttonOutside = true;
m_iFlags |= wxCC_IFLAG_BUTTON_OUTSIDE;
btnBorder = 0;
}
else
{
- buttonOutside = false;
m_iFlags &= ~(wxCC_IFLAG_BUTTON_OUTSIDE);
btnBorder = customBorder;
}
if ( butWidth <= 0 )
return;
+ int butHeight = sz.y - btnBorder*2;
+
// Adjust button width
if ( m_btnWid < 0 )
butWidth += m_btnWid;
else if ( m_btnWid > 0 )
butWidth = m_btnWid;
+ else
+ {
+ // Adjust button width to match aspect ratio
+ // (but only if control is smaller than best size).
+ int bestHeight = GetBestSize().y;
+ int height = GetSize().y;
- int butHeight = sz.y;
-
- butHeight -= btnBorder*2;
+ if ( height < bestHeight )
+ {
+ // Make very small buttons square, as it makes
+ // them accommodate arrow image better and still
+ // looks decent.
+ if ( height > 18 )
+ butWidth = (height*butWidth)/bestHeight;
+ else
+ butWidth = butHeight;
+ }
+ }
// Adjust button height
if ( m_btnHei < 0 )
return ret;
}
-void wxComboCtrlBase::DoMoveWindow(int x, int y, int width, int height)
-{
- // SetSize is called last in create, so it marks the end of creation
- m_iFlags |= wxCC_IFLAG_CREATED;
-
- wxControl::DoMoveWindow(x, y, width, height);
-}
-
void wxComboCtrlBase::OnSizeEvent( wxSizeEvent& event )
{
if ( !IsCreated() )
popupInterface->m_iFlags |= wxCP_IFLAG_CREATED;
}
+// Destroy popup window and the child control
+void wxComboCtrlBase::DestroyPopup()
+{
+ if ( m_popup )
+ m_popup->RemoveEventHandler(m_popupExtraHandler);
+
+ delete m_popupExtraHandler;
+
+ HidePopup();
+
+ delete m_popupInterface;
+
+ if ( m_winPopup )
+ m_winPopup->Destroy();
+
+ m_popupInterface = (wxComboPopup*) NULL;
+ m_winPopup = (wxWindow*) NULL;
+ m_popup = (wxWindow*) NULL;
+}
+
void wxComboCtrlBase::SetPopupControl( wxComboPopup* iface )
{
wxCHECK_RET( iface, wxT("no popup interface set for wxComboCtrl") );
- delete m_popupInterface;
- delete m_winPopup;
+ DestroyPopup();
iface->InitBase(this);
iface->Init();
m_popupInterface = iface;
- if ( !iface->LazyCreate() || m_winPopup )
+ if ( !iface->LazyCreate() )
{
CreatePopup();
}