Ignore:
Timestamp:
Apr 26, 2012, 9:12:02 AM (13 years ago)
Author:
chronos
Message:
  • Added: CoolDocking text logging support.
  • Added: CoolDocking update locking on TCDManager descendants update. This fixes tab disappear if tab with regions style conjoinform was switched to another tab.
  • Modified: CoolDocking regions style item layout changed to support aligned forms. Only one region is aligned as alClient. Rest contained regions are aligned to borders.
Location:
Docking/CoolDocking/Managers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Docking/CoolDocking/Managers/UCDManagerRegions.pas

    r218 r354  
    1717    PanelHeader: TCDPanelHeader;
    1818    Splitter: TSplitter;
     19    Align: TAlign;
    1920    procedure VisibleChange(Sender: TObject); override;
    2021    procedure Paint(Sender: TObject); override;
     
    4344    destructor Destroy; override;
    4445    procedure PaintSite(DC: HDC); override;
    45     procedure UpdateClientSize; override;
     46    procedure Update; override;
    4647    procedure SetVisible(const AValue: Boolean); override;
    4748    procedure ChangeVisible(Control: TWinControl; Visible: Boolean);
     
    6566    //  TCDManagerRegionsItem(DockItems[DockItems.IndexOf(FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
    6667    //end;
    67     UpdateClientSize;
     68    Update;
     69
     70    // if any region is visible, show parent docksite
     71    //if DockSite is TForm then
     72    //  DockSite.Visible := (DockSite.VisibleDockClientCount > 0);
    6873  end;
    6974end;
     
    130135  inherited SetHeaderPos(AValue);
    131136  if Assigned(DockSite.Parent) then
    132     TCDManager(DockSite.Parent.DockManager).UpdateClientSize;
     137    TCDManager(DockSite.Parent.DockManager).Update;
    133138(*  case AValue of
    134139    hpBottom, hpTop: FDockDirection := ddVertical;
     
    179184
    180185  NewItem.PanelHeader.Parent := DockSite;
     186
     187  if DockItems.Count = 0 then NewItem.Align := alClient
     188    else NewItem.Align := InsertAt;
    181189
    182190  NewItem.Control := TWinControl(Control);
     
    219227        Control.ManualDock(DockSite, nil, InsertAt);
    220228        NewConjoinDockForm.UpdateCaption;
    221         UpdateClientSize;
     229        Update;
    222230        Exit;
    223231      end;
     
    225233    InsertControlNoUpdate(Control, InsertAt);
    226234  end;
    227   UpdateClientSize;
     235  Update;
    228236end;
    229237
     
    257265  end;
    258266  inherited RemoveControl(Control);
    259   if ClientCount > 1 then UpdateClientSize;
     267  if ClientCount > 1 then Update;
    260268end;
    261269
     
    271279  for I := 0 to ADockSite.DockClientCount - 1 do
    272280    InsertControlNoUpdate(ADockSite.DockClients[I], alLeft);
    273   UpdateClientSize;
     281  Update;
    274282end;
    275283
     
    291299end;
    292300
    293 procedure TCDManagerRegions.UpdateClientSize;
     301procedure TCDManagerRegions.Update;
    294302var
    295303  I: Integer;
     
    299307  VisibleControlsCount: Integer;
    300308begin
    301   inherited UpdateClientSize;
    302   if FDockDirection = ddHorizontal then
    303     BaseAlign := alLeft else BaseAlign := alTop;
    304 
    305   SplitterLeft := 0;
    306   SplitterTop := 0;
     309  if FUpdateCount = 0 then begin
     310  DebugLog('TCDManagerRegions.UpdateClientSize');
     311  inherited;
    307312  VisibleControlsCount := DockSite.VisibleDockClientCount;
    308313  if DockSite is TForm then
    309     DockSite.Visible := VisibleControlsCount > 0;
     314    DockSite.Visible := (VisibleControlsCount > 0);
    310315  if VisibleControlsCount = 0 then VisibleControlsCount := 1;
    311316
     
    323328    PanelHeader.Visible := Control.Visible;
    324329    Paint(Self);
    325     if I < (DockItems.Count - 1) then PanelHeader.Align := BaseAlign
    326       else PanelHeader.Align := alClient;
    327 
    328     Inc(SplitterLeft, PanelHeader.Width);
    329     Inc(SplitterTop, PanelHeader.Height);
     330    if FDockDirection = ddHorizontal then
     331      BaseAlign := alLeft else BaseAlign := alTop;
     332
     333    if I < Trunc((DockItems.Count - 1) / 2) then BaseAlign := BaseAlign
     334        else if I = Trunc((DockItems.Count - 1) / 2) then BaseAlign := alClient
     335        else if I > Trunc((DockItems.Count - 1) / 2) then begin
     336          if BaseAlign = alTop then BaseAlign := alBottom
     337          else if BaseAlign = alLeft then BaseAlign := alRight;
     338        end;
     339    PanelHeader.Align := BaseAlign;
     340
     341    Splitter.Align := BaseAlign;
     342    SplitterLeft := PanelHeader.Left;
     343    SplitterTop := PanelHeader.Top;
    330344    Splitter.Left := SplitterLeft;
    331345    Splitter.Top := SplitterTop;
    332346    Splitter.Parent := Self.DockSite;
    333     Splitter.Align := BaseAlign;
    334     Splitter.Visible := I < (DockItems.Count - 1);
     347    Splitter.Visible := I <> (Trunc(DockItems.Count - 1) / 2);
    335348    Inc(SplitterLeft, Splitter.Width);
    336349    Inc(SplitterTop, Splitter.Height);
    337350
    338351    Paint(Self);
    339     if I < (DockItems.Count - 1) then begin
    340       if DockDirection = ddHorizontal then PanelHeader.Align := alLeft
    341         else PanelHeader.Align := alTop;
    342     end else PanelHeader.Align := alClient;
     352    PanelHeader.Align := BaseAlign;
     353  end;
    343354  end;
    344355end;
     
    349360begin
    350361  inherited;
    351   for I := 0 to DockItems.Count - 1 do
     362  try
     363    BeginUpdate;
     364    for I := 0 to DockItems.Count - 1 do
    352365      with TCDManagerRegionsItem(DockItems[I]) do begin
    353366        if AValue and (not Control.Visible) and (Control.Tag = Integer(dhtTemporal))  then begin
     
    361374      end;
    362375        //ClientAreaPanel.Show;
     376  finally
     377    EndUpdate;
     378  end;
    363379end;
    364380
  • Docking/CoolDocking/Managers/UCDManagerTabs.pas

    r253 r354  
    4444    TabImageList: TImageList;
    4545    PageControl: TPageControl;
    46     procedure UpdateClientSize; override;
     46    procedure Update; override;
    4747    procedure SetHeaderPos(const AValue: THeaderPos); override;
    4848    procedure InsertControlNoUpdate(Control: TControl; InsertAt: TAlign); virtual;
     
    8282  Temp2: TControl;
    8383begin
     84  DebugLog('TCDManagerTabsItem.VisibleChange');
    8485  with TCDManagerTabs(Manager) do begin
    8586    if TControl(Sender).Visible then begin
    86       UpdateClientSize;
     87      Update;
    8788      Switch(DockItems.IndexOf(FindControlInPanels(TControl(Sender))));
    8889      TCDManagerTabsItem(DockItems[DockItems.IndexOf(
    8990        FindControlInPanels(TControl(Sender)))]).HideType := dhtPermanent;
    90     end else UpdateClientSize;
     91    end else Update;
    9192  end;
    9293
     
    143144procedure TCDManagerTabs.TabControlChange(Sender: TObject);
    144145begin
    145   UpdateClientSize;
     146  DebugLog('TCDManagerTabs.TabControlChange ' + IntToStr(PageControl.TabIndex));
     147  Update;
    146148  MouseDownSkip := True;
    147149end;
     
    189191    OnChange := TabControlChange;
    190192    MultiLine := True;
     193    AutoSize := True;
    191194    PopupMenu := Self.PopupMenu;
    192195    OnMouseLeave := TabControlMouseLeave;
     
    225228procedure TCDManagerTabs.Switch(Index: Integer);
    226229begin
     230  DebugLog('TCDManagerTabs.Switch ' + IntToStr(Index));
    227231  PageControl.TabIndex := Index;
    228232end;
     
    265269  end; //else raise Exception.Create(Format('Control %s not found in DockItems', [Control.Name]));
    266270
    267   ManagerItem.Control.Visible := False;
     271  //ManagerItem.Control.Visible := False;
    268272  ManagerItem.Control.Parent := nil;
    269273  DockItems.Remove(ManagerItem);
     
    279283      end else TCDManagerItem(DockItems[0]).Control.ManualFloat(Rect(Left, Top, Left + Width, Top + Height));
    280284      ManualFloat(Rect(Left, Top, Left + Width, Top + Height));
    281       //UpdateClientSize;
     285      //Update;
    282286      inherited RemoveControl(Control);
    283287      Free;
     
    286290  end;
    287291  //if ClientCount > 0 then
    288   UpdateClientSize;
     292  Update;
    289293  inherited RemoveControl(Control);
    290294end;
     
    341345  inherited;
    342346  InsertControlNoUpdate(AControl, InsertAt);
    343   UpdateClientSize;
    344 end;
    345 
    346 procedure TCDManagerTabs.UpdateClientSize;
     347  Update;
     348end;
     349
     350procedure TCDManagerTabs.Update;
    347351var
    348352  I: Integer;
     
    350354  DeletedPage: TTabSheet;
    351355begin
     356  if FUpdateCount = 0 then begin
     357  DebugLog('TCDManagerTabs.Update');
    352358  for I := 0 to DockItems.Count - 1 do
    353359  with TCDManagerTabsItem(DockItems[I]) do begin
     
    407413    //TCDClientPanel(FDockPanels[I]).DockPanelPaint(Self);
    408414  end;
    409   inherited UpdateClientSize;
     415  end;
     416  inherited;
    410417end;
    411418
Note: See TracChangeset for help on using the changeset viewer.