mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 14:19:13 +02:00
Merged revision(s) 60965 #78bc4df384,60966 #3d2a723a44,60969 #73e6567b0f from trunk
git-svn-id: branches/fixes_2_0@61641 -
This commit is contained in:
parent
5e811e756f
commit
e573983533
@ -1888,6 +1888,7 @@ type
|
|||||||
FPosition: SmallInt;
|
FPosition: SmallInt;
|
||||||
FThousands: Boolean;
|
FThousands: Boolean;
|
||||||
FWrap: Boolean;
|
FWrap: Boolean;
|
||||||
|
FUseWS: Boolean;
|
||||||
function GetPosition: SmallInt;
|
function GetPosition: SmallInt;
|
||||||
procedure BTimerExec(Sender : TObject);
|
procedure BTimerExec(Sender : TObject);
|
||||||
function GetFlat: Boolean;
|
function GetFlat: Boolean;
|
||||||
@ -1908,6 +1909,8 @@ type
|
|||||||
procedure UpdateUpDownPositionText;
|
procedure UpdateUpDownPositionText;
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
|
procedure AdjustPos(incPos: Boolean);
|
||||||
|
procedure InitializeWnd; override;
|
||||||
procedure AssociateKeyDown(Sender: TObject; var Key: Word; ShiftState : TShiftState);
|
procedure AssociateKeyDown(Sender: TObject; var Key: Word; ShiftState : TShiftState);
|
||||||
procedure AssociateMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
|
procedure AssociateMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
|
||||||
MousePos: TPoint; var Handled: Boolean);
|
MousePos: TPoint; var Handled: Boolean);
|
||||||
|
@ -209,9 +209,13 @@ begin
|
|||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
ControlStyle := ControlStyle - [csDoubleClicks] +
|
ControlStyle := ControlStyle - [csDoubleClicks] +
|
||||||
[csClickEvents, csOpaque, csReplicatable, csNoFocus];
|
[csClickEvents, csOpaque, csReplicatable, csNoFocus];
|
||||||
|
FUseWS := IsWSComponentInheritsFrom(TCustomUpDown, TWSCustomUpDown);
|
||||||
FOrientation := udVertical;
|
FOrientation := udVertical;
|
||||||
FMinBtn := TUpDownButton.CreateWithParams(Self, btPrev);
|
|
||||||
FMaxBtn := TUpDownButton.CreateWithParams(Self, btNext);
|
if not FUseWS then begin
|
||||||
|
FMinBtn := TUpDownButton.CreateWithParams(Self, btPrev);
|
||||||
|
FMaxBtn := TUpDownButton.CreateWithParams(Self, btNext);
|
||||||
|
end;
|
||||||
with GetControlClassDefaultSize do
|
with GetControlClassDefaultSize do
|
||||||
SetInitialBounds(0, 0, CX, CY);
|
SetInitialBounds(0, 0, CX, CY);
|
||||||
FArrowKeys := True;
|
FArrowKeys := True;
|
||||||
@ -260,10 +264,24 @@ begin
|
|||||||
RegisterCustomUpDown;
|
RegisterCustomUpDown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomUpDown.InitializeWnd;
|
||||||
|
begin
|
||||||
|
inherited InitializeWnd;
|
||||||
|
if not FUseWS then Exit;
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetMaxPosition(Self, FMax);
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetPosition(Self, FPosition);
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetIncrement(Self, FIncrement);
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetWrap(Self, FWrap);
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetOrientation(Self, FOrientation);
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetUseArrowKeys(Self, FArrowKeys);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomUpDown.UpdateOrientation;
|
procedure TCustomUpDown.UpdateOrientation;
|
||||||
var
|
var
|
||||||
d, r: Integer;
|
d, r: Integer;
|
||||||
begin
|
begin
|
||||||
|
if FUseWS then Exit;
|
||||||
|
|
||||||
If FOrientation = udHorizontal then begin
|
If FOrientation = udHorizontal then begin
|
||||||
d:=ClientWidth div 2;
|
d:=ClientWidth div 2;
|
||||||
r:=ClientWidth mod 2;
|
r:=ClientWidth mod 2;
|
||||||
@ -362,6 +380,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomUpDown.AdjustPos(incPos: Boolean);
|
||||||
|
var
|
||||||
|
anewpos: Integer;
|
||||||
|
begin
|
||||||
|
if FUseWS then begin
|
||||||
|
if incPos then anewpos := Position + Increment
|
||||||
|
else anewpos := Position - Increment;
|
||||||
|
|
||||||
|
if (anewpos < Min) then anewpos := Min
|
||||||
|
else if (anewpos > Max) then anewpos := Max;
|
||||||
|
SetPosition(anewpos);
|
||||||
|
end else begin
|
||||||
|
if incPos then TCustomSpeedButton(FMaxBtn).Click
|
||||||
|
else TCustomSpeedButton(FMinBtn).Click;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomUpDown.AssociateKeyDown(Sender: TObject; var Key: Word;
|
procedure TCustomUpDown.AssociateKeyDown(Sender: TObject; var Key: Word;
|
||||||
ShiftState : TShiftState);
|
ShiftState : TShiftState);
|
||||||
var
|
var
|
||||||
@ -374,16 +410,28 @@ begin
|
|||||||
udVertical:
|
udVertical:
|
||||||
case Key of
|
case Key of
|
||||||
VK_Up:
|
VK_Up:
|
||||||
begin TCustomSpeedButton(FMaxBtn).Click; ConsumeKey := True; end;
|
begin
|
||||||
|
AdjustPos(True);
|
||||||
|
ConsumeKey := True;
|
||||||
|
end;
|
||||||
VK_Down:
|
VK_Down:
|
||||||
begin TCustomSpeedButton(FMinBtn).Click; ConsumeKey := True; end;
|
begin
|
||||||
|
AdjustPos(False);
|
||||||
|
ConsumeKey := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
udHorizontal:
|
udHorizontal:
|
||||||
case Key of
|
case Key of
|
||||||
VK_Left:
|
VK_Left:
|
||||||
begin TCustomSpeedButton(FMinBtn).Click; ConsumeKey := True; end;
|
begin
|
||||||
|
AdjustPos(False);
|
||||||
|
ConsumeKey := True;
|
||||||
|
end;
|
||||||
VK_Right:
|
VK_Right:
|
||||||
begin TCustomSpeedButton(FMaxBtn).Click; ConsumeKey := True; end;
|
begin
|
||||||
|
AdjustPos(True);
|
||||||
|
ConsumeKey := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -394,16 +442,17 @@ end;
|
|||||||
procedure TCustomUpDown.AssociateMouseWheel(Sender: TObject;
|
procedure TCustomUpDown.AssociateMouseWheel(Sender: TObject;
|
||||||
Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
|
Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
|
||||||
var Handled: Boolean);
|
var Handled: Boolean);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//debugln('TCustomUpDown.AssociateMouseWheel A: Handled = ',DbgS(Handled));
|
//debugln('TCustomUpDown.AssociateMouseWheel A: Handled = ',DbgS(Handled));
|
||||||
if (WheelDelta > 0) then
|
if (WheelDelta > 0) then
|
||||||
begin
|
begin
|
||||||
TCustomSpeedButton(FMaxBtn).Click;
|
AdjustPos(True);
|
||||||
Handled := True;
|
Handled := True;
|
||||||
end
|
end
|
||||||
else if (WheelDelta < 0) then
|
else if (WheelDelta < 0) then
|
||||||
begin
|
begin
|
||||||
TCustomSpeedButton(FMinBtn).Click;
|
AdjustPos(False);
|
||||||
Handled := True;
|
Handled := True;
|
||||||
end;
|
end;
|
||||||
//debugln('TCustomUpDown.AssociateMouseWheel End: Handled = ',DbgS(Handled));
|
//debugln('TCustomUpDown.AssociateMouseWheel End: Handled = ',DbgS(Handled));
|
||||||
@ -429,14 +478,14 @@ end;
|
|||||||
function TCustomUpDown.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
|
function TCustomUpDown.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := inherited DoMouseWheelDown(Shift, MousePos);
|
Result := inherited DoMouseWheelDown(Shift, MousePos);
|
||||||
if not Result then
|
if not Result and not FUseWS then
|
||||||
TCustomSpeedButton(FMinBtn).Click;
|
TCustomSpeedButton(FMinBtn).Click;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomUpDown.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
|
function TCustomUpDown.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := inherited DoMouseWheelUp(Shift, MousePos);
|
Result := inherited DoMouseWheelUp(Shift, MousePos);
|
||||||
if not Result then
|
if not Result and not FUseWS then
|
||||||
TCustomSpeedButton(FMaxBtn).Click;
|
TCustomSpeedButton(FMaxBtn).Click;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -444,7 +493,7 @@ function TCustomUpDown.DoMouseWheelLeft(Shift: TShiftState; MousePos: TPoint): B
|
|||||||
begin
|
begin
|
||||||
Result := inherited DoMouseWheelLeft(Shift, MousePos);
|
Result := inherited DoMouseWheelLeft(Shift, MousePos);
|
||||||
if not Result then
|
if not Result then
|
||||||
if Orientation=udHorizontal then
|
if (Orientation=udHorizontal) and not FUseWS then
|
||||||
TCustomSpeedButton(FMinBtn).Click;
|
TCustomSpeedButton(FMinBtn).Click;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -452,7 +501,7 @@ function TCustomUpDown.DoMouseWheelRight(Shift: TShiftState; MousePos: TPoint):
|
|||||||
begin
|
begin
|
||||||
Result := inherited DoMouseWheelRight(Shift, MousePos);
|
Result := inherited DoMouseWheelRight(Shift, MousePos);
|
||||||
if not Result then
|
if not Result then
|
||||||
if Orientation=udHorizontal then
|
if (Orientation=udHorizontal) and not FUseWS then
|
||||||
TCustomSpeedButton(FMaxBtn).Click;
|
TCustomSpeedButton(FMaxBtn).Click;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -529,7 +578,9 @@ end;
|
|||||||
|
|
||||||
function TCustomUpDown.GetFlat: Boolean;
|
function TCustomUpDown.GetFlat: Boolean;
|
||||||
begin
|
begin
|
||||||
if FMinBtn<>nil then
|
if FUseWS then
|
||||||
|
Result := false
|
||||||
|
else if FMinBtn<>nil then
|
||||||
Result := (FMinBtn as TSpeedButton).Flat
|
Result := (FMinBtn as TSpeedButton).Flat
|
||||||
else
|
else
|
||||||
Result := False;
|
Result := False;
|
||||||
@ -542,6 +593,8 @@ begin
|
|||||||
FMin := Value;
|
FMin := Value;
|
||||||
If FPosition < FMin then
|
If FPosition < FMin then
|
||||||
Position := FMin;
|
Position := FMin;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetMinPosition(Self, FMin);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -559,19 +612,26 @@ begin
|
|||||||
FMax := Value;
|
FMax := Value;
|
||||||
If FPosition > FMax then
|
If FPosition > FMax then
|
||||||
Position := FMax;
|
Position := FMax;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetMaxPosition(Self, FMax);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomUpDown.SetIncrement(Value: Integer);
|
procedure TCustomUpDown.SetIncrement(Value: Integer);
|
||||||
begin
|
begin
|
||||||
if Value <> FIncrement then
|
if Value <> FIncrement then begin
|
||||||
FIncrement := Value;
|
FIncrement := Value;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetIncrement(Self, FIncrement);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomUpDown.SetPosition(Value: SmallInt);
|
procedure TCustomUpDown.SetPosition(Value: SmallInt);
|
||||||
begin
|
begin
|
||||||
if FPosition = Value then exit;
|
if FPosition = Value then exit;
|
||||||
FPosition := Value;
|
FPosition := Value;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetPosition(Self, FPosition);
|
||||||
UpdateUpDownPositionText;
|
UpdateUpDownPositionText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -579,6 +639,9 @@ procedure TCustomUpDown.SetOrientation(Value: TUDOrientation);
|
|||||||
begin
|
begin
|
||||||
if FOrientation = Value then exit;
|
if FOrientation = Value then exit;
|
||||||
FOrientation := Value;
|
FOrientation := Value;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetOrientation(Self, FOrientation);
|
||||||
|
|
||||||
UpdateOrientation;
|
UpdateOrientation;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -591,8 +654,11 @@ end;
|
|||||||
|
|
||||||
procedure TCustomUpDown.SetArrowKeys(Value: Boolean);
|
procedure TCustomUpDown.SetArrowKeys(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if Value <> FArrowKeys then
|
if Value <> FArrowKeys then begin
|
||||||
FArrowKeys := Value;
|
FArrowKeys := Value;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetUseArrowKeys(Self, Value);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomUpDown.SetThousands(Value: Boolean);
|
procedure TCustomUpDown.SetThousands(Value: Boolean);
|
||||||
@ -603,6 +669,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomUpDown.SetFlat(Value: Boolean);
|
procedure TCustomUpDown.SetFlat(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
|
if FUseWS then Exit; // todo: not supported by WS yet
|
||||||
if Flat = Value then Exit;
|
if Flat = Value then Exit;
|
||||||
|
|
||||||
(FMinBtn as TSpeedButton).Flat := Value;
|
(FMinBtn as TSpeedButton).Flat := Value;
|
||||||
@ -613,6 +680,8 @@ procedure TCustomUpDown.SetWrap(Value: Boolean);
|
|||||||
begin
|
begin
|
||||||
if Value <> FWrap then
|
if Value <> FWrap then
|
||||||
FWrap := Value;
|
FWrap := Value;
|
||||||
|
if FUseWS then
|
||||||
|
TWSCustomUpDownClass(WidgetSetClass).SetWrap(Self, FWrap);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// included by comctrls.pp
|
// included by comctrls.pp
|
||||||
|
@ -195,7 +195,16 @@ type
|
|||||||
|
|
||||||
TWSCustomUpDown = class(TWSCustomControl)
|
TWSCustomUpDown = class(TWSCustomControl)
|
||||||
published
|
published
|
||||||
|
class procedure SetIncrement(const AUpDown: TCustomUpDown; AValue: Double); virtual;
|
||||||
|
class procedure SetMaxPosition(const AUpDown: TCustomUpDown; AValue: Double); virtual;
|
||||||
|
class procedure SetMinPosition(const AUpDown: TCustomUpDown; AValue: Double); virtual;
|
||||||
|
class procedure SetOrientation(const AUpDown: TCustomUpDown; AOrientation: TUDOrientation); virtual;
|
||||||
|
class procedure SetPosition(const AUpDown: TCustomUpDown; AValue: Double); virtual;
|
||||||
|
// class procedure SetRepeatInterval(const AUpDown: TWSCustomUpDown; ms: Integer); virtual;
|
||||||
|
class procedure SetUseArrowKeys(const AUpDown: TCustomUpDown; AUseArrow: Boolean); virtual;
|
||||||
|
class procedure SetWrap(const AUpDown: TCustomUpDown; ADoWrap: Boolean); virtual;
|
||||||
end;
|
end;
|
||||||
|
TWSCustomUpDownClass = class of TWSCustomUpDown;
|
||||||
|
|
||||||
{ TWSUpDown }
|
{ TWSUpDown }
|
||||||
|
|
||||||
@ -263,6 +272,50 @@ implementation
|
|||||||
uses
|
uses
|
||||||
LResources;
|
LResources;
|
||||||
|
|
||||||
|
{ TWSCustomUpDown }
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetUseArrowKeys(const AUpDown: TCustomUpDown;
|
||||||
|
AUseArrow: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetMinPosition(const AUpDown: TCustomUpDown;
|
||||||
|
AValue: Double);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetMaxPosition(const AUpDown: TCustomUpDown;
|
||||||
|
AValue: Double);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetPosition(const AUpDown: TCustomUpDown;
|
||||||
|
AValue: Double);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetIncrement(const AUpDown: TCustomUpDown;
|
||||||
|
AValue: Double);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetOrientation(const AUpDown: TCustomUpDown;
|
||||||
|
AOrientation: TUDOrientation);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomUpDown.SetWrap(const AUpDown: TCustomUpDown;
|
||||||
|
ADoWrap: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWSTabSheet }
|
{ TWSTabSheet }
|
||||||
|
|
||||||
class function TWSTabSheet.GetDefaultColor(const AControl: TControl;
|
class function TWSTabSheet.GetDefaultColor(const AControl: TControl;
|
||||||
|
Loading…
Reference in New Issue
Block a user