Skip to content

Commit 2038b94

Browse files
ver.1.2.1
- Fixed checkbox drawing in "Windows" style, using rowmargin and/or LinesPerRow - Fixed drawing cell right aligned - Fixed Setting custom cursor for Grid
1 parent 3016fd2 commit 2038b94

8 files changed

+110
-33
lines changed

Demo/DBAwareLabeledComponentsDemo.dproj

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
33
<ProjectGuid>{356F8995-048E-4B76-A115-41D00DD211C4}</ProjectGuid>
4-
<ProjectVersion>19.2</ProjectVersion>
4+
<ProjectVersion>19.4</ProjectVersion>
55
<FrameworkType>VCL</FrameworkType>
66
<Base>True</Base>
77
<Config Condition="'$(Config)'==''">Debug</Config>
@@ -149,17 +149,17 @@
149149
<DCCReference Include="..\Source\Vcl.DbAwareLabeledUtils.pas"/>
150150
<DCCReference Include="..\Source\Vcl.DbAwareLabeledConsts.pas"/>
151151
<DCCReference Include="..\Source\Vcl.BoundLabel.pas"/>
152-
<BuildConfiguration Include="Release">
153-
<Key>Cfg_2</Key>
154-
<CfgParent>Base</CfgParent>
155-
</BuildConfiguration>
156152
<BuildConfiguration Include="Base">
157153
<Key>Base</Key>
158154
</BuildConfiguration>
159155
<BuildConfiguration Include="Debug">
160156
<Key>Cfg_1</Key>
161157
<CfgParent>Base</CfgParent>
162158
</BuildConfiguration>
159+
<BuildConfiguration Include="Release">
160+
<Key>Cfg_2</Key>
161+
<CfgParent>Base</CfgParent>
162+
</BuildConfiguration>
163163
</ItemGroup>
164164
<ProjectExtensions>
165165
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
@@ -503,6 +503,11 @@
503503
<Operation>1</Operation>
504504
<Extensions>.framework</Extensions>
505505
</Platform>
506+
<Platform Name="OSXARM64">
507+
<RemoteDir>Contents\MacOS</RemoteDir>
508+
<Operation>1</Operation>
509+
<Extensions>.framework</Extensions>
510+
</Platform>
506511
<Platform Name="Win32">
507512
<Operation>0</Operation>
508513
</Platform>
@@ -530,6 +535,11 @@
530535
<Operation>1</Operation>
531536
<Extensions>.dylib</Extensions>
532537
</Platform>
538+
<Platform Name="OSXARM64">
539+
<RemoteDir>Contents\MacOS</RemoteDir>
540+
<Operation>1</Operation>
541+
<Extensions>.dylib</Extensions>
542+
</Platform>
533543
<Platform Name="Win32">
534544
<Operation>0</Operation>
535545
<Extensions>.dll;.bpl</Extensions>
@@ -558,6 +568,11 @@
558568
<Operation>1</Operation>
559569
<Extensions>.dylib</Extensions>
560570
</Platform>
571+
<Platform Name="OSXARM64">
572+
<RemoteDir>Contents\MacOS</RemoteDir>
573+
<Operation>1</Operation>
574+
<Extensions>.dylib</Extensions>
575+
</Platform>
561576
<Platform Name="Win32">
562577
<Operation>0</Operation>
563578
<Extensions>.bpl</Extensions>
@@ -587,6 +602,10 @@
587602
<RemoteDir>Contents\Resources\StartUp\</RemoteDir>
588603
<Operation>0</Operation>
589604
</Platform>
605+
<Platform Name="OSXARM64">
606+
<RemoteDir>Contents\Resources\StartUp\</RemoteDir>
607+
<Operation>0</Operation>
608+
</Platform>
590609
<Platform Name="Win32">
591610
<Operation>0</Operation>
592611
</Platform>
@@ -1124,6 +1143,10 @@
11241143
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
11251144
<Operation>1</Operation>
11261145
</Platform>
1146+
<Platform Name="OSXARM64">
1147+
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
1148+
<Operation>1</Operation>
1149+
</Platform>
11271150
</DeployClass>
11281151
<DeployClass Name="ProjectOSXEntitlements">
11291152
<Platform Name="OSX32">
@@ -1134,6 +1157,10 @@
11341157
<RemoteDir>..\</RemoteDir>
11351158
<Operation>1</Operation>
11361159
</Platform>
1160+
<Platform Name="OSXARM64">
1161+
<RemoteDir>..\</RemoteDir>
1162+
<Operation>1</Operation>
1163+
</Platform>
11371164
</DeployClass>
11381165
<DeployClass Name="ProjectOSXInfoPList">
11391166
<Platform Name="OSX32">
@@ -1144,6 +1171,10 @@
11441171
<RemoteDir>Contents</RemoteDir>
11451172
<Operation>1</Operation>
11461173
</Platform>
1174+
<Platform Name="OSXARM64">
1175+
<RemoteDir>Contents</RemoteDir>
1176+
<Operation>1</Operation>
1177+
</Platform>
11471178
</DeployClass>
11481179
<DeployClass Name="ProjectOSXResource">
11491180
<Platform Name="OSX32">
@@ -1154,6 +1185,10 @@
11541185
<RemoteDir>Contents\Resources</RemoteDir>
11551186
<Operation>1</Operation>
11561187
</Platform>
1188+
<Platform Name="OSXARM64">
1189+
<RemoteDir>Contents\Resources</RemoteDir>
1190+
<Operation>1</Operation>
1191+
</Platform>
11571192
</DeployClass>
11581193
<DeployClass Required="true" Name="ProjectOutput">
11591194
<Platform Name="Android">
@@ -1184,6 +1219,10 @@
11841219
<RemoteDir>Contents\MacOS</RemoteDir>
11851220
<Operation>1</Operation>
11861221
</Platform>
1222+
<Platform Name="OSXARM64">
1223+
<RemoteDir>Contents\MacOS</RemoteDir>
1224+
<Operation>1</Operation>
1225+
</Platform>
11871226
<Platform Name="Win32">
11881227
<Operation>0</Operation>
11891228
</Platform>
@@ -1222,17 +1261,17 @@
12221261
<Operation>1</Operation>
12231262
</Platform>
12241263
</DeployClass>
1225-
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
1226-
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
1264+
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
1265+
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
12271266
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
1228-
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
1267+
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
1268+
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
12291269
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
1230-
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
12311270
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
1232-
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
12331271
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
1234-
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
1235-
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
1272+
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
1273+
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
1274+
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
12361275
</Deployment>
12371276
<Platforms>
12381277
<Platform value="Win32">True</Platform>
494 KB
Binary file not shown.

