Changeset 197 for Docking/CoolDocking/UCDManager.pas
- Timestamp:
- Mar 16, 2011, 7:47:27 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Docking/CoolDocking/UCDManager.pas
r195 r197 6 6 7 7 uses 8 Classes, SysUtils, UCDCommon, Controls, Contnrs, 8 Classes, SysUtils, UCDCommon, Controls, Contnrs, Dialogs, 9 9 UCDPopupMenu, LCLType, LMessages, Graphics, Buttons, 10 10 UCDConjoinForm, Menus, StdCtrls, ExtCtrls, Forms; … … 18 18 TCDManager = class; 19 19 TCDManagerItem = class; 20 21 { TCDHeaderButton } 22 23 TCDHeaderButton = class 24 Icon: TImage; 25 constructor Create; 26 destructor Destroy; override; 27 end; 28 29 { TCDHeader } 20 30 21 31 TCDHeader = class(TPanel) … … 23 33 procedure CloseButtonClick(Sender: TObject); 24 34 procedure DrawGrabber(Canvas: TCanvas; AControl: TControl); 35 procedure PaintExecute(Sender: TObject); 36 procedure RearrangeButtons; 25 37 public 26 CloseButton: TSpeedButton;38 Buttons: TObjectList; // TList<TCDHeaderButton> 27 39 Title: TLabel; 28 40 Icon: TImage; 29 41 ManagerItem: TCDManagerItem; 30 Shape: TShape;31 42 constructor Create(TheOwner: TComponent); override; 32 43 destructor Destroy; override; … … 53 64 TCDManagerItem = class 54 65 private 55 procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton;56 Shift: TShiftState; X, Y: Integer);57 66 procedure ResizeExecute(Sender: TObject); 58 67 public 59 68 Control: TControl; 60 69 Manager: TCDManager; 70 procedure DockPanelMouseDown(Sender: TObject; Button: TMouseButton; 71 Shift: TShiftState; X, Y: Integer); 61 72 procedure Paint(Sender: TObject); virtual; 62 73 procedure VisibleChange(Sender: TObject); virtual; … … 124 135 125 136 uses 126 UCDManagerRegions, UCDManagerTabs, UCDManagerRegionsPopup, UCDManagerTabsPopup; 137 UCDManagerRegions, UCDManagerTabs, UCDManagerRegionsPopup, UCDManagerTabsPopup, 138 UCDResource; 139 140 { TCDHeaderButton } 141 142 constructor TCDHeaderButton.Create; 143 begin 144 inherited; 145 Icon := TImage.Create(nil); 146 end; 147 148 destructor TCDHeaderButton.Destroy; 149 begin 150 Icon.Free; 151 inherited Destroy; 152 end; 127 153 128 154 { TCDPanelHeader } … … 142 168 // Header.Title.OnMouseDown := DockPanelMouseDown; 143 169 HeaderPos := hpTop; 170 Constraints.MinHeight := GrabberSize; 171 Align := alClient; 144 172 145 173 ShowHeader := True; … … 164 192 end; 165 193 //OnResize := ResizeExecute; 166 BevelInner := bvNone;167 BevelOuter := bvNone;194 //BevelInner := bvNone; 195 //BevelOuter := bvNone; 168 196 end; 169 197 … … 195 223 constructor TCDManagerItem.Create; 196 224 begin 225 197 226 end; 198 227 … … 213 242 begin 214 243 if Control is TForm then begin 215 //TForm(Control).SetFocus;244 TForm(Control).SetFocus; 216 245 Paint(Self); 217 246 end; … … 219 248 //(Control as TWinControl).DockSite := False; 220 249 //ClientAreaPanel.DockSite := False; 221 //(Control as TWinControl).BeginDrag(False, 10);222 //DragManager.DragStart(Control, False, 1);250 (Control as TWinControl).BeginDrag(False, 10); 251 DragManager.DragStart(Control, False, 1); 223 252 end; 224 253 end; … … 549 578 550 579 constructor TCDHeader.Create(TheOwner: TComponent); 580 var 581 NewButton: TCDHeaderButton; 551 582 begin 552 583 inherited Create(TheOwner); 553 Shape := TShape.Create(Self); 554 with Shape do begin 555 Parent := Self; 556 Anchors := [akRight, akBottom, akLeft, akTop]; 557 Left := 1; 558 Top := 1; 559 Width := Self.Width - 2; 560 Height := Self.Height - 2; 561 Brush.Style := bsClear; 562 end; 584 OnPaint := PaintExecute; 585 563 586 Title := TLabel.Create(Self); 564 587 with Title do begin … … 570 593 BevelOuter := bvNone; 571 594 end; 572 CloseButton := TSpeedButton.Create(Self); 573 with CloseButton do begin 574 Parent := Self; 575 Caption := 'X'; 576 Font.Size := 6; 577 Width := GrabberSize - 8; 578 Height := GrabberSize - 8; 579 Anchors := [akRight, akTop]; 580 Left := Self.Width - Width - 4; 581 Top := 4; 582 Visible := True; 583 OnClick := CloseButtonClick; 584 end; 595 Buttons := TObjectList.Create; 596 597 NewButton := TCDHeaderButton.Create; 598 with NewButton do begin 599 DataModule2.ImageList1.GetBitmap(0, Icon.Picture.Bitmap); 600 Icon.Parent := Self; 601 Icon.OnClick := CloseButtonClick; 602 end; 603 Buttons.Add(NewButton); 604 NewButton := TCDHeaderButton.Create; 605 with NewButton do begin 606 DataModule2.ImageList1.GetBitmap(1, Icon.Picture.Bitmap); 607 Icon.Parent := Self; 608 Icon.OnClick := CloseButtonClick; 609 end; 610 Buttons.Add(NewButton); 611 RearrangeButtons; 612 585 613 Icon := TImage.Create(Self); 586 614 with Icon do begin … … 594 622 destructor TCDHeader.Destroy; 595 623 begin 624 Buttons.Free; 596 625 inherited Destroy; 597 626 end; … … 614 643 end; 615 644 645 procedure TCDHeader.PaintExecute(Sender: TObject); 646 const 647 Corner: Integer = 2; 648 Border: Integer = 1; 649 BorderColor: TColor = $B9C3C6; 650 TopColor: TColor = $CFD6D9; 651 BottomColor: TColor = $DAE0E1; 652 var 653 Points: array of TPoint; 654 begin 655 with Canvas do begin 656 GradientFill(Rect(Border, Border, Width - Border, 657 Height - Border), TopColor, BottomColor, gdVertical); 658 Brush.Color := clBtnFace; 659 Brush.Style := bsSolid; 660 Pen.Color := clBtnFace; 661 Pen.Style := psSolid; 662 SetLength(Points, 3); 663 Points[0] := Point(Border, Border); 664 Points[1] := Point(Border, Border + Corner); 665 Points[2] := Point(Border + Corner, Border); 666 Polygon(Points); 667 Points[0] := Point(Width - 1 - Border, Border); 668 Points[1] := Point(Width - 1 - Border, Border + Corner); 669 Points[2] := Point(Width - 1 - Border - Corner, Border); 670 Polygon(Points); 671 Points[0] := Point(Border, Height - 1 - Border); 672 Points[1] := Point(Border, Height - 1 - Border - Corner); 673 Points[2] := Point(Border + Corner, Height - 1 - Border); 674 Polygon(Points); 675 Points[0] := Point(Width - 1 - Border, Height - 1 - Border); 676 Points[1] := Point(Width - 1 - Border, Height - 1 - Border - Corner); 677 Points[2] := Point(Width - 1 - Border - Corner, Height - 1 - Border); 678 Polygon(Points); 679 680 SetLength(Points, 9); 681 Points[0] := Point(Border, Border + Corner); 682 Points[1] := Point(Border + Corner, Border); 683 Points[2] := Point(Width - 1 - Border - Corner, Border); 684 Points[3] := Point(Width - 1 - Border, Border + Corner); 685 Points[4] := Point(Width - 1 - Border, Height - 1 - Border - Corner); 686 Points[5] := Point(Width - 1 - Border - Corner, Height - 1 - Border); 687 Points[6] := Point(Border + Corner, Height - 1 - Border); 688 Points[7] := Point(Border, Height - 1 - Border - Corner); 689 Points[8] := Point(Border, Border + Corner); 690 Pen.Color := BorderColor; 691 Polyline(Points); 692 end; 693 end; 694 695 procedure TCDHeader.RearrangeButtons; 696 const 697 Separation: Integer = 4; 698 var 699 LeftPos: Integer; 700 I: Integer; 701 begin 702 LeftPos := Self.Width; 703 for I := 0 to Buttons.Count - 1 do 704 with TCDHeaderButton(Buttons[I]), Icon do begin 705 Anchors := [akRight, akTop]; 706 //Icon.Picture.Bitmap.SetSize(16, 16); 707 Icon.Width := Icon.Picture.Bitmap.Width; 708 Icon.Height := Icon.Picture.Bitmap.Height; 709 LeftPos := LeftPos - Icon.Width - Separation; 710 Icon.Left := LeftPos; 711 Icon.Top := (GrabberSize - Icon.Height) div 2; 712 713 //ShowMessage(IntToStr(Icon.Width) + ' ' + InttoStr(Icon.Height)); 714 Visible := True; 715 end; 716 end; 717 616 718 procedure TCDHeader.CloseButtonClick(Sender: TObject); 617 719 begin
Note:
See TracChangeset
for help on using the changeset viewer.