forked from DelphiPackageManager/DPM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DPM.IDE.ToolsAPI.pas
75 lines (63 loc) · 1.81 KB
/
DPM.IDE.ToolsAPI.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
unit DPM.IDE.ToolsAPI;
interface
uses
ToolsApi,
System.Classes,
Vcl.Forms;
type
TToolsApiUtils = class
class procedure RegisterFormClassForTheming(const AFormClass : TCustomFormClass; const Component : TComponent = nil);static;
class function FindProjectInGroup(const projectGroup : IOTAProjectGroup; const projectName : string) : IOTAProject;
end;
implementation
uses
System.SysUtils;
{ TToolsApiUtils }
{$IF CompilerVersion >= 24.0} //XE3
{$LEGACYIFEND ON}
{$IFEND}
class function TToolsApiUtils.FindProjectInGroup(const projectGroup: IOTAProjectGroup; const projectName: string): IOTAProject;
{$IF CompilerVersion < 24.0} //XE3
var
i : integer;
{$IFEND}
begin
result := nil;
if projectGroup = nil then
exit;
{$IF CompilerVersion < 24.0} //XE3
for i := 0 to projectGroup.ProjectCount -1 do
begin
if SameText(projectGroup.Projects[i].FileName, projectName) then
exit(projectGroup.Projects[i]);
end;
{$ELSE}
result := projectGroup.FindProject(projectName);
{$IFEND}
end;
class procedure TToolsApiUtils.RegisterFormClassForTheming(const AFormClass: TCustomFormClass; const Component: TComponent);
{$IF CompilerVersion >= 32.0} //10.2
Var
{$IF CompilerVersion = 34.0} //10.4
// Breaking change to the Open Tools API - They fixed the wrongly defined interface
ITS : IOTAIDEThemingServices;
{$ELSE}
ITS : IOTAIDEThemingServices250;
{$IFEND}
{$IFEND}
Begin
{$IF CompilerVersion >= 32.0} //10.2
{$IF CompilerVersion = 34.0} //10.4
If Supports(BorlandIDEServices, IOTAIDEThemingServices, ITS) Then
{$ELSE}
If Supports(BorlandIDEServices, IOTAIDEThemingServices250, ITS) Then
{$IFEND}
If ITS.IDEThemingEnabled Then
Begin
ITS.RegisterFormClass(AFormClass);
If Assigned(Component) Then
ITS.ApplyTheme(Component);
End;
{$IFEND}
end;
end.