-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathOWDesignTypes.pas
More file actions
379 lines (327 loc) · 14.7 KB
/
OWDesignTypes.pas
File metadata and controls
379 lines (327 loc) · 14.7 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
////////////////////////////////////////////////////////////////////////////////
// //
// This software is supplied under the terms of a license agreement or //
// nondisclosure agreement with Mitov Software and may not be copied //
// or disclosed except in accordance with the terms of that agreement. //
// Copyright(c) 2002-2025 Mitov Software. All Rights Reserved. //
// //
////////////////////////////////////////////////////////////////////////////////
unit OWDesignTypes;
{$IFDEF FPC}
{$MODE DELPHI}{$H+}
{$ENDIF}
interface
uses
{$IFDEF FPC}
LCLIntf, LMessages, LResources, PropEdits, ComponentEditors,
{$ELSE}
WinApi.Windows, Vcl.Graphics, Mitov.Containers.List,
{$IFDEF __VSDESIGN__}
Mitov.Design,
{$ELSE}
{$IFNDEF __DELPHI_DESIGN__}
Mitov.Design,
{$ELSE}
DesignEditors,
DesignIntf,
System.TypInfo,
{$ENDIF}
{$ENDIF}
{$ENDIF}
Vcl.Forms, WinApi.Messages, System.Classes, OWPins, OWStdTypes, Mitov.Containers.Dictionary, Mitov.Utils,
Mitov.Attributes, Mitov.Containers.Common;
type TOWPropNameString = String;
type TOWPropertyDesigner = IDesigner;
type
TOWEPinEntry = class( TBasicObject )
public
Pin : TOWBasicPin;
PinName : String;
OwnerName : String;
SavedChecked : Boolean;
Checked : Boolean;
Dispatcher : TOWBasicStateDispatcher;
end;
//---------------------------------------------------------------------------
TOWModulesColection = class( TStringArrayList )
public
procedure GetModules( const AFileName, AUnitName, AFormName, ADesignClass : String; ACoClasses : TStrings );
end;
//---------------------------------------------------------------------------
{$IFNDEF __VSDESIGN__}
{$IFDEF __DELPHI_DESIGN__}
function OWCanAccessRootFromName( ADesigner : TOWPropertyDesigner; const ARootName : String ) : Boolean;
procedure OWLinkAwaitsLinkingAllForms();
procedure OWRequestDesignerRefresh();
procedure OWGetPinValueList( ACollection : IPairCollection<String, TOWBasicPin>; AOwnerComponent : TComponent; APin : TOWPin; AFilterPins : Boolean );
function OWGetMainDesignOwner( AComponent : TComponent ) : TComponent;
procedure OWRequestRefreshEx( ADesigner : TOWPropertyDesigner );
{$ENDIF}
{$ENDIF}
//---------------------------------------------------------------------------
procedure OWRegisterStreamColorThickness( AStreamTypeID : TGUID; AColor : TColor; AThickness : Single );
function OWGetStreamThicknessColorFromID( AStreamTypeID : TGUID; var Color : TColor; var Thickness : Single ) : Boolean;
//---------------------------------------------------------------------------
procedure Register;
//---------------------------------------------------------------------------
implementation
uses
System.SysUtils, Mitov.Threading,
{$IFNDEF __VSDESIGN__}
{$IFDEF __DELPHI_DESIGN__}
ToolsAPI,
{$ENDIF} // __DELPHI_DESIGN__
{$ENDIF} // __VSDESIGN__
System.Math, System.UITypes;
//---------------------------------------------------------------------------
{$IFDEF BCB}
const
SEPARATOR = '->';
{$ELSE}
const
SEPARATOR = '.';
{$ENDIF}
//---------------------------------------------------------------------------
{$IFNDEF __VSDESIGN__}
{$IFDEF __DELPHI_DESIGN__}
var
InOppening : Boolean;
{$ENDIF}
{$ENDIF}
//---------------------------------------------------------------------------
procedure TOWModulesColection.GetModules( const AFileName, AUnitName, AFormName, ADesignClass : String; ACoClasses : TStrings );
begin
if( AFormName <> '' ) then
Add( AFormName );
end;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
{$IFNDEF __VSDESIGN__}
{$IFDEF __DELPHI_DESIGN__}
function OWCanAccessRootFromName( ADesigner : TOWPropertyDesigner; const ARootName : String ) : Boolean;
begin
var AComponent := ADesigner.GetComponent( ARootName + SEPARATOR + ARootName );
Result := False;
if( AComponent = NIL ) then
begin
AComponent := ADesigner.GetComponent( ARootName );
if( AComponent = NIL ) then
Exit;
end;
Result := ADesigner.IsComponentLinkable( AComponent );
end;
//---------------------------------------------------------------------------
procedure OWLinkAwaitsLinkingAllForms();
var
AModule : IOTAModule;
AModuleServices : IOTAModuleServices;
AFormEditor : INTAFormEditor;
begin
if( not GPinsNeedRefresh ) then
Exit;
if( OWGetAllLinked() ) then
Exit;
InOppening := True;
GPinsNeedRefresh := False;
BorlandIDEServices.QueryInterface( IOTAModuleServices, AModuleServices );
if( Assigned( AModuleServices )) then
begin
if( AModuleServices.CurrentModule.OwnerCount > 0 ) then
begin
var AProject : IOTAProject := AModuleServices.CurrentModule.Owners[ 0 ];
for var ModuleIndex : Integer := 0 to AProject.GetModuleCount - 1 do
begin
if( AProject.GetModule( ModuleIndex ).GetFileName <> '' ) then
begin
try
var AModuleFileExt := TypeString( ExtractFileExt( AProject.GetModule( ModuleIndex ).GetFileName() )).ToUpperCase();
if( ( AModuleFileExt <> '.CPP' ) and ( AModuleFileExt <> '.PAS' ) and ( AModuleFileExt <> '.DFM' )) then
Continue;
{
if( TypeString( ExtractFileExt( AProject.GetModule( ModuleIndex ).GetFileName ) ).ToUpperCase() = '.RES' ) then
Continue;
if( TypeString( ExtractFileExt( AProject.GetModule( ModuleIndex ).GetFileName )).ToUpperCase() = '.DCP' ) then
Continue;
}
AProject.GetModule( ModuleIndex ).OpenModule.QueryInterface( IOTAModule, AModule );
if( AProject.GetModule( ModuleIndex ).FormName = '' ) then
Continue;
for var I : Integer := 0 to AModule.GetModuleFileCount - 1 do
begin
AModule.GetModuleFileEditor( I ).QueryInterface( INTAFormEditor, AFormEditor );
if( Assigned( AFormEditor )) then
AFormEditor := NIL;
end;
finally
end;
end;
end;
end;
end;
InOppening := False;
end;
//---------------------------------------------------------------------------
procedure OWRequestDesignerRefresh();
begin
if( InOppening ) then
Exit;
if( OWGetAllLinked() ) then
Exit;
if( GPinsNeedRefresh ) then
Exit;
GPinsNeedRefresh := True;
MainThread.Execute( NIL, True, OWLinkAwaitsLinkingAllForms );
end;
//---------------------------------------------------------------------------
procedure OWGetPinValueList( ACollection : IPairCollection<String, TOWBasicPin>; AOwnerComponent : TComponent; APin : TOWPin; AFilterPins : Boolean );
var
AFilters : TOWPinValueFilters;
begin
if( APin <> NIL ) then
begin
if( AFilterPins ) then
AFilters := []
else
AFilters := [ pvoFullList, pvoExcludeDirectDependency ];
if( GetMainOwnerComponent( APin.Owner ) <> AOwnerComponent ) then
begin
OWGetPinsValueListSingleRoot( ACollection, AOwnerComponent, APin, '.', AOwnerComponent.Name, AFilters );
Exit;
end;
OWGetPinsValueListSingleRoot( ACollection, AOwnerComponent, APin, '.', '', AFilters );
end;
end;
//---------------------------------------------------------------------------
function OWGetMainDesignOwner( AComponent : TComponent ) : TComponent;
begin
if( AComponent.Owner = NIL ) then
Exit( AComponent );
Result := GetMainOwnerComponent( AComponent.Owner );
end;
//---------------------------------------------------------------------------
procedure OWRequestRefreshEx( ADesigner : TOWPropertyDesigner );
begin
var AFormNamesObj := TOWModulesColection.Create();
var AFormNames : IStringArrayList := AFormNamesObj;
ADesigner.GetProjectModules( AFormNamesObj.GetModules );
for var AName in AFormNames do
OWCanAccessRootFromName( ADesigner, AName );
OWRequestDesignerRefresh();
end;
//---------------------------------------------------------------------------
{$ENDIF}
{$ELSE}
procedure OWResetObjectInspector( ADesigner : TOWPropertyDesigner );
begin
end;
{$ENDIF}
//---------------------------------------------------------------------------
type
TOWStreamInfoOWEditorExtention = class;
//---------------------------------------------------------------------------
IOWStreamInfoOWEditorExtention = interface( IOWStreamInfoExtention )
['{21C15026-CF32-4579-AE17-4EA6A065A7C5}']
[Result : Weak]
function GetInstance() : TOWStreamInfoOWEditorExtention;
end;
//---------------------------------------------------------------------------
TOWStreamInfoOWEditorExtention = class( TOWStreamInfoExtention, IOWStreamInfoOWEditorExtention )
protected
FColor : TColor;
FThickness : Single;
protected
[Result : Weak]
function GetInstance() : TOWStreamInfoOWEditorExtention;
public
class function Make( const AExtentionId : TGUID; AColor : TColor; AThickness : Single ) : IOWStreamInfoOWEditorExtention; inline;
public
constructor CreateObject( const AExtentionId : TGUID; AColor : TColor; AThickness : Single );
public
property Color : TColor read FColor;
property Thickness : Single read FThickness;
end;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
constructor TOWStreamInfoOWEditorExtention.CreateObject( const AExtentionId : TGUID; AColor : TColor; AThickness : Single );
begin
inherited CreateObject( AExtentionId );
FColor := AColor;
FThickness := AThickness;
end;
//---------------------------------------------------------------------------
class function TOWStreamInfoOWEditorExtention.Make( const AExtentionId : TGUID; AColor : TColor; AThickness : Single ) : IOWStreamInfoOWEditorExtention;
begin
Result := CreateObject( AExtentionId, AColor, AThickness );
end;
//---------------------------------------------------------------------------
function TOWStreamInfoOWEditorExtention.GetInstance() : TOWStreamInfoOWEditorExtention;
begin
Result := Self;
end;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
procedure OWRegisterStreamColorThickness( AStreamTypeID : TGUID; AColor : TColor; AThickness : Single );
begin
OWRegisterStreamExtention( AStreamTypeID, TOWStreamInfoOWEditorExtention.Make( IOWStreamInfoOWEditorExtention, AColor, AThickness ) );
end;
//---------------------------------------------------------------------------
function OWGetStreamThicknessColorFromID( AStreamTypeID : TGUID; var Color : TColor; var Thickness : Single ) : Boolean;
var
AExtentionIntf : IOWStreamInfoExtention;
begin
if( not OWGetStreamExtentionFromID( AStreamTypeID, IOWStreamInfoOWEditorExtention, AExtentionIntf )) then
Exit( False );
var AExtention : IOWStreamInfoOWEditorExtention := ( AExtentionIntf as IOWStreamInfoOWEditorExtention );
Color := AExtention.GetInstance().Color;
Thickness := AExtention.GetInstance().Thickness;
Result := True;
end;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
procedure Register;
begin
OWRegisterStreamColorThickness( IOWIntegerStream, TColors.Fuchsia, 1 );
OWRegisterStreamColorThickness( IOWCardinalStream, TColors.Purple, 1 );
OWRegisterStreamColorThickness( IOWInt64Stream, TColors.Fuchsia, 1.2 );
OWRegisterStreamColorThickness( IOWUInt64Stream, TColors.Purple, 1.2 );
OWRegisterStreamColorThickness( IOWFloatStream, TColors.Red, 1 );
OWRegisterStreamColorThickness( IOWRealStream, TColors.Red, 1 );
OWRegisterStreamColorThickness( IOWRealComplexStream, TColors.Aqua, 1 );
OWRegisterStreamColorThickness( IOWFloatQuaternionStream, TColors.Fuchsia, 1.5 );
OWRegisterStreamColorThickness( IOWFloatPoint3DStream, TColors.Azure, 1.5 );
OWRegisterStreamColorThickness( IOWBoolStream, TColors.Blue, 1 );
OWRegisterStreamColorThickness( IOWByteStream, TColors.Blue, 1.5 );
OWRegisterStreamColorThickness( IOWCharStream, TColors.Teal, 1 );
OWRegisterStreamColorThickness( IOWStringStream, TColors.Teal, 1.5 );
OWRegisterStreamColorThickness( IOWStringListStream, TColors.Teal, 2 );
OWRegisterStreamColorThickness( IOWColorStream, TColors.Navy, 1 );
OWRegisterStreamColorThickness( IOWAlphaColorStream, TColors.Lightblue, 1 );
OWRegisterStreamColorThickness( IOWRGBWColorStream, TColors.Darkblue, 1 );
OWRegisterStreamColorThickness( IOWRGBWAlphaColorStream, TColors.Lightsteelblue, 1 );
OWRegisterStreamColorThickness( IOWIntRangedStream, TColors.Fuchsia, 1 );
OWRegisterStreamColorThickness( IOWInt64RangedStream, TColors.Fuchsia, 1 );
OWRegisterStreamColorThickness( IOWRealRangedStream, TColors.Red, 1 );
OWRegisterStreamColorThickness( IOWDateTimeStream, TColors.Yellow, 1 );
OWRegisterStreamColorThickness( IOWDateTimeRangedStream, TColors.Yellow, 1 );
OWRegisterStreamColorThickness( IOWStreamPersistStream, TColors.Lime, 2 );
OWRegisterStreamColorThickness( IOWIntegerListStream, TColors.Fuchsia, 2.5 );
OWRegisterStreamColorThickness( IOWInt64ListStream, TColors.Fuchsia, 2.5 );
OWRegisterStreamColorThickness( IOWFloatListStream, TColors.Red, 2.5 );
OWRegisterStreamColorThickness( IOWRealListStream, TColors.Red, 2.5 );
OWRegisterStreamColorThickness( IOWClockStream, TColors.Orange, 1 );
end;
initialization
{$IFNDEF __VSDESIGN__}
{$IFDEF __DELPHI_DESIGN__}
InOppening := False;
{$ENDIF}
{$ENDIF}
end.