ADD: We may configure the font used in the Tree View Menu.

FIX: The font used for the search results is not correctly preserved and restored from a session to another.
ADD: The font used for the function button at the buttom in main panel is now configurable (before, we were able to change size, but not actual font used).
CHG: The elements of the configuration window for the font are now generated at run-time instead of being at design-time. Elements are generated from the "gFonts" so we won't forget any configurable font this way.
UPD: New language files for above modification. But they have been updated in such way that the translated strings for the font usage have been preserved. Only the last three that were forgotten and not present visually in previous versions are to be translated.
This commit is contained in:
Denis Bisson 2020-01-03 04:55:45 +00:00
commit be0aed37ff
46 changed files with 2090 additions and 3109 deletions

View file

@ -1,477 +1,18 @@
inherited frmOptionsFonts: TfrmOptionsFonts
Height = 465
Width = 741
ClientHeight = 465
ClientWidth = 741
DesignLeft = 101
DesignTop = 155
object lblMainFont: TLabel[0]
Left = 6
Height = 15
Top = 8
Width = 52
Caption = 'Main &font'
FocusControl = edtMainFont
ParentColor = False
end
object lblEditorFont: TLabel[1]
AnchorSideTop.Control = edtMainFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 62
Width = 56
BorderSpacing.Top = 10
Caption = '&Editor font'
FocusControl = edtEditorFont
ParentColor = False
end
object lblViewerFont: TLabel[2]
AnchorSideTop.Control = edtEditorFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 116
Width = 60
BorderSpacing.Top = 10
Caption = '&Viewer font'
FocusControl = edtViewerFont
ParentColor = False
end
object btnSelMainFnt: TButton[3]
AnchorSideTop.Control = edtMainFontSize
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtMainFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 29
Width = 40
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Right = 8
Caption = '...'
OnClick = btnSelMainFntClick
TabOrder = 2
end
object edtMainFontSize: TSpinEdit[4]
AnchorSideTop.Control = edtMainFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelMainFnt
Left = 634
Height = 23
Top = 29
Width = 55
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtMainFontSizeChange
TabOrder = 1
Value = 14
end
object edtMainFont: TEdit[5]
AnchorSideLeft.Control = lblMainFont
AnchorSideTop.Control = lblMainFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtMainFontSize
Left = 6
Height = 23
Top = 29
Width = 624
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
OnExit = edtMainFontExit
TabOrder = 0
end
object btnSelEditFnt: TButton[6]
AnchorSideTop.Control = edtEditorFontSize
AnchorSideRight.Control = btnSelMainFnt
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtEditorFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 83
Width = 40
Anchors = [akTop, akRight, akBottom]
BorderSpacing.InnerBorder = 4
Caption = '...'
OnClick = btnSelEditFntClick
TabOrder = 5
end
object edtEditorFont: TEdit[7]
AnchorSideLeft.Control = lblEditorFont
AnchorSideTop.Control = lblEditorFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtEditorFontSize
Left = 6
Height = 23
Top = 83
Width = 624
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
OnExit = edtEditorFontExit
TabOrder = 3
end
object edtEditorFontSize: TSpinEdit[8]
AnchorSideTop.Control = edtEditorFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelEditFnt
Left = 634
Height = 23
Top = 83
Width = 55
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtEditorFontSizeChange
TabOrder = 4
Value = 14
end
object btnSelViewFnt: TButton[9]
AnchorSideTop.Control = edtViewerFontSize
AnchorSideRight.Control = btnSelEditFnt
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtViewerFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 137
Width = 40
Anchors = [akTop, akRight, akBottom]
BorderSpacing.InnerBorder = 4
Caption = '...'
OnClick = btnSelViewFntClick
TabOrder = 8
end
object edtViewerFont: TEdit[10]
AnchorSideLeft.Control = lblViewerFont
AnchorSideTop.Control = lblViewerFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtViewerFontSize
Left = 6
Height = 23
Top = 137
Width = 623
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
OnExit = edtViewerFontExit
TabOrder = 6
end
object edtViewerFontSize: TSpinEdit[11]
AnchorSideTop.Control = edtViewerFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelViewFnt
Left = 633
Height = 23
Top = 137
Width = 56
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtViewerFontSizeChange
TabOrder = 7
Value = 14
end
object lblLogFont: TLabel[12]
AnchorSideLeft.Control = edtViewerFont
AnchorSideTop.Control = edtViewerBookFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 224
Width = 45
BorderSpacing.Top = 10
Caption = '&Log font'
FocusControl = edtLogFont
ParentColor = False
end
object edtLogFont: TEdit[13]
AnchorSideLeft.Control = lblLogFont
AnchorSideTop.Control = lblLogFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtLogFontSize
Left = 6
Height = 23
Top = 245
Width = 623
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
OnExit = edtLogFontExit
TabOrder = 12
end
object btnSelLogFnt: TButton[14]
AnchorSideTop.Control = edtLogFontSize
AnchorSideRight.Control = btnSelViewerBookFnt
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtLogFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 245
Width = 40
Anchors = [akTop, akRight, akBottom]
BorderSpacing.InnerBorder = 4
Caption = '...'
OnClick = btnSelLogFntClick
TabOrder = 14
end
object edtLogFontSize: TSpinEdit[15]
AnchorSideTop.Control = edtLogFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelLogFnt
Left = 633
Height = 23
Top = 245
Width = 56
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtLogFontSizeChange
TabOrder = 13
Value = 14
end
object lblViewerBookFont: TLabel[16]
AnchorSideLeft.Control = edtViewerFont
AnchorSideTop.Control = edtViewerFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 170
Width = 89
BorderSpacing.Top = 10
Caption = 'Viewer&Book Font'
FocusControl = edtViewerBookFont
ParentColor = False
end
object edtViewerBookFont: TEdit[17]
AnchorSideLeft.Control = lblViewerBookFont
AnchorSideTop.Control = lblViewerBookFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtViewerBookFontSize
Left = 6
Height = 23
Top = 191
Width = 623
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
OnExit = edtViewerBookFontExit
TabOrder = 9
end
object edtViewerBookFontSize: TSpinEdit[18]
AnchorSideTop.Control = edtViewerBookFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelViewerBookFnt
Left = 633
Height = 23
Top = 191
Width = 56
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtViewerBookFontSizeChange
TabOrder = 10
Value = 18
end
object btnSelViewerBookFnt: TButton[19]
AnchorSideTop.Control = edtViewerBookFontSize
AnchorSideRight.Control = btnSelViewFnt
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtViewerBookFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 191
Width = 40
Anchors = [akTop, akRight, akBottom]
Caption = '...'
OnClick = btnSelViewerBookFntClick
TabOrder = 11
end
object btnSelConsoleFnt: TButton[20]
AnchorSideTop.Control = edtConsoleFontSize
AnchorSideRight.Control = btnSelViewerBookFnt
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtConsoleFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 299
Width = 40
Anchors = [akTop, akRight, akBottom]
BorderSpacing.InnerBorder = 4
Caption = '...'
OnClick = btnSelConsoleFntClick
TabOrder = 17
end
object edtConsoleFontSize: TSpinEdit[21]
AnchorSideTop.Control = edtConsoleFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelConsoleFnt
Left = 633
Height = 23
Top = 299
Width = 56
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtConsoleFontSizeChange
TabOrder = 16
Value = 14
end
object edtConsoleFont: TEdit[22]
AnchorSideLeft.Control = lblConsoleFont
AnchorSideTop.Control = lblConsoleFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtConsoleFontSize
Left = 6
Height = 23
Top = 299
Width = 623
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
OnExit = edtConsoleFontExit
TabOrder = 15
end
object lblConsoleFont: TLabel[23]
AnchorSideLeft.Control = edtViewerFont
AnchorSideTop.Control = edtLogFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 278
Width = 68
BorderSpacing.Top = 10
Caption = '&Console font'
FocusControl = edtConsoleFont
ParentColor = False
end
object lblPathEditFont: TLabel[24]
AnchorSideLeft.Control = edtViewerFont
AnchorSideTop.Control = edtConsoleFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 332
Width = 49
BorderSpacing.Top = 10
Caption = 'Path font'
FocusControl = edtPathEditFont
ParentColor = False
end
object edtPathEditFont: TEdit[25]
AnchorSideLeft.Control = lblPathEditFont
AnchorSideTop.Control = lblPathEditFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtPathEditFontSize
Left = 6
Height = 23
Top = 353
Width = 623
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
TabOrder = 18
end
object edtPathEditFontSize: TSpinEdit[26]
AnchorSideTop.Control = edtPathEditFont
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnSelMainFnt
Left = 633
Height = 23
Top = 353
Width = 56
Anchors = [akTop, akRight]
BorderSpacing.Right = 4
MaxValue = 99
MinValue = 6
OnChange = edtPathEditFontSizeChange
TabOrder = 19
Value = 12
end
object btnPathEditFnt: TButton[27]
AnchorSideTop.Control = edtPathEditFontSize
AnchorSideRight.Control = btnSelViewerBookFnt
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edtPathEditFontSize
AnchorSideBottom.Side = asrBottom
Left = 693
Height = 23
Top = 353
Width = 40
Anchors = [akTop, akRight, akBottom]
Caption = '...'
OnClick = btnPathEditFntClick
TabOrder = 20
end
object lblSearchResultsFont: TLabel[28]
AnchorSideLeft.Control = edtViewerFont
AnchorSideTop.Control = edtPathEditFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 15
Top = 386
Width = 97
BorderSpacing.Top = 10
Caption = 'Search results font'
ParentColor = False
Visible = False
end
object edtSearchResultsFont: TEdit[29]
AnchorSideTop.Control = lblSearchResultsFont
AnchorSideTop.Side = asrBottom
Left = 6
Height = 23
Top = 407
Width = 622
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 4
TabOrder = 21
Visible = False
end
object edtSearchresultsFontSize: TSpinEdit[30]
AnchorSideTop.Control = edtSearchResultsFont
AnchorSideTop.Side = asrCenter
Left = 632
Height = 23
Top = 407
Width = 57
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Right = 4
TabOrder = 22
Value = 12
Visible = False
end
object btnSearchResultsFnt: TButton[31]
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 689
Height = 25
Top = 409
Width = 40
Anchors = [akTop, akLeft, akRight, akBottom]
Caption = '...'
TabOrder = 23
Visible = False
end
object dlgFnt: TFontDialog[32]
Height = 372
Hint = 'Fonts'
Width = 601
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 3
ChildSizing.VerticalSpacing = 2
DesignLeft = 804
DesignTop = 355
object dlgFnt: TFontDialog[0]
MinFontSize = 0
MaxFontSize = 0
Options = [fdNoStyleSel]
left = 88
top = 8
Options = []
left = 80
top = 40
end
end