Packages/D11/DBAwareLabeledComponents.dproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@
109109
<DCCReference Include="..\..\Source\Vcl.LabeledDBListView.pas"/>
110110
<DCCReference Include="..\..\Source\Vcl.LabeledShellUtils.pas"/>
111111
<DCCReference Include="..\..\Source\Vcl.LabeledCurrencyEdit.pas"/>
112-
<BuildConfiguration Include="Release">
113-
<Key>Cfg_2</Key>
114-
<CfgParent>Base</CfgParent>
115-
</BuildConfiguration>
116112
<BuildConfiguration Include="Base">
117113
<Key>Base</Key>
118114
</BuildConfiguration>
119115
<BuildConfiguration Include="Debug">
120116
<Key>Cfg_1</Key>
121117
<CfgParent>Base</CfgParent>
122118
</BuildConfiguration>
119+
<BuildConfiguration Include="Release">
120+
<Key>Cfg_2</Key>
121+
<CfgParent>Base</CfgParent>
122+
</BuildConfiguration>
123123
</ItemGroup>
124124
<ProjectExtensions>
125125
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
@@ -129,8 +129,7 @@
129129
<Source>
130130
<Source Name="MainSource">DBAwareLabeledComponents.dpk</Source>
131131
</Source>
132-
<Excluded_Packages>
133-
</Excluded_Packages>
132+
<Excluded_Packages/>
134133
</Delphi.Personality>
135134
<Deployment Version="3">
136135
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
0 Bytes
Binary file not shown.

Packages/D11/dclDBAwareLabeledComponents.dproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@
8484
</DelphiCompile>
8585
<DCCReference Include="DBAwareLabeledComponents.dcp"/>
8686
<DCCReference Include="..\..\Source\Vcl.DBAwareLabeledComponentsRegistry.pas"/>
87-
<BuildConfiguration Include="Release">
88-
<Key>Cfg_2</Key>
89-
<CfgParent>Base</CfgParent>
90-
</BuildConfiguration>
9187
<BuildConfiguration Include="Base">
9288
<Key>Base</Key>
9389
</BuildConfiguration>
9490
<BuildConfiguration Include="Debug">
9591
<Key>Cfg_1</Key>
9692
<CfgParent>Base</CfgParent>
9793
</BuildConfiguration>
94+
<BuildConfiguration Include="Release">
95+
<Key>Cfg_2</Key>
96+
<CfgParent>Base</CfgParent>
97+
</BuildConfiguration>
9898
</ItemGroup>
9999
<ProjectExtensions>
100100
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
@@ -104,8 +104,7 @@
104104
<Source>
105105
<Source Name="MainSource">dclDBAwareLabeledComponents.dpk</Source>
106106
</Source>
107-
<Excluded_Packages>
108-
</Excluded_Packages>
107+
<Excluded_Packages/>
109108
</Delphi.Personality>
110109
<Deployment Version="3">
111110
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
12 Bytes
Binary file not shown.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Classic Delphi-VCL Editors plus a Boundary-Label (DB-Aware and Standard) including NumberBox, plus an Extended DbGrid
44

