X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4a11cca24d9781e45bfffc402e1b26d1e69f169f..09ff2ee1632c8c484134da2a31d0d5c4d0a4bef4:/src/gtk1/spinctrl.cpp diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index 44d10c8a73..10aa930138 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -22,9 +22,7 @@ #include "wx/utils.h" #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED - -#include - +#include "wx/math.h" #include "wx/gtk/private.h" //----------------------------------------------------------------------------- @@ -126,24 +124,10 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_parent->DoAddChild( this ); - PostCreation(); - InheritAttributes(); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if (new_size.y > size_best.y) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); + PostCreation(size); SetValue( value ); - Show( TRUE ); - return TRUE; } @@ -230,7 +214,7 @@ void wxSpinCtrl::SetValue( int value ) void wxSpinCtrl::SetSelection(long from, long to) { - // translate from wxWindows conventions to GTK+ ones: (-1, -1) means the + // translate from wxWidgets conventions to GTK+ ones: (-1, -1) means the // entire range if ( from == -1 && to == -1 ) { @@ -290,7 +274,7 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event ) } } - if ((event.GetKeyCode() == WXK_RETURN)) + if ((event.GetKeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) { wxCommandEvent evt( wxEVT_COMMAND_TEXT_ENTER, m_windowId ); evt.SetEventObject(this); @@ -312,16 +296,21 @@ bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window ) return FALSE; } -void wxSpinCtrl::ApplyWidgetStyle() +wxSize wxSpinCtrl::DoGetBestSize() const { - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); + wxSize ret( wxControl::DoGetBestSize() ); + wxSize best(95, ret.y); + CacheBestSize(best); + return best; } -wxSize wxSpinCtrl::DoGetBestSize() const +// static +wxVisualAttributes +wxSpinCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { - wxSize ret( wxControl::DoGetBestSize() ); - return wxSize(95, ret.y); + // TODO: overload to accept functions like gtk_spin_button_new? + // Until then use a similar type + return GetDefaultAttributesFromGTKWidget(gtk_entry_new, true); } #endif