View file

@ -1,18 +1,3 @@
{"version":1,"strings":[
{"hash":2756180,"name":"tfrmoptionsfonts.lblmainfont.caption","sourcebytes":[77,97,105,110,32,38,102,111,110,116],"value":"Main &font"},
{"hash":82675428,"name":"tfrmoptionsfonts.lbleditorfont.caption","sourcebytes":[38,69,100,105,116,111,114,32,102,111,110,116],"value":"&Editor font"},
{"hash":251284100,"name":"tfrmoptionsfonts.lblviewerfont.caption","sourcebytes":[38,86,105,101,119,101,114,32,102,111,110,116],"value":"&Viewer font"},
{"hash":12558,"name":"tfrmoptionsfonts.btnselmainfnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":12558,"name":"tfrmoptionsfonts.btnseleditfnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":12558,"name":"tfrmoptionsfonts.btnselviewfnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":93781860,"name":"tfrmoptionsfonts.lbllogfont.caption","sourcebytes":[38,76,111,103,32,102,111,110,116],"value":"&Log font"},
{"hash":12558,"name":"tfrmoptionsfonts.btnsellogfnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":135642868,"name":"tfrmoptionsfonts.lblviewerbookfont.caption","sourcebytes":[86,105,101,119,101,114,38,66,111,111,107,32,70,111,110,116],"value":"Viewer&Book Font"},
{"hash":12558,"name":"tfrmoptionsfonts.btnselviewerbookfnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":12558,"name":"tfrmoptionsfonts.btnselconsolefnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":147894484,"name":"tfrmoptionsfonts.lblconsolefont.caption","sourcebytes":[38,67,111,110,115,111,108,101,32,102,111,110,116],"value":"&Console font"},
{"hash":178693332,"name":"tfrmoptionsfonts.lblpatheditfont.caption","sourcebytes":[80,97,116,104,32,102,111,110,116],"value":"Path font"},
{"hash":12558,"name":"tfrmoptionsfonts.btnpatheditfnt.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":90371988,"name":"tfrmoptionsfonts.lblsearchresultsfont.caption","sourcebytes":[83,101,97,114,99,104,32,114,101,115,117,108,116,115,32,102,111,110,116],"value":"Search results font"},
{"hash":12558,"name":"tfrmoptionsfonts.btnsearchresultsfnt.caption","sourcebytes":[46,46,46],"value":"..."}
{"hash":5072307,"name":"tfrmoptionsfonts.hint","sourcebytes":[70,111,110,116,115],"value":"Fonts"}
]}

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
Fonts options page
Copyright (C) 2006-2011 Koblov Alexander (Alexx2000@mail.ru)
Copyright (C) 2006-2020 Alexander Koblov (alexx2000@mail.ru)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -16,8 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit fOptionsFonts;
@ -27,83 +26,35 @@ unit fOptionsFonts;
interface
uses
Classes, SysUtils,
StdCtrls, Spin, Dialogs, Graphics, fOptionsFrame, uGlobs;
//Lazarus, Free-Pascal, etc.
Classes, StdCtrls, Spin, Dialogs,
//DC
fOptionsFrame, uGlobs;
type
{ TVisualFontElements }
TVisualFontElements = record
FontEdit: TEdit;
FontSpindEdit: TSpinEdit;
end;
{ TfrmOptionsFonts }
TfrmOptionsFonts = class(TOptionsEditor)
btnSelEditFnt: TButton;
btnSelLogFnt: TButton;
btnSelConsoleFnt: TButton;
btnSelMainFnt: TButton;
btnSelViewerBookFnt: TButton;
btnSelViewFnt: TButton;
btnPathEditFnt: TButton;
btnSearchResultsFnt: TButton;
dlgFnt: TFontDialog;
edtSearchResultsFont: TEdit;
edtPathEditFont: TEdit;
edtEditorFont: TEdit;
edtEditorFontSize: TSpinEdit;
edtLogFont: TEdit;
edtConsoleFont: TEdit;
edtLogFontSize: TSpinEdit;
edtConsoleFontSize: TSpinEdit;
edtMainFont: TEdit;
edtMainFontSize: TSpinEdit;
edtViewerBookFont: TEdit;
edtViewerBookFontSize: TSpinEdit;
edtViewerFont: TEdit;
edtViewerFontSize: TSpinEdit;
lblSearchResultsFont: TLabel;
lblPathEditFont: TLabel;
lblEditorFont: TLabel;
lblLogFont: TLabel;
lblConsoleFont: TLabel;
lblMainFont: TLabel;
lblViewerBookFont: TLabel;
lblViewerFont: TLabel;
edtPathEditFontSize: TSpinEdit;
edtSearchresultsFontSize: TSpinEdit;
procedure btnPathEditFntClick(Sender: TObject);
procedure btnSelConsoleFntClick(Sender: TObject);
procedure btnSelEditFntClick(Sender: TObject);
procedure btnSelMainFntClick(Sender: TObject);
procedure btnSelViewFntClick(Sender: TObject);
procedure btnSelLogFntClick(Sender: TObject);
procedure btnSelViewerBookFntClick(Sender: TObject);
procedure edtConsoleFontExit(Sender: TObject);
procedure edtConsoleFontSizeChange(Sender: TObject);
procedure edtEditorFontExit(Sender: TObject);
procedure edtEditorFontSizeChange(Sender: TObject);
procedure edtLogFontExit(Sender: TObject);
procedure edtMainFontExit(Sender: TObject);
procedure edtMainFontSizeChange(Sender: TObject);
procedure edtPathEditFontSizeChange(Sender: TObject);
procedure edtViewerBookFontExit(Sender: TObject);
procedure edtViewerFontExit(Sender: TObject);
procedure edtViewerFontSizeChange(Sender: TObject);
procedure edtLogFontSizeChange(Sender: TObject);
procedure edtViewerBookFontSizeChange(Sender: TObject);
procedure edtFontExit(Sender: TObject);
procedure edtMouseWheelDown(Sender: TObject; Shift: TShiftState; {%H-}MousePos: TPoint; var {%H-}Handled: boolean);
procedure edtMouseWheelUp(Sender: TObject; Shift: TShiftState; {%H-}MousePos: TPoint; var {%H-}Handled: boolean);
procedure edtFontSizeChange(Sender: TObject);
procedure btnSelFontClick(Sender: TObject);
private
procedure LoadFont(aDCFont:TDCFont);
procedure SaveFont(aDCFont:TDCFont);
//
function GetFont(aDCFont:TDCFont):TFont;
procedure SetFont(aDCFont:TDCFont;aFont:TFont);
procedure SetFontSize(aDCFont:TDCFont;aFontSize:Integer);
procedure SetFontName(aDCFont:TDCFont;aFontName:String);
//
procedure RunDialogFont(aDCFont:TDCFont);
LocalVisualFontElements: array[0..pred(Length(TDCFontsOptions))] of TVisualFontElements;
protected
procedure Init; override;
procedure Load; override;
function Save: TOptionsEditorSaveFlags; override;
public
class function GetIconIndex: Integer; override;
class function GetTitle: String; override;
class function GetIconIndex: integer; override;
class function GetTitle: string; override;
end;
implementation
@ -111,248 +62,182 @@ implementation
{$R *.lfm}
uses
//Lazarus, Free-Pascal, etc.
Controls,
//DC
uLng;
{ TfrmOptionsFonts }
procedure TfrmOptionsFonts.btnSelMainFntClick(Sender: TObject);
begin
RunDialogFont(dcfMain);
end;
procedure TfrmOptionsFonts.btnSelEditFntClick(Sender: TObject);
begin
RunDialogFont(dcfEditor);
end;
procedure TfrmOptionsFonts.btnSelConsoleFntClick(Sender: TObject);
begin
RunDialogFont(dcfConsole);
end;
procedure TfrmOptionsFonts.btnPathEditFntClick(Sender: TObject);
begin
RunDialogFont(dcfPathEdit);
end;
procedure TfrmOptionsFonts.btnSelViewFntClick(Sender: TObject);
begin
RunDialogFont(dcfViewer);
end;
procedure TfrmOptionsFonts.btnSelViewerBookFntClick(Sender: TObject);
begin
RunDialogFont(dcfViewerBook);
end;
procedure TfrmOptionsFonts.edtConsoleFontExit(Sender: TObject);
begin
SetFontName(dcfConsole, TEdit(Sender).Text);
end;
procedure TfrmOptionsFonts.edtConsoleFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfConsole, TSpinEdit(Sender).Value);
end;
procedure TfrmOptionsFonts.btnSelLogFntClick(Sender: TObject);
begin
RunDialogFont(dcfLog);
end;
procedure TfrmOptionsFonts.edtMainFontExit(Sender: TObject);
begin
SetFontName(dcfMain, TEdit(Sender).Text);
end;
procedure TfrmOptionsFonts.edtEditorFontExit(Sender: TObject);
begin
SetFontName(dcfEditor, TEdit(Sender).Text);
end;
procedure TfrmOptionsFonts.edtViewerFontExit(Sender: TObject);
begin
SetFontName(dcfViewer, TEdit(Sender).Text);
end;
procedure TfrmOptionsFonts.edtViewerBookFontExit(Sender: TObject);
begin
SetFontName(dcfViewerBook, TEdit(Sender).Text);
end;
procedure TfrmOptionsFonts.edtLogFontExit(Sender: TObject);
begin
SetFontName(dcfLog, TEdit(Sender).Text);
end;
procedure TfrmOptionsFonts.edtMainFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfMain, TSpinEdit(Sender).Value);
end;
procedure TfrmOptionsFonts.edtPathEditFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfPathEdit, TSpinEdit(Sender).Value);
end;
procedure TfrmOptionsFonts.edtEditorFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfEditor, TSpinEdit(Sender).Value);
end;
procedure TfrmOptionsFonts.edtViewerFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfViewer, TSpinEdit(Sender).Value);
end;
procedure TfrmOptionsFonts.edtViewerBookFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfViewerBook, TSpinEdit(Sender).Value);
end;
procedure TfrmOptionsFonts.edtLogFontSizeChange(Sender: TObject);
begin
SetFontSize(dcfLog, TSpinEdit(Sender).Value);
end;
class function TfrmOptionsFonts.GetIconIndex: Integer;
{ TfrmOptionsFonts.GetIconIndex }
class function TfrmOptionsFonts.GetIconIndex: integer;
begin
Result := 3;
end;
class function TfrmOptionsFonts.GetTitle: String;
{ TfrmOptionsFonts.GetTitle }
class function TfrmOptionsFonts.GetTitle: string;
begin
Result := rsOptionsEditorFonts;
end;
procedure TfrmOptionsFonts.Load;
{ TfrmOptionsMultiRename.Init }
// We draw manually the whole thing from the gFont array instead of having designed the form at the conception time.
// This way, we're sure to don't forget a font, for one, and second, if we ever add a font, no modification will be required here, in the configuration section.
// ...or maybe just if the font has to be monospace.
procedure TfrmOptionsFonts.Init;
var
ALabelFont: TLabel;
AEditFont: TEdit;
APreviousEditFont: TEdit = nil;
ASpinEditFontSize: TSpinEdit;
AButtonFont: TButton;
iFontIndex: integer;
begin
LoadFont(dcfMain);
LoadFont(dcfEditor);
LoadFont(dcfViewer);
LoadFont(dcfLog);
LoadFont(dcfViewerBook);
LoadFont(dcfConsole);
LoadFont(dcfPathEdit);
LoadFont(dcfSearchResults);
for iFontIndex := 0 to pred(Length(TDCFontsOptions)) do
begin
ALabelFont := TLabel.Create(Self);
ALabelFont.Parent := Self;
ALabelFont.Caption := gFonts[TDCFont(iFontIndex)].Usage;
AEditFont := TEdit.Create(Self);
LocalVisualFontElements[iFontIndex].FontEdit := AEditFont;
AEditFont.Parent := Self;
AEditFont.Tag := iFontIndex;
AEditFont.OnExit := @edtFontExit;
AEditFont.OnMouseWheelDown := @edtMouseWheelDown;
AEditFont.OnMouseWheelUp := @edtMouseWheelUp;
AEditFont.Anchors := [akTop, akLeft, akRight];
ALabelFont.FocusControl := AEditFont;
ASpinEditFontSize := TSpinEdit.Create(Self);
LocalVisualFontElements[iFontIndex].FontSpindEdit := ASpinEditFontSize;
ASpinEditFontSize.Tag := iFontIndex;
ASpinEditFontSize.Parent := Self;
ASpinEditFontSize.OnChange := @edtFontSizeChange;
ASpinEditFontSize.MinValue := gFonts[TDCFont(iFontIndex)].MinValue;
ASpinEditFontSize.MaxValue := gFonts[TDCFont(iFontIndex)].MaxValue;
ASpinEditFontSize.Width := 55;
ASpinEditFontSize.Anchors := [akTop, akRight];
AButtonFont := TButton.Create(Self);
AButtonFont.Tag := iFontIndex;
AButtonFont.Parent := Self;;
AButtonFont.AutoSize := True;
AButtonFont.Caption := '...';
AButtonFont.OnClick := @btnSelFontClick;
AButtonFont.Anchors := [akTop, akRight];
ALabelFont.AnchorSideLeft.Control := Self;
if APreviousEditFont <> nil then
begin
ALabelFont.AnchorSideTop.Control := APreviousEditFont;
ALabelFont.AnchorSideTop.Side := asrBottom;
ALabelFont.BorderSpacing.Top := 6;
end
else
begin
ALabelFont.AnchorSideTop.Control := Self;
end;
AEditFont.AnchorSideLeft.Control := ALabelFont;
AEditFont.AnchorSideTop.Control := ALabelFont;
AEditFont.AnchorSideTop.Side := asrBottom;
AEditFont.AnchorSideRight.Control := ASpinEditFontSize;
ASpinEditFontSize.AnchorSideTop.Control := AEditFont;
ASpinEditFontSize.AnchorSideTop.Side := asrCenter;
ASpinEditFontSize.AnchorSideRight.Control := AButtonFont;
AButtonFont.AnchorSideTop.Control := AEditFont;
AButtonFont.AnchorSideTop.Side := asrCenter;
AButtonFont.AnchorSideRight.Control := Self;
AButtonFont.AnchorSideRight.Side := asrBottom;
AButtonFont.AnchorSideBottom.Side := asrBottom;
APreviousEditFont := AEditFont;
end;
end;
{ TfrmOptionsFonts.Load }
// The idea here is to take the general font style and apply them to TEdit in the page.
// User plays with that to set the properties he wants.
// Then at the end we recuperate the font from the TEdit's and store properties user set back to the general fonts.
procedure TfrmOptionsFonts.Load;
var
iFontIndex: integer;
begin
for iFontIndex := 0 to pred(Length(TDCFontsOptions)) do
begin
LocalVisualFontElements[iFontIndex].FontEdit.Text := gFonts[TDCFont(iFontIndex)].Name;
FontOptionsToFont(gFonts[TDCFont(iFontIndex)], LocalVisualFontElements[iFontIndex].FontEdit.Font);
LocalVisualFontElements[iFontIndex].FontSpindEdit.Value := gFonts[TDCFont(iFontIndex)].Size;
end;
end;
{ TfrmOptionsFonts.Save }
function TfrmOptionsFonts.Save: TOptionsEditorSaveFlags;
var
iFontIndex: integer;
begin
Result := [];
SaveFont(dcfMain);
SaveFont(dcfEditor);
SaveFont(dcfViewer);
SaveFont(dcfLog);
SaveFont(dcfViewerBook);
SaveFont(dcfConsole);
SaveFont(dcfPathEdit);
SaveFont(dcfSearchResults);
for iFontIndex := 0 to pred(Length(TDCFontsOptions)) do
FontToFontOptions(LocalVisualFontElements[iFontIndex].FontEdit.Font, gFonts[TDCFont(iFontIndex)]);
end;
procedure TfrmOptionsFonts.LoadFont(aDCFont: TDCFont);
var xFont:TFont;
{ TfrmOptionsFonts.edtFontExit }
procedure TfrmOptionsFonts.edtFontExit(Sender: TObject);
begin
xFont:=TFont.Create;
try
FontOptionsToFont(gFonts[aDCFont], xFont);
SetFont(aDCFont, xFont);
finally
FreeAndNil(xFont);
TEdit(Sender).Font.Name := TEdit(Sender).Text;
end;
{ TfrmOptionsFonts.edtMouseWheelDown }
procedure TfrmOptionsFonts.edtMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: boolean);
begin
if (ssCtrl in Shift) and (LocalVisualFontElements[TEdit(Sender).Tag].FontSpindEdit.Value > gFonts[TDCFont(TEdit(Sender).Tag)].MinValue) then
begin
TEdit(Sender).Font.Size := TEdit(Sender).Font.Size - 1;
LocalVisualFontElements[TEdit(Sender).Tag].FontSpindEdit.Value := TEdit(Sender).Font.Size;
end;
end;
procedure TfrmOptionsFonts.SaveFont(aDCFont: TDCFont);
{ TfrmOptionsFonts.edtMouseWheelUp }
procedure TfrmOptionsFonts.edtMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: boolean);
begin
FontToFontOptions(GetFont(aDCFont), gFonts[aDCFont]);
end;
procedure TfrmOptionsFonts.SetFont(aDCFont: TDCFont; aFont: TFont);
begin
case aDCFont of
dcfMain: begin
edtMainFont.Font := aFont;
edtMainFont.Text := aFont.Name;
edtMainFontSize.Value := aFont.Size;
end;
dcfEditor: begin
edtEditorFont.Font := aFont;
edtEditorFont.Text := aFont.Name;
edtEditorFontSize.Value := aFont.Size;
end;
dcfViewer: begin
edtViewerFont.Font := aFont;
edtViewerFont.Text := aFont.Name;
edtViewerFontSize.Value := aFont.Size;
end;
dcfLog: begin
edtLogFont.Font := aFont;
edtLogFont.Text := aFont.Name;
edtLogFontSize.Value := aFont.Size;
end;
dcfViewerBook: begin
edtViewerBookFont.Font := aFont;
edtViewerBookFont.Text := aFont.Name;
edtViewerBookFontSize.Value := aFont.Size;
end;
dcfConsole: begin
edtConsoleFont.Font := aFont;
edtConsoleFont.Text := aFont.Name;
edtConsoleFontSize.Value := aFont.Size;
end;
dcfSearchResults: begin
edtSearchResultsFont.Font := aFont;
edtSearchResultsFont.Text := aFont.Name;
edtSearchResultsFontSize.Value := aFont.Size;
end;
dcfPathEdit: begin
edtPathEditFont.Font := aFont;
edtPathEditFont.Text := aFont.Name;
edtPathEditFontSize.Value := aFont.Size;
end;
if (ssCtrl in Shift) and (LocalVisualFontElements[TEdit(Sender).Tag].FontSpindEdit.Value < gFonts[TDCFont(TEdit(Sender).Tag)].MaxValue) then
begin
TEdit(Sender).Font.Size := TEdit(Sender).Font.Size + 1;
LocalVisualFontElements[TEdit(Sender).Tag].FontSpindEdit.Value := TEdit(Sender).Font.Size;
end;
end;
procedure TfrmOptionsFonts.SetFontSize(aDCFont: TDCFont; aFontSize: Integer);
{ TfrmOptionsFonts.edtFontSizeChange }
procedure TfrmOptionsFonts.edtFontSizeChange(Sender: TObject);
begin
GetFont(aDCFont).Size:=aFontSize;
if (LocalVisualFontElements[TSpinEdit(Sender).Tag].FontEdit.Font.Size <> TSpinEdit(Sender).Value) then
LocalVisualFontElements[TSpinEdit(Sender).Tag].FontEdit.Font.Size := TSpinEdit(Sender).Value;
end;
procedure TfrmOptionsFonts.SetFontName(aDCFont: TDCFont; aFontName: String);
begin
GetFont(aDCFont).Name:=aFontName;
end;
function TfrmOptionsFonts.GetFont(aDCFont: TDCFont): TFont;
begin
case aDCFont of
dcfMain : Result := edtMainFont.Font;
dcfEditor : Result := edtEditorFont.Font;
dcfViewer : Result := edtViewerFont.Font;
dcfLog : Result := edtLogFont.Font;
dcfViewerBook: Result := edtViewerBookFont.Font;
dcfConsole : Result := edtConsoleFont.Font;
dcfSearchResults: Result := edtSearchResultsFont.Font;
dcfPathEdit : Result := edtPathEditFont.Font;
else Result := nil; // TODO: show error for programmer
end;
end;
procedure TfrmOptionsFonts.RunDialogFont(aDCFont: TDCFont);
{ TfrmOptionsFonts.btnSelFontClick }
procedure TfrmOptionsFonts.btnSelFontClick(Sender: TObject);
const
cMonoFonts = [dcfViewer, dcfEditor, dcfLog, dcfConsole];
cMonoFonts = [dcfEditor, dcfViewer, dcfLog, dcfConsole];
begin
dlgFnt.Font := GetFont(aDCFont);
if (aDCFont in cMonoFonts) then begin
dlgFnt.Options:= dlgFnt.Options + [fdFixedPitchOnly];
begin
dlgFnt.Font := LocalVisualFontElements[TButton(Sender).Tag].FontEdit.Font;
if (TDCFont(TButton(Sender).Tag) in cMonoFonts) then
dlgFnt.Options := dlgFnt.Options + [fdFixedPitchOnly, fdNoStyleSel]
else
dlgFnt.Options := dlgFnt.Options - [fdFixedPitchOnly, fdNoStyleSel];
if dlgFnt.Execute then
begin
LocalVisualFontElements[TButton(Sender).Tag].FontEdit.Font := dlgFnt.Font;
LocalVisualFontElements[TButton(Sender).Tag].FontEdit.Text := dlgFnt.Font.Name;
LocalVisualFontElements[TButton(Sender).Tag].FontSpindEdit.Value := dlgFnt.Font.Size;
end;
end;
if dlgFnt.Execute then SetFont(aDCFont, dlgFnt.Font);
dlgFnt.Options:= dlgFnt.Options - [fdFixedPitchOnly];
end;
end.

