You've already forked lazarus-ccr
GridPrinter: Fix alignment and layout of checkbox columns in preview/print.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8639 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -2,36 +2,39 @@ object Form1: TForm1
|
|||||||
Left = 256
|
Left = 256
|
||||||
Height = 324
|
Height = 324
|
||||||
Top = 134
|
Top = 134
|
||||||
Width = 303
|
Width = 470
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 324
|
ClientHeight = 324
|
||||||
ClientWidth = 303
|
ClientWidth = 470
|
||||||
LCLVersion = '2.3.0.0'
|
LCLVersion = '2.3.0.0'
|
||||||
object StringGrid1: TStringGrid
|
object StringGrid1: TStringGrid
|
||||||
Left = 0
|
Left = 6
|
||||||
Height = 287
|
Height = 250
|
||||||
Top = 0
|
Top = 31
|
||||||
Width = 303
|
Width = 426
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
BorderSpacing.Around = 6
|
||||||
ColCount = 4
|
ColCount = 4
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Title.Caption = 'Col 1'
|
Title.Caption = 'Col 1'
|
||||||
Width = 64
|
Width = 120
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Title.Alignment = taRightJustify
|
Title.Alignment = taRightJustify
|
||||||
Title.Caption = 'Col 2'
|
Title.Caption = 'Col 2'
|
||||||
Width = 64
|
Width = 120
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
ButtonStyle = cbsCheckboxColumn
|
ButtonStyle = cbsCheckboxColumn
|
||||||
Color = clActiveBorder
|
Color = clActiveBorder
|
||||||
Title.Alignment = taCenter
|
Title.Alignment = taCenter
|
||||||
Title.Caption = 'Col 3'
|
Title.Caption = 'Col 3'
|
||||||
Width = 64
|
Width = 100
|
||||||
end>
|
end>
|
||||||
|
DefaultColWidth = 40
|
||||||
|
DefaultRowHeight = 40
|
||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll, goFixedRowNumbering]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll, goFixedRowNumbering]
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Cells = (
|
Cells = (
|
||||||
@@ -75,12 +78,12 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 37
|
Height = 37
|
||||||
Top = 287
|
Top = 287
|
||||||
Width = 303
|
Width = 470
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 37
|
ClientHeight = 37
|
||||||
ClientWidth = 303
|
ClientWidth = 470
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
AnchorSideLeft.Control = Panel1
|
AnchorSideLeft.Control = Panel1
|
||||||
@@ -95,6 +98,239 @@ object Form1: TForm1
|
|||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object Panel2: TPanel
|
||||||
|
Left = 6
|
||||||
|
Height = 19
|
||||||
|
Top = 6
|
||||||
|
Width = 458
|
||||||
|
Align = alTop
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 19
|
||||||
|
ClientWidth = 458
|
||||||
|
TabOrder = 2
|
||||||
|
object pnlCol1Alignment: TPanel
|
||||||
|
AnchorSideLeft.Control = Panel2
|
||||||
|
Left = 42
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 87
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Left = 42
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 19
|
||||||
|
ClientWidth = 87
|
||||||
|
TabOrder = 0
|
||||||
|
object rbLeft1: TRadioButton
|
||||||
|
Tag = 11
|
||||||
|
AnchorSideLeft.Control = pnlCol1Alignment
|
||||||
|
AnchorSideTop.Control = pnlCol1Alignment
|
||||||
|
Left = 0
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 24
|
||||||
|
Caption = 'L'
|
||||||
|
Checked = True
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 2
|
||||||
|
TabStop = True
|
||||||
|
end
|
||||||
|
object rbCenter1: TRadioButton
|
||||||
|
Tag = 13
|
||||||
|
AnchorSideLeft.Control = rbLeft1
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = pnlCol1Alignment
|
||||||
|
Left = 30
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 26
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'C'
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object rbRight1: TRadioButton
|
||||||
|
Tag = 12
|
||||||
|
AnchorSideLeft.Control = rbCenter1
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = pnlCol1Alignment
|
||||||
|
Left = 62
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 25
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'R'
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object pnlCol2Alignment: TPanel
|
||||||
|
AnchorSideLeft.Control = Panel2
|
||||||
|
Left = 162
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 87
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Left = 162
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 19
|
||||||
|
ClientWidth = 87
|
||||||
|
TabOrder = 1
|
||||||
|
object rbLeft2: TRadioButton
|
||||||
|
Tag = 21
|
||||||
|
AnchorSideLeft.Control = pnlCol2Alignment
|
||||||
|
AnchorSideTop.Control = pnlCol2Alignment
|
||||||
|
Left = 0
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 24
|
||||||
|
Caption = 'L'
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object rbCenter2: TRadioButton
|
||||||
|
Tag = 23
|
||||||
|
AnchorSideLeft.Control = rbLeft2
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = pnlCol2Alignment
|
||||||
|
Left = 30
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 26
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'C'
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
object rbRight2: TRadioButton
|
||||||
|
Tag = 22
|
||||||
|
AnchorSideLeft.Control = rbCenter2
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = pnlCol2Alignment
|
||||||
|
Left = 62
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 25
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'R'
|
||||||
|
Checked = True
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 2
|
||||||
|
TabStop = True
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object pnlCol3Alignment: TPanel
|
||||||
|
AnchorSideLeft.Control = Panel2
|
||||||
|
AnchorSideTop.Control = Panel2
|
||||||
|
Left = 282
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 87
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Left = 282
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 19
|
||||||
|
ClientWidth = 87
|
||||||
|
TabOrder = 2
|
||||||
|
object rbLeft3: TRadioButton
|
||||||
|
Tag = 31
|
||||||
|
AnchorSideLeft.Control = pnlCol3Alignment
|
||||||
|
AnchorSideTop.Control = pnlCol3Alignment
|
||||||
|
Left = 0
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 24
|
||||||
|
Caption = 'L'
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object rbCenter3: TRadioButton
|
||||||
|
Tag = 33
|
||||||
|
AnchorSideLeft.Control = rbLeft3
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = pnlCol3Alignment
|
||||||
|
Left = 30
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 26
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'C'
|
||||||
|
Checked = True
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 1
|
||||||
|
TabStop = True
|
||||||
|
end
|
||||||
|
object rbRight3: TRadioButton
|
||||||
|
Tag = 32
|
||||||
|
AnchorSideLeft.Control = rbCenter3
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = pnlCol3Alignment
|
||||||
|
Left = 62
|
||||||
|
Height = 19
|
||||||
|
Top = 0
|
||||||
|
Width = 25
|
||||||
|
BorderSpacing.Left = 6
|
||||||
|
Caption = 'R'
|
||||||
|
OnChange = rbAlignmentChange
|
||||||
|
TabOrder = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object Panel3: TPanel
|
||||||
|
Left = 438
|
||||||
|
Height = 256
|
||||||
|
Top = 31
|
||||||
|
Width = 26
|
||||||
|
Align = alRight
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Right = 6
|
||||||
|
BevelOuter = bvNone
|
||||||
|
ClientHeight = 256
|
||||||
|
ClientWidth = 26
|
||||||
|
TabOrder = 3
|
||||||
|
object rbLayoutTop: TRadioButton
|
||||||
|
Tag = 1
|
||||||
|
AnchorSideLeft.Control = Panel3
|
||||||
|
AnchorSideTop.Control = Panel3
|
||||||
|
Left = 0
|
||||||
|
Height = 19
|
||||||
|
Top = 42
|
||||||
|
Width = 24
|
||||||
|
BorderSpacing.Top = 42
|
||||||
|
Caption = 'T'
|
||||||
|
OnChange = rbLayoutChange
|
||||||
|
TabOrder = 0
|
||||||
|
end
|
||||||
|
object rbLayoutCenter: TRadioButton
|
||||||
|
Tag = 2
|
||||||
|
AnchorSideLeft.Control = Panel3
|
||||||
|
AnchorSideTop.Control = rbLayoutTop
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 0
|
||||||
|
Height = 19
|
||||||
|
Top = 61
|
||||||
|
Width = 26
|
||||||
|
Caption = 'C'
|
||||||
|
Checked = True
|
||||||
|
OnChange = rbLayoutChange
|
||||||
|
TabOrder = 2
|
||||||
|
TabStop = True
|
||||||
|
end
|
||||||
|
object rbLayoutBottom: TRadioButton
|
||||||
|
Tag = 3
|
||||||
|
AnchorSideLeft.Control = Panel3
|
||||||
|
AnchorSideTop.Control = rbLayoutCenter
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 0
|
||||||
|
Height = 19
|
||||||
|
Top = 80
|
||||||
|
Width = 25
|
||||||
|
Caption = 'B'
|
||||||
|
OnChange = rbLayoutChange
|
||||||
|
TabOrder = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
object GridPrinter1: TGridPrinter
|
object GridPrinter1: TGridPrinter
|
||||||
Grid = StringGrid1
|
Grid = StringGrid1
|
||||||
Footer.Font.Height = -11
|
Footer.Font.Height = -11
|
||||||
|
@@ -17,8 +17,27 @@ type
|
|||||||
GridPrinter1: TGridPrinter;
|
GridPrinter1: TGridPrinter;
|
||||||
GridPrintPreviewDialog1: TGridPrintPreviewDialog;
|
GridPrintPreviewDialog1: TGridPrintPreviewDialog;
|
||||||
Panel1: TPanel;
|
Panel1: TPanel;
|
||||||
|
Panel2: TPanel;
|
||||||
|
Panel3: TPanel;
|
||||||
|
pnlCol1Alignment: TPanel;
|
||||||
|
pnlCol2Alignment: TPanel;
|
||||||
|
pnlCol3Alignment: TPanel;
|
||||||
|
rbLayoutTop: TRadioButton;
|
||||||
|
rbLayoutCenter: TRadioButton;
|
||||||
|
rbLayoutBottom: TRadioButton;
|
||||||
|
rbCenter2: TRadioButton;
|
||||||
|
rbCenter3: TRadioButton;
|
||||||
|
rbLeft1: TRadioButton;
|
||||||
|
rbCenter1: TRadioButton;
|
||||||
|
rbLeft2: TRadioButton;
|
||||||
|
rbLeft3: TRadioButton;
|
||||||
|
rbRight1: TRadioButton;
|
||||||
|
rbRight2: TRadioButton;
|
||||||
|
rbRight3: TRadioButton;
|
||||||
StringGrid1: TStringGrid;
|
StringGrid1: TStringGrid;
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
|
procedure rbLayoutChange(Sender: TObject);
|
||||||
|
procedure rbAlignmentChange(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
|
||||||
public
|
public
|
||||||
@@ -39,5 +58,38 @@ begin
|
|||||||
GridPrintPreviewDialog1.Execute;
|
GridPrintPreviewDialog1.Execute;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.rbLayoutChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
layoutIndex: Integer;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if not (Sender is TRadioButton) then
|
||||||
|
exit;
|
||||||
|
if not TRadioButton(Sender).Checked then
|
||||||
|
exit;
|
||||||
|
layoutIndex := TRadioButton(Sender).Tag - 1;
|
||||||
|
for i := 0 to StringGrid1.Columns.Count-1 do
|
||||||
|
begin
|
||||||
|
StringGrid1.Columns[i].Layout := TTextLayout(layoutIndex);
|
||||||
|
StringGrid1.Columns[i].Title.Layout := TTextLayout(layoutIndex);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.rbAlignmentChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
colIndex, alignmentIndex: Integer;
|
||||||
|
col: TGridColumn;
|
||||||
|
begin
|
||||||
|
if not (Sender is TRadioButton) then
|
||||||
|
exit;
|
||||||
|
if not TRadioButton(Sender).Checked then
|
||||||
|
exit;
|
||||||
|
colIndex := TRadioButton(Sender).Tag div 10 - 1;
|
||||||
|
alignmentIndex := TRadioButton(Sender).Tag mod 10 - 1;
|
||||||
|
col := StringGrid1.Columns[colIndex];
|
||||||
|
col.Alignment := TAlignment(alignmentIndex);
|
||||||
|
col.Title.Alignment := TAlignment(alignmentIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@@ -1409,8 +1409,16 @@ begin
|
|||||||
cSize.cx := ScaleX(cSize.cx);
|
cSize.cx := ScaleX(cSize.cx);
|
||||||
cSize.cy := ScaleY(cSize.cy);
|
cSize.cy := ScaleY(cSize.cy);
|
||||||
// Position the checkbox within the given rectangle, ARect.
|
// Position the checkbox within the given rectangle, ARect.
|
||||||
R.Left := (ARect.Left + ARect.Right - cSize.cx) div 2;
|
case ACanvas.TextStyle.Alignment of
|
||||||
R.Top := (ARect.Top + ARect.Bottom - cSize.cy) div 2;
|
taLeftJustify: R.Left := ARect.Left + FPadding;
|
||||||
|
taCenter: R.Left := (ARect.Left + ARect.Right - cSize.cx) div 2;
|
||||||
|
taRightJustify: R.Left := ARect.Right - cSize.cx - FPadding;
|
||||||
|
end;
|
||||||
|
case ACanvas.TextStyle.Layout of
|
||||||
|
tlTop: R.Top := ARect.Top + FPadding;
|
||||||
|
tlCenter: R.Top := (ARect.Top + ARect.Bottom - cSize.cy) div 2;
|
||||||
|
tlBottom: R.Top := ARect.Bottom - cSize.cy - FPadding;
|
||||||
|
end;
|
||||||
R.BottomRight := Point(R.Left + cSize.cx, R.Top + cSize.cy);
|
R.BottomRight := Point(R.Left + cSize.cx, R.Top + cSize.cy);
|
||||||
// Prepare pen and brush
|
// Prepare pen and brush
|
||||||
ACanvas.Pen.Width := ScaleX(1);
|
ACanvas.Pen.Width := ScaleX(1);
|
||||||
|
Reference in New Issue
Block a user