fixed keymapping, imrpoved autosizing envirnment options dialog

git-svn-id: trunk@7291 -
This commit is contained in:
mattias 2005-06-28 22:44:22 +00:00
parent 3412d8b96c
commit 7bbed9755e
5 changed files with 93 additions and 86 deletions

View File

@ -2157,7 +2157,7 @@ begin
begin begin
Position:=poScreenCenter; Position:=poScreenCenter;
Caption:=lismenueditoroptions; Caption:=lismenueditoroptions;
IDEDialogLayoutList.ApplyLayout(Self,480,459); IDEDialogLayoutList.ApplyLayout(Self,480,480);
OnResize:=@EditorOptionsFormResize; OnResize:=@EditorOptionsFormResize;
SynAutoComplete:=TSynEditAutoComplete.Create(Self); SynAutoComplete:=TSynEditAutoComplete.Create(Self);

View File

@ -1809,12 +1809,18 @@ begin
EndUpdate; EndUpdate;
end; end;
OnMouseUp:=@WindowPositionsListBoxMouseUp; OnMouseUp:=@WindowPositionsListBoxMouseUp;
BorderSpacing.Around:=2;
Align:=alTop;
Height:=100;
end; end;
WindowPositionsBox:=TIDEWindowSetupLayoutComponent.Create(Self); WindowPositionsBox:=TIDEWindowSetupLayoutComponent.Create(Self);
with WindowPositionsBox do begin with WindowPositionsBox do begin
Name:='WindowPositionsBox'; Name:='WindowPositionsBox';
Parent:=WindowPositionsGroupBox; Parent:=WindowPositionsGroupBox;
BorderSpacing.Around:=2;
Align:=alBottom;
AnchorToNeighbour(akTop,2,WindowPositionsListBox);
end; end;
end; end;
@ -2860,10 +2866,12 @@ var
x: Integer; x: Integer;
w: Integer; w: Integer;
y: Integer; y: Integer;
h: Integer;
begin begin
x:=10; x:=10;
w:=MinimizeAllOnMinimizeMainCheckBox.Parent.ClientWidth-2*x; w:=MinimizeAllOnMinimizeMainCheckBox.Parent.ClientWidth-2*x;
y:=10; y:=10;
h:=MinimizeAllOnMinimizeMainCheckBox.Parent.ClientHeight-y-2;
// window minimizing and hiding // window minimizing and hiding
with MinimizeAllOnMinimizeMainCheckBox do begin with MinimizeAllOnMinimizeMainCheckBox do begin
@ -2878,7 +2886,7 @@ begin
// Window Positions // Window Positions
with WindowPositionsGroupBox do with WindowPositionsGroupBox do
SetBounds(x,y,Max(10,(w div 2)-5),330); SetBounds(x,y,Max(10,(w div 2)-5),h-y);
end; end;
procedure TEnvironmentOptionsDialog.ResizeFormEditorPage; procedure TEnvironmentOptionsDialog.ResizeFormEditorPage;
@ -3054,16 +3062,6 @@ end;
procedure TEnvironmentOptionsDialog.WindowPositionsGroupBoxResize( procedure TEnvironmentOptionsDialog.WindowPositionsGroupBoxResize(
Sender: TObject); Sender: TObject);
begin begin
with WindowPositionsListBox do begin
SetBounds(2,2,Max(Parent.ClientWidth-2*2,100),Max(100,Parent.Height div 4));
end;
with WindowPositionsBox do begin
Left:=2;
Top:=WindowPositionsListBox.Top+WindowPositionsListBox.Height+5;
Width:=WindowPositionsListBox.Width;
Height:=Parent.ClientHeight-Top-2;
end;
end; end;
procedure TEnvironmentOptionsDialog.BakTypeRadioGroupClick(Sender: TObject); procedure TEnvironmentOptionsDialog.BakTypeRadioGroupClick(Sender: TObject);

View File

