Ignore:
Timestamp:
Sep 17, 2010, 4:16:15 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Částečná podpora pro volitelné umístění záložek.
  • Přidáno: Částečná podpora pro vysouvatelná okna v záložkách.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DockManager/Lazarus/UCustomDockManager.pas

    r48 r49  
    3333  TDockClientPanel = class(TPanel)
    3434  private
     35    FAutoHide: Boolean;
     36    FHeaderPos: THeaderPos;
    3537    FShowHeader: Boolean;
     38    procedure SetAutoHide(const AValue: Boolean);
     39    procedure SetHeaderPos(const AValue: THeaderPos);
    3640    procedure SetShowHeader(const AValue: Boolean);
    3741  public
     
    5054    procedure ResizeExecute(Sender: TObject);
    5155    property ShowHeader: Boolean read FShowHeader write SetShowHeader;
     56    property AutoHide: Boolean read FAutoHide write SetAutoHide;
     57    property HeaderPos: THeaderPos read FHeaderPos write SetHeaderPos;
    5258  end;
    5359
     
    5662  TCustomDockManager = class(TDockManager)
    5763  private
     64    FMoveDuration: Integer;
     65    FTabsPos: THeaderPos;
     66    Timer1: TTimer;
    5867    PopupMenu1: TPopupMenu;
    5968    FDockStyle: TDockStyle;
     
    6675      DropCtl: TControl);
    6776    procedure SetDockStyle(const AValue: TDockStyle);
     77    procedure SetMoveDuration(const AValue: Integer);
     78    procedure SetTabsPos(const AValue: THeaderPos);
    6879    procedure UpdateClientSize;
    6980    procedure TabControlChange(Sender: TObject);
    7081    procedure PopupMenuListClick(Sender: TObject);
    7182    procedure PopupMenuTabsClick(Sender: TObject);
     83    procedure PopupMenuCloseClick(Sender: TObject);
     84    procedure PopupMenuRenameClick(Sender: TObject);
     85    procedure Timer1Timer(Sender: TObject);
    7286  public
    7387    constructor Create(ADockSite: TWinControl); override;
     
    95109    function CreateContainer(InsertAt: TAlign): TConjoinDockForm;
    96110    property DockStyle: TDockStyle read FDockStyle write SetDockStyle;
     111    property MoveDuration: Integer read FMoveDuration write SetMoveDuration;
     112    property TabsPos: THeaderPos read FTabsPos write SetTabsPos;
    97113  end;
    98114
     
    119135implementation
    120136
     137resourcestring
     138  SDockStyle = 'Style';
     139  SDockList = 'List';
     140  SDockTabs = 'Tabs';
     141  SCloseForm = 'Close';
     142  SRenameForm = 'Rename';
     143
     144
    121145procedure Register;
    122146begin
     
    142166var
    143167  NewMenuItem: TMenuItem;
     168  NewMenuItem2: TMenuItem;
    144169begin
    145170  inherited Create(ADockSite);
     
    147172  FDockPanels := TObjectList.Create;
    148173  PopupMenu1 := TPopupMenu.Create(FDockSite);
     174
     175  Timer1 := TTimer.Create(nil);
     176  Timer1.Enabled := False;
     177  Timer1.OnTimer := Timer1Timer;
     178
    149179  NewMenuItem := TMenuItem.Create(PopupMenu1);
    150   NewMenuItem.Caption := 'List';
     180  NewMenuItem.Caption := SDockStyle;
    151181  PopupMenu1.Items.Add(NewMenuItem);
    152   NewMenuItem.OnClick := PopupMenuListClick;
     182
     183  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     184  NewMenuItem2.Caption := SDockList;
     185  NewMenuItem2.OnClick := PopupMenuListClick;
     186  NewMenuItem.Add(NewMenuItem2);
     187
     188  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     189  NewMenuItem2.Caption := SDockTabs;
     190  NewMenuItem2.OnClick := PopupMenuTabsClick;
     191  NewMenuItem.Add(NewMenuItem2);
     192
    153193  NewMenuItem := TMenuItem.Create(PopupMenu1);
    154   NewMenuItem.Caption := 'Tabs';
    155   NewMenuItem.OnClick := PopupMenuTabsClick;
     194  NewMenuItem.Caption := SCloseForm;
     195  NewMenuItem.OnClick := PopupMenuCloseClick;
    156196  PopupMenu1.Items.Add(NewMenuItem);
     197
     198  NewMenuItem := TMenuItem.Create(PopupMenu1);
     199  NewMenuItem.Caption := SRenameForm;
     200  NewMenuItem.OnClick := PopupMenuRenameClick;
     201  PopupMenu1.Items.Add(NewMenuItem);
     202
    157203  TabControl := TTabControl.Create(FDockSite);
    158204  with TabControl do begin
     
    164210    PopupMenu := PopupMenu1;
    165211  end;
     212  TabsPos := hpTop;
     213  MoveDuration := 1000; // ms
    166214end;
    167215
    168216destructor TCustomDockManager.Destroy;
    169217begin
     218  Timer1.Free;
    170219  FDockPanels.Free;
    171220  inherited Destroy;
     
    431480end;
    432481
     482procedure TCustomDockManager.SetMoveDuration(const AValue: Integer);
     483begin
     484  if FMoveDuration=AValue then exit;
     485  FMoveDuration := AValue;
     486  //Timer1.Interval := AValue;
     487end;
     488
     489procedure TCustomDockManager.SetTabsPos(const AValue: THeaderPos);
     490begin
     491  if FTabsPos=AValue then exit;
     492  FTabsPos := AValue;
     493  with TabControl do
     494  case AValue of
     495    hpAuto, hpTop: begin
     496      Align := alTop;
     497      TabPosition := tpTop;
     498      Height := GrabberSize;
     499    end;
     500    hpLeft: begin
     501      Align := alLeft;
     502      TabPosition := tpLeft;
     503      Width := GrabberSize;
     504    end;
     505    hpRight: begin
     506      Align := alRight;
     507      TabPosition := tpRight;
     508      Width := GrabberSize;
     509    end;
     510    hpBottom: begin
     511      Align := alBottom;
     512      TabPosition := tpBottom;
     513      Height := GrabberSize;
     514    end;
     515  end;
     516end;
     517
    433518procedure TCustomDockManager.UpdateClientSize;
    434519var
     
    461546  end;
    462547  if (TabControl.TabIndex <> -1) and (FDockPanels.Count > TabControl.TabIndex) then begin
    463     with TDockClientPanel(FDockPanels[TabControl.TabIndex]).ClientAreaPanel do begin
    464       Parent := FDockSite;
    465       Visible := True;
    466       UpdateClientSize;
     548    with TDockClientPanel(FDockPanels[TabControl.TabIndex]), ClientAreaPanel do begin
     549      if AutoHide then begin
     550        Parent := nil;
     551        Visible := True;
     552        Width := 0;
     553        //TimerMoveForm :=
     554        //TimerIncrement := 1;
     555        Timer1.Interval := MoveDuration div 10;
     556        Timer1.Enabled := True;
     557      end else begin
     558        Parent := FDockSite;
     559        Visible := True;
     560        UpdateClientSize;
     561      end;
    467562    end;
    468563//  TDockClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True;
     
    473568begin
    474569  DockStyle := dsTabs;
     570end;
     571
     572procedure TCustomDockManager.PopupMenuCloseClick(Sender: TObject);
     573begin
     574//  TForm(TCustomDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close;
     575end;
     576
     577procedure TCustomDockManager.PopupMenuRenameClick(Sender: TObject);
     578begin
     579
     580end;
     581
     582procedure TCustomDockManager.Timer1Timer(Sender: TObject);
     583begin
     584//  TimerMoveForm.Width := TimerMoveForm.Width
    475585end;
    476586
     
    487597  FShowHeader := AValue;
    488598  DockPanelPaint(Self);
     599end;
     600
     601procedure TDockClientPanel.SetAutoHide(const AValue: Boolean);
     602begin
     603  if FAutoHide=AValue then exit;
     604  FAutoHide:=AValue;
     605end;
     606
     607procedure TDockClientPanel.SetHeaderPos(const AValue: THeaderPos);
     608begin
     609  if FHeaderPos=AValue then exit;
     610  FHeaderPos:=AValue;
    489611end;
    490612
     
    527649  BevelOuter := bvNone;
    528650  ShowHeader := True;
     651  AutoHide := False;
     652  HeaderPos := hpTop;
    529653end;
    530654
Note: See TracChangeset for help on using the changeset viewer.