Skip to content

Commit afd3f20

Browse files
committed
Added support for Rad Studio 10 Seattle
1 parent 33818f5 commit afd3f20

30 files changed

+6601
-2290
lines changed

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Fixes.pas

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ interface
3737
Vcl.ExtCtrls,
3838
Vcl.Graphics;
3939

40-
{$IF CompilerVersion = 23.0}
40+
{$IF CompilerVersion >= 23.0}
4141
type
4242
/// <summary> The <c>TButtonStyleHookFix</c> vcl style hook fix these QC #103708, #107764 for Delphi XE2
43+
/// and the https://quality.embarcadero.com/browse/RSP-11619 issue present in X2-XE8
4344
/// </summary>
4445
/// <remarks>
4546
/// Use this hook in this way
@@ -103,6 +104,7 @@ implementation
103104
uses
104105
Winapi.CommCtrl,
105106
Vcl.Themes,
107+
Vcl.Forms,
106108
System.Classes,
107109
System.UITypes,
108110
System.Types;
@@ -111,7 +113,7 @@ implementation
111113
TCustomButtonClass = class(TCustomButton);
112114
TWinControlClass = class(TWinControl);
113115

114-
{$IF CompilerVersion = 23.0}
116+
{$IF CompilerVersion >= 23.0}
115117

116118
// we need this helper to access some strict private fields
117119
TButtonStyleHookHelper = class Helper for TButtonStyleHook
@@ -133,7 +135,7 @@ TComboBoxExStyleHookHelper = class helper for TComboBoxExStyleHook
133135
end;
134136
{$IFEND}
135137

136-
{$IF CompilerVersion = 23.0}
138+
{$IF CompilerVersion >= 23.0}
137139

138140
procedure TButtonStyleHookFix.Paint(Canvas: TCanvas);
139141
const
@@ -154,55 +156,42 @@ procedure TButtonStyleHookFix.Paint(Canvas: TCanvas);
154156
BufferLength: Integer;
155157
SaveIndex: Integer;
156158
X, Y, I: Integer;
159+
IsDefault: Boolean;
157160
BCaption: String;
158161
LImageIndex: Integer;
159162
begin
160-
// LImageIndex:=PBS_NORMAL;
163+
LImageIndex:=PBS_NORMAL;
164+
IsDefault := (Control is TCustomButton) and (TCustomButton(Control).Default);
161165

162166
if StyleServices.Available then
163167
begin
164168
BCaption := Text;
169+
170+
if not Control.Enabled then
171+
begin
172+
LDetails := StyleServices.GetElementDetails(tbPushButtonDisabled);
173+
LImageIndex := PBS_DISABLED;
174+
end
175+
else
165176
if Pressed then
166177
begin
167178
LDetails := StyleServices.GetElementDetails(tbPushButtonPressed);
168179
LImageIndex := PBS_PRESSED;
169180
end
170-
else if MouseInControl then
181+
else
182+
if MouseInControl then
171183
begin
172184
LDetails := StyleServices.GetElementDetails(tbPushButtonHot);
173185
LImageIndex := PBS_HOT;
174186
end
175-
else if Focused then
187+
else
188+
if Focused or (IsDefault and (Screen.ActiveControl<>nil) and not (Screen.ActiveControl is TCustomButton) ) then
176189
begin
177-
if not Control.Enabled then
178-
begin
179-
LDetails := StyleServices.GetElementDetails(tbPushButtonDisabled);
180-
LImageIndex := PBS_DISABLED;
181-
end
182-
else
183-
begin
184-
// if MouseInControl then
185-
begin
186-
LDetails := StyleServices.GetElementDetails(tbPushButtonDefaulted);
187-
LImageIndex := PBS_DEFAULTED;
188-
end;
189-
(* else
190-
begin
191-
LDetails := StyleServices.GetElementDetails(tbPushButtonNormal);
192-
LImageIndex := PBS_NORMAL;
193-
end; *)
194-
end;
190+
LDetails := StyleServices.GetElementDetails(tbPushButtonDefaulted);
191+
LImageIndex := PBS_DEFAULTED;
195192
end
196193
else if Control.Enabled then
197-
begin
198194
LDetails := StyleServices.GetElementDetails(tbPushButtonNormal);
199-
LImageIndex := PBS_NORMAL;
200-
end
201-
else
202-
begin
203-
LDetails := StyleServices.GetElementDetails(tbPushButtonDisabled);
204-
LImageIndex := PBS_DISABLED;
205-
end;
206195

207196
DrawRect := Control.ClientRect;
208197
StyleServices.DrawElement(Canvas.Handle, LDetails, DrawRect);

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Hooks.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ function Detour_LoadImageW(hInst: HINST; ImageName: LPCWSTR; ImageType: UINT; X,
534534
:
535535
begin
536536
//OutputDebugString(PChar('GetModuleName '+GetModuleName(hInst)));
537-
Exit(AwesomeFont.GetIcon(fa_check_square_o, 16, 16, StyleServices.GetSystemColor(clWindowText), StyleServices.GetSystemColor(clWindow), 0));
537+
Exit(AwesomeFont.GetIcon(fa_thumb_tack, 16, 16, 12, 12, StyleServices.GetSystemColor(clWindowText), StyleServices.GetSystemColor(clWindow), 0));
538+
//Exit(AwesomeFont.GetIcon(fa_check_square_o, 16, 16, StyleServices.GetSystemColor(clWindowText), StyleServices.GetSystemColor(clWindow), 0));
538539
end;
539540
end;
540541

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.NC.pas

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ interface
2828
System.Classes,
2929
System.Generics.Collections,
3030
System.Types,
31-
System.UITypes,
3231
Winapi.Windows,
3332
Winapi.Messages,
3433
Vcl.ImgList,
34+
System.UITypes,
3535
Vcl.Graphics,
3636
Vcl.Themes,
3737
Vcl.Styles,
@@ -82,6 +82,8 @@ TNCControls = class(TComponent)
8282
procedure SetImages(const Value: TCustomImageList);
8383
procedure SetShowSystemMenu(const Value: Boolean);
8484
procedure SetShowCaption(const Value: Boolean);
85+
function GetActiveTabButtonIndex: Integer;
86+
procedure SetActiveTabButtonIndex(const Value: Integer);
8587
property FormBorderSize : TRect read FFormBorderSize write FFormBorderSize;
8688
property Form : TCustomForm read FForm;
8789
public
@@ -93,6 +95,9 @@ TNCControls = class(TComponent)
9395
constructor Create(AOwner: TComponent);override;
9496
destructor Destroy; override;
9597
published
98+
99+
property ActiveTabButtonIndex : Integer read GetActiveTabButtonIndex write SetActiveTabButtonIndex;
100+
96101
property ButtonsList : TListNCButtons read FButtons;
97102
property Visible : Boolean read FVisible write SetVisible default True;
98103
property Images: TCustomImageList read FImages write SetImages;
@@ -166,7 +171,6 @@ TNCButton = class(TCollectionItem)
166171
procedure SetShowHint(const Value: Boolean);
167172
procedure SetName(const Value: TComponentName);
168173
procedure SetUseFontAwesome(const Value: Boolean);
169-
property TabIndex : Integer read GetTabIndex;
170174
protected
171175
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); virtual;
172176
public
@@ -179,6 +183,7 @@ TNCButton = class(TCollectionItem)
179183
property Height: Integer read FHeight write SetHeight;
180184
property NCControls: TNCControls read FNCControls;
181185
property BoundsRect: TRect read GetBoundsRect write SetBoundsRect;
186+
property TabIndex : Integer read GetTabIndex;
182187
published
183188
property Style: TNCButtonStyle read FStyle write SetStyle;
184189

@@ -209,6 +214,7 @@ TNCButton = class(TCollectionItem)
209214
property Name: TComponentName read FName write SetName stored False;
210215
property Tag: NativeInt read FTag write FTag default 0;
211216

217+
212218
property UseFontAwesome : Boolean read FUseFontAwesome write SetUseFontAwesome;
213219

214220
property OnDropDownClick: TNotifyEvent read FOnDropDownClick write FOnDropDownClick;
@@ -331,9 +337,14 @@ destructor TNCControls.Destroy;
331337
end;
332338

333339

340+
function TNCControls.GetActiveTabButtonIndex: Integer;
341+
begin
342+
Result:= FActiveTabButtonIndex;
343+
end;
344+
334345
function TNCControls.GetButton(index: Integer): TNCButton;
335346
begin
336-
Result:=FButtons[Index];
347+
Result:= FButtons[Index];
337348
end;
338349

339350
function TNCControls.GetCount: Integer;
@@ -354,6 +365,30 @@ procedure TNCControls.Invalidate;
354365
SendMessage(FForm.Handle, WM_NCPAINT, 0, 0);
355366
end;
356367

368+
procedure TNCControls.SetActiveTabButtonIndex(const Value: Integer);
369+
370+
function GetMaxTabIndex : Integer;
371+
var
372+
i : integer;
373+
begin
374+
Result:=-1;
375+
For i:=0 to FButtons.Count-1 do
376+
if FButtons[i].Style=nsTab then
377+
Inc(Result);
378+
end;
379+
380+
var
381+
lmax, i : Integer;
382+
begin
383+
lmax:=GetMaxTabIndex;
384+
if (Value<>FActiveTabButtonIndex) and (Value>=0) and (lmax>=0) and (Value<=lmax) then
385+
begin
386+
FActiveTabButtonIndex:=Value;
387+
Invalidate;
388+
end;
389+
390+
end;
391+
357392
procedure TNCControls.SetImages(const Value: TCustomImageList);
358393
begin
359394
FImages := Value;

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Utils.ComCtrls.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,14 +415,14 @@ procedure TSysListViewStyleHook.UpdateColors;
415415
if OverrideEraseBkgnd then
416416
Color := StyleServices.GetStyleColor(scListView)
417417
else
418-
Color := clWhite;
418+
Color := clWindow;
419419
if OverrideFont then
420420
FontColor := StyleServices.GetSystemColor(clWindowText)
421421
else
422422
FontColor := clWindowText;
423423

424-
ListView_SetBkColor(Handle, Color);
425-
ListView_SetTextBkColor(Handle, Color);
424+
ListView_SetBkColor(Handle, ColorToRGB(Color));
425+
ListView_SetTextBkColor(Handle, ColorToRGB(Color));
426426
ListView_SetTextColor(Handle, ColorToRGB(FontColor));
427427

428428
end;
@@ -828,8 +828,8 @@ procedure TSysTreeViewStyleHook.WndProc(var Message: TMessage);
828828
if (TreeView_GetBkColor(Handle) <> COLORREF(Color)) then
829829
begin
830830
// SetWindowTheme(Handle, '', '');
831-
TreeView_SetBkColor(Handle, Color);
832-
TreeView_SetTextColor(Handle, FontColor);
831+
TreeView_SetBkColor(Handle, ColorToRGB(Color));
832+
TreeView_SetTextColor(Handle, ColorToRGB(FontColor));
833833
end;
834834
Message.Result := CallDefaultProc(Message);
835835
Exit;

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Utils.Graphics.pas

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ TAwesomeFont = class
580580
procedure DrawChar(DC: HDC; const AChar: Char; DestRect: TRect; AColor : TColor; Orientation : Integer = 0; ImageAlignment: TImageAlignment = iaLeft); overload;
581581
procedure DrawChar(DC: HDC; const ACode: Word; DestRect: TRect; AColor : TColor; Orientation : Integer = 0; ImageAlignment: TImageAlignment = iaLeft); overload;
582582
function GetIcon(const ACode: Word; Width, Height : Integer; AColor, ABackColor : TColor; Orientation : Integer = 0; ImageAlignment: TImageAlignment = iaLeft) : HICON; overload;
583+
function GetIcon(const ACode: Word; Width, Height, CharX, CharY : Integer; AColor, ABackColor : TColor; Orientation : Integer = 0; ImageAlignment: TImageAlignment = iaLeft) : HICON; overload;
583584
end;
584585

