improve viewunits/viewform dialog

git-svn-id: trunk@13816 -
This commit is contained in:
paul 2008-01-21 05:39:56 +00:00
parent 9a0d779e49
commit 892e84240f
3 changed files with 80 additions and 84 deletions

View File

@ -15,9 +15,9 @@ object ViewUnitDialog: TViewUnitDialog
AnchorSideRight.Control = btnCancel
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 158
Height = 30
Top = 264
Left = 155
Height = 26
Top = 268
Width = 75
Anchors = [akRight, akBottom]
AutoSize = True
@ -38,10 +38,10 @@ object ViewUnitDialog: TViewUnitDialog
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 239
Height = 30
Top = 264
Width = 75
Left = 236
Height = 26
Top = 268
Width = 78
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
@ -64,6 +64,7 @@ object ViewUnitDialog: TViewUnitDialog
Anchors = [akRight]
BorderSpacing.Around = 6
OnChange = EditChange
OnEnter = EditEnter
OnKeyDown = EditKeyDown
TabOrder = 3
end
@ -72,7 +73,7 @@ object ViewUnitDialog: TViewUnitDialog
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = MultiSelectCheckBox
Left = 6
Height = 197
Height = 200
Top = 37
Width = 308
Align = alTop
@ -89,9 +90,9 @@ object ViewUnitDialog: TViewUnitDialog
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = btnCancel
Left = 6
Height = 18
Top = 240
Width = 78
Height = 19
Top = 243
Width = 81
Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6
Caption = 'Multi Select'
@ -103,8 +104,8 @@ object ViewUnitDialog: TViewUnitDialog
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 30
Top = 264
Height = 26
Top = 268
Width = 75
Anchors = [akLeft, akBottom]
AutoSize = True

View File

