Ignore:
Timestamp:
Sep 21, 2010, 8:03:17 AM (14 years ago)
Author:
george
Message:
  • Přidáno: Okno pro zobrazení seznamu všech oken.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDocking.pas

    r55 r56  
    1010  Classes, SysUtils, Controls, LCLType, LMessages, Graphics, StdCtrls,
    1111  Buttons, ExtCtrls, Contnrs, Forms, ComCtrls, Dialogs, Menus, FileUtil,
    12   UCoolDockCustomize, DOM, XMLWrite, XMLRead;
     12  UCoolDockCustomize, DOM, XMLWrite, XMLRead, UCoolDockWindowList;
    1313
    1414const
     
    2121  TCoolDockManager = class;
    2222  TCoolDockClientPanel = class;
     23  TCoolDockCustomize = class;
    2324
    2425  { TCoolDockConjoinForm }
     
    5657    procedure SetHeaderPos(const AValue: THeaderPos);
    5758    procedure SetShowHeader(const AValue: Boolean);
     59    procedure VisibleChange(Sender: TObject);
    5860  public
    5961    Header: TCoolDockHeader;
     
    8082    FTabsPos: THeaderPos;
    8183    Timer1: TTimer;
    82     PopupMenu1: TPopupMenu;
     84    PopupMenuTabs: TPopupMenu;
     85    PopupMenuHeader: TPopupMenu;
    8386    FDockStyle: TDockStyle;
    8487    TabControl: TTabControl;
     
    105108    procedure PopupMenuPositionBottomClick(Sender: TObject);
    106109    procedure PopupMenuUndockClick(Sender: TObject);
     110    procedure PopupMenuCustomizeClick(Sender: TObject);
    107111    procedure Timer1Timer(Sender: TObject);
    108112    procedure TabControlMouseDown(Sender: TObject; Button: TMouseButton;
     
    143147  TCoolDockMaster = class(TComponent)
    144148  private
     149    FCoolDockCustomize: TCoolDockCustomize;
    145150    FDefaultHeaderPos: THeaderPos;
    146151    FTabsEnabled: Boolean;
     152    procedure SetCustomize(const AValue: TCoolDockCustomize);
    147153    procedure SetTabsEnabled(const AValue: Boolean);
    148154  public
     
    155161    property DefaultHeaderPos: THeaderPos read FDefaultHeaderPos
    156162      write FDefaultHeaderPos;
     163    property Customize: TCoolDockCustomize read FCoolDockCustomize
     164      write SetCustomize;
     165  end;
     166
     167  { TCoolDockCustomize }
     168
     169  TCoolDockCustomize = class(TComponent)
     170  private
     171    FManager: TCoolDockMaster;
     172    procedure SetManager(const AValue: TCoolDockMaster);
     173  public
     174    Form: TCoolDockCustomizeForm;
     175    function Execute: Boolean;
     176    constructor Create(AOwner: TComponent); override;
     177  published
     178    property Manager: TCoolDockMaster read FManager write SetManager;
     179  end;
     180
     181  { TCoolDockWindowList }
     182
     183  TCoolDockWindowList = class(TComponent)
     184  private
     185  public
     186    Form: TCoolDockWindowListForm;
     187    function Execute: Boolean;
     188    constructor Create(AOwner: TComponent); override;
     189  published
    157190  end;
    158191
     
    174207  SPositionBottom = 'Bottom';
    175208  SUndock = 'Undock';
     209  SCustomize = 'Customize...';
    176210
    177211procedure Register;
     
    179213  RegisterComponents('CoolDocking', [TCoolDockMaster]);
    180214  RegisterComponents('CoolDocking', [TCoolDockCustomize]);
     215  RegisterComponents('CoolDocking', [TCoolDockWindowList]);
    181216end;
    182217
     
    204239  FDockSite := ADockSite;
    205240  FDockPanels := TObjectList.Create;
    206   PopupMenu1 := TPopupMenu.Create(FDockSite);
    207241
    208242  Timer1 := TTimer.Create(nil);
     
    210244  Timer1.OnTimer := Timer1Timer;
    211245
    212   NewMenuItem := TMenuItem.Create(PopupMenu1);
     246  // Tabs popup
     247
     248  PopupMenuTabs := TPopupMenu.Create(FDockSite);
     249
     250  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    213251  NewMenuItem.Caption := SDockStyle;
    214   PopupMenu1.Items.Add(NewMenuItem);
     252  PopupMenuTabs.Items.Add(NewMenuItem);
    215253
    216254  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     
    224262  NewMenuItem.Add(NewMenuItem2);
    225263
    226   NewMenuItem := TMenuItem.Create(PopupMenu1);
     264  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    227265  NewMenuItem.Caption := SPosition;
    228   PopupMenu1.Items.Add(NewMenuItem);
     266  PopupMenuTabs.Items.Add(NewMenuItem);
    229267
    230268  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     
    253291  NewMenuItem.Add(NewMenuItem2);
    254292
    255   NewMenuItem := TMenuItem.Create(PopupMenu1);
     293  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    256294  NewMenuItem.Caption := SCloseForm;
    257295  NewMenuItem.OnClick := PopupMenuCloseClick;
    258   PopupMenu1.Items.Add(NewMenuItem);
    259 
    260   NewMenuItem := TMenuItem.Create(PopupMenu1);
     296  PopupMenuTabs.Items.Add(NewMenuItem);
     297
     298  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    261299  NewMenuItem.Caption := SRenameForm;
    262300  NewMenuItem.OnClick := PopupMenuRenameClick;
    263   PopupMenu1.Items.Add(NewMenuItem);
    264 
    265   NewMenuItem := TMenuItem.Create(PopupMenu1);
     301  PopupMenuTabs.Items.Add(NewMenuItem);
     302
     303  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    266304  NewMenuItem.Caption := SUndock;
    267305  NewMenuItem.OnClick := PopupMenuUndockClick;
    268   PopupMenu1.Items.Add(NewMenuItem);
     306  PopupMenuTabs.Items.Add(NewMenuItem);
     307
     308  NewMenuItem := TMenuItem.Create(PopupMenuTabs);
     309  NewMenuItem.Caption := SCustomize;
     310  NewMenuItem.OnClick := PopupMenuCustomizeClick;
     311  PopupMenuTabs.Items.Add(NewMenuItem);
     312
     313  // Header popup
     314
     315  PopupMenuHeader := TPopupMenu.Create(FDockSite);
     316
     317  NewMenuItem := TMenuItem.Create(PopupMenuHeader);
     318  NewMenuItem.Caption := SDockStyle;
     319  PopupMenuHeader.Items.Add(NewMenuItem);
     320
     321  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     322  NewMenuItem2.Caption := SDockList;
     323  NewMenuItem2.OnClick := PopupMenuListClick;
     324  NewMenuItem.Add(NewMenuItem2);
     325
     326  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     327  NewMenuItem2.Caption := SDockTabs;
     328  NewMenuItem2.OnClick := PopupMenuTabsClick;
     329  NewMenuItem.Add(NewMenuItem2);
     330
     331  NewMenuItem := TMenuItem.Create(PopupMenuHeader);
     332  NewMenuItem.Caption := SPosition;
     333  PopupMenuHeader.Items.Add(NewMenuItem);
     334
     335  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     336  NewMenuItem2.Caption := SPositionAuto;
     337  NewMenuItem2.OnClick := PopupMenuPositionAutoClick;
     338  NewMenuItem.Add(NewMenuItem2);
     339
     340  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     341  NewMenuItem2.Caption := SPositionTop;
     342  NewMenuItem2.OnClick := PopupMenuPositionTopClick;
     343  NewMenuItem.Add(NewMenuItem2);
     344
     345  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     346  NewMenuItem2.Caption := SPositionLeft;
     347  NewMenuItem2.OnClick := PopupMenuPositionLeftClick;
     348  NewMenuItem.Add(NewMenuItem2);
     349
     350  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     351  NewMenuItem2.Caption := SPositionBottom;
     352  NewMenuItem2.OnClick := PopupMenuPositionBottomClick;
     353  NewMenuItem.Add(NewMenuItem2);
     354
     355  NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     356  NewMenuItem2.Caption := SPositionRight;
     357  NewMenuItem2.OnClick := PopupMenuPositionRightClick;
     358  NewMenuItem.Add(NewMenuItem2);
     359
     360  NewMenuItem := TMenuItem.Create(PopupMenuHeader);
     361  NewMenuItem.Caption := SCloseForm;
     362  NewMenuItem.OnClick := PopupMenuCloseClick;
     363  PopupMenuHeader.Items.Add(NewMenuItem);
     364
     365  NewMenuItem := TMenuItem.Create(PopupMenuHeader);
     366  NewMenuItem.Caption := SRenameForm;
     367  NewMenuItem.OnClick := PopupMenuRenameClick;
     368  PopupMenuHeader.Items.Add(NewMenuItem);
     369
     370  NewMenuItem := TMenuItem.Create(PopupMenuHeader);
     371  NewMenuItem.Caption := SUndock;
     372  NewMenuItem.OnClick := PopupMenuUndockClick;
     373  PopupMenuHeader.Items.Add(NewMenuItem);
     374
     375  NewMenuItem := TMenuItem.Create(PopupMenuHeader);
     376  NewMenuItem.Caption := SCustomize;
     377  NewMenuItem.OnClick := PopupMenuCustomizeClick;
     378  PopupMenuHeader.Items.Add(NewMenuItem);
    269379
    270380  TabControl := TTabControl.Create(FDockSite);
     
    275385    Height := 24;
    276386    OnChange := TabControlChange;
    277     PopupMenu := PopupMenu1;
     387    PopupMenu := PopupMenuTabs;
    278388    OnMouseDown := TabControlMouseDown;
    279389  end;
     
    357467      if DockStyle = dsList then Visible := True;
    358468      Align := alClient;
     469      Header.PopupMenu := PopupMenuHeader;
    359470    end;
    360471
     
    368479    end;
    369480    NewPanel.Control := Control;
     481    Control.AddHandlerOnVisibleChanged(NewPanel.VisibleChange);
    370482    Control.Parent := NewPanel.ClientAreaPanel;
    371483    Control.Align := alClient;
     
    596708    for I := 0 to FDockPanels.Count - 1 do begin
    597709      TCoolDockClientPanel(FDockPanels[I]).Height := FDockSite.Height div
    598         FDockSite.DockClientCount;
     710        FDockSite.VisibleDockClientCount;
    599711      TCoolDockClientPanel(FDockPanels[I]).Width := FDockSite.Width div
    600         FDockSite.DockClientCount;
     712        FDockSite.VisibleDockClientCount;
    601713      //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    602714    end;
     
    644756
    645757procedure TCoolDockManager.PopupMenuCloseClick(Sender: TObject);
    646 begin
    647   TForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close;
     758var
     759  Control: TControl;
     760begin
     761  Control := FindLCLControl(Mouse.CursorPos);
     762  if Assigned(Control) then
     763    ShowMessage(Control.ClassName);
     764//  DockSiteTForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close;
    648765end;
    649766
     
    687804begin
    688805
     806end;
     807
     808procedure TCoolDockManager.PopupMenuCustomizeClick(Sender: TObject);
     809begin
     810//  if Assigned(DockMaster.Customize) then
     811//    DockMaster.Customize.Execute;
    689812end;
    690813
     
    714837  FShowHeader := AValue;
    715838  DockPanelPaint(Self);
     839end;
     840
     841procedure TCoolDockClientPanel.VisibleChange(Sender: TObject);
     842begin
     843  //OwnerDockManager.FDockPanels.Remove(Self);
     844  ClientAreaPanel.Visible := Control.Visible;
     845  Splitter.Visible := Control.Visible;
     846  OwnerDockManager.UpdateClientSize;
    716847end;
    717848
     
    737868    Align := alTop;
    738869    Height := GrabberSize;
     870    ParentClientPanel := Self;
    739871  end;
    740872  ClientAreaPanel := TPanel.Create(Self);
     
    832964  if FTabsEnabled=AValue then exit;
    833965  FTabsEnabled:=AValue;
     966end;
     967
     968procedure TCoolDockMaster.SetCustomize(const AValue: TCoolDockCustomize
     969  );
     970begin
     971  if FCoolDockCustomize=AValue then exit;
     972  FCoolDockCustomize:=AValue;
     973  if Assigned(AValue) then
     974    if not Assigned(AValue.Manager) then
     975      AValue.Manager := Self;
    834976end;
    835977
     
    9981140procedure TCoolDockHeader.CloseButtonClick(Sender: TObject);
    9991141begin
    1000 //  Control.Hide;
     1142  ParentClientPanel.Control.Hide;
     1143end;
     1144
     1145{ TCoolDockCustomize }
     1146
     1147procedure TCoolDockCustomize.SetManager(const AValue: TCoolDockMaster);
     1148begin
     1149  if FManager = AValue then exit;
     1150  FManager := AValue;
     1151  if Assigned(AValue) then
     1152    if not Assigned(AValue.Customize) then
     1153      AValue.Customize := Self;
     1154end;
     1155
     1156function TCoolDockCustomize.Execute: Boolean;
     1157begin
     1158  Form.ShowModal;
     1159  Result := True;
     1160end;
     1161
     1162constructor TCoolDockCustomize.Create(AOwner: TComponent);
     1163begin
     1164  inherited Create(AOwner);
     1165  Form := TCoolDockCustomizeForm.Create(Self);
     1166end;
     1167
     1168
     1169{ TCoolDockWindowList }
     1170
     1171function TCoolDockWindowList.Execute: Boolean;
     1172begin
     1173  Form.ShowModal;
     1174  Result := True;
     1175end;
     1176
     1177constructor TCoolDockWindowList.Create(AOwner: TComponent);
     1178begin
     1179  inherited Create(AOwner);
     1180  Form := TCoolDockWindowListForm.Create(Self);
    10011181end;
    10021182
Note: See TracChangeset for help on using the changeset viewer.