Ignore:
Timestamp:
Dec 9, 2010, 2:51:55 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Obslužné funkce kontextového menu přesunuty do samostatné jednotky.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDocking.pas

    r97 r98  
    1212  UCoolDockCustomize, DOM, XMLWrite, XMLRead, UCoolDockWindowList,
    1313  DateUtils, UCoolDockStyleTabs, UCoolDockStyleRegions, UCoolDockStylePopupTabs,
    14   UCoolDockStylePopupRegions, UCoolDockStyle, UCoolDockClientPanel;
     14  UCoolDockStylePopupRegions, UCoolDockStyle, UCoolDockClientPanel,
     15  UCoolDockPopupMenu;
    1516
    1617const
     
    4243    FMaster: TCoolDockMaster;
    4344    DockStyleHandler: TCoolDockStyle;
    44     PopupMenuHeader: TPopupMenu;
    4545    FDockStyle: TDockStyle;
    4646    FDockDirection: TDockDirection;
     
    5656    procedure SetMoveDuration(const AValue: Integer);
    5757    procedure UpdateClientSize;
    58     procedure PopupMenuListClick(Sender: TObject);
    59     procedure PopupMenuTabsClick(Sender: TObject);
    60     procedure PopupMenuCloseClick(Sender: TObject);
    61     procedure PopupMenuRenameClick(Sender: TObject);
    62     procedure PopupMenuPositionAutoClick(Sender: TObject);
    63     procedure PopupMenuPositionLeftClick(Sender: TObject);
    64     procedure PopupMenuPositionRightClick(Sender: TObject);
    65     procedure PopupMenuPositionTopClick(Sender: TObject);
    66     procedure PopupMenuPositionBottomClick(Sender: TObject);
    67     procedure PopupMenuUndockClick(Sender: TObject);
    68     procedure PopupMenuCustomizeClick(Sender: TObject);
    6958  public
     59    PopupMenu: TCoolDockPopupMenu;
    7060    constructor Create(ADockSite: TWinControl); override;
    7161    destructor Destroy; override;
     
    192182
    193183resourcestring
    194   SDockStyle = 'Style';
    195   SDockList = 'List';
    196   SDockTabs = 'Tabs';
    197   SCloseForm = 'Close';
    198   SRenameForm = 'Rename';
    199   SPosition = 'Position';
    200   SPositionAuto = 'Auto';
    201   SPositionTop = 'Top';
    202   SPositionLeft = 'Left';
    203   SPositionRight = 'Right';
    204   SPositionBottom = 'Bottom';
    205   SUndock = 'Undock';
    206   SCustomize = 'Customize...';
    207184  SWrongOwner = 'Owner of TCoolDockClient have to be TForm';
    208   SEnterNewWindowName = 'Enter new window name';
    209   SRenameWindow = 'Rename window';
    210 
    211185
    212186implementation
     
    256230  FDockStyle := dsTabs; // To initialize style value have to be different
    257231  DockStyle := dsList;
    258 
    259 (*  // Tabs popup
    260 
    261   PopupMenuTabs := TPopupMenu.Create(FDockSite);
    262   PopupMenuTabs.Name := ADockSite.Name + '_' + 'PopupMenuTabs';
    263 
    264   NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    265   NewMenuItem.Caption := SDockStyle;
    266   PopupMenuTabs.Items.Add(NewMenuItem);
    267 
    268   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    269   NewMenuItem2.Caption := SDockList;
    270   NewMenuItem2.OnClick := PopupMenuListClick;
    271   NewMenuItem.Add(NewMenuItem2);
    272 
    273   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    274   NewMenuItem2.Caption := SDockTabs;
    275   NewMenuItem2.OnClick := PopupMenuTabsClick;
    276   NewMenuItem.Add(NewMenuItem2);
    277 
    278   NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    279   NewMenuItem.Caption := SPosition;
    280   PopupMenuTabs.Items.Add(NewMenuItem);
    281 
    282   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    283   NewMenuItem2.Caption := SPositionAuto;
    284   NewMenuItem2.OnClick := PopupMenuPositionAutoClick;
    285   NewMenuItem.Add(NewMenuItem2);
    286 
    287   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    288   NewMenuItem2.Caption := SPositionTop;
    289   NewMenuItem2.OnClick := PopupMenuPositionTopClick;
    290   NewMenuItem.Add(NewMenuItem2);
    291 
    292   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    293   NewMenuItem2.Caption := SPositionLeft;
    294   NewMenuItem2.OnClick := PopupMenuPositionLeftClick;
    295   NewMenuItem.Add(NewMenuItem2);
    296 
    297   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    298   NewMenuItem2.Caption := SPositionBottom;
    299   NewMenuItem2.OnClick := PopupMenuPositionBottomClick;
    300   NewMenuItem.Add(NewMenuItem2);
    301 
    302   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    303   NewMenuItem2.Caption := SPositionRight;
    304   NewMenuItem2.OnClick := PopupMenuPositionRightClick;
    305   NewMenuItem.Add(NewMenuItem2);
    306 
    307   NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    308   NewMenuItem.Caption := SCloseForm;
    309   NewMenuItem.OnClick := PopupMenuCloseClick;
    310   PopupMenuTabs.Items.Add(NewMenuItem);
    311 
    312   NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    313   NewMenuItem.Caption := SRenameForm;
    314   NewMenuItem.OnClick := PopupMenuRenameClick;
    315   PopupMenuTabs.Items.Add(NewMenuItem);
    316 
    317   NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    318   NewMenuItem.Caption := SUndock;
    319   NewMenuItem.OnClick := PopupMenuUndockClick;
    320   PopupMenuTabs.Items.Add(NewMenuItem);
    321 
    322   NewMenuItem := TMenuItem.Create(PopupMenuTabs);
    323   NewMenuItem.Caption := SCustomize;
    324   NewMenuItem.OnClick := PopupMenuCustomizeClick;
    325   PopupMenuTabs.Items.Add(NewMenuItem);
    326 
    327   // Header popup
    328 
    329   PopupMenuHeader := TPopupMenu.Create(FDockSite);
    330   PopupMenuHeader.Name := ADockSite.Name + '_' + 'PopupMenuHeader';
    331 
    332   NewMenuItem := TMenuItem.Create(PopupMenuHeader);
    333   NewMenuItem.Caption := SDockStyle;
    334   PopupMenuHeader.Items.Add(NewMenuItem);
    335 
    336   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    337   NewMenuItem2.Caption := SDockList;
    338   NewMenuItem2.OnClick := PopupMenuListClick;
    339   NewMenuItem.Add(NewMenuItem2);
    340 
    341   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    342   NewMenuItem2.Caption := SDockTabs;
    343   NewMenuItem2.OnClick := PopupMenuTabsClick;
    344   NewMenuItem.Add(NewMenuItem2);
    345 
    346   NewMenuItem := TMenuItem.Create(PopupMenuHeader);
    347   NewMenuItem.Caption := SPosition;
    348   PopupMenuHeader.Items.Add(NewMenuItem);
    349 
    350   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    351   NewMenuItem2.Caption := SPositionAuto;
    352   NewMenuItem2.OnClick := PopupMenuPositionAutoClick;
    353   NewMenuItem.Add(NewMenuItem2);
    354 
    355   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    356   NewMenuItem2.Caption := SPositionTop;
    357   NewMenuItem2.OnClick := PopupMenuPositionTopClick;
    358   NewMenuItem.Add(NewMenuItem2);
    359 
    360   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    361   NewMenuItem2.Caption := SPositionLeft;
    362   NewMenuItem2.OnClick := PopupMenuPositionLeftClick;
    363   NewMenuItem.Add(NewMenuItem2);
    364 
    365   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    366   NewMenuItem2.Caption := SPositionBottom;
    367   NewMenuItem2.OnClick := PopupMenuPositionBottomClick;
    368   NewMenuItem.Add(NewMenuItem2);
    369 
    370   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    371   NewMenuItem2.Caption := SPositionRight;
    372   NewMenuItem2.OnClick := PopupMenuPositionRightClick;
    373   NewMenuItem.Add(NewMenuItem2);
    374 
    375   NewMenuItem := TMenuItem.Create(PopupMenuHeader);
    376   NewMenuItem.Caption := SCloseForm;
    377   NewMenuItem.OnClick := PopupMenuCloseClick;
    378   PopupMenuHeader.Items.Add(NewMenuItem);
    379 
    380   NewMenuItem := TMenuItem.Create(PopupMenuHeader);
    381   NewMenuItem.Caption := SRenameForm;
    382   NewMenuItem.OnClick := PopupMenuRenameClick;
    383   PopupMenuHeader.Items.Add(NewMenuItem);
    384 
    385   NewMenuItem := TMenuItem.Create(PopupMenuHeader);
    386   NewMenuItem.Caption := SUndock;
    387   NewMenuItem.OnClick := PopupMenuUndockClick;
    388   PopupMenuHeader.Items.Add(NewMenuItem);
    389 
    390   NewMenuItem := TMenuItem.Create(PopupMenuHeader);
    391   NewMenuItem.Caption := SCustomize;
    392   NewMenuItem.OnClick := PopupMenuCustomizeClick;
    393   PopupMenuHeader.Items.Add(NewMenuItem);
    394   *)
     232  PopupMenu := TCoolDockPopupMenu.Create(Self);
    395233end;
    396234
    397235destructor TCoolDockManager.Destroy;
    398236begin
     237  PopupMenu.Free;
    399238  FDockPanels.Free;
     239  DockStyleHandler.Free;
    400240  inherited Destroy;
    401241end;
     
    469309      if DockStyle = dsList then Visible := True;
    470310      Align := alClient;
    471       Header.PopupMenu := PopupMenuHeader;
     311      Header.PopupMenu := PopupMenu;
    472312    end;
    473313    if (Control is TForm) and Assigned((Control as TForm).Icon) then
     
    515355
    516356//  FDockPanel.Invalidate;
    517   inherited;
     357  //inherited;
    518358end;
    519359
     
    574414  ClientPanel: TCoolDockClientPanel;
    575415begin
    576   inherited;
     416  //inherited;
    577417  if Control.HostDockSite = Self.FDockSite then begin
    578418    ClientPanel := FindControlInPanels(Control);
     
    663503end;
    664504
    665 procedure TCoolDockManager.PopupMenuTabsClick(Sender: TObject);
    666 begin
    667   DockStyle := dsTabs;
    668 end;
    669 
    670 procedure TCoolDockManager.PopupMenuCloseClick(Sender: TObject);
    671 var
    672   Control: TControl;
    673 begin
    674   Control := FindLCLControl(Mouse.CursorPos);
    675   if Assigned(Control) then
    676     ShowMessage(Control.ClassName);
    677 //  DockSiteTForm(TCoolDockManager(TControl(Sender).Parent.Parent.Parent.DockManager).FDockSite).Close;
    678 end;
    679 
    680 procedure TCoolDockManager.PopupMenuRenameClick(Sender: TObject);
    681 var
    682   Value: string;
    683 begin
    684   Value := DockSite.Parent.Caption;
    685   if InputQuery(SRenameWindow, SEnterNewWindowName, False, Value) then
    686     DockSite.Parent.Caption := Value;
    687 end;
    688 
    689 procedure TCoolDockManager.PopupMenuPositionAutoClick(Sender: TObject);
    690 begin
    691   //TabsPos := hpAuto;
    692 end;
    693 
    694 procedure TCoolDockManager.PopupMenuPositionLeftClick(Sender: TObject);
    695 begin
    696   //TabsPos := hpLeft;
    697 end;
    698 
    699 procedure TCoolDockManager.PopupMenuPositionRightClick(Sender: TObject);
    700 begin
    701   //TabsPos := hpRight;
    702 end;
    703 
    704 procedure TCoolDockManager.PopupMenuPositionTopClick(Sender: TObject);
    705 begin
    706   //TabsPos := hpTop;
    707 end;
    708 
    709 procedure TCoolDockManager.PopupMenuPositionBottomClick(Sender: TObject);
    710 begin
    711   //TabsPos := hpBottom;
    712 end;
    713 
    714 procedure TCoolDockManager.PopupMenuUndockClick(Sender: TObject);
    715 var
    716   Control: TControl;
    717 begin
    718 
    719   //Control.ManualFloat(Control.BoundsRect);
    720 end;
    721 
    722 procedure TCoolDockManager.PopupMenuCustomizeClick(Sender: TObject);
    723 begin
    724   if Assigned(Master) and
    725     Assigned(Master.Customize) then
    726     Master.Customize.Execute;
    727 end;
    728 
    729 procedure TCoolDockManager.PopupMenuListClick(Sender: TObject);
    730 begin
    731   DockStyle := dsList;
    732 end;
    733 
    734 
    735505{ TCoolDockConjoinForm }
    736506
Note: See TracChangeset for help on using the changeset viewer.