-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuInventorySideButtonPlugin.pas
480 lines (445 loc) · 17.2 KB
/
uInventorySideButtonPlugin.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
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
unit uInventorySideButtonPlugin;
interface
uses
SysUtils, Variants, Windows, Classes, ComObj, ActiveX, StdVcl,
Dialogs, ExtCtrls, AxCtrls, Plugins_TLB;
type
TInventorySideBtnPlugin = class(TAutoObject, IAbstractPlugin, IBOPlugin, ISideButtonPlugin)
private
{$REGION 'fields'}
/// <summary>
/// This field holds the Description of the plug-in.
/// </summary>
/// <remarks>
/// <para>The plug-in is expected to provide a unique and short description for the plug-in.
/// This is typically only accessed during discovery (and displayed in the list of registered
/// plug-ins if the <c>/LogPluginLoad</c> parameter is used to start RPro9), although in the
/// case of the IConfigure interface, this is the text used in the list of user interface plug-ins
/// in Retail Pro under Workstation Preferences.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
FDescription: AnsiString;
/// <summary>
/// This field holds the adapter value given by Retail Pro 9.
/// </summary>
/// <remarks>
/// <para> This property is populated by the Retail Pro plug-in manager. The
/// adapter is the plug-in�s attachment to the application and enables the plug-in to access business
/// objects, business objects referenced by the business object�s attributes, simple preference settings,
/// and a SQL session for accessing the Retail Pro� tablespace directly.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
FAdapter: IPluginAdapter;
/// <summary>
/// This field should be initialized to True and then is only changed by Retail Pro in rare exceptions.
/// </summary>
/// <remarks>
/// <para>This controls whether the plug-in is enabled, not whether the button shows as enabled.
/// Typically, this is set to True, and only turned off, by Retail Pro, if the button's HandleEvent
/// event handler returns an exception to the application.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
FEnabled: WordBool;
/// <summary>
/// This field holds the fly-over hint for the side-menu button.
/// </summary>
/// <remarks>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
FHint: AnsiString;
/// <summary>
/// This field holds the text used to name the action instance.
/// </summary>
/// <remarks>
/// <para>We're not really sure what "action instance" means or how it is used or what it might affect.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
FLayoutName: AnsiString;
/// <summary>
/// This field holds the text displayed on the button face.
/// </summary>
/// <remarks>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
FCaption: AnsiString;
/// <summary>
/// This field controls whether the button face includes a check mark.
/// </summary>
/// <remarks>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
FChecked: Boolean;
/// <summary>
/// This field holds the filename (with extension) of the icon (or glyph) used on the button in Retail Pro's side menu.
/// </summary>
/// <remarks>
/// <para>This is typically a 32x32 .BMP image and is expected to be in the "plugins" folder.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
FPictureFilename: AnsiString;
/// <summary>
/// This field holds controls whether the button is available or grayed out.
/// </summary>
/// <remarks>
/// <para>This property is checked several times a second, allowing the plug-in to react to changes in
/// the application, so the logic within the Get_ButtonEnabled getter must be succinct.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
FButtonEnabled: WordBool;
/// <summary>
/// This field holds the Business Object type for which this plug-in interface is associated.
/// </summary>
/// <remarks>
/// <para>The values (such as btInvoice or btCustomer) are defined in the section of contants for BusinessObjectType enums in Plugins_TLB.</para>
/// <para>From IBOPlugin.</para>
/// </remarks>
FBOType: Integer;
/// <summary>
/// This field holds unique identifier for the plug-in as defined in the Type Library for the project.
/// </summary>
/// <remarks>
/// From IAbstractPlugin.
/// </remarks>
FPluginGUID: TGUID;
/// <summary>
/// This field controls, in a limited fashion, the order in which the plug-ins are loaded at the
/// time they're activated.
/// </summary>
/// <remarks>
/// <para>The three settings for this property are ppHigh, ppNormal, and ppLow.
/// Typically, ppNormal is used for almost all plug-ins.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
FPluginPriority: PluginPriority;
{$ENDREGION}
protected
{$REGION 'Getters and Setters'}
/// <summary>
/// This returns the Description of the plug-in.
/// </summary>
/// <remarks>
/// <para>The plug-in is expected to provide a unique and short description for the plug-in.
/// This is typically only accessed during discovery (and displayed in the list of registered
/// plug-ins if the <c>/LogPluginLoad</c> parameter is used to start RPro9), although in the
/// case of the IConfigure interface, this is the text used in the list of user interface plug-ins
/// in Retail Pro under Workstation Preferences.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
function Get_Description: PAnsiChar; safecall;
/// <summary>
/// The "getter" function for the plug-in's GUID.
/// </summary>
/// <remarks>
/// <para>This should never need to be changed.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
function Get_GUID: TGUID; safecall;
/// <summary>
/// This is called just before the plug-in is unloaded.
/// </summary>
/// <remarks>
/// <para>Do any memory clean-up here.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
procedure CleanUp; safecall;
/// <summary>
/// The "getter" function for the Adapter field.
/// </summary>
/// <remarks>
/// <para>This should never need to be changed.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
function Get_Adapter: IPluginAdapter; safecall;
/// <summary>
/// The "setter" function for the Adapter field.
/// </summary>
/// <remarks>
/// <para>This should never need to be changed.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
procedure Set_Adapter(const Value: IPluginAdapter); safecall;
/// <summary>
/// This is called when the plug-in is first loaded.
/// </summary>
/// <returns>
/// <c>Boolean</c> If there's any problem preparing the plug-in, return False to prevent it from loading.
/// </returns>
/// <remarks>
/// <para>Do any necessary memory allocation here.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
function Prepare: WordBool; safecall;
/// <summary>
/// Priority controls, in a limited fashion, the order in which the plug-ins are loaded at the time they're
/// activated.
/// </summary>
/// <remarks>
/// <para>The three settings for this property are ppHigh, ppNormal, and ppLow.
/// Typically, ppNormal is used for almost all plug-ins.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
function Get_Priority: PluginPriority; safecall;
/// <summary>
/// This is the "getter" method for the Enabled property.
/// </summary>
/// <remarks>
/// <para>This controls whether the plug-in is enabled (not whether the button shows as enabled).
/// Typically, this is set to True, and only turned off, by Retail Pro, if the button's HandleEvent
/// event handler returns an exception to the application.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
function Get_Enabled: WordBool; safecall;
/// <summary>
/// This is the "setter" method for the Enabled property.
/// </summary>
/// <remarks>
/// <para>This controls whether the plug-in is enabled (not whether the button shows as enabled).
/// Typically, this is set to True, and only turned off, by Retail Pro, if the button's HandleEvent
/// event handler returns an exception to the application.</para>
/// <para>From IAbstractPlugin.</para>
/// </remarks>
procedure Set_Enabled(Value: WordBool); safecall;
/// <summary>
/// The "getter" for the BusinessObjectType property.
/// </summary>
/// <remarks>
/// <para>BusinessObjectType is the numeric identifier for the business
/// object which this side button should be associated with. When a
/// frame that uses this business object is presented, it will have added to
/// its list of buttons, in the Menu Designer, an action that references this
/// button. Selecting that action causes this button to be displayed on the side menu.</para>
/// <para>There is no corresponding "setter" method--this is a read-only property. A plug-in only hooks up to one interface, established when the plug-in is initialized.</para>
/// <para>From IBOPlugin.</para>
/// </remarks>
function Get_BusinessObjectType: Integer; safecall;
/// <summary>
/// This returns the text displayed on the button face.
/// </summary>
/// <remarks>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_Caption: PAnsiChar; safecall;
/// <summary>
/// This returns the filename (with extension) of the icon (or glyph) used on the button in Retail Pro's side menu.
/// </summary>
/// <remarks>
/// <para>This is typically a 32x32 .BMP image and is expected to be in the "plugins" folder.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_PictureFilename: PAnsiChar; safecall;
/// <summary>
/// This controls whether the button is available or grayed out.
/// </summary>
/// <remarks>
/// <para>This function is called several times a second, allowing the plug-in to react to changes in
/// the application, so the logic within the Get_ButtonEnabled getter must be succinct.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_ButtonEnabled: WordBool; safecall;
/// <summary>
/// The "getter" function for the UseLayoutManager property.
/// </summary>
/// <remarks>
/// <para>This property controls whether the button can be added
/// to a side menu via the layout manager. This should always be set to <c>True</c>.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_UseLayoutManager: WordBool; safecall;
/// <summary>
/// This is the "getter" function for the Checked property of a side button
/// </summary>
/// <remarks>
/// <para>This controls whether the button face includes a check mark.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_Checked: WordBool; safecall;
/// <summary>
/// This is the "getter" function that holds the fly-over hint for the side-menu button.
/// </summary>
/// <remarks>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_Hint: PAnsiChar; safecall;
/// <summary>
/// This returns the text used to name the action instance.
/// </summary>
/// <remarks>
/// <para>Seldom used.</para>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function Get_LayoutActionName: PAnsiChar; safecall;
/// <summary>
/// This is the meat of the SideButton plug-in interface--the equivalent
/// of the OnClick event handler of a TButton control.
/// </summary>
/// <remarks>
/// From ISideButtonPlugin.
/// </remarks>
function HandleEvent: WordBool; safecall;
/// <summary>
/// This tells Retail Pro what capabilities the plug-in supports.
/// </summary>
/// <param name="ACapability"><c>Integer</c> - should be <c>sbcHandleBOUIEvent</c>,
/// the only capability that will be queried of this plug-in.
/// </param>
/// <returns>
/// <c>True</c> if this plug-in handles BOUI Events.
/// </returns>
/// <remarks>
/// <para>From ISideButtonPlugin.</para>
/// </remarks>
function PluginCapability(ACapability: Integer): WordBool; safecall;
/// <summary>
/// This function enabled plug-in developers to respond to RPro UI events.
/// </summary>
/// <remarks>
/// Most BOUIEvents are in the form of a message dialog, in which a message is displayed to the
/// user and the user clicks Yes or No (or OK/Cancel). However, some BOUIEvents are more
/// complex; therefore, Retail Pro has tried to provide a flexible mechanism that can respond to a
/// variety of events. See the V9 Plug-in Programmers Guide for more information.
/// </remarks>
function HandleBOUIEvent(ABOHandle: Integer; AEventType: PAnsiChar; AParameters: OleVariant;
var AReturnValues: OleVariant; var AHandled: WordBool): WordBool; safecall;
/// <summary>
/// This property "getter" method returns a variant array of the specific UI events handled by this plugin.
/// </summary>
/// <remarks>
/// See the V9 Plug-in Programmer's Guide for more information.
/// </remarks>
function Get_BOUIEventsSupported: OleVariant; safecall;
{$ENDREGION}
public
/// <summary>
/// This method is used to set the data members used to identify the plug-in.
/// </summary>
/// <remarks>
/// No class or memory allocation should be done here. Initialize is called by the COM
/// layer anytime the plug-in is instantiated. <c>Prepare</c> is called before a plug-in is actually activated
/// for use by the UI, and that's where connections can be opened, memory allocated, etc.
/// </remarks>
procedure Initialize; override;
end;
implementation
uses
SideButtonsTest_TLB;
{ TInventorySideBtnPlugin }
procedure TInventorySideBtnPlugin.Initialize;
begin
inherited;
{ DONE : setup plug-in properties here }
FEnabled := True;
FCaption := 'Items Plugin!';
FPictureFilename := '';
FBOType := btInventoryItems;
FPluginGUID := CLASS_InventorySideBtn;
FPluginPriority := ppNormal;
FButtonEnabled := True;
FHint := 'Inventory side button';
FDescription := 'A SideButton on the Inventory screen';
FLayoutName := 'TestInventorySideButton';
FChecked := False;
end;
function TInventorySideBtnPlugin.Prepare: WordBool;
begin
Result := True;
end;
function TInventorySideBtnPlugin.HandleEvent: WORDBOOL;
begin
{ DONE : Here's the meat of the side-button plugin }
ShowMessage(' hi inventory :-) from Delphi ');
Result := True;
end;
function TInventorySideBtnPlugin.Get_ButtonEnabled: WordBool;
begin
Result := FButtonEnabled;
end;
function TInventorySideBtnPlugin.Get_PictureFilename: PAnsiChar;
begin
if Length(FPictureFilename) > 0 then
Result := PAnsiChar(FPictureFilename)
else
Result := nil;
end;
function TInventorySideBtnPlugin.Get_Checked: WordBool;
begin
Result := FChecked;
end;
function TInventorySideBtnPlugin.Get_Caption: PAnsiChar;
begin
if Length(FCaption) > 0 then
Result := PAnsiChar(FCaption)
else
Result := 'Say "Hi!"';
end;
function TInventorySideBtnPlugin.Get_Description: PAnsiChar;
begin
if Length(FDescription) > 0 then
Result := PAnsiChar(FDescription)
else
Result := nil;
end;
function TInventorySideBtnPlugin.Get_Hint: PAnsiChar;
begin
if Length(FHint) > 0 then
Result := PAnsiChar(FHint)
else
Result := nil;
end;
function TInventorySideBtnPlugin.Get_LayoutActionName: PAnsiChar;
begin
if Length(FLayoutName) > 0 then
Result := PAnsiChar(FLayoutName)
else
Result := nil;
end;
procedure TInventorySideBtnPlugin.Set_Enabled(Value: WordBool);
begin
FEnabled := Value;
end;
function TInventorySideBtnPlugin.Get_Enabled: WordBool;
begin
Result := FEnabled;
end;
function TInventorySideBtnPlugin.Get_Priority: PluginPriority;
begin
Result := FPluginPriority;
end;
function TInventorySideBtnPlugin.Get_UseLayoutManager: WordBool;
begin
Result := True;
end;
function TInventorySideBtnPlugin.Get_GUID: TGUID;
begin
Result := FPluginGUID;
end;
function TInventorySideBtnPlugin.Get_BusinessObjectType: Integer;
begin
Result := FBOType;
end;
procedure TInventorySideBtnPlugin.Set_Adapter(const Value: IPluginAdapter);
begin
FAdapter := Value;
end;
function TInventorySideBtnPlugin.Get_Adapter: IPluginAdapter;
begin
Result := FAdapter;
end;
function TInventorySideBtnPlugin.PluginCapability(ACapability: Integer): WordBool;
begin
Result := False;
end;
function TInventorySideBtnPlugin.Get_BOUIEventsSupported: OleVariant;
begin
Result := NULL;
end;
function TInventorySideBtnPlugin.HandleBOUIEvent(ABOHandle: Integer; AEventType: PAnsiChar;
AParameters: OleVariant; var AReturnValues: OleVariant; var AHandled: WordBool): WordBool;
begin
Result := False;
end;
procedure TInventorySideBtnPlugin.CleanUp;
begin
// REQUIRED!
FAdapter := nil;
end;
end.