IDE: Hide CheckBox in grid for build modes for default mode, replace error message dialog with a label.

git-svn-id: trunk@42001 -
This commit is contained in:
juha 2013-07-05 13:25:44 +00:00
parent 0a152e28e1
commit 25f4b56aca
2 changed files with 51 additions and 38 deletions

View File

@ -1,7 +1,7 @@
object BuildModesForm: TBuildModesForm
Left = 337
Left = 335
Height = 366
Top = 564
Top = 486
Width = 612
Caption = 'BuildModesForm'
ClientHeight = 366
@ -20,14 +20,14 @@ object BuildModesForm: TBuildModesForm
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
Caption = 'BuildModesGroupBox'
ClientHeight = 288
ClientHeight = 286
ClientWidth = 596
TabOrder = 0
object BuildModesStringGrid: TStringGrid
AnchorSideTop.Control = BuildModeAddSpeedButton
AnchorSideTop.Side = asrBottom
Left = 0
Height = 266
Height = 264
Top = 22
Width = 596
Align = alBottom
@ -39,13 +39,13 @@ object BuildModesForm: TBuildModesForm
ButtonStyle = cbsCheckboxColumn
MaxSize = 50
Title.Caption = 'Active'
Width = 198
Width = 197
end
item
ButtonStyle = cbsCheckboxColumn
MaxSize = 50
Title.Caption = 'InSession'
Width = 198
Width = 197
end
item
MaxSize = 500
@ -57,11 +57,12 @@ object BuildModesForm: TBuildModesForm
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
TabOrder = 0
OnCheckboxToggled = BuildModesCheckboxToggled
OnDrawCell = BuildModesStringGridDrawCell
OnSelection = BuildModesStringGridSelection
OnValidateEntry = BuildModesStringGridValidateEntry
ColWidths = (
198
198
197
197
198
)
end
@ -125,11 +126,19 @@ object BuildModesForm: TBuildModesForm
ShowHint = True
ParentShowHint = False
end
object NoteLabel: TLabel
Left = 160
Height = 15
Top = 3
Width = 63
Caption = 'NoteLabel'
ParentColor = False
end
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 36
Top = 324
Height = 41
Top = 319
Width = 600
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True

View File

@ -30,10 +30,10 @@ unit BuildModesManager;
interface
uses
Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls,
Grids, Buttons, Menus, ButtonPanel, LCLProc, IDEOptionsIntf, IDEDialogs,
TransferMacros, Project, LazarusIDEStrConsts,
CompilerOptions, Compiler_ModeMatrix, BuildModeDiffDlg;
Classes, SysUtils, Forms, Controls, Dialogs, StdCtrls, Grids, Buttons, Menus,
ButtonPanel, LCLProc, Graphics, IDEOptionsIntf, IDEDialogs, TransferMacros,
Project, LazarusIDEStrConsts, CompilerOptions, Compiler_ModeMatrix,
BuildModeDiffDlg;
type
@ -49,6 +49,9 @@ type
BuildModesPopupMenu: TPopupMenu;
BuildModesStringGrid: TStringGrid;
ButtonPanel1: TButtonPanel;
NoteLabel: TLabel;
procedure BuildModesStringGridDrawCell(Sender: TObject; aCol,
aRow: Integer; aRect: TRect; aState: TGridDrawState);
procedure CancelButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -78,7 +81,6 @@ type
procedure UpdateBuildModeButtons;
procedure SetShowSession(const AValue: boolean);
procedure DoShowSession;
procedure UpdateDialogCaption;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -199,7 +201,6 @@ end;
procedure TBuildModesForm.FormShow(Sender: TObject);
begin
// options dialog
UpdateDialogCaption;
BuildModesGroupBox.Caption:=lisBuildModes;
DoShowSession;
// modes
@ -350,9 +351,7 @@ begin
if (aState=cbChecked) and (i=0) then
begin
Grid.Cells[aCol,aRow]:=Grid.Columns[aCol].ValueUnchecked;
IDEMessageDialog(lisCCOErrorCaption,
lisTheFirstBuildModeIsTheDefaultModeAndMustBeStoredIn,
mtError,[mbCancel]);
NoteLabel.Caption:=lisTheDefaultModeMustBeStoredInProject;
exit;
end;
CurMode.InSession:=aState=cbChecked;
@ -384,8 +383,8 @@ begin
if b and (i=0) then
begin
NewValue:=OldValue;
IDEMessageDialog(lisCCOErrorCaption,lisTheFirstBuildModeIsTheDefaultModeAndMustBeStoredIn,
mtError,[mbCancel]);
IDEMessageDialog(lisCCOErrorCaption,lisTheDefaultModeMustBeStoredInProject,
mtError,[mbCancel]);
exit;
end;
CurMode.InSession:=b;
@ -412,7 +411,7 @@ begin
CurMode.Identifier:=s;
end;
end;
UpdateDialogCaption;
NoteLabel.Caption:='';
end;
procedure TBuildModesForm.FillBuildModesGrid(aOnlyActiveState: Boolean);
@ -461,7 +460,13 @@ begin
end
else
CurMode:=nil;
// Dialog caption
if Project1<>nil then
Caption:=Format(dlgProjectOptionsFor,[Project1.GetTitleOrName])
+ ', '+copy(Identifier,1,12)
else
Caption:='No project';
// Buttons
BuildModeAddSpeedButton.Hint:=Format(lisAddNewBuildModeCopyingSettingsFrom, [Identifier]);
BuildModeDeleteSpeedButton.Enabled:=(CurMode<>nil) and (fBuildModes.Count>1);
BuildModeDeleteSpeedButton.Hint:=Format(lisDeleteMode, [Identifier]);
@ -470,6 +475,7 @@ begin
BuildModeMoveDownSpeedButton.Enabled:=i<BuildModesStringGrid.RowCount-2;
BuildModeMoveDownSpeedButton.Hint:=Format(lisMoveOnePositionDown, [Identifier]);
BuildModeDiffSpeedButton.Hint:=lisShowDifferencesBetweenModes;
NoteLabel.Caption:='';
end;
procedure TBuildModesForm.SetShowSession(const AValue: boolean);
@ -514,21 +520,6 @@ begin
Grid.EndUpdate(true);
end;
procedure TBuildModesForm.UpdateDialogCaption;
var
s: String;
begin
if Project1<>nil then
begin
s := Project1.GetTitleOrName;
s:=Format(dlgProjectOptionsFor, [s]);
if fBuildModes.Count>1 then
s:=s+', '+copy(fActiveBuildMode.GetCaption,1,12);
end else
s:='TBuildModesForm.UpdateDialogCaption: no project';
Caption:=s;
end;
function TBuildModesForm.GetSelectedBuildMode: TProjectBuildMode;
var
i: LongInt;
@ -549,6 +540,19 @@ begin
;
end;
procedure TBuildModesForm.BuildModesStringGridDrawCell(Sender: TObject; aCol,
aRow: Integer; aRect: TRect; aState: TGridDrawState);
var
Canv: TCanvas;
begin
if (aCol=1) and (aRow=1) then
begin
Canv := (Sender as TStringGrid).Canvas;
// Canv.Brush.Color := clWindow;
Canv.FillRect(aRect);
end;
end;
function TBuildModesForm.GetActiveBuildMode: TProjectBuildMode;
begin
Result := fActiveBuildMode;