fpbrowser: Starts moving the controls to the tabs
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1949 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
3b020a82c2
commit
e1f2a19114
@ -27,6 +27,7 @@ type
|
||||
function GetDocumentTitle: string; virtual; abstract;
|
||||
procedure SetShowImages(AValue: Boolean); virtual; abstract;
|
||||
procedure HandlePageLoaderTerminated(Sender: TObject); virtual;
|
||||
procedure Reload; virtual; abstract;
|
||||
end;
|
||||
|
||||
TBrowserViewerClass = class of TBrowserViewer;
|
||||
|
@ -44,63 +44,13 @@ object formBrowser: TformBrowser
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object panelTop: TPanel
|
||||
Left = 0
|
||||
Height = 33
|
||||
Top = 0
|
||||
Width = 621
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 33
|
||||
ClientWidth = 621
|
||||
TabOrder = 1
|
||||
object editURL: TEdit
|
||||
Left = 190
|
||||
Height = 24
|
||||
Top = 4
|
||||
Width = 337
|
||||
AutoSize = False
|
||||
OnKeyDown = editURLKeyDown
|
||||
TabStop = False
|
||||
TabOrder = 3
|
||||
end
|
||||
object buttonReload: TButton
|
||||
Left = 10
|
||||
Height = 24
|
||||
Top = 4
|
||||
Width = 59
|
||||
Caption = '&Reload'
|
||||
OnClick = buttonReloadClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object buttonBack: TButton
|
||||
Left = 69
|
||||
Height = 24
|
||||
Top = 4
|
||||
Width = 59
|
||||
Caption = '&Back'
|
||||
Enabled = False
|
||||
OnClick = FwdBackClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object buttonForward: TButton
|
||||
Left = 128
|
||||
Height = 24
|
||||
Top = 4
|
||||
Width = 59
|
||||
Caption = '&Forward'
|
||||
Enabled = False
|
||||
OnClick = FwdBackClick
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object pageBrowser: TPageControl
|
||||
Left = 0
|
||||
Height = 388
|
||||
Top = 33
|
||||
Height = 421
|
||||
Top = 0
|
||||
Width = 621
|
||||
Align = alClient
|
||||
TabOrder = 2
|
||||
TabOrder = 1
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
DefaultExt = '.htm'
|
||||
|
@ -13,58 +13,47 @@ LazarusResources.Add('TformBrowser','FORMDATA',[
|
||||
+#0#12'TProgressBar'#11'ProgressBar'#4'Left'#3#214#1#6'Height'#2#16#3'Top'#2#1
|
||||
+#5'Width'#3#150#0#5'Align'#7#7'alRight'#8'TabOrder'#2#0#0#0#6'TLabel'#13'lab'
|
||||
+'elProgress'#4'Left'#3'?'#1#6'Height'#2#16#3'Top'#2#3#5'Width'#2#22#7'Captio'
|
||||
+'n'#6#4'Idle'#11'ParentColor'#8#0#0#0#6'TPanel'#8'panelTop'#4'Left'#2#0#6'He'
|
||||
+'ight'#2'!'#3'Top'#2#0#5'Width'#3'm'#2#5'Align'#7#5'alTop'#10'BevelOuter'#7#6
|
||||
+'bvNone'#12'ClientHeight'#2'!'#11'ClientWidth'#3'm'#2#8'TabOrder'#2#1#0#5'TE'
|
||||
+'dit'#7'editURL'#4'Left'#3#190#0#6'Height'#2#24#3'Top'#2#4#5'Width'#3'Q'#1#8
|
||||
+'AutoSize'#8#9'OnKeyDown'#7#14'editURLKeyDown'#7'TabStop'#8#8'TabOrder'#2#3#0
|
||||
+#0#7'TButton'#12'buttonReload'#4'Left'#2#10#6'Height'#2#24#3'Top'#2#4#5'Widt'
|
||||
+'h'#2';'#7'Caption'#6#7'&Reload'#7'OnClick'#7#17'buttonReloadClick'#8'TabOrd'
|
||||
+'er'#2#0#0#0#7'TButton'#10'buttonBack'#4'Left'#2'E'#6'Height'#2#24#3'Top'#2#4
|
||||
+#5'Width'#2';'#7'Caption'#6#5'&Back'#7'Enabled'#8#7'OnClick'#7#12'FwdBackCli'
|
||||
+'ck'#8'TabOrder'#2#1#0#0#7'TButton'#13'buttonForward'#4'Left'#3#128#0#6'Heig'
|
||||
+'ht'#2#24#3'Top'#2#4#5'Width'#2';'#7'Caption'#6#8'&Forward'#7'Enabled'#8#7'O'
|
||||
+'nClick'#7#12'FwdBackClick'#8'TabOrder'#2#2#0#0#0#12'TPageControl'#11'pageBr'
|
||||
+'owser'#4'Left'#2#0#6'Height'#3#132#1#3'Top'#2'!'#5'Width'#3'm'#2#5'Align'#7
|
||||
+#8'alClient'#8'TabOrder'#2#2#0#0#11'TOpenDialog'#10'OpenDialog'#10'DefaultEx'
|
||||
+'t'#6#4'.htm'#6'Filter'#6'%html files|*.htm;*.html|all files|*.*'#7'Options'
|
||||
+#11#14'ofHideReadOnly'#15'ofPathMustExist'#15'ofFileMustExist'#0#4'left'#3'I'
|
||||
+#1#3'top'#2#2#0#0#9'TMainMenu'#8'MainMenu'#4'left'#3'#'#1#3'top'#2#4#0#9'TMe'
|
||||
+'nuItem'#5'File1'#7'Caption'#6#5'&File'#0#9'TMenuItem'#4'Open'#7'Caption'#6#5
|
||||
+'&Open'#8'ShortCut'#2'r'#7'OnClick'#7#13'OpenFileClick'#0#0#9'TMenuItem'#12
|
||||
+'OpenTextFile'#7'Caption'#6#15'Open &Text File'#7'OnClick'#7#17'OpenTextFile'
|
||||
+'Click'#0#0#9'TMenuItem'#13'OpenImageFile'#7'Caption'#6#16'Open &Image File'
|
||||
+#7'OnClick'#7#18'OpenImageFileClick'#0#0#9'TMenuItem'#13'PrinterSetup1'#7'Ca'
|
||||
+'ption'#6#16'Printer Setup...'#7'OnClick'#7#18'PrinterSetup1Click'#0#0#9'TMe'
|
||||
+'nuItem'#12'Printpreview'#7'Caption'#6#14'Print pre&view'#7'Enabled'#8#7'OnC'
|
||||
+'lick'#7#17'PrintpreviewClick'#0#0#9'TMenuItem'#6'Print1'#7'Caption'#6#9'&Pr'
|
||||
+'int...'#7'Enabled'#8#7'OnClick'#7#11'Print1Click'#0#0#9'TMenuItem'#2'N1'#7
|
||||
+'Caption'#6#1'-'#0#0#9'TMenuItem'#5'Exit1'#7'Caption'#6#5'E&xit'#7'OnClick'#7
|
||||
+#10'Exit1Click'#0#0#0#9'TMenuItem'#5'Edit2'#7'Caption'#6#5'&Edit'#7'OnClick'
|
||||
+#7#10'Edit2Click'#0#9'TMenuItem'#5'Find1'#7'Caption'#6#5'&Find'#7'Enabled'#8
|
||||
+#7'OnClick'#7#10'Find1Click'#0#0#9'TMenuItem'#8'CopyItem'#7'Caption'#6#5'&Co'
|
||||
+'py'#8'ShortCut'#3'C@'#7'OnClick'#7#13'CopyItemClick'#0#0#9'TMenuItem'#2'N2'
|
||||
+#7'Caption'#6#1'-'#0#0#9'TMenuItem'#13'SelectAllItem'#7'Caption'#6#11'Select'
|
||||
+' &All'#7'Enabled'#8#7'OnClick'#7#18'SelectAllItemClick'#0#0#0#9'TMenuItem'#8
|
||||
+'options1'#7'Caption'#6#6'&Tools'#0#9'TMenuItem'#10'ShowImages'#7'Caption'#6
|
||||
+#12'&Show images'#7'OnClick'#7#15'ShowImagesClick'#0#0#9'TMenuItem'#5'Fonts'
|
||||
+#7'Caption'#6#23'Default &Font/Colors...'#7'OnClick'#7#15'FontColorsClick'#0
|
||||
+#0#9'TMenuItem'#13'menuViewDebug'#7'Caption'#6#26'View Source and Debug info'
|
||||
+#7'OnClick'#7#18'menuViewDebugClick'#0#0#0#9'TMenuItem'#15'HistoryMenuItem'#7
|
||||
+'Caption'#6#8'&History'#7'Visible'#8#0#0#9'TMenuItem'#6'About1'#7'Caption'#6
|
||||
+#6'&About'#7'OnClick'#7#11'About1Click'#0#0#0#12'TPrintDialog'#11'PrintDialo'
|
||||
+'g'#8'FromPage'#2#1#7'MinPage'#2#1#7'MaxPage'#3#15''''#7'Options'#11#10'poPa'
|
||||
+'geNums'#0#6'ToPage'#2#1#4'left'#3'j'#1#3'top'#2#1#0#0#11'TFindDialog'#10'Fi'
|
||||
+'ndDialog'#7'Options'#11#6'frDown'#15'frHideWholeWord'#18'frDisableWholeWord'
|
||||
+#0#6'OnFind'#7#14'FindDialogFind'#4'left'#3#248#0#3'top'#2#4#0#0#10'TPopupMe'
|
||||
+'nu'#9'PopupMenu'#4'left'#3#144#1#3'top'#2#1#0#9'TMenuItem'#9'Viewimage'#7'C'
|
||||
+'aption'#6#11'&View image'#7'OnClick'#7#14'ViewimageClick'#0#0#9'TMenuItem'
|
||||
+#20'CopyImageToClipboard'#7'Caption'#6#24'&Copy image to clipboard'#7'OnClic'
|
||||
+'k'#7#25'CopyImageToClipboardClick'#0#0#9'TMenuItem'#2'N3'#7'Caption'#6#1'-'
|
||||
+#0#0#9'TMenuItem'#15'OpenInNewWindow'#7'Caption'#6#19'&Open in new window'#7
|
||||
+'OnClick'#7#20'OpenInNewWindowClick'#0#0#0#6'TTimer'#9'MetaTimer'#7'Enabled'
|
||||
+#8#7'OnTimer'#7#14'MetaTimerTimer'#4'left'#3#242#0#3'top'#2'K'#0#0#6'TTimer'
|
||||
+#6'Timer1'#8'Interval'#3#200#0#7'OnTimer'#7#11'Timer1Timer'#4'left'#3'0'#1#3
|
||||
,'top'#2'G'#0#0#19'TPrinterSetupDialog'#18'PrinterSetupDialog'#4'left'#3#192#1
|
||||
+#0#0#0
|
||||
+'n'#6#4'Idle'#11'ParentColor'#8#0#0#0#12'TPageControl'#11'pageBrowser'#4'Lef'
|
||||
+'t'#2#0#6'Height'#3#165#1#3'Top'#2#0#5'Width'#3'm'#2#5'Align'#7#8'alClient'#8
|
||||
+'TabOrder'#2#1#0#0#11'TOpenDialog'#10'OpenDialog'#10'DefaultExt'#6#4'.htm'#6
|
||||
+'Filter'#6'%html files|*.htm;*.html|all files|*.*'#7'Options'#11#14'ofHideRe'
|
||||
+'adOnly'#15'ofPathMustExist'#15'ofFileMustExist'#0#4'left'#3'I'#1#3'top'#2#2
|
||||
+#0#0#9'TMainMenu'#8'MainMenu'#4'left'#3'#'#1#3'top'#2#4#0#9'TMenuItem'#5'Fil'
|
||||
+'e1'#7'Caption'#6#5'&File'#0#9'TMenuItem'#4'Open'#7'Caption'#6#5'&Open'#8'Sh'
|
||||
+'ortCut'#2'r'#7'OnClick'#7#13'OpenFileClick'#0#0#9'TMenuItem'#12'OpenTextFil'
|
||||
+'e'#7'Caption'#6#15'Open &Text File'#7'OnClick'#7#17'OpenTextFileClick'#0#0#9
|
||||
+'TMenuItem'#13'OpenImageFile'#7'Caption'#6#16'Open &Image File'#7'OnClick'#7
|
||||
+#18'OpenImageFileClick'#0#0#9'TMenuItem'#13'PrinterSetup1'#7'Caption'#6#16'P'
|
||||
+'rinter Setup...'#7'OnClick'#7#18'PrinterSetup1Click'#0#0#9'TMenuItem'#12'Pr'
|
||||
+'intpreview'#7'Caption'#6#14'Print pre&view'#7'Enabled'#8#7'OnClick'#7#17'Pr'
|
||||
+'intpreviewClick'#0#0#9'TMenuItem'#6'Print1'#7'Caption'#6#9'&Print...'#7'Ena'
|
||||
+'bled'#8#7'OnClick'#7#11'Print1Click'#0#0#9'TMenuItem'#2'N1'#7'Caption'#6#1
|
||||
+'-'#0#0#9'TMenuItem'#5'Exit1'#7'Caption'#6#5'E&xit'#7'OnClick'#7#10'Exit1Cli'
|
||||
+'ck'#0#0#0#9'TMenuItem'#5'Edit2'#7'Caption'#6#5'&Edit'#7'OnClick'#7#10'Edit2'
|
||||
+'Click'#0#9'TMenuItem'#5'Find1'#7'Caption'#6#5'&Find'#7'Enabled'#8#7'OnClick'
|
||||
+#7#10'Find1Click'#0#0#9'TMenuItem'#8'CopyItem'#7'Caption'#6#5'&Copy'#8'Short'
|
||||
+'Cut'#3'C@'#7'OnClick'#7#13'CopyItemClick'#0#0#9'TMenuItem'#2'N2'#7'Caption'
|
||||
+#6#1'-'#0#0#9'TMenuItem'#13'SelectAllItem'#7'Caption'#6#11'Select &All'#7'En'
|
||||
+'abled'#8#7'OnClick'#7#18'SelectAllItemClick'#0#0#0#9'TMenuItem'#8'options1'
|
||||
+#7'Caption'#6#6'&Tools'#0#9'TMenuItem'#10'ShowImages'#7'Caption'#6#12'&Show '
|
||||
+'images'#7'OnClick'#7#15'ShowImagesClick'#0#0#9'TMenuItem'#5'Fonts'#7'Captio'
|
||||
+'n'#6#23'Default &Font/Colors...'#7'OnClick'#7#15'FontColorsClick'#0#0#9'TMe'
|
||||
+'nuItem'#13'menuViewDebug'#7'Caption'#6#26'View Source and Debug info'#7'OnC'
|
||||
+'lick'#7#18'menuViewDebugClick'#0#0#0#9'TMenuItem'#15'HistoryMenuItem'#7'Cap'
|
||||
+'tion'#6#8'&History'#7'Visible'#8#0#0#9'TMenuItem'#6'About1'#7'Caption'#6#6
|
||||
+'&About'#7'OnClick'#7#11'About1Click'#0#0#0#12'TPrintDialog'#11'PrintDialog'
|
||||
+#8'FromPage'#2#1#7'MinPage'#2#1#7'MaxPage'#3#15''''#7'Options'#11#10'poPageN'
|
||||
+'ums'#0#6'ToPage'#2#1#4'left'#3'j'#1#3'top'#2#1#0#0#11'TFindDialog'#10'FindD'
|
||||
+'ialog'#7'Options'#11#6'frDown'#15'frHideWholeWord'#18'frDisableWholeWord'#0
|
||||
+#6'OnFind'#7#14'FindDialogFind'#4'left'#3#248#0#3'top'#2#4#0#0#10'TPopupMenu'
|
||||
+#9'PopupMenu'#4'left'#3#144#1#3'top'#2#1#0#9'TMenuItem'#9'Viewimage'#7'Capti'
|
||||
+'on'#6#11'&View image'#7'OnClick'#7#14'ViewimageClick'#0#0#9'TMenuItem'#20'C'
|
||||
+'opyImageToClipboard'#7'Caption'#6#24'&Copy image to clipboard'#7'OnClick'#7
|
||||
+#25'CopyImageToClipboardClick'#0#0#9'TMenuItem'#2'N3'#7'Caption'#6#1'-'#0#0#9
|
||||
+'TMenuItem'#15'OpenInNewWindow'#7'Caption'#6#19'&Open in new window'#7'OnCli'
|
||||
+'ck'#7#20'OpenInNewWindowClick'#0#0#0#6'TTimer'#9'MetaTimer'#7'Enabled'#8#7
|
||||
+'OnTimer'#7#14'MetaTimerTimer'#4'left'#3#242#0#3'top'#2'K'#0#0#6'TTimer'#6'T'
|
||||
+'imer1'#8'Interval'#3#200#0#7'OnTimer'#7#11'Timer1Timer'#4'left'#3'0'#1#3'to'
|
||||
+'p'#2'G'#0#0#19'TPrinterSetupDialog'#18'PrinterSetupDialog'#4'left'#3#192#1#0
|
||||
+#0#0
|
||||
]);
|
||||
|
@ -4,10 +4,13 @@ unit mainform;
|
||||
interface
|
||||
|
||||
uses
|
||||
LclIntf, LMessages, LclType, LResources, FPimage,
|
||||
SysUtils, Classes, Graphics, Controls,
|
||||
// RTL
|
||||
SysUtils, Classes, fpimage,
|
||||
// LCL
|
||||
LclIntf, LMessages, LclType, LResources,
|
||||
Graphics, Controls,
|
||||
Forms, Dialogs, ExtCtrls, Menus, StdCtrls, Clipbrd,
|
||||
PrintersDlgs,
|
||||
PrintersDlgs, buttons,
|
||||
ComCtrls,
|
||||
{$IFDEF MSWINDOWS} ShellAPI, {$ELSE} Unix, {$ENDIF}
|
||||
HTMLabt,
|
||||
@ -26,16 +29,11 @@ type
|
||||
MainMenu: TMainMenu;
|
||||
pageBrowser: TPageControl;
|
||||
panelBottom: TPanel;
|
||||
panelTop: TPanel;
|
||||
File1: TMenuItem;
|
||||
Open: TMenuItem;
|
||||
options1: TMenuItem;
|
||||
ShowImages: TMenuItem;
|
||||
Fonts: TMenuItem;
|
||||
editURL: TEdit;
|
||||
buttonReload: TButton;
|
||||
buttonBack: TButton;
|
||||
buttonForward: TButton;
|
||||
HistoryMenuItem: TMenuItem;
|
||||
Exit1: TMenuItem;
|
||||
PrintDialog: TPrintDialog;
|
||||
@ -66,7 +64,6 @@ type
|
||||
procedure ShowImagesClick(Sender: TObject);
|
||||
procedure buttonReloadClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FwdBackClick(Sender: TObject);
|
||||
procedure HistoryClick(Sender: TObject);
|
||||
procedure HistoryChange(Sender: TObject);
|
||||
procedure Exit1Click(Sender: TObject);
|
||||
@ -115,6 +112,8 @@ type
|
||||
procedure DropFiles( Sender : TObject;
|
||||
const FileNames: array of string);
|
||||
procedure CloseAll;
|
||||
procedure ForwardClick(Sender: TObject);
|
||||
procedure BackClick(Sender: TObject);
|
||||
public
|
||||
{ Public declarations }
|
||||
CurrentTab: Integer;
|
||||
@ -212,10 +211,13 @@ begin
|
||||
end;
|
||||
|
||||
procedure TformBrowser.editURLKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
lEdit: TEdit;
|
||||
begin
|
||||
lEdit := Sender as TEdit;
|
||||
if Key = VK_RETURN then
|
||||
begin
|
||||
LoadURL(editURL.Text);
|
||||
LoadURL(lEdit.Text);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -234,17 +236,15 @@ end;
|
||||
procedure TformBrowser.buttonReloadClick(Sender: TObject);
|
||||
{the Reload button was clicked}
|
||||
begin
|
||||
{$ifdef FPBROWSER_THTMLCOMP}
|
||||
buttonReload.Enabled := False;
|
||||
Viewer.ReLoad;
|
||||
buttonReload.Enabled := Viewer.CurrentFile <> '';
|
||||
Viewer.SetFocus;
|
||||
{$endif}
|
||||
GetCurrentBrowserViewer().Reload();
|
||||
end;
|
||||
|
||||
procedure TformBrowser.FwdBackClick(Sender: TObject);
|
||||
{Either the Forward or Back button was clicked}
|
||||
{Forward button was clicked}
|
||||
procedure TformBrowser.ForwardClick(Sender: TObject);
|
||||
var
|
||||
lButton: TWinControl;
|
||||
begin
|
||||
lButton := Sender as TWinControl;
|
||||
{$ifdef FPBROWSER_THTMLCOMP}
|
||||
{ if Sender = buttonBack then
|
||||
Viewer.HistoryIndex := Viewer.HistoryIndex +1
|
||||
@ -253,17 +253,23 @@ begin
|
||||
Self.Caption := Viewer.DocumentTitle;}
|
||||
{$endif}
|
||||
LoadURL(History.Strings[HistoryIndex]);
|
||||
if Sender = buttonBack then
|
||||
begin
|
||||
HistoryIndex := HistoryIndex-1;
|
||||
if HistoryIndex < 0 then buttonBack.Enabled := False;
|
||||
buttonForward.Enabled := True;
|
||||
end
|
||||
else
|
||||
begin
|
||||
HistoryIndex := HistoryIndex+1;
|
||||
if HistoryIndex >= History.Count then buttonForward.Enabled := False;
|
||||
end;
|
||||
|
||||
HistoryIndex := HistoryIndex+1;
|
||||
if HistoryIndex >= History.Count then lButton.Enabled := False;
|
||||
end;
|
||||
|
||||
{Back button was clicked}
|
||||
procedure TformBrowser.BackClick(Sender: TObject);
|
||||
var
|
||||
lButton, lForwardButton: TWinControl;
|
||||
begin
|
||||
lButton := Sender as TWinControl;
|
||||
|
||||
LoadURL(History.Strings[HistoryIndex]);
|
||||
|
||||
HistoryIndex := HistoryIndex-1;
|
||||
if HistoryIndex < 0 then lButton.Enabled := False;
|
||||
//buttonForward.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TformBrowser.HistoryChange(Sender: TObject);
|
||||
@ -604,57 +610,6 @@ begin
|
||||
History.Free;
|
||||
end;
|
||||
|
||||
{$ifdef FPBROWSER_THTMLCOMP}
|
||||
procedure TformBrowser.RightClick(Sender: TObject; Parameters: TRightClickParameters);
|
||||
var
|
||||
Pt: TPoint;
|
||||
S, Dest: string;
|
||||
I: integer;
|
||||
HintWindow: THintWindow;
|
||||
ARect: TRect;
|
||||
begin
|
||||
with Parameters do
|
||||
begin
|
||||
FoundObject := Image;
|
||||
ViewImage.Enabled := (FoundObject <> Nil) and (FoundObject.Bitmap <> Nil);
|
||||
CopyImageToClipboard.Enabled := (FoundObject <> Nil) and (FoundObject.Bitmap <> Nil);
|
||||
if URL <> '' then
|
||||
begin
|
||||
S := URL;
|
||||
I := Pos('#', S);
|
||||
if I >= 1 then
|
||||
begin
|
||||
Dest := System.Copy(S, I, 255); {local destination}
|
||||
S := System.Copy(S, 1, I-1); {the file name}
|
||||
end
|
||||
else
|
||||
Dest := ''; {no local destination}
|
||||
if S = '' then S := Viewer.CurrentFile
|
||||
else S := Viewer.HTMLExpandFileName(S);
|
||||
NewWindowFile := S+Dest;
|
||||
OpenInNewWindow.Enabled := FileExists(S);
|
||||
end
|
||||
else OpenInNewWindow.Enabled := False;
|
||||
|
||||
GetCursorPos(Pt);
|
||||
if Length(CLickWord) > 0 then
|
||||
begin
|
||||
HintWindow := THintWindow.Create(Self);
|
||||
try
|
||||
ARect := Rect(0,0,0,0);
|
||||
DrawTextW(HintWindow.Canvas.Handle, @ClickWord[1], Length(ClickWord), ARect, DT_CALCRECT);
|
||||
with ARect do
|
||||
HintWindow.ActivateHint(Rect(Pt.X+20, Pt.Y-(Bottom-Top)-15, Pt.x+30+Right, Pt.Y-15), ClickWord);
|
||||
PopupMenu.Popup(Pt.X, Pt.Y);
|
||||
finally
|
||||
HintWindow.Free;
|
||||
end;
|
||||
end
|
||||
else PopupMenu.Popup(Pt.X, Pt.Y);
|
||||
end;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
procedure TformBrowser.OpenInNewWindowClick(Sender: TObject);
|
||||
var
|
||||
PC: array[0..255] of char;
|
||||
@ -726,26 +681,6 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$ifdef FPBROWSER_THTMLCOMP}
|
||||
procedure TformBrowser.ViewerMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
TitleStr: string;
|
||||
begin
|
||||
if not Timer1.Enabled and Assigned(ActiveControl) and ActiveControl.Focused then {9.25}
|
||||
begin
|
||||
TitleStr := Viewer.TitleAttr;
|
||||
if TitleStr = '' then
|
||||
OldTitle := ''
|
||||
else if TitleStr <> OldTitle then
|
||||
begin
|
||||
TimerCount := 0;
|
||||
Timer1.Enabled := True;
|
||||
OldTitle := TitleStr;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TformBrowser.CloseAll;
|
||||
begin
|
||||
Timer1.Enabled := False;
|
||||
@ -762,9 +697,54 @@ procedure TformBrowser.AddBrowserTab(AURL: string; AGoToTab: Boolean);
|
||||
var
|
||||
lViewer: TBrowserViewer;
|
||||
lTabSheet: TTabSheet;
|
||||
lTopPanel: TPanel;
|
||||
lbuttonReload, lbuttonBack, lbuttonForward: TBitBtn;
|
||||
leditURL: TEdit;
|
||||
begin
|
||||
lTabSheet := pageBrowser.AddTabSheet(); // This call requires Lazarus 0.9.31+
|
||||
|
||||
// Add the top panel of the tab with buttons and the edit box
|
||||
lTopPanel := TPanel.Create(lTabSheet);
|
||||
lTopPanel.Parent := lTabSheet;
|
||||
lTopPanel.Align := alTop;
|
||||
lTopPanel.Height := 33;
|
||||
|
||||
lbuttonReload := TBitBtn.Create(lTopPanel);
|
||||
lbuttonReload.Top := 4;
|
||||
lbuttonReload.Left := 10;
|
||||
lbuttonReload.Width := 59;
|
||||
lbuttonReload.Height := 24;
|
||||
lbuttonReload.Parent := lTopPanel;
|
||||
lbuttonReload.Caption := 'Reload';
|
||||
lbuttonReload.OnClick := buttonReloadClick;
|
||||
|
||||
lbuttonBack := TBitBtn.Create(lTopPanel);
|
||||
lbuttonBack.Top := 4;
|
||||
lbuttonBack.Left := 69;
|
||||
lbuttonBack.Width := 59;
|
||||
lbuttonBack.Height := 24;
|
||||
lbuttonBack.Parent := lTopPanel;
|
||||
lbuttonBack.Caption := 'Back';
|
||||
lbuttonBack.OnClick := ForwardClick;
|
||||
|
||||
lbuttonForward := TBitBtn.Create(lTopPanel);
|
||||
lbuttonForward.Top := 4;
|
||||
lbuttonForward.Left := 128;
|
||||
lbuttonForward.Width := 59;
|
||||
lbuttonForward.Height := 24;
|
||||
lbuttonForward.Parent := lTopPanel;
|
||||
lbuttonForward.Caption := 'Forward';
|
||||
lbuttonForward.OnClick := BackClick;
|
||||
|
||||
leditURL := TEdit.Create(lTopPanel);
|
||||
leditURL.Top := 4;
|
||||
leditURL.Left := 190;
|
||||
leditURL.Width := 337;
|
||||
leditURL.Height := 24;
|
||||
leditURL.Parent := lTopPanel;
|
||||
leditURL.OnKeyDown := editURLKeyDown;
|
||||
|
||||
// Add the HTML Viewer
|
||||
lViewer := AddBrowserViewer();
|
||||
lViewer.CreateViewer(lTabSheet, Self);
|
||||
|
||||
@ -777,9 +757,9 @@ end;
|
||||
|
||||
procedure TformBrowser.AddURLToHistory(AURL: string);
|
||||
begin
|
||||
History.Add(AURL);
|
||||
{ History.Add(AURL);
|
||||
HistoryIndex := History.Count-1;
|
||||
buttonBack.Enabled := True;
|
||||
buttonBack.Enabled := True;}
|
||||
end;
|
||||
|
||||
procedure TformBrowser.HandlePageLoaderProgress(APercent: Integer);
|
||||
@ -843,22 +823,6 @@ begin
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
{$ifdef FPBROWSER_THTMLCOMP}
|
||||
procedure TformBrowser.ViewerProgress(Sender: TObject; Stage: TProgressStage;
|
||||
PercentDone: Integer);
|
||||
begin
|
||||
ProgressBar.Position := PercentDone;
|
||||
case Stage of
|
||||
psStarting:
|
||||
ProgressBar.Visible := True;
|
||||
psRunning:;
|
||||
psEnding:
|
||||
ProgressBar.Visible := False;
|
||||
end;
|
||||
ProgressBar.Update;
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
{HTML for print header and footer}
|
||||
const
|
||||
HFText: string = '<html><head><style>'+
|
||||
@ -886,28 +850,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ifdef FPBROWSER_THTMLCOMP}
|
||||
procedure TformBrowser.ViewerPrintHTMLHeader(Sender: TObject;
|
||||
HFViewer: THTMLViewer; NumPage: Integer; LastPage: boolean; var XL, XR: integer; var StopPrinting: Boolean);
|
||||
var
|
||||
S: string;
|
||||
begin
|
||||
S := ReplaceStr(HFText, '#left', Viewer.DocumentTitle);
|
||||
S := ReplaceStr(S, '#right', Viewer.CurrentFile);
|
||||
HFViewer.LoadFromString(S);
|
||||
end;
|
||||
|
||||
procedure TformBrowser.ViewerPrintHTMLFooter(Sender: TObject;
|
||||
HFViewer: THTMLViewer; NumPage: Integer; LastPage: boolean; var XL, XR: integer; var StopPrinting: Boolean);
|
||||
var
|
||||
S: string;
|
||||
begin
|
||||
S := ReplaceStr(HFText, '#left', DateToStr(Date));
|
||||
S := ReplaceStr(S, '#right', 'Page '+IntToStr(NumPage));
|
||||
HFViewer.LoadFromString(S);
|
||||
end;
|
||||
{$endif}
|
||||
|
||||
initialization
|
||||
{$IFDEF LCL}
|
||||
{$I mainform.lrs} {Include form's resource file}
|
||||
|
@ -43,6 +43,7 @@ type
|
||||
function GetDocumentTitle: string; override;
|
||||
procedure SetShowImages(AValue: Boolean); override;
|
||||
procedure HandlePageLoaderTerminated(Sender: TObject); override;
|
||||
procedure Reload; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -192,6 +193,10 @@ begin
|
||||
ShowHTML(MyPageLoader.Contents);
|
||||
end;
|
||||
|
||||
procedure TiProViewer.Reload;
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
SetBrowserViewerClass(TiProViewer);
|
||||
end.
|
||||
|
@ -43,6 +43,7 @@ type
|
||||
function GetDocumentTitle: string; override;
|
||||
procedure SetShowImages(AValue: Boolean); override;
|
||||
procedure HandlePageLoaderTerminated(Sender: TObject); override;
|
||||
procedure Reload; override;
|
||||
end;
|
||||
|
||||
|
||||
@ -52,28 +53,57 @@ implementation
|
||||
|
||||
procedure THtmlCompViewer.ViewerMouseMove(Sender: TObject; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
var
|
||||
TitleStr: string;
|
||||
begin
|
||||
|
||||
if not Timer1.Enabled and Assigned(ActiveControl) and ActiveControl.Focused then {9.25}
|
||||
begin
|
||||
TitleStr := Viewer.TitleAttr;
|
||||
if TitleStr = '' then
|
||||
OldTitle := ''
|
||||
else if TitleStr <> OldTitle then
|
||||
begin
|
||||
TimerCount := 0;
|
||||
Timer1.Enabled := True;
|
||||
OldTitle := TitleStr;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure THtmlCompViewer.ViewerProgress(Sender: TObject;
|
||||
Stage: TProgressStage; PercentDone: Integer);
|
||||
begin
|
||||
|
||||
ProgressBar.Position := PercentDone;
|
||||
case Stage of
|
||||
psStarting:
|
||||
ProgressBar.Visible := True;
|
||||
psRunning:;
|
||||
psEnding:
|
||||
ProgressBar.Visible := False;
|
||||
end;
|
||||
ProgressBar.Update;
|
||||
end;
|
||||
|
||||
procedure THtmlCompViewer.ViewerPrintHTMLFooter(Sender: TObject;
|
||||
HFViewer: THTMLViewer; NumPage: Integer; LastPage: Boolean; var XL,
|
||||
XR: Integer; var StopPrinting: Boolean);
|
||||
var
|
||||
S: string;
|
||||
begin
|
||||
|
||||
S := ReplaceStr(HFText, '#left', Viewer.DocumentTitle);
|
||||
S := ReplaceStr(S, '#right', Viewer.CurrentFile);
|
||||
HFViewer.LoadFromString(S);
|
||||
end;
|
||||
|
||||
procedure THtmlCompViewer.ViewerPrintHTMLHeader(Sender: TObject;
|
||||
HFViewer: THTMLViewer; NumPage: Integer; LastPage: Boolean; var XL,
|
||||
XR: Integer; var StopPrinting: Boolean);
|
||||
var
|
||||
S: string;
|
||||
begin
|
||||
|
||||
S := ReplaceStr(HFText, '#left', DateToStr(Date));
|
||||
S := ReplaceStr(S, '#right', 'Page '+IntToStr(NumPage));
|
||||
HFViewer.LoadFromString(S);
|
||||
end;
|
||||
|
||||
procedure THtmlCompViewer.HotSpotChange(Sender: TObject; const URL: string);
|
||||
@ -215,8 +245,52 @@ end;
|
||||
|
||||
procedure THtmlCompViewer.RightClick(Sender: TObject;
|
||||
Parameters: TRightClickParameters);
|
||||
var
|
||||
Pt: TPoint;
|
||||
S, Dest: string;
|
||||
I: integer;
|
||||
HintWindow: THintWindow;
|
||||
ARect: TRect;
|
||||
begin
|
||||
with Parameters do
|
||||
begin
|
||||
FoundObject := Image;
|
||||
ViewImage.Enabled := (FoundObject <> Nil) and (FoundObject.Bitmap <> Nil);
|
||||
CopyImageToClipboard.Enabled := (FoundObject <> Nil) and (FoundObject.Bitmap <> Nil);
|
||||
if URL <> '' then
|
||||
begin
|
||||
S := URL;
|
||||
I := Pos('#', S);
|
||||
if I >= 1 then
|
||||
begin
|
||||
Dest := System.Copy(S, I, 255); {local destination}
|
||||
S := System.Copy(S, 1, I-1); {the file name}
|
||||
end
|
||||
else
|
||||
Dest := ''; {no local destination}
|
||||
if S = '' then S := Viewer.CurrentFile
|
||||
else S := Viewer.HTMLExpandFileName(S);
|
||||
NewWindowFile := S+Dest;
|
||||
OpenInNewWindow.Enabled := FileExists(S);
|
||||
end
|
||||
else OpenInNewWindow.Enabled := False;
|
||||
|
||||
GetCursorPos(Pt);
|
||||
if Length(CLickWord) > 0 then
|
||||
begin
|
||||
HintWindow := THintWindow.Create(Self);
|
||||
try
|
||||
ARect := Rect(0,0,0,0);
|
||||
DrawTextW(HintWindow.Canvas.Handle, @ClickWord[1], Length(ClickWord), ARect, DT_CALCRECT);
|
||||
with ARect do
|
||||
HintWindow.ActivateHint(Rect(Pt.X+20, Pt.Y-(Bottom-Top)-15, Pt.x+30+Right, Pt.Y-15), ClickWord);
|
||||
PopupMenu.Popup(Pt.X, Pt.Y);
|
||||
finally
|
||||
HintWindow.Free;
|
||||
end;
|
||||
end
|
||||
else PopupMenu.Popup(Pt.X, Pt.Y);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ In this event we should provide images for the html component }
|
||||
@ -305,6 +379,12 @@ begin
|
||||
Caption := Viewer.DocumentTitle;
|
||||
end;
|
||||
|
||||
procedure THtmlCompViewer.Reload;
|
||||
begin
|
||||
Viewer.ReLoad;
|
||||
Viewer.SetFocus;
|
||||
end;
|
||||
|
||||
initialization
|
||||
SetBrowserViewerClass(THtmlCompViewer);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user