@ -7,37 +7,37 @@ LazarusResources.Add('TViewUnitDialog','FORMDATA',[
+'nu'#0#7'Caption'#6#18'View Project Units'#12'ClientHeight'#3','#1#11'Client'
+'Width'#3'@'#1#8'Position'#7#14'poScreenCenter'#0#7'TBitBtn'#5'btnOK'#23'Anc'
+'horSideRight.Control'#7#9'btnCancel'#24'AnchorSideBottom.Control'#7#5'Owner'
+#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3#158#0#6'Height'#2#30#3'T'
+'op'#3#8#1#5'Width'#2'K'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'#9
+#20'BorderSpacing.Around'#2#6#7'Caption'#6#3'&OK'#21'Constraints.MinHeight'#2
+#25#20'Constraints.MinWidth'#2'K'#7'Default'#9#4'Kind'#7#4'bkOK'#11'ModalRes'
+'ult'#2#1#9'NumGlyphs'#2#0#7'OnClick'#7#10'BTNOKCLICK'#8'TabOrder'#2#1#0#0#7
+'TBitBtn'#9'btnCancel'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRi'
+'ght.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSi'
+'deBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Lef'
+'t'#3#239#0#6'Height'#2#30#3'Top'#3#8#1#5'Width'#2'K'#7'Anchors'#11#7'akRigh'
+'t'#8'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#6'Cancel'#9#7'C'
+'aption'#6#6'Cancel'#21'Constraints.MinHeight'#2#25#20'Constraints.MinWidth'
+#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3#155#0#6'Height'#2#26#3'T'
+'op'#3#12#1#5'Width'#2'K'#7'Anchors'#11#7'akRight'#8'akBottom'#0#8'AutoSize'
+#9#20'BorderSpacing.Around'#2#6#7'Caption'#6#3'&OK'#21'Constraints.MinHeight'
+#2#25#20'Constraints.MinWidth'#2'K'#7'Default'#9#4'Kind'#7#4'bkOK'#11'ModalR'
+'esult'#2#1#9'NumGlyphs'#2#0#7'OnClick'#7#10'BTNOKCLICK'#8'TabOrder'#2#1#0#0
+#7'TBitBtn'#9'btnCancel'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSide'
+'Right.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'Anchor'
+'SideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'L'
+'eft'#3#236#0#6'Height'#2#26#3'Top'#3#12#1#5'Width'#2'N'#7'Anchors'#11#7'akR'
+'ight'#8'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#6'Cancel'#9#7
+'Caption'#6#6'Cancel'#21'Constraints.MinHeight'#2#25#20'Constraints.MinWidth'
+#2'K'#4'Kind'#7#8'bkCancel'#11'ModalResult'#2#2#9'NumGlyphs'#2#0#7'OnClick'#7
+#14'BTNCANCELCLICK'#8'TabOrder'#2#2#0#0#5'TEdit'#4'Edit'#4'Left'#2#6#6'Heigh'
+'t'#2#25#3'Top'#2#6#5'Width'#3'4'#1#5'Align'#7#5'alTop'#7'Anchors'#11#7'akRi'
+'ght'#0#20'BorderSpacing.Around'#2#6#8'OnChange'#7#10'EditChange'#9'OnKeyDow'
+'n'#7#11'EditKeyDown'#8'TabOrder'#2#3#0#0#8'TListBox'#7'Listbox'#18'AnchorSi'
+'deTop.Side'#7#9'asrBottom'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'Ancho'
+'rSideBottom.Control'#7#19'MultiSelectCheckBox'#4'Left'#2#6#6'Height'#3#197#0
+#3'Top'#2'%'#5'Width'#3'4'#1#5'Align'#7#5'alTop'#7'Anchors'#11#8'akBottom'#0
+#20'BorderSpacing.Around'#2#6#16'ClickOnSelChange'#8#7'OnClick'#7#12'Listbox'
+'Click'#10'OnDblClick'#7#10'BTNOKCLICK'#9'OnKeyDown'#7#14'ListboxKeyDown'#8
+'TabOrder'#2#0#0#0#9'TCheckBox'#19'MultiSelectCheckBox'#22'AnchorSideLeft.Co'
+'ntrol'#7#5'Owner'#18'AnchorSideTop.Side'#7#9'asrBottom'#24'AnchorSideBottom'
+'.Control'#7#9'btnCancel'#4'Left'#2#6#6'Height'#2#18#3'Top'#3#240#0#5'Width'
+#2'N'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#7'C'
+'aption'#6#12'Multi Select'#7'OnClick'#7#24'MultiselectCheckBoxClick'#8'TabO'
+'rder'#2#4#0#0#7'TBitBtn'#10'HelpButton'#22'AnchorSideLeft.Control'#7#5'Owne'
+'r'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'as'
+'rBottom'#4'Left'#2#6#6'Height'#2#30#3'Top'#3#8#1#5'Width'#2'K'#7'Anchors'#11
+#6'akLeft'#8'akBottom'#0#8'AutoSize'#9#20'BorderSpacing.Around'#2#6#7'Captio'
+'n'#6#5'&Help'#21'Constraints.MinHeight'#2#25#20'Constraints.MinWidth'#2'K'#4
+'Kind'#7#6'bkHelp'#9'NumGlyphs'#2#0#7'OnClick'#7#15'HelpButtonClick'#8'TabOr'
+'der'#2#5#0#0#0
+'ght'#0#20'BorderSpacing.Around'#2#6#8'OnChange'#7#10'EditChange'#7'OnEnter'
+#7#9'EditEnter'#9'OnKeyDown'#7#11'EditKeyDown'#8'TabOrder'#2#3#0#0#8'TListBo'
+'x'#7'Listbox'#18'AnchorSideTop.Side'#7#9'asrBottom'#20'AnchorSideRight.Side'
+#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#19'MultiSelectCheckBox'#4'Lef'
+'t'#2#6#6'Height'#3#200#0#3'Top'#2'%'#5'Width'#3'4'#1#5'Align'#7#5'alTop'#7
+'Anchors'#11#8'akBottom'#0#20'BorderSpacing.Around'#2#6#16'ClickOnSelChange'
+#8#7'OnClick'#7#12'ListboxClick'#10'OnDblClick'#7#10'BTNOKCLICK'#9'OnKeyDown'
+#7#14'ListboxKeyDown'#8'TabOrder'#2#0#0#0#9'TCheckBox'#19'MultiSelectCheckBo'
+'x'#22'AnchorSideLeft.Control'#7#5'Owner'#18'AnchorSideTop.Side'#7#9'asrBott'
+'om'#24'AnchorSideBottom.Control'#7#9'btnCancel'#4'Left'#2#6#6'Height'#2#19#3
+'Top'#3#243#0#5'Width'#2'Q'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#20'BorderS'
+'pacing.Around'#2#6#7'Caption'#6#12'Multi Select'#7'OnClick'#7#24'Multiselec'
+'tCheckBoxClick'#8'TabOrder'#2#4#0#0#7'TBitBtn'#10'HelpButton'#22'AnchorSide'
+'Left.Control'#7#5'Owner'#24'AnchorSideBottom.Control'#7#5'Owner'#21'AnchorS'
+'ideBottom.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#26#3'Top'#3#12#1#5'W'
+'idth'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#8'AutoSize'#9#20'BorderSpa'
+'cing.Around'#2#6#7'Caption'#6#5'&Help'#21'Constraints.MinHeight'#2#25#20'Co'
+'nstraints.MinWidth'#2'K'#4'Kind'#7#6'bkHelp'#9'NumGlyphs'#2#0#7'OnClick'#7
+#15'HelpButtonClick'#8'TabOrder'#2#5#0#0#0
]);

