jvcllaz: Activate LCL scaling for TJvYearGrid. Publish Font property. Update demo project.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7285 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-01-14 09:49:13 +00:00
parent 9100c787d7
commit 7c25c573a5
3 changed files with 240 additions and 90 deletions

View File

@ -7,6 +7,7 @@ object MainForm: TMainForm
Caption = 'JvYearGrid Demo' Caption = 'JvYearGrid Demo'
ClientHeight = 546 ClientHeight = 546
ClientWidth = 1310 ClientWidth = 1310
OnActivate = FormActivate
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '2.1.0.0' LCLVersion = '2.1.0.0'
object JvYearGrid1: TJvYearGrid object JvYearGrid1: TJvYearGrid
@ -97,78 +98,74 @@ object MainForm: TMainForm
AnchorSideTop.Control = JvYearGrid1 AnchorSideTop.Control = JvYearGrid1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 0 Left = 0
Height = 97 Height = 89
Top = 264 Top = 264
Width = 730 Width = 905
AutoSize = True AutoSize = True
BorderSpacing.Bottom = 16
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 97 ClientHeight = 89
ClientWidth = 730 ClientWidth = 905
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
object EdLeftMargin: TSpinEdit object edLeftMargin: TSpinEdit
AnchorSideTop.Control = EdTopMargin AnchorSideTop.Control = edTopMargin
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Label4 AnchorSideRight.Control = Label4
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 24 Left = 24
Height = 23 Height = 23
Top = 31 Top = 27
Width = 50 Width = 50
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Top = 4 BorderSpacing.Top = 4
OnChange = EdLeftMarginChange
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
end end
object EdRightMargin: TSpinEdit object edRightMargin: TSpinEdit
AnchorSideLeft.Control = EdTopMargin AnchorSideLeft.Control = edTopMargin
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = EdLeftMargin AnchorSideTop.Control = edLeftMargin
Left = 144 Left = 136
Height = 23 Height = 23
Top = 31 Top = 27
Width = 50 Width = 50
BorderSpacing.Left = 4 BorderSpacing.Left = 4
OnChange = EdRightMarginChange
ParentFont = False ParentFont = False
TabOrder = 1 TabOrder = 1
end end
object EdTopMargin: TSpinEdit object edTopMargin: TSpinEdit
AnchorSideLeft.Control = EdLeftMargin AnchorSideLeft.Control = edLeftMargin
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1 AnchorSideTop.Control = Panel1
Left = 82 Left = 82
Height = 23 Height = 23
Top = 4 Top = 0
Width = 58 Width = 50
BorderSpacing.Left = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 4
OnChange = EdTopMarginChange
ParentFont = False ParentFont = False
TabOrder = 2 TabOrder = 2
end end
object EdBottomMargin: TSpinEdit object edBottomMargin: TSpinEdit
AnchorSideLeft.Control = EdTopMargin AnchorSideLeft.Control = edTopMargin
AnchorSideTop.Control = EdLeftMargin AnchorSideTop.Control = edLeftMargin
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 82 Left = 82
Height = 23 Height = 23
Top = 58 Top = 54
Width = 58 Width = 50
BorderSpacing.Top = 4 BorderSpacing.Top = 4
OnChange = EdBottomMarginChange
ParentFont = False ParentFont = False
TabOrder = 3 TabOrder = 3
end end
object cmbDayNamesAlignment: TComboBox object cmbDayNamesAlignment: TComboBox
AnchorSideLeft.Control = Label1 AnchorSideLeft.Control = Label1
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = EdTopMargin AnchorSideTop.Control = edTopMargin
Left = 414 Left = 398
Height = 23 Height = 23
Top = 4 Top = 0
Width = 100 Width = 100
BorderSpacing.Left = 8 BorderSpacing.Left = 8
ItemHeight = 15 ItemHeight = 15
@ -187,9 +184,9 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label2 AnchorSideRight.Control = Label2
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 250 Left = 234
Height = 15 Height = 15
Top = 8 Top = 4
Width = 156 Width = 156
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'Day names alignment/format' Caption = 'Day names alignment/format'
@ -197,17 +194,17 @@ object MainForm: TMainForm
ParentFont = False ParentFont = False
end end
object Label2: TLabel object Label2: TLabel
AnchorSideLeft.Control = EdRightMargin AnchorSideLeft.Control = edRightMargin
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cmbMonthNamesAlignment AnchorSideTop.Control = cmbMonthNamesAlignment
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label1 AnchorSideRight.Control = Label1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 234 Left = 218
Height = 15 Height = 15
Top = 35 Top = 31
Width = 172 Width = 172
BorderSpacing.Left = 40 BorderSpacing.Left = 32
Caption = 'Month names alignment/format' Caption = 'Month names alignment/format'
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
@ -218,9 +215,9 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = cmbDayNamesAlignment AnchorSideRight.Control = cmbDayNamesAlignment
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 414 Left = 398
Height = 23 Height = 23
Top = 31 Top = 27
Width = 100 Width = 100
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
@ -240,9 +237,9 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label1 AnchorSideRight.Control = Label1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 324 Left = 308
Height = 15 Height = 15
Top = 62 Top = 58
Width = 82 Width = 82
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
Caption = 'Days alignment' Caption = 'Days alignment'
@ -255,13 +252,12 @@ object MainForm: TMainForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = cmbDayNamesAlignment AnchorSideRight.Control = cmbDayNamesAlignment
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 414 Left = 398
Height = 23 Height = 23
Top = 58 Top = 54
Width = 100 Width = 100
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4 BorderSpacing.Top = 4
BorderSpacing.Bottom = 16
ItemHeight = 15 ItemHeight = 15
Items.Strings = ( Items.Strings = (
'taLeftJustify' 'taLeftJustify'
@ -273,17 +269,17 @@ object MainForm: TMainForm
Style = csDropDownList Style = csDropDownList
TabOrder = 6 TabOrder = 6
end end
object CbFlat: TCheckBox object cmbFlat: TCheckBox
AnchorSideLeft.Control = lblYear AnchorSideLeft.Control = cmbMonthFormat
AnchorSideTop.Control = cmbMonthFormat AnchorSideTop.Control = cmbDaysAlignment
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 648 Left = 506
Height = 19 Height = 19
Top = 33 Top = 56
Width = 39 Width = 39
BorderSpacing.Right = 16 BorderSpacing.Right = 16
Caption = 'Flat' Caption = 'Flat'
OnChange = CbFlatChange OnChange = cmbFlatChange
ParentFont = False ParentFont = False
TabOrder = 7 TabOrder = 7
end end
@ -291,9 +287,9 @@ object MainForm: TMainForm
AnchorSideLeft.Control = cmbDayNamesAlignment AnchorSideLeft.Control = cmbDayNamesAlignment
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cmbDayNamesAlignment AnchorSideTop.Control = cmbDayNamesAlignment
Left = 522 Left = 506
Height = 23 Height = 23
Top = 4 Top = 0
Width = 100 Width = 100
BorderSpacing.Left = 8 BorderSpacing.Left = 8
ItemHeight = 15 ItemHeight = 15
@ -311,9 +307,9 @@ object MainForm: TMainForm
AnchorSideLeft.Control = cmbDayNamesAlignment AnchorSideLeft.Control = cmbDayNamesAlignment
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cmbMonthNamesAlignment AnchorSideTop.Control = cmbMonthNamesAlignment
Left = 522 Left = 506
Height = 23 Height = 23
Top = 31 Top = 27
Width = 100 Width = 100
BorderSpacing.Left = 8 BorderSpacing.Left = 8
ItemHeight = 15 ItemHeight = 15
@ -332,9 +328,9 @@ object MainForm: TMainForm
AnchorSideTop.Control = cmbDayFormat AnchorSideTop.Control = cmbDayFormat
AnchorSideBottom.Control = cmbDayFormat AnchorSideBottom.Control = cmbDayFormat
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 673 Left = 657
Height = 23 Height = 23
Top = 4 Top = 0
Width = 57 Width = 57
Anchors = [akTop, akLeft, akBottom] Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 3 BorderSpacing.Left = 3
@ -350,9 +346,9 @@ object MainForm: TMainForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cmbDayFormat AnchorSideTop.Control = cmbDayFormat
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 648 Left = 632
Height = 15 Height = 15
Top = 8 Top = 4
Width = 22 Width = 22
BorderSpacing.Left = 26 BorderSpacing.Left = 26
Caption = 'Year' Caption = 'Year'
@ -361,15 +357,88 @@ object MainForm: TMainForm
end end
object Label4: TLabel object Label4: TLabel
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = EdTopMargin AnchorSideTop.Control = edTopMargin
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 8 Left = 8
Height = 15 Height = 15
Top = 8 Top = 4
Width = 66 Width = 66
BorderSpacing.Left = 8 BorderSpacing.Left = 8
Caption = 'Cell margins' Caption = 'Cell margins'
ParentColor = False ParentColor = False
end end
object btnFont: TButton
AnchorSideLeft.Control = lblYear
AnchorSideTop.Control = cmbDaysAlignment
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = udYear
AnchorSideRight.Side = asrBottom
Left = 632
Height = 25
Top = 53
Width = 82
Anchors = [akTop, akLeft, akRight]
AutoSize = True
Caption = 'Font...'
OnClick = btnFontClick
TabOrder = 11
end
object rgAutoSize: TCheckGroup
AnchorSideLeft.Control = udYear
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edTopMargin
Left = 730
Height = 89
Top = 0
Width = 167
AutoFill = True
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Right = 8
Caption = 'Auto size'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 69
ClientWidth = 163
Columns = 2
Items.Strings = (
'Grid'
'First column'
'First row'
'Columns'
'Rows'
)
OnItemClick = rgAutoSizeItemClick
TabOrder = 12
Data = {
050000000202020202
}
end
object cmbAutoSize: TCheckBox
AnchorSideTop.Control = rgAutoSize
AnchorSideRight.Control = rgAutoSize
AnchorSideRight.Side = asrBottom
Left = 877
Height = 19
Top = 0
Width = 20
Anchors = [akTop, akRight]
Checked = True
OnChange = cmbAutoSizeChange
State = cbChecked
TabOrder = 13
end
end
object FontDialog1: TFontDialog
MinFontSize = 0
MaxFontSize = 0
left = 568
top = 320
end end
end end

View File

@ -14,35 +14,40 @@ type
{ TMainForm } { TMainForm }
TMainForm = class(TForm) TMainForm = class(TForm)
btnFont: TButton;
cmbAutoSize: TCheckBox;
cmbMonthFormat: TComboBox; cmbMonthFormat: TComboBox;
cmbDayNamesAlignment: TComboBox; cmbDayNamesAlignment: TComboBox;
cmbDayFormat: TComboBox; cmbDayFormat: TComboBox;
cmbMonthNamesAlignment: TComboBox; cmbMonthNamesAlignment: TComboBox;
cmbDaysAlignment: TComboBox; cmbDaysAlignment: TComboBox;
CbFlat: TCheckBox; cmbFlat: TCheckBox;
FontDialog1: TFontDialog;
JvYearGrid1: TJvYearGrid; JvYearGrid1: TJvYearGrid;
EdLeftMargin: TSpinEdit; edLeftMargin: TSpinEdit;
EdRightMargin: TSpinEdit; edRightMargin: TSpinEdit;
EdTopMargin: TSpinEdit; edTopMargin: TSpinEdit;
EdBottomMargin: TSpinEdit; edBottomMargin: TSpinEdit;
Label1: TLabel; Label1: TLabel;
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
Label4: TLabel; Label4: TLabel;
lblYear: TLabel; lblYear: TLabel;
Panel1: TPanel; Panel1: TPanel;
rgAutoSize: TCheckGroup;
udYear: TUpDown; udYear: TUpDown;
procedure btnFontClick(Sender: TObject);
procedure cmbAutoSizeChange(Sender: TObject);
procedure cmbDayFormatChange(Sender: TObject); procedure cmbDayFormatChange(Sender: TObject);
procedure cmbDayNamesAlignmentChange(Sender: TObject); procedure cmbDayNamesAlignmentChange(Sender: TObject);
procedure cmbDaysAlignmentChange(Sender: TObject); procedure cmbDaysAlignmentChange(Sender: TObject);
procedure CbFlatChange(Sender: TObject); procedure cmbFlatChange(Sender: TObject);
procedure cmbMonthFormatChange(Sender: TObject); procedure cmbMonthFormatChange(Sender: TObject);
procedure cmbMonthNamesAlignmentChange(Sender: TObject); procedure cmbMonthNamesAlignmentChange(Sender: TObject);
procedure EdBottomMarginChange(Sender: TObject); procedure edMarginChange(Sender: TObject);
procedure EdLeftMarginChange(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure EdRightMarginChange(Sender: TObject);
procedure EdTopMarginChange(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure rgAutoSizeItemClick(Sender: TObject; Index: integer);
procedure udYearClick(Sender: TObject; Button: TUDBtnType); procedure udYearClick(Sender: TObject; Button: TUDBtnType);
private private
@ -77,9 +82,22 @@ begin
JvYearGrid1.DaysAlignment := TAlignment(cmbDaysAlignment.ItemIndex); JvYearGrid1.DaysAlignment := TAlignment(cmbDaysAlignment.ItemIndex);
end; end;
procedure TMainForm.CbFlatChange(Sender: TObject); procedure TMainForm.btnFontClick(Sender: TObject);
begin begin
JvYearGrid1.Flat := CbFlat.Checked; FontDialog1.Font.Assign(JvYearGrid1.Font);
if FontDialog1.Execute then
JvYearGrid1.Font.Assign(FontDialog1.Font);
end;
procedure TMainForm.cmbAutoSizeChange(Sender: TObject);
begin
JvYearGrid1.AutoSize := cmbAutoSize.Checked;
rgAutoSize.Enabled := JvYearGrid1.AutoSize;
end;
procedure TMainForm.cmbFlatChange(Sender: TObject);
begin
JvYearGrid1.Flat := cmbFlat.Checked;
end; end;
procedure TMainForm.cmbMonthFormatChange(Sender: TObject); procedure TMainForm.cmbMonthFormatChange(Sender: TObject);
@ -92,35 +110,36 @@ begin
JvYearGrid1.MonthNamesAlignment := TAlignment(cmbMonthNamesAlignment.ItemIndex); JvYearGrid1.MonthNamesAlignment := TAlignment(cmbMonthNamesAlignment.ItemIndex);
end; end;
procedure TMainForm.EdBottomMarginChange(Sender: TObject); procedure TMainForm.edMarginChange(Sender: TObject);
begin begin
JvYearGrid1.CellMargins.Bottom := EdBottomMargin.Value; if Sender = edLeftMargin then
JvYearGrid1.CellMargins.Left := edLeftMargin.Value;
if Sender = edRightMargin then
JvYearGrid1.CellMargins.Right := edRightMargin.Value;
if Sender = edTopMargin then
JvYearGrid1.CellMargins.Top := edTopMargin.Value;
if Sender = edBottomMargin then
JvYearGrid1.CellMargins.Bottom := edBottomMargin.Value;
end; end;
procedure TMainForm.EdLeftMarginChange(Sender: TObject); procedure TMainForm.FormActivate(Sender: TObject);
begin begin
JvYearGrid1.CellMargins.Left := EdLeftMargin.Value; // Doing this in the OnCreate event would mean that the scaled values are
end; // not ready, yet.
edLeftMargin.Value := JvYearGrid1.CellMargins.Left;
procedure TMainForm.EdRightMarginChange(Sender: TObject); edRightMargin.Value := JvYearGrid1.CellMargins.Right;
begin edTopMargin.Value := JvYearGrid1.CellMargins.Top;
JvYearGrid1.CellMargins.Right := EdRightMargin.Value; edBottomMargin.Value := JvYearGrid1.CellMargins.Bottom;
end; edLeftMargin.OnChange := @edMarginChange;
edRightMargin.OnChange := @edMarginChange;
procedure TMainForm.EdTopMarginChange(Sender: TObject); edTopMargin.OnChange := @edMarginChange;
begin edBottomMargin.OnChange := @edMarginChange;
JvYearGrid1.CellMargins.Top := EdTopMargin.Value;
end; end;
procedure TMainForm.FormCreate(Sender: TObject); procedure TMainForm.FormCreate(Sender: TObject);
begin begin
JvYearGrid1.Year := YearOf(Date); JvYearGrid1.Year := YearOf(Date);
EdLeftMargin.Value := JvYearGrid1.CellMargins.Left;
EdRightMargin.Value := JvYearGrid1.CellMargins.Right;
EdTopMargin.Value := JvYearGrid1.CellMargins.Top;
EdBottomMargin.Value := JvYearGrid1.CellMargins.Bottom;
cmbDayNamesAlignment.ItemIndex := ord(JvYearGrid1.DayNamesAlignment); cmbDayNamesAlignment.ItemIndex := ord(JvYearGrid1.DayNamesAlignment);
cmbMonthNamesAlignment.ItemIndex := ord(JvYearGrid1.MonthNamesAlignment); cmbMonthNamesAlignment.ItemIndex := ord(JvYearGrid1.MonthNamesAlignment);
cmbDaysAlignment.ItemIndex := ord(JvYearGrid1.DaysAlignment); cmbDaysAlignment.ItemIndex := ord(JvYearGrid1.DaysAlignment);
@ -130,7 +149,41 @@ begin
udYear.Position := JvYearGrid1.Year; udYear.Position := JvYearGrid1.Year;
CbFlat.Checked := JvYearGrid1.Flat; cmbFlat.Checked := JvYearGrid1.Flat;
cmbAutoSize.Checked := JvYearGrid1.AutoSize;
rgAutoSize.Checked[ord(aoGrid)] := aoGrid in JvYearGrid1.AutosizeOptions;
rgAutoSize.Checked[ord(aoFirstColumn)] := aoFirstColumn in JvYearGrid1.AutosizeOptions;
rgAutoSize.Checked[ord(aoFirstRow)] := aoFirstRow in JvYearGrid1.AutosizeOptions;
rgAutoSize.Checked[ord(aoColumns)] := aoColumns in JvYearGrid1.AutosizeOptions;
rgAutoSize.Checked[ord(aoRows)] := aoRows in JvYearGrid1.AutosizeOptions;
end;
procedure TMainForm.rgAutoSizeItemClick(Sender: TObject; Index: integer);
begin
if rgAutoSize.Checked[ord(aoGrid)] then
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions + [aoGrid]
else
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions - [aoGrid];
if rgAutoSize.Checked[ord(aoFirstColumn)] then
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions + [aoFirstColumn]
else
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions - [aoFirstColumn];
if rgAutoSize.Checked[ord(aoFirstRow)] then
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions + [aoFirstRow]
else
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions - [aoFirstRow];
if rgAutoSize.Checked[ord(aoColumns)] then
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions + [aoColumns]
else
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions - [aoColumns];
if rgAutoSize.Checked[ord(aoRows)] then
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions + [aoRows]
else
JvYearGrid1.AutoSizeOptions := JvYearGrid1.AutoSizeOptions - [aoRows];
end; end;
procedure TMainForm.udYearClick(Sender: TObject; Button: TUDBtnType); procedure TMainForm.udYearClick(Sender: TObject; Button: TUDBtnType);

View File

@ -173,6 +173,7 @@ type
procedure DrawTextInCell(aCol, aRow: Integer; aRect: TRect; {%H-}aState: TGridDrawState); override; procedure DrawTextInCell(aCol, aRow: Integer; aRect: TRect; {%H-}aState: TGridDrawState); override;
function SelectCell(ACol, ARow: Integer): Boolean; override; function SelectCell(ACol, ARow: Integer): Boolean; override;
procedure DblClick; override; procedure DblClick; override;
procedure FontChanged(Sender: TObject); override;
procedure DoPrepareCanvas(aCol,aRow:Integer; {%H-}aState: TGridDrawState); override; procedure DoPrepareCanvas(aCol,aRow:Integer; {%H-}aState: TGridDrawState); override;
procedure SetAutoSize(Value: Boolean); override; procedure SetAutoSize(Value: Boolean); override;
procedure UpdateAllSizes; procedure UpdateAllSizes;
@ -189,6 +190,10 @@ type
procedure WriteGridYear({%H-}Writer: TWriter); procedure WriteGridYear({%H-}Writer: TWriter);
procedure DefineProperties(Filer: TFiler); override; procedure DefineProperties(Filer: TFiler); override;
{ LCL scaling }
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -264,6 +269,7 @@ type
property BorderSpacing; property BorderSpacing;
property BorderStyle; property BorderStyle;
property Flat read GetFlat write SetFlat default true; property Flat read GetFlat write SetFlat default true;
property Font;
property ScrollBars; property ScrollBars;
property TitleStyle; property TitleStyle;
end; end;
@ -1003,6 +1009,13 @@ begin
mnuEditClick(nil); mnuEditClick(nil);
end; end;
procedure TJvYearGrid.FontChanged(Sender: TObject);
begin
UpdateAllSizes;
AdjustBounds;
Invalidate;
end;
procedure TJvYearGrid.SetBorderColor(const Value: TColor); procedure TJvYearGrid.SetBorderColor(const Value: TColor);
begin begin
if Value <> FBorderColor then if Value <> FBorderColor then
@ -1291,6 +1304,7 @@ var
begin begin
if AutoSize then if AutoSize then
begin begin
Canvas.Font.Assign(Font);
Canvas.Font.Style := [fsBold]; Canvas.Font.Style := [fsBold];
if aoFirstRow in AutoSizeOptions then if aoFirstRow in AutoSizeOptions then
RowHeights[0] := GetHighestTextInRow(0) + CellMargins.Top + CellMargins.Bottom; RowHeights[0] := GetHighestTextInRow(0) + CellMargins.Top + CellMargins.Bottom;
@ -1530,6 +1544,7 @@ begin
with Canvas do with Canvas do
begin begin
Font.Assign(Self.Font);
Font.Color := clBlack; Font.Color := clBlack;
if (ACol = 0) and (ARow = 0) then if (ACol = 0) and (ARow = 0) then
Font.Style := Font.Style + [fsBold] Font.Style := Font.Style + [fsBold]
@ -1614,4 +1629,17 @@ begin
end; end;
end; end;
procedure TJvYearGrid.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
FCellMargins.Left := round(FCellMargins.Left * AXProportion);
FCellMargins.Right := round(FCellMargins.Right * AXProportion);
FCellMargins.Top := round(FCellMargins.Top * AYProportion);
FCellMargins.Bottom := round(FCellMargins.Bottom * AYProportion);
end;
end;
end. end.