X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/480be76aae46d8b05e178e8aefc9588df8a6f071..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/generic/clrpickerg.cpp?ds=sidebyside diff --git a/src/generic/clrpickerg.cpp b/src/generic/clrpickerg.cpp index 4e2a86b32c..ffc71547ad 100644 --- a/src/generic/clrpickerg.cpp +++ b/src/generic/clrpickerg.cpp @@ -27,8 +27,8 @@ #if wxUSE_COLOURPICKERCTRL #include "wx/clrpicker.h" - #include "wx/colordlg.h" +#include "wx/dcmemory.h" // ============================================================================ @@ -51,14 +51,14 @@ bool wxGenericColourButton::Create( wxWindow *parent, wxWindowID id, // create this button if (!wxBitmapButton::Create( parent, id, m_bitmap, pos, - size, style, validator, name )) + size, style | wxBU_AUTODRAW, validator, name )) { wxFAIL_MSG( wxT("wxGenericColourButton creation failed") ); return false; } // and handle user clicks on it - Connect(wxEVT_COMMAND_BUTTON_CLICKED, + Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxGenericColourButton::OnButtonClick), NULL, this); @@ -83,7 +83,7 @@ void wxGenericColourButton::InitColourData() void wxGenericColourButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev)) { - // update the wxColouData to be shown in the the dialog + // update the wxColouData to be shown in the dialog ms_data.SetColour(m_colour); // create the colour dialog and display it @@ -105,19 +105,27 @@ void wxGenericColourButton::UpdateColour() dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetBrush( wxBrush(m_colour) ); dc.DrawRectangle( 0,0,m_bitmap.GetWidth(),m_bitmap.GetHeight() ); + + if ( HasFlag(wxCLRP_SHOW_LABEL) ) + { + wxColour col( ~m_colour.Red(), ~m_colour.Green(), ~m_colour.Blue() ); + dc.SetTextForeground( col ); + dc.SetFont( GetFont() ); + dc.DrawText( m_colour.GetAsString(wxC2S_HTML_SYNTAX), 0, 0 ); + } + dc.SelectObject( wxNullBitmap ); SetBitmapLabel( m_bitmap ); - -#if 0 - if ( HasFlag(wxCLRP_SHOW_LABEL) ) - SetLabel(m_colour.GetAsString(wxC2S_HTML_SYNTAX)); -#endif } wxSize wxGenericColourButton::DoGetBestSize() const { wxSize sz(wxBitmapButton::DoGetBestSize()); +#ifdef __WXMAC__ sz.y += 6; +#else + sz.y += 2; +#endif sz.x += 30; if ( HasFlag(wxCLRP_SHOW_LABEL) ) return sz;