Have wxComboCtrl honour any application-specified foreground and background colour.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@62928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -858,7 +858,12 @@ void wxComboCtrlBase::OnThemeChange()
|
|||||||
// be the correct colour and themed brush. Instead we'll use
|
// be the correct colour and themed brush. Instead we'll use
|
||||||
// wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
|
// wxSYS_COLOUR_WINDOW in the EVT_PAINT handler as needed.
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
if ( !m_hasBgCol )
|
||||||
|
{
|
||||||
|
wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
|
SetOwnBackgroundColour(bgCol);
|
||||||
|
m_hasBgCol = false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1262,30 +1267,40 @@ void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags
|
|||||||
selRect.x += wcp + focusSpacingX;
|
selRect.x += wcp + focusSpacingX;
|
||||||
selRect.width -= wcp + (focusSpacingX*2);
|
selRect.width -= wcp + (focusSpacingX*2);
|
||||||
|
|
||||||
|
wxColour fgCol;
|
||||||
wxColour bgCol;
|
wxColour bgCol;
|
||||||
|
|
||||||
if ( isEnabled )
|
if ( isEnabled )
|
||||||
{
|
{
|
||||||
// If popup is hidden and this control is focused,
|
if ( m_hasFgCol )
|
||||||
// then draw the focus-indicator (selbgcolor background etc.).
|
// Honour the custom foreground colour
|
||||||
if ( isFocused )
|
fgCol = GetForegroundColour();
|
||||||
{
|
else if ( isFocused )
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
|
fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
|
||||||
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
|
else
|
||||||
}
|
fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isEnabled )
|
||||||
|
{
|
||||||
|
if ( m_hasBgCol )
|
||||||
|
// Honour the custom background colour
|
||||||
|
bgCol = GetBackgroundColour();
|
||||||
|
else if ( isFocused )
|
||||||
|
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
|
|
||||||
#ifndef __WXMAC__ // see note in OnThemeChange
|
#ifndef __WXMAC__ // see note in OnThemeChange
|
||||||
bgCol = GetBackgroundColour();
|
bgCol = GetBackgroundColour();
|
||||||
#else
|
#else
|
||||||
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT) );
|
|
||||||
#ifndef __WXMAC__ // see note in OnThemeChange
|
#ifndef __WXMAC__ // see note in OnThemeChange
|
||||||
bgCol = GetBackgroundColour();
|
bgCol = GetBackgroundColour();
|
||||||
#else
|
#else
|
||||||
@@ -1293,6 +1308,7 @@ void wxComboCtrlBase::PrepareBackground( wxDC& dc, const wxRect& rect, int flags
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dc.SetTextForeground( fgCol );
|
||||||
dc.SetBrush( bgCol );
|
dc.SetBrush( bgCol );
|
||||||
dc.SetPen( bgCol );
|
dc.SetPen( bgCol );
|
||||||
dc.DrawRectangle( selRect );
|
dc.DrawRectangle( selRect );
|
||||||
|
@@ -170,7 +170,14 @@ void wxComboCtrl::OnThemeChange()
|
|||||||
{
|
{
|
||||||
// there doesn't seem to be any way to get the text colour using themes
|
// there doesn't seem to be any way to get the text colour using themes
|
||||||
// API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX
|
// API: TMT_TEXTCOLOR doesn't work neither for EDIT nor COMBOBOX
|
||||||
SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
if ( !m_hasFgCol )
|
||||||
|
{
|
||||||
|
wxColour fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||||
|
SetForegroundColour(fgCol);
|
||||||
|
m_hasFgCol = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxColour bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
|
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
wxUxThemeEngine * const theme = wxUxThemeEngine::GetIfActive();
|
wxUxThemeEngine * const theme = wxUxThemeEngine::GetIfActive();
|
||||||
@@ -189,17 +196,21 @@ void wxComboCtrl::OnThemeChange()
|
|||||||
);
|
);
|
||||||
if ( SUCCEEDED(hr) )
|
if ( SUCCEEDED(hr) )
|
||||||
{
|
{
|
||||||
SetBackgroundColour(wxRGBToColour(col));
|
bgCol = wxRGBToColour(col);
|
||||||
|
}
|
||||||
// skip the call below
|
else
|
||||||
return;
|
{
|
||||||
|
wxLogApiError(_T("GetThemeColor(EDIT, ETS_NORMAL, TMT_FILLCOLOR)"),
|
||||||
|
hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogApiError(_T("GetThemeColor(EDIT, ETS_NORMAL, TMT_FILLCOLOR)"), hr);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
if ( !m_hasBgCol )
|
||||||
|
{
|
||||||
|
SetBackgroundColour(bgCol);
|
||||||
|
m_hasBgCol = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboCtrl::OnResize()
|
void wxComboCtrl::OnResize()
|
||||||
@@ -347,65 +358,43 @@ wxComboCtrl::PrepareBackground( wxDC& dc, const wxRect& rect, int flags ) const
|
|||||||
// theme = wxUxThemeEngine::GetIfActive();
|
// theme = wxUxThemeEngine::GetIfActive();
|
||||||
|
|
||||||
wxColour bgCol;
|
wxColour bgCol;
|
||||||
|
wxColour fgCol;
|
||||||
bool drawDottedEdge = false;
|
bool drawDottedEdge = false;
|
||||||
|
|
||||||
|
if ( isEnabled && isFocused && HasFlag(wxCB_READONLY) )
|
||||||
|
drawDottedEdge = true;
|
||||||
|
|
||||||
if ( isEnabled )
|
if ( isEnabled )
|
||||||
{
|
{
|
||||||
// If popup is hidden and this control is focused,
|
if ( m_hasFgCol )
|
||||||
// then draw the focus-indicator (selbgcolor background etc.).
|
// Honour the custom foreground colour
|
||||||
if ( isFocused )
|
fgCol = GetForegroundColour();
|
||||||
{
|
else if ( isFocused )
|
||||||
#if 0
|
fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||||
// TODO: Proper theme color getting (JMS: I don't know which parts/colors to use,
|
|
||||||
// those below don't work)
|
|
||||||
if ( hTheme )
|
|
||||||
{
|
|
||||||
theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_SELECTED,TMT_TEXTCOLOR,&cref);
|
|
||||||
dc.SetTextForeground( wxRGBToColour(cref) );
|
|
||||||
theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_SELECTED,TMT_FILLCOLOR,&cref);
|
|
||||||
bgCol = wxRGBToColour(cref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
|
|
||||||
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
|
|
||||||
if ( m_windowStyle & wxCB_READONLY )
|
|
||||||
drawDottedEdge = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||||
/*if ( hTheme )
|
|
||||||
{
|
|
||||||
theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_NORMAL,TMT_TEXTCOLOR,&cref);
|
|
||||||
dc.SetTextForeground( wxRGBToColour(cref) );
|
|
||||||
theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_NORMAL,TMT_FILLCOLOR,&cref);
|
|
||||||
bgCol = wxRGBToColour(cref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
|
|
||||||
bgCol = GetBackgroundColour();
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*if ( hTheme )
|
fgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
|
||||||
{
|
|
||||||
theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_DISABLED,TMT_TEXTCOLOR,&cref);
|
|
||||||
dc.SetTextForeground( wxRGBToColour(cref) );
|
|
||||||
theme->GetThemeColor(hTheme,EP_EDITTEXT,ETS_DISABLED,TMT_EDGEFILLCOLOR,&cref);
|
|
||||||
bgCol = wxRGBToColour(cref);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT) );
|
|
||||||
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isEnabled )
|
||||||
|
{
|
||||||
|
if ( m_hasBgCol )
|
||||||
|
// Honour the custom background colour
|
||||||
|
bgCol = GetBackgroundColour();
|
||||||
|
else if ( isFocused )
|
||||||
|
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
|
||||||
|
else
|
||||||
|
bgCol = GetBackgroundColour();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bgCol = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.SetTextForeground(fgCol);
|
||||||
dc.SetBrush(bgCol);
|
dc.SetBrush(bgCol);
|
||||||
dc.SetPen(bgCol);
|
dc.SetPen(bgCol);
|
||||||
dc.DrawRectangle(selRect);
|
dc.DrawRectangle(selRect);
|
||||||
@@ -725,7 +714,7 @@ bool wxComboCtrl::IsKeyPopupToggle(const wxKeyEvent& event) const
|
|||||||
( !isPopupShown &&
|
( !isPopupShown &&
|
||||||
HasFlag(wxCB_READONLY)
|
HasFlag(wxCB_READONLY)
|
||||||
#if wxUSE_UXTHEME
|
#if wxUSE_UXTHEME
|
||||||
&&
|
&&
|
||||||
!wxUxThemeEngine::GetIfActive()
|
!wxUxThemeEngine::GetIfActive()
|
||||||
#endif
|
#endif
|
||||||
) )
|
) )
|
||||||
|
Reference in New Issue
Block a user