~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/packages/univint/src/CFUserNotification.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{       CFUserNotification.h
 
2
        Copyright (c) 2000-2005, Apple, Inc. All rights reserved.
 
3
}
 
4
{         Pascal Translation:  Peter N Lewis, <peter@stairways.com.au>, 2004 }
 
5
{         Pascal Translation Updated:  Peter N Lewis, <peter@stairways.com.au>, November 2005 }
 
6
{
 
7
    Modified for use with Free Pascal
 
8
    Version 210
 
9
    Please report any bugs to <gpc@microbizz.nl>
 
10
}
 
11
 
 
12
{$mode macpas}
 
13
{$packenum 1}
 
14
{$macro on}
 
15
{$inline on}
 
16
{$calling mwpascal}
 
17
 
 
18
unit CFUserNotification;
 
19
interface
 
20
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
 
21
{$setc GAP_INTERFACES_VERSION := $0210}
 
22
 
 
23
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 
24
    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 
25
{$endc}
 
26
 
 
27
{$ifc defined CPUPOWERPC and defined CPUI386}
 
28
        {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 
29
{$endc}
 
30
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 
31
        {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 
32
{$endc}
 
33
 
 
34
{$ifc not defined __ppc__ and defined CPUPOWERPC}
 
35
        {$setc __ppc__ := 1}
 
36
{$elsec}
 
37
        {$setc __ppc__ := 0}
 
38
{$endc}
 
39
{$ifc not defined __i386__ and defined CPUI386}
 
40
        {$setc __i386__ := 1}
 
41
{$elsec}
 
42
        {$setc __i386__ := 0}
 
43
{$endc}
 
44
 
 
45
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
 
46
        {$error Conflicting definitions for __ppc__ and __i386__}
 
47
{$endc}
 
48
 
 
49
{$ifc defined __ppc__ and __ppc__}
 
50
        {$setc TARGET_CPU_PPC := TRUE}
 
51
        {$setc TARGET_CPU_X86 := FALSE}
 
52
{$elifc defined __i386__ and __i386__}
 
53
        {$setc TARGET_CPU_PPC := FALSE}
 
54
        {$setc TARGET_CPU_X86 := TRUE}
 
55
{$elsec}
 
56
        {$error Neither __ppc__ nor __i386__ is defined.}
 
57
{$endc}
 
58
{$setc TARGET_CPU_PPC_64 := FALSE}
 
59
 
 
60
{$ifc defined FPC_BIG_ENDIAN}
 
61
        {$setc TARGET_RT_BIG_ENDIAN := TRUE}
 
62
        {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
 
63
{$elifc defined FPC_LITTLE_ENDIAN}
 
64
        {$setc TARGET_RT_BIG_ENDIAN := FALSE}
 
65
        {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
 
66
{$elsec}
 
67
        {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
 
68
{$endc}
 
69
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
 
70
{$setc CALL_NOT_IN_CARBON := FALSE}
 
71
{$setc OLDROUTINENAMES := FALSE}
 
72
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
 
73
{$setc OPAQUE_UPP_TYPES := TRUE}
 
74
{$setc OTCARBONAPPLICATION := TRUE}
 
75
{$setc OTKERNEL := FALSE}
 
76
{$setc PM_USE_SESSION_APIS := TRUE}
 
77
{$setc TARGET_API_MAC_CARBON := TRUE}
 
78
{$setc TARGET_API_MAC_OS8 := FALSE}
 
79
{$setc TARGET_API_MAC_OSX := TRUE}
 
80
{$setc TARGET_CARBON := TRUE}
 
81
{$setc TARGET_CPU_68K := FALSE}
 
82
{$setc TARGET_CPU_MIPS := FALSE}
 
83
{$setc TARGET_CPU_SPARC := FALSE}
 
84
{$setc TARGET_OS_MAC := TRUE}
 
85
{$setc TARGET_OS_UNIX := FALSE}
 
86
{$setc TARGET_OS_WIN32 := FALSE}
 
87
{$setc TARGET_RT_MAC_68881 := FALSE}
 
88
{$setc TARGET_RT_MAC_CFM := FALSE}
 
89
{$setc TARGET_RT_MAC_MACHO := TRUE}
 
90
{$setc TYPED_FUNCTION_POINTERS := TRUE}
 
91
{$setc TYPE_BOOL := FALSE}
 
92
{$setc TYPE_EXTENDED := FALSE}
 
93
{$setc TYPE_LONGLONG := TRUE}
 
94
uses MacTypes,CFBase,CFDate,CFDictionary,CFString,CFURL,CFRunLoop;
 
95
{$ALIGN POWER}
 
96
 
 
97
 
 
98
type
 
99
        CFUserNotificationRef = ^SInt32; { an opaque 32-bit type }
 
100
 
 
101
{ A CFUserNotification is a notification intended to be presented to a 
 
102
user at the console (if one is present).  This is for the use of processes
 
103
that do not otherwise have user interfaces, but may need occasional
 
104
interaction with a user.  There is a parallel API for this functionality
 
105
at the System framework level, described in UNCUserNotification.h.
 
106
 
 
107
The contents of the notification can include a header, a message, textfields,
 
108
a popup button, radio buttons or checkboxes, a progress indicator, and up to
 
109
three ordinary buttons.  All of these items are optional, but a default
 
110
button will be supplied even if not specified unless the
 
111
kCFUserNotificationNoDefaultButtonFlag is set.
 
112
 
 
113
The contents of the notification are specified in the dictionary used to
 
114
create the notification, whose keys should be taken from the list of constants
 
115
below, and whose values should be either strings or arrays of strings
 
116
(except for kCFUserNotificationProgressIndicatorValueKey, in which case the
 
117
value should be a number between 0 and 1, for a "definite" progress indicator,
 
118
or a boolean, for an "indefinite" progress indicator).  Additionally, URLs can
 
119
optionally be supplied for an icon, a sound, and a bundle whose Localizable.strings
 
120
files will be used to localize strings.
 
121
    
 
122
Certain request flags are specified when a notification is created.
 
123
These specify an alert level for the notification, determine whether
 
124
radio buttons or check boxes are to be used, specify which if any of these
 
125
are checked by default, specify whether any of the textfields are to
 
126
be secure textfields, and determine which popup item should be selected
 
127
by default.  A timeout is also specified, which determines how long the
 
128
notification should be supplied to the user (if zero, it will not timeout).
 
129
    
 
130
A CFUserNotification is dispatched for presentation when it is created.
 
131
If any reply is required, it may be awaited in one of two ways:  either
 
132
synchronously, using CFUserNotificationReceiveResponse, or asynchronously,
 
133
using a run loop source.  CFUserNotificationReceiveResponse has a timeout
 
134
parameter that determines how long it will block (zero meaning indefinitely)
 
135
and it may be called as many times as necessary until a response arrives.
 
136
If a notification has not yet received a response, it may be updated with
 
137
new information, or it may be cancelled.  Notifications may not be reused.
 
138
    
 
139
When a response arrives, it carries with it response flags that describe
 
140
which button was used to dismiss the notification, which checkboxes or
 
141
radio buttons were checked, and what the selection of the popup was.
 
142
It also carries a response dictionary, which describes the contents
 
143
of the textfields.  }
 
144
    
 
145
type
 
146
        CFUserNotificationCallBack = procedure( userNotification: CFUserNotificationRef; responseFlags: CFOptionFlags );
 
147
 
 
148
function CFUserNotificationGetTypeID: CFTypeID; external name '_CFUserNotificationGetTypeID';
 
149
 
 
150
function CFUserNotificationCreate( allocator: CFAllocatorRef; timeout: CFTimeInterval; flags: CFOptionFlags; var error: SInt32; dictionary: CFDictionaryRef ): CFUserNotificationRef; external name '_CFUserNotificationCreate';
 
151
 
 
152
function CFUserNotificationReceiveResponse( userNotification: CFUserNotificationRef; timeout: CFTimeInterval; var responseFlags: CFOptionFlags ): SInt32; external name '_CFUserNotificationReceiveResponse';
 
153
 
 
154
function CFUserNotificationGetResponseValue( userNotification: CFUserNotificationRef; key: CFStringRef; idx: CFIndex ): CFStringRef; external name '_CFUserNotificationGetResponseValue';
 
155
 
 
156
function CFUserNotificationGetResponseDictionary( userNotification: CFUserNotificationRef ): CFDictionaryRef; external name '_CFUserNotificationGetResponseDictionary';
 
157
 
 
158
function CFUserNotificationUpdate( userNotification: CFUserNotificationRef; timeout: CFTimeInterval; flags: CFOptionFlags; dictionary: CFDictionaryRef ): SInt32; external name '_CFUserNotificationUpdate';
 
159
 
 
160
function CFUserNotificationCancel( userNotification: CFUserNotificationRef ): SInt32; external name '_CFUserNotificationCancel';
 
161
 
 
162
function CFUserNotificationCreateRunLoopSource( allocator: CFAllocatorRef; userNotification: CFUserNotificationRef; callout: CFUserNotificationCallBack; order: CFIndex ): CFRunLoopSourceRef; external name '_CFUserNotificationCreateRunLoopSource';
 
163
 
 
164
{ Convenience functions for handling the simplest and most common cases:  
 
165
a one-way notification, and a notification with up to three buttons. }
 
166
    
 
167
function CFUserNotificationDisplayNotice( timeout: CFTimeInterval; flags: CFOptionFlags; iconURL: CFURLRef; soundURL: CFURLRef; localizationURL: CFURLRef; alertHeader: CFStringRef; alertMessage: CFStringRef; defaultButtonTitle: CFStringRef ): SInt32; external name '_CFUserNotificationDisplayNotice';
 
168
 
 
169
function CFUserNotificationDisplayAlert( timeout: CFTimeInterval; flags: CFOptionFlags; iconURL: CFURLRef; soundURL: CFURLRef; localizationURL: CFURLRef; alertHeader: CFStringRef; alertMessage: CFStringRef; defaultButtonTitle: CFStringRef; alternateButtonTitle: CFStringRef; otherButtonTitle: CFStringRef; var responseFlags: CFOptionFlags ): SInt32; external name '_CFUserNotificationDisplayAlert';
 
170
 
 
171
 
 
172
{ Flags }
 
173
 
 
174
const
 
175
        kCFUserNotificationStopAlertLevel = 0;
 
176
        kCFUserNotificationNoteAlertLevel = 1;
 
177
        kCFUserNotificationCautionAlertLevel = 2;
 
178
        kCFUserNotificationPlainAlertLevel = 3;
 
179
 
 
180
const
 
181
        kCFUserNotificationDefaultResponse = 0;
 
182
        kCFUserNotificationAlternateResponse = 1;
 
183
        kCFUserNotificationOtherResponse = 2;
 
184
        kCFUserNotificationCancelResponse = 3;
 
185
 
 
186
const
 
187
        kCFUserNotificationNoDefaultButtonFlag = 1 shl 5;
 
188
        kCFUserNotificationUseRadioButtonsFlag = 1 shl 6;
 
189
 
 
190
function CFUserNotificationCheckBoxChecked( i: CFIndex ): CFOptionFlags; inline;
 
191
function CFUserNotificationSecureTextField( i: CFIndex ): CFOptionFlags; inline;
 
192
function CFUserNotificationPopUpSelection( n: CFIndex ): CFOptionFlags; inline;
 
193
 
 
194
 
 
195
{ Keys }
 
196
 
 
197
var kCFUserNotificationIconURLKey: CFStringRef; external name '_kCFUserNotificationIconURLKey'; (* attribute const *)
 
198
 
 
199
var kCFUserNotificationSoundURLKey: CFStringRef; external name '_kCFUserNotificationSoundURLKey'; (* attribute const *)
 
200
 
 
201
var kCFUserNotificationLocalizationURLKey: CFStringRef; external name '_kCFUserNotificationLocalizationURLKey'; (* attribute const *)
 
202
 
 
203
var kCFUserNotificationAlertHeaderKey: CFStringRef; external name '_kCFUserNotificationAlertHeaderKey'; (* attribute const *)
 
204
 
 
205
var kCFUserNotificationAlertMessageKey: CFStringRef; external name '_kCFUserNotificationAlertMessageKey'; (* attribute const *)
 
206
 
 
207
var kCFUserNotificationDefaultButtonTitleKey: CFStringRef; external name '_kCFUserNotificationDefaultButtonTitleKey'; (* attribute const *)
 
208
 
 
209
var kCFUserNotificationAlternateButtonTitleKey: CFStringRef; external name '_kCFUserNotificationAlternateButtonTitleKey'; (* attribute const *)
 
210
 
 
211
var kCFUserNotificationOtherButtonTitleKey: CFStringRef; external name '_kCFUserNotificationOtherButtonTitleKey'; (* attribute const *)
 
212
 
 
213
var kCFUserNotificationProgressIndicatorValueKey: CFStringRef; external name '_kCFUserNotificationProgressIndicatorValueKey'; (* attribute const *)
 
214
 
 
215
var kCFUserNotificationPopUpTitlesKey: CFStringRef; external name '_kCFUserNotificationPopUpTitlesKey'; (* attribute const *)
 
216
 
 
217
var kCFUserNotificationTextFieldTitlesKey: CFStringRef; external name '_kCFUserNotificationTextFieldTitlesKey'; (* attribute const *)
 
218
 
 
219
var kCFUserNotificationCheckBoxTitlesKey: CFStringRef; external name '_kCFUserNotificationCheckBoxTitlesKey'; (* attribute const *)
 
220
 
 
221
var kCFUserNotificationTextFieldValuesKey: CFStringRef; external name '_kCFUserNotificationTextFieldValuesKey'; (* attribute const *)
 
222
 
 
223
{#if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED}
 
224
var kCFUserNotificationPopUpSelectionKey: CFStringRef; external name '_kCFUserNotificationPopUpSelectionKey'; (* attribute const *)
 
225
(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
 
226
{#endif}
 
227
 
 
228
implementation
 
229
 
 
230
 
 
231
{$R-}
 
232
 
 
233
function CFUserNotificationCheckBoxChecked( i: CFIndex ): CFOptionFlags; inline;
 
234
begin
 
235
        CFUserNotificationCheckBoxChecked := CFOptionFlags(1 shl (8+i));
 
236
end;
 
237
 
 
238
function CFUserNotificationSecureTextField( i: CFIndex ): CFOptionFlags; inline;
 
239
begin
 
240
        CFUserNotificationSecureTextField := CFOptionFlags(1 shl (16+i));
 
241
end;
 
242
 
 
243
function CFUserNotificationPopUpSelection( n: CFIndex ): CFOptionFlags; inline;
 
244
begin
 
245
        CFUserNotificationPopUpSelection := CFOptionFlags(n shl 24);
 
246
end;
 
247
 
 
248
end.