fix for wxMiniFrame titlebar appearing blank

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2014-03-02 21:55:26 +00:00
parent fe22821a24
commit 2f83cddcc9

View File

@@ -16,7 +16,6 @@
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/settings.h" #include "wx/settings.h"
#include "wx/dcclient.h" #include "wx/dcclient.h"
#include "wx/image.h"
#endif #endif
#ifdef __WXGTK3__ #ifdef __WXGTK3__
@@ -39,28 +38,6 @@ extern bool g_blockEventsOnScroll;
// "expose_event" of m_mainWidget // "expose_event" of m_mainWidget
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// StepColour() it a utility function that simply darkens
// or lightens a color, based on the specified percentage
static wxColor StepColour(const wxColor& c, int percent)
{
int r = c.Red(), g = c.Green(), b = c.Blue();
return wxColour((unsigned char)wxMin((r*percent)/100,255),
(unsigned char)wxMin((g*percent)/100,255),
(unsigned char)wxMin((b*percent)/100,255));
}
static wxColor LightContrastColour(const wxColour& c)
{
int amount = 120;
// if the color is especially dark, then
// make the contrast even lighter
if (c.Red() < 128 && c.Green() < 128 && c.Blue() < 128)
amount = 160;
return StepColour(c, amount);
}
extern "C" { extern "C" {
#ifdef __WXGTK3__ #ifdef __WXGTK3__
static gboolean draw(GtkWidget* widget, cairo_t* cr, wxMiniFrame* win) static gboolean draw(GtkWidget* widget, cairo_t* cr, wxMiniFrame* win)
@@ -114,7 +91,7 @@ static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMin
{ {
dc.SetFont( *wxSMALL_FONT ); dc.SetFont( *wxSMALL_FONT );
wxBrush brush( LightContrastColour( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT) ) ); wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
dc.SetBrush( brush ); dc.SetBrush( brush );
dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle( win->m_miniEdge-1, dc.DrawRectangle( win->m_miniEdge-1,
@@ -122,12 +99,16 @@ static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMin
win->m_width - (2*(win->m_miniEdge-1)), win->m_width - (2*(win->m_miniEdge-1)),
15 ); 15 );
dc.SetTextForeground( *wxWHITE ); const wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
dc.SetTextForeground(textColor);
dc.DrawText( win->GetTitle(), 6, 4 ); dc.DrawText( win->GetTitle(), 6, 4 );
if (style & wxCLOSE_BOX) if (style & wxCLOSE_BOX)
{
dc.SetTextBackground(textColor);
dc.DrawBitmap( win->m_closeButton, win->m_width-18, 3, true ); dc.DrawBitmap( win->m_closeButton, win->m_width-18, 3, true );
} }
}
return false; return false;
} }
@@ -402,10 +383,8 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
if (m_miniTitle && (style & wxCLOSE_BOX)) if (m_miniTitle && (style & wxCLOSE_BOX))
{ {
wxImage img = wxBitmap((const char*)close_bits, 16, 16).ConvertToImage(); m_closeButton = wxBitmap((const char*)close_bits, 16, 16);
img.Replace(0,0,0,123,123,123); m_closeButton.SetMask(new wxMask(m_closeButton));
img.SetMaskColour(123,123,123);
m_closeButton = wxBitmap( img );
} }
/* these are called when the borders are drawn */ /* these are called when the borders are drawn */