Ignore:
Timestamp:
Mar 7, 2011, 4:16:02 PM (14 years ago)
Author:
george
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/UCoolDockStyleTabs.pas

    r176 r177  
    1717    MouseButton: TMouseButton;
    1818    MouseDownSkip: Boolean;
    19     TabControl: TTabControl;
     19    PageControl: TPageControl;
    2020    TabImageList: TImageList;
    2121    procedure TabControlMouseLeave(Sender: TObject);
     
    3030  private
    3131    FTabsPos: THeaderPos;
     32    procedure InsertControlNoUpdate(NewPanel: TCoolDockClientPanel;
     33      AControl: TControl; InsertAt: TAlign);
    3234  public
    3335    constructor Create(AManager: TObject);
     
    5052procedure TCoolDockStyleTabs.PopupMenuTabCloseClick(Sender: TObject);
    5153begin
    52   if TabControl.TabIndex <> -1 then
    53     TCoolDockClientPanel(TCoolDockManager(Manager).DockPanels[TabControl.TabIndex]).Control.Hide;
     54  if Assigned(PageControl.ActivePage) then
     55    TCoolDockClientPanel(TCoolDockManager(Manager).DockPanels[PageControl.TabIndex]).Control.Hide;
    5456end;
    5557
     
    5860  if MouseDown then
    5961  with TCoolDockManager(Manager) do
    60   if (TabControl.TabIndex <> -1) then begin
    61     TCoolDockClientPanel(DockPanels[TabControl.TabIndex]).ClientAreaPanel.DockSite := False;
    62     DragManager.DragStart(TCoolDockClientPanel(DockPanels[TabControl.TabIndex]).Control, False, 1);
     62  if Assigned(PageControl.ActivePage) then begin
     63    TCoolDockClientPanel(DockPanels[PageControl.TabIndex]).ClientAreaPanel.DockSite := False;
     64    DragManager.DragStart(TCoolDockClientPanel(DockPanels[PageControl.TabIndex]).Control, False, 1);
    6365  end;
    6466  MouseDown := False;
     
    7274  with TCoolDockManager(Manager) do
    7375  for I := 0 to DockPanels.Count - 1 do
    74     if TCoolDockClientPanel(DockPanels[I]).Control.Visible then begin
     76    if TCoolDockClientPanel(DockPanels[I]).Control.Visible
     77    //and (PageControl.TabIndex <> I)
     78    then
     79    begin
    7580      TCoolDockClientPanel(DockPanels[I]).Control.Tag := 1;
    7681      TCoolDockClientPanel(DockPanels[I]).Control.Hide;
    7782      TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Hide;
    78       TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Parent := DockSite;
     83      TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Parent := PageControl.Pages[I];
     84      //TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Parent := DockSite;
    7985      TCoolDockClientPanel(DockPanels[I]).Control.Align := alClient;
     86      //TCoolDockClientPanel(DockPanels[I]).Control.Parent :=
     87      //  TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel;
    8088      //ShowMessage(TCoolDockClientPanel(DockPanels[I]).Control.ClassName);
    8189      Application.ProcessMessages;
     
    8795  // Show selected
    8896  with TCoolDockManager(Manager) do
    89   if (TabControl.TabIndex <> -1) and (DockPanels.Count > TabControl.TabIndex) then begin
    90     with TCoolDockClientPanel(DockPanels[TabControl.TabIndex]), ClientAreaPanel do begin
     97  if (PageControl.TabIndex <> -1) and (DockPanels.Count > PageControl.TabIndex)
     98//  and not TCoolDockClientPanel(DockPanels[PageControl.TabIndex]).Control.Visible
     99  then begin
     100    with TCoolDockClientPanel(DockPanels[PageControl.TabIndex]), ClientAreaPanel do begin
    91101      Control.Show;
    92       Control.Tag := 0;
    93102      (*AutoHide.Enable := True;
    94103      if AutoHide.Enable then begin
     
    134143  NewMenuItem2: TMenuItem;
    135144  I: Integer;
     145  NewTabSheet: TTabSheet;
    136146begin
    137147  inherited;
     
    141151    Name := TCoolDockManager(Manager).DockSite.Name + '_' + 'ImageList';
    142152  end;
    143   TabControl := TTabControl.Create(TCoolDockManager(AManager).DockSite); //FDockSite);
    144   with TabControl do begin
     153  PageControl := TPageControl.Create(TCoolDockManager(AManager).DockSite); //FDockSite);
     154  with PageControl do begin
    145155    Parent := TCoolDockManager(Manager).DockSite;
    146156    Name := TCoolDockManager(Manager).DockSite.Name + '_' + 'TabControl';
    147157    Visible := False;
    148158    Align := alTop;
    149     Height := 24;
     159    //Height := 24;
     160    Align := alClient;
    150161    OnChange := TabControlChange;
     162    MultiLine := True;
    151163    PopupMenu := TCoolDockManager(Manager).PopupMenu;
    152164    //TTabControlNoteBookStrings(Tabs).NoteBook.OnMouseLeave := TabControlMouseLeave;
     
    159171  //MoveDuration := 1000; // ms
    160172
    161   TabControl.Visible := True;
    162   TabControl.Tabs.Clear;
    163   TabImageList.Clear;
     173  PageControl.Visible := True;
     174  //TabImageList.Clear;
    164175  with TCoolDockManager(Manager) do
    165176  for I := 0 to DockPanels.Count - 1 do
    166   if TCoolDockClientPanel(DockPanels[I]).Control.Visible then begin
    167     TCoolDockClientPanel(DockPanels[I]).Control.Tag := 1;
    168     TabControl.Tabs.Add(TCoolDockClientPanel(DockPanels[I]).Control.Caption);
    169     TabImageList.Add(TCoolDockClientPanel(DockPanels[I]).Header.Icon.Picture.Bitmap, nil);
    170     if Assigned(TCoolDockClientPanel(DockPanels[I]).Splitter) then
    171       TCoolDockClientPanel(DockPanels[I]).Splitter.Visible := False;
    172     TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Visible := False;
    173     TCoolDockClientPanel(DockPanels[I]).Visible := False;
    174   end;
     177    Self.InsertControlNoUpdate(TCoolDockClientPanel(DockPanels[I]),
     178      TCoolDockClientPanel(DockPanels[I]).Control, alNone);
     179  TabControlChange(Self);
    175180end;
    176181
    177182destructor TCoolDockStyleTabs.Destroy;
    178183begin
    179   TabControl.Free;
     184  PageControl.Free;
    180185  TabImageList.Free;
    181186  inherited Destroy;
     
    185190begin
    186191  inherited Switch(Index);
    187   TabControl.TabIndex := Index;
    188 end;
    189 
    190 procedure TCoolDockStyleTabs.InsertControl(NewPanel: TCoolDockClientPanel;
     192  PageControl.TabIndex := Index;
     193end;
     194
     195procedure TCoolDockStyleTabs.InsertControlNoUpdate(NewPanel: TCoolDockClientPanel;
    191196  AControl: TControl; InsertAt: TAlign);
     197var
     198  NewTabSheet: TTabSheet;
    192199begin
    193200  inherited;
    194201  if AControl.Visible then begin
    195     AControl.Tag := 1;
    196     TabControl.Tabs.Add(AControl.Caption);
     202    NewTabSheet := TTabSheet.Create(PageControl);
     203    NewTabSheet.PageControl := PageControl;
     204    NewTabSheet.Caption := AControl.Caption;
     205    NewTabSheet.ImageIndex := TabImageList.Count;
    197206    TabImageList.Add(NewPanel.Header.Icon.Picture.Bitmap, nil);
    198207    if Assigned(NewPanel.Splitter) then
     
    200209    NewPanel.ClientAreaPanel.Visible := False;
    201210    NewPanel.Visible := False;
    202     TabControlChange(Self);
    203   end;
     211    //NewPanel.Parent := NewTabSheet;
     212  end;
     213end;
     214
     215procedure TCoolDockStyleTabs.InsertControl(NewPanel: TCoolDockClientPanel;
     216  AControl: TControl; InsertAt: TAlign);
     217var
     218  NewTabSheet: TTabSheet;
     219begin
     220  inherited;
     221  InsertControlNoUpdate(NewPanel, AControl, InsertAt);
     222  TabControlChange(Self);
    204223end;
    205224
     
    211230  with TCoolDockManager(Manager) do
    212231  for I := 0 to DockPanels.Count - 1 do begin
    213     TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width;
    214     TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - TabControl.Height;
     232    //TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Width := DockSite.Width;
     233    //TCoolDockClientPanel(DockPanels[I]).ClientAreaPanel.Height := DockSite.Height - PageControl.Height;
    215234    //TCoolDockClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    216235  end;
     
    221240  inherited SetVisible(AValue);
    222241  with TCoolDockManager(Manager) do
    223     if (TabControl.TabIndex >= 0) and (TabControl.TabIndex < DockPanels.Count) then
    224       with TCoolDockClientPanel(DockPanels[TabControl.TabIndex]) do begin
     242    if (PageControl.TabIndex >= 0) and (PageControl.TabIndex < DockPanels.Count) then
     243      with TCoolDockClientPanel(DockPanels[PageControl.TabIndex]) do begin
    225244        //Show;
    226         if AValue and (not Control.Visible) and (Control.Tag = 1) then begin
     245        if AValue and (not Control.Visible) and (Control.Tag = 1)  then begin
    227246          Control.Show;
    228247          Control.Tag := 0;
     
    239258  inherited;
    240259  if not Visible then begin
    241     if Assigned(TWinControl(Control).DockManager) then
    242     with TCoolDockManager(TWinControl(Control).DockManager) do begin
     260    //if Assigned(TWinControl(Control).DockManager) then
     261    //with TCoolDockManager(TWinControl(Control).DockManager) do
     262    if Assigned(Manager) then
     263    with TCoolDockManager(Manager) do
     264    begin
    243265//    ShowMessage(IntToStr(TabControl.TabIndex) + ' ' + IntToStr(DockPanels.Count));
    244266//    TabControl.Tabs[0].;
     
    248270//    end;
    249271    //    ShowMessage(IntToStr(DockPanels.Count));
    250       if Control.Tag = 0 then begin
    251         TabImageList.Delete(TabControl.Tabs.IndexOf(Control.Caption));
    252 
    253         with TabControl.Tabs do
    254           Delete(IndexOf(Control.Caption));
    255       end;
     272        //TabImageList.Delete(PageControl.Tabs.IndexOf(Control.Caption));
     273
     274        I := DockPanels.IndexOf(FindControlInPanels(Control));
     275        if Control.Tag = 0 then
     276        if I <> -1 then
     277  //        Control.Hide;
     278          PageControl.Page[I].TabVisible := False;
     279        Control.Tag := 0;
     280//      end;
    256281    end;
    257282  end else
    258283  begin
    259     if Control.Tag = 0 then begin
    260       TabImageList.Add(TCoolDockClientPanel(TCoolDockManager(Manager).FindControlInPanels(Control)).Header.Icon.Picture.Bitmap, nil);
    261       TabControl.Tabs.Add(Control.Caption);
     284//    if Assigned(TWinControl(Control).DockManager) then
     285//    with TCoolDockManager(TWinControl(Control).DockManager) do
     286    if Assigned(Manager) then
     287    with TCoolDockManager(Manager) do
     288    begin
     289//      if Control.Tag = 0 then begin
     290        I := DockPanels.IndexOf(FindControlInPanels(Control));
     291        //if  then
     292        if I <> -1 then
     293          PageControl.Page[I].TabVisible := True;
     294//      TabImageList.Add(TCoolDockClientPanel(TCoolDockManager(Manager).FindControlInPanels(Control)).Header.Icon.Picture.Bitmap, nil);
     295//      TabControl.Tabs.Add(Control.Caption);
     296
     297//      end;
    262298    end;
    263299  end;
     
    268304  if FTabsPos = AValue then Exit;
    269305  FTabsPos := AValue;
    270   with TabControl do
     306  with PageControl do
    271307  case AValue of
    272308    hpAuto, hpTop: begin
Note: See TracChangeset for help on using the changeset viewer.