@ -948,7 +948,6 @@ begin
OnClick:=@RadioButtonClick; OnClick:=@RadioButtonClick;
Caption:=GetRadioBtnCaptions(APlacement); Caption:=GetRadioBtnCaptions(APlacement);
Checked:=(APlacement=AnLayout.WindowPlacement); Checked:=(APlacement=AnLayout.WindowPlacement);
Visible:=true;
end; end;
case APlacement of case APlacement of
@ -976,28 +975,30 @@ begin
end; end;
end; end;
end; end;
end else
begin end else begin
if PlacementRadioButtons[APlacement]<>nil then // window placement not allowed
begin if PlacementRadioButtons[APlacement]<>nil then
PlacementRadioButtons[APlacement].Free; begin
PlacementRadioButtons[APlacement]:=nil; PlacementRadioButtons[APlacement].Free;
end; PlacementRadioButtons[APlacement]:=nil;
end; end;
end; end;
end;
inc(CurY,2);
if ApplyButton=nil then inc(CurY,2);
ApplyButton:=TButton.Create(Self); if ApplyButton=nil then
ApplyButton:=TButton.Create(Self);
with ApplyButton do
begin with ApplyButton do
begin
Parent:=Self; Parent:=Self;
SetBounds(5,CurY,70,Height); SetBounds(5,CurY,Width,Height);
OnClick:=@ApplyButtonClick; OnClick:=@ApplyButtonClick;
Caption:=dlgButApply; Caption:=dlgButApply;
Visible:=true; AutoSize:=true;
end; end;
if iwpCustomPosition in AnLayout.WindowPlacementsAllowed then if iwpCustomPosition in AnLayout.WindowPlacementsAllowed then
begin begin
if GetWindowPositionButton=nil then if GetWindowPositionButton=nil then
@ -1005,10 +1006,11 @@ begin
with GetWindowPositionButton do with GetWindowPositionButton do
begin begin
Parent:=Self; Parent:=Self;
SetBounds(85,CurY,110,Height);
OnClick:=@GetWindowPositionButtonClick; OnClick:=@GetWindowPositionButtonClick;
Caption:=dlgGetPosition; Caption:=dlgGetPosition;
Visible:=true; AutoSize:=true;
AnchorToNeighbour(akLeft,5,ApplyButton);
AnchorParallel(akTop,0,ApplyButton);
end; end;
end; end;
//inc(CurY,ApplyButton.Height+7); //inc(CurY,ApplyButton.Height+7);

View File

