Skip to content

Commit 3196c76

Browse files
*Fixed rendering on TButton!
*Fixed rendering with Delphi7
1 parent 2cc7c0b commit 3196c76

File tree

4 files changed

+30
-82
lines changed

4 files changed

+30
-82
lines changed

Packages/IconFontsImageListEditorUnit.dfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ object IconFontsImageListEditor: TIconFontsImageListEditor
394394
Align = alClient
395395
Stretch = True
396396
Transparent = True
397-
ExplicitLeft = 6
398397
end
399398
end
400399
object IconName: TEdit

Source/IconFontsCharMapUnit.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface
4747
, ExtDlgs
4848
, Spin
4949
, IconFontsImageList
50-
, ActnList, System.Actions
50+
, ActnList
5151
;
5252

5353
type

Source/IconFontsImage.pas

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ interface
3838
{$IFDEF GDI+}
3939
, Winapi.GDIPOBJ
4040
{$ENDIF}
41-
, System.Classes
42-
, Vcl.Graphics
43-
, Vcl.Controls
41+
, Classes
42+
, Graphics
43+
, Controls
4444
, IconFontsImageList;
4545

4646
type
@@ -225,8 +225,13 @@ procedure TIconFontImage.Paint;
225225
end
226226
else
227227
begin
228+
{$IFDEF DXE8+}
228229
LBounds.Width := Round(ImageWidth * FScale);
229230
LBounds.Height := Round(ImageHeight * FScale);
231+
{$ELSE}
232+
LBounds.Right := Round(ImageWidth * FScale);
233+
LBounds.Bottom := Round(ImageHeight * FScale);
234+
{$ENDIF}
230235
end;
231236
end;
232237

@@ -245,8 +250,13 @@ procedure TIconFontImage.Paint;
245250
LBounds.Top := 0;
246251
if FCenter then
247252
begin
253+
{$IFDEF DXE8+}
248254
LBounds.Left := Round((Width - LBounds.Width) / 2);
249-
LBounds. Top := Round((Height - LBounds.Height) / 2);
255+
LBounds.Top := Round((Height - LBounds.Height) / 2);
256+
{$ELSE}
257+
LBounds.Left := Round((Width - LBounds.Right - LBounds.Left) / 2);
258+
LBounds.Top := Round((Height - LBounds.Bottom - LBounds.Top) / 2);
259+
{$ENDIF}
250260
end;
251261
{$ENDIF}
252262
end;
@@ -310,9 +320,15 @@ procedure TIconFontImage.Paint;
310320
LGraphics.Free;
311321
end;
312322
{$ELSE}
313-
LIconFont.PaintTo(Self.Canvas,
314-
LBounds.Left, LBounds.Top, LBounds.Width, LBounds.Height, LFontName,
315-
LFontIconDec, LFontColor, LMaskColor, Enabled, LDisabledFactor);
323+
{$IFDEF DXE8+}
324+
LIconFont.PaintTo(Self.Canvas,
325+
LBounds.Left, LBounds.Top, LBounds.Width, LBounds.Height, LFontName,
326+
LFontIconDec, LFontColor, LMaskColor, Enabled, LDisabledFactor);
327+
{$ELSE}
328+
LIconFont.PaintTo(Self.Canvas,
329+
LBounds.Left, LBounds.Top, LBounds.Right - LBounds.Left, LBounds.Bottom - LBounds.Top, LFontName,
330+
LFontIconDec, LFontColor, LMaskColor, Enabled, LDisabledFactor);
331+
{$ENDIF}
316332
{$ENDIF}
317333
end;
318334

Source/IconFontsImageList.pas

Lines changed: 6 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface
5454
ERR_ICONFONTS_FONT_NOT_INSTALLED = 'Font "%s" is not installed!';
5555

5656
const
57-
IconFontsImageListVersion = '2.0.0';
57+
IconFontsImageListVersion = '2.1.0';
5858
DEFAULT_SIZE = 16;
5959

6060
type
@@ -324,58 +324,7 @@ implementation
324324
, StrUtils
325325
;
326326

