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
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
|
/*
File: HIObject.h
Contains: Base object for HIToolbox
Version: QuickTime 7.3
Copyright: (c) 2007 (c) 2001 by Apple Computer, Inc., all rights reserved.
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __HIOBJECT__
#define __HIOBJECT__
#ifndef __CORESERVICES__
#include <CoreServices.h>
#endif
#ifndef __COREFOUNDATION__
#include <CoreFoundation.h>
#endif
#ifndef __CARBONEVENTSCORE__
#include <CarbonEventsCore.h>
#endif
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT
#pragma import on
#endif
/*
* HIObject
*
* Discussion:
* HIObject is the HIToolbox's base class for various objects. Over
* time, all of our common objects (controls, windows, menus, etc.)
* will be derived from HIObject. Code which is external to
* HIToolbox can also create its own subclasses of our objects using
* the routines contained in this file. There are also polymorphic
* functions one can use on any HIObject for getting the class ID,
* etc.
*
* HIObjects are actually CF types under the hood. This means that
* they can be put into CF collections and retain/release can be
* called on them.
*
* An HIObject is essentially a very basic building-block object
* which contains an event target. You can create these objects to
* use as your own Carbon Event receptors in your application, or
* you can subclass existing Toolbox object to suit your needs.
*
*
* You register your subclasses with HIObjectRegisterSubclass,
* passing your class ID, the parent class, and an event handler.
* You also pass a list of events the handler is interested in.
*
*
* To create an object of your subclass, you call HIObjectCreate,
* passing the class ref you registered, as well as an
* initialization event.
*
* Construction is two-phase: first the basic construction of the
* object is done, then initialization is performed. The toolbox
* sends construction events bottom-up, as you would expect in C++
* or the like. Here is the list of what goes on to create an
* object:
*
* 1) The Toolbox creates the base HIObject
*
* 2) It then installs the event handler you specified when you
* registered your subclass. Your handler must listen for
* kEventHIObjectConstruct and kEventHIObjectDestruct events. If it
* does not, the class cannot be registered (you will get a
* paramErr).
*
* 3) Next, the Toolbox _directly_ calls your handler with an
* kEventHIObjectConstruct event. When called like this, you are not
* really being called in the context of a handler stack, so you
* cannot do things like CallNextEventHandler. The userData
* parameter is what you specified when you registered the class.
* Typically, during construction you will allocate memory yourself
* to store your own instance data; this allocation might be as
* simple as calling malloc or NewPtr, or it might involve creating
* your own C++ object. In the construct event, you are passed the
* base HIObjectRef of the object being created. Typically you would
* store this HIObjectRef in your own instance data for later use.
* When handling this construct event, you should be sure to use
* SetEventParameter to set the kEventParamHIObjectInstance
* parameter in the construction event with your own instance data.
* You must use typeVoidPtr as the type.
*
* 4) The Toolbox looks for your instance of typeVoidPtr after you
* handle the construct event. It then takes that data and stores it
* off with the object and also sets the user data of the event
* handler it installed to be this instance data. This means that
* following the construct event, all calls to your event handler
* will have the instance data you returned to us.
*
* 5) Once construction has completed successfully, we will send
* your object the initialize event passed into HIObjectCreate. At
* this point, all events are now sent to your object using standard
* Carbon Events mechanisms (it is only the construct event which is
* special). When we send the initialization event to your subclass,
* you should pass the event to your superclass before proceeding.
* You do this with CallNextEventHandler. Once back from that call,
* you should verify that the result is noErr, indicating that the
* superclass did in fact initialize properly. If it did not, your
* should return the error that CallNextEventHandler returned from
* your handler as well. The object will be destroyed by the
* Toolbox. Your object should be able to be destroyed in a
* partially initialized state such as this. This stage is optional,
* i.e. an object does not need to respond to the initialize event
* unless it is expecting certain parameters to be passed to it at
* creation time. This is where those parameters can be fetched.
*
*
* 6) Once initialization is successful, the HIObjectRef is
* returned to the caller of HIObjectCreate. From there, you can
* have all sorts of cool fun.
*
* When someone has called HIObjectRelease enough such that the
* refcount of the object drops to zero, the object is destroyed.
* The Toolbox will send a kEventHIObjectDestruct event to your
* object. DO NOT CALL CALLNEXTEVENTHANDLER. You will be setting
* yourself up for some hurt. Just clean up and return from your
* handler.
*/
typedef struct OpaqueHIObjectClassRef* HIObjectClassRef;
typedef struct OpaqueHIObjectRef* HIObjectRef;
/*
* Discussion:
* HIObject errors
*/
enum {
/*
* You are trying to register a class ID that already exists.
*/
hiObjectClassExistsErr = -22080,
/*
* You are trying to unregister a class which has instances which
* still exist. You must destroy them first, before they destroy you!
*/
hiObjectClassHasInstancesErr = -22081,
hiObjectClassHasSubclassesErr = -22082,
/*
* You are trying to create an HIObject class that is defined as
* being abstract. You must subclass it instead. Oh yes. Don't make
* us say it twice!
*/
hiObjectClassIsAbstractErr = -22083
};
/*
Parameters for HIObject events:
kEventHIObjectConstruct
--> kEventParamHIObjectInstance typeHIObjectRef
kEventHIObjectInitialize
This is up to the class and any superclasses. It will contain the
union of all parameters needed by all classes to properly construct.
kEventHIObjectDestruct
No parameters are passed.
kEventHIObjectIsEqual
--> kEventParamDirectObject typeHIObjectRef
kEventHIObjectPrintDebugInfo
no parameters
*/
/*
* Discussion:
* These enums define the base class functionality of HIObjects. You
* should only need to be aware of these if you are implementing a
* subclass.
*/
enum {
/*
* The event class for HIObject events
*/
kEventClassHIObject = FOUR_CHAR_CODE('hiob'),
/*
* Your object is being constructed. When your event handler is
* called with this event, it is being called directly and not
* through the normal event dispatching mechanism. This means that
* the EventHandlerCallRef passed to your handler will be NULL and
* CallNextEventHandler will not work. You are passed the actual
* HIObjectRef of your base class for you to record in your instance
* data.
*/
kEventHIObjectConstruct = 1,
/*
* Your object is being initialized. Your handler should pass this
* onto the superclass first before handling this event. This is done
* by calling CallNextEventHandler with the event. When that function
* returns, you should make sure the result is noErr. If not, you
* should NOT continue to initialize your class.
*/
kEventHIObjectInitialize = 2,
/*
* Your object is being destroyed. This is your chance to dispose of
* anything you might have allocated for your object. Do NOT call
* through with CallNextEventHandler, as you will disrupt the fabric
* of space-time.
*/
kEventHIObjectDestruct = 3,
/*
* HIObjectIsEqual has been called, and you are being asked to
* determine if your object is equivalent to the one being passed to
* your handler. You should return true if so, and false if not.
*/
kEventHIObjectIsEqual = 4,
/*
* HIObjectPrintDebugInfo has been called, and you are being asked to
* print your information to stdout. This event is sent to all
* handlers and you should NOT call CallNextEventHandler.
*/
kEventHIObjectPrintDebugInfo = 5
};
enum {
kEventParamHIObjectInstance = FOUR_CHAR_CODE('hioi'),
typeHIObjectRef = FOUR_CHAR_CODE('hiob')
};
#define _HIObjectRegisterSubclass HIObjectRegisterSubclass
/*
* HIObjectRegisterSubclass()
*
* Discussion:
* Registers a class with the Toolbox for creation later.
*
* Parameters:
*
* inClassID:
* The class ID of your class. It should be unique. We recommend
* using Java-style com.company.foo naming conventions to avoid
* collisions.
*
* inBaseClassID:
* The class ID of the class you derive from. Passing NULL
* indicates you wish to subclass HIObject (the base class)
* directly.
*
* inOptions:
* Any special options for your class. Currently you must pass 0
* for this parameter.
*
* inConstructProc:
* The construction proc for this subclass. You pass the address
* of an event handler into this parameter. This handler is called
* directly, rather than through the normal event dispatching
* mechanism. This means that the EventHandlerCallRef passed in
* will be NULL, and you cannot use it for calls like
* CallNextEventHandler. Other than that, you should return a
* result as usual. After your object is constructed, this proc
* will be installed as the event handler for the remaining events
* specified in the inEventList parameter.
*
* inNumEvents:
* The number of events you are installing.
*
* inEventList:
* The events your handler wishes to receive. You must handle the
* kEventHIObjectConstruct and kEventHIObjectDestruct event. If
* these events are not specified, an error is returned.
*
* inConstructData:
* Pass any info you want passed into your event handler here. For
* a C++ hierarchy based on HIObjects, you might actually pass a
* static method to construct your object here, and the base class
* event handler to do construction as your event handler.
*
* outClassRef:
* The newly created class reference. Pass NULL if you don't care.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( OSStatus )
HIObjectRegisterSubclass(
CFStringRef inClassID,
CFStringRef inBaseClassID,
OptionBits inOptions,
EventHandlerUPP inConstructProc,
UInt32 inNumEvents,
const EventTypeSpec * inEventList,
void * inConstructData,
HIObjectClassRef * outClassRef); /* can be NULL */
/*
* HIObjectUnregisterClass()
*
* Discussion:
* Unregisters a previously registered subclass of HIObject. You
* will receive an error if there are subclasses of your class or
* instances of it which still exist. All instances and subclasses
* must be disposed of and unregistered first.
*
* Parameters:
*
* inClassRef:
* The class ref of the class of object you wish to unregister.
*
* inConstructData:
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( OSStatus )
HIObjectUnregisterClass(HIObjectClassRef inClassRef);
#define _HIObjectCreate HIObjectCreate
/*
* HIObjectCreate()
*
* Discussion:
* Creates an object derived from HIObject.
*
* Parameters:
*
* inClassID:
* The class ID of the class of object you wish to instantiate.
*
* inConstructData:
* If your class (or any class you derive from) accepts creation
* parameters, you need to pass an event into this parameter. The
* class must be kEventClassHIObject, and the kind should be
* kEventHIObjectInitialize. Any other parameters should be added
* as necessary. Specific subclasses of HIObject which require
* initialization parameters will specify those parameters in the
* appropriate headers.
*
* outObject:
* The instance of the object you create.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( OSStatus )
HIObjectCreate(
CFStringRef inClassID,
EventRef inConstructData,
HIObjectRef * outObject);
#define _HIObjectGetEventTarget HIObjectGetEventTarget
/*
* HIObjectGetEventTarget()
*
* Discussion:
* Returns the event target of an HIObjectRef.
*
* Parameters:
*
* inObject:
* The object whose target you want.
*
* Result:
* An EventTargetRef.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( EventTargetRef )
HIObjectGetEventTarget(HIObjectRef inObject);
#define _HIObjectPrintDebugInfo HIObjectPrintDebugInfo
/*
* HIObjectPrintDebugInfo()
*
* Discussion:
* Prints the internal information of an HIObject for debugging
* purposes. It outputs the info to stdout.
*
* Parameters:
*
* inObject:
* The object to inspect.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( void )
HIObjectPrintDebugInfo(HIObjectRef inObject);
#define _HIObjectCopyClassID HIObjectCopyClassID
/*
* HIObjectCopyClassID()
*
* Discussion:
* Returns the class ID of a given HIObject.
*
* Parameters:
*
* inObject:
* The object whose class ID you are interested in.
*
* Result:
* A CFStringRef containing the object's class ID.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( CFStringRef )
HIObjectCopyClassID(HIObjectRef inObject);
#define _HIObjectIsOfClass HIObjectIsOfClass
/*
* HIObjectIsOfClass()
*
* Discussion:
* Returns whether or not an object is of a certain class. You can
* us this to see whether or not an object you have derives from an
* expected superclass.
*
* Parameters:
*
* inObject:
* The object whose class ID you wish to check.
*
* inObjectClassID:
* The class ID in question.
*
* Result:
* A Boolean result indicating whether or not the object is of the
* class specified.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( Boolean )
HIObjectIsOfClass(
HIObjectRef inObject,
CFStringRef inObjectClassID);
#define _HIObjectDynamicCast HIObjectDynamicCast
/*
* HIObjectDynamicCast()
*
* Discussion:
* Returns the instance data for a specific class of an HIObject.
* The instance data returned is the same instance data the class's
* construction event handler returns in the instance data
* parameter. This is stored off with the class reference so that it
* can be fetched later for use by this function. It allows your
* subclass to easily get at the data it created, if your subclass
* needs that data outside of an event handler. (Inside an event
* handler, your subclass can get at its instance data via the
* userData parameter to the event handler.)
*
* Parameters:
*
* inObject:
* The object whose class ID you wish to check.
*
* inClassID:
* The class ID to get the instance data for.
*
* Result:
* A void * result which contains the instance data for the object,
* or NULL if the object is not an instance of the class.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( void * )
HIObjectDynamicCast(
HIObjectRef inObject,
CFStringRef inClassID);
/*
* HIObjectCreateFromBundle()
*
* Discussion:
* Returns the HIObject for the given bundle. A bundle can be
* designed to communicate with an app through an HIObject. The
* bundle must be designed to create an HIObject and have a defined
* suite of CarbonEvents that clients can use to communicate with
* the bundle's HIObject. Given a CFBundleRef, this API will tell
* the bundle to create the HIObject and return it to the caller.
*
* Parameters:
*
* inBundle:
* The bundle that you wish to communicate with.
*
* outObject:
* The HIObject associated with the bundle.
*
* Result:
* An operating system result code. If the bundle's HIObject
* creation function cannot be found, cfragNoSymbolErr will be
* returned.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( OSStatus )
HIObjectCreateFromBundle(
CFBundleRef inBundle,
HIObjectRef * outObject);
/*
* HIObjectIsAccessibilityIgnored()
*
* Discussion:
* Reports whether or not the given HIObject is marked as ignored
* for accessibility.
* See the discussion of HIObjectSetAccessibilityIgnored for details
* on what it means to be accessibility ignored.
*
* Parameters:
*
* inObject:
* The object whose accessibility ignored state you wish to query.
*
* Result:
* A Boolean value indicating whether or not the HIObject is ignored
* for accessibility.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( Boolean )
HIObjectIsAccessibilityIgnored(HIObjectRef inObject);
/*
* HIObjectSetAccessibilityIgnored()
*
* Discussion:
* Marks an HIObject as ignored (or not) for the purposes of the
* accessibility APIs.
* An HIObject that is ignored for accessibility will never be shown
* to an assistive application that uses the accessibility APIs to
* examine an interface. Your application's accessibility
* implementation can (and should) still report an ignored HIObject
* as usual. Carbon's accessibility engine will automatically prune
* any ignored HIObjects out of the data that is shown to an
* assistive application.
* By default, an HIObject is *not* accessibility ignored.
*
* Parameters:
*
* inObject:
* The object whose accessibility ignored state you wish to change.
*
* inIgnored:
* A Boolean value indicating whether or not to ignore the object.
*
* Result:
* An OSStatus signifying success or failure.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( OSStatus )
HIObjectSetAccessibilityIgnored(
HIObjectRef inObject,
Boolean inIgnored);
/*==============================================================================*/
/* DEPRECATED! DO NOT USE. USE CF ROUTINES INSTEAD!!! */
/*==============================================================================*/
/* Use CFRetain instead!*/
/*
* _HIObjectRetain()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( HIObjectRef )
_HIObjectRetain(HIObjectRef inObject);
/* Use CFRelease instead!*/
/*
* _HIObjectRelease()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( void )
_HIObjectRelease(HIObjectRef inObject);
/* Use CFGetRetainCount instead!*/
/*
* _HIObjectGetRetainCount()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( UInt32 )
_HIObjectGetRetainCount(HIObjectRef inObject);
/* Use CFEqual instead!*/
/*
* _HIObjectIsEqual()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
EXTERN_API_C( Boolean )
_HIObjectIsEqual(
HIObjectRef inObject,
HIObjectRef inOtherObject);
/*
These are no longer necessary! Just put the HIObjectRef directly into
an array using the standard CFType callbacks.
*/
/*
* kHIObjectCFArrayCallbacks
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
extern const CFArrayCallBacks kHIObjectCFArrayCallbacks;
/*
* kHIObjectCFDictKeyCallbacks
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
extern const CFDictionaryKeyCallBacks kHIObjectCFDictKeyCallbacks;
/*
* kHIObjectCFDictValueCallbacks
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
* Mac OS X: in version 10.2 and later
*/
extern const CFDictionaryValueCallBacks kHIObjectCFDictValueCallbacks;
#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#endif /* __HIOBJECT__ */
|