From 8d65569334e2ec33692bccaf46d9bed0ea3ebc83 Mon Sep 17 00:00:00 2001 From: Olly Date: Mon, 5 Jun 2023 02:19:37 +0100 Subject: [PATCH] Notes form theming --- Source/components/simba.component_synedit.pas | 27 +++++++++++- Source/editor/simba.editor.pas | 41 +++++-------------- Source/editor/simba.editor_paramhint.pas | 11 +---- Source/forms/simba.notesform.lfm | 23 +++-------- Source/forms/simba.notesform.pas | 30 ++++++++++---- Source/forms/simba.outputform.pas | 23 ++--------- Source/simba.settings.pas | 2 +- 7 files changed, 72 insertions(+), 85 deletions(-) diff --git a/Source/components/simba.component_synedit.pas b/Source/components/simba.component_synedit.pas index 33572f1b3..86f3d3316 100644 --- a/Source/components/simba.component_synedit.pas +++ b/Source/components/simba.component_synedit.pas @@ -5,7 +5,7 @@ interface uses - Classes, SysUtils, Controls, Forms, StdCtrls, + Classes, SysUtils, Controls, Forms, StdCtrls, Graphics, SynEdit, SynEditTypes, SynEditFoldedView, SynEditTextBuffer, SynEditMarkupSelection, LazSynEditText, ATScrollBar; @@ -23,8 +23,13 @@ TSimbaSynEdit = class(TSynEdit) procedure StatusChanged(AChanges: TSynStatusChanges); override; procedure DoLineChanges(Sender: TSynEditStrings; aIndex, aCount: Integer); procedure SetParent(NewParent: TWinControl); override; + + function GetFontAntialising: Boolean; + procedure SetFontAntialising(Value: Boolean); public constructor Create(AOwner: TComponent); override; + + property FontAntialising: Boolean read GetFontAntialising write SetFontAntialising; end; implementation @@ -32,6 +37,19 @@ implementation uses simba.mufasatypes, simba.theme; +function TSimbaSynEdit.GetFontAntialising: Boolean; +begin + Result := (Font.Quality = fqCleartypeNatural); +end; + +procedure TSimbaSynEdit.SetFontAntialising(Value: Boolean); +begin + case Value of + True: Font.Quality := fqCleartypeNatural; + False: Font.Quality := fqNonAntialiased; + end; +end; + procedure TSimbaSynEdit.DoVertScrollBarChange(Sender: TObject); begin TopLine := FScrollbarVert.Position; @@ -106,12 +124,17 @@ constructor TSimbaSynEdit.Create(AOwner: TComponent); TextView.AddChangeHandler(senrLineCount, @DoLineChanges); ScrollBars := ssNone; + BorderStyle := bsNone; TSynEditMarkupSelection(MarkupByClass[TSynEditMarkupSelection]).MarkupInfoSeletion.Background := SimbaTheme.ColorActive; - Color := SimbaTheme.ColorBackground; + Font.Color := SimbaTheme.ColorFont; + Font.Size := SynDefaultFontSize; + Font.Name := SynDefaultFontName; + + FontAntialising := True; end; end. diff --git a/Source/editor/simba.editor.pas b/Source/editor/simba.editor.pas index 96b1af8f8..81473c198 100644 --- a/Source/editor/simba.editor.pas +++ b/Source/editor/simba.editor.pas @@ -11,11 +11,8 @@ interface uses Classes, SysUtils, Graphics, Controls, ComCtrls, LCLType, - SynEdit, SynEditTypes, SynGutterLineOverview, SynEditMouseCmds, SynEditMiscClasses, - SynEditKeyCmds, SynEditHighlighter, SynHighlighterPas_Simba, SynEditMarkupHighAll, - LazSynEditMouseCmdsTypes, LazMethodList, - simba.mufasatypes, simba.settings, simba.editor_autocomplete, simba.editor_paramhint, - simba.editor_attributes, simba.editor_modifiedlinegutter, simba.component_synedit; + SynEdit, SynEditTypes, SynGutterLineOverview, SynEditMouseCmds, SynEditMiscClasses, SynEditKeyCmds, SynEditHighlighter, + simba.mufasatypes, simba.settings, simba.editor_autocomplete, simba.editor_paramhint, simba.editor_attributes, simba.editor_modifiedlinegutter, simba.component_synedit; type TSimbaEditor = class(TSimbaSynEdit) @@ -26,7 +23,6 @@ TSimbaEditor = class(TSimbaSynEdit) FAttributes: TSimbaEditor_Attributes; FModifiedLinesGutter: TSimbaEditorModifiedLinesGutter; - FFontChangedHandlerList: TMethodList; FFocusedLinesUpdating: Boolean; FFocusedLinesCount: Integer; @@ -42,9 +38,11 @@ TSimbaEditor = class(TSimbaSynEdit) FModifiedEvent: TNotifyEvent; procedure FontChanged(Sender: TObject); override; + procedure SimbaSettingChanged(Setting: TSimbaSetting); procedure DoSimbaSettingChanged_Colors(Setting: TSimbaSetting); + // Accept drop from TTreeView procedure DoDragDrop(Sender, Source: TObject; X, Y: Integer); procedure DoDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); @@ -87,8 +85,6 @@ TSimbaEditor = class(TSimbaSynEdit) // Repaint some extra things when saved procedure InvalidateGutter; override; - procedure RegisterFontChangedHandler(Handler: TNotifyEvent); - procedure UnRegisterFontChangedHandler(Handler: TNotifyEvent); procedure RegisterCaretMoveHandler(Handler: TNotifyEvent); procedure UnRegisterCaretMoveHandler(Handler: TNotifyEvent); @@ -102,7 +98,8 @@ TSimbaEditor = class(TSimbaSynEdit) implementation uses - SynEditPointClasses, SynGutterBase, SynEditMarkupWordGroup, + SynEditPointClasses, SynGutterBase, SynEditMarkupWordGroup, SynHighlighterPas_Simba, + LazSynEditMouseCmdsTypes, simba.fonthelpers, simba.editor_blockcompletion, simba.editor_docgenerator, simba.editor_commentblock, simba.editor_mousewheelzoom, simba.editor_multicaret, @@ -147,16 +144,6 @@ procedure TSimbaEditor.InvalidateGutter; inherited; end; -procedure TSimbaEditor.RegisterFontChangedHandler(Handler: TNotifyEvent); -begin - FFontChangedHandlerList.Add(TMethod(Handler)); -end; - -procedure TSimbaEditor.UnRegisterFontChangedHandler(Handler: TNotifyEvent); -begin - FFontChangedHandlerList.Remove(TMethod(Handler)); -end; - procedure TSimbaEditor.RegisterCaretMoveHandler(Handler: TNotifyEvent); begin GetCaretObj().AddChangeHandler(Handler); @@ -287,7 +274,10 @@ procedure TSimbaEditor.FontChanged(Sender: TObject); begin inherited FontChanged(Sender); - FFontChangedHandlerList.CallNotifyEvents(Self); + if (FAutoComplete <> nil) then + FAutoComplete.Form.Hide(); + if (FParamHint <> nil) then + FParamHint.Form.Hide(); end; procedure TSimbaEditor.SimbaSettingChanged(Setting: TSimbaSetting); @@ -321,10 +311,7 @@ procedure TSimbaEditor.SimbaSettingChanged(Setting: TSimbaSetting); 'Editor.AntiAliased': begin - if Setting.Value then - Font.Quality := fqCleartypeNatural - else - Font.Quality := fqNonAntialiased; + FontAntialising := Setting.Value; end; 'Editor.AllowCaretPastEOL': @@ -450,13 +437,9 @@ constructor TSimbaEditor.Create(AOwner: TComponent); begin inherited Create(AOwner); - BorderStyle := bsNone; - OnDragDrop := @DoDragDrop; OnDragOver := @DoDragOver; - FFontChangedHandlerList := TMethodList.Create(); - PopupMenu := GetSimbaEditorPopupMenu(); Options := Options + [eoTabIndent, eoKeepCaretX, eoDragDropEditing, eoScrollPastEof] - [eoSmartTabs]; @@ -540,8 +523,6 @@ destructor TSimbaEditor.Destroy; if (FAttributes <> nil) then FreeAndNil(FAttributes); - if (FFontChangedHandlerList <> nil) then - FreeAndNil(FFontChangedHandlerList); inherited Destroy(); end; diff --git a/Source/editor/simba.editor_paramhint.pas b/Source/editor/simba.editor_paramhint.pas index d7d73d6f4..3d771c419 100644 --- a/Source/editor/simba.editor_paramhint.pas +++ b/Source/editor/simba.editor_paramhint.pas @@ -46,7 +46,6 @@ TSimbaParamHint = class(TLazSynEditPlugin) function GetParameterIndexAtCaret: Integer; procedure DoEditorTopLineChanged(Sender: TObject; Changes: TSynStatusChanges); - procedure DoEditorFontChanged(Sender: TObject); procedure DoEditorCaretMove(Sender: TObject); procedure DoEditorCommand(Sender: TObject; AfterProcessing: Boolean; var Handled: Boolean; var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: Pointer; HandlerData: Pointer); procedure DoEditorKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); @@ -55,6 +54,8 @@ TSimbaParamHint = class(TLazSynEditPlugin) public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + + property Form: TSimbaParamHintForm read FHintForm; public class var ParamHintCommand: TSynEditorCommand; class function IsParamHintCommand(Command: TSynEditorCommand; AChar: TUTF8Char): Boolean; @@ -331,12 +332,6 @@ procedure TSimbaParamHint.DoEditorTopLineChanged(Sender: TObject; Changes: TSynS end; end; -procedure TSimbaParamHint.DoEditorFontChanged(Sender: TObject); -begin - if IsShowing then - FHintForm.Hide(); -end; - procedure TSimbaParamHint.DoEditorCaretMove(Sender: TObject); begin if IsShowing then @@ -432,7 +427,6 @@ procedure TSimbaParamHint.DoEditorAdded(Value: TCustomSynEdit); if (Value is TSimbaEditor) then with TSimbaEditor(Value) do begin - RegisterFontChangedHandler(@DoEditorFontChanged); RegisterCaretMoveHandler(@DoEditorCaretMove); RegisterBeforeKeyDownHandler(@DoEditorKeyDown); RegisterCommandHandler(@DoEditorCommand, nil, [hcfPostExec]); @@ -452,7 +446,6 @@ procedure TSimbaParamHint.DoEditorRemoving(Value: TCustomSynEdit); if (Value is TSimbaEditor) then with TSimbaEditor(Value) do begin - UnRegisterFontChangedHandler(@DoEditorFontChanged); UnRegisterCaretMoveHandler(@DoEditorCaretMove); UnRegisterBeforeKeyDownHandler(@DoEditorKeyDown); UnRegisterCommandHandler(@DoEditorCommand); diff --git a/Source/forms/simba.notesform.lfm b/Source/forms/simba.notesform.lfm index 18bec0d08..73eb77f88 100644 --- a/Source/forms/simba.notesform.lfm +++ b/Source/forms/simba.notesform.lfm @@ -1,24 +1,13 @@ object SimbaNotesForm: TSimbaNotesForm - Left = 1723 - Height = 174 - Top = 94 - Width = 517 + Left = 4478 + Height = 218 + Top = 58 + Width = 646 Caption = 'Notes' - ClientHeight = 174 - ClientWidth = 517 Color = clWindow + DesignTimePPI = 120 Font.CharSet = ANSI_CHARSET OnCreate = FormCreate OnDestroy = FormDestroy - LCLVersion = '2.2.0.4' - object Memo: TMemo - Left = 3 - Height = 168 - Top = 3 - Width = 511 - Align = alClient - BorderSpacing.Around = 3 - BorderStyle = bsNone - TabOrder = 0 - end + LCLVersion = '2.2.4.0' end diff --git a/Source/forms/simba.notesform.pas b/Source/forms/simba.notesform.pas index e635d5fb6..8b0e34036 100644 --- a/Source/forms/simba.notesform.pas +++ b/Source/forms/simba.notesform.pas @@ -10,13 +10,18 @@ interface uses - classes, sysutils, forms, controls, graphics, dialogs, stdctrls; + Classes, SysUtils, Forms, Controls, + simba.component_synedit, simba.settings; type TSimbaNotesForm = class(TForm) - Memo: TMemo; + published procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); + public + SynEdit: TSimbaSynEdit; + + constructor Create(AOwner: TComponent); override; end; var @@ -24,19 +29,30 @@ TSimbaNotesForm = class(TForm) implementation -{$R *.lfm} - uses - simba.settings; + SynEdit; + +{$R *.lfm} procedure TSimbaNotesForm.FormDestroy(Sender: TObject); begin - SimbaSettings.General.Notes.Value := Memo.Lines.Text; + SimbaSettings.General.Notes.Value := SynEdit.Text; end; procedure TSimbaNotesForm.FormCreate(Sender: TObject); begin - Memo.Lines.Text := SimbaSettings.General.Notes.Value; + SynEdit.Text := SimbaSettings.General.Notes.Value; +end; + +constructor TSimbaNotesForm.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + SynEdit := TSimbaSynEdit.Create(Self); + SynEdit.Parent := Self; + SynEdit.Align := alClient; + SynEdit.Gutter.Visible := False; + SynEdit.RightGutter.Visible := False; end; end. diff --git a/Source/forms/simba.outputform.pas b/Source/forms/simba.outputform.pas index 6c3ab6f01..36a30a245 100644 --- a/Source/forms/simba.outputform.pas +++ b/Source/forms/simba.outputform.pas @@ -40,8 +40,6 @@ TSimbaOutputBox = class(TSimbaSynEdit) procedure DoMouseLinkClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); function GetTab: TSimbaTab; - function GetAntialiasing: Boolean; - procedure SetAntialiasing(Value: Boolean); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -53,7 +51,6 @@ TSimbaOutputBox = class(TSimbaSynEdit) procedure Flush; property Tab: TSimbaTab read GetTab; - property Antialiasing: Boolean read GetAntialiasing write SetAntialiasing; end; TSimbaOutputTab = class(TSimbaTab) @@ -150,19 +147,6 @@ constructor TSimbaOutputTab.Create(AOwner: TComponent); SimbaIDEEvents.RegisterMethodOnScriptStateChange(@DoScriptStateChange); end; -function TSimbaOutputBox.GetAntialiasing: Boolean; -begin - Result := (Font.Quality = fqCleartypeNatural); -end; - -procedure TSimbaOutputBox.SetAntialiasing(Value: Boolean); -begin - case Value of - True: Font.Quality := fqCleartypeNatural; - False: Font.Quality := fqNonAntialiased; - end; -end; - function TSimbaOutputBox.GetTab: TSimbaTab; begin if (not (Parent is TSimbaTab)) then @@ -173,15 +157,16 @@ function TSimbaOutputBox.GetTab: TSimbaTab; procedure TSimbaOutputBox.SimbaSettingChanged(Setting: TSimbaSetting); begin - if Setting.Equals(SimbaSettings.OutputBox.FontAntiAliased) then - Antialiasing := Setting.Value - else + //if Setting.Equals(SimbaSettings.OutputBox.Color) then // Color := Setting.Value //else //if Setting.Equals(SimbaSettings.OutputBox.FontColor) then // Font.Color := Setting.Value //else + if Setting.Equals(SimbaSettings.OutputBox.FontAntiAliased) then + FontAntialising := Setting.Value + else if Setting.Equals(SimbaSettings.OutputBox.FontSize) then Font.Size := Setting.Value else diff --git a/Source/simba.settings.pas b/Source/simba.settings.pas index a543d4b2b..2b3474d9c 100644 --- a/Source/simba.settings.pas +++ b/Source/simba.settings.pas @@ -502,7 +502,7 @@ constructor TSimbaSettings.Create; OutputBox.FontColor := TSimbaSetting_Integer.Create(Self, 'OutputBox', 'FontColor', clBlack); OutputBox.Color := TSimbaSetting_Integer.Create(Self, 'OutputBox', 'Color', clWhite); - OutputBox.FontSize := TSimbaSetting_Integer.Create(Self, 'OutputBox', 'FontSize', SynDefaultFontHeight); + OutputBox.FontSize := TSimbaSetting_Integer.Create(Self, 'OutputBox', 'FontSize', SynDefaultFontSize); OutputBox.FontName := TSimbaSetting_String.Create(Self, 'OutputBox', 'FontName', SynDefaultFontName); OutputBox.FontAntiAliased := TSimbaSetting_Boolean.Create(Self, 'OutputBox', 'FontAntiAliased', True);