X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f68586e51b20dccee3fd5645aeaca7cc8ff298c2..cb2713bfa8fc9b8864eb2c0cebde8df2a7654444:/src/msw/checkbox.cpp diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp index 8b7ba211b9..3e10a30ec2 100644 --- a/src/msw/checkbox.cpp +++ b/src/msw/checkbox.cpp @@ -31,6 +31,8 @@ #ifndef WX_PRECOMP #include "wx/checkbox.h" #include "wx/brush.h" + #include "wx/dcscreen.h" + #include "wx/settings.h" #endif #include "wx/msw/private.h" @@ -39,10 +41,8 @@ // macros // ---------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) - IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) -#endif +IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) // ============================================================================ // implementation @@ -62,14 +62,18 @@ bool wxCheckBox::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) } // Single check box item -bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, - const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, - const wxString& name) +bool wxCheckBox::Create(wxWindow *parent, + wxWindowID id, + const wxString& label, + const wxPoint& pos, + const wxSize& size, long style, + const wxValidator& validator, + const wxString& name) { SetName(name); +#if wxUSE_VALIDATORS SetValidator(validator); +#endif // wxUSE_VALIDATORS if (parent) parent->AddChild(this); SetBackgroundColour(parent->GetBackgroundColour()) ; @@ -77,9 +81,14 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_windowStyle = style; + // VZ: disabling this ugliness which completely breaks checkboxes in wxGrid + // whoever did it, please tell me where and how does the checkbox fail + // to appear +#if 0 wxString Label = label; if (Label == wxT("")) Label = wxT(" "); // Apparently needed or checkbox won't show +#endif // 0 if ( id == -1 ) m_windowId = NewControlId(); @@ -109,7 +118,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, msStyle |= WS_BORDER; */ - m_hWnd = (WXHWND)CreateWindowEx(exStyle, wxT("BUTTON"), Label, + m_hWnd = (WXHWND)CreateWindowEx(exStyle, wxT("BUTTON"), label, msStyle, 0, 0, 0, 0, (HWND)parent->GetHWND(), (HMENU)m_windowId, @@ -135,27 +144,36 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, void wxCheckBox::SetLabel(const wxString& label) { - SetWindowText(GetHwnd(), label); + SetWindowText(GetHwnd(), label); } wxSize wxCheckBox::DoGetBestSize() const { - int wCheckbox, hCheckbox; + static int s_checkSize = 0; + + if ( !s_checkSize ) + { + wxScreenDC dc; + dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + + s_checkSize = (3*dc.GetCharHeight())/2; + } wxString str = wxGetWindowText(GetHWND()); + int wCheckbox, hCheckbox; if ( !str.IsEmpty() ) { GetTextExtent(str, &wCheckbox, &hCheckbox); - wCheckbox += RADIO_SIZE; + wCheckbox += s_checkSize + GetCharWidth(); - if ( hCheckbox < RADIO_SIZE ) - hCheckbox = RADIO_SIZE; + if ( hCheckbox < s_checkSize ) + hCheckbox = s_checkSize; } else { - wCheckbox = RADIO_SIZE; - hCheckbox = RADIO_SIZE; + wCheckbox = s_checkSize; + hCheckbox = s_checkSize; } return wxSize(wCheckbox, hCheckbox); @@ -175,36 +193,8 @@ bool wxCheckBox::GetValue() const #ifdef __WIN32__ return (SendMessage(GetHwnd(), BM_GETCHECK, 0, 0) == BST_CHECKED); #else - return ((0x003 & SendMessage(GetHwnd(), BM_GETCHECK, 0, 0)) == 0x003); -#endif -} - -WXHBRUSH wxCheckBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, - WXUINT message, WXWPARAM wParam, WXLPARAM lParam) -{ -#if wxUSE_CTL3D - if ( m_useCtl3D ) - { - HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); - - return (WXHBRUSH) hbrush; - } + return ((0x001 & SendMessage(GetHwnd(), BM_GETCHECK, 0, 0)) == 0x001); #endif - - if (GetParent()->GetTransparentBackground()) - SetBkMode((HDC) pDC, TRANSPARENT); - else - SetBkMode((HDC) pDC, OPAQUE); - - ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); - ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue())); - - wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID); - - // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush - // has a zero usage count. -// backgroundBrush->RealizeResource(); - return (WXHBRUSH) backgroundBrush->GetResourceHandle(); } void wxCheckBox::Command (wxCommandEvent & event) @@ -224,7 +214,9 @@ bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *l const wxString& name) { SetName(name); +#if wxUSE_VALIDATORS SetValidator(validator); +#endif // wxUSE_VALIDATORS if (parent) parent->AddChild(this); SetBackgroundColour(parent->GetBackgroundColour()) ;