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

View File

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