mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 21:29:27 +01:00 
			
		
		
		
	 a66f070242
			
		
	
	
		a66f070242
		
	
	
	
	
		
			
			* lhelp now will highlight the item in the TOC if it exists when a link is clicked in a document git-svn-id: trunk@21945 -
		
			
				
	
	
		
			108 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
			
		
		
	
	
			108 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
| unit BaseContentProvider;
 | |
| 
 | |
| {$mode objfpc}{$H+}
 | |
| 
 | |
| interface
 | |
| 
 | |
| uses
 | |
|   Classes, SysUtils, Controls;
 | |
|   
 | |
| type
 | |
| 
 | |
|   { TBaseContentProvider }
 | |
| 
 | |
|   TBaseContentProviderClass = Class of TBaseContentProvider;
 | |
|   TBaseContentProvider = class(TObject)
 | |
|   private
 | |
|     fParent: TWinControl;
 | |
|     FTitle: String;
 | |
|   protected
 | |
|     fImageList: TImageList;
 | |
|     function GetTitle: String; virtual;
 | |
|     procedure SetTitle(const AValue: String); virtual;
 | |
|   public
 | |
|     function CanGoBack: Boolean; virtual; abstract;
 | |
|     function CanGoForward: Boolean; virtual; abstract;
 | |
|     function GetHistory: TStrings; virtual; abstract;
 | |
|     function LoadURL(const AURL: String; const AContext: THelpContext=-1): Boolean; virtual; abstract;
 | |
|     procedure GoHome; virtual; abstract;
 | |
|     procedure GoBack; virtual; abstract;
 | |
|     procedure GoForward; virtual; abstract;
 | |
|     class function GetProperContentProvider(const AURL: String): TBaseContentProviderClass; virtual; abstract;
 | |
|     constructor Create(AParent: TWinControl; AImageList: TImageList); virtual;
 | |
|     property Parent: TWinControl read fParent;
 | |
|     property Title: String read GetTitle write SetTitle;
 | |
|   end;
 | |
|   
 | |
| 
 | |
| 
 | |
| 
 | |
|   // returns false if the protocol has already been registered
 | |
|   function RegisterContentProvider(const Protocol: String; ContentProvider: TBaseContentProviderClass): Boolean;
 | |
|   // example: RegisterContentProvider('chm://', TChmContentProvider);
 | |
|   
 | |
|   function GetContentProvider(const Protocol: String): TBaseContentProviderClass;
 | |
| 
 | |
|   // Result must be freed by caller
 | |
|   function GetContentProviderList: TStringList;
 | |
| 
 | |
| implementation
 | |
| 
 | |
| var
 | |
|   ContentProviders: TStringList;
 | |
| 
 | |
| function RegisterContentProvider(const Protocol: String;
 | |
|   ContentProvider: TBaseContentProviderClass): Boolean;
 | |
| begin
 | |
|   Result := False;
 | |
|   if ContentProviders.IndexOf(Protocol) > -1 then exit;
 | |
|   ContentProviders.AddObject(Protocol, TObject(ContentProvider));
 | |
| end;
 | |
| 
 | |
| function GetContentProvider(const Protocol: String): TBaseContentProviderClass;
 | |
| var
 | |
|   fIndex: Integer;
 | |
| begin
 | |
|   Result := nil;
 | |
|   fIndex := ContentProviders.IndexOf(Protocol);
 | |
|   if fIndex = -1 then Exit;
 | |
|   
 | |
|   Result := TBaseContentProviderClass(ContentProviders.Objects[fIndex]);
 | |
| end;
 | |
| 
 | |
| function GetContentProviderList: TStringList;
 | |
| begin
 | |
|   Result := TStringList.Create;
 | |
|   Result.AddStrings(ContentProviders);
 | |
| end;
 | |
| 
 | |
| 
 | |
| 
 | |
| { TBaseContentProvider }
 | |
| 
 | |
| function TBaseContentProvider.GetTitle: String;
 | |
| begin
 | |
|   Result := '';
 | |
| end;
 | |
| 
 | |
| procedure TBaseContentProvider.SetTitle(const AValue: String);
 | |
| begin
 | |
|   FTitle := AValue;
 | |
| end;
 | |
| 
 | |
| constructor TBaseContentProvider.Create(AParent: TWinControl; AImageList: TImageList);
 | |
| begin
 | |
|   fParent:= AParent;
 | |
|   fImageList:= AImageList;
 | |
| end;
 | |
| 
 | |
| initialization
 | |
|   ContentProviders := TStringList.Create;
 | |
| 
 | |
| finalization
 | |
| 
 | |
|   ContentProviders.Free;
 | |
| 
 | |
| end.
 | |
| 
 |