From: <rem...@us...> - 2007-04-05 22:12:58
|
Revision: 11252 http://svn.sourceforge.net/jvcl/?rev=11252&view=rev Author: remkobonte Date: 2007-04-05 15:12:55 -0700 (Thu, 05 Apr 2007) Log Message: ----------- * Use CM_INVALIDATEDOCKHOST to refresh hottrack docksites instead of FocusChanged. * Delphi 2005 uses CM_INVALIDATEDOCKHOST on WM_SETFOCUS,WM_KILLFOCUS thus does not need a lot of updates. * Focus dock form on click on TJvDockTabPanel. (Mantis #3761) Modified Paths: -------------- trunk/jvcl/run/JvDockControlForm.pas trunk/jvcl/run/JvDockInfo.pas trunk/jvcl/run/JvDockTree.pas trunk/jvcl/run/JvDockVIDStyle.pas trunk/jvcl/run/JvDockVIDVCStyle.pas trunk/jvcl/run/JvDockVSNetStyle.pas Modified: trunk/jvcl/run/JvDockControlForm.pas =================================================================== --- trunk/jvcl/run/JvDockControlForm.pas 2007-04-05 10:52:00 UTC (rev 11251) +++ trunk/jvcl/run/JvDockControlForm.pas 2007-04-05 22:12:55 UTC (rev 11252) @@ -64,6 +64,10 @@ JvDockState_Docking = 1; JvDockState_Floating = 2; + {$IFNDEF COMPILER9_UP} + CM_INVALIDATEDOCKHOST = CM_BASE + 70; + {$ENDIF !COMPILER9_UP} + type TJvDockSplitterSize = 0..32767; @@ -864,6 +868,10 @@ function DockStateStr(DockState: Integer): string; {return string for a dock state} +{$IFNDEF COMPILER9_UP} +procedure InvalidateDockHostSiteOfControl(Control: TControl; FocusLost: Boolean); +{$ENDIF !COMPILER9_UP} + {$IFDEF USEJVCL} {$IFDEF UNITVERSIONING} const @@ -1284,6 +1292,29 @@ TJvDockCustomControl(DockWindow.HostDockSite).UpdateCaption(DockWindow); end; +{$IFNDEF COMPILER9_UP} +procedure InvalidateDockHostSiteOfControl(Control: TControl; FocusLost: Boolean); +var + ChildDockSite: TControl; + ParentWalk: TWinControl; +begin + { Invalidate the first dock site we come across; its ui may + need updating to reflect which control has focus. } + if Control = nil then + Exit; + ChildDockSite := Control; + ParentWalk := Control.Parent; + while (ChildDockSite.HostDockSite = nil) and (ParentWalk <> nil) do + begin + ChildDockSite := ParentWalk; + ParentWalk := ParentWalk.Parent; + end; + if ChildDockSite <> nil then + TWinControlAccessProtected(ChildDockSite).SendDockNotification(CM_INVALIDATEDOCKHOST, + Integer(Control), Integer(FocusLost)); +end; +{$ENDIF !COMPILER9_UP} + function IsDockable(Sender: TWinControl; Client: TControl; DropCtl: TControl = nil; DockAlign: TAlign = alNone): Boolean; var @@ -2946,8 +2977,10 @@ procedure TJvDockClient.Activate; begin + {$IFNDEF COMPILER9_UP} if ParentForm.HostDockSite is TJvDockCustomPanel then - TJvDockCustomPanel(ParentForm.HostDockSite).JvDockManager.FocusChanged(ParentForm); + InvalidateDockHostSiteOfControl(ParentForm, False); + {$ENDIF !COMPILER9_UP} end; procedure TJvDockClient.AddDockStyle(ADockStyle: TJvDockBasicStyle); @@ -3109,9 +3142,10 @@ procedure TJvDockClient.Deactivate; begin + {$IFNDEF COMPILER9_UP} if ParentForm.HostDockSite is TJvDockCustomPanel then - if TJvDockCustomPanel(ParentForm.HostDockSite).JvDockManager <> nil then - TJvDockCustomPanel(ParentForm.HostDockSite).JvDockManager.FocusChanged(nil); + InvalidateDockHostSiteOfControl(ParentForm, True); + {$ENDIF !COMPILER9_UP} end; procedure TJvDockClient.DoFloatDockClients(PanelAlign: TAlign); @@ -3585,12 +3619,9 @@ procedure TJvDockClient.WMActivate(var Msg: TWMActivate); begin - if ParentForm is TJvDockConjoinHostForm then - if Msg.Active = WA_INACTIVE then - TJvDockConjoinPanel(TJvDockConjoinHostForm(ParentForm).Panel).JvDockManager.FocusChanged(nil) - else - TJvDockConjoinPanel(TJvDockConjoinHostForm(ParentForm).Panel).JvDockManager.FocusChanged( - GetActiveControl(ParentForm)); + {$IFNDEF COMPILER9_UP} + InvalidateDockHostSiteOfControl(ParentForm.ActiveControl, Msg.Active = WA_INACTIVE); + {$ENDIF !COMPILER9_UP} end; procedure TJvDockClient.WMNCLButtonDblClk(var Msg: TWMNCHitMessage); @@ -4563,31 +4594,30 @@ end; procedure TJvDockServer.WMActivate(var Msg: TWMActivate); +{$IFNDEF COMPILER9_UP} var - I: TAlign; Control: TWinControl; +{$ENDIF !COMPILER9_UP} begin + {$IFNDEF COMPILER9_UP} if Msg.Active = WA_INACTIVE then begin - for I := alTop to alRight do - if Assigned(DockPanelWithAlign[I]) then - DockPanelWithAlign[I].JvDockManager.FocusChanged(nil); + Control := ParentForm.ActiveControl; + if Assigned(Control) then + InvalidateDockHostSiteOfControl(Control, True); end else - if AutoFocusDockedForm then begin - Control := GetActiveControl(ParentForm); - if not Assigned(Control) then - Exit; - for I := alTop to alRight do - if Assigned(DockPanelWithAlign[I]) then - if GetHostDockParent(Control) = DockPanelWithAlign[I] then - begin - DockPanelWithAlign[I].JvDockManager.FocusChanged(Control); - if Control.CanFocus then - Control.SetFocus; - end; + Control := ParentForm.ActiveControl; + if Assigned(Control) then + begin + // { ?? } + // if AutoFocusDockedForm and Control.CanFocus then + // Control.SetFocus; + InvalidateDockHostSiteOfControl(Control, False); + end; end; + {$ENDIF !COMPILER9_UP} end; //=== { TJvDockSplitter } ==================================================== @@ -4985,6 +5015,32 @@ Result := Perform(CM_UNDOCKCLIENT, Integer(NewTarget), Integer(Client)) = 0; end; +function TJvDockTabPageControl.GetActiveDockForm: TCustomForm; +begin + Result := DockForm[ActivePageIndex]; +end; + +function TJvDockTabPageControl.GetDockForm(Index: Integer): TCustomForm; +var + Page: TJvDockTabSheet; +begin + Result := nil; + + if (Index > -1) and (Index < Count) then + begin + Page := Pages[Index]; + if Assigned(Page) and (Page.ControlCount = 1) and (Page.Controls[0] is TCustomForm) then + begin + Result := TCustomForm(Page.Controls[0]); + end + end; +end; + +function TJvDockTabPageControl.GetDockStyle: TJvDockObservableStyle; +begin + Result := FStyleLink.DockStyle; +end; + function TJvDockTabPageControl.GetParentForm: TJvDockTabHostForm; begin if Parent is TJvDockTabHostForm then @@ -5087,11 +5143,6 @@ TabPosition := DockStyle.TabServerOption.TabPosition; end; -function TJvDockTabPageControl.GetDockStyle: TJvDockObservableStyle; -begin - Result := FStyleLink.DockStyle; -end; - //=== { TJvGlobalDockManager } =============================================== constructor TJvGlobalDockManager.Create; @@ -5227,27 +5278,6 @@ FDockServers.Remove(ADockServer); end; -function TJvDockTabPageControl.GetActiveDockForm: TCustomForm; -begin - Result := DockForm[ActivePageIndex]; -end; - -function TJvDockTabPageControl.GetDockForm(Index: Integer): TCustomForm; -var - Page: TJvDockTabSheet; -begin - Result := nil; - - if (Index > -1) and (Index < Count) then - begin - Page := Pages[Index]; - if Assigned(Page) and (Page.ControlCount = 1) and (Page.Controls[0] is TCustomForm) then - begin - Result := TCustomForm(Page.Controls[0]); - end - end; -end; - procedure InitDockManager; var OSVersionInfo: TOSVersionInfo; Modified: trunk/jvcl/run/JvDockInfo.pas =================================================================== --- trunk/jvcl/run/JvDockInfo.pas 2007-04-05 10:52:00 UTC (rev 11251) +++ trunk/jvcl/run/JvDockInfo.pas 2007-04-05 22:12:55 UTC (rev 11252) @@ -1175,9 +1175,9 @@ TWinControl(Control).EnableAlign; end; end; - // KV to avoid flickering in Vista - if not ((Control is TForm) and (ParentName <> '')) then - Control.Visible := Visible; +// // KV to avoid flickering in Vista +// if not ((Control is TForm) and (ParentName <> '')) then + Control.Visible := Visible; Control.LRDockWidth := LRDockWidth; Control.TBDockHeight := TBDockHeight; Control.UnDockHeight := UnDockHeight; Modified: trunk/jvcl/run/JvDockTree.pas =================================================================== --- trunk/jvcl/run/JvDockTree.pas 2007-04-05 10:52:00 UTC (rev 11251) +++ trunk/jvcl/run/JvDockTree.pas 2007-04-05 22:12:55 UTC (rev 11252) @@ -82,7 +82,6 @@ // Descends the Tree and Finds and return TWinControls docked to a particular parent. procedure ControlQuery(DockedTo: TWinControl; FoundItems: TList); {$ENDIF JVDOCK_QUERY} - procedure FocusChanged(Control: TControl); property GrabberSize: Integer read GetGrabberSize write SetGrabberSize; property SplitterWidth: Integer read GetDockSplitterWidth write SetDockSplitterWidth; property BorderWidth: Integer read GetBorderWidth write SetBorderWidth; @@ -414,7 +413,6 @@ procedure UpdateZone(Zone: TJvDockZone); virtual; procedure DrawSplitter(Zone: TJvDockZone); virtual; procedure RemoveControl(Control: TControl); virtual; - procedure FocusChanged(Control: TControl); virtual; procedure SetGrabberSize(const Value: Integer); virtual; procedure SetNewBounds(Zone: TJvDockZone); virtual; procedure SetReplacingControl(Control: TControl); @@ -2865,10 +2863,6 @@ Result := nil; end; -procedure TJvDockTree.FocusChanged(Control: TControl); -begin -end; - function TJvDockTree.GetGrabberSize: Integer; begin Result := FGrabberSize; Modified: trunk/jvcl/run/JvDockVIDStyle.pas =================================================================== --- trunk/jvcl/run/JvDockVIDStyle.pas 2007-04-05 10:52:00 UTC (rev 11251) +++ trunk/jvcl/run/JvDockVIDStyle.pas 2007-04-05 22:12:55 UTC (rev 11252) @@ -235,6 +235,7 @@ procedure SetCaptionRightOffset(const Value: Integer); procedure SetShowCloseButtonOnGrabber(const Value: Boolean); procedure SetAlwaysShowGrabber(const Value: Boolean); + procedure InvalidateDockSite(const Client: TControl); protected procedure InsertControlFromConjoinHost(Control: TControl; InsertAt: TAlign; DropCtl: TControl); virtual; @@ -264,7 +265,6 @@ procedure DrawCloseButton(Canvas: TCanvas; Zone: TJvDockZone; Left, Top: Integer); virtual; procedure ResetBounds(Force: Boolean); override; - procedure FocusChanged(Control: TControl); override; procedure DrawDockSiteRect; override; procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign; var DockRect: TRect); override; @@ -448,6 +448,7 @@ function GetPage(Index: Integer): TJvDockVIDTabSheet; function GetActiveVIDPage: TJvDockVIDTabSheet; procedure SetActiveVIDPage(const Value: TJvDockVIDTabSheet); + procedure CMDockNotification(var Msg: TCMDockNotification); message CM_DOCKNOTIFICATION; protected procedure AdjustClientRect(var Rect: TRect); override; procedure CreatePanel; virtual; @@ -1133,7 +1134,9 @@ (Source.DropAlign = alClient)) then begin inherited CustomDockDrop(Source, X, Y); - JvDockManager.FocusChanged(Source.Control); + {$IFNDEF COMPILER9_UP} + InvalidateDockHostSiteOfControl(Source.Control, False); + {$ENDIF !COMPILER9_UP} if (Source.Control is TWinControl) and TWinControl(Source.Control).CanFocus then TWinControl(Source.Control).SetFocus; end; @@ -1818,16 +1821,21 @@ inherited DrawSplitterRect(ARect); end; -procedure TJvDockVIDTree.FocusChanged(Control: TControl); -begin - inherited FocusChanged(Control); - DockSite.Invalidate; -end; - procedure TJvDockVIDTree.WindowProc(var Msg: TMessage); var Align: TAlign; begin + if Msg.Msg = CM_DOCKNOTIFICATION then + begin + with TCMDockNotification(Msg) do + begin + if NotifyRec.ClientMsg = CM_INVALIDATEDOCKHOST then + InvalidateDockSite(TControl(NotifyRec.MsgWParam)) + else + inherited; + end; + end + else if Msg.Msg = CM_DOCKCLIENT then begin { (rb) no idea what gi_DockRect should be doing, but prevent it is used @@ -2380,8 +2388,9 @@ begin inherited CustomDockDrop(Source, X, Y); ParentForm.Caption := ''; - if JvDockManager <> nil then - JvDockManager.FocusChanged(Source.Control); + {$IFNDEF COMPILER9_UP} + InvalidateDockHostSiteOfControl(Source.Control, False); + {$ENDIF !COMPILER9_UP} if (Source.Control is TWinControl) and Source.Control.Visible and TWinControl(Source.Control).CanFocus then TWinControl(Source.Control).SetFocus; @@ -2515,6 +2524,23 @@ inherited CreateWnd; end; +procedure TJvDockVIDTabPageControl.CMDockNotification( + var Msg: TCMDockNotification); +begin + if Msg.Msg = CM_DOCKNOTIFICATION then + begin + with TCMDockNotification(Msg) do + begin + if NotifyRec.ClientMsg = CM_INVALIDATEDOCKHOST then + InvalidateDockHostSiteOfControl(Self, Boolean(NotifyRec.MsgLParam)) + else + inherited; + end; + end + else + inherited; +end; + procedure TJvDockVIDTabPageControl.CustomDockDrop(Source: TJvDockDragDockObject; X, Y: Integer); var @@ -4646,6 +4672,61 @@ SetDefaultSystemCaptionInfo; end; +{$IFNDEF COMPILER9_UP} +function GetRealParentForm(Control: TControl): TCustomForm; +begin + while not (Control is TCustomForm) and (Control.Parent <> nil) do + Control := Control.Parent; + if Control is TCustomForm then + Result := TCustomForm(Control) + else + Result := nil; +end; +{$ENDIF !COMPILER9_UP} + +{$IFNDEF COMPILER9_UP} +type + TWinControlAccessProtected = class(TWinControl); +{$ENDIF !COMPILER9_UP} + +function GetDockManager(Control: TWinControl; out ADockManager: IDockManager): Boolean; +begin + ADockManager := nil; + {$IFDEF COMPILER9_UP} + with Control do + if UseDockManager then + ADockManager := DockManager; + {$ELSE} + with TWinControlAccessProtected(Control) do + if UseDockManager then + ADockManager := DockManager; + {$ENDIF COMPILER9_UP} + Result := Assigned(ADockManager); +end; + +procedure TJvDockVIDTree.InvalidateDockSite(const Client: TControl); +var + ParentForm: TCustomForm; + Rect: TRect; + ADockManager: IDockManager; +begin + {$IFDEF COMPILER9_UP} + ParentForm := GetParentForm(Client, False); + {$ELSE} + ParentForm := GetRealParentForm(Client); + {$ENDIF COMPILER9_UP} + { Just invalidate the parent form's rect in the HostDockSite + so that we can "follow focus" on docked items. } + if (ParentForm <> nil) and (ParentForm.HostDockSite <> nil) then + begin + if GetDockManager(ParentForm.HostDockSite, ADockManager) then + begin + ADockManager.GetControlBounds(ParentForm, Rect); + InvalidateRect(ParentForm.HostDockSite.Handle, @Rect, False); + end; + end; +end; + {$IFDEF USEJVCL} {$IFDEF UNITVERSIONING} initialization Modified: trunk/jvcl/run/JvDockVIDVCStyle.pas =================================================================== --- trunk/jvcl/run/JvDockVIDVCStyle.pas 2007-04-05 10:52:00 UTC (rev 11251) +++ trunk/jvcl/run/JvDockVIDVCStyle.pas 2007-04-05 22:12:55 UTC (rev 11252) @@ -253,7 +253,6 @@ procedure DrawCloseButton(Canvas: TCanvas; Zone: TJvDockZone; Left, Top: Integer); virtual; procedure ResetBounds(Force: Boolean); override; - procedure FocusChanged(Control: TControl); override; procedure DrawDockSiteRect; override; { procedure PositionDockRect(Client, DropCtl: TControl; DropAlign: TAlign; var DockRect: TRect); override;} @@ -1083,7 +1082,9 @@ (Source.DropAlign = alClient)) then begin inherited CustomDockDrop(Source, X, Y); - JvDockManager.FocusChanged(Source.Control); + {$IFNDEF COMPILER9_UP} + InvalidateDockHostSiteOfControl(Source.Control, False); + {$ENDIF !COMPILER9_UP} if (Source.Control is TWinControl) and TWinControl(Source.Control).CanFocus then TWinControl(Source.Control).SetFocus; end; @@ -1779,12 +1780,6 @@ DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONPUSH or DFCS_ADJUSTRECT); end; -procedure TJvDockVIDVCTree.FocusChanged(Control: TControl); -begin - inherited FocusChanged(Control); - DockSite.Invalidate; -end; - procedure TJvDockVIDVCTree.WindowProc(var Msg: TMessage); var Align: TAlign; @@ -2395,8 +2390,9 @@ begin inherited CustomDockDrop(Source, X, Y); ParentForm.Caption := ''; - if JvDockManager <> nil then - JvDockManager.FocusChanged(Source.Control); + {$IFNDEF COMPILER9_UP} + InvalidateDockHostSiteOfControl(Source.Control, False); + {$ENDIF !COMPILER9_UP} if (Source.Control is TWinControl) and Source.Control.Visible and TWinControl(Source.Control).CanFocus then TWinControl(Source.Control).SetFocus; @@ -2645,15 +2641,16 @@ begin inherited Change; ParentForm.Caption := ActivePage.Caption; + if ParentForm.HostDockSite is TJvDockCustomPanel then begin - if ParentForm.Visible and ParentForm.CanFocus then - ParentForm.SetFocus; + // if ParentForm.Visible and ParentForm.CanFocus then + // ParentForm.SetFocus; ParentForm.HostDockSite.Invalidate; end; - if (ActivePage <> nil) and (ActivePage.Visible) and (ActivePage.CanFocus) then - if ParentForm.Visible and ParentForm.CanFocus then - ActivePage.SetFocus; + // if (ActivePage <> nil) and (ActivePage.Visible) and (ActivePage.CanFocus) then + // if ParentForm.Visible and ParentForm.CanFocus then + // ActivePage.SetFocus; end; procedure TJvDockVIDVCTabPageControl.AdjustClientRect(var Rect: TRect); @@ -3197,6 +3194,7 @@ Index: Integer; Msg: TWMMouse; Sheet: TJvDockVIDVCTabSheet; + AParentForm: TCustomForm; begin inherited MouseDown(Button, Shift, X, Y); if Page = nil then @@ -3207,6 +3205,12 @@ begin if Index <> Page.ActivePageIndex then begin + if Assigned(Page.ActivePage) and Page.ActivePage.CanFocus then + begin + AParentForm := GetParentForm(Page); + if Assigned(AParentForm) then + AParentForm.ActiveControl := Page.ActivePage; + end; Sheet := Page.ActiveVIDPage; Page.ActivePageIndex := Index; Sheet.SetSheetSort(Sheet.Caption); @@ -3780,7 +3784,6 @@ end; {$IFNDEF USEJVCL} - function TJvDockVIDVCStyle.GetControlName: string; begin Result := Format(RsDockLikeVIDStyle, [inherited GetControlName]); Modified: trunk/jvcl/run/JvDockVSNetStyle.pas =================================================================== --- trunk/jvcl/run/JvDockVSNetStyle.pas 2007-04-05 10:52:00 UTC (rev 11251) +++ trunk/jvcl/run/JvDockVSNetStyle.pas 2007-04-05 22:12:55 UTC (rev 11252) @@ -273,7 +273,6 @@ TJvDockVSNetStyle = class(TJvDockVIDStyle) private - FMouseleaved: Boolean; { Is the mouse over *any* of the forms with this style } FTimer: TTimer; FDockServers: TList; FCurrentTimer: Integer; @@ -1166,17 +1165,13 @@ end; procedure TJvDockVSChannel.AutoFocusActiveDockForm; -var - JvDockManager: IJvDockManager; begin if DockServer.AutoFocusDockedForm and Assigned(ActiveDockForm) and ActiveDockForm.CanFocus then begin ActiveDockForm.SetFocus; - if TWinControlAccessProtected(ActiveDockForm).UseDockManager and - Supports(TWinControlAccessProtected(ActiveDockForm).DockManager, IJvDockManager, JvDockManager) then - begin - JvDockManager.FocusChanged(ActiveDockForm); - end; + {$IFNDEF COMPILER9_UP} + InvalidateDockHostSiteOfControl(ActiveDockForm, False); + {$ENDIF !COMPILER9_UP} end; end; @@ -2238,7 +2233,6 @@ constructor TJvDockVSNetStyle.Create(AOwner: TComponent); begin inherited Create(AOwner); - FMouseleaved := True; DockPanelClass := TJvDockVSNETPanel; DockSplitterClass := TJvDockVSNETSplitter; ConjoinPanelClass := TJvDockVSNETConjoinPanel; @@ -2312,22 +2306,9 @@ var Msg: TMessage): Boolean; var Channel: TJvDockVSChannel; - FormRect: TRect; - MPosTp: TPoint; begin Result := inherited DockClientWindowProc(DockClient, Msg); case Msg.Msg of - CM_MOUSEENTER: - begin - FMouseleaved := False; - end; - CM_MOUSELEAVE: //Fix bug on AutoHide --Dejoy. - begin - GetCursorPos(MPosTp); - GetWindowRect(DockClient.ParentForm.Handle, FormRect); - if not PtInRect(FormRect, MPosTp) then - FMouseleaved := True; - end; CM_ENTER, CM_EXIT: begin Channel := RetrieveChannel(DockClient.ParentForm.HostDockSite); @@ -2649,14 +2630,10 @@ Exit; end; - if not FMouseleaved then - Exit; - Dec(FCurrentTimer, 100); if FCurrentTimer > 0 then Exit; - if FCurrentTimer < 0 then - DestroyTimer; + DestroyTimer; for I := 0 to FDockServers.Count - 1 do begin This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |