Skip to content

Commit

Permalink
Simple FindInFiles form
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Sep 30, 2023
1 parent 71bdfed commit 25ca7a3
Show file tree
Hide file tree
Showing 21 changed files with 2,430 additions and 1,589 deletions.
Binary file added Images/tick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/tick_150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/tick_200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="148">
<Units Count="149">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -1014,6 +1014,13 @@
<Filename Value="simba.boxarray.pas"/>
<IsPartOfProject Value="True"/>
</Unit147>
<Unit148>
<Filename Value="forms/simba.findinfilesform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaFindInFilesForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit148>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
2 changes: 2 additions & 0 deletions Source/Simba.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
simba.colorpickerhistoryform, simba.filebrowserform, simba.notesform,
simba.settingsform, simba.associate, simba.openexampleform,
simba.package_form, simba.shapeboxform, simba.backupsform,
simba.findinfilesform,
simba.compiler_dump, simba.plugin_dump,
simba.scriptthread, simba.ide_initialization, simba.threading,
simba.openssl, simba.ide_codetools_setup;
Expand Down Expand Up @@ -117,6 +118,7 @@
Application.CreateForm(TSimbaPackageForm, SimbaPackageForm);
Application.CreateForm(TSimbaShapeBoxForm, SimbaShapeBoxForm);
Application.CreateForm(TSimbaBackupsForm, SimbaBackupsForm);
Application.CreateForm(TSimbaFindInFilesForm, SimbaFindInFilesForm);

SimbaIDEInitialization_CallBeforeShow();
end;
Expand Down
220 changes: 203 additions & 17 deletions Source/components/simba.component_button.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,62 @@
interface

uses
Classes, SysUtils, Buttons;
Classes, SysUtils, Controls, StdCtrls, Buttons, Graphics, LMessages;

type
{$push}
{$scopedenums on}
ESimbaButtonImage = (
OK,
CLOSE,
CLEAR_FILTER,
SELECT_DIR,
SELECT_FILE,
TIME,
CALC,
CALENDER
);
{$pop}

const
IMG_TO_LAZ_GLYPH: array[ESimbaButtonImage] of String = (
'btn_ok',
'btn_cancel',
'btnfiltercancel',
'btnseldir',
'btnselfile',
'btntime',
'btncalculator',
'btncalendar'
);

type
TSimbaButton = class(TSpeedButton)
protected
// Use parent font size, but use SimbaTheme.FontStyle and font styles if changed
procedure CMParentFontChanged(var Message: TLMessage); message CM_PARENTFONTCHANGED;

procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;
procedure PaintBackground(var PaintRect: TRect); override;
public
VertPadding: Integer;
XPadding: Integer;
YPadding: Integer;

constructor Create(AOwner: TComponent); override;

procedure SetImage(Img: ESimbaButtonImage);
end;

TSimbaLabeledButton = class(TCustomControl)
protected
FLabel: TLabel;
FButton: TSimbaButton;

procedure TextChanged; override;
public
constructor Create(AOwner: TComponent); override;

procedure SetOkGlpyh;
procedure SetCloseGlyph;
procedure SetClearFilterGlyph;
property Button: TSimbaButton read FButton;
end;

TSimbaToggleButton = class(TSimbaButton)
Expand All @@ -39,10 +80,39 @@ TSimbaTransparentButton = class(TSimbaButton)
constructor Create(AOwner: TComponent); override;
end;

TSimbaCheckButton = class(TSimbaToggleButton)
public
constructor Create(AOwner: TComponent); override;
end;

TSimbaLabeledCheckButton = class(TCustomControl)
protected
FLabel: TLabel;
FCheckButton: TSimbaCheckButton;

procedure TextChanged; override;
public
constructor Create(AOwner: TComponent); override;

property CheckButton: TSimbaCheckButton read FCheckButton;
end;

TSimbaCheckButtonGroup = class(TCustomControl)
protected
function GetSelected(Index: Integer): Boolean;
procedure SetSelected(Index: Integer; Value: Boolean);
public
constructor Create(AOwner: TComponent); override;

function Add(ACaption: String): Integer;

property Checked[Index: Integer]: Boolean read GetSelected write SetSelected;
end;

implementation

uses
simba.theme,
simba.theme, simba.main,
ATCanvasPrimitives;

procedure TSimbaTransparentButton.PaintBackground(var PaintRect: TRect);
Expand All @@ -64,11 +134,112 @@ constructor TSimbaTransparentButton.Create(AOwner: TComponent);
ParentColor := True;
end;

constructor TSimbaCheckButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

XPadding:=0;
Images := SimbaForm.Images;
PressedImageIndex := 62;
SelectedImageIndex := 62;
end;

procedure TSimbaLabeledCheckButton.TextChanged;
begin
inherited TextChanged();

if Assigned(FLabel) then
FLabel.Caption := Text;
end;

constructor TSimbaLabeledCheckButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

ControlStyle := ControlStyle + [csOpaque];
Color := SimbaTheme.ColorFrame;
Font.Color := SimbaTheme.ColorFont;
AutoSize := True;
ParentFont := True;

FLabel := TLabel.Create(Self);
FLabel.Parent := Self;
FLabel.Align := alLeft;
FLabel.AutoSize := True;
FLabel.Layout := tlCenter;
FLabel.ParentFont := True;

FCheckButton := TSimbaCheckButton.Create(Self);
FCheckButton.Parent := Self;

