mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 05:58:06 +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)
|
||||
private
|
||||
FOrientation: TTrackBarOrientation;
|
||||
FReversed: Boolean;
|
||||
FSelEnd: Integer;
|
||||
FSelStart: Integer;
|
||||
FShowSelRange: Boolean;
|
||||
@ -1840,6 +1841,7 @@ type
|
||||
procedure SetPageSize(Value: Integer);
|
||||
procedure SetParams(APosition, AMin, AMax: Integer);
|
||||
procedure SetPosition(Value: Integer);
|
||||
procedure SetReversed(const AValue: Boolean);
|
||||
procedure SetScalePos(Value: TTrackBarScalePos);
|
||||
procedure SetSelEnd(const AValue: Integer);
|
||||
procedure SetSelStart(const AValue: Integer);
|
||||
@ -1868,6 +1870,7 @@ type
|
||||
property Orientation: TTrackBarOrientation read FOrientation write SetOrientation default trHorizontal;
|
||||
property PageSize: Integer read FPageSize write SetPageSize default 2;
|
||||
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 SelEnd: Integer read FSelEnd write SetSelEnd default 0;
|
||||
property SelStart: Integer read FSelStart write SetSelStart default 0;
|
||||
@ -1922,6 +1925,7 @@ type
|
||||
property ParentShowHint;
|
||||
property PopupMenu;
|
||||
property Position;
|
||||
property Reversed;
|
||||
property ScalePos;
|
||||
property SelEnd;
|
||||
property SelStart;
|
||||
|
@ -72,6 +72,7 @@ begin
|
||||
FSelStart := 0;
|
||||
FSelEnd := 0;
|
||||
FShowSelRange := True;
|
||||
FReversed := False;
|
||||
TabStop := True;
|
||||
with GetControlClassDefaultSize do
|
||||
SetInitialBounds(0, 0, CX, CY);
|
||||
@ -126,7 +127,8 @@ begin
|
||||
FOrientation := Value;
|
||||
// switch width and height, but not when loading, because we assume that the
|
||||
// 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;
|
||||
OldHeight:=Height;
|
||||
SetBounds(Left,Top,OldHeight,OldWidth);
|
||||
@ -180,6 +182,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomTrackBar.SetReversed(const AValue: Boolean);
|
||||
begin
|
||||
if FReversed <> AValue then
|
||||
begin
|
||||
FReversed := AValue;
|
||||
ApplyChanges;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCustomTrackBar.SetMin
|
||||
Params: Value : new minimum
|
||||
|
@ -877,22 +877,26 @@ var
|
||||
NewStyle: integer;
|
||||
const
|
||||
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);
|
||||
OrientationStyle: array[TTrackBarOrientation] of DWORD = (TBS_HORZ, TBS_VERT);
|
||||
TickMarksStyle: array[TTickMark] of DWORD = (TBS_BOTTOM, TBS_TOP, TBS_BOTH);
|
||||
SelRangeStyle: array[Boolean] of DWORD = (0, TBS_ENABLESELRANGE);
|
||||
ReversedStyle: array[Boolean] of DWORD = (0, TBS_REVERSED);
|
||||
begin
|
||||
with ATrackBar do
|
||||
begin
|
||||
{ cache handle }
|
||||
wHandle := Handle;
|
||||
NewStyle := TickStyleStyle[TickStyle] or OrientationStyle[Orientation] or
|
||||
TickMarksStyle[TickMarks] or SelRangeStyle[ShowSelRange];
|
||||
TickMarksStyle[TickMarks] or SelRangeStyle[ShowSelRange] or ReversedStyle[Reversed];
|
||||
UpdateWindowStyle(wHandle, NewStyle, StyleMask);
|
||||
Windows.SendMessage(wHandle, TBM_SETRANGEMAX, Windows.WPARAM(True), Max);
|
||||
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_SETPAGESIZE, 0, PageSize);
|
||||
Windows.SendMessage(wHandle, TBM_SETTICFREQ, Frequency, 0);
|
||||
@ -908,12 +912,17 @@ end;
|
||||
|
||||
class function TWin32WSTrackBar.GetPosition(const ATrackBar: TCustomTrackBar): integer;
|
||||
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;
|
||||
|
||||
class procedure TWin32WSTrackBar.SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer);
|
||||
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;
|
||||
|
||||
class procedure TWin32WSTrackBar.SetTick(const ATrackBar: TCustomTrackBar;
|
||||
|
@ -191,7 +191,6 @@ type
|
||||
|
||||
{ TWSTrackBar }
|
||||
|
||||
TWSTrackBarClass = class of TWSTrackBar;
|
||||
TWSTrackBar = class(TWSWinControl)
|
||||
published
|
||||
class procedure ApplyChanges(const ATrackBar: TCustomTrackBar); virtual;
|
||||
@ -199,6 +198,7 @@ type
|
||||
class procedure SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer); virtual;
|
||||
class procedure SetTick(const ATrackBar: TCustomTrackBar; const ATick: integer); virtual;
|
||||
end;
|
||||
TWSTrackBarClass = class of TWSTrackBar;
|
||||
|
||||
{ TWSCustomTreeView }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user