1 {
2 File: HIToolbox/HISlider.h
3
4 Contains: API and type definitions related to HISlider.
5
6 Version: HIToolbox-624~3
7
8 Copyright: � 1999-2008 by Apple Computer, Inc., all rights reserved.
9
10 Bugs?: For bug reports, consult the following page on
11 the World Wide Web:
12
13 http://bugs.freepascal.org
14
15 }
16 { Initial Pascal Translation: Jonas Maebe, <jonas@freepascal.org>, October 2009 }
17 { Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2012 }
18 {
19 Modified for use with Free Pascal
20 Version 308
21 Please report any bugs to <gpc@microbizz.nl>
22 }
23
24 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
25 {$mode macpas}
26 {$modeswitch cblocks}
27 {$packenum 1}
28 {$macro on}
29 {$inline on}
30 {$calling mwpascal}
31
32 unit HISlider;
33 interface
34 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
35 {$setc GAP_INTERFACES_VERSION := $0308}
36
37 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
38 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
39 {$endc}
40
41 {$ifc defined CPUPOWERPC and defined CPUI386}
42 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
43 {$endc}
44 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
45 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
46 {$endc}
47
48 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
49 {$setc __ppc__ := 1}
50 {$elsec}
51 {$setc __ppc__ := 0}
52 {$endc}
53 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
54 {$setc __ppc64__ := 1}
55 {$elsec}
56 {$setc __ppc64__ := 0}
57 {$endc}
58 {$ifc not defined __i386__ and defined CPUI386}
59 {$setc __i386__ := 1}
60 {$elsec}
61 {$setc __i386__ := 0}
62 {$endc}
63 {$ifc not defined __x86_64__ and defined CPUX86_64}
64 {$setc __x86_64__ := 1}
65 {$elsec}
66 {$setc __x86_64__ := 0}
67 {$endc}
68 {$ifc not defined __arm__ and defined CPUARM}
69 {$setc __arm__ := 1}
70 {$elsec}
71 {$setc __arm__ := 0}
72 {$endc}
73 {$ifc not defined __arm64__ and defined CPUAARCH64}
74 {$setc __arm64__ := 1}
75 {$elsec}
76 {$setc __arm64__ := 0}
77 {$endc}
78
79 {$ifc defined cpu64}
80 {$setc __LP64__ := 1}
81 {$elsec}
82 {$setc __LP64__ := 0}
83 {$endc}
84
85
86 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
87 {$error Conflicting definitions for __ppc__ and __i386__}
88 {$endc}
89
90 {$ifc defined __ppc__ and __ppc__}
91 {$setc TARGET_CPU_PPC := TRUE}
92 {$setc TARGET_CPU_PPC64 := FALSE}
93 {$setc TARGET_CPU_X86 := FALSE}
94 {$setc TARGET_CPU_X86_64 := FALSE}
95 {$setc TARGET_CPU_ARM := FALSE}
96 {$setc TARGET_CPU_ARM64 := FALSE}
97 {$setc TARGET_OS_MAC := TRUE}
98 {$setc TARGET_OS_IPHONE := FALSE}
99 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
100 {$setc TARGET_OS_EMBEDDED := FALSE}
101 {$elifc defined __ppc64__ and __ppc64__}
102 {$setc TARGET_CPU_PPC := FALSE}
103 {$setc TARGET_CPU_PPC64 := TRUE}
104 {$setc TARGET_CPU_X86 := FALSE}
105 {$setc TARGET_CPU_X86_64 := FALSE}
106 {$setc TARGET_CPU_ARM := FALSE}
107 {$setc TARGET_CPU_ARM64 := FALSE}
108 {$setc TARGET_OS_MAC := TRUE}
109 {$setc TARGET_OS_IPHONE := FALSE}
110 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
111 {$setc TARGET_OS_EMBEDDED := FALSE}
112 {$elifc defined __i386__ and __i386__}
113 {$setc TARGET_CPU_PPC := FALSE}
114 {$setc TARGET_CPU_PPC64 := FALSE}
115 {$setc TARGET_CPU_X86 := TRUE}
116 {$setc TARGET_CPU_X86_64 := FALSE}
117 {$setc TARGET_CPU_ARM := FALSE}
118 {$setc TARGET_CPU_ARM64 := FALSE}
119 {$ifc defined iphonesim}
120 {$setc TARGET_OS_MAC := FALSE}
121 {$setc TARGET_OS_IPHONE := TRUE}
122 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
123 {$elsec}
124 {$setc TARGET_OS_MAC := TRUE}
125 {$setc TARGET_OS_IPHONE := FALSE}
126 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
127 {$endc}
128 {$setc TARGET_OS_EMBEDDED := FALSE}
129 {$elifc defined __x86_64__ and __x86_64__}
130 {$setc TARGET_CPU_PPC := FALSE}
131 {$setc TARGET_CPU_PPC64 := FALSE}
132 {$setc TARGET_CPU_X86 := FALSE}
133 {$setc TARGET_CPU_X86_64 := TRUE}
134 {$setc TARGET_CPU_ARM := FALSE}
135 {$setc TARGET_CPU_ARM64 := FALSE}
136 {$ifc defined iphonesim}
137 {$setc TARGET_OS_MAC := FALSE}
138 {$setc TARGET_OS_IPHONE := TRUE}
139 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
140 {$elsec}
141 {$setc TARGET_OS_MAC := TRUE}
142 {$setc TARGET_OS_IPHONE := FALSE}
143 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
144 {$endc}
145 {$setc TARGET_OS_EMBEDDED := FALSE}
146 {$elifc defined __arm__ and __arm__}
147 {$setc TARGET_CPU_PPC := FALSE}
148 {$setc TARGET_CPU_PPC64 := FALSE}
149 {$setc TARGET_CPU_X86 := FALSE}
150 {$setc TARGET_CPU_X86_64 := FALSE}
151 {$setc TARGET_CPU_ARM := TRUE}
152 {$setc TARGET_CPU_ARM64 := FALSE}
153 {$setc TARGET_OS_MAC := FALSE}
154 {$setc TARGET_OS_IPHONE := TRUE}
155 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
156 {$setc TARGET_OS_EMBEDDED := TRUE}
157 {$elifc defined __arm64__ and __arm64__}
158 {$setc TARGET_CPU_PPC := FALSE}
159 {$setc TARGET_CPU_PPC64 := FALSE}
160 {$setc TARGET_CPU_X86 := FALSE}
161 {$setc TARGET_CPU_X86_64 := FALSE}
162 {$setc TARGET_CPU_ARM := FALSE}
163 {$setc TARGET_CPU_ARM64 := TRUE}
164 {$ifc defined ios}
165 {$setc TARGET_OS_MAC := FALSE}
166 {$setc TARGET_OS_IPHONE := TRUE}
167 {$setc TARGET_OS_EMBEDDED := TRUE}
168 {$elsec}
169 {$setc TARGET_OS_MAC := TRUE}
170 {$setc TARGET_OS_IPHONE := FALSE}
171 {$setc TARGET_OS_EMBEDDED := FALSE}
172 {$endc}
173 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
174 {$elsec}
175 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
176 {$endc}
177
178 {$ifc defined __LP64__ and __LP64__ }
179 {$setc TARGET_CPU_64 := TRUE}
180 {$elsec}
181 {$setc TARGET_CPU_64 := FALSE}
182 {$endc}
183
184 {$ifc defined FPC_BIG_ENDIAN}
185 {$setc TARGET_RT_BIG_ENDIAN := TRUE}
186 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
187 {$elifc defined FPC_LITTLE_ENDIAN}
188 {$setc TARGET_RT_BIG_ENDIAN := FALSE}
189 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
190 {$elsec}
191 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
192 {$endc}
193 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
194 {$setc CALL_NOT_IN_CARBON := FALSE}
195 {$setc OLDROUTINENAMES := FALSE}
196 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
197 {$setc OPAQUE_UPP_TYPES := TRUE}
198 {$setc OTCARBONAPPLICATION := TRUE}
199 {$setc OTKERNEL := FALSE}
200 {$setc PM_USE_SESSION_APIS := TRUE}
201 {$setc TARGET_API_MAC_CARBON := TRUE}
202 {$setc TARGET_API_MAC_OS8 := FALSE}
203 {$setc TARGET_API_MAC_OSX := TRUE}
204 {$setc TARGET_CARBON := TRUE}
205 {$setc TARGET_CPU_68K := FALSE}
206 {$setc TARGET_CPU_MIPS := FALSE}
207 {$setc TARGET_CPU_SPARC := FALSE}
208 {$setc TARGET_OS_UNIX := FALSE}
209 {$setc TARGET_OS_WIN32 := FALSE}
210 {$setc TARGET_RT_MAC_68881 := FALSE}
211 {$setc TARGET_RT_MAC_CFM := FALSE}
212 {$setc TARGET_RT_MAC_MACHO := TRUE}
213 {$setc TYPED_FUNCTION_POINTERS := TRUE}
214 {$setc TYPE_BOOL := FALSE}
215 {$setc TYPE_EXTENDED := FALSE}
216 {$setc TYPE_LONGLONG := TRUE}
217 uses MacTypes,HIView,MacWindows,Controls,QuickdrawTypes,HIObject;
218 {$endc} {not MACOSALLINCLUDE}
219
220
221 {$ifc TARGET_OS_MAC}
222
223 {$ALIGN POWER}
224
225
226 {
227 * Discussion:
228 * There are several variants that control the behavior of the
229 * slider control. Any combination of the following three constants
230 * can be added to the basic CDEF ID (kSliderProc).
231 *
232 * Mac OS X has a "Scroll to here" option in the General pane of
233 * System Preferences which allows users to click in the page
234 * up/down regions of a slider and have the thumb/indicator jump
235 * directly to the clicked position, which alters the value of the
236 * slider and moves any associated content appropriately. As long as
237 * the mouse button is held down, the click is treated as though the
238 * user had clicked in the thumb/indicator in the first place.
239 *
240 *
241 * If you want the sliders in your application to work with the
242 * "Scroll to here" option, you must do the following:
243 *
244 * 1. Create live-tracking sliders, not sliders that show a "ghost"
245 * thumb when you click on it. You can request live-tracking sliders
246 * by passing true in the liveTracking parameter to
247 * CreateSliderControl. If you create sliders with NewControl, use
248 * the kControlSliderLiveFeedback variant.
249 *
250 * 2. Write an appropriate ControlActionProc and associate it with
251 * your slider via the SetControlAction API. This allows your
252 * application to update its content appropriately when the
253 * live-tracking slider is clicked.
254 *
255 * 3. When calling HandleControlClick or TrackControl, pass -1 in
256 * the action proc parameter. This is a request for the Control
257 * Manager to use the action proc you associated with your control
258 * in step 2. If you rely on the standard window event handler to do
259 * your control tracking, this step is handled for you automatically.
260 }
261 const
262 kControlSliderProc = 48;
263 kControlSliderLiveFeedback = 1 shl 0;
264 kControlSliderHasTickMarks = 1 shl 1;
265 kControlSliderReverseDirection = 1 shl 2;
266 kControlSliderNonDirectional = 1 shl 3;
267
268
269 {
270 * ControlSliderOrientation
271 *
272 * Discussion:
273 * Slider Orientation
274 }
275 type
276 ControlSliderOrientation = UInt16;
277 const
278 {
279 * If horizontal, the thumb of the slider points downwards. If
280 * vertical, the thumb of the slider points to the right. This
281 * orientation of slider can show tick marks.
282 }
283 kControlSliderPointsDownOrRight = 0;
284
285 {
286 * If horizontal, the thumb of the slider points upwards. If
287 * vertical, the thumb of the slider points to the left. This
288 * orientation of slider can show tick marks.
289 }
290 kControlSliderPointsUpOrLeft = 1;
291
292 {
293 * The slider thumb is non-directional. This orientation of slider is
294 * not capable of showing tick marks.
295 }
296 kControlSliderDoesNotPoint = 2;
297
298 { Control Kind Tag }
299 const
300 kControlKindSlider = FourCharCode('sldr');
301
302 { The HIObject class ID for the HISlider class. }
303 {$ifc USE_CFSTR_CONSTANT_MACROS}
304 {$definec kHISliderClassID CFSTRP('com.apple.HISlider')}
305 {$endc}
306 {$ifc not TARGET_CPU_64}
307 {
308 * CreateSliderControl()
309 *
310 * Summary:
311 * Creates a slider control with the specified settings.
312 *
313 * Mac OS X threading:
314 * Not thread safe
315 *
316 * Parameters:
317 *
318 * window:
319 * The window in which to create the slider.
320 *
321 * boundsRect:
322 * The bounds with which to create the slider.
323 *
324 * value:
325 * The initial value of the slider. Should be in the range of the
326 * minimum and maximum values.
327 *
328 * minimum:
329 * The minimum value of the slider. Should be less than the
330 * maximum.
331 *
332 * maximum:
333 * The maximum value of the slider. Should be greater than the
334 * minimum.
335 *
336 * orientation:
337 * The orientation of the slider.
338 *
339 * numTickMarks:
340 * The number of tick marks of the slider. The orientation must
341 * not support tick marks if this value is non-zero.
342 *
343 * liveTracking:
344 *
345 * liveTrackingProc:
346 *
347 * outControl:
348 * A pointer to a ControlRef in which to store a reference to the
349 * created slider.
350 *
351 * Result:
352 * An operating system status code.
353 *
354 * Availability:
355 * Mac OS X: in version 10.0 and later in Carbon.framework [32-bit only]
356 * CarbonLib: in CarbonLib 1.1 and later
357 * Non-Carbon CFM: not available
358 }
CreateSliderControlnull359 function CreateSliderControl( window: WindowRef; const (*var*) boundsRect: Rect; value: SInt32; minimum: SInt32; maximum: SInt32; orientation: ControlSliderOrientation; numTickMarks: UInt16; liveTracking: Boolean; liveTrackingProc: ControlActionUPP; var outControl: ControlRef ): OSStatus; external name '_CreateSliderControl';
360 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
361
362
363 {
364 * HISliderGetThumbOrientation()
365 *
366 * Summary:
367 * Get the orientation of the thumb of a slider.
368 *
369 * Discussion:
370 * Available only on Mac OS X 10.5 and later.
371 *
372 * Mac OS X threading:
373 * Not thread safe
374 *
375 * Parameters:
376 *
377 * inSlider:
378 * A reference to the slider from which to retrieve the thumb
379 * orientation.
380 *
381 * Result:
382 * The current thumb orientation of the specified slider. The
383 * incoming slider reference must be valid or the return value is
384 * undefined.
385 *
386 * Availability:
387 * Mac OS X: in version 10.5 and later in Carbon.framework [32-bit only]
388 * CarbonLib: not available
389 * Non-Carbon CFM: not available
390 }
HISliderGetThumbOrientationnull391 function HISliderGetThumbOrientation( inSlider: HIViewRef ): ControlSliderOrientation; external name '_HISliderGetThumbOrientation';
392 (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
393
394
395 {
396 * HISliderSetThumbOrientation()
397 *
398 * Summary:
399 * Set the orientation of the thumb of a slider.
400 *
401 * Discussion:
402 * Available only on Mac OS X 10.5 and later. This call may change
403 * the bounds needed to draw the slider fully. If changing the
404 * orientation so that tick marks will appear/disappear, be sure to
405 * resize the control to its optimal size if necessary.
406 *
407 * Mac OS X threading:
408 * Not thread safe
409 *
410 * Parameters:
411 *
412 * inSlider:
413 * A reference to the slider from which to retrieve the thumb
414 * orientation.
415 *
416 * inOrientation:
417 * A ControlSliderOrientation for the desired thumb orientation.
418 *
419 * Result:
420 * An OSStatus code indicating success or failure.
421 *
422 * Availability:
423 * Mac OS X: in version 10.5 and later in Carbon.framework [32-bit only]
424 * CarbonLib: not available
425 * Non-Carbon CFM: not available
426 }
HISliderSetThumbOrientationnull427 function HISliderSetThumbOrientation( inSlider: HIViewRef; inOrientation: ControlSliderOrientation ): OSStatus; external name '_HISliderSetThumbOrientation';
428 (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
429
430
431 {
432 * HISliderGetTickMarkCount()
433 *
434 * Summary:
435 * Get the tick mark count of a slider.
436 *
437 * Discussion:
438 * Available only on Mac OS X 10.5 and later.
439 *
440 * Mac OS X threading:
441 * Not thread safe
442 *
443 * Parameters:
444 *
445 * inSlider:
446 * A reference to the slider for which to get the tick mark count.
447 *
448 * Result:
449 * The current tick mark count of the specified slider. The incoming
450 * slider reference must be valid or the return value is undefined.
451 *
452 * Availability:
453 * Mac OS X: in version 10.5 and later in Carbon.framework [32-bit only]
454 * CarbonLib: not available
455 * Non-Carbon CFM: not available
456 }
HISliderGetTickMarkCountnull457 function HISliderGetTickMarkCount( inSlider: HIViewRef ): ItemCount; external name '_HISliderGetTickMarkCount';
458 (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
459
460
461 {
462 * HISliderSetTickMarkCount()
463 *
464 * Summary:
465 * Set the tick mark count of a slider. Tick marks will not appear
466 * on a slider unless its orientation is pointy (i.e.
467 * kControlSliderPointsDownOrRight/UpOrLeft) This call may change
468 * the bounds needed to draw the slider fully. If changing the tick
469 * mark count so that tick marks will appear/disappear, be sure to
470 * resize the control to its optimal size if necessary.
471 *
472 * Discussion:
473 * Available only on Mac OS X 10.5 and later.
474 *
475 * Mac OS X threading:
476 * Not thread safe
477 *
478 * Parameters:
479 *
480 * inSlider:
481 * A reference to the slider for which to set the tick mark count.
482 *
483 * inNumTicks:
484 * The desired number of tick marks.
485 *
486 * Result:
487 * An OSStatus code indicating success or failure.
488 *
489 * Availability:
490 * Mac OS X: in version 10.5 and later in Carbon.framework [32-bit only]
491 * CarbonLib: not available
492 * Non-Carbon CFM: not available
493 }
HISliderSetTickMarkCountnull494 function HISliderSetTickMarkCount( inSlider: HIViewRef; inNumTicks: ItemCount ): OSStatus; external name '_HISliderSetTickMarkCount';
495 (* AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER *)
496
497
498 {$endc} {not TARGET_CPU_64}
499
500 {$endc} {TARGET_OS_MAC}
501 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
502
503 end.
504 {$endc} {not MACOSALLINCLUDE}
505