1 {
2 ***************************************************************************
3 * *
4 * This source is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This code is distributed in the hope that it will be useful, but *
10 * WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * General Public License for more details. *
13 * *
14 * A copy of the GNU General Public License is available on the World *
15 * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
16 * obtain it by writing to the Free Software Foundation, *
17 * Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
18 * *
19 ***************************************************************************
20
21 Author: Mattias Gaertner
22
23 Abstract:
24 Dialog to choose an IDE keymapping scheme.
25 }
26 unit KeymapSchemeDlg;
27
28 {$mode objfpc}{$H+}
29
30 interface
31
32 uses
33 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
34 ExtCtrls, Buttons, KeyMapping, LazarusIDEStrConsts, ButtonPanel,
35 IDEHelpIntf;
36
37 type
38
39 { TChooseKeySchemeDlg }
40
41 TChooseKeySchemeDlg = class(TForm)
42 ButtonPanel: TButtonPanel;
43 NoteLabel: TLABEL;
44 SchemeRadiogroup: TRADIOGROUP;
45 procedure ChooseKeySchemeDlgCREATE(Sender: TObject);
46 procedure HelpButtonClick(Sender: TObject);
47 private
GetKeymapSchemenull48 function GetKeymapScheme: string;
49 procedure SetKeymapScheme(const AValue: string);
50 public
51 property KeymapScheme: string read GetKeymapScheme write SetKeymapScheme;// untranslated
52 end;
53
ShowChooseKeySchemeDialognull54 function ShowChooseKeySchemeDialog(var NewScheme: string): TModalResult;
55
56 implementation
57
58 {$R *.lfm}
59
ShowChooseKeySchemeDialognull60 function ShowChooseKeySchemeDialog(var NewScheme: string): TModalResult;
61 var
62 ChooseKeySchemeDlg: TChooseKeySchemeDlg;
63 begin
64 ChooseKeySchemeDlg:=TChooseKeySchemeDlg.Create(nil);
65 ChooseKeySchemeDlg.KeymapScheme:=NewScheme;
66 Result:=ChooseKeySchemeDlg.ShowModal;
67 if Result=mrOk then
68 NewScheme:=ChooseKeySchemeDlg.KeymapScheme;
69 ChooseKeySchemeDlg.Free;
70 end;
71
72 { TChooseKeySchemeDlg }
73
74 procedure TChooseKeySchemeDlg.ChooseKeySchemeDlgCREATE(Sender: TObject);
75 begin
76 Caption:=lisKMChooseKeymappingScheme;
77 NoteLabel.Caption:=lisKMNoteAllKeysWillBeSetToTheValuesOfTheChosenScheme;
78 SchemeRadiogroup.Caption:=lisKMKeymappingScheme;
79
80 ButtonPanel.HelpButton.OnClick := @HelpButtonClick;
81
82 with SchemeRadiogroup.Items do begin
83 Clear;
84 // keep order of TKeyMapScheme
85 Add(lisKMLazarusDefault);
86 Add(lisKMClassic);
87 Add(lisKMMacOSXApple);
88 Add(lisKMMacOSXLaz);
89 Add(lisKMDefaultToOSX);
90 // do not add custom
91 end;
92 end;
93
94 procedure TChooseKeySchemeDlg.HelpButtonClick(Sender: TObject);
95 begin
96 LazarusHelp.ShowHelpForIDEControl(Self);
97 end;
98
TChooseKeySchemeDlg.GetKeymapSchemenull99 function TChooseKeySchemeDlg.GetKeymapScheme: string;
100 begin
101 if SchemeRadiogroup.ItemIndex<0 then
102 Result:=KeyMapSchemeNames[kmsLazarus]
103 else if SchemeRadiogroup.ItemIndex<ord(kmsCustom) then
104 Result:=KeyMapSchemeNames[TKeyMapScheme(SchemeRadiogroup.ItemIndex)]
105 else
106 Result:=SchemeRadiogroup.Items[SchemeRadiogroup.ItemIndex];
107 end;
108
109 procedure TChooseKeySchemeDlg.SetKeymapScheme(const AValue: string);
110 var
111 kms: TKeyMapScheme;
112 begin
113 kms:=KeySchemeNameToSchemeType(AValue);
114 if kms=kmsCustom then begin
115 if SchemeRadiogroup.Items.Count<=ord(kms) then
116 SchemeRadiogroup.Items.Add(AValue)
117 else
118 SchemeRadiogroup.Items[SchemeRadiogroup.Items.Count-1]:=AValue;
119 end;
120 SchemeRadiogroup.ItemIndex:=ord(kms);
121 end;
122
123 end.
124
125