X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/20123d495814b8b8543bf43fbd63aa7ec21e5d78..8bffcd08c26ab977d908b119a9a41a6ce9887b64:/include/wx/gtk/spinctrl.h diff --git a/include/wx/gtk/spinctrl.h b/include/wx/gtk/spinctrl.h index c784b1d05a..15d663785c 100644 --- a/include/wx/gtk/spinctrl.h +++ b/include/wx/gtk/spinctrl.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: spinctrl.h +// Name: wx/gtk/spinctrl.h // Purpose: wxSpinCtrl class // Author: Robert Roebling // Modified by: @@ -8,84 +8,180 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __GTKSPINCTRLH__ -#define __GTKSPINCTRLH__ +#ifndef _WX_GTK_SPINCTRL_H_ +#define _WX_GTK_SPINCTRL_H_ -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma interface -#endif +//----------------------------------------------------------------------------- +// wxSpinCtrlGTKBase - Base class for GTK versions of the wxSpinCtrl[Double] +// +// This class manages a double valued GTK spinctrl through the DoGet/SetXXX +// functions that are made public as Get/SetXXX functions for int or double +// for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid +// function ambiguity. +//----------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxSpinCtrlGTKBase : public wxSpinCtrlBase +{ +public: + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + long style, + double min, double max, double initial, + double inc, + const wxString& name); + + // wxSpinCtrl(Double) methods call DoXXX functions of the same name + + // accessors + // T GetValue() const + // T GetMin() const + // T GetMax() const + // T GetIncrement() const + virtual bool GetSnapToTicks() const; + + // operations + virtual void SetValue(const wxString& value); + // void SetValue(T val) + // void SetRange(T minVal, T maxVal) + // void SetIncrement(T inc) + void SetSnapToTicks( bool snap_to_ticks ); + + // Select text in the textctrl + void SetSelection(long from, long to); + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + + // implementation + void OnChar( wxKeyEvent &event ); -#include "wx/defs.h" +protected: + double DoGetValue() const; + double DoGetMin() const; + double DoGetMax() const; + double DoGetIncrement() const; + + void DoSetValue(double val); + void DoSetValue(const wxString& strValue); + void DoSetRange(double min_val, double max_val); + void DoSetIncrement(double inc); -#if wxUSE_SPINCTRL + void GtkDisableEvents() const; + void GtkEnableEvents() const; + + virtual wxSize DoGetBestSize() const; + virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; -#include "wx/control.h" + // Widgets that use the style->base colour for the BG colour should + // override this and return true. + virtual bool UseGTKStyleBase() const { return true; } + + DECLARE_DYNAMIC_CLASS(wxSpinCtrlGTKBase) + DECLARE_EVENT_TABLE() +}; //----------------------------------------------------------------------------- -// wxSpinCtrl +// wxSpinCtrl - An integer valued spin control //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxSpinCtrl : public wxControl +class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGTKBase { public: wxSpinCtrl() {} wxSpinCtrl(wxWindow *parent, - wxWindowID id = -1, + wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, - const wxString& name = _T("wxSpinCtrl")) + const wxString& name = wxS("wxSpinCtrl")) { Create(parent, id, value, pos, size, style, min, max, initial, name); } bool Create(wxWindow *parent, - wxWindowID id = -1, + wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, int min = 0, int max = 100, int initial = 0, - const wxString& name = _T("wxSpinCtrl")); + const wxString& name = wxS("wxSpinCtrl")) + { + return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, + style, min, max, initial, 1, name); + } - void SetValue(const wxString& text); - void SetSelection(long from, long to); + // accessors + int GetValue() const { return int(DoGetValue()); } + int GetMin() const { return int(DoGetMin()); } + int GetMax() const { return int(DoGetMax()); } + int GetIncrement() const { return int(DoGetIncrement()); } - virtual int GetValue() const; - virtual void SetValue( int value ); - virtual void SetRange( int minVal, int maxVal ); - virtual int GetMin() const; - virtual int GetMax() const; + // operations + void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc + void SetValue( int value ) { DoSetValue(value); } + void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); } + void SetIncrement(int inc) { DoSetIncrement(inc); } - static wxVisualAttributes - GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); - - // implementation - void OnChar( wxKeyEvent &event ); - - bool IsOwnGtkWindow( GdkWindow *window ); - void GtkDisableEvents(); - void GtkEnableEvents(); + DECLARE_DYNAMIC_CLASS(wxSpinCtrl) +}; - GtkAdjustment *m_adjust; - float m_oldPos; +//----------------------------------------------------------------------------- +// wxSpinCtrlDouble - a double valued spin control +//----------------------------------------------------------------------------- -protected: - virtual wxSize DoGetBestSize() const; +class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGTKBase +{ +public: + wxSpinCtrlDouble() {} + wxSpinCtrlDouble(wxWindow *parent, + wxWindowID id = wxID_ANY, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + double min = 0, double max = 100, double initial = 0, + double inc = 1, + const wxString& name = wxS("wxSpinCtrlDouble")) + { + Create(parent, id, value, pos, size, style, + min, max, initial, inc, name); + } - // Widgets that use the style->base colour for the BG colour should - // override this and return true. - virtual bool UseGTKStyleBase() const { return true; } + bool Create(wxWindow *parent, + wxWindowID id = wxID_ANY, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, + double min = 0, double max = 100, double initial = 0, + double inc = 1, + const wxString& name = wxS("wxSpinCtrlDouble")) + { + return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, + style, min, max, initial, inc, name); + } -private: - DECLARE_DYNAMIC_CLASS(wxSpinCtrl) - DECLARE_EVENT_TABLE() + // accessors + double GetValue() const { return DoGetValue(); } + double GetMin() const { return DoGetMin(); } + double GetMax() const { return DoGetMax(); } + double GetIncrement() const { return DoGetIncrement(); } + unsigned GetDigits() const; + + // operations + void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc + void SetValue(double value) { DoSetValue(value); } + void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); } + void SetIncrement(double inc) { DoSetIncrement(inc); } + void SetDigits(unsigned digits); + + DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble) }; -#endif - // wxUSE_SPINCTRL - -#endif - // __GTKSPINCTRLH__ +#endif // _WX_GTK_SPINCTRL_H_