PageRenderTime 51ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/univint/src/ABPeoplePicker.pas

https://github.com/slibre/freepascal
Pascal | 357 lines | 55 code | 49 blank | 253 comment | 0 complexity | fe055c8c650e5ed50843c7c3b03ef384 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  1{
  2//
  3//  ABPeoplePickerC.h
  4//  AddressBook Framework
  5//
  6//  Copyright (c) 2003-2007 Apple Inc.  All rights reserved.
  7//
  8}
  9{	  Pascal Translation:  Peter N Lewis, <peter@stairways.com.au>, 2004 }
 10{	  Pascal Translation Updated:  Gorazd Krosl, <gorazd_1957@yahoo.ca>, November 2009 }
 11
 12{
 13    Modified for use with Free Pascal
 14    Version 308
 15    Please report any bugs to <gpc@microbizz.nl>
 16}
 17
 18{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 19{$mode macpas}
 20{$packenum 1}
 21{$macro on}
 22{$inline on}
 23{$calling mwpascal}
 24
 25unit ABPeoplePicker;
 26interface
 27{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
 28{$setc GAP_INTERFACES_VERSION := $0308}
 29
 30{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 31    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 32{$endc}
 33
 34{$ifc defined CPUPOWERPC and defined CPUI386}
 35	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 36{$endc}
 37{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 38	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 39{$endc}
 40
 41{$ifc not defined __ppc__ and defined CPUPOWERPC32}
 42	{$setc __ppc__ := 1}
 43{$elsec}
 44	{$setc __ppc__ := 0}
 45{$endc}
 46{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
 47	{$setc __ppc64__ := 1}
 48{$elsec}
 49	{$setc __ppc64__ := 0}
 50{$endc}
 51{$ifc not defined __i386__ and defined CPUI386}
 52	{$setc __i386__ := 1}
 53{$elsec}
 54	{$setc __i386__ := 0}
 55{$endc}
 56{$ifc not defined __x86_64__ and defined CPUX86_64}
 57	{$setc __x86_64__ := 1}
 58{$elsec}
 59	{$setc __x86_64__ := 0}
 60{$endc}
 61{$ifc not defined __arm__ and defined CPUARM}
 62	{$setc __arm__ := 1}
 63{$elsec}
 64	{$setc __arm__ := 0}
 65{$endc}
 66
 67{$ifc defined cpu64}
 68  {$setc __LP64__ := 1}
 69{$elsec}
 70  {$setc __LP64__ := 0}
 71{$endc}
 72
 73
 74{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 75	{$error Conflicting definitions for __ppc__ and __i386__}
 76{$endc}
 77
 78{$ifc defined __ppc__ and __ppc__}
 79	{$setc TARGET_CPU_PPC := TRUE}
 80	{$setc TARGET_CPU_PPC64 := FALSE}
 81	{$setc TARGET_CPU_X86 := FALSE}
 82	{$setc TARGET_CPU_X86_64 := FALSE}
 83	{$setc TARGET_CPU_ARM := FALSE}
 84	{$setc TARGET_OS_MAC := TRUE}
 85	{$setc TARGET_OS_IPHONE := FALSE}
 86	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 87	{$setc TARGET_OS_EMBEDDED := FALSE}
 88{$elifc defined __ppc64__ and __ppc64__}
 89	{$setc TARGET_CPU_PPC := FALSE}
 90	{$setc TARGET_CPU_PPC64 := TRUE}
 91	{$setc TARGET_CPU_X86 := FALSE}
 92	{$setc TARGET_CPU_X86_64 := FALSE}
 93	{$setc TARGET_CPU_ARM := FALSE}
 94	{$setc TARGET_OS_MAC := TRUE}
 95	{$setc TARGET_OS_IPHONE := FALSE}
 96	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 97	{$setc TARGET_OS_EMBEDDED := FALSE}
 98{$elifc defined __i386__ and __i386__}
 99	{$setc TARGET_CPU_PPC := FALSE}
100	{$setc TARGET_CPU_PPC64 := FALSE}
101	{$setc TARGET_CPU_X86 := TRUE}
102	{$setc TARGET_CPU_X86_64 := FALSE}
103	{$setc TARGET_CPU_ARM := FALSE}
104{$ifc defined(iphonesim)}
105 	{$setc TARGET_OS_MAC := FALSE}
106	{$setc TARGET_OS_IPHONE := TRUE}
107	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
108{$elsec}
109	{$setc TARGET_OS_MAC := TRUE}
110	{$setc TARGET_OS_IPHONE := FALSE}
111	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
112{$endc}
113	{$setc TARGET_OS_EMBEDDED := FALSE}
114{$elifc defined __x86_64__ and __x86_64__}
115	{$setc TARGET_CPU_PPC := FALSE}
116	{$setc TARGET_CPU_PPC64 := FALSE}
117	{$setc TARGET_CPU_X86 := FALSE}
118	{$setc TARGET_CPU_X86_64 := TRUE}
119	{$setc TARGET_CPU_ARM := FALSE}
120	{$setc TARGET_OS_MAC := TRUE}
121	{$setc TARGET_OS_IPHONE := FALSE}
122	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
123	{$setc TARGET_OS_EMBEDDED := FALSE}
124{$elifc defined __arm__ and __arm__}
125	{$setc TARGET_CPU_PPC := FALSE}
126	{$setc TARGET_CPU_PPC64 := FALSE}
127	{$setc TARGET_CPU_X86 := FALSE}
128	{$setc TARGET_CPU_X86_64 := FALSE}
129	{$setc TARGET_CPU_ARM := TRUE}
130	{ will require compiler define when/if other Apple devices with ARM cpus ship }
131	{$setc TARGET_OS_MAC := FALSE}
132	{$setc TARGET_OS_IPHONE := TRUE}
133	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
134	{$setc TARGET_OS_EMBEDDED := TRUE}
135{$elsec}
136	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
137{$endc}
138
139{$ifc defined __LP64__ and __LP64__ }
140  {$setc TARGET_CPU_64 := TRUE}
141{$elsec}
142  {$setc TARGET_CPU_64 := FALSE}
143{$endc}
144
145{$ifc defined FPC_BIG_ENDIAN}
146	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
147	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
148{$elifc defined FPC_LITTLE_ENDIAN}
149	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
150	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
151{$elsec}
152	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
153{$endc}
154{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
155{$setc CALL_NOT_IN_CARBON := FALSE}
156{$setc OLDROUTINENAMES := FALSE}
157{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
158{$setc OPAQUE_UPP_TYPES := TRUE}
159{$setc OTCARBONAPPLICATION := TRUE}
160{$setc OTKERNEL := FALSE}
161{$setc PM_USE_SESSION_APIS := TRUE}
162{$setc TARGET_API_MAC_CARBON := TRUE}
163{$setc TARGET_API_MAC_OS8 := FALSE}
164{$setc TARGET_API_MAC_OSX := TRUE}
165{$setc TARGET_CARBON := TRUE}
166{$setc TARGET_CPU_68K := FALSE}
167{$setc TARGET_CPU_MIPS := FALSE}
168{$setc TARGET_CPU_SPARC := FALSE}
169{$setc TARGET_OS_UNIX := FALSE}
170{$setc TARGET_OS_WIN32 := FALSE}
171{$setc TARGET_RT_MAC_68881 := FALSE}
172{$setc TARGET_RT_MAC_CFM := FALSE}
173{$setc TARGET_RT_MAC_MACHO := TRUE}
174{$setc TYPED_FUNCTION_POINTERS := TRUE}
175{$setc TYPE_BOOL := FALSE}
176{$setc TYPE_EXTENDED := FALSE}
177{$setc TYPE_LONGLONG := TRUE}
178uses MacTypes,ABAddressBook,CFBase,CFArray,CGGeometry,HIGeometry,CarbonEventsCore;
179{$endc} {not MACOSALLINCLUDE}
180
181
182{$ifc TARGET_OS_MAC}
183
184{$ALIGN POWER}
185
186
187type
188	ABPickerRef = ^OpaqueABPicker; { an opaque type }
189	OpaqueABPicker = record end;
190
191{
192 * Picker creation and manipulation
193 }
194
195// Creates an ABPickerRef. Release with CFRelease(). The window is created hidden. Call
196// ABPickerSetVisibility() to show it.
197function ABPickerCreate: ABPickerRef; external name '_ABPickerCreate';
198(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
199
200// Change the structural frame of the window.
201procedure ABPickerSetFrame( inPicker: ABPickerRef; const (*var*) inFrame: HIRect ); external name '_ABPickerSetFrame';
202(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
203procedure ABPickerGetFrame( inPicker: ABPickerRef; var outFrame: HIRect ); external name '_ABPickerGetFrame';
204(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
205
206procedure ABPickerSetVisibility( inPicker: ABPickerRef; visible: CBool ); external name '_ABPickerSetVisibility';
207(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
208function ABPickerIsVisible( inPicker: ABPickerRef ): CBool; external name '_ABPickerIsVisible';
209(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
210
211{
212 * Look and Feel
213 }
214
215const
216// Choose the selection behavior for the value column. If multiple behaviors are selected,
217    // the most restrictive behavior will be used. Defaults to kABPickerSingleValueSelection set
218    // to TRUE.
219	kABPickerSingleValueSelection = 1 shl 0; // Allow user to choose a single value for a person.
220	kABPickerMultipleValueSelection = 1 shl 1; // Allow user to choose multiple values for a person.
221
222    // Allow the user to select entire groups in the group column. If false, at least one
223    // person in the group will be selected. Defaults to FALSE.
224	kABPickerAllowGroupSelection = 1 shl 2;
225
226    // Allow the user to select more than one group/record at a time. Defaults to TRUE.
227	kABPickerAllowMultipleSelection = 1 shl 3;
228
229type
230	ABPickerAttributes = OptionBits;
231
232function ABPickerGetAttributes( inPicker: ABPickerRef ): ABPickerAttributes; external name '_ABPickerGetAttributes';
233(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
234procedure ABPickerChangeAttributes( inPicker: ABPickerRef; inAttributesToSet: ABPickerAttributes; inAttributesToClear: ABPickerAttributes ); external name '_ABPickerChangeAttributes';
235(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
236
237{
238 * Value column
239 }
240
241    // These methods control what data (if any) is shown in the values column. The column will only
242    // display if an AB property is added. A popup button in the column header will be used if more
243    // than one property is added. Titles for built in properties will localized automatically. A
244    // list of AB properties can be found in <AddressBook/ABGlobals.h>.
245procedure ABPickerAddProperty( inPicker: ABPickerRef; inProperty: CFStringRef ); external name '_ABPickerAddProperty';
246(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
247procedure ABPickerRemoveProperty( inPicker: ABPickerRef; inProperty: CFStringRef ); external name '_ABPickerRemoveProperty';
248(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
249    // Returns an array of AB Properties as CFStringRefs.
250function ABPickerCopyProperties( inPicker: ABPickerRef ): CFArrayRef; external name '_ABPickerCopyProperties';
251(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
252
253    // Localized titles for third party properties should be set with these methods.
254procedure ABPickerSetColumnTitle( inPicker: ABPickerRef; inTitle: CFStringRef; inProperty: CFStringRef ); external name '_ABPickerSetColumnTitle';
255(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
256function ABPickerCopyColumnTitle( inPicker: ABPickerRef; inProperty: CFStringRef ): CFStringRef; external name '_ABPickerCopyColumnTitle';
257(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
258
259    // Display one of the properties added above in the values column.
260procedure ABPickerSetDisplayedProperty( inPicker: ABPickerRef; inProperty: CFStringRef ); external name '_ABPickerSetDisplayedProperty';
261(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
262function ABPickerCopyDisplayedProperty( inPicker: ABPickerRef ): CFStringRef; external name '_ABPickerCopyDisplayedProperty';
263(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
264
265{
266 * Selection
267 }
268
269    // Returns group column selection as an array of ABGroupRef objects.
270function ABPickerCopySelectedGroups( inPicker: ABPickerRef ): CFArrayRef; external name '_ABPickerCopySelectedGroups';
271(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
272
273    // Returns names column selection as an array of ABGroupRef or ABPersonRef objects.
274function ABPickerCopySelectedRecords( inPicker: ABPickerRef ): CFArrayRef; external name '_ABPickerCopySelectedRecords';
275(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
276
277    // This method returns an array of selected multi-value identifiers. Returns nil if the displayed
278    // property is a single value type.
279function ABPickerCopySelectedIdentifiers( inPicker: ABPickerRef; inPerson: ABPersonRef ): CFArrayRef; external name '_ABPickerCopySelectedIdentifiers';
280(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
281
282    // Returns an array containing CFStringRefs for each item selected in the values column.
283function ABPickerCopySelectedValues( inPicker: ABPickerRef ): CFArrayRef; external name '_ABPickerCopySelectedValues';
284(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
285
286    // Select group/name/value programatically.
287procedure ABPickerSelectGroup( inPicker: ABPickerRef; inGroup: ABGroupRef; inExtendSelection: CBool ); external name '_ABPickerSelectGroup';
288(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
289procedure ABPickerSelectRecord( inPicker: ABPickerRef; inRecord: ABRecordRef; inExtendSelection: CBool ); external name '_ABPickerSelectRecord';
290(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
291    // Individual values contained within an multi-value property can be selected with this method.
292procedure ABPickerSelectIdentifier( inPicker: ABPickerRef; inPerson: ABPersonRef; inIdentifier: CFStringRef; inExtendSelection: CBool ); external name '_ABPickerSelectIdentifier';
293(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
294
295    // Remove selection
296procedure ABPickerDeselectGroup( inPicker: ABPickerRef; inGroup: ABGroupRef ); external name '_ABPickerDeselectGroup';
297(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
298procedure ABPickerDeselectRecord( inPicker: ABPickerRef; inRecord: ABRecordRef ); external name '_ABPickerDeselectRecord';
299(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
300procedure ABPickerDeselectIdentifier( inPicker: ABPickerRef; inPerson: ABPersonRef; inIdentifier: CFStringRef ); external name '_ABPickerDeselectIdentifier';
301(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
302
303procedure ABPickerDeselectAll( inPicker: ABPickerRef ); external name '_ABPickerDeselectAll';
304(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
305
306{
307 * Events and Actions
308 *
309 * Your delegate will be notified when the user changes the selection or displayed property of the picker.
310 * Picker events have an event class of kEventClassABPeoplePicker and one of the kinds listed below. Picker
311 * events contain an event parameter which contains the ABPickerRef. To obtain this:
312 *
313 * GetEventParameter(inEvent, kEventParamABPickerRef,
314 *                   typeCFTypeRef, NULL, sizeof(ABPickerRef),
315 *                   NULL, &outPickerRef);
316 *
317 }
318
319const
320// Carbon Event class for People Picker
321	kEventClassABPeoplePicker = FourCharCode('abpp');
322
323const
324    // Carbon Event kinds for People Picker
325    kEventABPeoplePickerGroupSelectionChanged     = 1;
326    kEventABPeoplePickerNameSelectionChanged      = 2;
327    kEventABPeoplePickerValueSelectionChanged     = 3;
328    kEventABPeoplePickerDisplayedPropertyChanged  = 4;
329
330    kEventABPeoplePickerGroupDoubleClicked        = 5;
331    kEventABPeoplePickerNameDoubleClicked         = 6;
332
333const
334// Carbon Event parameter name
335	kEventParamABPickerRef = FourCharCode('abpp');
336
337    // Set the event handler for People Picker events.
338procedure ABPickerSetDelegate( inPicker: ABPickerRef; inDelegate: EventTargetRef ); external name '_ABPickerSetDelegate';
339(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
340function ABPickerGetDelegate( inPicker: ABPickerRef ): EventTargetRef; external name '_ABPickerGetDelegate';
341(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
342
343    // Clear the search field and reset the list of displayed names.
344procedure ABPickerClearSearchField( inPicker: ABPickerRef ); external name '_ABPickerClearSearchField';
345(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
346
347    // Launch AddressBook and edit the current selection
348procedure ABPickerEditInAddressBook( inPicker: ABPickerRef ); external name '_ABPickerEditInAddressBook';
349(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
350procedure ABPickerSelectInAddressBook( inPicker: ABPickerRef ); external name '_ABPickerSelectInAddressBook';
351(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
352
353{$endc} {TARGET_OS_MAC}
354{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
355
356end.
357{$endc} {not MACOSALLINCLUDE}