From 18e046a7c549687f42e37c4db6e80ff9df17f955 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Thu, 11 Dec 2008 16:14:55 +0000 Subject: [PATCH] SpinCtrl editor's 'value change by mouse motion' feature is made optional, enabled via 'MotionSpin' attribute. Also, for now only enabled on MSW (mouse capture etc. inconsistent on native wxGTK spinbutton?). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57252 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/propgrid/property.h | 5 +++++ samples/propgrid/propgrid.cpp | 1 + src/propgrid/advprops.cpp | 34 +++++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index fbd27ec033..9369d8cb96 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -128,6 +128,11 @@ */ #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap") +/** SpinCtrl editor, bool. If @true, value can also by changed by moving + mouse when left mouse button is being pressed. +*/ +#define wxPG_ATTR_SPINCTRL_MOTIONSPIN wxS("MotionSpin") + /** wxMultiChoiceProperty, int. If 0, no user strings allowed. If 1, user strings appear before list strings. If 2, user strings appear after list string. */ diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 46baf1c55c..8cc2d539da 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -1371,6 +1371,7 @@ void FormMain::PopulateWithExamples () pg->SetPropertyAttribute( wxT("SpinCtrl"), wxPG_ATTR_MIN, (long)-10 ); // Use constants instead of string pg->SetPropertyAttribute( wxT("SpinCtrl"), wxPG_ATTR_MAX, (long)16384 ); // for reduced binary size. pg->SetPropertyAttribute( wxT("SpinCtrl"), wxT("Step"), (long)2 ); + pg->SetPropertyAttribute( wxT("SpinCtrl"), wxT("MotionSpin"), true ); //pg->SetPropertyAttribute( wxT("SpinCtrl"), wxT("Wrap"), true ); pg->SetPropertyHelpString( wxT("SpinCtrl"), diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index 5bd56c3cd4..5c5a2e99fa 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -108,6 +108,14 @@ bool operator == (const wxArrayInt& array1, const wxArrayInt& array2) #if wxUSE_SPINBTN +#ifdef __WXMSW__ + #define IS_MOTION_SPIN_SUPPORTED 1 +#else + #define IS_MOTION_SPIN_SUPPORTED 0 +#endif + +#if IS_MOTION_SPIN_SUPPORTED + // // This class implements ability to rapidly change "spin" value // by moving mouse when one of the spin buttons is depressed. @@ -222,6 +230,8 @@ private: } }; +#endif // IS_MOTION_SPIN_SUPPORTED + WX_PG_IMPLEMENT_INTERNAL_EDITOR_CLASS(SpinCtrl, wxPGSpinCtrlEditor, @@ -245,7 +255,16 @@ wxPGWindowList wxPGSpinCtrlEditor::CreateControls( wxPropertyGrid* propgrid, wxP wxSpinButton* wnd2; - wnd2 = new wxPGSpinButton(); +#if IS_MOTION_SPIN_SUPPORTED + if ( property->GetAttributeAsLong(wxT("MotionSpin"), 0) ) + { + wnd2 = new wxPGSpinButton(); + } + else +#endif + { + wnd2 = new wxSpinButton(); + } #ifdef __WXMSW__ wnd2->Hide(); @@ -296,11 +315,16 @@ bool wxPGSpinCtrlEditor::OnEvent( wxPropertyGrid* propgrid, wxPGProperty* proper if ( evtType == wxEVT_SCROLL_LINEUP || evtType == wxEVT_SCROLL_LINEDOWN ) { - wxPGSpinButton* spinButton = - (wxPGSpinButton*) propgrid->GetEditorControlSecondary(); + #if IS_MOTION_SPIN_SUPPORTED + if ( property->GetAttributeAsLong(wxT("MotionSpin"), 0) ) + { + wxPGSpinButton* spinButton = + (wxPGSpinButton*) propgrid->GetEditorControlSecondary(); - if ( spinButton ) - spins = spinButton->GetSpins(); + if ( spinButton ) + spins = spinButton->GetSpins(); + } + #endif wxString s; // Can't use wnd since it might be clipper window -- 2.45.2