X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/415a0ff16d5d50015e3d43c1c6f32f48f995cbab..c13815810e8ff427614ca82fe0dfd4b1e773f0f3:/src/univ/checkbox.cpp diff --git a/src/univ/checkbox.cpp b/src/univ/checkbox.cpp index fa84b05a95..2c070024f6 100644 --- a/src/univ/checkbox.cpp +++ b/src/univ/checkbox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: univ/checkbox.cpp +// Name: src/univ/checkbox.cpp // Purpose: wxCheckBox implementation // Author: Vadim Zeitlin // Modified by: @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "univcheckbox.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ @@ -29,9 +25,10 @@ #if wxUSE_CHECKBOX +#include "wx/checkbox.h" + #ifndef WX_PRECOMP #include "wx/dcclient.h" - #include "wx/checkbox.h" #include "wx/validate.h" #include "wx/button.h" // for wxACTION_BUTTON_XXX @@ -42,12 +39,26 @@ #include "wx/univ/inphand.h" #include "wx/univ/colschem.h" +// ---------------------------------------------------------------------------- +// wxStdCheckboxInputHandler: handles the mouse events for the check and radio +// boxes (handling the keyboard input is simple, but its handling differs a +// lot between GTK and MSW, so a new class should be derived for this) +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxStdCheckboxInputHandler : public wxStdInputHandler +{ +public: + wxStdCheckboxInputHandler(wxInputHandler *inphand); + + // we have to override this one as wxStdButtonInputHandler version works + // only with the buttons + virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); +}; + // ============================================================================ // implementation // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) - // ---------------------------------------------------------------------------- // wxCheckBox // ---------------------------------------------------------------------------- @@ -67,11 +78,12 @@ bool wxCheckBox::Create(wxWindow *parent, const wxValidator& validator, const wxString &name) { + WXValidateStyle( &style ); if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) return false; SetLabel(label); - SetBestSize(size); + SetInitialSize(size); CreateInputHandler(wxINP_HANDLER_CHECKBOX); @@ -104,7 +116,7 @@ void wxCheckBox::OnCheck() wxBitmap wxCheckBox::GetBitmap(State state, Status status) const { wxBitmap bmp = m_bitmaps[state][status]; - if ( !bmp.Ok() ) + if ( !bmp.IsOk() ) bmp = m_bitmaps[State_Normal][status]; return bmp; @@ -141,8 +153,9 @@ void wxCheckBox::DoDraw(wxControlRenderer *renderer) switch ( Get3StateValue() ) { - case wxCHK_CHECKED: flags |= wxCONTROL_CHECKED; - case wxCHK_UNDETERMINED: flags |= wxCONTROL_UNDETERMINED; + case wxCHK_CHECKED: flags |= wxCONTROL_CHECKED; break; + case wxCHK_UNDETERMINED: flags |= wxCONTROL_UNDETERMINED; break; + default: /* do nothing */ break; } wxBitmap bitmap(GetBitmap(GetState(flags), m_status)); @@ -165,7 +178,7 @@ void wxCheckBox::DoDraw(wxControlRenderer *renderer) wxSize wxCheckBox::GetBitmapSize() const { wxBitmap bmp = GetBitmap(State_Normal, Status_Checked); - return bmp.Ok() ? wxSize(bmp.GetWidth(), bmp.GetHeight()) + return bmp.IsOk() ? wxSize(bmp.GetWidth(), bmp.GetHeight()) : GetRenderer()->GetCheckBitmapSize(); } @@ -180,7 +193,9 @@ wxSize wxCheckBox::DoGetBestClientSize() const if ( height < sizeBmp.y ) height = sizeBmp.y; -#if wxUNIV_COMPATIBLE_MSW +#if defined(wxUNIV_COMPATIBLE_MSW) && wxUNIV_COMPATIBLE_MSW + // FIXME: flag nowhere defined so perhaps should be removed? + // this looks better but is different from what wxMSW does height += GetCharHeight()/2; #endif // wxUNIV_COMPATIBLE_MSW @@ -201,7 +216,7 @@ void wxCheckBox::DoSet3StateValue(wxCheckBoxState state) { case wxCHK_UNCHECKED: status = Status_Unchecked; break; case wxCHK_CHECKED: status = Status_Checked; break; - default: wxFAIL_MSG(_T("Unknown checkbox state")); + default: wxFAIL_MSG(wxT("Unknown checkbox state")); case wxCHK_UNDETERMINED: status = Status_3rdState; break; } if ( status != m_status ) @@ -224,6 +239,7 @@ wxCheckBoxState wxCheckBox::DoGet3StateValue() const { case Status_Checked: return wxCHK_CHECKED; case Status_Unchecked: return wxCHK_UNCHECKED; + default: /* go further */ break; } return wxCHK_UNDETERMINED; } @@ -322,12 +338,20 @@ bool wxCheckBox::PerformAction(const wxControlAction& action, return true; } +/* static */ +wxInputHandler *wxCheckBox::CreateStdInputHandler(wxInputHandler *handlerDef) +{ + static wxStdCheckboxInputHandler s_handler(handlerDef); + + return &s_handler; +} + // ---------------------------------------------------------------------------- // wxStdCheckboxInputHandler // ---------------------------------------------------------------------------- -wxStdCheckboxInputHandler::wxStdCheckboxInputHandler(wxInputHandler *inphand) - : wxStdButtonInputHandler(inphand) +wxStdCheckboxInputHandler::wxStdCheckboxInputHandler(wxInputHandler *def) + : wxStdInputHandler(wxButton::GetStdInputHandler(def)) { }