327-
328327
{$IFDEF GDI+}
329-
(*
330-
type
331-
TBoxAlignment = (baTopLeft, baTopCenter, baTopRight,
332-
baCenterLeft, baCenterCenter, baCenterRight,
333-
baBottomLeft, baBottomCenter, baBottomRight);
334-
335-
function CalcRect(const Bounds: TGPRectF; const Width, Height: Double;
336-
const Alignment: TBoxAlignment): TGPRectF;
337-
var
338-
R: Double;
339-
begin
340-
if Height > 0 then
341-
R := Width / Height
342-
else
343-
R := 1;
344-
345-
if (Bounds.Height <> 0) and
346-
(Bounds.Width / Bounds.Height > R) then
347-
begin
348-
Result.Width := Bounds.Height * R;
349-
Result.Height := Bounds.Height;
350-
end else
351-
begin
352-
Result.Width := Bounds.Width;
353-
Result.Height := Bounds.Width / R;
354-
end;
355-
356-
case Alignment of
357-
baTopCenter, baCenterCenter, baBottomCenter:
358-
Result.X := (Bounds.Width - Result.Width) / 2;
359-
baTopRight, baCenterRight, baBottomRight:
360-
Result.X := Bounds.Width - Result.Width;
361-
else
362-
Result.X := 0;
363-
end;
364-
365-
case Alignment of
366-
baCenterLeft, baCenterCenter, baCenterRight:
367-
Result.Y := (Bounds.Height - Result.Height) / 2;
368-
baBottomLeft, baBottomCenter, baBottomRight:
369-
Result.Y := Bounds.Height - Result.Height;
370-
else
371-
Result.Y := 0;
372-
end;
373-
374-
Result.X := Result.X + Bounds.X;
375-
Result.Y := Result.Y + Bounds.Y;
376-
end;
377-
*)
378-
379328
function GPColor(Col: TColor; Alpha: Byte): TGPColor;
380329

381330
type
@@ -517,26 +466,7 @@ procedure TIconFontsImageList.SetDisabledFactor(const Value: Byte);
517466
{$IFDEF GDI+}
518467
procedure TIconFontsImageList.DoDraw(Index: Integer; Canvas: TCanvas; X, Y: Integer;
519468
Style: Cardinal; Enabled: Boolean);
520-
(*
521-
var
522-
LMasked: Boolean;
523-
LDrawingStyle: TDrawingStyle;
524-
LStyle: Longint;
525-
I: Integer;
526-
*)
527-
begin
528-
(*
529-
LMasked := (Style and Cardinal(ILD_MASK)) <> 0;
530-
LStyle := LongInt(Style) and not LongInt(ILD_MASK);
531-
case LStyle of
532-
ILD_FOCUS: LDrawingStyle := TDrawingStyle.dsFocus;
533-
ILD_SELECTED: LDrawingStyle := TDrawingStyle.dsSelected;
534-
ILD_NORMAL: LDrawingStyle := TDrawingStyle.dsNormal;
535-
ILD_TRANSPARENT: LDrawingStyle := TDrawingStyle.dsTransparent;
536-
else
537-
LDrawingStyle := TDrawingStyle.dsNormal;
538-
end;
539-
*)
469+
begin
540470
PaintTo(Canvas, Index, X, Y, Width, Height, Enabled);
541471
end;
542472

@@ -737,6 +667,9 @@ procedure TIconFontsImageList.ClearIcons;
737667
constructor TIconFontsImageList.Create(AOwner: TComponent);
738668
begin
739669
inherited;
670+
{$IFDEF D2010+}
671+
ColorDepth := cd32Bit;
672+
{$ENDIF}
740673
FStopDrawing := 0;
741674
FFontColor := clNone;
742675
FMaskColor := clNone;
@@ -1714,7 +1647,7 @@ procedure TIconFont.PaintTo(const ACanvas: TCanvas;
17141647
{$WARN SYMBOL_DEPRECATED ON}
17151648
TextOut(X, Y, S);
17161649
{$ELSE}
1717-
S := WideChar(FFontIconDec);
1650+
S := WideChar(AFontIconDec);
17181651
TextOutW(ACanvas.Handle, X, Y, PWideChar(S), 1);
17191652
{$ENDIF}
17201653
end;

0 commit comments

Comments
 (0)