* Some visual improvements:

* Load options on startup.
  * Button to go to settings
  * Margins around controls
  * Better Left and right margin inside listbox
  * Use different default colors (maroon, navy)
  * Handle keydown instead of key up, so repeat is enabled.

git-svn-id: trunk@59165 -
This commit is contained in:
michael 2018-09-25 07:44:13 +00:00
parent a6d2915670
commit 51b431043e
3 changed files with 92 additions and 34 deletions

View File

@ -3,7 +3,6 @@ object SpotterForm: TSpotterForm
Height = 232 Height = 232
Top = 195 Top = 195
Width = 497 Width = 497
ActiveControl = ECommand
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'Spotter' Caption = 'Spotter'
ClientHeight = 232 ClientHeight = 232
@ -18,34 +17,78 @@ object SpotterForm: TSpotterForm
ShowInTaskBar = stNever ShowInTaskBar = stNever
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
Visible = True Visible = True
object ECommand: TEdit
Left = 0
Height = 27
Top = 0
Width = 497
Align = alTop
OnChange = ECommandChange
OnKeyUp = ECommandKeyUp
TabOrder = 0
TextHint = 'Search command'
end
object LBMatches: TListBox object LBMatches: TListBox
Left = 0 Left = 3
Height = 205 Height = 196
Top = 27 Top = 33
Width = 497 Width = 491
Align = alClient Align = alClient
BorderSpacing.Around = 3
ClickOnSelChange = False ClickOnSelChange = False
ItemHeight = 0 ItemHeight = 0
OnClick = LBMatchesClick OnClick = LBMatchesClick
OnDrawItem = LBMatchesDrawItem OnDrawItem = LBMatchesDrawItem
OnKeyUp = LBMatchesKeyUp OnKeyUp = LBMatchesKeyUp
ParentShowHint = False ParentShowHint = False
ScrollWidth = 495 ScrollWidth = 489
ShowHint = True ShowHint = True
Style = lbOwnerDrawFixed Style = lbOwnerDrawFixed
TabOrder = 1 TabOrder = 0
TabStop = False TabStop = False
TopIndex = -1 TopIndex = -1
end end
object ESearch: TEditButton
Left = 3
Height = 27
Top = 3
Width = 491
Align = alTop
BorderSpacing.Around = 3
ButtonWidth = 23
Flat = True
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000020A1C9FF2CAACFFF1082
ACFF000000000000000000000000000000000000000000000000000000000000
0000000000002BA3C9FF24A5CCFF0F84AEFF149AC3FF24AED6FF33B1D5FF188B
B4FF1787AFFF43ABCCFF3DA8CBFF000000000000000000000000000000000000
00000000000032A5C9FF37B8DCFF14AED9FF11A1CBFF1DC7F0FF48D7F8FF34A6
CAFF5CC1DDFF67C4DEFF3FA4C6FF00000000000000000000000000000000208C
B4FF2C98BDFF4EB5D5FF85DBEFFF51C0DEFF39C8ECFF1ED7FFFF3ADBFFFF5FD4
F1FF75C6DFFFB0E1ECFF90CEE1FF1B8BB5FF00000000000000000000000060BA
D7FF48B0D2FF53BEE0FF95EDFFFF8DEFFFFF5AE5FFFF27DAFFFF1CD8FFFF52E2
FFFF79E8FFFF7DEBFFFF3FCBEEFF31B1D9FF2CA4CEFF00000000000000001391
C0FF22A6D7FF4EC3EAFF81DFF7FF92EFFFFF71D3E8FF5CB8CCFF50B2C9FF2AC7
EBFF07D1FFFF04CFFEFF09D0FEFF08C9F5FF0EB4E1FF00000000000000001C8E
B8FF28ADDEFF3FBBE7FF6DD7F6FF91C7D3FF979696FF979696FF979696FF9796
96FF45BCD8FF02D2FFFF14D3FEFF1ED2FBFF0C9ECBFF00000000000000001E92
BCFF27ADDFFF31B4E3FF5ACFF4FF979696FFE9E3E2FFB2B3B3FFACA2A2FFE1B7
B5FF979696FF59DCFAFF9CF0FFFFB5EFFCFF3D9BBDFF0000000000000000148C
B8FF1F9DCDFF27ACDDFF47C5EFFF979696FFE9E2E0FFB1B2B2FFACA2A2FFDCB5
B4FF979696FF7CE4FBFFACECF9FF8ACBE0FF48A5C4FF00000000000000000000
00000E80AAFF20A2D3FF36BCEBFF979696FFE9E2E0FFB1B2B2FFACA2A2FFDDB6
B4FF979696FF65E1FDFF68CAE6FF0579A4FF0000000000000000000000000000
0000000000001389B4FF0D8FBEFF979696FFECE5E2FFB1B2B2FFACA2A2FFE0B8
B6FF979696FF1E9AC1FF2293BAFF000000000000000000000000000000000000
0000000000000000000000000000979696FFE5E3E2FFAEAFAFFFABA1A1FFD8B6
B6FF979696FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000979696FFB2B2B2FFA0A0A0FF999696FFABA0
A0FF979696FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000979696FFE1E0E0FFC6C7C7FFA5A3A3FFB3A5
A5FF979696FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000979696FFE5E4E4FFEAE9E9FFBCBCBCFFA39E
9EFF979696FF0000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000979696FF979696FF979696FF9796
96FF000000000000000000000000000000000000000000000000
}
MaxLength = 0
NumGlyphs = 1
OnButtonClick = ESearchButtonClick
OnChange = ECommandChange
OnKeyDown = ECommandKeyDown
PasswordChar = #0
TabOrder = 1
TextHint = 'Type search terms'
end
end end

