You've already forked lazarus-ccr
NiceGrid: Support high-dpi.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8860 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -12,6 +12,10 @@
|
||||
</Flags>
|
||||
<Title Value="basic_demo"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
@ -33,12 +37,12 @@
|
||||
<PackageName Value="NiceGridLaz"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="9">
|
||||
<Units Count="10">
|
||||
<Unit0>
|
||||
<Filename Value="basic_demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<CursorPos X="22" Y="8"/>
|
||||
<UsageCount Value="26"/>
|
||||
<CursorPos X="47" Y="15"/>
|
||||
<UsageCount Value="30"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -96,8 +100,8 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Main"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<CursorPos X="5" Y="15"/>
|
||||
<UsageCount Value="24"/>
|
||||
<CursorPos X="74" Y="23"/>
|
||||
<UsageCount Value="28"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit7>
|
||||
@ -105,86 +109,147 @@
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<UnitName Value="NiceGrid"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="2264"/>
|
||||
<CursorPos X="15" Y="2298"/>
|
||||
<UsageCount Value="10"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="1305"/>
|
||||
<CursorPos X="32" Y="1323"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="..\..\..\..\nicesidebar\source\NiceSideBar.pas"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="740"/>
|
||||
<CursorPos Y="771"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit9>
|
||||
</Units>
|
||||
<JumpHistory Count="17" HistoryIndex="15">
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\common\main.pas"/>
|
||||
<Caret Line="33" Column="22"/>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="311" Column="15" TopLine="295"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\common\main.pas"/>
|
||||
<Caret Line="110" TopLine="106"/>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="1334" Column="63" TopLine="1334"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\common\main.pas"/>
|
||||
<Caret Line="112" Column="13" TopLine="106"/>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\common\main.pas"/>
|
||||
<Caret Line="117" Column="58" TopLine="103"/>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="64" Column="84" TopLine="34"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\common\main.pas"/>
|
||||
<Caret Line="15" Column="5"/>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="205" Column="12" TopLine="175"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="12" Column="28"/>
|
||||
<Caret Line="249" Column="13" TopLine="221"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="396" Column="21" TopLine="367"/>
|
||||
<Caret Line="222" Column="13" TopLine="222"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="662" Column="9" TopLine="632"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="754" Column="11" TopLine="754"/>
|
||||
<Caret Line="251" Column="16" TopLine="223"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="627" Column="14" TopLine="598"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="396" Column="21" TopLine="367"/>
|
||||
<Caret Line="1325" Column="21" TopLine="1296"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="662" Column="9" TopLine="632"/>
|
||||
<Caret Line="1331" Column="21" TopLine="1302"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="396" Column="15" TopLine="379"/>
|
||||
<Caret Line="1339" Column="16" TopLine="1310"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="820" Column="20" TopLine="802"/>
|
||||
<Caret Line="2369" Column="16" TopLine="2340"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="401" Column="32" TopLine="379"/>
|
||||
<Caret Line="2385" Column="16" TopLine="2356"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="2289" Column="18" TopLine="2265"/>
|
||||
<Caret Line="2485" Column="20" TopLine="2456"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="420" Column="14" TopLine="402"/>
|
||||
<Caret Line="2499" Column="20" TopLine="2455"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="547" Column="10" TopLine="529"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="553" Column="35" TopLine="529"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="633" Column="25" TopLine="604"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="2360" Column="23" TopLine="2331"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="2447" Column="44" TopLine="2447"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="636" Column="12" TopLine="607"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="2437" Column="14" TopLine="2407"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="2535" Column="14" TopLine="2506"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="423" Column="14" TopLine="405"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="2306" Column="20" TopLine="2286"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="332" Column="14" TopLine="319"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\..\..\source\nicegrid.pas"/>
|
||||
<Caret Line="627" Column="14" TopLine="598"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="basic_demo"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\common"/>
|
||||
|
@ -10,6 +10,7 @@ uses
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Scaled := true;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
|
@ -8,7 +8,7 @@ object MainForm: TMainForm
|
||||
ClientWidth = 638
|
||||
OnCreate = FormCreate
|
||||
Position = poDesktopCenter
|
||||
LCLVersion = '2.3.0.0'
|
||||
LCLVersion = '3.99.0.0'
|
||||
object Label1: TLabel
|
||||
Left = 16
|
||||
Height = 15
|
||||
@ -41,11 +41,7 @@ object MainForm: TMainForm
|
||||
HeaderLightColor = 16744448
|
||||
HeaderDarkColor = clBlack
|
||||
HeaderFont.Color = clWhite
|
||||
HeaderFont.Height = -11
|
||||
HeaderFont.Name = 'MS Sans Serif'
|
||||
FooterFont.Color = clRed
|
||||
FooterFont.Height = -11
|
||||
FooterFont.Name = 'MS Sans Serif'
|
||||
SelectionColor = 13816575
|
||||
Columns = <
|
||||
item
|
||||
@ -87,8 +83,6 @@ object MainForm: TMainForm
|
||||
GutterKind = gkNumber
|
||||
GutterWidth = 40
|
||||
GutterFont.Color = clWhite
|
||||
GutterFont.Height = -11
|
||||
GutterFont.Name = 'MS Sans Serif'
|
||||
ShowFooter = True
|
||||
OnDrawHeader = NiceGrid1DrawHeader
|
||||
OnInsertRow = NiceGrid1InsertRow
|
||||
|
@ -4,7 +4,7 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="NiceGridLaz"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<Author Value="Priyatna"/>
|
||||
<Author Value="Original Delphi code by Priyatna, Lazarus port by Leledumbo"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
|
@ -403,6 +403,9 @@ type
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure KeyPress(var Key: Char); override;
|
||||
{$IFDEF FPC}
|
||||
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); override;
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -430,6 +433,10 @@ type
|
||||
property VertOffset: Integer read FVertOffset write SetVertOffset;
|
||||
function MergeCells(const X1, Y1, X2, Y2: Integer; ACaption: string): TMergeCell;
|
||||
procedure ClearMergeCells;
|
||||
{$IFDEF FPC}
|
||||
procedure FixDesignFontsPPI(const ADesignTimePPI: Integer); override;
|
||||
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
|
||||
{$ENDIF}
|
||||
|
||||
published
|
||||
property Enabled: Boolean read FEnabled write SetEnabled default True;
|
||||
@ -1275,6 +1282,8 @@ procedure TNiceGrid.DrawSelection;
|
||||
var
|
||||
R, R1, R2: TRect;
|
||||
HOffset, VOffset: Integer;
|
||||
boxSize: Integer;
|
||||
boxSize2: Integer;
|
||||
|
||||
begin
|
||||
|
||||
@ -1307,11 +1316,25 @@ begin
|
||||
else Brush.Color := FGridColor;
|
||||
Pen.Color := clWhite;
|
||||
|
||||
boxSize2 := 6;
|
||||
{$IFDEF FPC}
|
||||
boxSize2 := Scale96ToFont(boxSize2);
|
||||
{$ENDIF}
|
||||
boxSize := boxSize2 div 2;
|
||||
|
||||
case SmallBoxPos of
|
||||
0: SmallBox := Rect(R.Right, R.Bottom, R.Right, R.Bottom);
|
||||
1: SmallBox := Rect(R.Right, R.Top + boxSize2-1, R.Right, R.Top + boxSize2-1);
|
||||
2: SmallBox := Rect(R.Left + boxSize2-1, R.Bottom, R.Left + boxSize2-1, R.Bottom);
|
||||
end;
|
||||
InflateRect(SmallBox, boxSize, boxSize);
|
||||
{
|
||||
case SmallBoxPos of
|
||||
0: SmallBox := Rect(R.Right - 3, R.Bottom - 3, R.Right + 3, R.Bottom + 3);
|
||||
1: SmallBox := Rect(R.Right - 3, R.Top - 3 + 5, R.Right + 3, R.Top + 3 + 5);
|
||||
2: SmallBox := Rect(R.Left - 3 + 5, R.Bottom - 3, R.Left + 3 + 5, R.Bottom + 3);
|
||||
end;
|
||||
}
|
||||
|
||||
Rectangle(SmallBox);
|
||||
SmallBoxPos := 0; // Reset to Right Bottom
|
||||
@ -3465,6 +3488,62 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
// Handle Lazarus' High-DPI scaling
|
||||
procedure TNiceGrid.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||
const AXProportion, AYProportion: Double);
|
||||
var
|
||||
i: Integer;
|
||||
col: TNiceColumn;
|
||||
begin
|
||||
inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
|
||||
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||
begin
|
||||
FDefColWidth := round(FDefColWidth * AYProportion);
|
||||
FDefRowHeight := round(FDefRowHeight * AYProportion);
|
||||
FGutterWidth := round(FGutterWidth * AXProportion);
|
||||
for i := 0 to Columns.Count-1 do
|
||||
begin
|
||||
col := Columns[i];
|
||||
col.Width := round(col.Width * AXProportion);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TNiceGrid.FixDesignFontsPPI(const ADesignTimePPI: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
col: TNiceColumn;
|
||||
begin
|
||||
inherited;
|
||||
DoFixDesignFontPPI(FHeaderFont, ADesignTimePPI);
|
||||
DoFixDesignFontPPI(FGutterFont, ADesignTimePPI);
|
||||
DoFixDesignFontPPI(FFooterFont, ADesignTimePPI);
|
||||
for i := 0 to Columns.Count-1 do
|
||||
begin
|
||||
col := Columns[i];
|
||||
DoFixDesignFontPPI(col.Font, ADesignTimePPI);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TNiceGrid.ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double);
|
||||
var
|
||||
i: Integer;
|
||||
col: TNiceColumn;
|
||||
begin
|
||||
inherited;
|
||||
DoScaleFontPPI(FHeaderFont, AToPPI, AProportion);
|
||||
DoScaleFontPPI(FGutterFont, AToPPI, AProportion);
|
||||
DoScaleFontPPI(FFooterFont, AToPPI, AProportion);
|
||||
for i := 0 to Columns.Count-1 do
|
||||
begin
|
||||
col := Columns[i];
|
||||
DoScaleFontPPI(col.Font, AToPPI, AProportion);
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
{ TNiceColumn }
|
||||
|
||||
constructor TNiceColumn.Create(Collection: TCollection);
|
||||
|
Reference in New Issue
Block a user