From fa83cfbcf9c8dabcfbcb4899bdc17e19077e0517 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 13 May 2006 12:58:32 +0000 Subject: [PATCH] added TCustomForm.IntfHelp - a method to be called by the interfaces git-svn-id: trunk@9274 - --- ideintf/helpintf.pas | 7 ++----- lcl/forms.pp | 7 +++++-- lcl/include/application.inc | 38 ++++++++++++++----------------------- lcl/include/customform.inc | 35 +++++++++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/ideintf/helpintf.pas b/ideintf/helpintf.pas index 7269c92dc7..972adadb32 100644 --- a/ideintf/helpintf.pas +++ b/ideintf/helpintf.pas @@ -685,8 +685,8 @@ type end; var - HelpDatabases: THelpDatabases; // initialized by the IDE - HelpViewers: THelpViewers; // initialized by the IDE + HelpDatabases: THelpDatabases = nil; // initialized by the IDE + HelpViewers: THelpViewers = nil; // initialized by the IDE //============================================================================== { Showing help (how it works): @@ -2677,8 +2677,5 @@ begin BaseURL:=TheBaseURL; end; -initialization - HelpDatabases:=nil; - end. diff --git a/lcl/forms.pp b/lcl/forms.pp index 1d965f356d..472129685a 100644 --- a/lcl/forms.pp +++ b/lcl/forms.pp @@ -498,6 +498,7 @@ type procedure AddHandlerCreate(OnCreateHandler: TNotifyEvent; AsLast: Boolean=true); procedure RemoveHandlerCreate(OnCreateHandler: TNotifyEvent); function IsShortcut(var Message: TLMKey): boolean; + procedure IntfHelp(AComponent: TComponent); public // drag and dock procedure Dock(NewDockSite: TWinControl; ARect: TRect); override; @@ -977,9 +978,11 @@ type function UpdateAction(TheAction: TBasicAction): Boolean; override; procedure HandleException(Sender: TObject); override; procedure HandleMessage; - function HelpCommand(Command: Word; Data: Longint): Boolean; + function HelpContext(Sender: TObject; const Position: TPoint; + Context: THelpContext): Boolean; function HelpContext(Context: THelpContext): Boolean; - function HelpJump(const JumpID: string): Boolean; + function HelpKeyword(Sender: TObject; const Position: TPoint; + const Keyword: String): Boolean; function HelpKeyword(const Keyword: String): Boolean; procedure HideAllFormsWithStayOnTop; function IsWaiting: boolean; diff --git a/lcl/include/application.inc b/lcl/include/application.inc index 0c0896abb4..12d7e8e0c4 100644 --- a/lcl/include/application.inc +++ b/lcl/include/application.inc @@ -920,18 +920,8 @@ begin if not Terminated then Idle(true); end; -{------------------------------------------------------------------------------ - function TApplication.HelpCommand(Command: Word; Data: Longint): Boolean; -------------------------------------------------------------------------------} -function TApplication.HelpCommand(Command: Word; Data: Longint): Boolean; -begin - Result := InvokeHelp(Command, Data); -end; - -{------------------------------------------------------------------------------ - function TApplication.HelpContext(Context: THelpContext): Boolean; -------------------------------------------------------------------------------} -function TApplication.HelpContext(Context: THelpContext): Boolean; +function TApplication.HelpContext(Sender: TObject; const Position: TPoint; + Context: THelpContext): Boolean; begin if ValidateHelpSystem then begin Result := true; @@ -941,13 +931,19 @@ begin end; {------------------------------------------------------------------------------ - function TApplication.HelpJump(const JumpID: string): Boolean; + function TApplication.HelpContext(Context: THelpContext): Boolean; ------------------------------------------------------------------------------} -function TApplication.HelpJump(const JumpID: string): Boolean; +function TApplication.HelpContext(Context: THelpContext): Boolean; +begin + Result:=HelpContext(nil,Point(0,0),Context); +end; + +function TApplication.HelpKeyword(Sender: TObject; const Position: TPoint; + const Keyword: String): Boolean; begin if ValidateHelpSystem then begin Result := true; - //HelpSystem.ShowTopicHelp(JumpID, GetCurrentHelpFile); + //HelpSystem.ShowHelp(Keyword, GetCurrentHelpFile); end else Result := false; end; @@ -957,11 +953,7 @@ end; ------------------------------------------------------------------------------} function TApplication.HelpKeyword(const Keyword: String): Boolean; begin - if ValidateHelpSystem then begin - Result := true; - //HelpSystem.ShowHelp(Keyword, GetCurrentHelpFile); - end else - Result := false; + Result:=HelpKeyword(nil,Point(0,0),Keyword); end; {------------------------------------------------------------------------------ @@ -1400,10 +1392,9 @@ begin end; {------------------------------------------------------------------------------ - procedure TApplication.IntfEndSession(); + procedure TApplication.IntfEndSession; ------------------------------------------------------------------------------} - -procedure TApplication.IntfEndSession(); +procedure TApplication.IntfEndSession; begin if Assigned(FOnEndSession) then FOnEndSession(Self); end; @@ -1411,7 +1402,6 @@ end; {------------------------------------------------------------------------------ procedure TApplication.IntfQueryEndSession(var Cancel : Boolean); ------------------------------------------------------------------------------} - procedure TApplication.IntfQueryEndSession(var Cancel : Boolean); begin if Assigned(FOnQueryEndSession) then FOnQueryEndSession(Cancel); diff --git a/lcl/include/customform.inc b/lcl/include/customform.inc index eb0fdad398..c693973435 100644 --- a/lcl/include/customform.inc +++ b/lcl/include/customform.inc @@ -1666,6 +1666,39 @@ begin end; end; +{------------------------------------------------------------------------------ + procedure TCustomForm.IntfHelp(AComponent: TComponent); + + Show help for control or menu item. + This function is called by the interface. +------------------------------------------------------------------------------} +procedure TCustomForm.IntfHelp(AComponent: TComponent); +var + AControl: TControl; +begin + if AComponent is TControl then begin + AControl:=TControl(AComponent); + repeat + if AControl.HelpType=htContext then begin + if AControl.HelpContext<>0 then begin + Application.HelpContext(Self,AControl.ClientToScreen(Point(0,0)), + AControl.HelpContext); + exit; + end; + end else begin + if AControl.HelpKeyword<>'' then begin + Application.HelpKeyword(Self,AControl.ClientToScreen(Point(0,0)), + AControl.HelpKeyword); + exit; + end; + end; + AControl:=AControl.Parent; + until AControl=nil; + end else begin + DebugLn('TCustomForm.IntfHelp TODO help for ',DbgSName(AComponent)); + end; +end; + {------------------------------------------------------------------------------ Method: TCustomForm.CreateWnd Params: None @@ -2003,4 +2036,4 @@ begin if Owner is TControl then TControl(Owner).RemoveAllHandlersOfObject(Self); inherited Destroy; -end; \ No newline at end of file +end;