FCheckButton.Anchors := [akLeft];
FCheckButton.AnchorSideLeft.Control := FLabel;
FCheckButton.AnchorSideLeft.Side := asrRight;
FCheckButton.AnchorVerticalCenterTo(FLabel);

FCheckButton.BorderSpacing.Top := 5;
FCheckButton.BorderSpacing.Bottom := 5;
FCheckButton.BorderSpacing.Right := 5;
FCheckButton.BorderSpacing.Left := 8;
end;

procedure TSimbaCheckButtonGroup.SetSelected(Index: Integer; Value: Boolean);
begin
if (Controls[Index] is TSimbaLabeledCheckButton) then
TSimbaLabeledCheckButton(Controls[Index]).CheckButton.Down := Value;
end;

function TSimbaCheckButtonGroup.GetSelected(Index: Integer): Boolean;
begin
if (Controls[Index] is TSimbaLabeledCheckButton) then
Result := TSimbaLabeledCheckButton(Controls[Index]).CheckButton.Down
else
Result := False;
end;

constructor TSimbaCheckButtonGroup.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

AutoSize := True;
end;

function TSimbaCheckButtonGroup.Add(ACaption: String): Integer;
var
CheckButton: TSimbaLabeledCheckButton;
begin
CheckButton := TSimbaLabeledCheckButton.Create(Self);
CheckButton.Parent := Self;
CheckButton.Caption := ACaption;
CheckButton.Align := alBottom;

Result := Self.GetControlIndex(CheckButton);
end;

procedure TSimbaButton.CMParentFontChanged(var Message: TLMessage);
var
OldStyle: TFontStyles;
begin
OldStyle := Font.Style;

inherited;

if Assigned(Parent) then
begin
Font.BeginUpdate();
Font := Parent.Font;
Font.Style := OldStyle;
Font.Color := SimbaTheme.ColorFont;
Font.EndUpdate();
end;
end;

procedure TSimbaButton.CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
begin
inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, WithThemeSpace);

PreferredWidth += VertPadding * 2;
PreferredWidth += XPadding * 2;
PreferredHeight += YPadding * 2;
end;

procedure TSimbaButton.PaintBackground(var PaintRect: TRect);
Expand All @@ -87,23 +258,40 @@ constructor TSimbaButton.Create(AOwner: TComponent);
inherited Create(AOwner);

AutoSize := True;
Font.Color := SimbaTheme.ColorFont;
VertPadding := 5;
XPadding := 5;
end;

procedure TSimbaButton.SetOkGlpyh;
procedure TSimbaButton.SetImage(Img: ESimbaButtonImage);
begin
ButtonGlyph.LCLGlyphName := 'btn_ok';
ButtonGlyph.LCLGlyphName := IMG_TO_LAZ_GLYPH[Img];
end;

procedure TSimbaButton.SetCloseGlyph;
procedure TSimbaLabeledButton.TextChanged;
begin
ButtonGlyph.LCLGlyphName := 'btn_cancel';
inherited TextChanged();

if Assigned(FLabel) then
FLabel.Caption := Text;
end;

procedure TSimbaButton.SetClearFilterGlyph;
constructor TSimbaLabeledButton.Create(AOwner: TComponent);
begin
ButtonGlyph.LCLGlyphName := 'btnfiltercancel';
inherited Create(AOwner);

ControlStyle := ControlStyle + [csOpaque];
Color := SimbaTheme.ColorBackground;
AutoSize := True;

FButton := TSimbaButton.Create(Self);
FButton.AutoSize := True;
FButton.Parent := Self;
FButton.Align := alLeft;

FLabel := TLabel.Create(Self);
FLabel.Parent := Self;
FLabel.AutoSize := True;
FLabel.Align := alClient;
FLabel.Layout := tlCenter;
end;

constructor TSimbaToggleButton.Create(AOwner: TComponent);
Expand All @@ -112,8 +300,6 @@ constructor TSimbaToggleButton.Create(AOwner: TComponent);

AllowAllUp := True;
GroupIndex := 1 + AOwner.ComponentCount;

Font.Color := SimbaTheme.ColorFont;
end;

end.
Expand Down
9 changes: 4 additions & 5 deletions Source/components/simba.component_buttonpanel.pas
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,16 @@ constructor TSimbaButtonPanel.Create(AOwner: TComponent);
FButtonOk.Align := alRight;
FButtonOk.Caption := 'Ok';
FButtonOk.BorderSpacing.Around := 8;
FButtonOk.VertPadding := 10;
FButtonOk.AutoSize := False;
FButtonOk.SetOkGlpyh();
FButtonOk.XPadding := 10;
FButtonOk.SetImage(ESimbaButtonImage.OK);

FButtonCancel := TButtonPanelButton.Create(Self);
FButtonCancel.Parent := Self;
FButtonCancel.Align := alRight;
FButtonCancel.Caption := 'Cancel';
FButtonCancel.BorderSpacing.Around := 8;
FButtonCancel.VertPadding := 10;
FButtonCancel.SetCloseGlyph();
FButtonCancel.XPadding := 10;
FButtonCancel.SetImage(ESimbaButtonImage.CLOSE);
FButtonCancel.OnResize := @DoButtonCancelResize;

Color := SimbaTheme.ColorFrame;
Expand Down
Loading

0 comments on commit 25ca7a3

Please sign in to comment.