mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-16 11:43:40 +02:00
134 lines
4.7 KiB
ObjectPascal
134 lines
4.7 KiB
ObjectPascal
{
|
|
*****************************************************************************
|
|
* QtWSSpin.pp *
|
|
* ----------- *
|
|
* *
|
|
* *
|
|
*****************************************************************************
|
|
|
|
*****************************************************************************
|
|
This file is part of the Lazarus Component Library (LCL)
|
|
|
|
See the file COPYING.modifiedLGPL.txt, included in this distribution,
|
|
for details about the license.
|
|
*****************************************************************************
|
|
}
|
|
unit customdrawnwsspin;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
{$I customdrawndefines.inc}
|
|
|
|
uses
|
|
// RTL
|
|
Classes,
|
|
// LCL
|
|
Spin, SysUtils, Controls, LCLType, LCLProc, LCLIntf, Forms,
|
|
customdrawncontrols,
|
|
// Widgetset
|
|
WSProc, WSSpin, WSLCLClasses, CustomDrawnWsControls, customdrawnproc,
|
|
customdrawnprivate;
|
|
|
|
type
|
|
|
|
{ TCDWSCustomFloatSpinEdit }
|
|
|
|
TCDWSCustomFloatSpinEdit = class(TWSCustomFloatSpinEdit)
|
|
public
|
|
class procedure InjectCDControl(const AWinControl: TWinControl; var ACDControlField: TCDControl);
|
|
published
|
|
class function CreateHandle(const AWinControl: TWinControl;
|
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
|
class procedure ShowHide(const AWinControl: TWinControl); override;
|
|
|
|
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
|
|
|
|
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override;
|
|
|
|
(*TODO: seperation into properties instead of bulk update
|
|
class procedure SetIncrement(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewIncrement: Double); virtual;
|
|
class procedure SetMinValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual;
|
|
class procedure SetMaxValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewValue: Double); virtual;
|
|
class procedure SetValueEmpty(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewEmpty: boolean); virtual;
|
|
*)
|
|
end;
|
|
|
|
implementation
|
|
|
|
class procedure TCDWSCustomFloatSpinEdit.InjectCDControl(
|
|
const AWinControl: TWinControl; var ACDControlField: TCDControl);
|
|
begin
|
|
TCDIntfSpinEdit(ACDControlField).LCLControl := TCustomFloatSpinEdit(AWinControl);
|
|
ACDControlField.Caption := AWinControl.Caption;
|
|
ACDControlField.Parent := AWinControl;
|
|
ACDControlField.Align := alClient;
|
|
end;
|
|
|
|
{------------------------------------------------------------------------------
|
|
Method: TCDWSCustomFloatSpinEdit.CreateHandle
|
|
Params: None
|
|
Returns: Nothing
|
|
------------------------------------------------------------------------------}
|
|
class function TCDWSCustomFloatSpinEdit.CreateHandle(const AWinControl: TWinControl;
|
|
const AParams: TCreateParams): TLCLIntfHandle;
|
|
var
|
|
lCDWinControl: TCDWinControl;
|
|
begin
|
|
Result := TCDWSWinControl.CreateHandle(AWinControl, AParams);
|
|
lCDWinControl := TCDWinControl(Result);
|
|
lCDWinControl.CDControl := TCDIntfSpinEdit.Create(AWinControl);
|
|
end;
|
|
|
|
class procedure TCDWSCustomFloatSpinEdit.DestroyHandle(
|
|
const AWinControl: TWinControl);
|
|
var
|
|
lCDWinControl: TCDWinControl;
|
|
begin
|
|
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
|
lCDWinControl.CDControl.Free;
|
|
lCDWinControl.Free;
|
|
end;
|
|
|
|
class procedure TCDWSCustomFloatSpinEdit.ShowHide(const AWinControl: TWinControl);
|
|
var
|
|
lCDWinControl: TCDWinControl;
|
|
begin
|
|
lCDWinControl := TCDWinControl(AWinControl.Handle);
|
|
|
|
TCDWSWinControl.ShowHide(AWinControl);
|
|
|
|
if not lCDWinControl.CDControlInjected then
|
|
begin
|
|
InjectCDControl(AWinControl, lCDWinControl.CDControl);
|
|
lCDWinControl.CDControlInjected := True;
|
|
end;
|
|
end;
|
|
|
|
class function TCDWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double;
|
|
var
|
|
lCDWinControl: TCDWinControl;
|
|
begin
|
|
lCDWinControl := TCDWinControl(ACustomFloatSpinEdit.Handle);
|
|
Result := TCDIntfSpinEdit(lCDWinControl.CDControl).Value;
|
|
end;
|
|
|
|
class procedure TCDWSCustomFloatSpinEdit.UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit);
|
|
{var
|
|
CurrentSpinWidget: TQtAbstractSpinBox;}
|
|
begin
|
|
{ if not WSCheckHandleAllocated(ACustomFloatSpinEdit, 'UpdateControl') then
|
|
Exit;
|
|
|
|
CurrentSpinWidget := TQtAbstractSpinBox(ACustomFloatSpinEdit.Handle);
|
|
if ((ACustomFloatSpinEdit.DecimalPlaces > 0) and (CurrentSpinWidget is TQtSpinBox)) or
|
|
((ACustomFloatSpinEdit.DecimalPlaces = 0) and (CurrentSpinWidget is TQtFloatSpinBox)) then
|
|
RecreateWnd(ACustomFloatSpinEdit)
|
|
else
|
|
InternalUpdateControl(CurrentSpinWidget, ACustomFloatSpinEdit);}
|
|
end;
|
|
|
|
end.
|