1 { IDE options frame for IDE Scout options
2 
3   Copyright (C) 2018  Michael van Canneyt  michael@freepascal.org
4 
5   This library is free software; you can redistribute it and/or modify it
6   under the terms of the GNU Library General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or (at your
8   option) any later version with the following modification:
9 
10   As a special exception, the copyright holders of this library give you
11   permission to link this library with independent modules to produce an
12   executable, regardless of the license terms of these independent modules,and
13   to copy and distribute the resulting executable under terms of your choice,
14   provided that you also meet, for each linked independent module, the terms
15   and conditions of the license of that module. An independent module is a
16   module which is not derived from or based on this library. If you modify
17   this library, you may extend this exception to your version of the library,
18   but you are not obligated to do so. If you do not wish to do so, delete this
19   exception statement from your version.
20 
21   This program is distributed in the hope that it will be useful, but WITHOUT
22   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
24   for more details.
25 
26   You should have received a copy of the GNU Library General Public License
27   along with this library; if not, write to the Free Software Foundation,
28   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.
29 }
30 unit IDEScoutOptions;
31 
32 {$mode objfpc}{$H+}
33 {$Inline on}
34 
35 interface
36 
37 uses
38   Classes, SysUtils,
39   // LCL
40   Forms, StdCtrls, Dialogs, Spin, ExtCtrls, ColorBox,
41   // IdeIntf
42   IDEOptionsIntf, IDEOptEditorIntf, frmScout, IDEScoutStrConsts;
43 
44 
45 Type
46   { TIDEScoutOptionsFrame }
47 
48   TIDEScoutOptionsFrame = class(TAbstractIDEOptionsEditor)
49     CGSearch: TCheckGroup;
50     CBShowShortCut: TCheckBox;
51     CBMatchColor: TColorBox;
52     CBShortCutColor: TColorBox;
53     CBShowCategory: TCheckBox;
54     CBSelectComponent: TCheckBox;
55     GBColors: TGroupBox;
56     GBComponents: TGroupBox;
57     LSEComponentDefaultWidth: TLabel;
58     LSEComponentDefaultHeight: TLabel;
59     LCBShortCut: TLabel;
60     LCBMatchColor: TLabel;
61     GBOptions: TGroupBox;
62     SEComponentDefaultWidth: TSpinEdit;
63     SEComponentDefaultHeight: TSpinEdit;
64     procedure CGSearchItemClick(Sender: TObject; Index: integer);
65   private
66   public
GetTitlenull67     function GetTitle: String; override;
68     procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
69     procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
70     procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
SupportedOptionsClassnull71     class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
72   end;
73 
74 implementation
75 
76 {$R *.lfm}
77 
78 { TIDEScoutOptionsFrame }
79 
80 procedure TIDEScoutOptionsFrame.CGSearchItemClick(Sender: TObject;
81   Index: integer);
82 begin
83   if Index=Ord(stComponents) then
84     GBComponents.Enabled:=CGsearch.Checked[Index];
85 end;
86 
TIDEScoutOptionsFrame.GetTitlenull87 function TIDEScoutOptionsFrame.GetTitle: String;
88 begin
89   Result:=isrsIDEScout;
90 end;
91 
92 procedure TIDEScoutOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
93 begin
94   CGSearch.Caption:=isrsSearchScope;
95   CGSearch.Items[0]:=isrsCommands;
96   CGSearch.Items[1]:=isrsRecentProjects;
97   CGSearch.Items[2]:=isrsRecentFiles;
98   CGSearch.Items[3]:=isrsRecentPackages;
99   CGSearch.Items[4]:=isrsComponents;
100 
101   GBOptions.Caption:=isrsOptions;
102   CBShowShortCut.Caption:=isrsShowShOrtcutWhenAvailable;
103   CBShowCategory.Caption:=isrsShowCategoryWhenAvailable;
104 
105   GBColors.Caption:=isrsColors;
106   LCBMatchColor.Caption:=isrsMatches;
107   LCBShortCut.Caption:=isrsShortcut;
108 
109   GBComponents.Caption:=isrsComponents;
110   CBSelectComponent.Caption:=isrsOnlySelectOnComponentPalette;
111   LSEComponentDefaultWidth.Caption:=isrsDefaultWidth;
112   LSEComponentDefaultHeight.Caption:=isrsDefaultHeight;
113 end;
114 
115 procedure TIDEScoutOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
116 
117 Var
118   st : TScoutTerrain;
119 
120 begin
121   for St in TScoutTerrain do
122     CGSearch.Checked[Ord(St)]:=St in ScoutTerrains;
123   CBSelectComponent.Checked:=Not TComponentItem.Drop;
124   SEComponentDefaultHeight.Value:=TComponentItem.DefaultHeight;
125   SEComponentDefaultWidth.Value:=TComponentItem.DefaultWidth;
126   CBShowCategory.Checked  := ShowCmdCategory;
127   CBShowShortCut.Checked  := ShowShortCutKey;
128   CBMatchColor.Selected   := MatchColor;
129   CBShortCutColor.Selected := KeyStrokeColor;
130 end;
131 
132 procedure TIDEScoutOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
133 
134 Var
135   st : TScoutTerrain;
136   STS : TScoutTerrains;
137 
138 begin
139   STS:=[];
140   for ST in TScoutTerrain do
141     if CGSearch.Checked[Ord(ST)] then
142       Include(STS,ST);
143   ScoutTerrains:=STS;
144   TComponentItem.Drop:=not CBSelectComponent.Checked;
145   TComponentItem.DefaultHeight:=SEComponentDefaultHeight.Value;
146   TComponentItem.DefaultWidth:=SEComponentDefaultWidth.Value;
147   ShowCmdCategory:=CBShowCategory.Checked;
148   ShowShortCutKey:=CBShowShortCut.Checked;
149   MatchColor:=CBMatchColor.Selected;
150   KeyStrokeColor:=CBShortCutColor.Selected;
151   SaveScoutOptions;
152   ApplyScoutOptions;
153 end;
154 
TIDEScoutOptionsFrame.SupportedOptionsClassnull155 class function TIDEScoutOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
156 begin
157   Result:=IDEEditorGroups.GetByIndex(GroupEnvironment)^.GroupClass;
158 end;
159 
160 end.
161 
162