5-
### Actual official version 1.2.0 (VCL)
5+
### Actual official version 1.2.1 (VCL)
66

77
With this small library of VCL components it is possible to have the classic VCL editors (standard and data-aware) with the addition of a "label" attached to the component itself (like the native component TLabeledEdit).
88

@@ -76,6 +76,11 @@ _{InstallDir}\Source_
7676
Coming soon, into Wiki section.
7777

7878
### RELEASE NOTES
79+
19 Aug 2022: ver.1.2.1
80+
- Fixed checkbox drawing in "Windows" style, using rowmargin and/or LinesPerRow
81+
- Fixed drawing cell right aligned
82+
- Fixed Setting custom cursor for Grid
83+
7984
15 Jun 2022: ver.1.2.0
8085
- Added TLabeledButtonEdit and TLabeledDBButtonEdit (from Delphi 10.1)
8186
- Updated Demo with TLabeledButtonEdit and TLabeledDBButtonEdit examples

Source/Vcl.LabeledDBCtrls.pas

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ TLabeledDbGrid = class(TDBGrid)
351351
procedure ClearCell(Rect: TRect; const State: TGridDrawState);
352352
function GetTitleFont: TFont;
353353
procedure SetTitleFont(const Value: TFont);
354+
function GetCursor: TCursor;
355+
procedure SetCursor(const Value: TCursor);
354356
protected
355357
procedure SetParent(AParent: TWinControl); override;
356358
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
@@ -403,6 +405,7 @@ TLabeledDbGrid = class(TDBGrid)
403405
property Options default [dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgConfirmDelete];
404406
property BoundCaption: TCaption read FBoundCaption write SetBoundCaption;
405407
property BoundLabel: TControlBoundLabel read FBoundLabel;
408+
property Cursor: TCursor read GetCursor write SetCursor default crDefault;
406409
property HighlightCurrRow: boolean read FHighlightCurrRow write SetHighlightCurrRow default True;
407410
property AlternateRowColor: boolean read FAlternateRowColor write SetAlternateRowColor default True;
408411
property OnColWidthsChanged: TNotifyEvent read FOnColWidthsChanged write FOnColWidthsChanged;
@@ -1161,6 +1164,7 @@ procedure TLabeledDbGrid.ColWidthsChanged;
11611164
inherited;
11621165
if (inherited LayoutLock = 0) and Assigned(FOnColWidthsChanged) then
11631166
FOnColWidthsChanged(self);
1167+
LayoutChanged;
11641168
end;
11651169

11661170
procedure TLabeledDbGrid.KeyDown(var Key: Word; Shift: TShiftState);
@@ -1337,6 +1341,13 @@ procedure TLabeledDbGrid.StandardTitleClick(Column: TColumn);
13371341
End;
13381342
end;
13391343

1344+
procedure TLabeledDbGrid.SetCursor(const Value: TCursor);
1345+
begin
1346+
if Value <> crDefault then
1347+
FCursorIsDefault := False;
1348+
inherited Cursor := Value;
1349+
end;
1350+
13401351
procedure TLabeledDbGrid.SetDrawCheckBoxImages(const Value: Boolean);
13411352
begin
13421353
if FDrawCheckBoxImages <> Value then
@@ -1444,7 +1455,7 @@ procedure TLabeledDbGrid.LayoutChanged;
14441455
UpdateRowCount;
14451456

14461457
// set the height of each row
1447-
DefaultRowHeight := (LPixelsPerRow * FLinesPerRow) + FRowMargin;
1458+
DefaultRowHeight := (LPixelsPerRow * FLinesPerRow) + (FRowMargin*2);
14481459
if TitleOffset = 1 then
14491460
RowHeights[0] := LPixelsTitle;
14501461
finally
@@ -1464,6 +1475,12 @@ function TLabeledDbGrid.CanApplyCustomColors: boolean;
14641475

14651476
procedure TLabeledDbGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer;
14661477
Column: TColumn; State: TGridDrawState);
1478+
const
1479+
AlignFlags : array [TAlignment] of Integer =
1480+
( DT_LEFT or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX,
1481+
DT_RIGHT or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX,
1482+
DT_CENTER or DT_WORDBREAK or DT_EXPANDTABS or DT_NOPREFIX );
1483+
RTL: array [Boolean] of Integer = (0, DT_RTLREADING);
14671484
var
14681485
CellColor: TColor;
14691486
OutRect: TRect;
@@ -1531,19 +1548,20 @@ procedure TLabeledDbGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer;
15311548

