From 33ed59075b5ac3ac24e42bda1dc6e0c5887f91ef Mon Sep 17 00:00:00 2001 From: lazarus Date: Sat, 9 Feb 2002 01:45:14 +0000 Subject: [PATCH] Bug fix for Mattias. Fixed spinedit so you can now get the value and set the value. Shane git-svn-id: trunk@687 - --- lcl/include/spinedit.inc | 25 +++++++++------- lcl/interfaces/gtk/gtkobject.inc | 18 ++++++++++++ lcl/spin.pp | 50 ++++++++++++++++---------------- 3 files changed, 58 insertions(+), 35 deletions(-) diff --git a/lcl/include/spinedit.inc b/lcl/include/spinedit.inc index fce29be893..e8f74b222e 100644 --- a/lcl/include/spinedit.inc +++ b/lcl/include/spinedit.inc @@ -1,30 +1,34 @@ // included by spin.pp + + +{-----------------------------------------------------------------------------} +procedure TSpinEdit.UpdateControl; +begin + CNSendMessage(LM_SetProperties,self,nil); +end; + {-----------------------------------------------------------------------------} procedure TSpinEdit.SetClimbRate(Num : Single); begin fClimbRate := Num; -// ****************************** -// the following line has been commented out so that gtk dependency can be -// removed from all files. The following function needs to be moved. MAH -// -// PgtkSpinButton(fComponent)^.Climb_rate := fCLimbRate; + UpdateControl; end; {-----------------------------------------------------------------------------} Procedure TSpinEdit.SetValue(num : Single); begin FValue := Num; -// ****************************** -// the following line has been commented out so that gtk dependency can be -// removed from all files. The following function needs to be moved. MAH -// -// gtk_spin_button_set_value(PgtkSpinButton(fComponent),FValue); + UpdateControl; end; {-----------------------------------------------------------------------------} Function TSpinEdit.GetValue : Single; +Var + Temp : Real; begin + CNSendMessage(LM_GETVALUE,Self,@Temp); + FValue := Temp; getvalue := fValue; end; @@ -32,6 +36,7 @@ end; procedure TSpinEdit.SetDecimals(Num : Integer); begin fDecimals := Num; + UpdateControl; end; {-----------------------------------------------------------------------------} diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index c3b627466f..1a121cd07c 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -2975,6 +2975,12 @@ begin end; + + csSpinEdit : Begin + Single(Data^) := gtk_spin_button_get_value_As_Float(PgtkSpinButton(Handle)); + + end; + else Assert (true, Format ('WARNING:[TgtkObject.GetValue] failed for %s', [Sender.ClassName])); end; @@ -3324,6 +3330,13 @@ begin then TWinControl(sender).Handle := THandle(gtk_image_new(Image,nil)) else gtk_image_set(PgtkImage(handle),Image,nil); end; + csSpinEdit: + Begin + gtk_spin_button_set_digits(PgtkSpinButton(Widget),TSpinEdit(Sender).Decimal_Places); + gtk_spin_button_set_value(PgtkSpinButton(Widget),TSpinEdit(Sender).Value); + + End; + else Assert (true, Format ('WARNING:[TgtkObject.SetProperties] failed for %s', [Sender.ClassName])); end; @@ -3791,6 +3804,11 @@ end; { ============================================================================= $Log$ + Revision 1.109 2002/03/14 20:28:49 lazarus + Bug fix for Mattias. + Fixed spinedit so you can now get the value and set the value. + Shane + Revision 1.108 2002/03/13 22:48:16 lazarus Constraints implementation (first cut) and sizig - moving system rework to better match Delphi/Kylix way of doing things (the existing implementation diff --git a/lcl/spin.pp b/lcl/spin.pp index 15aa368e7b..bf1e2cc50f 100644 --- a/lcl/spin.pp +++ b/lcl/spin.pp @@ -25,35 +25,35 @@ unit spin; interface -uses classes,controls,sysutils, stdCtrls,vclGlobals; +uses classes,controls,sysutils, stdCtrls,vclGlobals,LMessages; type - TSpinEdit = class(TWinControl) - private - fdecimals : Integer; - fValue : Single; - fClimbRate : Single; + TSpinEdit = class(TWinControl) + private + fdecimals : Integer; + fValue : Single; + fClimbRate : Single; + Procedure UpdateControl; protected - procedure SetDecimals(num : Integer); - Function GetValue : Single; - procedure SetValue(Num : Single); - procedure SetClimbRate(num : Single); - public - - constructor Create(AOwner : TComponent); override; - destructor Destroy; override; - published - property Align; - property Decimal_Places : Integer read fDecimals write SetDecimals; - property Enabled; - property Value : Single read GetValue write SetValue; - property Climb_Rate : Single read fClimbRate write SetClimbRate; - property Visible; - property OnEnter; - property OnExit; - property PopupMenu; - property ShowHint; + procedure SetDecimals(num : Integer); + Function GetValue : Single; + procedure SetValue(Num : Single); + procedure SetClimbRate(num : Single); + public + constructor Create(AOwner : TComponent); override; + destructor Destroy; override; + published + property Align; + property Decimal_Places : Integer read fDecimals write SetDecimals; + property Enabled; + property Value : Single read GetValue write SetValue; + property Climb_Rate : Single read fClimbRate write SetClimbRate; + property Visible; + property OnEnter; + property OnExit; + property PopupMenu; + property ShowHint; end; Implementation