Merge branches 'auidemo' and 'auibarmsw' of mimi89999/wxWidgets

Improve appearance of disabled AUI buttons

Use wxSYS_COLOUR_GRAYTEXT for the disabled buttons, it works better in
non-default themes.

Also show how a disabled button looks like in the aui sample.

See https://github.com/wxWidgets/wxWidgets/pull/1801

See https://github.com/wxWidgets/wxWidgets/pull/1803
This commit is contained in:
Vadim Zeitlin
2020-04-17 23:53:41 +02:00
2 changed files with 8 additions and 11 deletions

View File

@@ -847,7 +847,8 @@ MyFrame::MyFrame(wxWindow* parent,
tb4->AddTool(ID_DropDownToolbarItem, "Item 1", tb4_bmp1);
tb4->AddTool(ID_SampleItem+23, "Item 2", tb4_bmp1);
tb4->SetToolSticky(ID_SampleItem+23, true);
tb4->AddTool(ID_SampleItem+24, "Item 3", tb4_bmp1);
tb4->AddTool(ID_SampleItem+24, "Disabled", tb4_bmp1);
tb4->EnableTool(ID_SampleItem+24, false); // Just to show disabled items look
tb4->AddTool(ID_SampleItem+25, "Item 4", tb4_bmp1);
tb4->AddSeparator();
tb4->AddTool(ID_SampleItem+26, "Item 5", tb4_bmp1);

View File

@@ -105,12 +105,6 @@ void wxAuiMSWToolBarArt::DrawLabel(
wxAuiGenericToolBarArt::DrawLabel(dc, wnd, item, rect);
}
static const unsigned char
DISABLED_TEXT_GREY_HUE = wxColour::AlphaBlend(0, 255, 0.4);
const wxColour DISABLED_TEXT_COLOR(DISABLED_TEXT_GREY_HUE,
DISABLED_TEXT_GREY_HUE,
DISABLED_TEXT_GREY_HUE);
void wxAuiMSWToolBarArt::DrawButton(
wxDC& dc,
wxWindow* wnd,
@@ -200,9 +194,10 @@ void wxAuiMSWToolBarArt::DrawButton(
dc.DrawBitmap(bmp, bmpX, bmpY, true);
// set the item's text color based on if it is disabled
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED )
dc.SetTextForeground(DISABLED_TEXT_COLOR);
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
else
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() )
{
@@ -322,9 +317,10 @@ void wxAuiMSWToolBarArt::DrawDropDownButton(
dc.DrawBitmap(bmp, bmpX, bmpY, true);
// set the item's text color based on if it is disabled
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED )
dc.SetTextForeground(DISABLED_TEXT_COLOR);
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
else
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT));
if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() )
{