From 166844b8e507d058dca6dd78432e7fc599c3738d Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 11 Oct 2011 07:45:04 +0000 Subject: [PATCH] IDE: improve the new Example manager GUI. git-svn-id: trunk@32814 - --- ide/lazarusidestrconsts.pas | 2 +- ide/manageexamples.lfm | 128 +++++++++++++++++++----------------- ide/manageexamples.pas | 44 ++++++++++--- 3 files changed, 101 insertions(+), 73 deletions(-) diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index e902ed7306..567bea5eda 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -420,6 +420,7 @@ resourcestring lisMenuBuildLazarusProf = 'Build Lazarus with profile: %s'; lisMenuConfigureBuildLazarus = 'Configure "Build Lazarus" ...'; + lisRootDirectoryForProjects = 'Root directory for projects'; lisMenuGeneralOptions = 'Options ...'; lisMenuEditCodeTemplates = 'Code Templates ...'; lisMenuCodeToolsDefinesEditor = 'CodeTools defines editor ...'; @@ -2846,7 +2847,6 @@ resourcestring lisLazBuildBuildSynEdit = 'Build SynEdit'; lisLazBuildBuildCodeTools = 'Build CodeTools'; lisLazBuildBuildIDE = 'Build IDE'; - lisLazBuildBuildExamples = 'Build examples'; lisLazBuildOptions = 'Options:'; lisLazBuildTargetOS = 'Target OS:'; lisLazBuildTargetCPU = 'Target CPU:'; diff --git a/ide/manageexamples.lfm b/ide/manageexamples.lfm index c403d014b1..fd300f2c3d 100644 --- a/ide/manageexamples.lfm +++ b/ide/manageexamples.lfm @@ -1,74 +1,39 @@ object ManageExamplesForm: TManageExamplesForm - Left = 389 + Left = 378 Height = 416 - Top = 162 - Width = 768 + Top = 161 + Width = 790 Caption = 'ManageExamplesForm' ClientHeight = 416 - ClientWidth = 768 + ClientWidth = 790 Position = poDesktopCenter LCLVersion = '0.9.31' - object SettingsGroupBox: TGroupBox - Left = 0 - Height = 80 - Top = 0 - Width = 768 - Align = alTop - Caption = 'Settings' - ClientHeight = 63 - ClientWidth = 764 - TabOrder = 0 - object RootDirectoryEdit: TDirectoryEdit - AnchorSideLeft.Control = RootDirectoryLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = RootDirectoryLabel - AnchorSideTop.Side = asrCenter - Left = 101 - Height = 23 - Top = 9 - Width = 480 - ShowHidden = False - ButtonWidth = 23 - NumGlyphs = 0 - BorderSpacing.Left = 7 - MaxLength = 0 - TabOrder = 0 - OnChange = RootDirectoryEditChange - end - object RootDirectoryLabel: TLabel - Left = 6 - Height = 16 - Top = 12 - Width = 88 - Caption = 'Root directory' - ParentColor = False - end - end object ProjectsGroupBox: TGroupBox - AnchorSideLeft.Control = SettingsGroupBox - AnchorSideTop.Control = SettingsGroupBox + AnchorSideLeft.Control = RootRadioGroup + AnchorSideTop.Control = RootDirectoryEdit AnchorSideTop.Side = asrBottom AnchorSideRight.Control = ActionGroupBox AnchorSideBottom.Control = ButtonPanel1 - Left = 0 - Height = 290 - Top = 80 - Width = 549 + Left = 1 + Height = 227 + Top = 143 + Width = 564 Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 13 Caption = 'Projects' - ClientHeight = 273 - ClientWidth = 545 - TabOrder = 1 + ClientHeight = 210 + ClientWidth = 560 + TabOrder = 0 object ProjectsListBox: TListBox Left = 0 - Height = 273 + Height = 210 Top = 0 - Width = 545 + Width = 560 Align = alClient ItemHeight = 0 MultiSelect = True OnSelectionChange = ProjectsListBoxSelectionChange - ScrollWidth = 541 + ScrollWidth = 556 TabOrder = 0 TopIndex = -1 end @@ -77,7 +42,7 @@ object ManageExamplesForm: TManageExamplesForm Left = 6 Height = 34 Top = 376 - Width = 756 + Width = 778 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True HelpButton.Name = 'HelpButton' @@ -86,27 +51,26 @@ object ManageExamplesForm: TManageExamplesForm CloseButton.DefaultCaption = True CancelButton.Name = 'CancelButton' CancelButton.DefaultCaption = True - TabOrder = 2 + TabOrder = 1 ShowButtons = [pbClose, pbHelp] end object ActionGroupBox: TGroupBox AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = SettingsGroupBox - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = SettingsGroupBox + AnchorSideTop.Control = ProjectsGroupBox + AnchorSideRight.Control = RootRadioGroup AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = ProjectsGroupBox AnchorSideBottom.Side = asrBottom - Left = 552 - Height = 290 - Top = 80 + Left = 568 + Height = 227 + Top = 143 Width = 216 Anchors = [akTop, akRight, akBottom] BorderSpacing.Left = 3 Caption = 'Action' - ClientHeight = 273 + ClientHeight = 210 ClientWidth = 212 - TabOrder = 3 + TabOrder = 2 object Label1: TLabel AnchorSideTop.Side = asrBottom AnchorSideRight.Side = asrBottom @@ -160,4 +124,44 @@ object ManageExamplesForm: TManageExamplesForm TabOrder = 3 end end + object RootRadioGroup: TRadioGroup + Left = 1 + Height = 97 + Top = 5 + Width = 783 + Anchors = [akTop, akLeft, akRight] + AutoFill = True + BorderSpacing.Top = 5 + Caption = 'Root directory for projects' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 2 + Columns = 2 + OnClick = RootRadioGroupClick + TabOrder = 3 + end + object RootDirectoryEdit: TDirectoryEdit + AnchorSideLeft.Control = RootRadioGroup + AnchorSideTop.Control = RootRadioGroup + AnchorSideTop.Side = asrBottom + AnchorSideRight.Side = asrBottom + Left = 4 + Height = 23 + Top = 107 + Width = 743 + ShowHidden = False + ButtonWidth = 23 + NumGlyphs = 0 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 3 + BorderSpacing.Top = 5 + MaxLength = 0 + TabOrder = 4 + OnChange = RootDirectoryEditChange + end end diff --git a/ide/manageexamples.pas b/ide/manageexamples.pas index f0d14df26b..c2d26c376a 100644 --- a/ide/manageexamples.pas +++ b/ide/manageexamples.pas @@ -18,26 +18,27 @@ type OpenSelectedButton: TBitBtn; Label1: TLabel; ProjectsListBox: TListBox; + RootRadioGroup: TRadioGroup; SelectAllButton: TBitBtn; ButtonPanel1: TButtonPanel; RootDirectoryEdit: TDirectoryEdit; ActionGroupBox: TGroupBox; - RootDirectoryLabel: TLabel; SelectNoneButton: TBitBtn; - SettingsGroupBox: TGroupBox; ProjectsGroupBox: TGroupBox; procedure BuildAllSelectedButtonClick(Sender: TObject); procedure OpenSelectedButtonClick(Sender: TObject); procedure ProjectsListBoxSelectionChange(Sender: TObject; User: boolean); procedure RootDirectoryEditChange(Sender: TObject); + procedure RootRadioGroupClick(Sender: TObject); procedure SelectAllButtonClick(Sender: TObject); procedure SelectNoneButtonClick(Sender: TObject); procedure ShowPathCheckBoxChange(Sender: TObject); private + fOtherPathIndex: Integer; + fSelectedFilename: string; fChangingSelections: Boolean; fUpdating: Boolean; fIdleConnected: boolean; - fSelectedFilename: string; procedure FillProjectList(Immediately: boolean); procedure SetIdleConnected(const AValue: boolean); procedure OnIdle(Sender: TObject; var Done: Boolean); @@ -57,16 +58,10 @@ implementation function ShowManageExamplesDlg: TModalResult; var theForm: TManageExamplesForm; - path: String; begin Result:=mrCancel; theForm:=TManageExamplesForm.Create(Nil); try - path:=EnvironmentOptions.LazarusDirectory+'examples'; - if DirectoryExistsUTF8(path) then begin - theForm.RootDirectoryEdit.Text:=path; - theForm.FillProjectList(False); - end; Result:=theForm.ShowModal; if Result=mrYes then MainIDEInterface.DoOpenProjectFile(theForm.fSelectedFilename, @@ -105,10 +100,30 @@ end; { TManageExamplesForm } constructor TManageExamplesForm.Create(AnOwner: TComponent); +var + path: String; begin inherited Create(AnOwner); fChangingSelections:=False; fUpdating:=False; + Caption:=lisKMExampleProjects; + RootRadioGroup.Caption:=lisRootDirectoryForProjects; + + // Add some paths for example projects + RootRadioGroup.Items.Add(EnvironmentOptions.LazarusDirectory); // Lazarus root + + path:=EnvironmentOptions.LazarusDirectory+'examples'; + if DirectoryExistsUTF8(path) then // Select this one + RootRadioGroup.ItemIndex:=RootRadioGroup.Items.Add(path); + + path:=EnvironmentOptions.LazarusDirectory+'components/codetools/examples/'; + if DirectoryExistsUTF8(path) then + RootRadioGroup.Items.Add(path); + + fOtherPathIndex:=RootRadioGroup.Items.Add('Other'); + + RootDirectoryEdit.Text:=RootRadioGroup.Items[RootRadioGroup.ItemIndex]; + FillProjectList(False); OpenSelectedButton.Caption:=lisExamplesOpenFirstSelected; BuildAllSelectedButton.Caption:=lisExamplesBuildAllSelected; @@ -159,7 +174,6 @@ end; procedure TManageExamplesForm.OnIdle(Sender: TObject; var Done: Boolean); begin - if Done then ; IdleConnected:=false; FillProjectList(true); end; @@ -169,6 +183,16 @@ begin FillProjectList(False); end; +procedure TManageExamplesForm.RootRadioGroupClick(Sender: TObject); +begin + if RootRadioGroup.ItemIndex=fOtherPathIndex then + RootDirectoryEdit.Enabled:=True + else begin + RootDirectoryEdit.Enabled:=False; + RootDirectoryEdit.Text:=RootRadioGroup.Items[RootRadioGroup.ItemIndex]; + end; +end; + procedure TManageExamplesForm.ShowPathCheckBoxChange(Sender: TObject); begin FillProjectList(False);