585586

@@ -2769,7 +2770,9 @@ procedure TAwesomeFont.DrawChar(DC: HDC; const ACode: Word; DestRect: TRect; ACo
27692770
DrawChar(DC, Chr(ACode), DestRect, AColor, Orientation, ImageAlignment);
27702771
end;
27712772

2772-
function TAwesomeFont.GetIcon(const ACode: Word; Width, Height: Integer; AColor, ABackColor: TColor; Orientation: Integer = 0; ImageAlignment: TImageAlignment = iaLeft): HICON;
2773+
function TAwesomeFont.GetIcon(const ACode: Word; Width, Height, CharX,
2774+
CharY: Integer; AColor, ABackColor: TColor; Orientation: Integer;
2775+
ImageAlignment: TImageAlignment): HICON;
27732776
var
27742777
LIconInfo : TIconInfo;
27752778
LBitmap, LMask : TBitmap;
@@ -2783,7 +2786,8 @@ function TAwesomeFont.GetIcon(const ACode: Word; Width, Height: Integer; AColor,
27832786
//LBitmap.Canvas.FillRect(Rect(0, 0, LBitmap.Width, LBitmap.Height));
27842787
//Bitmap32_SetAlphaAndColor(LBitmap, 255, clFuchsia);
27852788

2786-
DrawChar(LBitmap.Canvas.Handle, ACode, Rect(0, 0, LBitmap.Width, LBitmap.Height), AColor, Orientation, ImageAlignment);
2789+
//DrawChar(LBitmap.Canvas.Handle, ACode, Rect(0, 0, LBitmap.Width, LBitmap.Height), AColor, Orientation, ImageAlignment);
2790+
DrawChar(LBitmap.Canvas.Handle, ACode, Rect(0, 0, CharX, CharY), AColor, Orientation, ImageAlignment);
27872791
Bitmap32_SetAlphaExceptColor(LBitmap, 255, ABackColor);
27882792
LBitmap.AlphaFormat := afDefined;
27892793

@@ -2808,6 +2812,12 @@ function TAwesomeFont.GetIcon(const ACode: Word; Width, Height: Integer; AColor,
28082812
LBitmap.Free;
28092813
end;
28102814
end;
2815+
2816+
2817+
function TAwesomeFont.GetIcon(const ACode: Word; Width, Height: Integer; AColor, ABackColor: TColor; Orientation: Integer = 0; ImageAlignment: TImageAlignment = iaLeft): HICON;
2818+
begin
2819+
Result:=GetIcon(ACode, Width, Height, Width, Height, AColor, ABackColor, Orientation, ImageAlignment);
2820+
end;
28112821
procedure TAwesomeFont.DrawChar(DC: HDC; const AChar: Char; DestRect: TRect; AColor: TColor; Orientation : Integer = 0; ImageAlignment: TImageAlignment = iaLeft);
28122822
var
28132823
LogFont: TLogFont;

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Utils.Menus.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,14 @@ procedure TSysPopupStyleHook.DrawItem(Canvas: TCanvas; const Index: integer; con
436436
LogFont.lfFaceName := 'Marlett';
437437

438438
if Disabled then
439-
oldColor := StyleServices.GetStyleFontColor(sfPopupMenuItemTextDisabled)
439+
oldColor := ColorToRGB(StyleServices.GetStyleFontColor(sfPopupMenuItemTextDisabled))
440440
else
441441
begin
442-
oldColor := StyleServices.GetStyleFontColor(sfPopupMenuItemTextNormal);
442+
oldColor := ColorToRGB(StyleServices.GetStyleFontColor(sfPopupMenuItemTextNormal));
443443
if isHot in State then
444-
oldColor := StyleServices.GetStyleFontColor(sfPopupMenuItemTextHot);
444+
oldColor := ColorToRGB(StyleServices.GetStyleFontColor(sfPopupMenuItemTextHot));
445445
if isDisabled in State then
446-
oldColor := StyleServices.GetStyleFontColor(sfPopupMenuItemTextDisabled);
446+
oldColor := ColorToRGB(StyleServices.GetStyleFontColor(sfPopupMenuItemTextDisabled));
447447
end;
448448

449449
AFont := CreateFontIndirect(LogFont);

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Utils.ScreenTips.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ procedure TSysTooltipsStyleHook.PaintHint(Canvas: TCanvas; TextRect: TRect);
8989
{ Draw Tooltips Face }
9090
GradientFillCanvas(Canvas, GradientStartColor, GradientEndColor, SysControl.ClientRect, gdVertical);
9191
{ Draw Tooltips Border }
92-
Brush := CreateSolidBrush(BkColor);
92+
Brush := CreateSolidBrush(ColorToRGB(BkColor));
9393
FrameRect(DC, SysControl.ClientRect, Brush);
9494
DeleteObject(Brush);
9595
{ Use default font for Tooltips text }
9696
SelectObject(DC, Screen.HintFont.Handle);
9797
{ Draw Tooltips Text }
9898
SetBkMode(DC, TRANSPARENT);
99-
SetTextColor(DC, TextColor);
99+
SetTextColor(DC, ColorToRGB(TextColor));
100100
AText := PChar(SysControl.Text);
101101
Winapi.Windows.DrawText(DC, AText, -1, TextRect, DT_LEFT);
102102
end;

delphi-ide-theme-editor/Common/Vcl Styles Utils/Vcl.Styles.Utils.SysStyleHook.pas

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -637,16 +637,16 @@ function TSysStyleHook.DrawText(DC: HDC; Details: TThemedElementDetails; S: Stri
637637
var
638638
DrawFlags: Cardinal;
639639
SaveIndex: Integer;
640-
sColor: TColor;
640+
LColor: TColor;
641641
begin
642642
SaveIndex := SaveDC(DC);
643643
try
644644
SetBkMode(DC, TRANSPARENT);
645-
if not StyleServices.GetElementColor(Details, ecTextColor, sColor) then
646-
sColor := FontColor;
645+
if not StyleServices.GetElementColor(Details, ecTextColor, LColor) then
646+
LColor := FontColor;
647647
if not OverrideFont then
648-
sColor := FontColor;
649-
SetTextColor(DC, sColor);
648+
LColor := FontColor;
649+
SetTextColor(DC, ColorToRGB(LColor));
650650
DrawFlags := TTextFormatFlags(Flags);
651651
Result := Winapi.Windows.DrawText(DC, S, -1, R, DrawFlags);
652652
finally
@@ -660,16 +660,16 @@ function TSysStyleHook.DrawTextCentered(DC: HDC; Details: TThemedElementDetails;
660660
DrawFlags: Cardinal;
661661
DrawParams: TDrawTextParams;
662662
SaveIndex: Integer;
663-
sColor: TColor;
663+
LColor: TColor;
664664
begin
665665
SaveIndex := SaveDC(DC);
666666
try
667667
SetBkMode(DC, TRANSPARENT);
668-
if not StyleServices.GetElementColor(Details, ecTextColor, sColor) then
669-
sColor := FontColor;
668+
if not StyleServices.GetElementColor(Details, ecTextColor, LColor) then
669+
LColor := FontColor;
670670
if not OverrideFont then
671-
sColor := FontColor;
672-
SetTextColor(DC, sColor);
671+
LColor := FontColor;
672+
SetTextColor(DC, ColorToRGB(LColor));
673673
DrawRect := R;
674674
DrawFlags := DT_END_ELLIPSIS or DT_WORDBREAK or DT_EDITCONTROL or DT_CENTER;
675675
if DrawFlags <> 0 then

0 commit comments

Comments
 (0)