Ignore:
Timestamp:
Dec 9, 2010, 2:15:54 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Rozdělení zobrazovaných stylů do více jednotek.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDocking.pas

    r96 r97  
    1111  Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil,
    1212  UCoolDockCustomize, DOM, XMLWrite, XMLRead, UCoolDockWindowList,
    13   DateUtils;
     13  DateUtils, UCoolDockStyleTabs, UCoolDockStyleRegions, UCoolDockStylePopupTabs,
     14  UCoolDockStylePopupRegions, UCoolDockStyle, UCoolDockClientPanel;
    1415
    1516const
    1617  GrabberSize = 22;
    17   AutoHideStepCount = 20;
    1818
    1919type
    2020  TDockDirection = (ddNone, ddHorizontal, ddVertical);
    21   THeaderPos = (hpAuto, hpLeft, hpTop, hpRight, hpBottom);
    2221
    2322  TCoolDockManager = class;
    24   TCoolDockClientPanel = class;
    2523  TCoolDockCustomize = class;
    2624  TCoolDockClient = class;
     
    3634  end;
    3735
    38   TDockStyle = (dsList, dsTabs);
    39 
    40   { TCoolDockHeader }
    41 
    42   TCoolDockHeader = class(TPanel)
    43   private
    44     procedure CloseButtonClick(Sender: TObject);
    45     procedure DrawGrabber(Canvas: TCanvas; AControl: TControl);
    46   public
    47     CloseButton: TSpeedButton;
    48     Title: TLabel;
    49     Icon: TImage;
    50     ParentClientPanel: TCoolDockClientPanel;
    51     Shape: TShape;
    52     constructor Create(TheOwner: TComponent); override;
    53     destructor Destroy; override;
    54   end;
    55 
    56   TCoolDockStyle = class
    57   end;
    58 
    59   { TCoolDockClientPanel }
    60 
    61   TCoolDockClientPanel = class(TPanel)
    62   private
    63     FAutoHide: Boolean;
    64     FHeaderPos: THeaderPos;
    65     FShowHeader: Boolean;
    66     function GetAutoHideEnabled: Boolean;
    67     procedure SetAutoHide(const AValue: Boolean);
    68     procedure SetAutoHideEnabled(const AValue: Boolean);
    69     procedure SetHeaderPos(const AValue: THeaderPos);
    70     procedure SetShowHeader(const AValue: Boolean);
    71     procedure VisibleChange(Sender: TObject);
    72   public
    73     Header: TCoolDockHeader;
    74     OwnerDockManager: TCoolDockManager;
    75     Control: TControl;
    76     Splitter: TSplitter;
    77     ClientAreaPanel: TPanel;
    78     constructor Create(TheOwner: TComponent); override;
    79     destructor Destroy; override;
    80     procedure DockPanelPaint(Sender: TObject);
    81     procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton;
    82       Shift: TShiftState; X, Y: Integer);
    83     procedure ResizeExecute(Sender: TObject);
    84     property ShowHeader: Boolean read FShowHeader write SetShowHeader;
    85     property AutoHideEnabled: Boolean read GetAutoHideEnabled
    86       write SetAutoHideEnabled;
    87     property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos;
    88   end;
    89 
    90   { TCoolDockAutoHide }
    91 
    92   TCoolDockAutoHide = class
    93   private
    94     FDuration: Real;
    95     FStepCount: Integer;
    96     StartBounds: TRect;
    97     procedure SetDuration(const AValue: Real);
    98     procedure SetStepCount(const AValue: Integer);
    99     procedure UpdateBounds;
    100     procedure UpdateTimerInterval;
    101   public
    102     Position: Real;
    103     Direction: Integer;
    104     TabPosition: TTabPosition;
    105     Enable: Boolean;
    106     Timer: TTimer;
    107     Control: TControl;
    108     ControlVisible: Boolean;
    109     procedure Hide;
    110     procedure Show;
    111     constructor Create;
    112     destructor Destroy; override;
    113     procedure TimerExecute(Sender: TObject);
    114     property Duration: Real read FDuration write SetDuration;
    115     property StepCount: Integer read FStepCount write SetStepCount;
    116   end;
     36  TDockStyle = (dsList, dsTabs, dsPopupTabs, dsPopupList);
    11737
    11838  { TCoolDockManager }
     
    12040  TCoolDockManager = class(TDockManager)
    12141  private
    122     MouseDown: Boolean;
    123     MouseButton: TMouseButton;
    124     MouseDownSkip: Boolean;
    12542    FMaster: TCoolDockMaster;
    126     FTabsPos: THeaderPos;
    127     PopupMenuTabs: TPopupMenu;
     43    DockStyleHandler: TCoolDockStyle;
    12844    PopupMenuHeader: TPopupMenu;
    12945    FDockStyle: TDockStyle;
    130     TabControl: TTabControl;
    131     TabImageList: TImageList;
    13246    FDockDirection: TDockDirection;
    13347    FDockSite: TWinControl;
    13448    FDockPanels: TObjectList; // TObjectList<TCoolDockClientPanel>
    135     AutoHide: TCoolDockAutoHide;
    13649    function FindControlInPanels(Control: TControl): TCoolDockClientPanel;
    13750    function GetDockSite: TWinControl;
     
    13952    procedure InsertControlPanel(Control: TControl; InsertAt: TAlign;
    14053      DropCtl: TControl);
    141     procedure PopupMenuTabCloseClick(Sender: TObject);
    14254    procedure SetDockStyle(const AValue: TDockStyle);
    14355    procedure SetMaster(const AValue: TCoolDockMaster);
    14456    procedure SetMoveDuration(const AValue: Integer);
    145     procedure SetTabsPos(const AValue: THeaderPos);
    146     procedure TabControlMouseLeave(Sender: TObject);
    147     procedure TabControlChange(Sender: TObject);
    148     procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton;
    149       Shift: TShiftState; X, Y: Integer);
    150     procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton;
    151       Shift: TShiftState; X, Y: Integer);
    15257    procedure UpdateClientSize;
    15358    procedure PopupMenuListClick(Sender: TObject);
     
    18893
    18994    function CreateContainer(InsertAt: TAlign): TCoolDockConjoinForm;
     95    property DockPanels: TObjectList read FDockPanels write FDockPanels;
    19096    property DockStyle: TDockStyle read FDockStyle write SetDockStyle;
    19197    property MoveDuration: Integer read GetMoveDuration write SetMoveDuration;
    192     property TabsPos: THeaderPos read FTabsPos write SetTabsPos;
    19398    property Master: TCoolDockMaster read FMaster write SetMaster;
    19499    property DockSite: TWinControl read GetDockSite;
     
    286191procedure Register;
    287192
    288 implementation
    289 
    290 uses
    291   UCoolDockStyleTabs;
    292 
    293193resourcestring
    294194  SDockStyle = 'Style';
     
    309209  SRenameWindow = 'Rename window';
    310210
     211
     212implementation
     213
    311214procedure Register;
    312215begin
     
    342245end;
    343246
    344 procedure TCoolDockManager.TabControlMouseLeave(Sender: TObject);
    345 begin
    346   if MouseDown then
    347   if (TabControl.TabIndex <> -1) then begin
    348     TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).ClientAreaPanel.DockSite := False;
    349     DragManager.DragStart(TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control, False, 1);
    350   end;
    351   MouseDown := False;
    352 end;
    353 
    354247constructor TCoolDockManager.Create(ADockSite: TWinControl);
    355248var
     
    361254  FDockPanels := TObjectList.Create;
    362255
    363   AutoHide := TCoolDockAutoHide.Create;
    364 
    365   // Tabs popup
     256  FDockStyle := dsTabs; // To initialize style value have to be different
     257  DockStyle := dsList;
     258
     259(*  // Tabs popup
    366260
    367261  PopupMenuTabs := TPopupMenu.Create(FDockSite);
     
    498392  NewMenuItem.OnClick := PopupMenuCustomizeClick;
    499393  PopupMenuHeader.Items.Add(NewMenuItem);
    500 
    501   TabImageList := TImageList.Create(FDockSite);
    502   with TabImageList do begin
    503     Name := ADockSite.Name + '_' + 'ImageList';
    504   end;
    505   TabControl := TTabControl.Create(FDockSite);
    506   with TabControl do begin
    507     Parent := FDockSite;
    508     Name := ADockSite.Name + '_' + 'TabControl';
    509     Visible := False;
    510     Align := alTop;
    511     Height := 24;
    512     OnChange := TabControlChange;
    513     PopupMenu := PopupMenuTabs;
    514     TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave;
    515     TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseDown := TabControlMouseDown;
    516     TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseUp := TabControlMouseUp;
    517     OnMouseUp := TabControlMouseUp;
    518     Images := TabImageList;
    519   end;
    520   TabsPos := hpTop;
    521   MoveDuration := 1000; // ms
     394  *)
    522395end;
    523396
     
    601474      NewPanel.Header.Icon.Picture.Assign((Control as TForm).Icon);
    602475
    603     if DockStyle = dsTabs then begin
    604       TabControl.Tabs.Add(Control.Caption);
    605       TabImageList.Add(NewPanel.Header.Icon.Picture.Bitmap, nil);
    606       if Assigned(NewPanel.Splitter) then
    607         NewPanel.Splitter.Visible := False;
    608       NewPanel.ClientAreaPanel.Visible := False;
    609       NewPanel.Visible := False;
    610       TabControlChange(Self);
    611     end;
     476    DockStyleHandler.InsertControl(NewPanel, Control, InsertAt);
     477
    612478    NewPanel.Control := Control;
    613479    Control.AddHandlerOnVisibleChanged(NewPanel.VisibleChange);
     
    765631  if FDockStyle <> AValue then begin
    766632    FDockStyle := AValue;
     633    DockStyleHandler.Free;
    767634    if AValue = dsTabs then begin
    768       TabControl.Visible := True;
    769       TabControl.Tabs.Clear;
    770       TabImageList.Clear;
    771       for I := 0 to FDockPanels.Count - 1 do begin
    772         TabControl.Tabs.Add(TCoolDockClientPanel(FDockPanels[I]).Control.Caption);
    773         TabImageList.Add(TCoolDockClientPanel(FDockPanels[I]).Header.Icon.Picture.Bitmap, nil);
    774         if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then
    775           TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := False;
    776         TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False;
    777         TCoolDockClientPanel(FDockPanels[I]).Visible := False;
    778       end;
    779       TabControlChange(Self);
     635      DockStyleHandler := TCoolDockStyleTabs.Create(Self);
    780636    end else
    781637    if AValue = dsList then begin
    782       TabControl.Visible := False;
    783       TabControl.Tabs.Clear;
    784       for I := 0 to FDockPanels.Count - 1 do begin
    785         if Assigned(TCoolDockClientPanel(FDockPanels[I]).Splitter) then
    786         TCoolDockClientPanel(FDockPanels[I]).Splitter.Visible := True;
    787         TCoolDockClientPanel(FDockPanels[I]).Visible := True;
    788         TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := TCoolDockClientPanel(FDockPanels[I]);
    789         TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := True;
    790         TCoolDockClientPanel(FDockPanels[I]).Control.Visible := True;
    791       end;
     638      DockStyleHandler := TCoolDockStyleRegions.Create(Self);
     639    end else
     640    if AValue = dsPopupList then begin
     641      DockStyleHandler := TCoolDockStylePopupRegions.Create(Self);
     642    end else
     643    if AValue = dsPopupTabs then begin
     644      DockStyleHandler := TCoolDockStylePopupTabs.Create(Self);
    792645    end;
    793646  end;
     
    799652  if FMaster = AValue then Exit;
    800653  FMaster := AValue;
    801   TabsPos := AValue.DefaultTabsPos;
    802654end;
    803655
     
    806658end;
    807659
    808 procedure TCoolDockManager.SetTabsPos(const AValue: THeaderPos);
    809 begin
    810   if FTabsPos = AValue then Exit;
    811   FTabsPos := AValue;
    812   with TabControl do
    813   case AValue of
    814     hpAuto, hpTop: begin
    815       Align := alTop;
    816       TabPosition := tpTop;
    817       Height := GrabberSize;
    818     end;
    819     hpLeft: begin
    820       Align := alLeft;
    821       TabPosition := tpLeft;
    822       Width := GrabberSize;
    823     end;
    824     hpRight: begin
    825       Align := alRight;
    826       TabPosition := tpRight;
    827       Width := GrabberSize;
    828     end;
    829     hpBottom: begin
    830       Align := alBottom;
    831       TabPosition := tpBottom;
    832       Height := GrabberSize;
    833     end;
    834   end;
    835 end;
    836 
    837660procedure TCoolDockManager.UpdateClientSize;
    838 var
    839   I: Integer;
    840 begin
    841   if DockStyle = dsList then begin
    842     for I := 0 to FDockPanels.Count - 1 do begin
    843       TCoolDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div
    844         FDockSite.DockClientCount;
    845       TCoolDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div
    846         FDockSite.DockClientCount;
    847       //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    848       TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    849     end;
    850   end else
    851   if DockStyle = dsTabs then begin
    852     for I := 0 to FDockPanels.Count - 1 do begin
    853       TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Width := FDockSite.Width;
    854       TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Height := FDockSite.Height - TabControl.Height;
    855       //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    856     end;
    857   end;
    858 end;
    859 
    860 procedure TCoolDockManager.TabControlChange(Sender: TObject);
    861 var
    862   I: Integer;
    863 begin
    864   // Hide all clients
    865   for I := 0 to FDockPanels.Count - 1 do begin
    866     TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Visible := False;
    867     TCoolDockClientPanel(FDockPanels[I]).ClientAreaPanel.Parent := FDockSite;
    868     TCoolDockClientPanel(FDockPanels[I]).Control.Align := alClient;
    869     TCoolDockClientPanel(FDockPanels[I]).Control.Visible := False;
    870 
    871     // Workaround for "Cannot focus" error
    872     TForm(TCoolDockClientPanel(FDockPanels[I]).Control).ActiveControl := nil;
    873   end;
    874   if (TabControl.TabIndex <> -1) and (FDockPanels.Count > TabControl.TabIndex) then begin
    875     with TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]), ClientAreaPanel do begin
    876       Control.Show;
    877       AutoHide.Enable := True;
    878       if AutoHide.Enable then begin
    879         //Parent := nil;
    880         Visible := True;
    881         if AutoHide.ControlVisible then begin
    882           AutoHide.Hide;
    883         end;
    884         AutoHide.Control := Control;
    885         AutoHide.Show;
    886       end else begin
    887         Parent := FDockSite;
    888         Visible := True;
    889         UpdateClientSize;
    890       end;
    891     end;
    892   //TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True;
    893   end;
    894   MouseDownSkip := True;
     661begin
     662  DockStyleHandler.UpdateClientSize;
    895663end;
    896664
     
    910678end;
    911679
    912 procedure TCoolDockManager.PopupMenuTabCloseClick(Sender: TObject);
    913 begin
    914   if TabControl.TabIndex <> -1 then
    915     TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control.Hide;
    916 end;
    917 
    918680procedure TCoolDockManager.PopupMenuRenameClick(Sender: TObject);
    919681var
     
    927689procedure TCoolDockManager.PopupMenuPositionAutoClick(Sender: TObject);
    928690begin
    929   TabsPos := hpAuto;
     691  //TabsPos := hpAuto;
    930692end;
    931693
    932694procedure TCoolDockManager.PopupMenuPositionLeftClick(Sender: TObject);
    933695begin
    934   TabsPos := hpLeft;
     696  //TabsPos := hpLeft;
    935697end;
    936698
    937699procedure TCoolDockManager.PopupMenuPositionRightClick(Sender: TObject);
    938700begin
    939   TabsPos := hpRight;
     701  //TabsPos := hpRight;
    940702end;
    941703
    942704procedure TCoolDockManager.PopupMenuPositionTopClick(Sender: TObject);
    943705begin
    944   TabsPos := hpTop;
     706  //TabsPos := hpTop;
    945707end;
    946708
    947709procedure TCoolDockManager.PopupMenuPositionBottomClick(Sender: TObject);
    948710begin
    949   TabsPos := hpBottom;
     711  //TabsPos := hpBottom;
    950712end;
    951713
     
    965727end;
    966728
    967 procedure TCoolDockManager.TabControlMouseDown(Sender: TObject; Button: TMouseButton;
    968   Shift: TShiftState; X, Y: Integer);
    969 begin
    970   if not MouseDownSkip then begin
    971     MouseDown := True;
    972     MouseButton := Button;
    973   end;
    974   MouseDownSkip := False;
    975 end;
    976 
    977 procedure TCoolDockManager.TabControlMouseUp(Sender: TObject;
    978   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    979 begin
    980   MouseDown := False;
    981 end;
    982 
    983729procedure TCoolDockManager.PopupMenuListClick(Sender: TObject);
    984730begin
     
    986732end;
    987733
    988 { TCoolDockClientPanel }
    989 
    990 procedure TCoolDockClientPanel.SetShowHeader(const AValue: Boolean);
    991 begin
    992   if FShowHeader = AValue then Exit;
    993   FShowHeader := AValue;
    994   DockPanelPaint(Self);
    995 end;
    996 
    997 procedure TCoolDockClientPanel.VisibleChange(Sender: TObject);
    998 var
    999   Visible: Boolean;
    1000 begin
    1001   (*if Assigned(Control) then begin
    1002     Visible := Control.Visible;
    1003     if Assigned(ClientAreaPanel) then
    1004       ClientAreaPanel.Visible := Visible;
    1005     if Assigned(Splitter) then
    1006       Splitter.Visible := Visible;
    1007     OwnerDockManager.UpdateClientSize;
    1008   end;*)
    1009 end;
    1010 
    1011 procedure TCoolDockClientPanel.SetAutoHide(const AValue: Boolean);
    1012 begin
    1013   if FAutoHide = AValue then Exit;
    1014   FAutoHide := AValue;
    1015 end;
    1016 
    1017 function TCoolDockClientPanel.GetAutoHideEnabled: Boolean;
    1018 begin
    1019 end;
    1020 
    1021 procedure TCoolDockClientPanel.SetAutoHideEnabled(const AValue: Boolean);
    1022 begin
    1023 
    1024 end;
    1025 
    1026 procedure TCoolDockClientPanel.SetHeaderPos(const AValue: THeaderPos);
    1027 begin
    1028   if FHeaderPos=AValue then exit;
    1029   FHeaderPos:=AValue;
    1030 end;
    1031 
    1032 constructor TCoolDockClientPanel.Create(TheOwner: TComponent);
    1033 begin
    1034   inherited;
    1035   ShowHeader := True;
    1036   Header := TCoolDockHeader.Create(Self);
    1037   with Header do begin
    1038     Parent := Self;
    1039     Visible := ShowHeader;
    1040     Align := alTop;
    1041     Height := GrabberSize;
    1042     ParentClientPanel := Self;
    1043   end;
    1044   ClientAreaPanel := TPanel.Create(Self);
    1045   with ClientAreaPanel do begin
    1046     Parent := Self;
    1047     Visible := True;
    1048     DockSite := True;
    1049     UseDockManager := True;
    1050     Align := alClient;
    1051     BevelInner := bvNone;
    1052     BevelOuter := bvNone;
    1053     //Color := clGreen;
    1054   end;
    1055   Splitter := TSplitter.Create(Self);
    1056   with Splitter do begin
    1057     //Color := clRed;
    1058   end;
    1059   OnPaint := DockPanelPaint;
    1060   Header.Shape.OnMouseDown := DockPanelMouseDown;
    1061   OnResize := ResizeExecute;
    1062   BevelInner := bvNone;
    1063   BevelOuter := bvNone;
    1064   AutoHideEnabled := True;
    1065   HeaderPos := hpTop;
    1066 end;
    1067 
    1068 destructor TCoolDockClientPanel.Destroy;
    1069 begin
    1070   inherited Destroy;
    1071 end;
    1072 
    1073 procedure TCoolDockClientPanel.ResizeExecute(Sender: TObject);
    1074 begin
    1075   Control.Top := GrabberSize;
    1076   Control.Left := 0;
    1077   Control.Width := Width;
    1078   Control.Height := Height - GrabberSize;
    1079   //Control.SetBounds(0, GrabberSize, Width - Control.Left,
    1080   //  Height - Control.Top);
    1081 end;
    1082 
    1083 procedure TCoolDockClientPanel.DockPanelPaint(Sender: TObject);
    1084 var
    1085   I: Integer;
    1086   R: TRect;
    1087 begin
    1088   if not (csDesigning in ComponentState) then
    1089   if Assigned(Control) then begin
    1090     R := Control.ClientRect;
    1091     Canvas.FillRect(R);
    1092     Header.Visible := ShowHeader;
    1093     if ShowHeader then begin
    1094       if ClientAreaPanel.DockClientCount = 0 then
    1095         Header.DrawGrabber(Canvas, Control) else
    1096       Header.DrawGrabber(Canvas, ClientAreaPanel);
    1097     end;
    1098   end;
    1099 end;
    1100 
    1101 procedure TCoolDockClientPanel.DockPanelMouseDown(Sender: TObject;
    1102   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    1103 begin
    1104   if Control is TForm then begin
    1105     //TForm(Control).SetFocus;
    1106     DockPanelPaint(Self);
    1107   end;
    1108   if (Button = mbLeft) then begin
    1109     //(Control as TWinControl).DockSite := False;
    1110     ClientAreaPanel.DockSite := False;
    1111     (Control as TWinControl).BeginDrag(False, 10);
    1112     //DragManager.DragStart(Control, False, 1);
    1113   end;
    1114 end;
    1115734
    1116735{ TCoolDockConjoinForm }
     
    1314933    FClients.Remove(Client);
    1315934  end;
    1316 end;
    1317 
    1318 { TCoolDockHeader }
    1319 
    1320 constructor TCoolDockHeader.Create(TheOwner: TComponent);
    1321 begin
    1322   inherited Create(TheOwner);
    1323   Shape := TShape.Create(Self);
    1324   with Shape do begin
    1325     Parent := Self;
    1326     Anchors := [akRight, akBottom, akLeft, akTop];
    1327     Left := 1;
    1328     Top := 1;
    1329     Width := Self.Width - 2;
    1330     Height := Self.Height - 2;
    1331     Brush.Style := bsClear;
    1332   end;
    1333   CloseButton := TSpeedButton.Create(Self);
    1334   with CloseButton do begin
    1335     Parent := Self;
    1336     Caption := 'X';
    1337     Font.Size := 6;
    1338     Width := GrabberSize - 8;
    1339     Height := GrabberSize - 8;
    1340     Anchors := [akRight, akTop];
    1341     Left := Self.Width - Width - 4;
    1342     Top := 4;
    1343     Visible := True;
    1344     OnClick := CloseButtonClick;
    1345   end;
    1346   Title := TLabel.Create(Self);
    1347   with Title do begin
    1348     Parent := Self;
    1349     Visible := True;
    1350     Top := 4;
    1351     Left := 6;
    1352     BevelInner := bvNone;
    1353     BevelOuter := bvNone;
    1354   end;
    1355   Icon := TImage.Create(Self);
    1356   with Icon do begin
    1357     Parent := Self;
    1358     Left := 4;
    1359     Top := 2;
    1360     Visible := True;
    1361   end;
    1362 end;
    1363 
    1364 destructor TCoolDockHeader.Destroy;
    1365 begin
    1366   inherited Destroy;
    1367 end;
    1368 
    1369 procedure TCoolDockHeader.DrawGrabber(Canvas: TCanvas; AControl: TControl);
    1370 begin
    1371   with Canvas do begin
    1372     Brush.Color := clBtnFace;
    1373     Pen.Color := clBlack;
    1374     //FillRect(0, 0, AControl.Width, GrabberSize);
    1375 
    1376     if (AControl as TWinControl).Focused then
    1377       Title.Font.Style := Font.Style + [fsBold]
    1378       else Title.Font.Style := Font.Style - [fsBold];
    1379     Rectangle(1, 1, AControl.Width - 1, GrabberSize - 1);
    1380     if Icon.Picture.Width > 0 then Title.Left := 8 + Icon.Picture.Width
    1381       else Title.Left := 6;
    1382     Title.Caption := AControl.Caption;
    1383   end;
    1384 end;
    1385 
    1386 procedure TCoolDockHeader.CloseButtonClick(Sender: TObject);
    1387 begin
    1388   ParentClientPanel.Control.Hide;
    1389935end;
    1390936
     
    15391085end;
    15401086
    1541 { TCoolDockAutoHide }
    1542 
    1543 procedure TCoolDockAutoHide.UpdateBounds;
    1544 begin
    1545   case TabPosition of
    1546     tpBottom: begin
    1547       Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);
    1548       Control.Top := StartBounds.Bottom - Control.Height;
    1549     end;
    1550     tpTop: begin
    1551       Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);
    1552     end;
    1553     tpRight: begin
    1554       Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);
    1555     end;
    1556     tpLeft: begin
    1557       Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);
    1558       Control.Left := StartBounds.Right - Control.Width;
    1559     end;
    1560   end;
    1561 end;
    1562 
    1563 procedure TCoolDockAutoHide.UpdateTimerInterval;
    1564 begin
    1565   Timer.Interval := Round(FDuration * 1000 / FStepCount);
    1566 end;
    1567 
    1568 procedure TCoolDockAutoHide.SetDuration(const AValue: Real);
    1569 begin
    1570   if FDuration = AValue then Exit;
    1571   FDuration := AValue;
    1572   UpdateTimerInterval;
    1573 end;
    1574 
    1575 procedure TCoolDockAutoHide.SetStepCount(const AValue: Integer);
    1576 begin
    1577   if FStepCount = AValue then Exit;
    1578   FStepCount := AValue;
    1579   UpdateTimerInterval;
    1580 end;
    1581 
    1582 procedure TCoolDockAutoHide.Hide;
    1583 begin
    1584   StartBounds := Control.BoundsRect;
    1585   Direction := -1;
    1586   Position := 1;
    1587   Timer.Enabled := True;
    1588   UpdateBounds;
    1589 end;
    1590 
    1591 procedure TCoolDockAutoHide.Show;
    1592 begin
    1593   StartBounds := Control.BoundsRect;
    1594   Control.Align := alCustom;
    1595   Direction := 1;
    1596   Position := 0;
    1597   Timer.Enabled := True;
    1598   UpdateBounds;
    1599 end;
    1600 
    1601 constructor TCoolDockAutoHide.Create;
    1602 begin
    1603   Timer := TTimer.Create(nil);
    1604   Timer.Enabled := False;
    1605   Timer.OnTimer := TimerExecute;
    1606   StepCount := AutoHideStepCount;
    1607   Duration := 0.5;
    1608 end;
    1609 
    1610 destructor TCoolDockAutoHide.Destroy;
    1611 begin
    1612   Timer.Free;
    1613   inherited Destroy;
    1614 end;
    1615 
    1616 procedure TCoolDockAutoHide.TimerExecute(Sender: TObject);
    1617 begin
    1618   if Direction = 1 then begin
    1619     Position := Position + 1 / StepCount;
    1620     if Position > 1 then begin
    1621       Position := 1;
    1622       Timer.Enabled := False;
    1623       ControlVisible := True;
    1624     end;
    1625   end else
    1626   if Direction = -1 then begin
    1627     Position := Position - 1 / StepCount;
    1628     if Position < 1 then begin
    1629       Position := 0;
    1630       Timer.Enabled := False;
    1631       ControlVisible := False;
    1632     end;
    1633   end;
    1634   UpdateBounds;
    1635 end;
    16361087
    16371088end.
Note: See TracChangeset for help on using the changeset viewer.