mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 03:19:17 +02:00
lcl: add TTrackBar.Reversed property, implement for win32. Zeljan will implement for other widgetsets
git-svn-id: trunk@28312 -
This commit is contained in:
parent
a74e75f6a5
commit
c6ae8b8210
@ -1818,6 +1818,7 @@ type
|
|||||||
TCustomTrackBar = class(TWinControl)
|
TCustomTrackBar = class(TWinControl)
|
||||||
private
|
private
|
||||||
FOrientation: TTrackBarOrientation;
|
FOrientation: TTrackBarOrientation;
|
||||||
|
FReversed: Boolean;
|
||||||
FSelEnd: Integer;
|
FSelEnd: Integer;
|
||||||
FSelStart: Integer;
|
FSelStart: Integer;
|
||||||
FShowSelRange: Boolean;
|
FShowSelRange: Boolean;
|
||||||
@ -1840,6 +1841,7 @@ type
|
|||||||
procedure SetPageSize(Value: Integer);
|
procedure SetPageSize(Value: Integer);
|
||||||
procedure SetParams(APosition, AMin, AMax: Integer);
|
procedure SetParams(APosition, AMin, AMax: Integer);
|
||||||
procedure SetPosition(Value: Integer);
|
procedure SetPosition(Value: Integer);
|
||||||
|
procedure SetReversed(const AValue: Boolean);
|
||||||
procedure SetScalePos(Value: TTrackBarScalePos);
|
procedure SetScalePos(Value: TTrackBarScalePos);
|
||||||
procedure SetSelEnd(const AValue: Integer);
|
procedure SetSelEnd(const AValue: Integer);
|
||||||
procedure SetSelStart(const AValue: Integer);
|
procedure SetSelStart(const AValue: Integer);
|
||||||
@ -1868,6 +1870,7 @@ type
|
|||||||
property Orientation: TTrackBarOrientation read FOrientation write SetOrientation default trHorizontal;
|
property Orientation: TTrackBarOrientation read FOrientation write SetOrientation default trHorizontal;
|
||||||
property PageSize: Integer read FPageSize write SetPageSize default 2;
|
property PageSize: Integer read FPageSize write SetPageSize default 2;
|
||||||
property Position: Integer read FPosition write SetPosition;
|
property Position: Integer read FPosition write SetPosition;
|
||||||
|
property Reversed: Boolean read FReversed write SetReversed default False;
|
||||||
property ScalePos: TTrackBarScalePos read FScalePos write SetScalePos default trTop;
|
property ScalePos: TTrackBarScalePos read FScalePos write SetScalePos default trTop;
|
||||||
property SelEnd: Integer read FSelEnd write SetSelEnd default 0;
|
property SelEnd: Integer read FSelEnd write SetSelEnd default 0;
|
||||||
property SelStart: Integer read FSelStart write SetSelStart default 0;
|
property SelStart: Integer read FSelStart write SetSelStart default 0;
|
||||||
@ -1922,6 +1925,7 @@ type
|
|||||||
property ParentShowHint;
|
property ParentShowHint;
|
||||||
property PopupMenu;
|
property PopupMenu;
|
||||||
property Position;
|
property Position;
|
||||||
|
property Reversed;
|
||||||
property ScalePos;
|
property ScalePos;
|
||||||
property SelEnd;
|
property SelEnd;
|
||||||
property SelStart;
|
property SelStart;
|
||||||
|
@ -72,6 +72,7 @@ begin
|
|||||||
FSelStart := 0;
|
FSelStart := 0;
|
||||||
FSelEnd := 0;
|
FSelEnd := 0;
|
||||||
FShowSelRange := True;
|
FShowSelRange := True;
|
||||||
|
FReversed := False;
|
||||||
TabStop := True;
|
TabStop := True;
|
||||||
with GetControlClassDefaultSize do
|
with GetControlClassDefaultSize do
|
||||||
SetInitialBounds(0, 0, CX, CY);
|
SetInitialBounds(0, 0, CX, CY);
|
||||||
@ -126,7 +127,8 @@ begin
|
|||||||
FOrientation := Value;
|
FOrientation := Value;
|
||||||
// switch width and height, but not when loading, because we assume that the
|
// switch width and height, but not when loading, because we assume that the
|
||||||
// lfm contains a consistent combination of Orientation and (width, height)
|
// lfm contains a consistent combination of Orientation and (width, height)
|
||||||
if not (csLoading in ComponentState) then begin
|
if not (csLoading in ComponentState) then
|
||||||
|
begin
|
||||||
OldWidth:=Width;
|
OldWidth:=Width;
|
||||||
OldHeight:=Height;
|
OldHeight:=Height;
|
||||||
SetBounds(Left,Top,OldHeight,OldWidth);
|
SetBounds(Left,Top,OldHeight,OldWidth);
|
||||||
@ -180,6 +182,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomTrackBar.SetReversed(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FReversed <> AValue then
|
||||||
|
begin
|
||||||
|
FReversed := AValue;
|
||||||
|
ApplyChanges;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomTrackBar.SetMin
|
Method: TCustomTrackBar.SetMin
|
||||||
Params: Value : new minimum
|
Params: Value : new minimum
|
||||||
|
@ -877,22 +877,26 @@ var
|
|||||||
NewStyle: integer;
|
NewStyle: integer;
|
||||||
const
|
const
|
||||||
StyleMask = TBS_AUTOTICKS or TBS_NOTICKS or TBS_VERT or TBS_TOP or TBS_BOTH or
|
StyleMask = TBS_AUTOTICKS or TBS_NOTICKS or TBS_VERT or TBS_TOP or TBS_BOTH or
|
||||||
TBS_ENABLESELRANGE;
|
TBS_ENABLESELRANGE or TBS_REVERSED;
|
||||||
TickStyleStyle: array[TTickStyle] of DWORD = (TBS_NOTICKS, TBS_AUTOTICKS, 0);
|
TickStyleStyle: array[TTickStyle] of DWORD = (TBS_NOTICKS, TBS_AUTOTICKS, 0);
|
||||||
OrientationStyle: array[TTrackBarOrientation] of DWORD = (TBS_HORZ, TBS_VERT);
|
OrientationStyle: array[TTrackBarOrientation] of DWORD = (TBS_HORZ, TBS_VERT);
|
||||||
TickMarksStyle: array[TTickMark] of DWORD = (TBS_BOTTOM, TBS_TOP, TBS_BOTH);
|
TickMarksStyle: array[TTickMark] of DWORD = (TBS_BOTTOM, TBS_TOP, TBS_BOTH);
|
||||||
SelRangeStyle: array[Boolean] of DWORD = (0, TBS_ENABLESELRANGE);
|
SelRangeStyle: array[Boolean] of DWORD = (0, TBS_ENABLESELRANGE);
|
||||||
|
ReversedStyle: array[Boolean] of DWORD = (0, TBS_REVERSED);
|
||||||
begin
|
begin
|
||||||
with ATrackBar do
|
with ATrackBar do
|
||||||
begin
|
begin
|
||||||
{ cache handle }
|
{ cache handle }
|
||||||
wHandle := Handle;
|
wHandle := Handle;
|
||||||
NewStyle := TickStyleStyle[TickStyle] or OrientationStyle[Orientation] or
|
NewStyle := TickStyleStyle[TickStyle] or OrientationStyle[Orientation] or
|
||||||
TickMarksStyle[TickMarks] or SelRangeStyle[ShowSelRange];
|
TickMarksStyle[TickMarks] or SelRangeStyle[ShowSelRange] or ReversedStyle[Reversed];
|
||||||
UpdateWindowStyle(wHandle, NewStyle, StyleMask);
|
UpdateWindowStyle(wHandle, NewStyle, StyleMask);
|
||||||
Windows.SendMessage(wHandle, TBM_SETRANGEMAX, Windows.WPARAM(True), Max);
|
Windows.SendMessage(wHandle, TBM_SETRANGEMAX, Windows.WPARAM(True), Max);
|
||||||
Windows.SendMessage(wHandle, TBM_SETRANGEMIN, Windows.WPARAM(True), Min);
|
Windows.SendMessage(wHandle, TBM_SETRANGEMIN, Windows.WPARAM(True), Min);
|
||||||
Windows.SendMessage(wHandle, TBM_SETPOS, Windows.WPARAM(True), Position);
|
if Reversed then
|
||||||
|
Windows.SendMessage(wHandle, TBM_SETPOS, Windows.WPARAM(True), Max + Min - Position)
|
||||||
|
else
|
||||||
|
Windows.SendMessage(wHandle, TBM_SETPOS, Windows.WPARAM(True), Position);
|
||||||
Windows.SendMessage(wHandle, TBM_SETLINESIZE, 0, LineSize);
|
Windows.SendMessage(wHandle, TBM_SETLINESIZE, 0, LineSize);
|
||||||
Windows.SendMessage(wHandle, TBM_SETPAGESIZE, 0, PageSize);
|
Windows.SendMessage(wHandle, TBM_SETPAGESIZE, 0, PageSize);
|
||||||
Windows.SendMessage(wHandle, TBM_SETTICFREQ, Frequency, 0);
|
Windows.SendMessage(wHandle, TBM_SETTICFREQ, Frequency, 0);
|
||||||
@ -908,12 +912,17 @@ end;
|
|||||||
|
|
||||||
class function TWin32WSTrackBar.GetPosition(const ATrackBar: TCustomTrackBar): integer;
|
class function TWin32WSTrackBar.GetPosition(const ATrackBar: TCustomTrackBar): integer;
|
||||||
begin
|
begin
|
||||||
Result := SendMessage(ATrackBar.Handle, TBM_GETPOS, 0, 0)
|
Result := SendMessage(ATrackBar.Handle, TBM_GETPOS, 0, 0);
|
||||||
|
if (GetWindowLong(ATrackBar.Handle, GWL_STYLE) and TBS_REVERSED) <> 0 then
|
||||||
|
Result := ATrackBar.Max + ATrackBar.Min - Result;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSTrackBar.SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer);
|
class procedure TWin32WSTrackBar.SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer);
|
||||||
begin
|
begin
|
||||||
Windows.SendMessage(ATrackBar.Handle, TBM_SETPOS, Windows.WPARAM(true), Windows.LPARAM(NewPosition));
|
if (GetWindowLong(ATrackBar.Handle, GWL_STYLE) and TBS_REVERSED) <> 0 then
|
||||||
|
Windows.SendMessage(ATrackBar.Handle, TBM_SETPOS, Windows.WPARAM(true), Windows.LPARAM(ATrackBar.Max + ATrackBar.Min - NewPosition))
|
||||||
|
else
|
||||||
|
Windows.SendMessage(ATrackBar.Handle, TBM_SETPOS, Windows.WPARAM(true), Windows.LPARAM(NewPosition));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSTrackBar.SetTick(const ATrackBar: TCustomTrackBar;
|
class procedure TWin32WSTrackBar.SetTick(const ATrackBar: TCustomTrackBar;
|
||||||
|
@ -191,7 +191,6 @@ type
|
|||||||
|
|
||||||
{ TWSTrackBar }
|
{ TWSTrackBar }
|
||||||
|
|
||||||
TWSTrackBarClass = class of TWSTrackBar;
|
|
||||||
TWSTrackBar = class(TWSWinControl)
|
TWSTrackBar = class(TWSWinControl)
|
||||||
published
|
published
|
||||||
class procedure ApplyChanges(const ATrackBar: TCustomTrackBar); virtual;
|
class procedure ApplyChanges(const ATrackBar: TCustomTrackBar); virtual;
|
||||||
@ -199,6 +198,7 @@ type
|
|||||||
class procedure SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer); virtual;
|
class procedure SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer); virtual;
|
||||||
class procedure SetTick(const ATrackBar: TCustomTrackBar; const ATick: integer); virtual;
|
class procedure SetTick(const ATrackBar: TCustomTrackBar; const ATick: integer); virtual;
|
||||||
end;
|
end;
|
||||||
|
TWSTrackBarClass = class of TWSTrackBar;
|
||||||
|
|
||||||
{ TWSCustomTreeView }
|
{ TWSCustomTreeView }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user