View File

@ -39,8 +39,8 @@ unit ViewUnit_Dlg;
interface
uses
SysUtils, Classes, Controls, Forms, Dialogs, LResources, Buttons, StdCtrls,
LazarusIdeStrConsts, LCLType, IDEWindowIntf, IDEContextHelpEdit;
SysUtils, Classes, Math, Controls, Forms, Dialogs, LResources, Buttons, StdCtrls,
LazarusIdeStrConsts, LCLType, LCLIntf, LMessages, IDEWindowIntf, IDEContextHelpEdit;
type
TViewUnitsEntry = class
@ -61,6 +61,7 @@ type
btnCancel: TBitBtn;
MultiSelectCheckBox: TCheckBox;
procedure EditChange(Sender: TObject);
procedure EditEnter(Sender: TObject);
procedure EditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure HelpButtonClick(Sender: TObject);
Procedure btnOKClick(Sender :TObject);
@ -69,8 +70,7 @@ type
procedure ListboxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure MultiselectCheckBoxClick(Sender :TObject);
private
FBlockEditChange: Boolean;
FBlockListBoxChange: Boolean;
procedure LM_USER1(var Message: TLMessage); message LM_USER + 1;
public
constructor Create(TheOwner: TComponent); override;
end;
@ -152,8 +152,6 @@ begin
CancelControl := btnCancel;
MultiSelectCheckBox.Caption := dlgMultiSelect;
MultiSelectCheckBox.Left := btnOk.Left;
FBlockEditChange := False;
FBlockListBoxChange := False;
end;
Procedure TViewUnitDialog.btnOKClick(Sender : TOBject);
@ -171,32 +169,28 @@ procedure TViewUnitDialog.EditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure MoveItemIndex(d: integer); inline;
var
NewIndex: Integer;
begin
d := ListBox.ItemIndex + d;
if (d >= 0) and (d < ListBox.Items.Count) then
begin
FBlockEditChange := True;
FBlockListBoxChange := True;
ListBox.ItemIndex := d;
Edit.Text := ListBox.Items[d];
Edit.SelectAll;
FBlockListBoxChange := False;
FBlockEditChange := False;
end;
NewIndex := Min(ListBox.Items.Count - 1, Max(0, ListBox.ItemIndex + D));
ListBox.ItemIndex := NewIndex;
ListBoxClick(nil);
end;
function PageCount: Integer;
begin
if ListBox.ItemHeight > 0 then
Result := ListBox.Height div ListBox.ItemHeight
else
Result := 0;
end;
begin
case Key of
VK_UP:
begin
MoveItemIndex(-1);
Key := 0;
end;
VK_DOWN:
begin
MoveItemIndex(1);
Key := 0;
end;
VK_UP: MoveItemIndex(-1);
VK_DOWN: MoveItemIndex(1);
VK_NEXT: MoveItemIndex(PageCount);
VK_PRIOR: MoveItemIndex(-PageCount);
VK_RETURN: btnOKClick(nil);
end;
end;
@ -205,20 +199,20 @@ procedure TViewUnitDialog.EditChange(Sender: TObject);
var
Index: Integer;
begin
if FBlockEditChange then
Exit;
FBlockListBoxChange := True;
Index := SearchItem(ListBox.Items, Edit.Text);
// WriteLn('Index = ', Index);
ListBox.ItemIndex := Index;
if ListBox.MultiSelect then
begin
ListBox.ClearSelection;
if Index <> -1 then
ListBox.Selected[Index] := True;
end;
FBlockListBoxChange := False;
end;
procedure TViewUnitDialog.EditEnter(Sender: TObject);
begin
PostMessage(Handle, LM_USER + 1, 0, 0);
end;
Procedure TViewUnitDialog.btnCancelClick(Sender : TOBject);
@ -229,15 +223,9 @@ end;
procedure TViewUnitDialog.ListboxClick(Sender: TObject);
begin
if FBlockListBoxChange then
Exit;
FBlockEditChange := True;
if ListBox.ItemIndex <> -1 then
Edit.Text := ListBox.Items[ListBox.ItemIndex]
else
Edit.Text := '';
FBlockEditChange := False;
Edit.Text := ListBox.Items[ListBox.ItemIndex];
PostMessage(Handle, LM_USER + 1, 0, 0);
end;
procedure TViewUnitDialog.ListboxKeyDown(Sender: TObject; var Key: Word;
@ -252,6 +240,13 @@ begin
ListBox.Multiselect := MultiselectCheckBox.Checked;
end;
procedure TViewUnitDialog.LM_USER1(var Message: TLMessage);
begin
Edit.SelectAll;
Edit.SetFocus;
end;
initialization
{$I viewunit_dlg.lrs}