#define TEXTCTRL_TEXT_CENTERED 0 // 1 if text in textctrl is vertically centered
#define FOCUS_RING 0 // No focus ring on wxMSW
-#if !defined(__WXWINCE__)
- // 1 if wxTextEntry::SetMargins() can be used to set the left margin
- #define LEFT_MARGIN_CAN_BE_SET 1
-#else
- #define LEFT_MARGIN_CAN_BE_SET 0
-#endif
-
//#undef wxUSE_POPUPWIN
//#define wxUSE_POPUPWIN 0
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
#define FOCUS_RING 0 // No focus ring on wxGTK
-#if GTK_CHECK_VERSION(2,10,0)
- // 1 if wxTextEntry::SetMargins() can be used to set the left margin
- #define LEFT_MARGIN_CAN_BE_SET 1
-#else
- #define LEFT_MARGIN_CAN_BE_SET 0
-#endif
-
#elif defined(__WXMAC__)
#define USE_TRANSIENT_POPUP 1 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
#undef COMBO_MARGIN
#define COMBO_MARGIN FOCUS_RING
-// 1 if wxTextEntry::SetMargins() can be used to set the left margin
-#define LEFT_MARGIN_CAN_BE_SET 0
-
#else
#define USE_TRANSIENT_POPUP 0 // Use wxPopupWindowTransient (preferred, if it works properly on platform)
#define TEXTCTRL_TEXT_CENTERED 1 // 1 if text in textctrl is vertically centered
#define FOCUS_RING 0
-// 1 if wxTextEntry::SetMargins() can be used to set the left margin
-#define LEFT_MARGIN_CAN_BE_SET 0
-
#endif
winFocused != m_combo->GetButton() // GTK (atleast) requires this
)
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
}
event.Skip();
void wxComboFrameEventHandler::OnMenuEvent( wxMenuEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnMouseEvent( wxMouseEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnClose( wxCloseEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnActivate( wxActivateEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnResize( wxSizeEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboFrameEventHandler::OnMove( wxMoveEvent& event )
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxComboCtrlBase)),
wxT("parent might not be wxComboCtrl, but check IMPLEMENT_DYNAMIC_CLASS(2) macro for correctness") );
- combo->OnPopupDismiss();
+ combo->OnPopupDismiss(true);
}
#endif // USES_WXPOPUPTRANSIENTWINDOW
if ( !event.GetActive() )
{
// Tell combo control that we are dismissed.
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
event.Skip();
}
void wxComboPopup::Dismiss()
{
- m_combo->HidePopup();
+ m_combo->HidePopup(true);
}
// ----------------------------------------------------------------------------
int customBorder = m_widthCustomBorder;
if ( (m_text->GetWindowStyleFlag() & wxBORDER_MASK) == wxNO_BORDER )
{
-#if LEFT_MARGIN_CAN_BE_SET
- // Call SetMargins() on textctrl if LEFT_MARGIN_CAN_BE_SET == 1
- wxUnusedVar(textCtrlXAdjust);
- m_text->SetMargins(0);
- textCtrlXAdjust = 0;
-#endif
+ int x;
- // Centre textctrl
+ if ( !m_widthCustomPaint )
+ {
+ // No special custom paint area - we can use 0 left margin
+ // with wxTextCtrl.
+ if ( m_text->SetMargins(0) )
+ textCtrlXAdjust = 0;
+ x = m_tcArea.x + m_marginLeft + textCtrlXAdjust;
+ }
+ else
+ {
+ // There is special custom paint area - it is better to
+ // use some margin with the wxTextCtrl.
+ m_text->SetMargins(m_marginLeft);
+ x = m_tcArea.x + m_widthCustomPaint +
+ m_marginLeft + textCtrlXAdjust;
+ }
+
+ // Centre textctrl vertically, if needed
#if !TEXTCTRL_TEXT_CENTERED
int tcSizeY = m_text->GetBestSize().y;
int diff0 = sz.y - tcSizeY;
if ( y < customBorder )
y = customBorder;
- int x = m_tcArea.x + m_widthCustomPaint +
- m_marginLeft + textCtrlXAdjust;
-
m_text->SetSize(x,
y,
m_tcArea.width - m_tcArea.x - x,
- /*m_tcArea.width - COMBO_MARGIN -
- (textCtrlXAdjust + m_widthCustomPaint +
- m_marginLeft),*/
-1 );
// Make sure textctrl doesn't exceed the bottom custom border
if ( !wxControl::SetFont(font) )
return false;
- if (m_text)
+ if ( m_text )
+ {
+ // Without hiding the wxTextCtrl there would be some
+ // visible 'flicker' (at least on Windows XP).
+ m_text->Hide();
m_text->SetFont(font);
+ OnResize();
+ m_text->Show();
+ }
return true;
}
if ( IsPopupWindowState(Visible) &&
( evtType == wxEVT_LEFT_DOWN || evtType == wxEVT_RIGHT_DOWN ) )
{
- HidePopup();
+ HidePopup(true);
return true;
}
}
#if USES_WXPOPUPWINDOW
// Click here always hides the popup.
if ( m_popupWinType == POPUPWIN_WXPOPUPWINDOW )
- HidePopup();
+ HidePopup(true);
#endif
}
else
{
wxWindow* tc = GetTextCtrl();
if ( tc && tc != DoFindFocus() )
-#ifdef __WXMAC__
- m_resetFocus = true;
-#else
{
tc->SetFocus();
}
-#endif
}
Refresh();
// Destroy popup window and the child control
void wxComboCtrlBase::DestroyPopup()
{
- HidePopup();
+ HidePopup(true);
if ( m_popup )
m_popup->RemoveEventHandler(m_popupExtraHandler);
// Derived classes can override this method for totally custom
// popup action
if ( !IsPopupWindowState(Visible) )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
+ event.SetEventObject(this);
+ HandleWindowEvent(event);
+
ShowPopup();
+ }
else
- HidePopup();
+ {
+ HidePopup(true);
+ }
}
void wxComboCtrlBase::ShowPopup()
Refresh();
}
-void wxComboCtrlBase::OnPopupDismiss()
+void wxComboCtrlBase::OnPopupDismiss(bool generateEvent)
{
// Just in case, avoid double dismiss
if ( IsPopupWindowState(Hidden) )
Refresh();
SetFocus();
+
+ if ( generateEvent )
+ {
+ wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_CLOSEUP, GetId());
+ event.SetEventObject(this);
+ HandleWindowEvent(event);
+ }
}
-void wxComboCtrlBase::HidePopup()
+void wxComboCtrlBase::HidePopup(bool generateEvent)
{
// Should be able to call this without popup interface
if ( IsPopupWindowState(Hidden) )
m_winPopup->Hide();
- OnPopupDismiss();
+ OnPopupDismiss(generateEvent);
}
// ----------------------------------------------------------------------------