{"id":1401,"date":"2014-04-22T22:22:57","date_gmt":"2014-04-22T21:22:57","guid":{"rendered":"http:\/\/tulip-ui.azurewebsites.net\/?page_id=1401"},"modified":"2014-04-22T23:19:15","modified_gmt":"2014-04-22T22:19:15","slug":"tulip-ui-trackbars-pas","status":"publish","type":"page","link":"https:\/\/tulip-ui.azurewebsites.net\/?page_id=1401","title":{"rendered":"Tulip.UI.TrackBars.pas"},"content":{"rendered":"<div style=\"background-color: #FFFFFF; width: 680px\">\n<p style=\"text-align: right;\"><a title=\"Source Files\" href=\"http:\/\/tulip-ui.azurewebsites.net\/?page_id=1091\">Source Files<\/a><\/p>\n<p><code><\/p>\n<pre>\r\n{******************************************************************************}\r\n{                                                                              }\r\n{                        Tulip - User Interface Library                        }\r\n{                                                                              }\r\n{             Copyright(c) 2012 Marcos Gomes. All rights Reserved.             }\r\n{                                                                              }\r\n{  --------------------------------------------------------------------------  }\r\n{                                                                              }\r\n{  This product is based on Asphyre Sphinx (c) 2000 - 2012  Yuriy Kotsarenko.  }\r\n{       All rights reserved. Official web site: http:\/\/www.afterwarp.net       }\r\n{                                                                              }\r\n{******************************************************************************}\r\n{                                                                              }\r\n{  Important Notice:                                                           }\r\n{                                                                              }\r\n{  If you modify\/use this code or one of its parts either in original or       }\r\n{  modified form, you must comply with Mozilla Public License Version 2.0,     }\r\n{  including section 3, \"Responsibilities\". Failure to do so will result in    }\r\n{  the license breach, which will be resolved in the court. Remember that      }\r\n{  violating author's rights either accidentally or intentionally is           }\r\n{  considered a serious crime in many countries. Thank you!                    }\r\n{                                                                              }\r\n{  !! Please *read* Mozilla Public License 2.0 document located at:            }\r\n{  http:\/\/www.mozilla.org\/MPL\/                                                 }\r\n{                                                                              }\r\n{  --------------------------------------------------------------------------  }\r\n{                                                                              }\r\n{  The contents of this file are subject to the Mozilla Public License         }\r\n{  Version 2.0 (the \"License\"); you may not use this file except in            }\r\n{  compliance with the License. You may obtain a copy of the License at        }\r\n{  http:\/\/www.mozilla.org\/MPL\/                                                 }\r\n{                                                                              }\r\n{  Software distributed under the License is distributed on an \"AS IS\"         }\r\n{  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the     }\r\n{  License for the specific language governing rights and limitations          }\r\n{  under the License.                                                          }\r\n{                                                                              }\r\n{  The Original Code is Tulip.UI.TrackBars.pas.                                }\r\n{                                                                              }\r\n{  The Initial Developer of the Original Code is Marcos Gomes.                 }\r\n{  Portions created by Marcos Gomes are Copyright (C) 2012, Marcos Gomes.      }\r\n{  All Rights Reserved.                                                        }\r\n{                                                                              }\r\n{******************************************************************************}\r\n{                                                                              }\r\n{  Tulip.UI.TrackBars.pas                               Modified: 05-Out-2012  }\r\n{  --------------------------------------------------------------------------  }\r\n{                                                                              }\r\n{                 Base Implementations for TrackBar Controls                   }\r\n{                                                                              }\r\n{                                Version 1.02                                  }\r\n{                                                                              }\r\n{******************************************************************************}\r\n\r\nunit Tulip.UI.TrackBars;\r\n\r\ninterface\r\n\r\nuses\r\n  System.SysUtils, System.Types, System.Classes,\r\n  \/\/ Aspryre units\r\n  AsphyreTypes, AbstractCanvas, AsphyreFonts, AsphyreImages, Vectors2,\r\n  \/\/ Tulip UI Units\r\n  Tulip.UI.Classes, Tulip.UI.Types, Tulip.UI.Utils, Tulip.UI.Controls,\r\n  Tulip.UI.Forms, Tulip.UI.Helpers;\r\n\r\ntype\r\n{$REGION 'TCustomATrackBar'}\r\n  TCustomATrackBar = class(TWControl)\r\n  private\r\n    FAntialiased: Boolean;\r\n    FBorder: TBorder;\r\n    FButton: TBtBox;\r\n    FColor: TFillColor;\r\n    FFocusRect: TFocusRect;\r\n    FImage: TImage;\r\n    FIncrement: Integer;\r\n    FMargin: Word;\r\n    FMax: Integer;\r\n    FMin: Integer;\r\n    FPosition: Integer;\r\n    FTransparent: Boolean;\r\n\r\n    procedure SetAntialiased(Value: Boolean);\r\n    procedure SetBorder(Value: TBorder);\r\n    procedure SetButton(Value: TBtBox);\r\n    procedure SetColor(Value: TFillColor);\r\n    procedure SetFocusRect(Value: TFocusRect);\r\n    procedure SetImage(Value: TImage);\r\n    procedure SetIncrement(Value: Integer);\r\n    procedure SetMargin(Value: Word);\r\n    procedure SetMax(Value: Integer);\r\n    procedure SetMin(Value: Integer);\r\n    procedure SetPosition(Value: Integer);\r\n    procedure SetTransparent(Value: Boolean);\r\n  protected\r\n    procedure AssignTo(Dest: TPersistent); override;\r\n    procedure Paint; override;\r\n\r\n    procedure SetHeight(Value: Integer); override;\r\n    procedure SetWidth(Value: Integer); override;\r\n  public\r\n    constructor Create(AOwner: TComponent); override;\r\n    destructor Destroy; override;\r\n\r\n    function GetPercentage: Integer;\r\n\r\n    procedure KeyDown(var Key: Word; Shift: TShiftState); override;\r\n\r\n    procedure MouseLeave; override;\r\n    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;\r\n      X, Y: Integer); override;\r\n    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;\r\n    procedure MouseUp(Button: TMouseButton; Shift: TShiftState;\r\n      X, Y: Integer); override;\r\n\r\n    function MouseWheelDown(Shift: TShiftState; MousePos: TPoint)\r\n      : Boolean; override;\r\n    function MouseWheelUp(Shift: TShiftState; MousePos: TPoint)\r\n      : Boolean; override;\r\n\r\n    property Antialiased: Boolean read FAntialiased write SetAntialiased;\r\n    property Border: TBorder read FBorder write SetBorder;\r\n    property Button: TBtBox read FButton write SetButton;\r\n    property Color: TFillColor read FColor write SetColor;\r\n    property FocusRect: TFocusRect read FFocusRect write SetFocusRect;\r\n    property Image: TImage read FImage write SetImage;\r\n    property Increment: Integer read FIncrement write SetIncrement;\r\n    property Margin: Word read FMargin write SetMargin;\r\n    property Max: Integer read FMax write SetMax;\r\n    property Min: Integer read FMin write SetMin;\r\n    property Position: Integer read FPosition write SetPosition;\r\n    property Transparent: Boolean read FTransparent write SetTransparent;\r\n  end;\r\n{$ENDREGION}\r\n\r\nimplementation\r\n\r\n{$REGION 'TCustomATrackBar'}\r\n{ TCustomATrackBar }\r\n\r\nprocedure TCustomATrackBar.AssignTo(Dest: TPersistent);\r\nbegin\r\n  ControlState := ControlState + [csReadingState];\r\n\r\n  inherited AssignTo(Dest);\r\n\r\n  if Dest is TCustomATrackBar then\r\n    with TCustomATrackBar(Dest) do\r\n    begin\r\n      Antialiased := Self.Antialiased;\r\n      Border := Self.Border;\r\n      Button := Self.Button;\r\n      Color := Self.Color;\r\n      FocusRect := Self.FocusRect;\r\n      Image := Self.Image;\r\n      Increment := Self.Increment;\r\n      Margin := Self.Margin;\r\n      Max := Self.Max;\r\n      Min := Self.Min;\r\n      Position := Self.Position;\r\n      Transparent := Self.Transparent;\r\n    end;\r\n\r\n  ControlState := ControlState - [csReadingState];\r\nend;\r\n\r\nconstructor TCustomATrackBar.Create(AOwner: TComponent);\r\nvar\r\n  Num: Integer;\r\nbegin\r\n  ControlState := ControlState + [csCreating];\r\n\r\n  inherited Create(AOwner);\r\n\r\n  if (AOwner <> nil) and (AOwner <> Self) and (AOwner is TWControl) then\r\n  begin\r\n    \/\/ Auto generate name\r\n    Num := 1;\r\n    while AOwner.FindComponent('TrackBar' + IntToStr(Num)) <> nil do\r\n      Inc(Num);\r\n    Name := 'TrackBar' + IntToStr(Num);\r\n  end;\r\n\r\n  \/\/ Set Fields\r\n  FAntialiased := True;\r\n  FBorder := TBorder.Create;\r\n  FBorder.Color := $B0FFFFFF;\r\n  FBorder.Size := 1;\r\n  FButton := TBtBox.Create;\r\n  FColor := TFillColor.Create($FF4090F0, $FF4090F0, $FF6EAAF4, $FF6EAAF4);\r\n  FFocusRect := fDark;\r\n  FImage := TImage.Create;\r\n  FIncrement := 10;\r\n  FMargin := 1;\r\n  FMax := 100;\r\n  FMin := 0;\r\n  FPosition := 0;\r\n  FTransparent := False;\r\n\r\n  \/\/ Set Properties\r\n  Self.Left := 0;\r\n  Self.Top := 0;\r\n  Self.Height := 16;\r\n  Self.Width := 120;\r\n  Self.TabStop := True;\r\n\r\n  ControlState := ControlState - [csCreating];\r\nend;\r\n\r\ndestructor TCustomATrackBar.Destroy;\r\nbegin\r\n  FBorder.Free;\r\n  FButton.Free;\r\n  FColor.Free;\r\n  FImage.Free;\r\n\r\n  inherited;\r\nend;\r\n\r\nfunction TCustomATrackBar.GetPercentage: Integer;\r\nbegin\r\n  Result := Round((FPosition \/ FMax) * 100);\r\nend;\r\n\r\nprocedure TCustomATrackBar.KeyDown(var Key: Word; Shift: TShiftState);\r\nbegin\r\n  if Key = 39 then \/\/ right\r\n  begin\r\n    Self.Position := FPosition + FIncrement;\r\n  end;\r\n\r\n  if Key = 37 then \/\/ left\r\n  begin\r\n    Self.Position := FPosition - FIncrement;\r\n  end;\r\n\r\n  if Key = 36 then \/\/ home\r\n  begin\r\n    Self.Position := FMin;\r\n  end;\r\n\r\n  if Key = 35 then \/\/ end\r\n  begin\r\n    Self.Position := FMax;\r\n  end;\r\n\r\n  inherited KeyDown(Key, Shift);\r\nend;\r\n\r\nprocedure TCustomATrackBar.MouseDown(Button: TMouseButton; Shift: TShiftState;\r\n  X, Y: Integer);\r\nvar\r\n  L, T, H, W, Pos, BtL, BtW: Integer;\r\nbegin\r\n  L := ClientLeft + FBorder.Size + FMargin + (FButton.Width div 2);\r\n  W := Self.Width - FBorder.Size * 2 - FMargin * 2 - FButton.Width;\r\n  T := ClientTop + Round((Self.Height \/ 2) - (FButton.Height \/ 2));\r\n  H := T + FButton.Height;\r\n\r\n  Pos := L + Round((FPosition \/ FMax) * W);\r\n  BtL := Pos - (FButton.Width div 2);\r\n  BtW := Pos + (FButton.Width div 2);\r\n\r\n  if PtInRect(Rect(BtL, T, BtW, H), Point(X, Y)) then\r\n  begin\r\n    FButton.ControlState := FButton.ControlState + [csClicked];\r\n  end;\r\n\r\n  Self.SetFocus;\r\n\r\n  inherited MouseDown(Button, Shift, X, Y);\r\nend;\r\n\r\nprocedure TCustomATrackBar.MouseLeave;\r\nbegin\r\n  FButton.ControlState := FButton.ControlState - [csMouseHover];\r\n\r\n  inherited;\r\nend;\r\n\r\nprocedure TCustomATrackBar.MouseMove(Shift: TShiftState; X, Y: Integer);\r\nvar\r\n  L, T, H, W, Pos, BtL, BtW: Integer;\r\n  VPos: Integer;\r\nbegin\r\n  L := ClientLeft + FBorder.Size + FMargin + (FButton.Width div 2);\r\n  W := Self.Width - FBorder.Size * 2 - FMargin * 2 - FButton.Width;\r\n  T := ClientTop + Round((Self.Height \/ 2) - (FButton.Height \/ 2));\r\n  H := T + FButton.Height;\r\n\r\n  if csClicked in FButton.ControlState then\r\n  begin\r\n    VPos := X - L;\r\n    Self.Position := Round((VPos \/ W) * FMax);\r\n  end;\r\n\r\n  Pos := L + Round((FPosition \/ FMax) * W);\r\n  BtL := Pos - (FButton.Width div 2);\r\n  BtW := Pos + (FButton.Width div 2);\r\n\r\n  if PtInRect(Rect(BtL, T, BtW, H), Point(X, Y)) then\r\n  begin\r\n    FButton.ControlState := FButton.ControlState + [csMouseHover];\r\n  end\r\n  else\r\n  begin\r\n    FButton.ControlState := FButton.ControlState - [csMouseHover];\r\n  end;\r\n\r\n  inherited MouseMove(Shift, X, Y);\r\nend;\r\n\r\nprocedure TCustomATrackBar.MouseUp(Button: TMouseButton; Shift: TShiftState;\r\n  X, Y: Integer);\r\nvar\r\n  L, T, H, W, Pos, BtL, BtW: Integer;\r\nbegin\r\n  L := ClientLeft + FBorder.Size + FMargin + (FButton.Width div 2);\r\n  W := Self.Width - FBorder.Size * 2 - FMargin * 2 - FButton.Width;\r\n  T := ClientTop + Round((Self.Height \/ 2) - (FButton.Height \/ 2));\r\n  H := T + FButton.Height;\r\n\r\n  Pos := L + Round((FPosition \/ (FMax - FMin)) * W);\r\n  BtL := Pos - (FButton.Width div 2);\r\n  BtW := Pos + (FButton.Width div 2);\r\n\r\n  if not(PtInRect(Rect(BtL, T, BtW, H), Point(X, Y))) and\r\n    not(csClicked in FButton.ControlState) then\r\n  begin\r\n    if (X <= L + (W div 8)) then \/\/ 0\r\n    begin\r\n      FPosition := FMin;\r\n    end;\r\n    if (X > L + (W div 8)) and (X <= L + (W div 8) + (W div 4)) then \/\/ 1\/4\r\n    begin\r\n      FPosition := FMax div 4;\r\n    end;\r\n    if (X > L + (W div 8) + (W div 4)) and (X <= L + (W div 8) + (W div 4) * 2)\r\n    then \/\/ 1\/2\r\n    begin\r\n      FPosition := FMax div 2;\r\n    end;\r\n    if (X > L + (W div 8) + (W div 4) * 2) and\r\n      (X <= L + (W div 8) + (W div 4) * 3) then \/\/ 3\/4\r\n    begin\r\n      FPosition := (FMax div 4) * 3;\r\n    end;\r\n    if (X > L + (W div 8) + (W div 4) * 3) then \/\/ 1\r\n    begin\r\n      FPosition := FMax;\r\n    end;\r\n  end;\r\n\r\n  FButton.ControlState := FButton.ControlState - [csClicked];\r\n\r\n  inherited MouseUp(Button, Shift, X, Y);\r\nend;\r\n\r\nfunction TCustomATrackBar.MouseWheelDown(Shift: TShiftState;\r\n  MousePos: TPoint): Boolean;\r\nbegin\r\n  Self.Position := FPosition + FIncrement;\r\n\r\n  Result := True;\r\nend;\r\n\r\nfunction TCustomATrackBar.MouseWheelUp(Shift: TShiftState;\r\n  MousePos: TPoint): Boolean;\r\nbegin\r\n  Self.Position := FPosition - FIncrement;\r\n\r\n  Result := True;\r\nend;\r\n\r\nprocedure TCustomATrackBar.Paint;\r\nvar\r\n  X, Y: Integer;\r\n  AImage: TAsphyreImage;\r\n  bTop, bBottom: TConstraintSize;\r\n  L, T, H, W, Pos, BtL, BtW: Integer;\r\n  BtBorderColor: TAColor;\r\n  BtColor: TFillColor;\r\n  BtImage: TImage;\r\nbegin\r\n  \/\/ Set initial values\r\n  X := ClientLeft;\r\n  Y := ClientTop;\r\n\r\n  ControlManager.Canvas.Antialias := FAntialiased;\r\n\r\n  \/\/ Draw Background\r\n  if not FTransparent then\r\n  begin\r\n    AImage := ControlManager.Images.Image[FImage.Image];\r\n    if AImage <> nil then\r\n    begin\r\n      ControlManager.Canvas.UseImagePx(AImage, pRect4(FImage.Rect));\r\n      ControlManager.Canvas.TexMap(pRect4(Rect(X, Y, X + Width, Y + Height)),\r\n        cAlpha4(FColor), beNormal);\r\n    end\r\n    else\r\n    begin\r\n      ControlManager.Canvas.FillRect(Rect(X, Y, X + Width, Y + Height),\r\n        cColor4(FColor), beNormal);\r\n    end;\r\n  end;\r\n\r\n  \/\/ Draw Border\r\n  if Border.Size > 0 then\r\n  begin\r\n    bTop := 0;\r\n    bBottom := 0;\r\n\r\n    if eTop in Border.Edges then\r\n    begin\r\n      ControlManager.Canvas.FillRect(Rect(X, Y, X + Width, Y + Border.Size),\r\n        Border.Color, beNormal);\r\n      bTop := Border.Size;\r\n    end;\r\n\r\n    if eBottom in Border.Edges then\r\n    begin\r\n      ControlManager.Canvas.FillRect(Rect(X, Y + Height - Border.Size,\r\n        X + Width, Y + Height), Border.Color, beNormal);\r\n      bBottom := Border.Size;\r\n    end;\r\n\r\n    if eLeft in Border.Edges then\r\n      ControlManager.Canvas.FillRect(Rect(X, Y + bTop, X + Border.Size,\r\n        Y + Height - bBottom), Border.Color, beNormal);\r\n\r\n    if eRight in Border.Edges then\r\n      ControlManager.Canvas.FillRect(Rect(X + Width - Border.Size, Y + bTop,\r\n        X + Width, Y + Height - bBottom), Border.Color, beNormal);\r\n  end;\r\n\r\n  \/\/ Draw Focus rect\r\n  if (ControlManager.ActiveControl = Self) and (Self.FocusRect = fLight) then\r\n  begin\r\n    ControlManager.Canvas.FrameRect(Rect(X - 1, Y - 1, X + Width + 1,\r\n      Y + Height + 1), cColor4($40FFFFFF), beNormal);\r\n  end;\r\n  if (ControlManager.ActiveControl = Self) and (Self.FocusRect = fDark) then\r\n  begin\r\n    ControlManager.Canvas.FrameRect(Rect(X - 1, Y - 1, X + Width + 1,\r\n      Y + Height + 1), cColor4($30000000), beNormal);\r\n  end;\r\n\r\n  \/\/ Draw button\r\n  L := X + FBorder.Size + FMargin + (FButton.Width div 2);\r\n  W := Self.Width - FBorder.Size * 2 - FMargin * 2 - FButton.Width;\r\n  \/\/ T := Y + FBorder.Size + FMargin;\r\n  T := Y + Round((Self.Height \/ 2) - (FButton.Height \/ 2));\r\n  \/\/ H := Y + Self.Height - FBorder.Size - FMargin;\r\n  H := T + FButton.Height;\r\n\r\n  Pos := L + Round((FPosition \/ (FMax)) * W);\r\n  BtL := Pos - (FButton.Width div 2);\r\n  BtW := Pos + (FButton.Width div 2);\r\n\r\n  if csClicked in FButton.ControlState then \/\/ mouse pressed\r\n  begin\r\n    BtColor := FButton.ColorPressed;\r\n    BtImage := FButton.ImagePressed;\r\n    BtBorderColor := FButton.Border.ColorPressed;\r\n  end\r\n  else if csMouseHover in FButton.ControlState then \/\/ MouseHover\r\n  begin\r\n    BtColor := FButton.ColorHover;\r\n    BtImage := FButton.ImageHover;\r\n    BtBorderColor := FButton.Border.ColorHover;\r\n  end\r\n  else \/\/ normal\r\n  begin\r\n    BtColor := FButton.Color;\r\n    BtImage := FButton.Image;\r\n    BtBorderColor := FButton.Border.Color;\r\n  end;\r\n\r\n  \/\/ Draw button background\r\n  AImage := ControlManager.Images.Image[BtImage.Image];\r\n  if AImage <> nil then\r\n  begin\r\n    ControlManager.Canvas.UseImagePx(AImage, pRect4(BtImage.Rect));\r\n    ControlManager.Canvas.TexMap(pRect4(Rect(BtL, T, BtW, H)), cAlpha4(BtColor),\r\n      beNormal);\r\n  end\r\n  else\r\n  begin\r\n    \/\/ Draw shadow scroll area\r\n    ControlManager.Canvas.FillRect(Rect(L, T + (FButton.Height div 2) - 1,\r\n      L + W, H - (FButton.Height div 2) + 1), cColor4($20000000), beNormal);\r\n\r\n    ControlManager.Canvas.FillRect(Rect(BtL, T, BtW, H), cColor4(BtColor),\r\n      beNormal);\r\n  end;\r\n\r\n  \/\/ Draw Button Border\r\n  if FButton.Border.Size > 0 then\r\n  begin\r\n    bTop := 0;\r\n    bBottom := 0;\r\n\r\n    if eTop in FButton.Border.Edges then\r\n    begin\r\n      ControlManager.Canvas.FillRect(Rect(BtL, T, BtW, T + FButton.Border.Size),\r\n        BtBorderColor, beNormal);\r\n      bTop := FButton.Border.Size;\r\n    end;\r\n\r\n    if eBottom in FButton.Border.Edges then\r\n    begin\r\n      ControlManager.Canvas.FillRect(Rect(BtL, H - FButton.Border.Size, BtW, H),\r\n        BtBorderColor, beNormal);\r\n      bBottom := FButton.Border.Size;\r\n    end;\r\n\r\n    if eLeft in FButton.Border.Edges then\r\n      ControlManager.Canvas.FillRect(Rect(BtL, T + bTop,\r\n        BtL + FButton.Border.Size, H - bBottom), BtBorderColor, beNormal);\r\n\r\n    if eRight in FButton.Border.Edges then\r\n      ControlManager.Canvas.FillRect(Rect(BtW - FButton.Border.Size, T + bTop,\r\n        BtW, H - bBottom), BtBorderColor, beNormal);\r\n  end;\r\n\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetAntialiased(Value: Boolean);\r\nbegin\r\n  FAntialiased := Value;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetBorder(Value: TBorder);\r\nbegin\r\n  if Value <> nil then\r\n    FBorder.Assign(Value);\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetButton(Value: TBtBox);\r\nbegin\r\n  if Value <> nil then\r\n    FButton.Assign(Value);\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetColor(Value: TFillColor);\r\nbegin\r\n  if Value <> nil then\r\n    FColor.Assign(Value);\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetFocusRect(Value: TFocusRect);\r\nbegin\r\n  FFocusRect := Value;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetHeight(Value: Integer);\r\nvar\r\n  MinH: Integer;\r\nbegin\r\n  MinH := FBorder.Size * 2 + FMargin * 2 + FButton.Height;\r\n\r\n  if Value < MinH then\r\n    Value := MinH;\r\n\r\n  inherited SetHeight(Value);\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetImage(Value: TImage);\r\nbegin\r\n  if Value <> nil then\r\n    FImage.Assign(Value);\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetIncrement(Value: Integer);\r\nbegin\r\n  FIncrement := Value;\r\n\r\n  if FIncrement > FMax then\r\n    FIncrement := FMax;\r\n\r\n  if FIncrement <= 0 then\r\n    FIncrement := 1;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetMargin(Value: Word);\r\nbegin\r\n  FMargin := Value;\r\n\r\n  SetHeight(Self.Height);\r\n  SetWidth(Self.Width);\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetMax(Value: Integer);\r\nbegin\r\n  FMax := Value;\r\n\r\n  if FMax < FMin then\r\n    FMax := FMin;\r\n\r\n  if FPosition > FMax then\r\n    FPosition := FMax;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetMin(Value: Integer);\r\nbegin\r\n  FMin := Value;\r\n\r\n  if FMin > FMax then\r\n    FMin := FMax;\r\n\r\n  if FMin < 0 then\r\n    FMin := 0;\r\n\r\n  if FPosition < FMin then\r\n    FPosition := FMin;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetPosition(Value: Integer);\r\nbegin\r\n  FPosition := Value;\r\n\r\n  if FPosition > FMax then\r\n    FPosition := FMax;\r\n\r\n  if FPosition < FMin then\r\n    FPosition := FMin;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetTransparent(Value: Boolean);\r\nbegin\r\n  FTransparent := Value;\r\nend;\r\n\r\nprocedure TCustomATrackBar.SetWidth(Value: Integer);\r\nvar\r\n  MinW: Integer;\r\nbegin\r\n  MinW := FBorder.Size * 2 + FMargin * 2 + FButton.Width;\r\n\r\n  if Value < MinW then\r\n    Value := MinW;\r\n\r\n  inherited SetWidth(Value);\r\nend;\r\n{$ENDREGION}\r\n\r\nend.\r\n<\/pre>\n<p><\/code>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Source Files {******************************************************************************} { } { Tulip &#8211; User Interface Library } { } { Copyright(c) 2012 Marcos Gomes. All rights Reserved. } { } { &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; } { } <a class=\"more-link\" href=\"https:\/\/tulip-ui.azurewebsites.net\/?page_id=1401\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1091,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/pages\/1401"}],"collection":[{"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1401"}],"version-history":[{"count":2,"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/pages\/1401\/revisions"}],"predecessor-version":[{"id":1821,"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/pages\/1401\/revisions\/1821"}],"up":[{"embeddable":true,"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/pages\/1091"}],"wp:attachment":[{"href":"https:\/\/tulip-ui.azurewebsites.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}