📄 aqdockingvs2005.pas
字号:
constructor TaqVS2005Mover.Create(ADockingManager: TaqCustomDockingManager);
begin
inherited;
FControllers := TaqBucketList.Create;
FActiveControllers := TList.Create;
end;
destructor TaqVS2005Mover.Destroy;
begin
FreeAndNil(FActiveControllers);
FreeAndNil(FControllers);
inherited;
end;
procedure TaqVS2005Mover.EndDragging(const Coord: TPoint;
const Bounds: TRect);
begin
FDragDockControlSite := nil;
FDragJustStarted := False;
ClearDockingZones;
inherited;
end;
procedure TaqVS2005Mover.EnumDockingZones;
var
DockSite: TaqCustomDockingSite;
procedure TraverseDockingControls(Control: TaqCustomDockingControl);
var
i: Integer;
begin
if not CanDockTo(Control) then
Exit;
if (Control.ChildCount = 0) and IsDockingControlVisible(Control) then
FControllers.Add(Control, TaqDockingZoneController.Create(Style, Control))
else if Control is TaqInsideContainer then
begin
if GetBooleanValue(TaqInsideContainer(Control).ShowInsideContainerDockZones,
TaqDockingManager(DockingManager).ShowInsideContainerDockZones) or
(Control.ParentItem = nil) then
FControllers.Add(Control, TaqDockingZoneController.Create(Style, Control));
TraverseDockingControls(TaqInsideContainer(Control).CurrentTab);
end
else
begin
if (Control.ParentItem = nil) and (Control.Visible) then
FControllers.Add(Control, TaqDockingZoneController.Create(Style, Control));
for i := 0 to Control.ChildCount - 1 do
TraverseDockingControls(Control.Children[i]);
end;
end;
begin
with DockingManager.DockingSiteIterator do
begin
while HasNext do
begin
DockSite := TaqCustomDockingSite(Next.Data);
if (DockSite <> TaqDockingManagerFriend(DockingManager).NullDockingSite) and
IsDockingSiteVisible(DockSite) then
TraverseDockingControls(DockSite.MainItem);
end;
Free;
end;
end;
function TaqVS2005Mover.FindDockingControlInternal(
const Coord: TPoint): TaqCustomDockingControl;
var
DockSites: TList;
DockSite: TaqCustomDockingSite;
i, Index: Integer;
Wnd1, Wnd2: TaqHandle;
var
DockTarget: TaqCustomDockingControl;
begin
with TaqDockingManagerFriend(DockingManager) do
if Customizing then
begin
// In customizing mode: restrict docking to main site only.
if (MainDockSite <> nil) and (MainDockSite.MainItem <> nil) and
PtInRect(TaqCustomDockingSiteFriend(MainDockSite).GetScreenDockZone, Coord) then
Result := MainDockSite.GetItemByPos(Coord)
else
Result := nil;
end
//else if (FHotController <> nil) and (FHotController.FindDockingRegion(Coord) <> drtNone) then
// Result := FHotController.Control
else
begin
DockSites := nil;
with DockingSiteIterator do
begin
while HasNext do
begin
DockSite := TaqCustomDockingSite(Next.Data);
if (DockSite = NullDockingSite) or
not PtInRect(TaqCustomDockingSiteFriend(DockSite).GetScreenDockZone, Coord) or
not IsDockingSiteVisible(DockSite) then
Continue;
DockTarget := DockSite.GetItemByPos(Coord);
if not ((DockSite = FDragDockControlSite) and
((DockTarget <> nil) and DockTarget.IsParentItemOf(DragDockControl)) or
((DockSite is TaqFloatingSite) and (DragDockControl = DockSite.MainItem))) then
begin
if DockSites = nil then
DockSites := TList.Create;
DockSites.Add(DockSite);
end;
end;
Free;
end;
if DockSites <> nil then
begin
if DockSites.Count > 1 then
begin
// Find top docking site by z-order
Index := 0;
Wnd1 := aqGetRootParentHandle(TaqCustomDockingSite(DockSites.List[0]));
for i := 0 to DockSites.Count - 1 do
if i <> Index then
begin
Wnd2 := aqGetRootParentHandle(TaqCustomDockingSite(DockSites.List[i]));
if aqIsWindowHigher(Wnd2, Wnd1) > 0 then
begin
Index := i;
Wnd1 := Wnd2;
end;
end;
DockSite := DockSites.List[Index];
end
else
DockSite := DockSites.List[0];
DockSites.Free;
Result := DockSite.GetItemByPos(Coord);
if (Result <> nil) and (not (Result is TaqCustomDockingContainer)) and
not IsDockingControlVisible(Result) then
Result := nil;
end
else
Result := nil;
end;
if FDragJustStarted then
begin
FOriginDragPosition := Coord;
FDragJustStarted := False;
end;
end;
function TaqVS2005Mover.FindDockingControl(const Coord: TPoint): TaqCustomDockingControl;
var
Control: TaqCustomDockingControl;
Controller: TaqDockingZoneController;
DockRegion: TaqDockingRegionType;
begin
Result := FindDockingControlInternal(Coord);
if Result <> nil then
begin
if Result = DragItem then
Result := DragItem.ParentItem;
Control := Result;
while Control <> nil do
begin
Controller := ControllerByControl(Control);
if Controller <> nil then
begin
DockRegion := Controller.FindDockingRegion(Coord);
if not (DockRegion in [drtNone, drtInside]) then
begin
Result := Control;
Break;
end;
end;
Control := Control.ParentItem;
end;
end;
end;
procedure TaqVS2005Mover.StartDragging;
begin
inherited;
FDragDockControlSite := DragItem.Parent as TaqCustomDockingSite;
FDragJustStarted := True;
EnumDockingZones;
if Style.FlashZonesOnStart and (GetShiftState(DockingManager.AutoDragKey) <> KeyboardStateToShiftState) then
begin
FShowAllDockZones := True;
ShowDockingZones;
end;
end;
procedure TaqVS2005Mover.ShowDockingZones;
begin
with ControllerIterator do
try
while HasNext do
TaqDockingZoneController(Next.Data).Show(Style.DockZone.ActiveTransparency);
finally
Free;
end;
end;
function TaqVS2005Mover.GetStyle: TaqVS2005DockingStyle;
begin
Result := TaqVS2005DockingStyle(inherited Style);
end;
function TaqVS2005Mover.IsDockingSiteVisible(DockSite: TaqCustomDockingSite): Boolean;
begin
Result := DockSite.HandleAllocated and IsWindowVisible(DockSite.Handle);
end;
function TaqVS2005Mover.IsDockingControlVisible(DockControl: TaqCustomDockingControl): Boolean;
var
DC : hDC;
Rgn: hRGN;
const
SYSRGN = 4;
begin
Result := False;
if DockControl.HandleAllocated and IsWindowVisible(DockControl.Handle) then
begin
Rgn := CreateRectRgn(0, 0, 0, 0);
DC := GetWindowDC(DockControl.Handle);
GetRandomRgn(DC, Rgn, SYSRGN);
ReleaseDC(DockControl.Handle, DC);
if Win32Platform = VER_PLATFORM_WIN32_NT then
Result := RectInRegion(Rgn, DockControl.ScreenRect)
else
Result := RectInRegion(Rgn, DockControl.BoundsRect);
DeleteObject(Rgn);
end;
end;
procedure TaqVS2005Mover.EnterInsideContainer(AContainer: TaqInsideContainer;
ARegion: TaqDockingRegionType);
var
I, J: Integer;
begin
if AContainer <> nil then
with TaqInsideContainerFriend(AContainer) do
begin
ResetTabControl;
I := IndexOf(ActualTarget);
if I >= 0 then
begin
if DragItem.ParentItem = AContainer then
begin
J := DragItem.Index;
DeleteTab(J);
if J < I then
Dec(I);
end;
InsertVirtualTab(I + Integer(ARegion = drtInside), DragItem.Caption, DragItem.ImageIndex);
end;
Invalidate;
end;
end;
procedure TaqVS2005Mover.LeaveInsideContainer(AContainer: TaqInsideContainer);
begin
if AContainer <> nil then
with TaqInsideContainerFriend(AContainer) do
begin
ResetTabControl;
Invalidate;
end;
end;
function TaqVS2005Mover.CanDockTo(DockTarget: TaqCustomDockingControl): Boolean;
begin
Result := inherited CanDockTo(DockTarget);
// - the dock target is child in inside container
if not Result then
Result := (DockTarget = DragItem) and (DockTarget.ParentItem <> nil) and
(DockTarget.ParentItem is TaqInsideContainer);
end;
{ TaqDockingZone }
procedure TaqDockingZone.CMVisibleChanged(var Message: TMessage);
begin
if not Visible and (FFadeTimer <> nil) then
FFadeTimer.Enabled := False;
inherited;
end;
constructor TaqDockingZone.CreateEx(AImages: TImageList; AActiveImages: TImageList; AImageIndex: Integer);
begin
inherited CreateNew(nil);
FFadeTimer := TTimer.Create(Self);
FFadeTimer.Enabled := False;
FFadeTimer.Interval := HideInterval;
FFadeTimer.OnTimer := FadeDelayTimer;
FImages := AImages;
FActiveImages := AActiveImages;
FImageIndex := AImageIndex;
AlphaBlend := True;
AutoScroll := False;
BorderStyle := bsNone;
Color := clFuchsia;
ControlStyle := [csNoStdEvents, csFixedWidth, csFixedHeight];
FormStyle := fsStayOnTop;
Scaled := False;
TransparentColor := True;
TransparentColorValue := clFuchsia;
DoubleBuffered := True;
DefaultMonitor := dmDesktop;
Position := poDesigned;
end;
destructor TaqDockingZone.Destroy;
begin
if FRegion <> aqNullHandle then
DeleteObject(FRegion);
inherited;
end;
procedure TaqDockingZone.Fade(Transparency: Byte; FadeDelay: TaqDockerFadeDelay);
begin
FFadeTimer.Enabled := False;
if FadeDelay < HideInterval then
FadeDelay := HideInterval;
if Transparency = AlphaBlendValue then
InternalShow(Transparency > 0)
else
begin
FFadeCounter := FadeDelay div HideInterval - 1;
FAlphaBlendDelta := (AlphaBlendValue - Transparency) * HideInterval / FadeDelay;
FEndAlphaBlendValue := Transparency;
FFadeTimer.Enabled := True;
InternalShow(True);
end;
end;
procedure TaqDockingZone.FadeDelayTimer(Sender: TObject);
begin
AlphaBlendValue := FEndAlphaBlendValue + Round(FAlphaBlendDelta * FFadeCounter);
Dec(FFadeCounter);
if FFadeCounter < 0 then
begin
FFadeTimer.Enabled := False;
if AlphaBlendValue = 0 then
InternalShow(False);
end;
end;
procedure TaqDockingZone.CreateWindowHandle(const Params: TCreateParams);
var
Region: Cardinal;
begin
inherited;
if not TransparencyAvailable then
begin
TImageListDIB(FImages).CreateRegionFromItem(FImageIndex, Region);
SetWindowRgn(Handle, Region, False);
end;
end;
procedure TaqDockingZone.InternalShow(Show: Boolean);
begin
// Visible := Show;
Invalidate;
if Show then
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOSENDCHANGING or SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE or SWP_SHOWWINDOW)
else
ShowWindow(Handle, SW_HIDE);
end;
procedure TaqDockingZone.MakeVisible(Transparency: Byte);
begin
FFadeTimer.Enabled := False;
AlphaBlendValue := Transparency;
InternalShow(Transparency > 0);
end;
procedure TaqDockingZone.Paint;
begin
if FActive then
FActiveImages.Draw(Canvas, 0, 0, FImageIndex)
else
FImages.Draw(Canvas, 0, 0, FImageIndex);
end;
procedure TaqDockingZone.SetRegion(ARegion: TaqHandle);
var
Rect: TRect;
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -