Skip to content

Commit

Permalink
Notes form theming
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jun 5, 2023
1 parent 8b246ea commit 8d65569
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 85 deletions.
27 changes: 25 additions & 2 deletions Source/components/simba.component_synedit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
interface

uses
Classes, SysUtils, Controls, Forms, StdCtrls,
Classes, SysUtils, Controls, Forms, StdCtrls, Graphics,
SynEdit, SynEditTypes, SynEditFoldedView, SynEditTextBuffer, SynEditMarkupSelection,
LazSynEditText,
ATScrollBar;
Expand All @@ -23,15 +23,33 @@ 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

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;
Expand Down Expand Up @@ -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.
Expand Down
41 changes: 11 additions & 30 deletions Source/editor/simba.editor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -26,7 +23,6 @@ TSimbaEditor = class(TSimbaSynEdit)

FAttributes: TSimbaEditor_Attributes;
FModifiedLinesGutter: TSimbaEditorModifiedLinesGutter;
FFontChangedHandlerList: TMethodList;

FFocusedLinesUpdating: Boolean;
FFocusedLinesCount: Integer;
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -540,8 +523,6 @@ destructor TSimbaEditor.Destroy;

if (FAttributes <> nil) then
FreeAndNil(FAttributes);
if (FFontChangedHandlerList <> nil) then
FreeAndNil(FFontChangedHandlerList);

inherited Destroy();
end;
Expand Down
11 changes: 2 additions & 9 deletions Source/editor/simba.editor_paramhint.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand All @@ -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);
Expand Down
23 changes: 6 additions & 17 deletions Source/forms/simba.notesform.lfm
Original file line number Diff line number Diff line change
@@ -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
30 changes: 23 additions & 7 deletions Source/forms/simba.notesform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,49 @@
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
SimbaNotesForm: TSimbaNotesForm;

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.
Expand Down
23 changes: 4 additions & 19 deletions Source/forms/simba.outputform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/simba.settings.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 8d65569

Please sign in to comment.