easycustomdlg.pas.svn-base
来自「支持自定义语法高亮显示的编辑器控件」· SVN-BASE 代码 · 共 616 行 · 第 1/2 页
SVN-BASE
616 行
{*****************************************************}
{ }
{ Customize dialog }
{ }
{ Copyright (c) 1992-2002 Altium Limited }
{ All rights reserved. }
{ }
{ http://www.dream-com.com }
{ contact@dream-com.com }
{ }
{*****************************************************}
unit EasyCustomDlg;
interface
{$I Easy.inc}
uses
{$IFNDEF EASY_CLX}
Windows, Messages, Graphics, Controls, Forms, Dialogs, ComCtrls, ExtCtrls, StdCtrls, Buttons, Menus,
{$ELSE}
QForms, QControls, QGraphics, QStdCtrls, QExtCtrls, QComCtrls, QDialogs, QButtons,
{$ENDIF}
SysUtils, Classes,
EasyBox, EasyClasses, EasyParser, EasyEditor, EasyEditSource, EasyUtils, EasyEditorSettings, EasyControls;
type
TCustomizeForm = class(TForm)
TreeViewOptions: TTreeView;
ColorDialog1: TColorDialog;
HolderPanel: TPanel;
PageControl: TPageControl;
EditorSheet: TTabSheet;
DisplaySheet: TTabSheet;
DispPanel: TPanel;
gbMarginAndGutter: TGroupBox;
lbRightMargin: TLabel;
lbGutterWidth: TLabel;
chbVisibleRightMargin: TCheckBox;
chbVisibleGutter: TCheckBox;
ColorsSheet: TTabSheet;
ColorsPanel: TPanel;
plButtons: TPanel;
btOK: TButton;
btCancel: TButton;
btHelp: TButton;
EdPanel: TPanel;
gbEditorOptions: TGroupBox;
cbAutoIndentMode: TCheckBox;
cbInsertMode: TCheckBox;
cbUseTabCharacter: TCheckBox;
cbSmartTab: TCheckBox;
cbOptimalFill: TCheckBox;
cbBackspaceUnindents: TCheckBox;
cbCursorThroughTabs: TCheckBox;
cbGroupUndo: TCheckBox;
cbCursorBeyondEOF: TCheckBox;
cbKeepTrailingBlanks: TCheckBox;
cbPersistentBlocks: TCheckBox;
cbOverwriteBlocks: TCheckBox;
cbDoubleClickLine: TCheckBox;
cbFindTextAtCursor: TCheckBox;
cbForceCutAndCopyEnabled: TCheckBox;
cbUseSyntaxHighlight: TCheckBox;
cbEnableSelection: TCheckBox;
cbEnableDragging: TCheckBox;
cbCursorBeyondEol: TCheckBox;
cbEnableSearchHighlight: TCheckBox;
lbKeyMapping: TLabel;
cbEditorSpeedSetting: TComboBox;
lbBlockIndent: TLabel;
lbTabStops: TLabel;
gbDispOptions: TGroupBox;
lbEditorFont: TLabel;
lbSize: TLabel;
cbEditorFont: TComboBox;
cbSize: TComboBox;
pnAaBbYyZz: TPanel;
lbSample: TLabel;
GroupBox1: TGroupBox;
cbColorSpeedSetting: TComboBox;
EasycbForegroundColor: TEasyColorBox;
ForeColorBtn: TBitBtn;
gbTextAttributes: TGroupBox;
chbBold: TCheckBox;
chbItalic: TCheckBox;
chbUnderline: TCheckBox;
EasycbBackgroundColor: TEasyColorBox;
BackColorBtn: TBitBtn;
lsbElements: TListBox;
gbUseDefault: TGroupBox;
chbForeground: TCheckBox;
chbBackground: TCheckBox;
btOpen: TButton;
btSave: TButton;
cbRightMargin: TEasyHistoryEditor;
cbGutterWidth: TEasyHistoryEditor;
cbTabStops: TEasyHistoryEditor;
cbBlockIndent: TEasyHistoryEditor;
gbLineNumbersAndScrolls: TGroupBox;
cbPaintOnGutter: TCheckBox;
cbPaintBeyondEof: TCheckBox;
cbTripleClickLine: TCheckBox;
cbUndoAfterSave: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure TreeViewOptionsChange(Sender: TObject; Node: TTreeNode);
procedure lsbElementsClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure cbColorSpeedSettingChange(Sender: TObject);
procedure EasycbForegroundColorChange(Sender: TObject);
procedure EasycbBackgroundColorChange(Sender: TObject);
procedure chbBoldClick(Sender: TObject);
procedure chbItalicClick(Sender: TObject);
procedure chbUnderlineClick(Sender: TObject);
procedure chbForegroundClick(Sender: TObject);
procedure chbBackgroundClick(Sender: TObject);
procedure ForeColorBtnClick(Sender: TObject);
procedure BackColorBtnClick(Sender: TObject);
procedure cbEditorFontChange(Sender: TObject);
procedure cbSizeChange(Sender: TObject);
private
FStyles : TEasyParserStyles;
FDialogSettings : TEasyDialogSettings;
procedure ShowPanel(Panel : TPanel);
procedure HidePanel(Panel : TPanel);
{ Private declarations }
public
procedure ShowOptionsPanel;
procedure SetBackAndForeStyles(Value : integer);
procedure SaveSettings;
procedure LoadSettings;
{ Public declarations }
end;
var
CustomizeForm : TCustomizeForm;
procedure ShowEditorSettings;
implementation
{$IFNDEF EASY_CLX}
{$R *.DFM}
{$ELSE}
{$R *.xfm}
{$ENDIF}
{---------------------------------------------------}
procedure ShowEditorSettings;
begin
with TCustomizeForm.Create(Application) do
try
if ShowModal = mrOk then
SaveSettings;
finally
Free;
end;
end;
{---------------------------------------------------}
procedure TCustomizeForm.FormCreate(Sender: TObject);
var
i : integer;
F : TFont;
s : string;
begin
{$IFDEF _DELPHI4}
TreeViewOptions.Color := clBtnFace;
{$ENDIF}
FStyles := TEasyParserStyles.Create(TEasyParserStyle);
s := AddSlash(GetTempDir) + 'dialogs.ini';
cbBlockIndent.FileName := s;
cbTabStops.FileName := s;
cbRightMargin.FileName := s;
cbGutterWidth.FileName := s;
cbBlockIndent.LoadHistory;
cbTabStops.LoadHistory;
cbRightMargin.LoadHistory;
cbGutterWidth.LoadHistory;
LoadSettings;
lsbElements.Items.Clear;
for i := 0 to FStyles.Count - 1 do
with FStyles[i] do
if Description <> '' then
lsbElements.Items.Add(Description)
else
lsbElements.Items.Add(Name);
lsbElements.ItemIndex := 0;
SetBackAndForeStyles(0);
cbEditorFontChange(Self);
Height := Height - (PageControl.Height - EditorSheet.Height);
ShowPanel(EdPanel);
TreeViewOptions.FullExpand;
TreeViewOptions.Selected := TreeViewOptions.Items[1];
F := TFont.Create;
try
with Screen.Fonts do
for i := 0 to Count - 1 do
begin
F.Name := Strings[i];
if IsMonoFont(F) then
cbEditorFont.Items.Add(F.Name);
end;
cbEditorFont.Text := EasyEditSettings.Font.Name;
finally
F.Free;
end;
FDialogSettings := TEasyDialogSettings.Create(self);
FDialogSettings.Key := 'CustomizeDlg';
FDialogSettings.LoadSettings;
end;
{---------------------------------------------------}
procedure TCustomizeForm.ShowPanel(Panel : TPanel);
var
i : integer;
begin
with Panel do
for i := ControlCount - 1 downto 0 do
if Controls[i] is TPanel then
Controls[i].Hide;
Panel.Parent := HolderPanel;
Panel.Visible := true;
Panel.BringToFront;
end;
{---------------------------------------------------}
procedure TCustomizeForm.HidePanel(Panel : TPanel);
begin
Panel.Visible := false;
end;
{---------------------------------------------------}
procedure TCustomizeForm.ShowOptionsPanel;
begin
with TreeViewOptions do
if Selected <> nil then
case Selected.AbsoluteIndex of
1 :
begin
ShowPanel(EdPanel);
HidePanel(DispPanel);
HidePanel(ColorsPanel);
end;
2 :
begin
ShowPanel(DispPanel);
HidePanel(EdPanel);
HidePanel(ColorsPanel);
end;
3 :
begin
ShowPanel(ColorsPanel);
HidePanel(EdPanel);
HidePanel(DispPanel);
end;
end;
end;
{---------------------------------------------------}
procedure TCustomizeForm.TreeViewOptionsChange(Sender: TObject; Node: TTreeNode);
begin
ShowOptionsPanel;
end;
{---------------------------------------------------}
procedure TCustomizeForm.SetBackAndForeStyles(Value : integer);
begin
if Value >= 0 then
with FStyles.Items[Value] do
begin
EasycbForegroundColor.SelectedColor := FontColor;
EasycbBackgroundColor.SelectedColor := Color;
chbBold.Checked := fsBold in FontStyle;
chbItalic.Checked := fsItalic in FontStyle;
chbUnderline.Checked := fsUnderline in FontStyle;
end;
end;
{-------------------------------------------------}
procedure TCustomizeForm.chbItalicClick(Sender: TObject);
begin
with FStyles.Items[lsbElements.ItemIndex] do
if chbItalic.Checked then
FontStyle := FontStyle + [fsItalic]
else
FontStyle := FontStyle - [fsItalic];
end;
{-------------------------------------------------}
procedure TCustomizeForm.chbUnderlineClick(Sender: TObject);
begin
with FStyles.Items[lsbElements.ItemIndex] do
if chbUnderline.Checked then
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?