View file

@ -1,11 +1,11 @@
inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
Height = 402
Width = 577
Height = 478
Width = 600
AutoSize = True
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 402
ClientWidth = 577
ClientHeight = 478
ClientWidth = 600
Constraints.MinHeight = 400
Constraints.MinWidth = 500
ParentShowHint = False
@ -21,7 +21,7 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
Left = 6
Height = 371
Top = 10
Width = 565
Width = 588
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 10
@ -29,7 +29,7 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
ChildSizing.LeftRightSpacing = 10
ChildSizing.TopBottomSpacing = 6
ClientHeight = 351
ClientWidth = 561
ClientWidth = 584
TabOrder = 0
object cbkUsageKeyboardShortcut: TCheckBox
AnchorSideLeft.Control = gbLayoutAndColors
@ -145,10 +145,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 61
Left = 60
Height = 15
Top = 89
Width = 95
Width = 96
Anchors = [akTop, akRight]
Caption = 'Normal text color:'
FocusControl = cbNormalTextColor
@ -197,10 +197,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 46
Left = 45
Height = 15
Top = 117
Width = 110
Width = 111
Anchors = [akTop, akRight]
Caption = 'Secondary text color:'
FocusControl = cbSecondaryTextColor
@ -249,10 +249,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 67
Left = 66
Height = 15
Top = 143
Width = 89
Width = 90
Anchors = [akTop, akRight]
Caption = 'Found text color:'
FocusControl = cbFoundTextColor
@ -299,10 +299,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 34
Left = 33
Height = 15
Top = 169
Width = 122
Width = 123
Anchors = [akTop, akRight]
Caption = 'Unselectable text color:'
FocusControl = cbUnselectableTextColor
@ -450,10 +450,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 21
Left = 20
Height = 15
Top = 247
Width = 135
Width = 136
Anchors = [akTop, akRight]
Caption = 'Normal text under cursor:'
FocusControl = cbNormalTextUnderCursor
@ -501,10 +501,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 6
Left = 5
Height = 15
Top = 275
Width = 150
Width = 151
Anchors = [akTop, akRight]
Caption = 'Secondary text under cursor:'
FocusControl = cbSecondaryTextUnderCursor
@ -553,10 +553,10 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = lblShortcutColor
AnchorSideRight.Side = asrBottom
Left = 27
Left = 26
Height = 15
Top = 301
Width = 129
Width = 130
Anchors = [akTop, akRight]
Caption = 'Found text under cursor:'
FocusControl = cbFoundTextUnderCursor
@ -658,7 +658,7 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
Left = 404
Height = 15
Top = 8
Width = 147
Width = 170
Alignment = taCenter
Anchors = [akTop, akLeft, akRight]
Caption = 'Tree View Menu Preview:'
@ -679,19 +679,82 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
Height = 322
Hint = 'Change color on left and you''ll see here a preview of what your Tree View Menus will look likes with this sample.'
Top = 23
Width = 147
Width = 170
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 10
BackgroundColor = clBtnFace
Color = clBtnFace
DefaultItemHeight = 18
ReadOnly = True
ScrollBars = ssNone
TabOrder = 25
OnMouseWheelDown = TreeViewMenuSampleMouseWheelDown
OnMouseWheelUp = TreeViewMenuSampleMouseWheelUp
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
end
end
object optColorDialog: TColorDialog[1]
object gbFont: TGroupBox[1]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = gbLayoutAndColors
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 55
Top = 381
Width = 588
Anchors = [akTop, akLeft, akRight]
AutoSize = True
Caption = 'Font'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.HorizontalSpacing = 3
ClientHeight = 35
ClientWidth = 584
TabOrder = 1
object edFontName: TEdit
AnchorSideLeft.Control = gbFont
AnchorSideTop.Control = gbFont
AnchorSideRight.Control = sedFont
Left = 6
Height = 23
Top = 6
Width = 411
Anchors = [akTop, akLeft, akRight]
Enabled = False
ReadOnly = True
TabOrder = 0
end
object sedFont: TSpinEdit
AnchorSideTop.Control = edFontName
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btFont
Left = 420
Height = 23
Top = 6
Width = 120
Anchors = [akTop, akRight]
OnChange = sedFontChange
TabOrder = 1
Value = 12
end
object btFont: TButton
AnchorSideTop.Control = edFontName
AnchorSideRight.Control = gbFont
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edFontName
AnchorSideBottom.Side = asrBottom
Left = 543
Height = 23
Top = 6
Width = 35
Anchors = [akTop, akRight, akBottom]
AutoSize = True
Caption = '...'
OnClick = btFontClick
TabOrder = 2
end
end
object optColorDialog: TColorDialog[2]
Color = clBlack
CustomColors.Strings = (
'ColorA=000000'
@ -718,4 +781,11 @@ inherited frmOptionsTreeViewMenuColor: TfrmOptionsTreeViewMenuColor
left = 488
top = 288
end
object dlgFnt: TFontDialog[3]
MinFontSize = 0
MaxFontSize = 0
Options = [fdNoStyleSel]
left = 416
top = 344
end
end

View file

@ -26,5 +26,7 @@
{"hash":258370346,"name":"tfrmoptionstreeviewmenucolor.lblunselectableundercursor.caption","sourcebytes":[85,110,115,101,108,101,99,116,97,98,108,101,32,117,110,100,101,114,32,99,117,114,115,111,114,58],"value":"Unselectable under cursor:"},
{"hash":1054,"name":"tfrmoptionstreeviewmenucolor.btnunselectableundercursor.caption","sourcebytes":[62,62],"value":">>"},
{"hash":251513754,"name":"tfrmoptionstreeviewmenucolor.lblpreview.caption","sourcebytes":[84,114,101,101,32,86,105,101,119,32,77,101,110,117,32,80,114,101,118,105,101,119,58],"value":"Tree View Menu Preview:"},
{"hash":108342734,"name":"tfrmoptionstreeviewmenucolor.treeviewmenusample.hint","sourcebytes":[67,104,97,110,103,101,32,99,111,108,111,114,32,111,110,32,108,101,102,116,32,97,110,100,32,121,111,117,39,108,108,32,115,101,101,32,104,101,114,101,32,97,32,112,114,101,118,105,101,119,32,111,102,32,119,104,97,116,32,121,111,117,114,32,84,114,101,101,32,86,105,101,119,32,77,101,110,117,115,32,119,105,108,108,32,108,111,111,107,32,108,105,107,101,115,32,119,105,116,104,32,116,104,105,115,32,115,97,109,112,108,101,46],"value":"Change color on left and you'll see here a preview of what your Tree View Menus will look likes with this sample."}
{"hash":108342734,"name":"tfrmoptionstreeviewmenucolor.treeviewmenusample.hint","sourcebytes":[67,104,97,110,103,101,32,99,111,108,111,114,32,111,110,32,108,101,102,116,32,97,110,100,32,121,111,117,39,108,108,32,115,101,101,32,104,101,114,101,32,97,32,112,114,101,118,105,101,119,32,111,102,32,119,104,97,116,32,121,111,117,114,32,84,114,101,101,32,86,105,101,119,32,77,101,110,117,115,32,119,105,108,108,32,108,111,111,107,32,108,105,107,101,115,32,119,105,116,104,32,116,104,105,115,32,115,97,109,112,108,101,46],"value":"Change color on left and you'll see here a preview of what your Tree View Menus will look likes with this sample."},
{"hash":317012,"name":"tfrmoptionstreeviewmenucolor.gbfont.caption","sourcebytes":[70,111,110,116],"value":"Font"},
{"hash":12558,"name":"tfrmoptionstreeviewmenucolor.btfont.caption","sourcebytes":[46,46,46],"value":"..."}
]}

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
Configuration of Tree View Menu Color and Layout.
Copyright (C) 2016 Alexander Koblov (alexx2000@mail.ru)
Copyright (C) 2016-2020 Alexander Koblov (alexx2000@mail.ru)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,9 +15,8 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit fOptionsTreeViewMenuColor;
@ -29,13 +28,19 @@ interface
uses
//Lazarus, Free-Pascal, etc.
SysUtils, Classes, Controls, Forms, StdCtrls, Buttons, ExtCtrls, Menus,
Dialogs, ComCtrls, ColorBox,
Dialogs, ComCtrls, ColorBox, Spin,
//DC
fOptionsFrame, fTreeViewMenu;
uGlobs, fOptionsFrame, fTreeViewMenu, Types;
type
{ TfrmOptionsTreeViewMenuColor }
TfrmOptionsTreeViewMenuColor = class(TOptionsEditor)
btFont: TButton;
dlgFnt: TFontDialog;
edFontName: TEdit;
sedFont: TSpinEdit;
gbFont: TGroupBox;
gbLayoutAndColors: TGroupBox;
cbkUsageKeyboardShortcut: TCheckBox;
lblBackgroundColor: TLabel;
@ -76,8 +81,15 @@ type
btnUnselectableUnderCursor: TButton;
lblPreview: TLabel;
TreeViewMenuSample: TTreeView;
optColorDialog: TColorDialog; procedure btnChooseColorClick(Sender: TObject);
optColorDialog: TColorDialog;
procedure btFontClick(Sender: TObject);
procedure btnChooseColorClick(Sender: TObject);
procedure RefreshColorOfOurSampleClick(Sender: TObject);
procedure sedFontChange(Sender: TObject);
procedure TreeViewMenuSampleMouseWheelDown(Sender: TObject;
Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure TreeViewMenuSampleMouseWheelUp(Sender: TObject;
Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
protected
procedure Init; override;
procedure Load; override;
@ -85,7 +97,9 @@ type
private
{ Private declarations }
TreeViewMenuGenericRoutineAndVarHolder: TTreeViewMenuGenericRoutineAndVarHolder;
TempoFont: TDCFontOptions;
ColorBoxPointer: array[1..12] of TColorBox;
procedure ApplyTempoFontToVisual;
public
{ Public declarations }
class function GetIconIndex: integer; override;
@ -102,7 +116,7 @@ uses
Graphics, LCLType, LCLProc, LCLIntf,
//DC
uGlobs, uLng, uDCUtils, fmain, DCOSUtils;
uLng, uDCUtils, fmain, DCOSUtils;
{ TfrmOptionsTreeViewMenuColor.Init }
procedure TfrmOptionsTreeViewMenuColor.Init;
@ -200,6 +214,8 @@ begin
SetColorInColorBox(cbSecondaryTextUnderCursor, gTVMSecondaryTextUnderCursor);
SetColorInColorBox(cbFoundTextUnderCursor, gTVMFoundTextUnderCursor);
SetColorInColorBox(cbUnselectableUnderCursor, gTVMUnselectableUnderCursor);
TempoFont := gFonts[dcfTreeViewMenu];
ApplyTempoFontToVisual;
end;
{ TfrmOptionsTreeViewMenuColor.Save }
@ -219,6 +235,7 @@ begin
gTVMSecondaryTextUnderCursor := cbSecondaryTextUnderCursor.Selected;
gTVMFoundTextUnderCursor := cbFoundTextUnderCursor.Selected;
gTVMUnselectableUnderCursor := cbUnselectableUnderCursor.Selected;
gFonts[dcfTreeViewMenu] := TempoFont;
end;
{ TfrmOptionsTreeViewMenuColor.GetIconIndex }
@ -273,6 +290,61 @@ begin
end;
end;
{ TfrmOptionsTreeViewMenuColor.ApplyTempoFontToVisual }
procedure TfrmOptionsTreeViewMenuColor.ApplyTempoFontToVisual;
begin
FontOptionsToFont(TempoFont, edFontName.Font);
FontOptionsToFont(TempoFont, TreeViewMenuSample.Font);
FontOptionsToFont(TempoFont, sedFont.Font);
FontOptionsToFont(TempoFont, btFont.Font);
edFontName.Text := TempoFont.Name;
if sedFont.Value <> TempoFont.Size then
sedFont.Value := TempoFont.Size;
end;
{ TfrmOptionsTreeViewMenuColor.sedFontChange }
procedure TfrmOptionsTreeViewMenuColor.sedFontChange(Sender: TObject);
begin
if TempoFont.Size <> TSpinEdit(Sender).Value then
begin
TempoFont.Size := TSpinEdit(Sender).Value;
ApplyTempoFontToVisual;
end;
end;
{ TfrmOptionsTreeViewMenuColor.btFontClick }
procedure TfrmOptionsTreeViewMenuColor.btFontClick(Sender: TObject);
begin
FontOptionsToFont(TempoFont, dlgFnt.Font);
if dlgFnt.Execute then
begin
FontToFontOptions(dlgFnt.Font, TempoFont);
ApplyTempoFontToVisual;
end;
end;
{ TfrmOptionsTreeViewMenuColor.TreeViewMenuSampleMouseWheelDown }
procedure TfrmOptionsTreeViewMenuColor.TreeViewMenuSampleMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
if (Shift = [ssCtrl]) and (TempoFont.Size > TempoFont.MinValue) then
begin
dec(TempoFont.Size);
ApplyTempoFontToVisual;
Handled := True;
end;
end;
{ TfrmOptionsTreeViewMenuColor.TreeViewMenuSampleMouseWheelUp }
procedure TfrmOptionsTreeViewMenuColor.TreeViewMenuSampleMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
if (Shift = [ssCtrl]) and (TempoFont.Size < TempoFont.MaxValue) then
begin
inc(TempoFont.Size);
ApplyTempoFontToVisual;
Handled := True;
end;
end;
end.