GTK2 intf: Fixed spin edit bug #0009253 and #0009205 from Valdas Janknas

git-svn-id: trunk@11587 -
This commit is contained in:
tombo 2007-07-21 12:15:17 +00:00
parent 04f56784d8
commit 9a4689733f
4 changed files with 22 additions and 15 deletions

View File

@ -47,10 +47,15 @@ var
begin
PrevValue := FValue;
FValueChanged := True;
if Value <> PrevValue then FValueEmpty := False;
inherited;
DebugLn('TCustomFloatSpinEdit.TextChanged Text: ' + Text + ' Value: ' + DbgS(Value));
if Value <> PrevValue then
begin
FValueEmpty := False;
inherited;
end;
end;
procedure TCustomFloatSpinEdit.SetMaxValue(const AValue: Single);
@ -144,13 +149,6 @@ begin
SetInitialBounds(0, 0, 50, 23);
end;
procedure TCustomFloatSpinEdit.EditingDone;
begin
Text := ValueToStr(FValue);
inherited EditingDone;
end;
function TCustomFloatSpinEdit.GetLimitedValue(const AValue: Single): Single;
begin
Result := AValue;

View File

@ -3380,6 +3380,11 @@ begin
ConnectSenderSignal(gCore, 'changed', @gtkchanged_editbox)
else if ALCLObject is TCustomCheckbox then
ConnectSenderSignal(gObject, 'toggled', @gtktoggledCB)
{$IFDEF GTK2}
// in gtk2 callback signal of SpinEdit is 'value-changed' (in gtk1- 'changed')
else if ALCLObject is TCustomFloatSpinEdit then
ConnectSenderSignal(gObject, 'value-changed', @gtkchanged_editbox)
{$ENDIF}
else
ConnectSenderSignal(gObject, 'changed', @gtkchanged_editbox);
end;

View File

@ -98,8 +98,13 @@ end;
class function TGtkWSCustomFloatSpinEdit.GetValue(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
begin
Result:=gtk_spin_button_get_value_as_float(
PGtkSpinButton(ACustomFloatSpinEdit.Handle));
{$IFDEF GTK2}
// developer.gnome.org/doc/API/2.2/gtk/GtkSpinButton.html:
// "function gtk_spin_button_get_value_as_float is deprecated, use gtk_spin_button_get_value() instead"
Result:=Single(gtk_spin_button_get_value(PGtkSpinButton(ACustomFloatSpinEdit.Handle)));
{$ELSE}
Result:=gtk_spin_button_get_value_as_float(PGtkSpinButton(ACustomFloatSpinEdit.Handle));
{$ENDIF}
end;
class procedure TGtkWSCustomFloatSpinEdit.SetSelStart(const ACustomEdit: TCustomEdit;

View File

@ -30,7 +30,7 @@ unit Spin;
interface
uses
Classes, Controls, SysUtils, LCLType, LMessages, ClipBrd, StdCtrls;
Classes, Controls, SysUtils, LCLType, LCLProc, LMessages, ClipBrd, StdCtrls;
type
{ TCustomFloatSpinEdit }
@ -62,7 +62,6 @@ type
procedure Loaded; override;
public
constructor Create(TheOwner: TComponent); override;
procedure EditingDone; override;
function GetLimitedValue(const AValue: Single): Single;
function ValueToStr(const AValue: Single): String;
function StrToValue(const S: String): Single;