Changeset 217 for Docking/CoolDocking/UCDManager.pas
- Timestamp:
- Mar 22, 2011, 11:32:28 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCDManager.pas
r216 r217 7 7 uses 8 8 Classes, SysUtils, UCDCommon, Controls, Contnrs, Dialogs, 9 UCDPopupMenu, LCLType, L Messages, Graphics, Buttons,9 UCDPopupMenu, LCLType, LCLIntf, LMessages, Graphics, Buttons, 10 10 UCDConjoinForm, Menus, StdCtrls, ExtCtrls, Forms; 11 11 … … 30 30 TCDHeader = class(TPanel) 31 31 private 32 MyFont: hFont; 32 33 procedure CloseButtonClick(Sender: TObject); 33 34 procedure PaintExecute(Sender: TObject); … … 35 36 public 36 37 Buttons: TObjectList; // TList<TCDHeaderButton> 37 Title: TLabel;38 38 Icon: TImage; 39 39 ManagerItem: TCDManagerItem; … … 67 67 procedure SetHideType(const AValue: TCDHideType); 68 68 public 69 Control: T Control;69 Control: TWinControl; 70 70 Manager: TCDManager; 71 71 procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton; … … 139 139 end; 140 140 141 function HeaderPosToTabPos(HeaderPos: THeaderPos): TTabPosition;142 143 141 144 142 implementation … … 148 146 UCDResource; 149 147 150 function HeaderPosToTabPos(HeaderPos: THeaderPos): TTabPosition; 151 begin 152 case HeaderPos of 153 hpBottom: Result := tpBottom; 154 hpLeft: Result := tpLeft; 155 hpTop: Result := tpTop; 156 hpRight: Result := tpRight; 157 hpAuto: Result := tpTop; 158 end; 148 function CreateRotatedFont(F: TFont; Angle: Integer): Integer; 149 var 150 LF: TLogFont; 151 begin 152 FillChar(LF, SizeOf(LF), #0); 153 with LF do begin 154 lfHeight := F.Height; 155 lfWidth := 0; 156 lfEscapement := Angle * 10; 157 lfOrientation := 0; 158 if fsBold in F.Style then 159 lfWeight := FW_BOLD 160 else 161 lfWeight := FW_NORMAL; 162 lfItalic := Byte(fsItalic in F.Style); 163 lfUnderline := Byte(fsUnderline in F.Style); 164 lfStrikeOut := Byte(fsStrikeOut in F.Style); 165 lfCharSet := DEFAULT_CHARSET; 166 StrPCopy(lfFaceName, F.Name); 167 lfQuality := DEFAULT_QUALITY; 168 {everything else as default} 169 lfOutPrecision := OUT_DEFAULT_PRECIS; 170 lfClipPrecision := CLIP_DEFAULT_PRECIS; 171 case F.Pitch of 172 fpVariable: lfPitchAndFamily := VARIABLE_PITCH; 173 fpFixed: lfPitchAndFamily := FIXED_PITCH; 174 else 175 lfPitchAndFamily := DEFAULT_PITCH; 176 end; 177 end; 178 Result := CreateFontIndirect(LF); 159 179 end; 160 180 … … 179 199 if FHeaderPos=AValue then exit; 180 200 FHeaderPos:=AValue; 201 181 202 //Paint(Self); 182 203 end; … … 580 601 inherited Create(TheOwner); 581 602 OnPaint := PaintExecute; 582 583 Title := TLabel.Create(Self); 584 with Title do begin 585 Parent := Self; 586 Visible := True; 587 Top := 4; 588 Left := 6; 589 BevelInner := bvNone; 590 BevelOuter := bvNone; 591 end; 603 //MyFont := CreateRotatedFont(Canvas.Font, 90); 604 592 605 Buttons := TObjectList.Create; 593 606 … … 642 655 var 643 656 Points: array of TPoint; 644 begin 657 TitleLeft: Integer; 658 TitleWidth: Integer; 659 TitleMaxWidth: Integer; 660 I: Integer; 661 Title: string; 662 R: TRect; 663 begin 664 with TCDManager(TWinControl(ManagerItem.Control).DockManager) do 665 case HeaderPos of 666 hpLeft: begin 667 Align := alLeft; 668 Width := GrabberSize; 669 end; 670 hpTop, hpAuto: begin 671 Align := alTop; 672 Height := GrabberSize; 673 end; 674 hpRight: begin 675 Align := alRight; 676 Width := GrabberSize; 677 end; 678 hpBottom: begin 679 Align := alBottom; 680 Height := GrabberSize; 681 end; 682 end; 683 645 684 if (ManagerItem.Control as TWinControl).Focused then 646 Title.Font.Style := Font.Style + [fsBold] 647 else Title.Font.Style := Font.Style - [fsBold]; 648 649 if Icon.Picture.Width > 0 then Title.Left := 8 + Icon.Picture.Width 650 else Title.Left := 6; 651 Title.Caption := ManagerItem.Control.Caption; 685 Canvas.Font.Style := Canvas.Font.Style + [fsBold] 686 else Canvas.Font.Style := Canvas.Font.Style - [fsBold]; 687 652 688 RearrangeButtons; 653 689 … … 689 725 Pen.Color := BorderColor; 690 726 Polyline(Points); 727 728 Canvas.Brush.Style := bsClear; 729 TitleMaxWidth := Self.Width - 6; 730 for I := 0 to Buttons.Count - 1 do 731 if TCDHeaderButton(Buttons[I]).Visible then 732 Dec(TitleMaxWidth, TCDHeaderButton(Buttons[I]).Icon.Width + 2); 733 if Icon.Picture.Width > 0 then begin 734 TitleLeft := 8 + Icon.Picture.Width; 735 Dec(TitleMaxWidth, Icon.Picture.Width + 2) 736 end else TitleLeft := 6; 737 738 //SelectObject(Canvas.Handle, MyFont); 739 Title := ManagerItem.Control.Caption; 740 if (TextWidth(Title) > TitleMaxWidth) then begin 741 while (Length(Title) > 0) and (TextWidth(Title + '...') > TitleMaxWidth) do begin 742 Delete(Title, Length(Title), 1); 743 end; 744 Title := Title + '...'; 745 end; 746 747 R := Rect(TitleLeft, 4, TitleLeft + TitleMaxWidth, 4 + TextHeight(Title)); 748 TextRect(R, TitleLeft, 4, Title); 691 749 end; 692 750 end;
Note:
See TracChangeset
for help on using the changeset viewer.