summaryrefslogtreecommitdiff
path: root/docview
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-09-03 18:35:55 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2010-09-03 18:35:55 +0200
commit7ba60ed71babeca38e25da3637c4a4186dead2af (patch)
tree9b0cd32439eac591ba2957f7f5effdc0dffb00a5 /docview
parent511330468287b4a161d46034d7fa4c1a618bbae7 (diff)
parentd39c55fc75c07c01887840d15e493cbdcf892847 (diff)
downloadfpGUI-7ba60ed71babeca38e25da3637c4a4186dead2af.tar.xz
Merge branch 'master' of /media/flash16gig/git_repos/fpgui
Diffstat (limited to 'docview')
-rw-r--r--docview/components/richtext/CanvasFontManager.pas23
-rw-r--r--docview/components/richtext/RichTextDisplayUnit.pas1
-rw-r--r--docview/components/richtext/RichTextDocumentUnit.pas1
-rw-r--r--docview/components/richtext/RichTextLayoutUnit.pas7
-rw-r--r--docview/components/richtext/RichTextStyleUnit.pas42
-rw-r--r--docview/components/richtext/RichTextView.pas132
-rw-r--r--docview/docs/docview.ipf39
-rw-r--r--docview/src/SettingsUnit.pas61
-rw-r--r--docview/src/docview.lpi6
-rw-r--r--docview/src/frm_configuration.pas174
-rw-r--r--docview/src/frm_main.pas22
11 files changed, 310 insertions, 198 deletions
diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas
index cfdb4924..ed3abf08 100644
--- a/docview/components/richtext/CanvasFontManager.pas
+++ b/docview/components/richtext/CanvasFontManager.pas
@@ -15,12 +15,16 @@ Const
// This defines the fraction of a pixel that
// font character widths will be given in
FontWidthPrecisionFactor = 1; // 256 seems to be specific to OS/2 API
- DefaultTopicFont = 'Sans';
+ DefaultTopicFontName = 'Arial';
DefaultTopicFontSize = '10';
- DefaultTopicFixedFont = 'Courier New';
+ DefaultTopicFixedFontName = 'Courier New';
DefaultTopicFixedFontSize = '10';
+ DefaultTopicFont = DefaultTopicFontName + '-' + DefaultTopicFontSize;
+ DefaultTopicFixedFont = DefaultTopicFixedFontName + '-' + DefaultTopicFixedFontSize;
+
+
Type
{Standard Font types}
TFontType=(ftBitmap,ftOutline);
@@ -146,6 +150,7 @@ uses
,ACLStringUtility
,nvUtilities
,fpg_stringutils
+ ,SettingsUnit
;
@@ -345,13 +350,13 @@ end;
procedure GetDefaultFonts;
begin
// courier new is common and reasonably nice
- DefaultOutlineFixedFace := FindFaceName( 'Courier New' );
+ DefaultOutlineFixedFace := FindFaceName( DefaultTopicFixedFontName );
if DefaultOutlineFixedFace = nil then
begin
DefaultOutlineFixedFace := GetFirstOutlineFace( true ); // first fixed outline face
end;
- DefaultOutlineProportionalFace := FindFaceName( DefaultTopicFont );
+ DefaultOutlineProportionalFace := FindFaceName( DefaultTopicFontName );
if DefaultOutlineProportionalFace = nil then
begin
DefaultOutlineProportionalFace := GetFirstOutlineFace( false ); // first prop outline face
@@ -455,17 +460,17 @@ end;
function SubstituteBitmapFontToOutline( const FaceName: string ): string;
begin
if StringsSame( FaceName, 'Helv' ) then
- result := DefaultTopicFont
+ result := DefaultTopicFontName
else if StringsSame( FaceName, 'Helvetica' ) then
- result := DefaultTopicFont
+ result := DefaultTopicFontName
else if StringsSame( FaceName, 'Tms Rmn' ) then
result := 'Times New Roman'
else if StringsSame( FaceName, 'System Proportional' ) then
- result := DefaultTopicFont
+ result := DefaultTopicFontName
else if StringsSame( FaceName, 'System Monospaced' ) then
- result := DefaultTopicFixedFont
+ result := DefaultTopicFixedFontName
else if StringsSame( FaceName, 'System VIO' ) then
- result := DefaultTopicFixedFont
+ result := DefaultTopicFixedFontName
else
result := FaceName; // no substitution
end;
diff --git a/docview/components/richtext/RichTextDisplayUnit.pas b/docview/components/richtext/RichTextDisplayUnit.pas
index 6009e7e2..b8e18264 100644
--- a/docview/components/richtext/RichTextDisplayUnit.pas
+++ b/docview/components/richtext/RichTextDisplayUnit.pas
@@ -35,7 +35,6 @@ Implementation
uses
SysUtils
-// ACLString, ACLUtility,
,RichTextDocumentUnit
,fpg_base
,fpg_main
diff --git a/docview/components/richtext/RichTextDocumentUnit.pas b/docview/components/richtext/RichTextDocumentUnit.pas
index dd2f9a96..a3e951d1 100644
--- a/docview/components/richtext/RichTextDocumentUnit.pas
+++ b/docview/components/richtext/RichTextDocumentUnit.pas
@@ -151,7 +151,6 @@ function CopyPlainTextToBuffer( StartP: PChar;
Implementation
uses
-// BseDOS, // for NLS/case mapping
SysUtils
,ACLStringUtility
;
diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas
index 4c6cf427..bbf60643 100644
--- a/docview/components/richtext/RichTextLayoutUnit.pas
+++ b/docview/components/richtext/RichTextLayoutUnit.pas
@@ -10,7 +10,8 @@ Interface
Uses
Classes,
CanvasFontManager,
- RichTextDocumentUnit, RichTextStyleUnit,
+ RichTextDocumentUnit,
+ RichTextStyleUnit,
fpg_imagelist;
Type
@@ -117,11 +118,7 @@ Implementation
Uses
SysUtils
-// PMWin, BseDos, Dos, ClipBrd, Printers,
-// ACLUtility,
,ACLStringUtility
-// ACLString,
-// ControlScrolling;
,nvUtilities
,fpg_main
;
diff --git a/docview/components/richtext/RichTextStyleUnit.pas b/docview/components/richtext/RichTextStyleUnit.pas
index 782889bd..cfdde684 100644
--- a/docview/components/richtext/RichTextStyleUnit.pas
+++ b/docview/components/richtext/RichTextStyleUnit.pas
@@ -61,8 +61,7 @@ type
function GetMargin_Top: longint;
Procedure SetMargin_Top( NewValue: longint );
Procedure SetupComponent;
- Procedure AssignFont( Var Font: TfpgFont;
- NewFont: TfpgFont );
+ Procedure AssignFont(var AFont: TfpgFont; NewFont: TfpgFont);
// Hide properties...
property Name;
@@ -131,6 +130,7 @@ uses
SysUtils,
ACLStringUtility
,nvUtilities
+ ,SettingsUnit
// , ACLProfile
;
@@ -320,11 +320,11 @@ end;
function GetDefaultStyle( const Settings: TRichTextSettings ): TTextDrawStyle;
begin
FillChar(Result, SizeOf(TTextDrawStyle), 0);
- FPGuiFontToFontSpec( Settings.FNormalFont, Result.Font );
- Result.Alignment := Settings.FDefaultAlignment;
- Result.Wrap := Settings.FDefaultWrap;
- Result.Color := Settings.FDefaultColor;
- Result.BackgroundColor := Settings.FDefaultBackgroundColor;
+ FPGuiFontToFontSpec( Settings.NormalFont, Result.Font );
+ Result.Alignment := Settings.DefaultAlignment;
+ Result.Wrap := Settings.DefaultWrap;
+ Result.Color := Settings.DefaultColor;
+ Result.BackgroundColor := Settings.DefaultBackgroundColor;
Result.LeftMargin := Settings.Margins.Left;
Result.RightMargin := Settings.Margins.Right;
end;
@@ -334,11 +334,11 @@ Procedure TRichTextSettings.SetupComponent;
begin
Name := 'RichTextSettings';
- FNormalFont := fpgGetFont('Arial-10');
- FFixedFont := fpgGetFont('Courier New-10');
- FHeading1Font := fpgGetFont('Arial-20');
- FHeading2Font := fpgGetFont('Arial-14');
- FHeading3Font := fpgGetFont('Arial-10:bold');
+ FNormalFont := fpgGetFont(Settings.NormalFontDesc); // fpgGetFont(DefaultTopicFont);
+ FFixedFont := fpgGetFont(Settings.FixedFontDesc); // fpgGetFont(DefaultTopicFixedFont);
+ FHeading1Font := fpgGetFont(DefaultTopicFontName + '-20');
+ FHeading2Font := fpgGetFont(DefaultTopicFontName + '-14');
+ FHeading3Font := fpgGetFont(DefaultTopicFontName + '-10:bold');
FDefaultColor := clBlack;
FDefaultBackgroundColor := clWhite;
@@ -350,12 +350,12 @@ begin
FMarginSizeStyle := msMaximumCharWidth;
FMarginChar := Ord( ' ' );
- FMargins.Left := 0;
- FMargins.Right := 0;
- FMargins.Top := 0;
+ FMargins.Left := 0;
+ FMargins.Right := 0;
+ FMargins.Top := 0;
FMargins.Bottom := 0;
- FUpdateCount := 0;
+ FUpdateCount := 0;
FChangesPending := false;
end;
@@ -502,18 +502,16 @@ begin
Result := FontA.FontDesc = FontB.FontDesc;
end;
-Procedure TRichTextSettings.AssignFont( Var Font: TfpgFont;
- NewFont: TfpgFont );
+Procedure TRichTextSettings.AssignFont(var AFont: TfpgFont; NewFont: TfpgFont );
begin
If NewFont = Nil Then
NewFont := fpgApplication.DefaultFont;
- if FontSame( NewFont, Font ) then
+ if FontSame( NewFont, AFont ) then
exit; // no change
- Font.Free;
- Font := NewFont;
-// Font.Free;
+ AFont.Free;
+ AFont := NewFont;
Change;
End;
diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas
index 49ea97c4..f611ab2f 100644
--- a/docview/components/richtext/RichTextView.pas
+++ b/docview/components/richtext/RichTextView.pas
@@ -14,7 +14,6 @@ Uses
fpg_imagelist,
RichTextStyleUnit,
RichTextLayoutUnit,
-// RichTextDocumentUnit,
CanvasFontManager;
{
@@ -50,9 +49,10 @@ Type
TLinkEvent = procedure( Sender: TRichTextView; Link: string ) of object;
- TRichTextView = Class( TfpgWidget )
+ TRichTextView = class(TfpgWidget)
private
FPopupMenu: TfpgPopupMenu;
+ FScrollDistance: integer;
procedure FVScrollbarScroll(Sender: TObject; position: integer);
procedure FHScrollbarScroll(Sender: TObject; position: integer);
procedure ShowDefaultPopupMenu(const x, y: integer; const shiftstate: TShiftState); virtual;
@@ -64,6 +64,7 @@ Type
Procedure SmoothScrollMIClick( Sender: TObject );
Procedure DebugMIClick( Sender: TObject );
Procedure DefaultMenuPopup( Sender: TObject );
+ procedure SetScrollDistance(const AValue: integer);
protected
FFontManager: TCanvasFontManager;
FRichTextSettings: TRichTextSettings;
@@ -80,12 +81,12 @@ Type
FOnClickLink: TLinkEvent;
FDefaultMenu: TfpgPopupMenu;
- FSelectAllMI: TfpgMenuItem;
- FCopyMI: TfpgMenuItem;
- FRefreshMI: TfpgMenuItem;
- FWordWrapMI: TfpgMenuItem;
- FSmoothScrollMI: TfpgMenuItem;
- FDebugMI: TfpgMenuItem;
+ FSelectAllMI: TfpgMenuItem;
+ FCopyMI: TfpgMenuItem;
+ FRefreshMI: TfpgMenuItem;
+ FWordWrapMI: TfpgMenuItem;
+ FSmoothScrollMI: TfpgMenuItem;
+ FDebugMI: TfpgMenuItem;
// Internal layout data
FNeedVScroll, FNeedHScroll: boolean;
@@ -138,6 +139,7 @@ Type
procedure HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override;
procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override;
procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override;
+ procedure HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); override;
//procedure ScanEvent( Var KeyCode: TKeyCode;
// RepeatCount: Byte ); override;
@@ -367,6 +369,7 @@ Type
property RichTextSettings: TRichTextSettings read FRichTextSettings;
property ScrollBarWidth: longint read FScrollBarWidth write SetScrollBarWidth default 15;
property SmoothScroll: boolean read FSmoothScroll write FSmoothScroll;
+ property ScrollDistance: integer read FScrollDistance write SetScrollDistance default 75;
property UseDefaultMenu: boolean read FUseDefaultMenu write FUseDefaultMenu default True;
property Debug: boolean read FDebug write SetDebug default False;
property Images: TfpgImageList read FImages write SetImages;
@@ -395,9 +398,6 @@ Type
//Property OnSetupShow;
//Property OnScan;
- Protected
- //Property Font;
-
End;
@@ -407,7 +407,6 @@ uses
SysUtils
,ACLStringUtility
,nvUtilities
-// ControlScrolling, ControlsUtility,
,RichTextDocumentUnit
,RichTextDisplayUnit
;
@@ -586,6 +585,17 @@ begin
FDebugMI.Checked := Debug;
end;
+procedure TRichTextView.SetScrollDistance(const AValue: integer);
+begin
+ if FScrollDistance = AValue then
+ exit;
+ FScrollDistance := AValue;
+ if Assigned(FVScrollBar) then
+ FVScrollBar.ScrollStep := FScrollDistance;
+ if Assigned(FHScrollBar) then
+ FHScrollBar.ScrollStep := FScrollDistance;
+end;
+
constructor TRichTextView.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@@ -753,7 +763,7 @@ procedure TRichTextView.HandleLMouseDown(x, y: integer; shiftstate: TShiftState)
var
Line: longint;
Offset: longint;
- Link: string;
+ Link: TfpgString;
Position: TTextPosition;
Shift: boolean;
begin
@@ -772,6 +782,41 @@ begin
FClickedLink := ''; // reset link
end;
+procedure TRichTextView.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState);
+var
+ Line: longint;
+ Offset: longint;
+ Link: TfpgString;
+ Position: TTextPosition;
+begin
+ inherited HandleMouseMove(x, y, btnstate, shiftstate);
+ Position := FindPoint(X, Y, Line, Offset, Link);
+
+// if not MouseCapture then // TODO: Introduce a IsMouseCaptured in TfpgWindow
+ begin
+ if Link <> FLastLinkOver then
+ begin
+ if Link <> '' then
+ begin
+ if Assigned(FOnOverLink) then
+ FOnOverLink(Self, Link)
+ end
+ else
+ begin
+ if Assigned(FOnNotOverLink) then
+ FOnNotOverLink(Self, FLastLinkOver);
+ end;
+ FLastLinkOver := Link;
+ end;
+
+ if Link <> '' then
+ MouseCursor := mcHand
+ else
+ MouseCursor := mcDefault; // TODO: later this should be IBeam when RichView supports editing
+ exit;
+ end;
+end;
+
Destructor TRichTextView.Destroy;
Begin
FDefaultMenu.Free;
@@ -1052,13 +1097,9 @@ begin
TextHeight := GetTextAreaHeight;
-// YToFind := Height - YToFind;
-
- //if FBorderStyle = bsSingle then
- //begin
- // dec( YToFind, 2 );
- // dec( XToFind, 2 );
- //end;
+ // Should we take into account Border Styles?
+ XToFind := XToFind - FRichTextSettings.Margins.Left;
+ YToFind := YToFind - FRichTextSettings.Margins.Top;
if YToFind < 3 then
begin
@@ -1210,12 +1251,12 @@ begin
FVScrollBar.Max := 0;
end;
- FHScrollBar.ScrollStep := 25; // pixels
- FHScrollBar.PageSize := AvailableWidth - FHScrollbar.ScrollStep; // slightly less than width
- FHScrollBar.SliderSize := AvailableWidth / MaxDisplayWidth;
- FVScrollBar.ScrollStep := 25; // not used (line up/down calculated explicitly)
- FVScrollBar.PageSize := AvailableHeight - FVScrollBar.ScrollStep;
- FVScrollBar.SliderSize := AvailableHeight / FLayout.Height;
+ FHScrollBar.ScrollStep := FScrollDistance; // pixels
+ FHScrollBar.PageSize := AvailableWidth - FHScrollbar.ScrollStep; // slightly less than width
+ FHScrollBar.SliderSize := AvailableWidth / MaxDisplayWidth;
+ FVScrollBar.ScrollStep := FScrollDistance; // pixels
+ FVScrollBar.PageSize := AvailableHeight - FVScrollBar.ScrollStep;
+ FVScrollBar.SliderSize := AvailableHeight / FLayout.Height;
// Physical horizontal scroll setup
FHScrollbar.Visible := FNeedHScroll;
@@ -1427,7 +1468,7 @@ begin
Result := 0;
end;
-Function TRichTextView.GetLineUpPosition: longint;
+function TRichTextView.GetLineUpPosition: longint;
var
FirstVisibleLine: longint;
Offset: longint;
@@ -1436,8 +1477,7 @@ begin
Result := GetLineUpPositionFrom( FirstVisibleLine, Offset );
end;
-Function TRichTextView.GetLineUpPositionFrom( FirstVisibleLine: longint;
- Offset: longint ): longint;
+function TRichTextView.GetLineUpPositionFrom( FirstVisibleLine: longint; Offset: longint ): longint;
begin
// we should never have scrolled all lines off the top!!
assert( FirstVisibleLine <> -1 );
@@ -1454,15 +1494,13 @@ begin
end;
// scroll so that top line is fully visible...
- Result := FVScrollBar.Position
- - Offset;
+ Result := FVScrollBar.Position - Offset;
if Offset < (FLayout.FLines^[ FirstVisibleLine ].Height div 2) then
// more than half the line was already displayed so
if FirstVisibleLine > 0 then
// AND to make next line up visible
dec( Result, FLayout.FLines^[ FirstVisibleLine - 1 ].Height );
-
end;
Function Sign( arg: longint ): longint;
@@ -1531,54 +1569,26 @@ end;
*)
Procedure TRichTextView.DoVerticalScroll( NewY: longint );
-//var
-// ScrollDistance: longint;
begin
FYScroll := 0 - NewY;
-
if not Visible then
begin
FLastYScroll := FYScroll;
exit;
end;
-
-// ScrollDistance := FYScroll - FLastYScroll;
-
- { TODO -ograeme -cscrolling : Implement vertical scrolling here }
- //ScrollControlRect( Self,
- // GetTextAreaRect,
- // 0,
- // ScrollDistance,
- // Color,
- // FSmoothScroll );
-
FLastYScroll := FYScroll;
RePaint;
SetupCursor;
end;
Procedure TRichTextView.DoHorizontalScroll( NewX: longint );
-var
- ScrollDistance: longint;
begin
FXScroll := NewX;
-
if not Visible then
begin
FLastXScroll := FXScroll;
exit;
end;
-
-// ScrollDistance := FXScroll - FLastXScroll;
-
- { TODO -ograemeg -cscrolling : Implement horizontal scrolling }
- //ScrollControlRect( Self,
- // GetTextAreaRect,
- // - ScrollDistance,
- // 0,
- // Color,
- // FSmoothScroll );
-
FLastXScroll := FXScroll;
RePaint;
SetupCursor;
@@ -1629,7 +1639,7 @@ begin
s := Text;
// Warning: Hack Alert! replace some strange Bell character found in some INF files
// s := SubstituteChar(s, Chr($07), Chr($20) );
- s := StringReplace(s, Chr($07), '•', [rfReplaceAll, rfIgnoreCase]);
+ s := StringReplace(s, Chr($07), #$E2#$80#$A2, [rfReplaceAll, rfIgnoreCase]); // u+2022 small bullet
//// Hack Alert #2: replace strange table chars with something we can actually see
// s := SubstituteChar(s, Chr(218), Char('+') ); // top-left corner
diff --git a/docview/docs/docview.ipf b/docview/docs/docview.ipf
index 2c876ecb..e21490e4 100644
--- a/docview/docs/docview.ipf
+++ b/docview/docs/docview.ipf
@@ -107,6 +107,33 @@ text wrapping and font substitution support.
environment variables BOOKSHELF or HELP.
:eul.
+.* ----------------------------------------------------------------------
+:h2.Disclaimers
+:p.
+Since this program is free, it is supplied with no warranty, either expressed or
+implied.
+:p.
+I disclaim all warranties for any damages, including, but not limited to, incidental
+or consequential damage caused directly or indirectly by this software.
+:p.
+All software is supplied AS IS. You may use the program package only at your own
+risk.
+:p.
+This program must not be used in states that do not allow the above limitation of
+liability.
+
+
+.* ----------------------------------------------------------------------
+:h2.Trademarks
+:p.
+The following trademarks are used in this online help file:
+:ul compact.
+:li.OS/2 is a registered trademark of IBM Corporation.
+:li.eComStation is a registered trademark of Serenity Systems, Inc.
+:li.Windows is a registered trademark of Microsoft Corporation
+:li.Linux is a registered trademark of Linus Torvalds
+:li.FreeBSD is a registered trademark of The FreeBSD Foundation
+:eul.
.* ************************************************************
.* Using DocView
@@ -178,6 +205,7 @@ For example, on my system I can do the following:
:xmp.
docview FPCHELP
:exmp.
+:p.
which loads the whole Free Pascal help library on my system. FPCHELP is an environment
variable set in ~/.profile (Linux) or config.sys (Windows) consisting of "rtl+fcl+ref"
which tells DocView to load the help files rtl.inf, fcl.inf and ref.inf. The
@@ -622,7 +650,8 @@ parameters. None of them are required. For a quick summary, select
docview [<filename>] [[option] [option parameter]]
:exmp.
-:link reftype=hd refid='CommandLineExamples'.Examples:elink.
+:p.
+:link reftype=hd refid='CommandLineExamples'.:hp2.Examples:ehp2.:elink.
:p.
:hp2.<filename>:ehp2.
:p.
@@ -652,19 +681,26 @@ Example:
.br
:lm margin=8.
To search for TfpgApplication in the whole fpGUI Toolkit class document you can call
+
:xmp.
docview fpgui.inf -k TfpgApplication
:exmp.
+
+:p.
DocView is clever enough to handle multiple words (like the :link reftype=hd
refid='search'.search panel:elink.). This is a OR search.
+
:xmp.
docview fpgui.inf -k net access
:exmp.
+
+:p.
To perform an AND search enclose the search phrase in double quotes.
:xmp.
docview fpgui.inf -k "net access"
:exmp.
:lm margin=1.
+
:pt.-n <id>
:pd.Open a topic with the numeric ID equal to <id>.
:pt.-s <id>
@@ -952,6 +988,7 @@ our help file!
wipfc -i sample.ipf
:exmp.
+:p.
If you typed the document correctly, you should now have
a :hp2.sample.inf:ehp2. file in the current directory. Now you simply
run DocView and open your first INF help file. Well done!
diff --git a/docview/src/SettingsUnit.pas b/docview/src/SettingsUnit.pas
index 903e9fe7..e100b1b1 100644
--- a/docview/src/SettingsUnit.pas
+++ b/docview/src/SettingsUnit.pas
@@ -36,20 +36,6 @@ Const
//clLightCyan = $c0ffff;
//clLightGreen = $e0ffe0;
- VGADefaultColors: array[ 0 .. NumColorSettings - 1 ] of TfpgColor
- = ( clBoxColor,
- clText1,
- clText1,
- clBoxColor,
- clText1,
- clBoxColor,
- clText1,
- clBoxColor,
- clText1,
- clBoxColor,
- clGreen,
- clYellow );
-
DefaultColors: array[ 0 .. NumColorSettings - 1 ] of TfpgColor
= ( clLightCyan,
clBlack,
@@ -67,9 +53,6 @@ Const
ApplicationFontIndex = 0;
NumFontSettings = 1;
- DefaultTopicFont = DefaultTopicFont + '-' + DefaultTopicFontSize;
- DefaultTopicFixedFont = DefaultTopicFixedFont + '-10' + DefaultTopicFixedFontSize;
-
Type
TIndexStyle = ( isAlphabetical, isFileOnly, isFull );
@@ -93,10 +76,11 @@ Type
StartupHelp: boolean;
LeftPanelWidth: longint;
ShowLeftPanel: boolean;
+ ScrollDistance: integer;
FileDialogSplit: Double;
Colors: array[ 0..NumColorSettings - 1 ] of TfpgColor;
- NormalFont: TfpgFont;
- FixedFont: TfpgFont;
+ NormalFontDesc: TfpgString;
+ FixedFontDesc: TfpgString;
Fonts: array[ 0..NumFontSettings - 1 ] of TfpgFont;
FixedFontSubstitution: boolean;
FixedFontSubstitutes: string;
@@ -116,7 +100,7 @@ Type
// global procs
procedure LoadSettings;
procedure SaveSettings;
-procedure writeSettingsDetailsTo(aStrings : TStrings);
+procedure WriteSettingsDetailsTo(aStrings : TStrings);
procedure AddToMRUList( const Title: string; Filenames: TStrings );
var
@@ -186,13 +170,12 @@ begin
ShowLeftPanel := ReadBool( GeneralSection, 'ShowLeftPanel', true );
+ ScrollDistance := ReadInteger(GeneralSection, 'ScrollDistance', 75);
+
// Colours
for ColorIndex := 0 to High( Colors ) do
begin
- //if GetScreenColorDepth > 8 then
- DefaultColor := DefaultColors[ ColorIndex ];
- //else
- // DefaultColor := VGADefaultColors[ ColorIndex ];
+ DefaultColor := DefaultColors[ ColorIndex ];
Colors[ ColorIndex ] := ReadInteger( ColoursSection,
'Color' + IntToStr( ColorIndex ),
DefaultColor );
@@ -226,13 +209,8 @@ begin
end;
// Fonts
- NormalFont := fpgGetFont(ReadString(FontsSection, 'NormalFont', DefaultTopicFont));
- if NormalFont = nil then
- NormalFont := fpgStyle.DefaultFont;
-
- FixedFont := fpgGetFont(ReadString(FontsSection, 'FixedFont', DefaultTopicFixedFont));
- if FixedFont = nil then
- FixedFont := fpgStyle.FixedFont;
+ NormalFontDesc := ReadString(FontsSection, 'NormalFont', DefaultTopicFont);
+ FixedFontDesc := ReadString(FontsSection, 'FixedFont', DefaultTopicFixedFont);
for i := 0 to NumFontSettings - 1 do
begin
@@ -243,7 +221,7 @@ begin
end;
FixedFontSubstitution := ReadBool( FontsSection, 'FixedFontSubstitution', true );
- FixedFontSubstitutes := ReadString( FontsSection, 'FixedFontSubstitutes', 'Mono-10' );
+ FixedFontSubstitutes := ReadString( FontsSection, 'FixedFontSubstitutes', DefaultTopicFixedFont );
// Index style
SettingString := ReadString( GeneralSection, 'IndexStyle', 'Full' );
@@ -327,6 +305,7 @@ begin
WriteInteger( GeneralSection, 'FileDialogSplit', Round( FileDialogSplit * 1000 ) );
WriteBool( GeneralSection, 'ShowLeftPanel', ShowLeftPanel);
+ WriteInteger(GeneralSection, 'ScrollDistance', ScrollDistance);
// Colours
for ColorIndex := 0 to High( Colors ) do
@@ -357,8 +336,8 @@ begin
end;
// Fonts
- WriteString( FontsSection, 'NormalFont', NormalFont.FontDesc );
- WriteString( FontsSection, 'FixedFont', FixedFont.FontDesc );
+ WriteString( FontsSection, 'NormalFont', NormalFontDesc );
+ WriteString( FontsSection, 'FixedFont', FixedFontDesc );
for FontIndex := 0 to NumFontSettings - 1 do
begin
FontName := 'Font' + IntToStr( FontIndex );
@@ -473,7 +452,7 @@ begin
end;
end;
-procedure writeSettingsDetailsTo(aStrings : TStrings);
+procedure WriteSettingsDetailsTo(aStrings : TStrings);
Begin
aStrings.Add('');
aStrings.Add('---- Settings ----');
@@ -486,10 +465,11 @@ Begin
aStrings.Add('StartupHelp: ' + boolToStr(Settings.StartupHelp));
// LeftPanelWidth: longint;
aStrings.Add('ShowLeftPanel: ' + boolToStr(Settings.ShowLeftPanel));
+ aStrings.Add('ScrollDistance: ' + IntToStr(Settings.ScrollDistance));
// FileDialogSplit: real;
// Colors: array[ 0..NumColorSettings - 1 ] of TColor;
- // NormalFont: TFont;
- // FixedFont: TFont;
+ aStrings.Add('NormalFont: ' + Settings.NormalFontDesc);
+ aStrings.Add('FixedFont: ' + Settings.FixedFontDesc);
// Fonts: array[ 0..NumFontSettings - 1 ] of TFont;
aStrings.Add('FixedFontSubstitution: ' + boolToStr(Settings.FixedFontSubstitution));
aStrings.Add('FixedFontSubstitutes: ' + Settings.FixedFontSubstitutes);
@@ -508,14 +488,9 @@ end;
Initialization
Settings.MRUList := TObjectList.Create;
-
- //Settings.NormalFont := fpgStyle.DefaultFont;
- //Settings.FixedFont := fpgStyle.FixedFont;
- //Settings.SearchDirectories := TStringList.Create;
+ Settings.SearchDirectories := TStringList.Create;
Finalization
- Settings.NormalFont.Free;
- Settings.FixedFont.Free;
Settings.SearchDirectories.Free;
Settings.MRUList.Free;
diff --git a/docview/src/docview.lpi b/docview/src/docview.lpi
index 5e71947c..9b5c71a8 100644
--- a/docview/src/docview.lpi
+++ b/docview/src/docview.lpi
@@ -28,7 +28,7 @@
<PackageName Value="fpgui_toolkit"/>
</Item1>
</RequiredPackages>
- <Units Count="32">
+ <Units Count="33">
<Unit0>
<Filename Value="docview.lpr"/>
<IsPartOfProject Value="True"/>
@@ -184,6 +184,10 @@
<Filename Value="docview.rc"/>
<IsPartOfProject Value="True"/>
</Unit31>
+ <Unit32>
+ <Filename Value="../docs/docview.ipf"/>
+ <IsPartOfProject Value="True"/>
+ </Unit32>
</Units>
</ProjectOptions>
<CompilerOptions>
diff --git a/docview/src/frm_configuration.pas b/docview/src/frm_configuration.pas
index 9d63db94..10ea5616 100644
--- a/docview/src/frm_configuration.pas
+++ b/docview/src/frm_configuration.pas
@@ -7,22 +7,22 @@ interface
uses
SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_tab, fpg_button,
fpg_label, fpg_edit, fpg_panel, fpg_combobox, fpg_listbox, fpg_checkbox,
- fpg_editbtn;
+ fpg_editbtn, fpg_radiobutton;
type
TConfigurationForm = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: ConfigurationForm}
- PageControl1: TfpgPageControl;
+ pcSettings: TfpgPageControl;
btnSave: TfpgButton;
btnCancel: TfpgButton;
tsGeneral: TfpgTabSheet;
tsFontsColor: TfpgTabSheet;
+ tsIndex: TfpgTabSheet;
Label1: TfpgLabel;
Label2: TfpgLabel;
pnlSearchHighlight: TfpgPanel;
- cbIndexStyle: TfpgComboBox;
lblIndexStyle: TfpgLabel;
lblSearchDirs: TfpgLabel;
btnSearchDirAdd: TfpgButton;
@@ -35,6 +35,12 @@ type
btnResetColors: TfpgButton;
edtFixedFont: TfpgFontEdit;
edtNormalFont: TfpgFontEdit;
+ rbIndexOrig: TfpgRadioButton;
+ rbIndexAlpha: TfpgRadioButton;
+ rbIndexBoth: TfpgRadioButton;
+ lblScrollDistance: TfpgLabel;
+ edtScrollDistance: TfpgEditInteger;
+ lblPixels: TfpgLabel;
{@VFD_HEAD_END: ConfigurationForm}
btnHelp: TfpgButton;
procedure ConfigurationFormShow(Sender: TObject);
@@ -79,7 +85,7 @@ end;
procedure TConfigurationForm.ConfigurationFormShow(Sender: TObject);
begin
SettingsToGui;
- PageControl1.ActivePage := tsGeneral;
+ pcSettings.ActivePage := tsGeneral;
// programatically seting a tab does not fire OnChange event, so we do it mantually
PageControl1Change(self, tsGeneral);
end;
@@ -143,31 +149,44 @@ End;
procedure TConfigurationForm.SettingsToGui;
begin
// General
- cbIndexStyle.FocusItem := Ord(Settings.IndexStyle);
+ edtScrollDistance.Value := Settings.ScrollDistance;
lbSearchDirs.Items.Assign(Settings.SearchDirectories);
chkEscapeIPFSymbols.Checked := Settings.IPFTopicSaveAsEscaped;
chkStartupHelp.Checked := Settings.StartupHelp;
chkOpenTOC.Checked := Settings.OpenWithExpandedContents;
// Fonts & Color
- edtNormalFont.FontDesc := Settings.NormalFont.FontDesc;
- edtFixedFont.FontDesc := Settings.FixedFont.FontDesc;
+ edtNormalFont.FontDesc := Settings.NormalFontDesc;
+ edtFixedFont.FontDesc := Settings.FixedFontDesc;
UpdateColorPanels;
+ // Index
+ rbIndexOrig.Checked := Settings.IndexStyle = isFileOnly;
+ rbIndexAlpha.Checked := Settings.IndexStyle = isAlphabetical;
+ rbIndexBoth.Checked := Settings.IndexStyle = isFull;
end;
procedure TConfigurationForm.GuiToSettings;
begin
// General
- Settings.IndexStyle := TIndexStyle(cbIndexStyle.FocusItem);
+ if edtScrollDistance.Value < 1 then
+ edtScrollDistance.Value := 75; // default
+ if edtScrollDistance.Value > 400 then
+ edtScrollDistance.Value := 400;
+ Settings.ScrollDistance := edtScrollDistance.Value;
Settings.SearchDirectories.Assign(lbSearchDirs.Items);
Settings.IPFTopicSaveAsEscaped := chkEscapeIPFSymbols.Checked;
Settings.StartupHelp := chkStartupHelp.Checked;
Settings.OpenWithExpandedContents := chkOpenTOC.Checked;
// Fonts & Color
- Settings.NormalFont.Free;
- Settings.NormalFont := fpgGetFont(edtNormalFont.FontDesc);
- Settings.FixedFont.Free;
- Settings.FixedFont := fpgGetFont(edtFixedFont.FontDesc);
+ Settings.NormalFontDesc := edtNormalFont.FontDesc;
+ Settings.FixedFontDesc := edtFixedFont.FontDesc;
Settings.Colors[SearchHighlightTextColorIndex] := pnlSearchHighlight.BackgroundColor;
+ // Index
+ if rbIndexOrig.Checked then
+ Settings.IndexStyle := isFileOnly
+ else if rbIndexAlpha.Checked then
+ Settings.IndexStyle := isAlphabetical
+ else if rbIndexBoth.Checked then
+ Settings.IndexStyle := isFull;
end;
procedure TConfigurationForm.UpdateColorPanels;
@@ -189,12 +208,13 @@ begin
SetPosition(402, 189, 515, 439);
WindowTitle := 'Configuration';
Hint := '';
+ ShowHint := True;
WindowPosition := wpOneThirdDown;
- PageControl1 := TfpgPageControl.Create(self);
- with PageControl1 do
+ pcSettings := TfpgPageControl.Create(self);
+ with pcSettings do
begin
- Name := 'PageControl1';
+ Name := 'pcSettings';
SetPosition(4, 4, 506, 388);
Anchors := [anLeft,anRight,anTop,anBottom];
ActivePageIndex := 0;
@@ -212,7 +232,7 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
- TabOrder := 19;
+ TabOrder := 25;
OnClick := @btnSaveClick;
end;
@@ -225,11 +245,11 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
- TabOrder := 20;
+ TabOrder := 26;
OnClick := @btnCancelClick;
end;
- tsGeneral := TfpgTabSheet.Create(PageControl1);
+ tsGeneral := TfpgTabSheet.Create(pcSettings);
with tsGeneral do
begin
Name := 'tsGeneral';
@@ -237,7 +257,7 @@ begin
Text := 'General';
end;
- tsFontsColor := TfpgTabSheet.Create(PageControl1);
+ tsFontsColor := TfpgTabSheet.Create(pcSettings);
with tsFontsColor do
begin
Name := 'tsFontsColor';
@@ -245,6 +265,14 @@ begin
Text := 'Fonts & Color';
end;
+ tsIndex := TfpgTabSheet.Create(pcSettings);
+ with tsIndex do
+ begin
+ Name := 'tsIndex';
+ SetPosition(3, 24, 500, 361);
+ Text := 'Index';
+ end;
+
Label1 := TfpgLabel.Create(tsFontsColor);
with Label1 do
begin
@@ -278,25 +306,12 @@ begin
Text := 'Search Highlight Color';
end;
- cbIndexStyle := TfpgComboBox.Create(tsGeneral);
- with cbIndexStyle do
- begin
- Name := 'cbIndexStyle';
- SetPosition(12, 32, 160, 25);
- FontDesc := '#List';
- Hint := '';
- Items.Add('Alphabetical');
- Items.Add('FileOnly');
- Items.Add('Full');
- TabOrder := 2;
- end;
-
- lblIndexStyle := TfpgLabel.Create(tsGeneral);
+ lblIndexStyle := TfpgLabel.Create(tsIndex);
with lblIndexStyle do
begin
Name := 'lblIndexStyle';
- SetPosition(12, 13, 296, 17);
- FontDesc := '#Label1';
+ SetPosition(12, 12, 224, 17);
+ FontDesc := '#Label2';
Hint := '';
Text := 'Index style';
end;
@@ -320,7 +335,7 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
- TabOrder := 5;
+ TabOrder := 3;
OnClick :=@btnSearchDirAddClicked;
end;
@@ -333,7 +348,7 @@ begin
Hint := '';
HotTrack := False;
PopupFrame := False;
- TabOrder := 7;
+ TabOrder := 5;
Items.Duplicates := dupIgnore;
end;
@@ -346,7 +361,7 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
- TabOrder := 6;
+ TabOrder := 4;
end;
chkEscapeIPFSymbols := TfpgCheckBox.Create(tsGeneral);
@@ -357,7 +372,7 @@ begin
Anchors := [anLeft,anRight,anTop];
FontDesc := '#Label1';
Hint := '';
- TabOrder := 8;
+ TabOrder := 6;
Text := 'Escape symbols when saving topics as IPF text';
end;
@@ -370,7 +385,7 @@ begin
Checked := True;
FontDesc := '#Label1';
Hint := '';
- TabOrder := 9;
+ TabOrder := 7;
Text := 'Show DocView help at startup if no files opened';
end;
@@ -382,7 +397,7 @@ begin
Anchors := [anLeft,anRight,anTop];
FontDesc := '#Label1';
Hint := '';
- TabOrder := 10;
+ TabOrder := 8;
Text := 'Open files with contents expanded';
end;
@@ -395,7 +410,7 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
- TabOrder := 17;
+ TabOrder := 15;
OnClick := @btnSearchHighlightClicked;
end;
@@ -408,7 +423,7 @@ begin
FontDesc := '#Label1';
Hint := '';
ImageName := '';
- TabOrder := 18;
+ TabOrder := 16;
OnClick := @ResetColorsButtonOnClick;
end;
@@ -419,7 +434,7 @@ begin
SetPosition(124, 48, 340, 24);
Anchors := [anLeft,anRight,anTop];
FontDesc := '';
- TabOrder := 15;
+ TabOrder := 14;
end;
edtNormalFont := TfpgFontEdit.Create(tsFontsColor);
@@ -429,14 +444,81 @@ begin
SetPosition(124, 16, 340, 24);
Anchors := [anLeft,anRight,anTop];
FontDesc := '';
- TabOrder := 14;
+ TabOrder := 13;
+ end;
+
+ rbIndexOrig := TfpgRadioButton.Create(tsIndex);
+ with rbIndexOrig do
+ begin
+ Name := 'rbIndexOrig';
+ SetPosition(24, 28, 280, 20);
+ FontDesc := '#Label1';
+ GroupIndex := 1;
+ Hint := '';
+ TabOrder := 21;
+ Text := 'File Only (only entries specified in file)';
+ end;
+
+ rbIndexAlpha := TfpgRadioButton.Create(tsIndex);
+ with rbIndexAlpha do
+ begin
+ Name := 'rbIndexAlpha';
+ SetPosition(24, 48, 280, 20);
+ FontDesc := '#Label1';
+ GroupIndex := 1;
+ Hint := '';
+ TabOrder := 22;
+ Text := 'Alphabetical listing of topics';
+ end;
+
+ rbIndexBoth := TfpgRadioButton.Create(tsIndex);
+ with rbIndexBoth do
+ begin
+ Name := 'rbIndexBoth';
+ SetPosition(24, 68, 280, 20);
+ FontDesc := '#Label1';
+ GroupIndex := 1;
+ Hint := '';
+ TabOrder := 23;
+ Text := 'Both';
+ end;
+
+ lblScrollDistance := TfpgLabel.Create(tsGeneral);
+ with lblScrollDistance do
+ begin
+ Name := 'lblScrollDistance';
+ SetPosition(12, 12, 280, 17);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Mouse Wheel Scroll Distance';
+ end;
+
+ edtScrollDistance := TfpgEditInteger.Create(tsGeneral);
+ with edtScrollDistance do
+ begin
+ Name := 'edtScrollDistance';
+ SetPosition(12, 32, 72, 24);
+ Hint := '';
+ TabOrder := 2;
+ FontDesc := '#Edit1';
+ Value := 0;
+ end;
+
+ lblPixels := TfpgLabel.Create(tsGeneral);
+ with lblPixels do
+ begin
+ Name := 'lblPixels';
+ SetPosition(88, 36, 80, 17);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := '(pixels)';
end;
{@VFD_BODY_END: ConfigurationForm}
{%endregion}
// always reset pagecotrol
- PageControl1.ActivePageIndex := 0;
+ pcSettings.ActivePageIndex := 0;
//btnHelp := TfpgButton.Create(self);
//with btnHelp do
diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas
index 4f040105..4cc0abfa 100644
--- a/docview/src/frm_main.pas
+++ b/docview/src/frm_main.pas
@@ -95,6 +95,7 @@ type
CurrentHistoryIndex: integer;
OpenAdditionalFile: boolean;
+ procedure UpdateRichViewFromSettings;
procedure btnBackHistClick(Sender: TObject);
procedure btnFwdHistClick(Sender: TObject);
procedure btnPrevClick(Sender: TObject);
@@ -210,6 +211,7 @@ uses
,frm_configuration
,frm_text
,NewViewConstantsUnit
+ ,CanvasFontManager
;
const
@@ -237,6 +239,13 @@ begin
end
end;
+procedure TMainForm.UpdateRichViewFromSettings;
+begin
+ RichView.RichTextSettings.NormalFont := fpgGetFont(Settings.NormalFontDesc);
+ RichView.RichTextSettings.FixedFont := fpgGetFont(Settings.FixedFontDesc);
+ RichView.ScrollDistance := Settings.ScrollDistance;
+end;
+
procedure TMainForm.btnBackHistClick(Sender: TObject);
begin
if CurrentHistoryIndex > 0 then
@@ -359,16 +368,11 @@ begin
PageControl1.Width := gINI.ReadInteger('Options', 'SplitterLeft', 260);
UpdateWindowPosition;
- Settings.NormalFont := fpgStyle.DefaultFont;
- Settings.FixedFont := fpgStyle.FixedFont;
- Settings.SearchDirectories := TStringList.Create;
-
- LogEvent(LogSettings, 'Loading settings');
- LoadSettings;
CreateMRUMenuItems;
ProcessCommandLineParams;
RichView.Images := FImages;
+ UpdateRichViewFromSettings;
if ParamCount = 0 then
begin
@@ -382,7 +386,6 @@ begin
OpenFile(lFilename, '', true);
end;
end;
-
end;
procedure TMainForm.MainFormDestroy(Sender: TObject);
@@ -436,6 +439,7 @@ end;
procedure TMainForm.miConfigureClicked(Sender: TObject);
begin
ShowConfigForm;
+ UpdateRichViewFromSettings;
end;
procedure TMainForm.miViewExpandAllClicked(Sender: TObject);
@@ -1934,6 +1938,8 @@ begin
'dv.arrowdown', @usr_arrow_down,
sizeof(usr_arrow_down), 0, 0);
+ // load custom user settings like Fonts, Search Highlight Color etc.
+ LoadSettings;
end;
destructor TMainForm.Destroy;
@@ -2745,7 +2751,7 @@ const
var
s: string;
begin
- s := '<font "Arial" 12><b>' + cLongName + '</b></font>' + le
+ s := '<font "' + DefaultTopicFontName + '" 12><b>' + cLongName + '</b></font>' + le
+ cVersion + le + le
+ 'Supported command line parameters:' + le + le
+ '<tt>'