IDE: build modes: draw mode groups

git-svn-id: trunk@23208 -
This commit is contained in:
mattias 2009-12-20 23:52:13 +00:00
parent 28506dad55
commit 0f5bdca192
3 changed files with 110 additions and 38 deletions

View File

@ -2,7 +2,7 @@
This source is only used to compile and install the package. This source is only used to compile and install the package.
} }
unit Printer4Lazarus; unit printer4lazarus;
interface interface

View File

@ -25,8 +25,9 @@ unit BuildModesEditor;
interface interface
uses uses
Classes, SysUtils, LCLProc, Controls, FileUtil, LResources, Forms, Grids, Math, Classes, SysUtils, LCLProc, Controls, FileUtil, LResources, Forms,
Menus, ComCtrls, Dialogs, AvgLvlTree, DefineTemplates, StdCtrls, Grids, Graphics, Menus, ComCtrls, Dialogs, AvgLvlTree, DefineTemplates,
StdCtrls, GraphMath,
ProjectIntf, IDEImagesIntf, ProjectIntf, IDEImagesIntf,
PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions, PathEditorDlg, Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions,
IDEProcs; IDEProcs;
@ -56,11 +57,13 @@ type
FGroupModeCount: integer; FGroupModeCount: integer;
FModeRows: TFPList; // list of TBuildModeGridRow FModeRows: TFPList; // list of TBuildModeGridRow
FRebuilding: boolean; FRebuilding: boolean;
FShowGroupGrid: boolean;
function GetSelectedModeRow: TBuildModeGridRow; function GetSelectedModeRow: TBuildModeGridRow;
function GetModeRowCount: integer; function GetModeRowCount: integer;
function GetModeRows(Index: integer): TBuildModeGridRow; function GetModeRows(Index: integer): TBuildModeGridRow;
procedure ClearModeRows; procedure ClearModeRows;
procedure FillGridRow(i: integer); procedure FillGridRow(i: integer);
procedure SetShowGroupGrid(const AValue: boolean);
protected protected
function ValidateEntry(const ACol,ARow:Integer; const OldValue:string; function ValidateEntry(const ACol,ARow:Integer; const OldValue:string;
var NewValue:string): boolean; override; var NewValue:string): boolean; override;
@ -96,6 +99,7 @@ type
property ModeRows[Index: integer]: TBuildModeGridRow read GetModeRows; property ModeRows[Index: integer]: TBuildModeGridRow read GetModeRows;
property GroupModeCount: integer read FGroupModeCount; // number of modes that are group of modes property GroupModeCount: integer read FGroupModeCount; // number of modes that are group of modes
property SelectedModeRow: TBuildModeGridRow read GetSelectedModeRow; property SelectedModeRow: TBuildModeGridRow read GetSelectedModeRow;
property ShowGroupGrid: boolean read FShowGroupGrid write SetShowGroupGrid;
end; end;
{ TBuildModesEditorFrame } { TBuildModesEditorFrame }
@ -217,6 +221,13 @@ begin
end; end;
end; end;
procedure TBuildModesGrid.SetShowGroupGrid(const AValue: boolean);
begin
if FShowGroupGrid=AValue then exit;
FShowGroupGrid:=AValue;
Invalidate;
end;
function TBuildModesGrid.ValidateEntry(const ACol, ARow: Integer; function TBuildModesGrid.ValidateEntry(const ACol, ARow: Integer;
const OldValue: string; var NewValue: string): boolean; const OldValue: string; var NewValue: string): boolean;
begin begin
@ -505,12 +516,14 @@ var
GrpMode: TBuildMode; GrpMode: TBuildMode;
NewState: TCheckBoxState; NewState: TCheckBoxState;
begin begin
//DebugLn(['TBuildModesGrid.SetCheckboxState ',acol,' ',arow,' ',ord(aState)]); DebugLn(['TBuildModesGrid.SetCheckboxState ',acol,' ',arow,' ',ord(aState)]);
NewState:=cbUnchecked; NewState:=cbUnchecked;
CurModeRow:=GetSelectedModeRow; if (aRow>=1) and (aRow<=ModeRowCount) and (ModeRows[aRow-1].IndexInGroup=0)
if (CurModeRow<>nil) and (CurModeRow.IndexInGroup=0) then begin then begin
CurModeRow:=ModeRows[aRow-1];
GrpID:=ColToBuildGroup(aCol); GrpID:=ColToBuildGroup(aCol);
if (GrpID>=0) and (GrpID<GroupModeCount) then begin if (GrpID>=0) and (GrpID<GroupModeCount) then begin
if ShowGroupGrid or (not CurModeRow.Mode.ShowIncludes) then begin
GrpMode:=ModeRows[GrpID].Mode; GrpMode:=ModeRows[GrpID].Mode;
if CurModeRow.Mode=GrpMode then begin if CurModeRow.Mode=GrpMode then begin
// invalid circle // invalid circle
@ -518,27 +531,34 @@ begin
end else if CurModeRow.Mode.IsIncludedBy(GrpMode)<>(aState=cbChecked) then end else if CurModeRow.Mode.IsIncludedBy(GrpMode)<>(aState=cbChecked) then
begin begin
// state changed // state changed
//DebugLn(['TBuildModesGrid.SetCheckboxState STATE CHANGED']); DebugLn(['TBuildModesGrid.SetCheckboxState STATE CHANGED']);
if aState=cbChecked then begin if aState=cbChecked then begin
GrpMode.Include(CurModeRow.Mode); GrpMode.Include(CurModeRow.Mode);
NewState:=cbChecked; NewState:=cbChecked;
end else begin end else begin
GrpMode.Exclude(CurModeRow.Mode); GrpMode.Exclude(CurModeRow.Mode);
end; end;
end else if CurModeRow.Mode.IsIncludedBy(GrpMode) then begin end else begin
// state kept // state kept
//DebugLn(['TBuildModesGrid.SetCheckboxState STATE KEPT']); DebugLn(['TBuildModesGrid.SetCheckboxState STATE KEPT']);
if CurModeRow.Mode.IsIncludedBy(GrpMode) then
NewState:=cbChecked; NewState:=cbChecked;
end; end;
end else begin end else begin
// invalid column // invalid column
DebugLn(['TBuildModesGrid.SetCheckboxState invalid col ',ACol,' ',GrpId,' ',GroupModeCount]); DebugLn(['TBuildModesGrid.SetCheckboxState invalid col ',ACol,' ',GrpId,' ',GroupModeCount]);
end; end;
end else begin
// group grid is hidden => keep state
DebugLn(['TBuildModesGrid.SetCheckboxState group grid is hidden']);
if CellToInclude(aCol,aRow) then
NewState:=cbChecked;
end;
end else begin end else begin
// invalid row // invalid row
DebugLn(['TBuildModesGrid.SetCheckboxState invalid row']); DebugLn(['TBuildModesGrid.SetCheckboxState invalid row']);
end; end;
//DebugLn(['TBuildModesGrid.SetCheckboxState END ',aCol,' ',aRow,' ',ord(NewState)]); DebugLn(['TBuildModesGrid.SetCheckboxState END ',aCol,' ',aRow,' ',ord(NewState)]);
inherited SetCheckboxState(aCol, aRow, NewState); inherited SetCheckboxState(aCol, aRow, NewState);
{for i:=1 to ModeRowCount do begin {for i:=1 to ModeRowCount do begin
dbgout(' '+dbgs(i)); dbgout(' '+dbgs(i));
@ -558,6 +578,8 @@ end;
procedure TBuildModesGrid.DrawCell(aCol, aRow: Integer; aRect: TRect; procedure TBuildModesGrid.DrawCell(aCol, aRow: Integer; aRect: TRect;
aState: TGridDrawState); aState: TGridDrawState);
const
w = 3;
procedure DrawGrid(Right, Bottom: boolean); procedure DrawGrid(Right, Bottom: boolean);
begin begin
@ -582,28 +604,76 @@ procedure TBuildModesGrid.DrawCell(aCol, aRow: Integer; aRect: TRect;
var var
CurModeRow: TBuildModeGridRow; CurModeRow: TBuildModeGridRow;
TypeCol: Integer; TypeCol: Integer;
GrpID: LongInt;
x: Integer;
y: Integer;
RowGrpID: Integer;
BezierPoints: PPoint;
r: Integer;
begin begin
if (aRow>=1) and (aRow<=ModeRowCount) then begin if (aRow>=1) and (aRow<=ModeRowCount) then begin
TypeCol:=GroupModeCount+1; TypeCol:=GroupModeCount+1;
CurModeRow:=ModeRows[aRow-1]; CurModeRow:=ModeRows[aRow-1];
DebugLn(['TBuildModesGrid.DrawCell ',aCol,' ',aRow,' IndexInGroup=',CurModeRow.IndexInGroup]); //DebugLn(['TBuildModesGrid.DrawCell ',aCol,' ',aRow,' IndexInGroup=',CurModeRow.IndexInGroup]);
if (CurModeRow.IndexInGroup>0) and (aCol<TypeCol) then begin if (CurModeRow.IndexInGroup>0) and (aCol<TypeCol) then begin
// only the first line of a group shows the name and groups // only the first line of a group shows the name and groups
// => clear // => clear
PrepareCanvas(aCol, aRow, aState);
Canvas.FillRect(aRect); Canvas.FillRect(aRect);
DrawGrid(aCol=TypeCol-1, DrawGrid(aCol=TypeCol-1,
CurModeRow.IndexInGroup=CurModeRow.Mode.FlagCount-1); CurModeRow.IndexInGroup=CurModeRow.Mode.FlagCount-1);
exit; exit;
end else if CurModeRow.Mode.ShowIncludes then begin end else if CurModeRow.Mode.ShowIncludes then begin
GrpID:=ColToBuildGroup(aCol);
if aCol>=TypeCol then begin if aCol>=TypeCol then begin
// groups have no type/value // groups have no type/value
PrepareCanvas(aCol, aRow, aState);
Canvas.FillRect(aRect); Canvas.FillRect(aRect);
if aRow=GroupModeCount then if aRow=GroupModeCount then
DrawGrid(false,true); DrawGrid(false,true);
exit; exit;
end else if (GrpID>=0) and (GrpID<GroupModeCount) then begin
// draw paths from mode row to mode column
PrepareCanvas(aCol, aRow, aState);
Canvas.FillRect(aRect);
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Color := clBtnFace;
Canvas.Pen.Style := psClear;
x:=(aRect.Left+aRect.Right) div 2;
y:=(aRect.Top+aRect.Bottom) div 2;
r:=Min(aRect.Right-aRect.Left,aRect.Bottom-aRect.Top) div 2;
RowGrpID:=aRow-1;
if GrpID=RowGrpID then begin
// draw curve left to bottom
GetMem(BezierPoints,SizeOf(TPoint)*10);
BezierPoints[0]:=Point(x-r,y-w); // middle,left
BezierPoints[1]:=Point(x-r+10,y-w); // to the right
BezierPoints[2]:=Point(x+w,y+r-10); // downwards
BezierPoints[3]:=Point(x+w,y+r); // bottom, middle
BezierPoints[4]:=Point(x+w-10,y+r); // to the left
BezierPoints[5]:=Point(x-w-10,y+r); // to the left
BezierPoints[6]:=Point(x-w,y+r); // bottom, middle
BezierPoints[7]:=Point(x-w,y+r-10); // upwards
BezierPoints[8]:=Point(x-r-10,y+w); // to the left
BezierPoints[9]:=Point(x-r,y+w); // middle,left
Canvas.PolyBezier(BezierPoints,10,true,true);
Freemem(BezierPoints);
Canvas.FillRect(aRect.Left,y-w,x-r,y+w+1);
Canvas.FillRect(x-w,y+r,x+w+1,aRect.Bottom);
end else if GrpID>RowGrpID then begin
// draw left to right
Canvas.FillRect(aRect.Left,y-w,aRect.Right,y+w+1);
end else begin
// draw top to bottom
Canvas.FillRect(x-w,aRect.Top,x+w+1,aRect.Bottom);
end;
if aRow=GroupModeCount then
DrawGrid(false,true);
exit;
end; end;
end; end;
end; end;
//DebugLn(['TBuildModesGrid.DrawCell draw default ',aCol,' ',aRow]);
inherited DrawCell(aCol, aRow, aRect, aState); inherited DrawCell(aCol, aRow, aRect, aState);
end; end;

View File

@ -884,18 +884,20 @@ end;
Params: X, Y, Width, Height, Angle1, Angle2, Rotation, Points, Count Params: X, Y, Width, Height, Angle1, Angle2, Rotation, Points, Count
Returns: Nothing Returns: Nothing
Use PolyBezierArcPoints to convert an Arc and ArcLength into a Pointer Array Use PolyBezierArcPoints to convert an Agnle and AgnleLength into a
of TPoints for use with Polyline or Polygon. The Rotation parameter accepts Pointer Array of TPoints for use with Polyline or Polygon.
a Rotation-Angle for a rotated Ellipse'- for a non-rotated ellipse this The Rotation parameter accepts a Rotation-Angle for a rotated Ellipse'- for
value would be 0, or 360. The result is an Aproximation based on 1 or more a non-rotated ellipse this value would be 0, or 360*16.
Beziers. If the AngleLength is greater than 45 degrees, it recursively breaks The result is an Aproximation based on 1 or more Beziers. If the AngleLength
the Arc into Arcs of 45 degrees or less, and converts them into Beziers with is greater than 45*16 degrees, it recursively breaks the Arc into Arcs of
BezierArcPoints. The angles are 1/16th of a degree. For example, a full circle 45*16 degrees or less, and converts them into Beziers with BezierArcPoints.
equals 5760 (16*360). Positive values of Angle and AngleLength mean The angles are 1/16th of a degree. For example, a full circle equals
counter-clockwise while negative values mean clockwise direction. Zero 5760 (16*360).
degrees is at the 3'o clock position. Points is automatically initialized, Positive values of Angle and AngleLength mean counter-clockwise while negative
so any existing information is lost, and the array starts at 0. Points values mean clockwise direction. Zero degrees is at the 3'o clock position.
should ALWAYS be Freed when done by calling to ReallocMem(Points, 0). Points is automatically initialized, so any existing information is lost,
and the array starts at 0. Points should ALWAYS be Freed when done by calling
to ReallocMem(Points, 0).
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure PolyBezierArcPoints(X, Y, Width, Height : Longint; Angle1, Angle2, procedure PolyBezierArcPoints(X, Y, Width, Height : Longint; Angle1, Angle2,