m_text->Create(this, wxID_ANY, m_valueString,
wxDefaultPosition, wxSize(10,-1),
style, validator);
+ m_text->SetHint(m_hintText);
}
}
// be the correct colour and themed brush. Instead we'll use
// wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
#ifndef __WXMAC__
- SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
-#endif
+ #if defined(__WXMSW__) || defined(__WXGTK__)
+ wxVisualAttributes vattrs = wxComboBox::GetClassDefaultAttributes();
+ #else
+ wxVisualAttributes vattrs;
+ vattrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ vattrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
+ #endif
+
+ // Only change the colours if application has not specified
+ // custom ones.
+ if ( !m_hasFgCol )
+ {
+ SetOwnForegroundColour(vattrs.colFg);
+ m_hasFgCol = false;
+ }
+ if ( !m_hasBgCol )
+ {
+ SetOwnBackgroundColour(vattrs.colBg);
+ m_hasBgCol = false;
+ }
+#endif // !__WXMAC__
}
wxComboCtrlBase::~wxComboCtrlBase()
}
#endif // wxUSE_VALIDATORS
+bool wxComboCtrlBase::SetForegroundColour(const wxColour& colour)
+{
+ if ( wxControl::SetForegroundColour(colour) )
+ {
+ if ( m_text )
+ m_text->SetForegroundColour(colour);
+ return true;
+ }
+ return false;
+}
+
+bool wxComboCtrlBase::SetBackgroundColour(const wxColour& colour)
+{
+ if ( wxControl::SetBackgroundColour(colour) )
+ {
+ if ( m_text )
+ m_text->SetBackgroundColour(colour);
+ return true;
+ }
+ return false;
+}
// ----------------------------------------------------------------------------
// painting
// ----------------------------------------------------------------------------
selRect.width -= wcp + (focusSpacingX*2);
wxColour bgCol;
+ wxColour fgCol;
+
bool doDrawSelRect = true;
+ // Determine foreground colour
+ if ( isEnabled )
+ {
+ if ( doDrawFocusRect )
+ {
+ fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+ }
+ else if ( m_hasFgCol )
+ {
+ // Honour the custom foreground colour
+ fgCol = GetForegroundColour();
+ }
+ else
+ {
+ fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ }
+ }
+ else
+ {
+ fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
+ }
+
+ // Determine background colour
if ( isEnabled )
{
- // If popup is hidden and this control is focused,
- // then draw the focus-indicator (selbgcolor background etc.).
if ( doDrawFocusRect )
{
- dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
}
+ else if ( m_hasBgCol )
+ {
+ // Honour the custom background colour
+ bgCol = GetBackgroundColour();
+ }
else
{
- dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
#ifndef __WXMAC__ // see note in OnThemeChange
doDrawSelRect = false;
bgCol = GetBackgroundColour();
}
else
{
- dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT) );
#ifndef __WXMAC__ // see note in OnThemeChange
bgCol = GetBackgroundColour();
#else
#endif
}
+ dc.SetTextForeground( fgCol );
dc.SetBrush( bgCol );
if ( doDrawSelRect )
{
}
else // no popup
{
- if ( GetParent()->HasFlag(wxTAB_TRAVERSAL) &&
- HandleAsNavigationKey(event) )
- return;
+ wxWindow* mainCtrl = GetMainWindowOfCompositeControl();
+
+ if ( mainCtrl->GetParent()->HasFlag(wxTAB_TRAVERSAL) )
+ {
+ if ( mainCtrl->HandleAsNavigationKey(event) )
+ return;
+ }
if ( IsKeyPopupToggle(event) )
{
// that if transient popup is open, then tab traversal is to be ignored.
// However, I think this code would still be needed for cases where
// transient popup doesn't work yet (wxWinCE?).
- wxWindow* parent = GetParent();
+ wxWindow* mainCtrl = GetMainWindowOfCompositeControl();
+ wxWindow* parent = mainCtrl->GetParent();
int parentFlags = parent->GetWindowStyle();
if ( parentFlags & wxTAB_TRAVERSAL )
{
m_text->Undo();
}
+bool wxComboCtrlBase::SetHint(const wxString& hint)
+{
+ m_hintText = hint;
+ bool res = true;
+ if ( m_text )
+ res = m_text->SetHint(hint);
+ Refresh();
+ return res;
+}
+
+wxString wxComboCtrlBase::GetHint() const
+{
+ return m_hintText;
+}
+
#endif // wxUSE_COMBOCTRL