From 9f6ed9ea7dc3f605b6cc8407098b6a04a1cc88e7 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 11 Apr 2009 17:36:59 +0000 Subject: [PATCH] IDE: unused units: enable ok button depending on selection git-svn-id: trunk@19355 - --- ide/unusedunitsdlg.lfm | 10 ++++++---- ide/unusedunitsdlg.lrs | 12 +++++++----- ide/unusedunitsdlg.pas | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/ide/unusedunitsdlg.lfm b/ide/unusedunitsdlg.lfm index 9eedcbc418..d3e649163f 100644 --- a/ide/unusedunitsdlg.lfm +++ b/ide/unusedunitsdlg.lfm @@ -19,14 +19,16 @@ object UnusedUnitsDialog: TUnusedUnitsDialog ShowBevel = False end object UnitsTreeView: TTreeView - Left = 0 - Height = 317 - Top = 0 - Width = 340 + Left = 6 + Height = 311 + Top = 6 + Width = 328 Align = alClient + BorderSpacing.Around = 6 DefaultItemHeight = 19 ScrollBars = ssAutoBoth TabOrder = 1 + OnSelectionChanged = UnitsTreeViewSelectionChanged Options = [tvoAllowMultiselect, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips] end end diff --git a/ide/unusedunitsdlg.lrs b/ide/unusedunitsdlg.lrs index cf41a908bb..fa3fb1a8c3 100644 --- a/ide/unusedunitsdlg.lrs +++ b/ide/unusedunitsdlg.lrs @@ -7,9 +7,11 @@ LazarusResources.Add('TUnusedUnitsDialog','FORMDATA',[ +'T'#1#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'#6#6'0.9.27'#0#12'TButtonPa' +'nel'#12'ButtonPanel1'#4'Left'#2#6#6'Height'#2'$'#3'Top'#3'C'#1#5'Width'#3'H' +#1#8'TabOrder'#2#0#11'ShowButtons'#11#4'pbOK'#8'pbCancel'#0#9'ShowBevel'#8#0 - +#0#9'TTreeView'#13'UnitsTreeView'#4'Left'#2#0#6'Height'#3'='#1#3'Top'#2#0#5 - +'Width'#3'T'#1#5'Align'#7#8'alClient'#17'DefaultItemHeight'#2#19#10'ScrollBa' - +'rs'#7#10'ssAutoBoth'#8'TabOrder'#2#1#7'Options'#11#19'tvoAllowMultiselect' - +#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsedNodes'#14'tvo' - +'ShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0#0#0#0 + +#0#9'TTreeView'#13'UnitsTreeView'#4'Left'#2#6#6'Height'#3'7'#1#3'Top'#2#6#5 + +'Width'#3'H'#1#5'Align'#7#8'alClient'#20'BorderSpacing.Around'#2#6#17'Defaul' + +'tItemHeight'#2#19#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#1#18'OnSele' + +'ctionChanged'#7#29'UnitsTreeViewSelectionChanged'#7'Options'#11#19'tvoAllow' + +'Multiselect'#17'tvoAutoItemHeight'#16'tvoHideSelection'#21'tvoKeepCollapsed' + +'Nodes'#14'tvoShowButtons'#12'tvoShowLines'#11'tvoShowRoot'#11'tvoToolTips'#0 + +#0#0#0 ]); diff --git a/ide/unusedunitsdlg.pas b/ide/unusedunitsdlg.pas index 22e74b2714..9a384dcf3a 100644 --- a/ide/unusedunitsdlg.pas +++ b/ide/unusedunitsdlg.pas @@ -46,6 +46,7 @@ type UnitsTreeView: TTreeView; procedure FormCreate(Sender: TObject); procedure OkClick(Sender: TObject); + procedure UnitsTreeViewSelectionChanged(Sender: TObject); private FUnits: TStrings; ImgIDInterface: LongInt; @@ -54,6 +55,7 @@ type ImgIDNone: LongInt; procedure SetUnits(const AValue: TStrings); procedure RebuildUnitsTreeView; + procedure UpdateButtons; public function GetSelectedUnits: TStrings; property Units: TStrings read FUnits write SetUnits; @@ -136,6 +138,11 @@ begin end; +procedure TUnusedUnitsDialog.UnitsTreeViewSelectionChanged(Sender: TObject); +begin + UpdateButtons; +end; + procedure TUnusedUnitsDialog.SetUnits(const AValue: TStrings); begin if FUnits=AValue then exit; @@ -187,6 +194,16 @@ begin IntfTreeNode.Expanded:=true; ImplTreeNode.Expanded:=true; UnitsTreeView.EndUpdate; + UpdateButtons; +end; + +procedure TUnusedUnitsDialog.UpdateButtons; +var + RemoveUnits: TStrings; +begin + RemoveUnits:=GetSelectedUnits; + ButtonPanel1.OKButton.Enabled:=RemoveUnits.Count>0; + RemoveUnits.Free; end; function TUnusedUnitsDialog.GetSelectedUnits: TStrings;