mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 13:20:18 +02:00
CharacterMap: Provide config file.
This commit is contained in:
parent
0a0cd01f15
commit
0a9e061e05
@ -2636,8 +2636,7 @@ object CharacterMapForm: TCharacterMapForm
|
|||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnKeyDown = FormKeyDown
|
OnKeyDown = FormKeyDown
|
||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
LCLVersion = '3.99.0.0'
|
||||||
LCLVersion = '2.3.0.0'
|
|
||||||
object ButtonPanel: TButtonPanel
|
object ButtonPanel: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 26
|
Height = 26
|
||||||
@ -2648,7 +2647,6 @@ object CharacterMapForm: TCharacterMapForm
|
|||||||
OKButton.Enabled = False
|
OKButton.Enabled = False
|
||||||
HelpButton.Name = 'HelpButton'
|
HelpButton.Name = 'HelpButton'
|
||||||
HelpButton.DefaultCaption = True
|
HelpButton.DefaultCaption = True
|
||||||
HelpButton.OnClick = HelpButtonClick
|
|
||||||
CloseButton.Name = 'CloseButton'
|
CloseButton.Name = 'CloseButton'
|
||||||
CloseButton.DefaultCaption = True
|
CloseButton.DefaultCaption = True
|
||||||
CancelButton.Name = 'CancelButton'
|
CancelButton.Name = 'CancelButton'
|
||||||
@ -2668,10 +2666,10 @@ object CharacterMapForm: TCharacterMapForm
|
|||||||
Height = 433
|
Height = 433
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 578
|
Width = 578
|
||||||
ActivePage = pgAnsi
|
ActivePage = pgUnicode
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
TabIndex = 1
|
TabIndex = 0
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object pgUnicode: TTabSheet
|
object pgUnicode: TTabSheet
|
||||||
Caption = 'Unicode'
|
Caption = 'Unicode'
|
||||||
|
@ -46,6 +46,7 @@ uses
|
|||||||
GraphType, LazUTF8, LConvEncoding;
|
GraphType, LazUTF8, LConvEncoding;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TCharMapPage = (cmpUnicode, cmpAnsi);
|
||||||
TOnInsertCharacterEvent = procedure (const C: TUTF8Char) of object;
|
TOnInsertCharacterEvent = procedure (const C: TUTF8Char) of object;
|
||||||
|
|
||||||
{ TCharacterMapForm }
|
{ TCharacterMapForm }
|
||||||
@ -73,7 +74,6 @@ type
|
|||||||
procedure cbCodePageSelect(Sender: TObject);
|
procedure cbCodePageSelect(Sender: TObject);
|
||||||
procedure cbUniRangeSelect(Sender: TObject);
|
procedure cbUniRangeSelect(Sender: TObject);
|
||||||
procedure FormKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
procedure FormKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||||
procedure HelpButtonClick(Sender: TObject);
|
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure seAnsiSizeChange(Sender: TObject);
|
procedure seAnsiSizeChange(Sender: TObject);
|
||||||
@ -99,11 +99,23 @@ type
|
|||||||
procedure FillAnsiGrid;
|
procedure FillAnsiGrid;
|
||||||
procedure FillUnicodeGrid;
|
procedure FillUnicodeGrid;
|
||||||
procedure FillUniRangeList(ASorted: Boolean);
|
procedure FillUniRangeList(ASorted: Boolean);
|
||||||
|
function GetActivePage: TCharMapPage;
|
||||||
|
function GetAlphaSort: Boolean;
|
||||||
|
function GetDropDownCount: Integer;
|
||||||
|
function GetFontSize: Integer;
|
||||||
function UnicodeBlockIndexByName(AName: String): Integer;
|
function UnicodeBlockIndexByName(AName: String): Integer;
|
||||||
function UnicodeBlockSelected: Boolean;
|
function UnicodeBlockSelected: Boolean;
|
||||||
procedure SelectSystemCP;
|
procedure SelectSystemCP;
|
||||||
|
procedure SetActivePage(AValue: TCharMapPage);
|
||||||
|
procedure SetAlphaSort(AValue: Boolean);
|
||||||
|
procedure SetDropDownCount(AValue: Integer);
|
||||||
|
procedure SetFontSize(AValue: Integer);
|
||||||
procedure SetOnShowHelp(AValue: TNotifyEvent);
|
procedure SetOnShowHelp(AValue: TNotifyEvent);
|
||||||
public
|
public
|
||||||
|
property ActivePage: TCharMapPage read GetActivePage write SetActivePage;
|
||||||
|
property AlphaSort: Boolean read GetAlphaSort write SetAlphaSort;
|
||||||
|
property DropDownCount: Integer read GetDropDownCount write SetDropDownCount;
|
||||||
|
property FontSize: Integer read GetFontSize write SetFontSize;
|
||||||
property OnInsertCharacter: TOnInsertCharacterEvent
|
property OnInsertCharacter: TOnInsertCharacterEvent
|
||||||
read FOnInsertCharacter write FOnInsertCharacter;
|
read FOnInsertCharacter write FOnInsertCharacter;
|
||||||
property OnShowHelp: TNotifyEvent
|
property OnShowHelp: TNotifyEvent
|
||||||
@ -210,11 +222,6 @@ begin
|
|||||||
cbCodePage.ItemIndex := 0;
|
cbCodePage.ItemIndex := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapForm.HelpButtonClick(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//LazarusHelp.ShowHelpForIDEControl(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function RoundUp(Value, Divi:integer):integer;
|
function RoundUp(Value, Divi:integer):integer;
|
||||||
begin
|
begin
|
||||||
if Value mod Divi = 0 then
|
if Value mod Divi = 0 then
|
||||||
@ -247,13 +254,6 @@ procedure TCharacterMapForm.FormShow(Sender: TObject);
|
|||||||
var
|
var
|
||||||
savedFontSize: Integer;
|
savedFontSize: Integer;
|
||||||
begin
|
begin
|
||||||
(* wp
|
|
||||||
AnsiGrid.Font.Name := EditorOpts.EditorFont;
|
|
||||||
UnicodeGrid.Font.Name := EditorOpts.EditorFont;
|
|
||||||
AnsiGrid.Font.Size := seAnsiSize.Value;
|
|
||||||
UnicodeGrid.Font.Size := seUniSize.Value;
|
|
||||||
*)
|
|
||||||
|
|
||||||
// Auto-adjust the width of the AnsiGrid's fixed column. Note that
|
// Auto-adjust the width of the AnsiGrid's fixed column. Note that
|
||||||
// the font defined in PrepareCanvas is ignored by AutoSizeColumn.
|
// the font defined in PrepareCanvas is ignored by AutoSizeColumn.
|
||||||
savedfontSize := AnsiGrid.Font.Size;
|
savedfontSize := AnsiGrid.Font.Size;
|
||||||
@ -266,9 +266,6 @@ begin
|
|||||||
FUnicodeBlockIndex:=NOT_SELECTED;
|
FUnicodeBlockIndex:=NOT_SELECTED;
|
||||||
FillUniRangeList(SortUniRangeListButton.Down);
|
FillUniRangeList(SortUniRangeListButton.Down);
|
||||||
FillUnicodeGrid;
|
FillUnicodeGrid;
|
||||||
// wp
|
|
||||||
//cbCodePage.DropDownCount := Math.max(EnvironmentOptions.DropDownCount, 25);
|
|
||||||
//cbUniRange.DropDownCount := Math.max(EnvironmentOptions.DropDownCount, 25);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapForm.seAnsiSizeChange(Sender: TObject);
|
procedure TCharacterMapForm.seAnsiSizeChange(Sender: TObject);
|
||||||
@ -455,6 +452,51 @@ begin
|
|||||||
cbUniRange.Text:=UnicodeBlocks[FUnicodeBlockIndex].PG;
|
cbUniRange.Text:=UnicodeBlocks[FUnicodeBlockIndex].PG;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCharacterMapForm.GetActivePage: TCharMapPage;
|
||||||
|
begin
|
||||||
|
Result := TCharMapPage(PageControl1.ActivePageIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCharacterMapForm.GetAlphaSort: Boolean;
|
||||||
|
begin
|
||||||
|
Result := SortUniRangeListButton.Down;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCharacterMapForm.GetDropDownCount: Integer;
|
||||||
|
begin
|
||||||
|
Result := CbUniRange.DropDownCount;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCharacterMapForm.GetFontSize: Integer;
|
||||||
|
begin
|
||||||
|
Result := seUniSize.Value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapForm.SetActivePage(AValue: TCharMapPage);
|
||||||
|
begin
|
||||||
|
PageControl1.ActivePageIndex := ord(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapForm.SetAlphaSort(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
SortUniRangeListButton.Down := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapForm.SetDropDownCount(AValue: Integer);
|
||||||
|
begin
|
||||||
|
CbUniRange.DropDownCount := AValue;
|
||||||
|
CbCodePage.DropDownCount := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapForm.SetFontSize(AValue: Integer);
|
||||||
|
begin
|
||||||
|
seUniSize.Value := AValue;
|
||||||
|
seAnsiSize.Value := AValue;
|
||||||
|
|
||||||
|
UnicodeGrid.Font.Size := AValue;
|
||||||
|
AnsiGrid.Font.Size := AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCharacterMapForm.UnicodeBlockIndexByName(AName: String): Integer;
|
function TCharacterMapForm.UnicodeBlockIndexByName(AName: String): Integer;
|
||||||
var
|
var
|
||||||
BlockIdx: Integer;
|
BlockIdx: Integer;
|
||||||
|
@ -5,8 +5,8 @@ unit charactermap_reg;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLType, Forms, SynEdit,
|
Classes, SysUtils, LCLIntf, LCLType, Forms, SynEdit, Laz2_XMLCfg,
|
||||||
MenuIntf, IDECommands, IDEHelpIntf, SrcEditorIntf,
|
MenuIntf, IDECommands, IDEHelpIntf, SrcEditorIntf, EnvironmentOpts,
|
||||||
CharacterMapFrm;
|
CharacterMapFrm;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -15,12 +15,17 @@ type
|
|||||||
|
|
||||||
TCharacterMapDialog = class(TCharacterMapForm)
|
TCharacterMapDialog = class(TCharacterMapForm)
|
||||||
private
|
private
|
||||||
|
FXMLCfg: TXMLConfig;
|
||||||
procedure HelpButtonClick(Sender: TObject);
|
procedure HelpButtonClick(Sender: TObject);
|
||||||
procedure InsertCharacter(const C: TUTF8Char);
|
procedure InsertCharacter(const C: TUTF8Char);
|
||||||
|
procedure CloseQueryHandler(Sender: TObject; var CanClose: Boolean);
|
||||||
|
procedure LoadConfig;
|
||||||
|
procedure SaveConfig;
|
||||||
protected
|
protected
|
||||||
procedure Activate; override;
|
procedure Activate; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
@ -35,15 +40,27 @@ procedure ShowCharacterMapProc({%H-}ASender: TObject);
|
|||||||
begin
|
begin
|
||||||
if CharacterMapDialog = nil then
|
if CharacterMapDialog = nil then
|
||||||
Application.CreateForm(TCharacterMapDialog, CharacterMapDialog);
|
Application.CreateForm(TCharacterMapDialog, CharacterMapDialog);
|
||||||
|
CharacterMapDialog.LoadConfig;
|
||||||
CharacterMapDialog.Show;
|
CharacterMapDialog.Show;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCharacterMapDialog }
|
{ TCharacterMapDialog }
|
||||||
|
|
||||||
|
const
|
||||||
|
Path = 'CharacterMap/';
|
||||||
|
|
||||||
constructor TCharacterMapDialog.Create(AOwner: TComponent);
|
constructor TCharacterMapDialog.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
OnInsertCharacter := @InsertCharacter;
|
OnInsertCharacter := @InsertCharacter;
|
||||||
|
OnCloseQuery := @CloseQueryHandler;
|
||||||
|
FXMLCfg := TXMLConfig.Create(ExtractFilePath(EnvironmentOptions.FileName) + 'charactermap.xml');
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TCharacterMapDialog.Destroy;
|
||||||
|
begin
|
||||||
|
FXMLCfg.Free;
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapDialog.Activate;
|
procedure TCharacterMapDialog.Activate;
|
||||||
@ -51,6 +68,13 @@ begin
|
|||||||
OnShowHelp := @HelpButtonClick;
|
OnShowHelp := @HelpButtonClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapDialog.CloseQueryHandler(Sender: TObject;
|
||||||
|
var CanClose: Boolean);
|
||||||
|
begin
|
||||||
|
if CanClose then
|
||||||
|
SaveConfig;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCharacterMapDialog.HelpButtonClick(Sender: TObject);
|
procedure TCharacterMapDialog.HelpButtonClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
LazarusHelp.ShowHelpForIDEControl(Self);
|
LazarusHelp.ShowHelpForIDEControl(Self);
|
||||||
@ -69,6 +93,45 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapDialog.LoadConfig;
|
||||||
|
var
|
||||||
|
L, T, W, H: Integer;
|
||||||
|
R: TRect;
|
||||||
|
begin
|
||||||
|
L := FXMLCfg.GetValue(Path + 'Position/Left', Left);
|
||||||
|
T := FXMLCfg.GetValue(Path + 'Position/Top', Top);
|
||||||
|
W := FXMLCfg.GetValue(Path + 'Position/Width', Width);
|
||||||
|
H := FXMLCfg.GetValue(Path + 'Position/Height', Height);
|
||||||
|
R := Screen.WorkAreaRect;
|
||||||
|
if W > R.Width then W := R.Width;
|
||||||
|
if H > R.Height then H := R.Height;
|
||||||
|
if L < R.Left then L := R.Left;
|
||||||
|
if T < R.Top then T := R.Top;
|
||||||
|
if L + W > R.Right then L := R.Right - W - GetSystemMetrics(SM_CXSIZEFRAME);
|
||||||
|
if T + H > R.Bottom then T := R.Bottom - H - GetSystemMetrics(SM_CYCAPTION) - GetSystemMetrics(SM_CYSIZEFRAME);
|
||||||
|
SetBounds(L, T, W, H);
|
||||||
|
WindowState := TWindowState(FXMLCfg.GetValue(Path + 'Position/WindowState', 0));
|
||||||
|
FontSize := FXMLCfg.GetValue(Path + 'FontSize', 12);
|
||||||
|
ActivePage := TCharMapPage(FXMLCfg.GetValue(Path + 'ActivePage', Integer(ActivePage)));
|
||||||
|
AlphaSort := FXMLCfg.GetValue(Path + 'SortedUnicodeRangeList', AlphaSort);
|
||||||
|
|
||||||
|
DropDownCount := EnvironmentOptions.DropDownCount;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCharacterMapDialog.SaveConfig;
|
||||||
|
begin
|
||||||
|
FXMLCfg.SetValue(Path + 'Position/Top', RestoredTop);
|
||||||
|
FXMLCfg.SetValue(Path + 'Position/Left', RestoredLeft);
|
||||||
|
FXMLCfg.SetValue(Path + 'Position/Width', RestoredWidth);
|
||||||
|
FXMLCfg.SetValue(Path + 'Position/Height', RestoredHeight);
|
||||||
|
FXMLCfg.SetValue(Path + 'Position/WindowState', Integer(WindowState));
|
||||||
|
FXMLCfg.SetValue(Path + 'FontSize', FontSize);
|
||||||
|
FXMLCfg.SetValue(Path + 'ActivePage', ord(ActivePage));
|
||||||
|
FXMLCfg.SetValue(Path + 'SortedUnicodeRangeList', AlphaSort);
|
||||||
|
|
||||||
|
EnvironmentOptions.DropDownCount := DropDownCount;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Registration }
|
{ Registration }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user