@ -318,7 +318,7 @@ type
procedure Assign(List: TKeyCommandRelationList); procedure Assign(List: TKeyCommandRelationList);
procedure LoadScheme(const SchemeName: string); procedure LoadScheme(const SchemeName: string);
public public
property ExtToolCount: integer read fExtToolCount write SetExtToolCount; property ExtToolCount: integer read fExtToolCount write SetExtToolCount;// in menu
property CustomKeyCount: integer read FCustomKeyCount write SetCustomKeyCount; property CustomKeyCount: integer read FCustomKeyCount write SetCustomKeyCount;
property Relations[Index:integer]:TKeyCommandRelation read GetRelation; property Relations[Index:integer]:TKeyCommandRelation read GetRelation;
property RelationCount:integer read GetRelationCount; property RelationCount:integer read GetRelationCount;
@ -338,34 +338,16 @@ type
KeyShiftCheckBox: array[0..3] of TCheckBox; KeyShiftCheckBox: array[0..3] of TCheckBox;
KeyComboBox: array[0..3] of TComboBox; KeyComboBox: array[0..3] of TComboBox;
KeyGrabButton: array[0..3] of TButton; KeyGrabButton: array[0..3] of TButton;
// Key1GroupBox: TGroupBox;
// Key1aCtrlCheckBox: TCheckBox;
// Key1aAltCheckBox: TCheckBox;
// Key1aShiftCheckBox: TCheckBox;
// Key1aKeyComboBox: TComboBox;
// Key1aGrabButton: TButton;
// Key1bCtrlCheckBox: TCheckBox;
// Key1bAltCheckBox: TCheckBox;
// Key1bShiftCheckBox: TCheckBox;
// Key1bKeyComboBox: TComboBox;
// Key1bGrabButton: TButton;
// Key2GroupBox: TGroupBox;
// Key2aCtrlCheckBox: TCheckBox;
// Key2aAltCheckBox: TCheckBox;
// Key2aShiftCheckBox: TCheckBox;
// Key2aKeyComboBox: TComboBox;
// Key2aGrabButton: TButton;
// Key2bCtrlCheckBox: TCheckBox;
// Key2bAltCheckBox: TCheckBox;
// Key2bShiftCheckBox: TCheckBox;
// Key2bKeyComboBox: TComboBox;
// Key2bGrabButton: TButton;
procedure OkButtonClick(Sender: TObject); procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject); procedure CancelButtonClick(Sender: TObject);
procedure KeyGrabButtonClick(Sender: TObject); procedure KeyGrabButtonClick(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word; Shift:TShiftState); procedure FormKeyUp(Sender: TObject; var Key: Word; Shift:TShiftState);
private private
GrabbingKey: integer; // 0=none, 1=Default key, 2=Alternative key GrabbingKey: integer; { 0=none,
1=Default key (1st in sequence),
2=Default key (second in sequence),
3=Alternative key (1st in sequence)
4=Alternative key (second in sequence) }
procedure ActivateGrabbing(AGrabbingKey: integer); procedure ActivateGrabbing(AGrabbingKey: integer);
procedure DeactivateGrabbing; procedure DeactivateGrabbing;
procedure SetComboBox(AComboBox: TComboBox; const AValue: string); procedure SetComboBox(AComboBox: TComboBox; const AValue: string);
@ -409,7 +391,7 @@ implementation
const const
KeyMappingFormatVersion = 2; KeyMappingFormatVersion = 3;
VirtualKeyStrings: TStringHashList = nil; VirtualKeyStrings: TStringHashList = nil;
@ -427,6 +409,7 @@ var
Data: Pointer; Data: Pointer;
begin begin
Result:=VK_UNKNOWN; Result:=VK_UNKNOWN;
//debugln('EditorKeyStringToVKCode A "',s,'"');
if EditorKeyStringIsIrregular(s) then begin if EditorKeyStringIsIrregular(s) then begin
Result:=word(StrToIntDef(copy(s,7,length(s)-8),VK_UNKNOWN)); Result:=word(StrToIntDef(copy(s,7,length(s)-8),VK_UNKNOWN));
exit; exit;
@ -1758,7 +1741,7 @@ begin
inherited Create(TheOwner); inherited Create(TheOwner);
if LazarusResources.Find(ClassName)=nil then if LazarusResources.Find(ClassName)=nil then
begin begin
SetBounds((Screen.Width-432) div 2, (Screen.Height-310) div 2, 432, 310); SetBounds((Screen.Width-432) div 2, (Screen.Height-310) div 2, 432, 340);
Caption := srkmEditForCmd; Caption := srkmEditForCmd;
OnKeyUp:=@FormKeyUp; OnKeyUp:=@FormKeyUp;
@ -1892,14 +1875,8 @@ var
CurRelation: TKeyCommandRelation; CurRelation: TKeyCommandRelation;
begin begin
// set defaults // set defaults
NewKeyA.Key1:=VK_UNKNOWN; NewKeyA:=CleanIDEShortCut;
NewKeyA.Shift1:=[]; NewKeyB:=CleanIDEShortCut;
NewKeyA.Key2:=VK_UNKNOWN;
NewKeyA.Shift2:=[];
NewKeyB.Key1:=VK_UNKNOWN;
NewKeyB.Shift1:=[];
NewKeyB.Key2:=VK_UNKNOWN;
NewKeyB.Shift2:=[];
//debugln('TKeyMappingEditForm.OkButtonClick A KeyA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' KeyB=',KeyAndShiftStateToEditorKeyString(NewKeyB)); //debugln('TKeyMappingEditForm.OkButtonClick A KeyA=',KeyAndShiftStateToEditorKeyString(NewKeyA),' KeyB=',KeyAndShiftStateToEditorKeyString(NewKeyB));
@ -2045,6 +2022,7 @@ begin
with KeyCommandRelationList.Relations[j] do with KeyCommandRelationList.Relations[j] do
begin begin
if (j=KeyIndex) or (Category.Areas*Areas=[]) then continue; if (j=KeyIndex) or (Category.Areas*Areas=[]) then continue;
if (Key.Key1=KeyA.Key1) and (Key.Shift1=KeyA.Shift1) then if (Key.Key1=KeyA.Key1) and (Key.Shift1=KeyA.Shift1) then
if (Key.Key2=KeyA.Key2) and (Key.Shift2=KeyA.Shift2) then if (Key.Key2=KeyA.Key2) and (Key.Shift2=KeyA.Shift2) then
begin begin
@ -2162,7 +2140,7 @@ begin
KeyCtrlCheckBox[GrabbingKey-1].Checked:=(ssCtrl in Shift); KeyCtrlCheckBox[GrabbingKey-1].Checked:=(ssCtrl in Shift);
KeyShiftCheckBox[GrabbingKey-1].Checked:=(ssShift in Shift); KeyShiftCheckBox[GrabbingKey-1].Checked:=(ssShift in Shift);
KeyAltCheckBox[GrabbingKey-1].Checked:=(ssAlt in Shift); KeyAltCheckBox[GrabbingKey-1].Checked:=(ssAlt in Shift);
SetComboBox(KeyComboBox[GrabbingKey-1], KeyAndShiftStateToEditorKeyString(Key,Shift)); SetComboBox(KeyComboBox[GrabbingKey-1], KeyAndShiftStateToEditorKeyString(Key,[]));
Key:=0; Key:=0;
DeactivateGrabbing; DeactivateGrabbing;
end; end;
@ -2228,6 +2206,8 @@ begin
AddDefault(C,'Normal selection mode',ecNormalSelect); AddDefault(C,'Normal selection mode',ecNormalSelect);
AddDefault(C,'Column selection mode',ecColumnSelect); AddDefault(C,'Column selection mode',ecColumnSelect);
AddDefault(C,'Line selection mode',ecLineSelect); AddDefault(C,'Line selection mode',ecLineSelect);
AddDefault(C,'Indent block',ecBlockIndent);
AddDefault(C,'Unindent block',ecBlockUnindent);
AddDefault(C,'Uppercase selection',ecSelectionUpperCase); AddDefault(C,'Uppercase selection',ecSelectionUpperCase);
AddDefault(C,'Lowercase selection',ecSelectionLowerCase); AddDefault(C,'Lowercase selection',ecSelectionLowerCase);
AddDefault(C,'Convert tabs to spaces in selection',ecSelectionTabs2Spaces); AddDefault(C,'Convert tabs to spaces in selection',ecSelectionTabs2Spaces);
@ -2251,10 +2231,8 @@ begin
AddDefault(C,'Select line',ecSelectLine); AddDefault(C,'Select line',ecSelectLine);
AddDefault(C,'Select paragraph',ecSelectParagraph); AddDefault(C,'Select paragraph',ecSelectParagraph);
// editing // editing - without menu items in the IDE bar
C:=Categories[AddCategory('editing commands',srkmCatEditing,caSrcEdit)]; C:=Categories[AddCategory('text editing commands',srkmCatEditing,caSrcEditOnly)];
AddDefault(C,'Indent block',ecBlockIndent);
AddDefault(C,'Unindent block',ecBlockUnindent);
AddDefault(C,'Delete last char',ecDeleteLastChar); AddDefault(C,'Delete last char',ecDeleteLastChar);
AddDefault(C,'Delete char at cursor',ecDeleteChar); AddDefault(C,'Delete char at cursor',ecDeleteChar);
AddDefault(C,'Delete to end of word',ecDeleteWord); AddDefault(C,'Delete to end of word',ecDeleteWord);
@ -2265,6 +2243,7 @@ begin
AddDefault(C,'Delete whole text',ecClearAll); AddDefault(C,'Delete whole text',ecClearAll);
AddDefault(C,'Break line and move cursor',ecLineBreak); AddDefault(C,'Break line and move cursor',ecLineBreak);
AddDefault(C,'Break line, leave cursor',ecInsertLine); AddDefault(C,'Break line, leave cursor',ecInsertLine);
// TODO: these commands do have a menu item
AddDefault(C,'Insert from Character Map',ecInsertCharacter); AddDefault(C,'Insert from Character Map',ecInsertCharacter);
AddDefault(C,'Insert GPL notice',ecInsertGPLNotice); AddDefault(C,'Insert GPL notice',ecInsertGPLNotice);
AddDefault(C,'Insert LGPL notice',ecInsertLGPLNotice); AddDefault(C,'Insert LGPL notice',ecInsertLGPLNotice);
@ -2303,8 +2282,8 @@ begin
AddDefault(C,'Jump to previous error',ecJumpToPrevError); AddDefault(C,'Jump to previous error',ecJumpToPrevError);
AddDefault(C,'Open file at cursor',ecOpenFileAtCursor); AddDefault(C,'Open file at cursor',ecOpenFileAtCursor);
// marker // marker - without menu items in the IDE bar
C:=Categories[AddCategory('Marker',srkmCatMarker,caSrcEdit)]; C:=Categories[AddCategory('Marker',srkmCatMarker,caSrcEditOnly)];
AddDefault(C,'Go to marker 0',ecGotoMarker0); AddDefault(C,'Go to marker 0',ecGotoMarker0);
AddDefault(C,'Go to marker 1',ecGotoMarker1); AddDefault(C,'Go to marker 1',ecGotoMarker1);
AddDefault(C,'Go to marker 2',ecGotoMarker2); AddDefault(C,'Go to marker 2',ecGotoMarker2);
@ -2346,8 +2325,8 @@ begin
AddDefault(C,'Find block start',ecFindBlockStart); AddDefault(C,'Find block start',ecFindBlockStart);
AddDefault(C,'Goto include directive',ecGotoIncludeDirective); AddDefault(C,'Goto include directive',ecGotoIncludeDirective);
// source notebook // source notebook - without menu items in the IDE bar
C:=Categories[AddCategory('SourceNotebook',srkmCatSrcNoteBook,caAll)]; C:=Categories[AddCategory('SourceNotebook',srkmCatSrcNoteBook,caSrcEditOnly)];
AddDefault(C,'Go to next editor',ecNextEditor); AddDefault(C,'Go to next editor',ecNextEditor);
AddDefault(C,'Go to prior editor',ecPrevEditor); AddDefault(C,'Go to prior editor',ecPrevEditor);
AddDefault(C,'Add break point',ecAddBreakPoint); AddDefault(C,'Add break point',ecAddBreakPoint);
@ -2473,8 +2452,8 @@ begin
AddDefault(C,'Configure Help',ecConfigureHelp); AddDefault(C,'Configure Help',ecConfigureHelp);
AddDefault(C,'Context sensitive help',ecContextHelp); AddDefault(C,'Context sensitive help',ecContextHelp);
// designer // designer - without menu items in the IDE bar (at least no direct)
C:=Categories[AddCategory('Designer',lisKeyCatDesigner,caDesign)]; C:=Categories[AddCategory('Designer',lisKeyCatDesigner,caDesignOnly)];
AddDefault(C,'Copy selected Components to clipboard',ecCopyComponents); AddDefault(C,'Copy selected Components to clipboard',ecCopyComponents);
AddDefault(C,'Cut selected Components to clipboard',ecCutComponents); AddDefault(C,'Cut selected Components to clipboard',ecCutComponents);
AddDefault(C,'Paste Components from clipboard',ecPasteComponents); AddDefault(C,'Paste Components from clipboard',ecPasteComponents);
@ -2627,6 +2606,12 @@ var a,b,p:integer;
if (i and 4)>0 then Include(Result,ssAlt); if (i and 4)>0 then Include(Result,ssAlt);
end; end;
function OldKeyValuesToStr(const KeyA, KeyB: TIDEShortCut): string;
begin
Result:=IntToStr(KeyA.Key1) + ',' + ShiftStateToStr(KeyA.Shift1) + ',' +
IntToStr(KeyB.Key1) + ',' + ShiftStateToStr(KeyB.Shift1);
end;
// LoadFromXMLConfig // LoadFromXMLConfig
var var
FileVersion: integer; FileVersion: integer;
@ -2634,30 +2619,46 @@ var
Key1, Key2: word; Key1, Key2: word;
Shift1, Shift2: TShiftState; Shift1, Shift2: TShiftState;
begin begin
//debugln('TKeyCommandRelationList.LoadFromXMLConfig A ');
FileVersion:=XMLConfig.GetValue(Prefix+'Version/Value',0); FileVersion:=XMLConfig.GetValue(Prefix+'Version/Value',0);
ExtToolCount:=XMLConfig.GetValue(Prefix+'ExternalToolCount/Value',0); ExtToolCount:=XMLConfig.GetValue(Prefix+'ExternalToolCount/Value',0);
for a:=0 to FRelations.Count-1 do begin for a:=0 to FRelations.Count-1 do begin
Name:=lowercase(Relations[a].Name); Name:=lowercase(Relations[a].Name);
for b:=1 to length(Name) do for b:=1 to length(Name) do
if not (Name[b] in ['a'..'z','A'..'Z','0'..'9']) then Name[b]:='_'; if not (Name[b] in ['a'..'z','A'..'Z','0'..'9']) then Name[b]:='_';
with Relations[a] do begin GetDefaultKeyForCommand(Relations[a].Command,TheKeyA,TheKeyB);
GetDefaultKeyForCommand(Command,TheKeyA,TheKeyB); if FileVersion>2 then
DefaultStr:=KeyValuesToStr(TheKeyA, TheKeyB); DefaultStr:=KeyValuesToStr(TheKeyA, TheKeyB)
end; else
DefaultStr:=OldKeyValuesToStr(TheKeyA, TheKeyB);
//if Relations[a].Command=ecCopy then debugln(' DefaultStr=',DefaultStr);
if FileVersion<2 then if FileVersion<2 then
NewValue:=XMLConfig.GetValue(Prefix+Name,DefaultStr) NewValue:=XMLConfig.GetValue(Prefix+Name,DefaultStr)
else else
NewValue:=XMLConfig.GetValue(Prefix+Name+'/Value',DefaultStr); NewValue:=XMLConfig.GetValue(Prefix+Name+'/Value',DefaultStr);
//if Relations[a].Command=ecCopy then debugln(' NewValue=',NewValue);
p:=1; p:=1;
Key1:=word(ReadNextInt); Key1:=word(ReadNextInt);
Shift1:=IntToShiftState(ReadNextInt); Shift1:=IntToShiftState(ReadNextInt);
Key2:=word(ReadNextInt); if FileVersion>2 then begin
Shift2:=IntToShiftState(ReadNextInt); Key2:=word(ReadNextInt);
Shift2:=IntToShiftState(ReadNextInt);
end else begin
Key2:=0;
Shift2:=[];
end;
Relations[a].KeyA:=IDEShortCut(Key1, Shift1, Key2, Shift2); Relations[a].KeyA:=IDEShortCut(Key1, Shift1, Key2, Shift2);
Key1:=word(ReadNextInt); Key1:=word(ReadNextInt);
Shift1:=IntToShiftState(ReadNextInt); Shift1:=IntToShiftState(ReadNextInt);
Key2:=word(ReadNextInt); if FileVersion>2 then begin
Shift2:=IntToShiftState(ReadNextInt); Key2:=word(ReadNextInt);
Shift2:=IntToShiftState(ReadNextInt);
end else begin
Key2:=0;
Shift2:=[];
end;
Relations[a].KeyB:=IDEShortCut(Key1, Shift1, Key2, Shift2); Relations[a].KeyB:=IDEShortCut(Key1, Shift1, Key2, Shift2);
end; end;
Result:=true; Result:=true;

View File

@ -38,13 +38,19 @@ uses
Classes, SysUtils, LCLType; Classes, SysUtils, LCLType;
type type
TCommandArea = (caMenu, caSourceEditor, caDesigner); TCommandArea = (
caMenu,
caSourceEditor,
caDesigner
);
TCommandAreas = set of TCommandArea; TCommandAreas = set of TCommandArea;
const const
caAll = [caMenu, caSourceEditor, caDesigner]; caAll = [caMenu, caSourceEditor, caDesigner];
caMenuOnly = [caMenu]; caMenuOnly = [caMenu];
caSrcEdit = [caMenu,caSourceEditor]; caSrcEdit = [caMenu,caSourceEditor];
caSrcEditOnly = [caSourceEditor];
caDesign = [caMenu,caDesigner]; caDesign = [caMenu,caDesigner];
caDesignOnly = [caDesigner];
type type