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

    r89 r97  
    11unit UCoolDockStyleTabs;
    22
    3 {$mode objfpc}{$H+}
     3{$mode Delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, UCoolDocking;
     8  Classes, Controls, ExtCtrls, ComCtrls, SysUtils,
     9  Menus, UCoolDockStyle, Forms, UCoolDockClientPanel;
    910
    1011type
     12
     13  { TCoolDockStyleTabs }
     14
    1115  TCoolDockStyleTabs = class(TCoolDockStyle)
    12 
     16    MouseDown: Boolean;
     17    MouseButton: TMouseButton;
     18    MouseDownSkip: Boolean;
     19    TabControl: TTabControl;
     20    TabImageList: TImageList;
     21    PopupMenuTabs: TPopupMenu;
     22    procedure TabControlMouseLeave(Sender: TObject);
     23    procedure TabControlChange(Sender: TObject);
     24    procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton;
     25      Shift: TShiftState; X, Y: Integer);
     26    procedure TabControlMouseUp(Sender: TObject; Button: TMouseButton;
     27      Shift: TShiftState; X, Y: Integer);
     28    constructor Create(AManager: TObject);
     29    destructor Destroy; override;
     30    procedure InsertControl(NewPanel: TCoolDockClientPanel;
     31      AControl: TControl; InsertAt: TAlign); override;
     32    procedure UpdateClientSize; override;
     33  private
     34    FTabsPos: THeaderPos;
     35  public
     36    procedure SetTabsPos(const AValue: THeaderPos);
     37    procedure PopupMenuTabCloseClick(Sender: TObject);
     38    property TabsPos: THeaderPos read FTabsPos write SetTabsPos;
    1339  end;
    1440
    1541implementation
    1642
     43uses
     44  UCoolDocking;
     45
     46{ TCoolDockStyleTabs }
     47
     48procedure TCoolDockStyleTabs.PopupMenuTabCloseClick(Sender: TObject);
     49begin
     50  if TabControl.TabIndex <> -1 then
     51    TCoolDockClientPanel(TCoolDockManager(Manager).DockPanels[TabControl.TabIndex]).Control.Hide;
     52end;
     53
     54procedure TCoolDockStyleTabs.TabControlMouseLeave(Sender: TObject);
     55begin
     56(*  if MouseDown then
     57  if (TabControl.TabIndex <> -1) then begin
     58    TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).ClientAreaPanel.DockSite := False;
     59    DragManager.DragStart(TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Control, False, 1);
     60  end;
     61  MouseDown := False;
     62  *)
     63end;
     64
     65procedure TCoolDockStyleTabs.TabControlChange(Sender: TObject);
     66var
     67  I: Integer;
     68begin
     69  // Hide all clients
     70  with TCoolDockManager(Manager) do
     71  for I := 0 to DockPanels.Count - 1 do begin
     72    TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Visible := False;
     73    TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Parent := DockSite;
     74    TCoolDockClientPanel(DockPanels[I]).Control.Align := alClient;
     75    TCoolDockClientPanel(DockPanels[I]).Control.Visible := False;
     76
     77    // Workaround for "Cannot focus" error
     78    TForm(TCoolDockClientPanel(DockPanels[I]).Control).ActiveControl := nil;
     79  end;
     80  with TCoolDockManager(Manager) do
     81  if (TabControl.TabIndex <> -1) and (DockPanels.Count > TabControl.TabIndex) then begin
     82    with TCoolDockClientPanel(DockPanels[TabControl.TabIndex]), ClientAreaPanel do begin
     83      Control.Show;
     84      (*AutoHide.Enable := True;
     85      if AutoHide.Enable then begin
     86        //Parent := nil;
     87        Visible := True;
     88        if AutoHide.ControlVisible then begin
     89          AutoHide.Hide;
     90        end;
     91        AutoHide.Control := Control;
     92        AutoHide.Show;
     93      end else begin
     94      *)
     95        //Parent := DockSite;
     96        Visible := True;
     97        UpdateClientSize;
     98//      end;
     99    end;
     100  //TCoolDockClientPanel(FDockPanels[TabControl.TabIndex]).Visible := True;
     101  end;
     102  MouseDownSkip := True;
     103end;
     104
     105procedure TCoolDockStyleTabs.TabControlMouseDown(Sender: TObject;
     106  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     107begin
     108  if not MouseDownSkip then begin
     109    MouseDown := True;
     110    MouseButton := Button;
     111  end;
     112  MouseDownSkip := False;
     113end;
     114
     115procedure TCoolDockStyleTabs.TabControlMouseUp(Sender: TObject;
     116  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
     117begin
     118  MouseDown := False;
     119end;
     120
     121constructor TCoolDockStyleTabs.Create(AManager: TObject);
     122var
     123  NewMenuItem: TMenuItem;
     124  NewMenuItem2: TMenuItem;
     125  I: Integer;
     126begin
     127  inherited;
     128
     129  (*// Tabs popup
     130
     131  PopupMenuTabs := TPopupMenu.Create(Manager.DockSite);
     132
     133  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     134  NewMenuItem.Caption := SDockStyle;
     135  PopupMenuTabs.Items.Add(NewMenuItem);
     136
     137  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     138  NewMenuItem2.Caption := SDockList;
     139  NewMenuItem2.OnClick := PopupMenuListClick;
     140  NewMenuItem.Add(NewMenuItem2);
     141
     142  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     143  NewMenuItem2.Caption := SDockTabs;
     144  NewMenuItem2.OnClick := PopupMenuTabsClick;
     145  NewMenuItem.Add(NewMenuItem2);
     146
     147  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     148  NewMenuItem.Caption := SPosition;
     149  PopupMenuTabs.Items.Add(NewMenuItem);
     150
     151  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     152  NewMenuItem2.Caption := SPositionAuto;
     153  NewMenuItem2.OnClick := PopupMenuPositionAutoClick;
     154  NewMenuItem.Add(NewMenuItem2);
     155
     156  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     157  NewMenuItem2.Caption := SPositionTop;
     158  NewMenuItem2.OnClick := PopupMenuPositionTopClick;
     159  NewMenuItem.Add(NewMenuItem2);
     160
     161  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     162  NewMenuItem2.Caption := SPositionLeft;
     163  NewMenuItem2.OnClick := PopupMenuPositionLeftClick;
     164  NewMenuItem.Add(NewMenuItem2);
     165
     166  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     167  NewMenuItem2.Caption := SPositionBottom;
     168  NewMenuItem2.OnClick := PopupMenuPositionBottomClick;
     169  NewMenuItem.Add(NewMenuItem2);
     170
     171  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     172  NewMenuItem2.Caption := SPositionRight;
     173  NewMenuItem2.OnClick := PopupMenuPositionRightClick;
     174  NewMenuItem.Add(NewMenuItem2);
     175
     176  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     177  NewMenuItem.Caption := SCloseForm;
     178  NewMenuItem.OnClick := PopupMenuCloseClick;
     179  PopupMenuTabs.Items.Add(NewMenuItem);
     180
     181  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     182  NewMenuItem.Caption := SRenameForm;
     183  NewMenuItem.OnClick := PopupMenuRenameClick;
     184  PopupMenuTabs.Items.Add(NewMenuItem);
     185
     186  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     187  NewMenuItem.Caption := SUndock;
     188  NewMenuItem.OnClick := PopupMenuUndockClick;
     189  PopupMenuTabs.Items.Add(NewMenuItem);
     190
     191  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     192  NewMenuItem.Caption := SCustomize;
     193  NewMenuItem.OnClick := PopupMenuCustomizeClick;
     194  PopupMenuTabs.Items.Add(NewMenuItem);     *)
     195
     196  TabImageList := TImageList.Create(TCoolDockManager(AManager).DockSite); //FDockSite);
     197  with TabImageList do begin
     198    Name := TCoolDockManager(Manager).DockSite.Name + '_' + 'ImageList';
     199  end;
     200  TabControl := TTabControl.Create(TCoolDockManager(AManager).DockSite); //FDockSite);
     201  with TabControl do begin
     202    Parent := TCoolDockManager(Manager).DockSite;
     203    Name := TCoolDockManager(Manager).DockSite.Name + '_' + 'TabControl';
     204    Visible := False;
     205    Align := alTop;
     206    Height := 24;
     207    OnChange := TabControlChange;
     208    PopupMenu := PopupMenuTabs;
     209    TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave;
     210    TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseDown := TabControlMouseDown;
     211    TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseUp := TabControlMouseUp;
     212    OnMouseUp := TabControlMouseUp;
     213    Images := TabImageList;
     214  end;
     215  //TabsPos := hpTop;
     216  //MoveDuration := 1000; // ms
     217
     218  TabControl.Visible := True;
     219  TabControl.Tabs.Clear;
     220  TabImageList.Clear;
     221  with TCoolDockManager(Manager) do
     222  for I := 0 to DockPanels.Count - 1 do begin
     223    TabControl.Tabs.Add(TCoolDockClientPanel(DockPanels[I]).Control.Caption);
     224    TabImageList.Add(TCoolDockClientPanel(DockPanels[I]).Header.Icon.Picture.Bitmap, nil);
     225    if Assigned(TCoolDockClientPanel(DockPanels[I]).Splitter) then
     226      TCoolDockClientPanel(DockPanels[I]).Splitter.Visible := False;
     227    TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Visible := False;
     228    TCoolDockClientPanel(DockPanels[I]).Visible := False;
     229  end;
     230  TabControlChange(Self);
     231end;
     232
     233destructor TCoolDockStyleTabs.Destroy;
     234begin
     235  TabControl.Visible := False;
     236  TabControl.Tabs.Clear;
     237  inherited Destroy;
     238end;
     239
     240procedure TCoolDockStyleTabs.InsertControl(NewPanel: TCoolDockClientPanel;
     241  AControl: TControl; InsertAt: TAlign);
     242begin
     243  inherited;
     244  TabControl.Tabs.Add(AControl.Caption);
     245  TabImageList.Add(NewPanel.Header.Icon.Picture.Bitmap, nil);
     246  if Assigned(NewPanel.Splitter) then
     247    NewPanel.Splitter.Visible := False;
     248  NewPanel.ClientAreaPanel.Visible := False;
     249  NewPanel.Visible := False;
     250  TabControlChange(Self);
     251end;
     252
     253procedure TCoolDockStyleTabs.UpdateClientSize;
     254var
     255  I: Integer;
     256begin
     257  inherited UpdateClientSize;
     258  with TCoolDockManager(Manager) do
     259  for I := 0 to DockPanels.Count - 1 do begin
     260    TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width;
     261    TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - TabControl.Height;
     262    //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
     263  end;
     264end;
     265
     266procedure TCoolDockStyleTabs.SetTabsPos(const AValue: THeaderPos);
     267begin
     268  (*if FTabsPos = AValue then Exit;
     269  FTabsPos := AValue;
     270  with TabControl do
     271  case AValue of
     272    hpAuto, hpTop: begin
     273      Align := alTop;
     274      TabPosition := tpTop;
     275      Height := GrabberSize;
     276    end;
     277    hpLeft: begin
     278      Align := alLeft;
     279      TabPosition := tpLeft;
     280      Width := GrabberSize;
     281    end;
     282    hpRight: begin
     283      Align := alRight;
     284      TabPosition := tpRight;
     285      Width := GrabberSize;
     286    end;
     287    hpBottom: begin
     288      Align := alBottom;
     289      TabPosition := tpBottom;
     290      Height := GrabberSize;
     291    end;
     292  end;       *)
     293end;
     294
     295
    17296end.
    18297
Note: See TracChangeset for help on using the changeset viewer.