Okay.. Docking is officially a hell. I really have no clue how it works, bullz does the docking manually.. But in all the examples they use weird Dockingmanangers, I've got no clue howto create that lil bar! :-(.. Looks like the header is drawn by a 3rd-party component:
procedure TEasyDockHeader.Draw(AZone: TEasyZone; ACanvas: TCanvas; ACaption: string; const MousePos: TPoint);
(* Problem with colors on other than win32 widgetsets (gtk2...)
*)
const
clBack = clHighlight;
clFont = clHighlightText;
var
IsMouseDown: Boolean;
//procedure DrawButton(ARect: TRect; IsMouseDown, IsMouseOver: Boolean; ABitmap: TCustomBitmap); inline;
procedure DrawButton(ARect: TRect; ABitmap: TCustomBitmap);
const
// ------------- Pressed, Hot -----------------------
BtnDetail: array[Boolean, Boolean] of TThemedToolBar =
(
(ttbButtonNormal, ttbButtonHot),
(ttbButtonNormal, ttbButtonPressed)
);
var
Details: TThemedElementDetails;
dx, dy: integer;
IsMouseOver: boolean;
begin
ACanvas.FillRect(ARect);
IsMouseOver := PtInRect(ARect, MousePos);
Details := ThemeServices.GetElementDetails(BtnDetail[IsMouseDown, IsMouseOver]);
ThemeServices.DrawElement(ACanvas.Handle, Details, ARect);
ARect := ThemeServices.ContentRect(ACanvas.Handle, Details, ARect);
//move button into rect, excluding border
dx := (ARect.Right - ARect.Left - ABitmap.Width) div 2;
dy := (ARect.Bottom - ARect.Top - ABitmap.Height) div 2;
ACanvas.Draw(ARect.Left + dx, ARect.Top + dy, ABitmap);
end;
procedure DrawGrabberLine(Left, Top, Right, Bottom: Integer);
begin
with ACanvas do
begin
Pen.Color := clBtnHighlight;
MoveTo(Right, Top);
LineTo(Left, Top);
LineTo(Left, Bottom);
Pen.Color := clBtnShadow;
LineTo(Right, Bottom);
LineTo(Right, Top);
end;
end;
var
BtnRect: TRect;
ARect, DrawRect: TRect;
// LCL doesn't handle orientation in TFont
OldFont, RotatedFont: HFONT;
OldMode: Integer;
ALogFont: TLogFont;
AOrientation: TDockOrientation;
AControl: TControl;
AStyle: TEasyHeaderStyle;
HasSizer: boolean;
begin
(* Some colors inavailable on some widgetsets!
*)
if AZone.Style = hsNone then
exit; //no header at all
IsMouseDown := (GetKeyState(VK_LBUTTON) and $80) <> 0;
//debug
AControl := AZone.FChildControl;
AStyle := AZone.Style;
HasSizer := AZone.HasSizer;
AOrientation := AControl.DockOrientation;
ARect := AZone.GetBounds;
ACanvas.Brush.Color := clBtnFace;
//draw splitter?
if HasSizer then begin
// border?
BtnRect := GetRectOfPart(ARect, AOrientation, zpSizer, HasSizer, AStyle);
ACanvas.FillRect(BtnRect);
end;
//erase - which color(s)?
DrawRect := GetRectOfPart(ARect, AOrientation, zpAll, HasSizer, AStyle);
//ACanvas.Brush.Color := clBack; // clActiveCaption;
ACanvas.FillRect(DrawRect);
//border
InflateRect(DrawRect, -1, -1); //outer bevel?
ACanvas.Brush.Color := clBtnShadow;
ACanvas.FrameRect(DrawRect); //1 pixel border
ACanvas.Brush.Color := clBtnFace;
// draw caption
case AStyle of
hsMinimal:
with DrawRect do begin
DrawRect := GetRectOfPart(ARect, AOrientation, zpCaption, HasSizer, AStyle);
if AOrientation = doVertical then begin
inc(Top, dDBorder);
DrawGrabberLine(Left, Top, Right, Top+2);
inc(Top, 3);
DrawGrabberLine(Left, Top, Right, Top+2);
end else begin
inc(Left, dDBorder);
DrawGrabberLine(Left, Top, Left+2, Bottom);
inc(Left, 3);
DrawGrabberLine(Left, Top, Left+2, Bottom);
end;
end;
hsForm:
begin
//ACanvas.Font.Color := clFont; //clCaptionText;
DrawRect := GetRectOfPart(ARect, AOrientation, zpCaption, HasSizer, AStyle);
OldMode := SetBkMode(ACanvas.Handle, TRANSPARENT);
//for some reason the caption is not offset properly?
if AOrientation = doVertical then begin
inc(DrawRect.Left, dBorder); //looks better
DrawText(ACanvas.Handle, PChar(ACaption), -1, DrawRect, DT_LEFT or DT_SINGLELINE or DT_VCENTER)
end else begin
OldFont := 0;
if GetObject(ACanvas.Font.Reference.Handle, SizeOf(ALogFont), @ALogFont) <> 0 then
begin
ALogFont.lfEscapement := 900;
RotatedFont := CreateFontIndirect(ALogFont);
if RotatedFont <> 0 then
OldFont := SelectObject(ACanvas.Handle, RotatedFont);
end;
// from msdn: DrawText doesnot support font with orientation and escapement <> 0
//TextOut(ACanvas.Handle, DrawRect.Left, DrawRect.Bottom, PChar(ACaption), Length(ACaption));
TextOut(ACanvas.Handle, DrawRect.Left-2, DrawRect.Bottom-2, PChar(ACaption), Length(ACaption));
if OldFont <> 0 then
DeleteObject(SelectObject(ACanvas.Handle, OldFont));
end;
SetBkMode(ACanvas.Handle, OldMode);
end;
end;
// buttons - which colors to use?
ACanvas.Brush.Color := clBtnFace;
//ACanvas.Pen.Color := clButtonText;
// draw close button
BtnRect := GetRectOfPart(ARect, AOrientation, zpCloseButton, HasSizer, AStyle);
DrawButton(BtnRect, DockBtnImages[dhiClose]);
{$IFDEF restore}
// draw restore button
BtnRect := GetRectOfPart(ARect, AOrientation, zpRestoreButton, HasSizer, AStyle);
DrawButton(BtnRect, DockBtnImages[dhiRestore]);
{$ENDIF}
end;