From e77c7bec7b05169133857378217a63dc9dbcbf6f Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 19 Dec 2009 23:41:24 +0000 Subject: [PATCH] IDE: build modes: stared group includes git-svn-id: trunk@23199 - --- ide/compileroptions.pp | 10 ++++ ide/frames/buildmodeseditor.pas | 103 ++++++++++++++++++++++++++++++-- lcl/grids.pas | 1 + 3 files changed, 109 insertions(+), 5 deletions(-) diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 5588373572..80aa5aa3c2 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -181,6 +181,7 @@ type procedure ClearIncludedBys; procedure Include(aMode: TBuildMode); procedure Exclude(aMode: TBuildMode); + function IsIncludedBy(aMode: TBuildMode): boolean; function AddFlag(FlagType: TBuildModeFlagType; Value: string; Variable: string = ''): TBuildModeFlag; function InsertFlag(InsertPos: integer; FlagType: TBuildModeFlagType; @@ -5026,6 +5027,15 @@ begin if aMode<>nil then aMode.FIncludedBy.Remove(Self); end; +function TBuildMode.IsIncludedBy(aMode: TBuildMode): boolean; +var + i: Integer; +begin + for i:=0 to IncludedByCount-1 do + if IncludedBy[i]=aMode then exit(true); + Result:=false; +end; + function TBuildMode.AddFlag(FlagType: TBuildModeFlagType; Value: string; Variable: string): TBuildModeFlag; begin diff --git a/ide/frames/buildmodeseditor.pas b/ide/frames/buildmodeseditor.pas index 860ce44bb6..1dd90e5ce3 100644 --- a/ide/frames/buildmodeseditor.pas +++ b/ide/frames/buildmodeseditor.pas @@ -26,7 +26,7 @@ interface uses Classes, SysUtils, LCLProc, Controls, FileUtil, LResources, Forms, Grids, - Menus, ComCtrls, Dialogs, AvgLvlTree, DefineTemplates, + Menus, ComCtrls, Dialogs, AvgLvlTree, DefineTemplates, StdCtrls, ProjectIntf, IDEImagesIntf, PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions, IDEProcs; @@ -73,6 +73,10 @@ type out Vars: TLazBuildVariables; out aVariable: TLazBuildVariable); function SelectCell(aCol, aRow: Integer): boolean; override; procedure BuildModesGridEditButtonClick(Sender: TObject); + procedure GetCheckBoxState(const aCol, aRow: Integer; + var aState: TCheckboxState); override; + procedure SetCheckboxState(const aCol, aRow: Integer; + const aState: TCheckboxState); override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -81,6 +85,7 @@ type procedure DeleteSelectedModeRow; function BuildGroupToCol(GroupIndex: integer): integer; function ColToBuildGroup(aCol: integer): integer; + function CellToInclude(aCol, aRow: integer): boolean; property Graph: TBuildModeGraph read FGraph; procedure RebuildGrid; // call this after Graph changed property ModeRowCount: integer read GetModeRowCount; @@ -185,8 +190,13 @@ begin else Cells[0,i]:=''; // included by - for j:=0 to GroupModeCount-1 do - Cells[j+1,i]:=''; + for j:=0 to GroupModeCount-1 do begin + if CellToInclude(j+1,i) then + Cells[j+1,i]:=Columns[j+1].ValueChecked + else + Cells[j+1,i]:=Columns[j+1].ValueUnchecked; + DebugLn(['TBuildModesGrid.FillGridRow ',j+1,' ',i,' ',Cells[j+1,i]]); + end; // type + value CurFlag:=CurRow.Flag; TypeStr:=''; @@ -474,6 +484,69 @@ begin end; end; +procedure TBuildModesGrid.GetCheckBoxState(const aCol, aRow: Integer; + var aState: TCheckboxState); +var + CurModeRow: TBuildModeGridRow; + GrpID: LongInt; +begin + CurModeRow:=GetSelectedModeRow; + aState:=cbUnchecked; + if (CurModeRow<>nil) and (CurModeRow.IndexInGroup=0) then begin + GrpID:=ColToBuildGroup(aCol); + if (GrpID>=0) and (GrpIDnil) and (CurModeRow.IndexInGroup=0) then begin + GrpID:=ColToBuildGroup(aCol); + if (GrpID>=0) and (GrpID(aState=cbChecked) then + begin + // state changed + DebugLn(['TBuildModesGrid.SetCheckboxState STATE CHANGED']); + if aState=cbChecked then begin + GrpMode.Include(CurModeRow.Mode); + NewState:=cbChecked; + end else begin + GrpMode.Exclude(CurModeRow.Mode); + end; + end else if CurModeRow.Mode.IsIncludedBy(GrpMode) then begin + // state kept + DebugLn(['TBuildModesGrid.SetCheckboxState STATE KEPT']); + NewState:=cbChecked; + end; + end else begin + // invalid column + DebugLn(['TBuildModesGrid.SetCheckboxState invalid col ',ACol,' ',GrpId,' ',GroupModeCount]); + end; + end else begin + // invalid row + DebugLn(['TBuildModesGrid.SetCheckboxState invalid row']); + end; + DebugLn(['TBuildModesGrid.SetCheckboxState END ',aCol,' ',aRow,' ',ord(NewState)]); + inherited SetCheckboxState(aCol, aRow, NewState); +end; + function TBuildModesGrid.GetSelectedModeRow: TBuildModeGridRow; begin if (Row<1) or (Row>ModeRowCount) then @@ -518,6 +591,8 @@ begin InsertCol:=BuildGroupToCol(GroupModeCount-1); InsertColRow(true,InsertCol); Columns[InsertCol].Title.Caption:=' '; + Columns[InsertCol].ButtonStyle:=cbsCheckboxColumn; + inc(FGroupModeCount); end else begin CurFlag:=Result.AddFlag(bmftNone,''); InsertPos:=ModeRowCount; @@ -619,6 +694,22 @@ begin Result:=GroupModeCount-aCol; end; +function TBuildModesGrid.CellToInclude(aCol, aRow: integer): boolean; +var + GrpID: LongInt; + CurMode: TBuildModeGridRow; +begin + if (aRow>=1) and (ARow<=GroupModeCount) then begin + CurMode:=ModeRows[aRow-1]; + GrpID:=ColToBuildGroup(aCol); + if (GrpID>=0) and (GrpID