View File

@ -35,7 +35,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, LazUTF8, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LazUTF8, Forms, Controls, Graphics, Dialogs,
StdCtrls, IDECommands, LazIDEIntf, Types; StdCtrls, EditBtn, IDECommands, LazIDEIntf, Types, LCLType, IDEOptionsIntf, IDEOptEditorIntf;
type type
@ -64,10 +64,11 @@ type
{ TSpotterForm } { TSpotterForm }
TSpotterForm = class(TForm) TSpotterForm = class(TForm)
ECommand: TEdit; ESearch: TEditButton;
LBMatches: TListBox; LBMatches: TListBox;
procedure ECommandChange(Sender: TObject); procedure ECommandChange(Sender: TObject);
procedure ECommandKeyUp(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState); procedure ECommandKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
procedure ESearchButtonClick(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
@ -101,8 +102,9 @@ type
Var Var
ShowCmdCategory : Boolean = True; ShowCmdCategory : Boolean = True;
ShowShortCutKey : Boolean = True; ShowShortCutKey : Boolean = True;
MatchColor : TColor = clRed; MatchColor : TColor = clMaroon;
KeyStrokeColor : TColor = clGreen; KeyStrokeColor : TColor = clNavy;
SettingsClass : TAbstractIDEOptionsEditorClass = Nil;
Procedure ShowSpotterForm; Procedure ShowSpotterForm;
Procedure ApplySpotterOptions; Procedure ApplySpotterOptions;
@ -111,7 +113,7 @@ procedure LoadSpotterOptions;
implementation implementation
Uses BaseIDEIntf, LazConfigStorage, StrUtils, LCLIntf, LCLType, LCLProc, srceditorintf; Uses BaseIDEIntf, LazConfigStorage, StrUtils, LCLIntf, LCLProc, srceditorintf;
{$R *.lfm} {$R *.lfm}
@ -207,10 +209,10 @@ end;
procedure TSpotterForm.ECommandChange(Sender: TObject); procedure TSpotterForm.ECommandChange(Sender: TObject);
begin begin
FilterList(ECommand.Text); FilterList(ESearch.Text);
end; end;
procedure TSpotterForm.ECommandKeyUp(Sender: TObject; var Key: Word; procedure TSpotterForm.ECommandKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); Shift: TShiftState);
begin begin
Case Key of Case Key of
@ -220,14 +222,14 @@ begin
If LBMatches.ItemIndex>0 then If LBMatches.ItemIndex>0 then
LBMatches.ItemIndex:=LBMatches.ItemIndex-1; LBMatches.ItemIndex:=LBMatches.ItemIndex-1;
Key:=0; Key:=0;
ECommand.SelStart:=Length(ECommand.Text); ESearch.SelStart:=Length(ESearch.Text);
end; end;
VK_DOWN: VK_DOWN:
begin begin
If LBMatches.ItemIndex<LBMatches.Items.Count-1 then If LBMatches.ItemIndex<LBMatches.Items.Count-1 then
LBMatches.ItemIndex:=LBMatches.ItemIndex+1; LBMatches.ItemIndex:=LBMatches.ItemIndex+1;
Key:=0; Key:=0;
ECommand.SelStart:=Length(ECommand.Text); ESearch.SelStart:=Length(ESearch.Text);
end; end;
VK_RETURN : VK_RETURN :
If LBMatches.ItemIndex>=0 then If LBMatches.ItemIndex>=0 then
@ -235,9 +237,16 @@ begin
end; end;
end; end;
procedure TSpotterForm.ESearchButtonClick(Sender: TObject);
begin
LazarusIDE.DoOpenIDEOptions(SettingsClass,'IDE Spotter');
Close;
end;
procedure TSpotterForm.FormActivate(Sender: TObject); procedure TSpotterForm.FormActivate(Sender: TObject);
begin begin
ECommand.SetFocus; ESearch.SetFocus;
end; end;
procedure TSpotterForm.FormClose(Sender: TObject; procedure TSpotterForm.FormClose(Sender: TObject;
@ -338,7 +347,7 @@ begin
Top:=MF.ClientOrigin.y+32; // Note: docked or not docked Top:=MF.ClientOrigin.y+32; // Note: docked or not docked
Left:=MF.ClientOrigin.x+(MF.Width-Width) div 2; Left:=MF.ClientOrigin.x+(MF.Width-Width) div 2;
end; end;
ECommand.Clear; ESearch.Clear;
LBMatches.Clear; LBMatches.Clear;
RefreshCaption(-1); RefreshCaption(-1);
end; end;
@ -352,16 +361,19 @@ end;
procedure TSpotterForm.LBMatchesDrawItem(Control: TWinControl; Index: Integer; procedure TSpotterForm.LBMatchesDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState); ARect: TRect; State: TOwnerDrawState);
Const
LeftMargin = 5;
RightMargin = LeftMargin;
Var Var
LB : TListbox; LB : TListbox;
DS,S : String; DS,S : String;
Itm : TSearchItem; Itm : TSearchItem;
R : TRect; R : TRect;
P,I,SP,W,SW : Integer; P,I,SP,W : Integer;
FC : TColor; FC : TColor;
begin begin
SW := GetSystemMetrics(SM_CXVSCROLL);
LB:=Control as TListBox; LB:=Control as TListBox;
LB.Canvas.FillRect(ARect); LB.Canvas.FillRect(ARect);
FC:=LB.Canvas.Font.Color; FC:=LB.Canvas.Font.Color;
@ -371,9 +383,9 @@ begin
if ShowShortCutKey and (Itm.KeyStroke<>'') then if ShowShortCutKey and (Itm.KeyStroke<>'') then
begin begin
W:=LB.Canvas.TextWidth(Itm.KeyStroke); W:=LB.Canvas.TextWidth(Itm.KeyStroke);
R.Right:=R.Right-W-SW; R.Right:=R.Right-W-RightMargin;
end; end;
Inc(R.Left,2); Inc(R.Left,LeftMargin);
SP:=1; SP:=1;
For I:=0 to Length(Itm.MatchPos)-1 do For I:=0 to Length(Itm.MatchPos)-1 do
begin begin

View File

@ -66,6 +66,7 @@ var
IDESpotteroptionsFrameID: Integer = 2000; IDESpotteroptionsFrameID: Integer = 2000;
begin begin
LoadSpotterOptions;
IDEShortCutX := IDEShortCut(VK_P, ShiftKeys, VK_UNKNOWN, []); IDEShortCutX := IDEShortCut(VK_P, ShiftKeys, VK_UNKNOWN, []);
IDECommandCategory := IDECommandList.FindCategoryByName(CommandCategoryViewName); IDECommandCategory := IDECommandList.FindCategoryByName(CommandCategoryViewName);
if IDECommandCategory <> nil then if IDECommandCategory <> nil then
@ -81,5 +82,7 @@ begin
@IDEMenuClicked,IDECommand); @IDEMenuClicked,IDECommand);
end; end;
Initialization
SettingsClass:=TIDESpotterOptionsFrame;
end. end.