Ignore:
Timestamp:
Mar 16, 2011, 12:32:41 PM (14 years ago)
Author:
george
Message:
  • Fixed: Popup submenus style and position item selection.
  • Added: Locking dock managers.
  • Modified: Enhanced auto popup tabs handling. Not yet finished.
  • Modified: Dock manager position united for all dock manager descendands.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCDPopupMenu.pas

    r194 r198  
    1414
    1515  TCDPopupMenu = class(TPopupMenu)
     16  private
     17    procedure PopupExecute(Sender: TObject);
    1618  public
    1719    Manager: TCDManagerBase;
     20    PositionMenu: TMenuItem;
     21    StyleMenu: TMenuItem;
     22    LockedMenu: TMenuItem;
    1823    constructor Create(AManager: TCDManagerBase);
     24    procedure UncheckMenuGroup(Item: TMenuItem);
    1925    procedure PopupMenuListClick(Sender: TObject);
    2026    procedure PopupMenuTabsClick(Sender: TObject);
     
    3036    procedure PopupMenuUndockClick(Sender: TObject);
    3137    procedure PopupMenuCustomizeClick(Sender: TObject);
     38    procedure PopupMenuLockedClick(Sender: TObject);
    3239  end;
    3340
     
    5562  SEnterNewWindowName = 'Enter new window name';
    5663  SRenameWindow = 'Rename window';
     64  SLocked = 'Locked';
    5765
    5866
    5967{ TCDPopupMenu }
     68
     69procedure TCDPopupMenu.UncheckMenuGroup(Item: TMenuItem);
     70var
     71  I: Integer;
     72begin
     73  for I := 0 to Item.Count - 1 do
     74    Item.Items[I].Checked := False;
     75end;
     76
     77procedure TCDPopupMenu.PopupExecute(Sender: TObject);
     78begin
     79  UncheckMenuGroup(StyleMenu);
     80  StyleMenu.Items[Integer(TCDManager(Manager).DockStyle)].Checked := True;
     81  UncheckMenuGroup(PositionMenu);
     82  PositionMenu.Items[Integer(TCDManager(Manager).HeaderPos)].Checked := True;;
     83  LockedMenu.Checked := TCDManager(Manager).Locked;
     84end;
    6085
    6186constructor TCDPopupMenu.Create(AManager: TCDManagerBase);
     
    6893  Manager := AManager;
    6994
    70   Name := TCDManager(AManager).DockSite.Name + '_' + 'PopupMenu';
    71 
    72   NewMenuItem := TMenuItem.Create(Self);
    73   NewMenuItem.Caption := SDockStyle;
    74   Items.Add(NewMenuItem);
    75 
    76   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     95  Name := GetUniqueName(TCDManager(AManager).DockSite.Name + 'PopupMenu');
     96  OnPopup := PopupExecute;
     97
     98  StyleMenu := TMenuItem.Create(Self);
     99  StyleMenu.Caption := SDockStyle;
     100  Items.Add(StyleMenu);
     101
     102  NewMenuItem2 := TMenuItem.Create(StyleMenu);
    77103  NewMenuItem2.Caption := SDockList;
    78104  NewMenuItem2.OnClick := PopupMenuListClick;
    79   NewMenuItem.Add(NewMenuItem2);
    80 
    81   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     105  StyleMenu.Add(NewMenuItem2);
     106
     107  NewMenuItem2 := TMenuItem.Create(StyleMenu);
    82108  NewMenuItem2.Caption := SDockTabs;
    83109  NewMenuItem2.OnClick := PopupMenuTabsClick;
    84   NewMenuItem.Add(NewMenuItem2);
    85 
    86   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     110  StyleMenu.Add(NewMenuItem2);
     111
     112  NewMenuItem2 := TMenuItem.Create(StyleMenu);
     113  NewMenuItem2.Caption := SDockPopupTabs;
     114  NewMenuItem2.OnClick := PopupMenuPopupTabsClick;
     115  StyleMenu.Add(NewMenuItem2);
     116
     117  NewMenuItem2 := TMenuItem.Create(StyleMenu);
    87118  NewMenuItem2.Caption := SDockPopupList;
    88119  NewMenuItem2.OnClick := PopupMenuPopupListClick;
    89   NewMenuItem.Add(NewMenuItem2);
    90 
    91   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    92   NewMenuItem2.Caption := SDockPopupTabs;
    93   NewMenuItem2.OnClick := PopupMenuPopupTabsClick;
    94   NewMenuItem.Add(NewMenuItem2);
    95 
    96   NewMenuItem := TMenuItem.Create(Self);
    97   NewMenuItem.Caption := SPosition;
    98   Items.Add(NewMenuItem);
    99 
    100   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     120  StyleMenu.Add(NewMenuItem2);
     121
     122  PositionMenu := TMenuItem.Create(Self);
     123  PositionMenu.Caption := SPosition;
     124  Items.Add(PositionMenu);
     125
     126  NewMenuItem2 := TMenuItem.Create(PositionMenu);
    101127  NewMenuItem2.Caption := SPositionAuto;
    102128  NewMenuItem2.OnClick := PopupMenuPositionAutoClick;
    103   NewMenuItem.Add(NewMenuItem2);
    104 
    105   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     129  PositionMenu.Add(NewMenuItem2);
     130
     131  NewMenuItem2 := TMenuItem.Create(PositionMenu);
     132  NewMenuItem2.Caption := SPositionLeft;
     133  NewMenuItem2.OnClick := PopupMenuPositionLeftClick;
     134  PositionMenu.Add(NewMenuItem2);
     135
     136  NewMenuItem2 := TMenuItem.Create(PositionMenu);
    106137  NewMenuItem2.Caption := SPositionTop;
    107138  NewMenuItem2.OnClick := PopupMenuPositionTopClick;
    108   NewMenuItem.Add(NewMenuItem2);
    109 
    110   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    111   NewMenuItem2.Caption := SPositionLeft;
    112   NewMenuItem2.OnClick := PopupMenuPositionLeftClick;
    113   NewMenuItem.Add(NewMenuItem2);
    114 
    115   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
     139  PositionMenu.Add(NewMenuItem2);
     140
     141  NewMenuItem2 := TMenuItem.Create(PositionMenu);
     142  NewMenuItem2.Caption := SPositionRight;
     143  NewMenuItem2.OnClick := PopupMenuPositionRightClick;
     144  PositionMenu.Add(NewMenuItem2);
     145
     146  NewMenuItem2 := TMenuItem.Create(PositionMenu);
    116147  NewMenuItem2.Caption := SPositionBottom;
    117148  NewMenuItem2.OnClick := PopupMenuPositionBottomClick;
    118   NewMenuItem.Add(NewMenuItem2);
    119 
    120   NewMenuItem2 := TMenuItem.Create(NewMenuItem);
    121   NewMenuItem2.Caption := SPositionRight;
    122   NewMenuItem2.OnClick := PopupMenuPositionRightClick;
    123   NewMenuItem.Add(NewMenuItem2);
     149  PositionMenu.Add(NewMenuItem2);
    124150
    125151  NewMenuItem := TMenuItem.Create(Self);
     
    142168  NewMenuItem.OnClick := PopupMenuCustomizeClick;
    143169  Items.Add(NewMenuItem);
     170
     171  LockedMenu := TMenuItem.Create(Self);
     172  LockedMenu.Caption := SLocked;
     173  LockedMenu.OnClick := PopupMenuLockedClick;
     174  Items.Add(LockedMenu);
    144175end;
    145176
     
    200231  if PopupComponent is TPageControl then
    201232  with TPageControl(PopupComponent) do begin
    202     TCDManagerTabs(Manager).TabsPos := hpAuto;
     233    TCDManagerTabs(Manager).HeaderPos := hpAuto;
    203234  end else
    204235  if PopupComponent is TCDHeader then
     
    212243  if PopupComponent is TPageControl then
    213244  with TPageControl(PopupComponent) do begin
    214     TCDManagerTabs(Manager).TabsPos := hpLeft;
     245    TCDManagerTabs(Manager).HeaderPos := hpLeft;
    215246  end else
    216247  if PopupComponent is TCDHeader then
     
    224255  if PopupComponent is TPageControl then
    225256  with TPageControl(PopupComponent) do begin
    226     TCDManagerTabs(Manager).TabsPos := hpRight;
     257    TCDManagerTabs(Manager).HeaderPos := hpRight;
    227258  end else
    228259  if PopupComponent is TCDHeader then
     
    236267  if PopupComponent is TPageControl then
    237268  with TPageControl(PopupComponent) do begin
    238     TCDManagerTabs(Manager).TabsPos := hpTop;
     269    TCDManagerTabs(Manager).HeaderPos := hpTop;
    239270  end else
    240271  if PopupComponent is TCDHeader then
     
    248279  if PopupComponent is TPageControl then
    249280  with TPageControl(PopupComponent) do begin
    250     TCDManagerTabs(Manager).TabsPos := hpBottom;
     281    TCDManagerTabs(Manager).HeaderPos := hpBottom;
    251282  end else
    252283  if PopupComponent is TCDHeader then
     
    280311end;
    281312
     313procedure TCDPopupMenu.PopupMenuLockedClick(Sender: TObject);
     314begin
     315  if PopupComponent is TPageControl then
     316  with TPageControl(PopupComponent) do begin
     317    TCDManagerTabs(Manager).Locked := not TCDManagerTabs(Manager).Locked;
     318  end else
     319  if PopupComponent is TCDHeader then
     320  with TCDHeader(PopupComponent) do begin
     321    TCDManagerTabs(Manager).Locked := not TCDManagerTabs(Manager).Locked;
     322  end;
     323end;
     324
    282325procedure TCDPopupMenu.PopupMenuListClick(Sender: TObject);
    283326begin
Note: See TracChangeset for help on using the changeset viewer.