diff --git a/examples/idehelp/demoidehelp.lpk b/examples/idehelp/demoidehelp.lpk index 25ffbbc4fc..fe023de180 100644 --- a/examples/idehelp/demoidehelp.lpk +++ b/examples/idehelp/demoidehelp.lpk @@ -22,10 +22,13 @@ - + - + + + + diff --git a/examples/idehelp/myidehelp.lfm b/examples/idehelp/myidehelp.lfm index 130bfe576d..d7e3ce6b6a 100644 --- a/examples/idehelp/myidehelp.lfm +++ b/examples/idehelp/myidehelp.lfm @@ -1,9 +1,180 @@ object MyHelpSetupDialog: TMyHelpSetupDialog - Height = 384 - Width = 581 - ClientHeight = 384 - ClientWidth = 581 + Left = 0 + Height = 474 + Top = 0 + Width = 767 + ClientHeight = 474 + ClientWidth = 767 TabOrder = 0 - DesignLeft = 358 - DesignTop = 166 + DesignLeft = 270 + DesignTop = 332 + object PageControl1: TPageControl + Left = 0 + Height = 474 + Top = 0 + Width = 767 + ActivePage = ContextTabSheet + Align = alClient + TabIndex = 3 + TabOrder = 0 + object FPCKeywordsTabSheet: TTabSheet + Caption = 'FPCKeywordsTabSheet' + ClientHeight = 442 + ClientWidth = 761 + object FPCKeywordsMemo: TMemo + AnchorSideTop.Control = FPCKeywordsEnableCheckBox + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 381 + Top = 55 + Width = 749 + Align = alBottom + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Around = 6 + Lines.Strings = ( + 'FPCKeywordsMemo' + ) + TabOrder = 0 + end + object FPCKeywordsEnableCheckBox: TCheckBox + AnchorSideLeft.Control = FPCKeywordsTabSheet + AnchorSideTop.Control = FPCKeywordsNoteLabel + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 22 + Top = 27 + Width = 189 + BorderSpacing.Around = 6 + Caption = 'FPCKeywordsEnableCheckBox' + TabOrder = 1 + end + object FPCKeywordsNoteLabel: TLabel + Left = 6 + Height = 15 + Top = 6 + Width = 749 + Align = alTop + BorderSpacing.Around = 6 + Caption = 'FPCKeywordsNoteLabel' + ParentColor = False + WordWrap = True + end + end + object DirectivesTabSheet: TTabSheet + Caption = 'DirectivesTabSheet' + ClientHeight = 442 + ClientWidth = 761 + object DirectivesNoteLabel: TLabel + Left = 6 + Height = 15 + Top = 6 + Width = 749 + Align = alTop + BorderSpacing.Around = 6 + Caption = 'DirectivesNoteLabel' + ParentColor = False + WordWrap = True + end + object DirectivesEnableCheckBox: TCheckBox + AnchorSideLeft.Control = DirectivesTabSheet + AnchorSideTop.Control = DirectivesNoteLabel + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 22 + Top = 27 + Width = 170 + BorderSpacing.Around = 6 + Caption = 'DirectivesEnableCheckBox' + TabOrder = 0 + end + object DirectivesMemo: TMemo + AnchorSideTop.Control = DirectivesEnableCheckBox + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 381 + Top = 55 + Width = 749 + Align = alBottom + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Around = 6 + Lines.Strings = ( + 'DirectivesMemo' + ) + TabOrder = 1 + end + end + object MessagesTabSheet: TTabSheet + Caption = 'MessagesTabSheet' + ClientHeight = 442 + ClientWidth = 761 + object MessagesNoteLabel: TLabel + Left = 6 + Height = 15 + Top = 6 + Width = 749 + Align = alTop + BorderSpacing.Around = 6 + Caption = 'MessagesNoteLabel' + ParentColor = False + end + object MessagesEnableCheckBox: TCheckBox + AnchorSideLeft.Control = MessagesTabSheet + AnchorSideTop.Control = MessagesNoteLabel + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 22 + Top = 27 + Width = 171 + BorderSpacing.Around = 6 + Caption = 'MessagesEnableCheckBox' + TabOrder = 0 + end + end + object ContextTabSheet: TTabSheet + Caption = 'ContextTabSheet' + ClientHeight = 442 + ClientWidth = 761 + object ContextNoteLabel: TLabel + Left = 6 + Height = 15 + Top = 6 + Width = 749 + Align = alTop + BorderSpacing.Around = 6 + Caption = 'ContextNoteLabel' + ParentColor = False + end + object ContextEnableCheckBox: TCheckBox + AnchorSideLeft.Control = ContextTabSheet + AnchorSideTop.Control = ContextNoteLabel + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 22 + Top = 27 + Width = 159 + BorderSpacing.Around = 6 + Caption = 'ContextEnableCheckBox' + TabOrder = 0 + end + object ContextMemo: TMemo + AnchorSideTop.Control = ContextEnableCheckBox + Left = 6 + Height = 90 + Top = 346 + Width = 749 + Align = alBottom + BorderSpacing.Around = 6 + Lines.Strings = ( + 'ContextMemo' + ) + TabOrder = 1 + end + end + object ClassesTabSheet: TTabSheet + Caption = 'ClassesTabSheet' + end + object SourcesTabSheet: TTabSheet + Caption = 'SourcesTabSheet' + end + end end diff --git a/examples/idehelp/myidehelp.pas b/examples/idehelp/myidehelp.pas index 60147c6e02..2ce7057ad7 100644 --- a/examples/idehelp/myidehelp.pas +++ b/examples/idehelp/myidehelp.pas @@ -45,7 +45,8 @@ interface uses Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs, - LazHelpIntf, HelpIntfs, IDEHelpIntf, IDEDialogs, IDEOptionsIntf; + LazHelpIntf, HelpIntfs, ComCtrls, StdCtrls, IDEHelpIntf, IDEDialogs, + IDEOptionsIntf; const MyHelpOptionID: integer = 10000; // an arbitrary number, choose a big number @@ -63,6 +64,7 @@ type FAllKeywordNode: THelpNode; public KeywordToText: TStrings; // every line has the format: Keyword=Text + Enabled: boolean; constructor Create(TheOwner: TComponent); override; destructor Destroy; override; function GetNodesForKeyword(const HelpKeyword: string; @@ -85,6 +87,7 @@ type private FAllDirectiveNode: THelpNode; public + Enabled: boolean; FPCDirectiveToText: TStrings; // every line has the format: Keyword=Text IDEDirectiveToText: TStrings; // every line has the format: Keyword=Text constructor Create(TheOwner: TComponent); override; @@ -109,6 +112,8 @@ type private FAllMessageNode: THelpNode; public + Enabled: boolean; + constructor Create(TheOwner: TComponent); override; function GetNodesForMessage(const AMessage: string; MessageParts: TStrings; var ListOfNodes: THelpNodeQueryList; var ErrMsg: string ): TShowHelpResult; override; @@ -133,6 +138,7 @@ type private FAllContextNode: THelpNode; public + Enabled: boolean; ContextToMessage: TStrings; // every line has the format: DecimalNumber=Text constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -150,8 +156,28 @@ type { TMyHelpSetupDialog } TMyHelpSetupDialog = class(TAbstractIDEOptionsEditor) + ContextEnableCheckBox: TCheckBox; + ContextMemo: TMemo; + ContextNoteLabel: TLabel; + DirectivesEnableCheckBox: TCheckBox; + DirectivesMemo: TMemo; + DirectivesNoteLabel: TLabel; + FPCKeywordsEnableCheckBox: TCheckBox; + FPCKeywordsMemo: TMemo; + FPCKeywordsNoteLabel: TLabel; + MessagesEnableCheckBox: TCheckBox; + MessagesNoteLabel: TLabel; + PageControl1: TPageControl; + FPCKeywordsTabSheet: TTabSheet; + DirectivesTabSheet: TTabSheet; + MessagesTabSheet: TTabSheet; + ContextTabSheet: TTabSheet; + SourcesTabSheet: TTabSheet; + ClassesTabSheet: TTabSheet; private public + HelpShortCutAsText: string; + PkgName: string; function GetTitle: String; override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; @@ -166,8 +192,8 @@ implementation procedure Register; begin // register help databases - // For demonstration purpose one help database per help type - // Normally you would combine them into one or a few. + // For demonstration purpose there is one help database per help type. + // Normally you would combine them into one database. MyFPCKeywordHelpDatabase:=TMyFPCKeywordHelpDatabase( HelpDatabases.CreateHelpDatabase('MyFPCKeyWordHelpDB',TMyFPCKeywordHelpDatabase,true)); MyDirectiveHelpDatabase:=TMyDirectiveHelpDatabase( @@ -190,11 +216,41 @@ end; procedure TMyHelpSetupDialog.ReadSettings(AOptions: TAbstractIDEOptions); begin + // fpc keywords + FPCKeywordsEnableCheckBox.Checked:=MyFPCKeywordHelpDatabase.Enabled; + FPCKeywordsMemo.Text:=Trim(MyFPCKeywordHelpDatabase.KeywordToText.Text); + // directives + + // messages + + // context + + // classes + + // sources end; procedure TMyHelpSetupDialog.Setup(ADialog: TAbstractOptionsEditorDialog); begin + HelpShortCutAsText:='F1'; + PkgName:='DemoIDEHelp'; + + // fpc keywords + FPCKeywordsNoteLabel.Caption:='Simple help for FPC keywords installed by package '+PkgName+'.' + +' You get this help when you press the help key ('+HelpShortCutAsText+') in the source editor and caret is not on an identifier.' + +' Each line has the format "keyword=text" without the quotes. For example "repeat=This keyword starts a repeat-until loop."'; + FPCKeywordsEnableCheckBox.Caption:='Enable'; + + // directives + + // messages + + // context + + // classes + + // sources end; @@ -207,6 +263,19 @@ end; procedure TMyHelpSetupDialog.WriteSettings(AOptions: TAbstractIDEOptions); begin + // fpc keywords + MyFPCKeywordHelpDatabase.Enabled:=FPCKeywordsEnableCheckBox.Checked; + MyFPCKeywordHelpDatabase.KeywordToText.Text:=Trim(FPCKeywordsMemo.Text); + + // directives + + // messages + + // context + + // classes + + // sources end; @@ -215,6 +284,7 @@ end; constructor TMyContextHelpDatabase.Create(TheOwner: TComponent); begin inherited Create(TheOwner); + Enabled:=true; ContextToMessage:=TStringList.Create; ContextToMessage.Add('3456=A help text for helpcontext 3456'); end; @@ -233,7 +303,7 @@ var begin ErrMsg:=''; Result:=shrHelpNotFound; - if (csDesigning in ComponentState) then exit; + if (csDesigning in ComponentState) or (not Enabled) then exit; Msg:=ContextToMessage.Values[IntToStr(HelpContext)]; if Msg='' then exit; @@ -272,6 +342,12 @@ end; { TMyMessagesHelpDatabase } +constructor TMyMessagesHelpDatabase.Create(TheOwner: TComponent); +begin + inherited Create(TheOwner); + Enabled:=true; +end; + function TMyMessagesHelpDatabase.GetNodesForMessage(const AMessage: string; MessageParts: TStrings; var ListOfNodes: THelpNodeQueryList; var ErrMsg: string): TShowHelpResult; @@ -280,7 +356,7 @@ var begin ErrMsg:=''; Result:=shrHelpNotFound; - if (csDesigning in ComponentState) then exit; + if (csDesigning in ComponentState) or (not Enabled) then exit; debugln(['TMyMessagesHelpDatabase.GetNodesForDirective AMessage="',AMessage,'" Parts="',MessageParts.Text,'"']); // check if the message fits @@ -324,6 +400,7 @@ end; constructor TMyDirectiveHelpDatabase.Create(TheOwner: TComponent); begin inherited Create(TheOwner); + Enabled:=true; FPCDirectiveToText:=TStringList.Create; FPCDirectiveToText.Add('mode=Set the syntax, e.g. fpc, objfpc, delphi, macpas, tp'); IDEDirectiveToText:=TStringList.Create; @@ -346,7 +423,7 @@ var Title: String; begin Result:=shrHelpNotFound; - if (csDesigning in ComponentState) then exit; + if (csDesigning in ComponentState) or (not Enabled) then exit; debugln(['TMyDirectiveHelpDatabase.GetNodesForDirective HelpDirective="',HelpDirective,'"']); if (FPCDirectiveHelpPrefix<>'') and (LeftStr(HelpDirective,length(FPCDirectiveHelpPrefix))=FPCDirectiveHelpPrefix) @@ -416,6 +493,7 @@ end; constructor TMyFPCKeywordHelpDatabase.Create(TheOwner: TComponent); begin inherited Create(TheOwner); + Enabled:=true; KeywordToText:=TStringList.Create; KeywordToText.Add('procedure=Named code block'); end; @@ -434,7 +512,7 @@ var i: Integer; begin Result:=shrHelpNotFound; - if (csDesigning in ComponentState) then exit; + if (csDesigning in ComponentState) or (not Enabled) then exit; if (FPCKeyWordHelpPrefix='') or (LeftStr(HelpKeyword,length(FPCKeyWordHelpPrefix))<>FPCKeyWordHelpPrefix) then exit;