15321549
ClearCell(Rect, State);
15331550

1534-
// Event Handler
1535-
if Assigned(OnDrawColumnCell) then
1536-
OnDrawColumnCell(Self, Rect, DataCol, Column, State);
1537-
15381551
// Se il tipo di dato è Boolean, mostra in alternativa alle diciture
15391552
// false e true, l'immagine check e uncheck
15401553
if (not (csLoading in ComponentState)) and isCheckBoxedColumn(Column) and FDrawCheckBoxImages then
15411554
begin
15421555
ClearCell(Rect, State);
1556+
// Event Handler
1557+
if Assigned(OnDrawColumnCell) then
1558+
OnDrawColumnCell(Self, Rect, DataCol, Column, State);
1559+
15431560
DrawCheckImage(Rect, Column, State);
15441561
end
15451562
else
15461563
begin
1564+
//This section is the equivalent of DefaultDrawColumnCell
15471565
OutRect := Rect;
15481566
//Reduce output
15491567
InflateRect(OutRect, -2, -2);
@@ -1557,7 +1575,7 @@ procedure TLabeledDbGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer;
15571575
//memo field: draw wordwrap text
15581576
if Column.Field.DataType in [ftMemo, ftFmtMemo, ftWideMemo] then
15591577
begin
1560-
InflateRect(OutRect, 0, -FRowMargin div 2);
1578+
InflateRect(OutRect, 0, -(FRowMargin*2) div 2);
15611579
LFormat := dt_WordBreak or dt_NoPrefix;
15621580
LFieldValue := Column.Field.AsString;
15631581
end;
@@ -1567,13 +1585,17 @@ procedure TLabeledDbGrid.DrawColumnCell(const Rect: TRect; DataCol: Integer;
15671585
ChangeBiDiModeAlignment(LAlignment);
15681586
case LAlignment of
15691587
taRightJustify:
1570-
OutRect.Left := OutRect.Right - Canvas.TextWidth(LFieldValue) - 3;
1588+
OutRect.Left := Max(OutRect.Left,OutRect.Right - Canvas.TextWidth(LFieldValue) - 3);
15711589
taCenter:
15721590
OutRect.Left := OutRect.Left + (OutRect.Right - OutRect.Left) div 2
15731591
- (Canvas.TextWidth(LfieldValue) div 2);
15741592
end;
15751593
end;
1576-
DrawText(Canvas.Handle, PChar(LFieldValue), Length(LFieldValue), OutRect, LFormat);
1594+
DrawText(Canvas.Handle, PChar(LFieldValue), Length(LFieldValue), OutRect,
1595+
AlignFlags[Column.Alignment] or RTL[LRightToLeft] or LFormat);
1596+
// Event Handler
1597+
if Assigned(OnDrawColumnCell) then
1598+
OnDrawColumnCell(Self, Rect, DataCol, Column, State);
15771599
end;
15781600
end;
15791601

@@ -1597,6 +1619,11 @@ function TLabeledDbGrid.GetCheckBounds(Rect: TRect; Alignment: TAlignment): TRec
15971619
Result.Bottom := Result.Top + Check_Size;
15981620
end;
15991621

1622+
function TLabeledDbGrid.GetCursor: TCursor;
1623+
begin
1624+
Result := inherited Cursor;
1625+
end;
1626+
16001627
procedure TLabeledDbGrid.ClearCell(Rect: TRect; const State: TGridDrawState);
16011628
begin
16021629
if (gdFocused in State) and StyleServices.Enabled then
@@ -1615,6 +1642,7 @@ procedure TLabeledDbGrid.DrawCheckImage(Rect: TRect; Column: TColumn;
16151642
LState: TCheckBoxState;
16161643
LDetails: TThemedElementDetails;
16171644
LOutRect: TRect;
1645+
LHeight, LMargin: Integer;
16181646

16191647
function GetDrawState(AState: TCheckBoxState): TThemedButton;
16201648
begin
@@ -1636,6 +1664,13 @@ procedure TLabeledDbGrid.DrawCheckImage(Rect: TRect; Column: TColumn;
16361664

16371665
begin
16381666
LOutRect := GetCheckBounds(Rect, Column.Alignment);
1667+
//Recalc OutRect considering rowmargin and rowLines
1668+
LMargin := Round(FRowMargin)+1;
1669+
LHeight := Rect.Height-(FRowMargin*2);
1670+
LMargin := LMargin + Round((LHeight - (LHeight / FLinesPerRow)) / 2);
1671+
LOutRect.Top := LOutRect.Top + LMargin;
1672+
LOutRect.Bottom := LOutRect.Bottom - LMargin;
1673+
16391674
if Column.Field.IsNull then
16401675
LState := cbGrayed
16411676
else if Column.Field.AsBoolean then

0 commit comments

Comments
 (0)