Skip to content

Commit 6dcc7bd

Browse files
committed
Making it backward compatible #12
1 parent 758c1ba commit 6dcc7bd

2 files changed

Lines changed: 37 additions & 9 deletions

File tree

Source/Design/PythonTools.Design.Forms.pas

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{$I PythonTools.inc}
12
unit PythonTools.Design.Forms;
23

34
interface
@@ -15,6 +16,9 @@ interface
1516
TDBGrid = class(Vcl.DBGrids.TDBGrid)
1617
protected
1718
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override;
19+
public
20+
function ScaleValue(const Value: Integer): Integer; overload;
21+
function ScaleValue(const Value: TSize): TSize; overload;
1822
end;
1923

2024
TFormsExportDialog = class(TDesignForm)
@@ -94,8 +98,6 @@ procedure DrawCheckBox(const ADBGrid: TDBGrid; const AColumn: TColumn;
9498
const
9599
IS_CHECKED: array[boolean] of integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED);
96100
var
97-
LhTheme: Cardinal;
98-
LSize: TSize;
99101
LStyle: TCustomStyleServices;
100102
LBoxSize: TSize;
101103
LDetail: TThemedButton;
@@ -117,7 +119,7 @@ procedure DrawCheckBox(const ADBGrid: TDBGrid; const AColumn: TColumn;
117119
LDetail := TThemedButton(Integer(LDetail) + 4);
118120

119121
LDetails := LStyle.GetElementDetails(tbCheckBoxUncheckedNormal);
120-
if not LStyle.GetElementSize(gCheckBoxElement.Handle, LDetails, esActual, LBoxSize, ADBGrid.CurrentPPI) then
122+
if not LStyle.GetElementSize(gCheckBoxElement.Handle, LDetails, esActual, LBoxSize {$IFDEF DELPHI10_3_UP}, ADBGrid.CurrentPPI {$ENDIF}) then
121123
begin
122124
LBoxSize.cx := GetSystemMetrics(SM_CXMENUCHECK);
123125
LBoxSize.cy := GetSystemMetrics(SM_CYMENUCHECK);
@@ -130,7 +132,7 @@ procedure DrawCheckBox(const ADBGrid: TDBGrid; const AColumn: TColumn;
130132
RectVCenter(LRect, Rect(0, ARect.Top, ARect.Right, ARect.Bottom));
131133

132134
LDetails := LStyle.GetElementDetails(LDetail);
133-
LStyle.DrawElement(ADBGrid.Canvas.Handle, LDetails, LRect, nil, ADBGrid.CurrentPPI);
135+
LStyle.DrawElement(ADBGrid.Canvas.Handle, LDetails, LRect, nil {$IFDEF DELPHI10_3_UP}, ADBGrid.CurrentPPI {$ENDIF});
134136

135137
if not (gdFocused in AState) then
136138
ADBGrid.Canvas.Brush.Color := LStyle.GetSystemColor(clHighlight);
@@ -213,10 +215,12 @@ procedure TFormsExportDialog.grFormsColEnter(Sender: TObject);
213215

214216
procedure TFormsExportDialog.grFormsDrawColumnCell(Sender: TObject;
215217
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
218+
var
219+
LRect: TRect;
216220
begin
217221
inherited;
218222
if Column.Field.DataType = ftBoolean then begin
219-
var LRect := System.Classes.Rect(
223+
LRect := System.Classes.Rect(
220224
Rect.Left,
221225
Rect.Top,
222226
Rect.Right - (Column.Width div 2),
@@ -363,4 +367,22 @@ procedure TDBGrid.DrawCell(ACol, ARow: Longint; ARect: TRect;
363367
end;
364368
end;
365369

370+
function TDBGrid.ScaleValue(const Value: TSize): TSize;
371+
begin
372+
{$IFDEF DELPHI10_4_UP}
373+
Result := inherited;
374+
{$ELSE}
375+
Result := Value;
376+
{$ENDIF}
377+
end;
378+
379+
function TDBGrid.ScaleValue(const Value: Integer): Integer;
380+
begin
381+
{$IFDEF DELPHI10_4_UP}
382+
Result := inherited;
383+
{$ELSE}
384+
Result := Value;
385+
{$ENDIF}
386+
end;
387+
366388
end.

Source/Menu/PythonTools.Menu.pas

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ TPythonToolsMenu = class
2525
procedure DoCreateMenuHooked(Sender: TObject);
2626
procedure DoDestroyMenu();
2727
public
28-
class constructor Create();
29-
class destructor Destroy();
28+
class procedure Initialize();
29+
class procedure Finalize();
3030

3131
constructor Create();
3232
destructor Destroy(); override;
@@ -81,12 +81,12 @@ TPythonToolsMenuItem = class(TMenuItem)
8181

8282
{ TPythonToolsMenu }
8383

84-
class constructor TPythonToolsMenu.Create;
84+
class procedure TPythonToolsMenu.Initialize;
8585
begin
8686
FInstance := TPythonToolsMenu.Create();
8787
end;
8888

89-
class destructor TPythonToolsMenu.Destroy;
89+
class procedure TPythonToolsMenu.Finalize;
9090
begin
9191
FInstance.Free();
9292
end;
@@ -298,4 +298,10 @@ procedure TToolsMenuEventHook.UnHook(AEvt: TNotifyEvent);
298298
FHook := nil;
299299
end;
300300

301+
initialization
302+
TPythonToolsMenu.Initialize();
303+
304+
finalization
305+
TPythonToolsMenu.Finalize();
306+
301307
end.

0 commit comments

Comments
 (0)