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/UCoolDockStylePopupTabs.pas

    r89 r97  
    1 unit UCoolDockStylePopupTabs; 
    2 
    3 {$mode objfpc}{$H+}
     1unit UCoolDockStylePopupTabs;
     2
     3{$mode Delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils;
     8  Classes, Controls, SysUtils, ComCtrls, ExtCtrls,
     9  UCoolDockStyleTabs, UCoolDockStyle;
     10
     11type
     12  { TCoolDockAutoHide }
     13
     14  TCoolDockAutoHide = class
     15  private
     16    FDuration: Real;
     17    FStepCount: Integer;
     18    StartBounds: TRect;
     19    procedure SetDuration(const AValue: Real);
     20    procedure SetStepCount(const AValue: Integer);
     21    procedure UpdateBounds;
     22    procedure UpdateTimerInterval;
     23  public
     24    Position: Real;
     25    Direction: Integer;
     26    TabPosition: TTabPosition;
     27    Enable: Boolean;
     28    Timer: TTimer;
     29    Control: TControl;
     30    ControlVisible: Boolean;
     31    procedure Hide;
     32    procedure Show;
     33    constructor Create;
     34    destructor Destroy; override;
     35    procedure TimerExecute(Sender: TObject);
     36    property Duration: Real read FDuration write SetDuration;
     37    property StepCount: Integer read FStepCount write SetStepCount;
     38  end;
     39
     40  { TCoolDockStylePopupTabs }
     41
     42  TCoolDockStylePopupTabs = class(TCoolDockStyleTabs)
     43    TabControl: TTabControl;
     44    TabImageList: TImageList;
     45    AutoHide: TCoolDockAutoHide;
     46    procedure TabControlMouseLeave(Sender: TObject);
     47    procedure TabControlChange(Sender: TObject);
     48    procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton;
     49      Shift: TShiftState; X, Y: Integer);
     50    procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton;
     51      Shift: TShiftState; X, Y: Integer);
     52    constructor Create(AManager: TObject);
     53    destructor Destroy; override;
     54  end;
     55
    956
    1057implementation
    1158
     59uses
     60  UCoolDocking;
     61
     62{ TCoolDockAutoHide }
     63
     64procedure TCoolDockAutoHide.UpdateBounds;
     65begin
     66  case TabPosition of
     67    tpBottom: begin
     68      Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);
     69      Control.Top := StartBounds.Bottom - Control.Height;
     70    end;
     71    tpTop: begin
     72      Control.Height := Round((StartBounds.Bottom - StartBounds.Top) * Position);
     73    end;
     74    tpRight: begin
     75      Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);
     76    end;
     77    tpLeft: begin
     78      Control.Width := Round((StartBounds.Right - StartBounds.Left) * Position);
     79      Control.Left := StartBounds.Right - Control.Width;
     80    end;
     81  end;
     82end;
     83
     84procedure TCoolDockAutoHide.UpdateTimerInterval;
     85begin
     86  Timer.Interval := Round(FDuration * 1000 / FStepCount);
     87end;
     88
     89procedure TCoolDockAutoHide.SetDuration(const AValue: Real);
     90begin
     91  if FDuration = AValue then Exit;
     92  FDuration := AValue;
     93  UpdateTimerInterval;
     94end;
     95
     96procedure TCoolDockAutoHide.SetStepCount(const AValue: Integer);
     97begin
     98  if FStepCount = AValue then Exit;
     99  FStepCount := AValue;
     100  UpdateTimerInterval;
     101end;
     102
     103procedure TCoolDockAutoHide.Hide;
     104begin
     105  StartBounds := Control.BoundsRect;
     106  Direction := -1;
     107  Position := 1;
     108  Timer.Enabled := True;
     109  UpdateBounds;
     110end;
     111
     112procedure TCoolDockAutoHide.Show;
     113begin
     114  StartBounds := Control.BoundsRect;
     115  Control.Align := alCustom;
     116  Direction := 1;
     117  Position := 0;
     118  Timer.Enabled := True;
     119  UpdateBounds;
     120end;
     121
     122constructor TCoolDockAutoHide.Create;
     123begin
     124  Timer := TTimer.Create(nil);
     125  Timer.Enabled := False;
     126  Timer.OnTimer := TimerExecute;
     127  StepCount := 10;
     128  Duration := 0.5;
     129end;
     130
     131destructor TCoolDockAutoHide.Destroy;
     132begin
     133  Timer.Free;
     134  inherited Destroy;
     135end;
     136
     137procedure TCoolDockAutoHide.TimerExecute(Sender: TObject);
     138begin
     139  if Direction = 1 then begin
     140    Position := Position + 1 / StepCount;
     141    if Position > 1 then begin
     142      Position := 1;
     143      Timer.Enabled := False;
     144      ControlVisible := True;
     145    end;
     146  end else
     147  if Direction = -1 then begin
     148    Position := Position - 1 / StepCount;
     149    if Position < 1 then begin
     150      Position := 0;
     151      Timer.Enabled := False;
     152      ControlVisible := False;
     153    end;
     154  end;
     155  UpdateBounds;
     156end;
     157
     158{ TCoolDockStylePopupTabs }
     159
     160procedure TCoolDockStylePopupTabs.TabControlMouseLeave(Sender: TObject);
     161begin
     162
     163end;
     164
     165procedure TCoolDockStylePopupTabs.TabControlChange(Sender: TObject);
     166begin
     167
     168end;
     169
     170procedure TCoolDockStylePopupTabs.TabControlMouseDown(Sender: TObject;
     171  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     172begin
     173
     174end;
     175
     176procedure TCoolDockStylePopupTabs.TabControlMouseUp(Sender: TObject;
     177  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     178begin
     179
     180end;
     181
     182constructor TCoolDockStylePopupTabs.Create(AManager: TObject);
     183begin
     184  AutoHide := TCoolDockAutoHide.Create;
     185  TabImageList := TImageList.Create(TCoolDockManager(AManager).DockSite);
     186  with TabImageList do begin
     187  end;
     188  TabControl := TTabControl.Create(TCoolDockManager(AManager).DockSite);
     189  with TabControl do begin
     190    Parent := TCoolDockManager(AManager).DockSite;
     191    Visible := False;
     192    Align := alTop;
     193    Height := 24;
     194    OnChange := TabControlChange;
     195    PopupMenu := PopupMenuTabs;
     196    TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave;
     197    TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseDown := TabControlMouseDown;
     198    TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseUp := TabControlMouseUp;
     199    OnMouseUp := TabControlMouseUp;
     200    Images := TabImageList;
     201  end;
     202end;
     203
     204destructor TCoolDockStylePopupTabs.Destroy;
     205begin
     206  AutoHide.Free;
     207  inherited Destroy;
     208end;
     209
    12210end.
    13211
Note: See TracChangeset for help on using the changeset viewer.