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
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
|
/*
File: CarbonEventsCore.h
Contains: Carbon Event Manager
Version: QuickTime 7.3
Copyright: (c) 2007 (c) 1999-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 __CARBONEVENTSCORE__
#define __CARBONEVENTSCORE__
#ifndef __CFSTRING__
#include <CFString.h>
#endif
#ifndef __AEREGISTRY__
#include <AERegistry.h>
#endif
#ifndef __AEDATAMODEL__
#include <AEDataModel.h>
#endif
#if PRAGMA_ONCE
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if PRAGMA_IMPORT
#pragma import on
#endif
#if PRAGMA_STRUCT_ALIGN
#pragma options align=mac68k
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(push, 2)
#elif PRAGMA_STRUCT_PACK
#pragma pack(2)
#endif
/*======================================================================================*/
/* The core data structure of the Carbon Event system */
/*======================================================================================*/
typedef struct OpaqueEventRef* EventRef;
/*======================================================================================*/
/* EVENT COMMON */
/*======================================================================================*/
/*
* Discussion:
* The following are all errors which can be returned from the
* routines contained in this file.
*/
enum {
/*
* This is returned from PostEventToQueue if the event in question is
* already in the queue you are posting it to (or any other queue).
*/
eventAlreadyPostedErr = -9860,
/*
* You are attemtping to modify a target that is currently in use,
* such as when dispatching.
*/
eventTargetBusyErr = -9861,
/*
* This is obsolete and will be removed.
*/
eventClassInvalidErr = -9862,
/*
* This is obsolete and will be removed.
*/
eventClassIncorrectErr = -9864,
/*
* Returned from InstallEventHandler if the handler proc you pass is
* already installed for a given event type you are trying to
* register.
*/
eventHandlerAlreadyInstalledErr = -9866,
/*
* A generic error.
*/
eventInternalErr = -9868,
/*
* This is obsolete and will be removed.
*/
eventKindIncorrectErr = -9869,
/*
* The piece of data you are requesting from an event is not present.
*/
eventParameterNotFoundErr = -9870,
/*
* This is what you should return from an event handler when your
* handler has received an event it doesn't currently want to (or
* isn't able to) handle. If you handle an event, you should return
* noErr from your event handler. Any return value other than
* eventNotHandledErr will cause event handling to stop; the event
* will not be sent to any other event handler, and the return value
* will be provided to the original caller of SendEventToTarget.
*/
eventNotHandledErr = -9874,
/*
* The event loop has timed out. This can be returned from calls to
* ReceiveNextEvent or RunCurrentEventLoop.
*/
eventLoopTimedOutErr = -9875,
/*
* The event loop was quit, probably by a call to QuitEventLoop. This
* can be returned from ReceiveNextEvent or RunCurrentEventLoop.
*/
eventLoopQuitErr = -9876,
/*
* Returned from RemoveEventFromQueue when trying to remove an event
* that's not in any queue.
*/
eventNotInQueueErr = -9877,
eventHotKeyExistsErr = -9878,
eventHotKeyInvalidErr = -9879
};
/*======================================================================================*/
/* EVENT CORE */
/*======================================================================================*/
/*--------------------------------------------------------------------------------------*/
/* o Event Flags, options */
/*--------------------------------------------------------------------------------------*/
/*
* EventPriority
*
* Discussion:
* These values define the relative priority of an event, and are
* used when posting events with PostEventToQueue. In general events
* are pulled from the queue in order of first posted to last
* posted. These priorities are a way to alter that when posting
* events. You can post a standard priority event and then a high
* priority event and the high priority event will be pulled from
* the queue first.
*/
typedef SInt16 EventPriority;
enum {
/*
* Lowest priority. Currently only window update events are posted at
* this priority.
*/
kEventPriorityLow = 0,
/*
* Normal priority of events. Most events are standard priority.
*/
kEventPriorityStandard = 1,
/*
* Highest priority.
*/
kEventPriorityHigh = 2
};
enum {
kEventLeaveInQueue = false,
kEventRemoveFromQueue = true
};
/*--------------------------------------------------------------------------------------*/
/* o Event Times */
/* */
/* EventTime is in seconds since boot. Use the constants to make life easy. */
/*--------------------------------------------------------------------------------------*/
typedef double EventTime;
typedef EventTime EventTimeout;
typedef EventTime EventTimerInterval;
#define kEventDurationSecond ((EventTime)1.0)
#define kEventDurationMillisecond ((EventTime)(kEventDurationSecond/1000))
#define kEventDurationMicrosecond ((EventTime)(kEventDurationSecond/1000000))
#define kEventDurationNanosecond ((EventTime)(kEventDurationSecond/1000000000))
#define kEventDurationMinute ((EventTime)(kEventDurationSecond*60))
#define kEventDurationHour ((EventTime)(kEventDurationMinute*60))
#define kEventDurationDay ((EventTime)(kEventDurationHour*24))
#define kEventDurationNoWait ((EventTime)0.0)
#define kEventDurationForever ((EventTime)(-1.0))
/* Helpful doodads to convert to and from ticks and event times*/
#ifdef __cplusplus
inline EventTime TicksToEventTime( UInt32 t ) { return ( (t) / 60.0 ); }
inline UInt32 EventTimeToTicks( EventTime t ) { return (UInt32)( ((t) * 60) + 0.5 ); }
#else
#define TicksToEventTime( t ) ((EventTime)( (t) / 60.0 ))
#define EventTimeToTicks( t ) ((UInt32)( ((t) * 60) + 0.5 ))
#endif /* defined(__cplusplus) */
/*--------------------------------------------------------------------------------------*/
/* EventTypeSpec structure */
/* */
/* This structure is used in many routines to pass a list of event types to a function. */
/* You typically would declare a const array of these types to pass in. */
/*--------------------------------------------------------------------------------------*/
/*
* EventTypeSpec
*
* Discussion:
* This structure is used to specify an event. Typically, a static
* array of EventTypeSpecs are passed into functions such as
* InstallEventHandler, as well as routines such as
* FlushEventsMatchingListFromQueue.
*/
struct EventTypeSpec {
UInt32 eventClass;
UInt32 eventKind;
};
typedef struct EventTypeSpec EventTypeSpec;
/*A helpful macro for dealing with EventTypeSpecs */
#define GetEventTypeCount( t ) (sizeof( (t) ) / sizeof( EventTypeSpec ))
typedef OSType EventParamName;
typedef OSType EventParamType;
/*--------------------------------------------------------------------------------------*/
/* o EventLoop */
/*--------------------------------------------------------------------------------------*/
/*
* EventLoopRef
*
* Discussion:
* An EventLoopRef represents an 'event loop', which is the
* conceptual entity that you 'run' to fetch events from hardware
* and other sources and also fires timers that might be installed
* with InstallEventLoopTimer. The term 'run' is a bit of a
* misnomer, as the event loop's goal is to stay as blocked as
* possible to minimize CPU usage for the current application. The
* event loop is run implicitly thru APIs like ReceiveNextEvent,
* RunApplicationEventLoop, or even WaitNextEvent. It can also be
* run explicitly thru a call to RunCurrentEventLoop. Each
* preemptive thread can have an event loop. Cooperative threads
* share the main thread's event loop.
*/
typedef struct OpaqueEventLoopRef* EventLoopRef;
/*
* GetCurrentEventLoop()
*
* Discussion:
* Returns the current event loop for the current thread. If the
* current thread is a cooperative thread, the main event loop is
* returned.
*
* Result:
* An event loop reference.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventLoopRef )
GetCurrentEventLoop(void);
/*
* GetMainEventLoop()
*
* Discussion:
* Returns the event loop object for the main application thread.
*
* Result:
* An event loop reference.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventLoopRef )
GetMainEventLoop(void);
/*
* RunCurrentEventLoop()
*
* Discussion:
* This routine 'runs' the event loop, returning only if aborted or
* the timeout specified is reached. The event loop is mostly
* blocked while in this function, occasionally waking up to fire
* timers or pick up events. The typical use of this function is to
* cause the current thread to wait for some operation to complete,
* most likely on another thread of execution.
*
* Parameters:
*
* inTimeout:
* The time to wait until returning (can be kEventDurationForever).
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
RunCurrentEventLoop(EventTimeout inTimeout);
/*
* QuitEventLoop()
*
* Discussion:
* Causes a specific event loop to terminate. Usage of this is
* similar to WakeUpProcess, in that it causes the eventloop
* specified to return immediately (as opposed to timing out).
* Typically this call is used in conjunction with
* RunCurrentEventLoop.
*
* Parameters:
*
* inEventLoop:
* The event loop to terminate.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
QuitEventLoop(EventLoopRef inEventLoop);
/*
* GetCFRunLoopFromEventLoop()
*
* Discussion:
* Returns the corresponding CFRunLoopRef for the given EventLoop.
* This is not necessarily a one-to-one mapping, hence the need for
* this function. In Carbon, all cooperative threads use the same
* run loop under the covers, so using CFRunLoopGetCurrent might
* yield the wrong result. In general, you would only need to use
* this function if you wished to add your own sources to the run
* loop. If you don't know what I'm talking about, then you probably
* don't need to use this.
*
* Parameters:
*
* inEventLoop:
* The event loop to get the CFRunLoop for.
*
* Result:
* The CFRunLoopRef for inEventLoop.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.1 and later
* Mac OS X: in version 10.1 and later
*/
EXTERN_API_C( CFTypeRef )
GetCFRunLoopFromEventLoop(EventLoopRef inEventLoop);
/*--------------------------------------------------------------------------------------*/
/* o Low-level event fetching */
/*--------------------------------------------------------------------------------------*/
/*
* ReceiveNextEvent()
*
* Discussion:
* This routine tries to fetch the next event of a specified type.
* If no events in the event queue match, this routine will run the
* current event loop until an event that matches arrives, or the
* timeout expires. Except for timers firing, your application is
* blocked waiting for events to arrive when inside this function.
*
* Parameters:
*
* inNumTypes:
* The number of event types we are waiting for (0 if any event
* should cause this routine to return).
*
* inList:
* The list of event types we are waiting for (pass NULL if any
* event should cause this routine to return).
*
* inTimeout:
* The time to wait (passing kEventDurationForever is preferred).
*
* inPullEvent:
* Pass true for this parameter to actually remove the next
* matching event from the queue.
*
* outEvent:
* The next event that matches the list passed in. If inPullEvent
* is true, the event is owned by you, and you will need to
* release it when done.
*
* Result:
* A result indicating whether an event was received, the timeout
* expired, or the current event loop was quit.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
ReceiveNextEvent(
UInt32 inNumTypes,
const EventTypeSpec * inList,
EventTimeout inTimeout,
Boolean inPullEvent,
EventRef * outEvent);
/*--------------------------------------------------------------------------------------*/
/* o Core event lifetime APIs */
/*--------------------------------------------------------------------------------------*/
typedef UInt32 EventAttributes;
enum {
kEventAttributeNone = 0,
kEventAttributeUserEvent = (1 << 0)
};
/*
* [Mac]CreateEvent()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
#if TARGET_OS_MAC
#define MacCreateEvent CreateEvent
#endif
EXTERN_API( OSStatus )
MacCreateEvent(
CFAllocatorRef inAllocator, /* can be NULL */
UInt32 inClassID,
UInt32 kind,
EventTime when,
EventAttributes flags,
EventRef * outEvent);
/*
* CopyEvent()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventRef )
CopyEvent(EventRef inOther);
/*
* RetainEvent()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventRef )
RetainEvent(EventRef inEvent);
/*
* GetEventRetainCount()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( UInt32 )
GetEventRetainCount(EventRef inEvent);
/*
* ReleaseEvent()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( void )
ReleaseEvent(EventRef inEvent);
/*
* SetEventParameter()
*
* Discussion:
* Sets a piece of data for the given event.
*
* Parameters:
*
* inEvent:
* The event to set the data for.
*
* inName:
* The symbolic name of the parameter.
*
* inType:
* The symbolic type of the parameter.
*
* inSize:
* The size of the parameter data.
*
* inDataPtr:
* The pointer to the parameter data.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
SetEventParameter(
EventRef inEvent,
EventParamName inName,
EventParamType inType,
UInt32 inSize,
const void * inDataPtr);
/*
* GetEventParameter()
*
* Discussion:
* Gets a piece of data from the given event, if it exists.
*
* Parameters:
*
* inEvent:
* The event to get the parameter from.
*
* inName:
* The symbolic name of the parameter.
*
* inDesiredType:
* The desired type of the parameter. At present we do not support
* coercion, so this parameter must be the actual type of data
* stored in the event, or an error will be returned.
*
* outActualType:
* The actual type of the parameter, can be NULL if you are not
* interested in receiving this information.
*
* inBufferSize:
* The size of the output buffer specified by ioBuffer.
*
* outActualSize:
* The actual size of the data, or NULL if you don't want this
* information.
*
* outData:
* The pointer to the buffer which will receive the parameter data.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
GetEventParameter(
EventRef inEvent,
EventParamName inName,
EventParamType inDesiredType,
EventParamType * outActualType, /* can be NULL */
UInt32 inBufferSize,
UInt32 * outActualSize, /* can be NULL */
void * outData);
/*--------------------------------------------------------------------------------------*/
/* o Getters for 'base-class' event info */
/*--------------------------------------------------------------------------------------*/
/*
* GetEventClass()
*
* Discussion:
* Returns the class of the given event, such as mouse, keyboard,
* etc.
*
* Parameters:
*
* inEvent:
* The event in question.
*
* Result:
* The class ID of the event.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( UInt32 )
GetEventClass(EventRef inEvent);
/*
* GetEventKind()
*
* Discussion:
* Returns the kind of the given event (mousedown, etc.). Event
* kinds overlap between event classes, e.g. kEventMouseDown and
* kEventAppActivated have the same value (1). The combination of
* class and kind is what determines an event signature.
*
* Parameters:
*
* inEvent:
* The event in question.
*
* Result:
* The kind of the event.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( UInt32 )
GetEventKind(EventRef inEvent);
/*
* GetEventTime()
*
* Discussion:
* Returns the time the event specified occurred, specified in
* EventTime, which is a floating point number representing seconds
* since the last system startup.
*
* Parameters:
*
* inEvent:
* The event in question.
*
* Result:
* The time the event occurred.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventTime )
GetEventTime(EventRef inEvent);
/*--------------------------------------------------------------------------------------*/
/* o Setters for 'base-class' event info */
/*--------------------------------------------------------------------------------------*/
/*
* SetEventTime()
*
* Discussion:
* This routine allows you to set the time of a given event, if you
* so desire. In general, you would never use this routine, except
* for those special cases where you reuse an event from time to
* time instead of creating a new event each time.
*
* Parameters:
*
* inEvent:
* The event in question.
*
* inTime:
* The new time.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
SetEventTime(
EventRef inEvent,
EventTime inTime);
/*--------------------------------------------------------------------------------------*/
/* o Event Queue routines (posting, finding, flushing) */
/*--------------------------------------------------------------------------------------*/
typedef struct OpaqueEventQueueRef* EventQueueRef;
/*
* GetCurrentEventQueue()
*
* Discussion:
* Returns the current event queue for the current thread. If the
* current thread is a cooperative thread, the main event queue is
* returned.
*
* Result:
* An event queue reference.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventQueueRef )
GetCurrentEventQueue(void);
/*
* GetMainEventQueue()
*
* Discussion:
* Returns the event queue object for the main application thread.
*
* Result:
* An event queue reference.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventQueueRef )
GetMainEventQueue(void);
/*
* EventComparatorProcPtr
*
* Discussion:
* Type of a callback function used by queue searches.
*
* Parameters:
*
* inEvent:
* The event to compare.
*
* inCompareData:
* The data used to compare the event.
*
* Result:
* A boolean value indicating whether the event matches (true) or
* not (false).
*/
typedef CALLBACK_API( Boolean , EventComparatorProcPtr )(EventRef inEvent, void *inCompareData);
typedef STACK_UPP_TYPE(EventComparatorProcPtr) EventComparatorUPP;
/*
* NewEventComparatorUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( EventComparatorUPP )
NewEventComparatorUPP(EventComparatorProcPtr userRoutine);
#if !OPAQUE_UPP_TYPES
enum { uppEventComparatorProcInfo = 0x000003D0 }; /* pascal 1_byte Func(4_bytes, 4_bytes) */
#ifdef __cplusplus
inline DEFINE_API_C(EventComparatorUPP) NewEventComparatorUPP(EventComparatorProcPtr userRoutine) { return (EventComparatorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventComparatorProcInfo, GetCurrentArchitecture()); }
#else
#define NewEventComparatorUPP(userRoutine) (EventComparatorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventComparatorProcInfo, GetCurrentArchitecture())
#endif
#endif
/*
* DisposeEventComparatorUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void )
DisposeEventComparatorUPP(EventComparatorUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(void) DisposeEventComparatorUPP(EventComparatorUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
#else
#define DisposeEventComparatorUPP(userUPP) DisposeRoutineDescriptor(userUPP)
#endif
#endif
/*
* InvokeEventComparatorUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( Boolean )
InvokeEventComparatorUPP(
EventRef inEvent,
void * inCompareData,
EventComparatorUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(Boolean) InvokeEventComparatorUPP(EventRef inEvent, void * inCompareData, EventComparatorUPP userUPP) { return (Boolean)CALL_TWO_PARAMETER_UPP(userUPP, uppEventComparatorProcInfo, inEvent, inCompareData); }
#else
#define InvokeEventComparatorUPP(inEvent, inCompareData, userUPP) (Boolean)CALL_TWO_PARAMETER_UPP((userUPP), uppEventComparatorProcInfo, (inEvent), (inCompareData))
#endif
#endif
#if CALL_NOT_IN_CARBON || OLDROUTINENAMES
/* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
#define NewEventComparatorProc(userRoutine) NewEventComparatorUPP(userRoutine)
#define CallEventComparatorProc(userRoutine, inEvent, inCompareData) InvokeEventComparatorUPP(inEvent, inCompareData, userRoutine)
#endif /* CALL_NOT_IN_CARBON */
/*
* PostEventToQueue()
*
* Discussion:
* Posts an event to the queue specified. This automatically wakes
* up the event loop of the thread the queue belongs to. After
* posting the event, you should release the event. The event queue
* retains it.
*
* Parameters:
*
* inQueue:
* The event queue to post the event onto.
*
* inEvent:
* The event to post.
*
* inPriority:
* The priority of the event.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
PostEventToQueue(
EventQueueRef inQueue,
EventRef inEvent,
EventPriority inPriority);
/*
* FlushEventsMatchingListFromQueue()
*
* Discussion:
* Flushes events matching a specified list of classes and kinds
* from an event queue.
*
* Parameters:
*
* inQueue:
* The event queue to flush events from.
*
* inNumTypes:
* The number of event kinds to flush.
*
* inList:
* The list of event classes and kinds to flush from the queue.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
FlushEventsMatchingListFromQueue(
EventQueueRef inQueue,
UInt32 inNumTypes,
const EventTypeSpec * inList);
/*
* FlushSpecificEventsFromQueue()
*
* Discussion:
* Flushes events that match a comparator function.
*
* Parameters:
*
* inQueue:
* The event queue to flush events from.
*
* inComparator:
* The comparison function to invoke for each event in the queue.
*
* inCompareData:
* The data you wish to pass to your comparison function.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
FlushSpecificEventsFromQueue(
EventQueueRef inQueue,
EventComparatorUPP inComparator,
void * inCompareData);
/*
* FlushEventQueue()
*
* Discussion:
* Flushes all events from an event queue.
*
* Parameters:
*
* inQueue:
* The event queue to flush.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
FlushEventQueue(EventQueueRef inQueue);
/*
* FindSpecificEventInQueue()
*
* Discussion:
* Returns the first event that matches a comparator function, or
* NULL if no events match.
*
* Parameters:
*
* inQueue:
* The event queue to search.
*
* inComparator:
* The comparison function to invoke for each event in the queue.
*
* inCompareData:
* The data you wish to pass to your comparison function.
*
* Result:
* An event reference. The event is still in the queue when
* FindSpecificEventInQueue returns; you can remove it from the
* queue with RemoveEventFromQueue. The returned event does not need
* to be released by the caller.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventRef )
FindSpecificEventInQueue(
EventQueueRef inQueue,
EventComparatorUPP inComparator,
void * inCompareData);
/*
* GetNumEventsInQueue()
*
* Discussion:
* Returns the number of events in an event queue.
*
* Parameters:
*
* inQueue:
* The event queue to query.
*
* Result:
* The number of items in the queue.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( UInt32 )
GetNumEventsInQueue(EventQueueRef inQueue);
/*
* RemoveEventFromQueue()
*
* Discussion:
* Removes the given event from the queue which it was posted. When
* you call this function, the event ownership is transferred to
* you, the caller, at no charge. You must release the event when
* you are through with it.
*
* Parameters:
*
* inQueue:
* The queue to remove the event from.
*
* inEvent:
* The event to remove.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
RemoveEventFromQueue(
EventQueueRef inQueue,
EventRef inEvent);
/*
* IsEventInQueue()
*
* Discussion:
* Returns true if the specified event is posted to a queue.
*
* Parameters:
*
* inQueue:
* The queue to check.
*
* inEvent:
* The event in question.
*
* Result:
* A boolean value.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( Boolean )
IsEventInQueue(
EventQueueRef inQueue,
EventRef inEvent);
/*--------------------------------------------------------------------------------------*/
/* Queue-synchronized event state */
/*--------------------------------------------------------------------------------------*/
/*
* GetCurrentEvent()
*
* Summary:
* Returns the user input event currently being handled.
*
* Discussion:
* When an event with kEventAttributeUserEvent is dispatched by the
* event dispatcher target, it is recorded internally by the Event
* Manager. At any time during the handling of that event,
* GetCurrentEvent may be used to retrieve the original EventRef.
*
* Result:
* The user input (mouse or keyboard) event currently being handled.
* May be NULL if no event is currently being handled, or if the
* current event was not a user input event. The returned event is
* not retained, and its lifetime should be considered to be no
* longer than the current function; if you need to keep the event
* alive past that time, you should retain it.
*
* 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( EventRef )
GetCurrentEvent(void);
/*
* GetCurrentEventButtonState()
*
* Summary:
* Returns the current queue-synchronized mouse button state on the
* primary input device.
*
* Discussion:
* At any point in the handling of user input, there are two
* different mouse button states: the queue-synchronized state and
* the hardware state. The hardware state reflects the actual
* current state of the mouse attached to the user's machine. The
* queue-synchronized state reflects the state according to the
* events that have been processed at that point by the application.
* These two states may be different if there are unprocessed events
* in the event queue, or if events are being artificially
* introduced into the event queue from an outside source.
* GetCurrentEventButtonState returns the queue-synchronized button
* state. It is generally better to use this API than to use the
* Button function or the GetCurrentButtonState function (which
* return the hardware state). This gives a more consistent user
* experience when the user input queue is being remoted controlled
* or manipulated via non-hardware event sources such as speech or
* AppleEvents; using GetCurrentEventButtonState is also much faster
* than using Button or GetCurrentButtonState.
*
* Note that GetCurrentEventButtonState only returns a valid button
* state if your application is the active application. If your
* application is not active, then user input events are not flowing
* through the event dispatcher and the queue-synchronized state is
* not updated.
*
* Result:
* The queue-synchronized state of the mouse buttons. Bit zero
* indicates the state of the primary button, bit one the state of
* the secondary button, and so on.
*
* 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 )
GetCurrentEventButtonState(void);
/*
* GetCurrentEventKeyModifiers()
*
* Summary:
* Returns the current queue-synchronized keyboard modifier state.
*
* Discussion:
* At any point in the handling of user input, there are two
* different keyboard modifier states: the queue-synchronized state
* and the hardware state. The hardware state reflects the actual
* current state of the keyboard attached to the user's machine. The
* queue-synchronized state reflects the state according to the
* events that have been processed at that point by the application.
* These two states may be different if there are unprocessed events
* in the event queue, or if events are being artificially
* introduced into the event queue from an outside source.
* GetCurrentEventKeyModifiers returns the queue-synchronized
* modifier state. It is generally better to use this API than to
* use the GetCurrentKeyModifiers API (which returns the hardware
* state). This gives a more consistent user experience when the
* user input queue is being remoted controlled or manipulated via
* non-hardware event sources such as speech or AppleEvents; using
* GetCurrentEventKeyModifiers is also much faster than using
* EventAvail(0, &eventRecord) or GetCurrentKeyModifiers.
*
* Note that GetCurrentEventKeyModifiers only returns a valid
* modifier state if your application is the active application. If
* your application is not active, then user input events are not
* flowing through the event dispatcher and the queue-synchronized
* state is not updated.
*
* Result:
* The queue-synchronized state of the keyboard modifiers. The
* format of the return value is the same as the modifiers field of
* an EventRecord (but only includes keyboard modifiers and not the
* other modifier flags included in an EventRecord).
*
* 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 )
GetCurrentEventKeyModifiers(void);
/*--------------------------------------------------------------------------------------*/
/* Multiple-button support */
/*--------------------------------------------------------------------------------------*/
/*
* GetCurrentButtonState()
*
* Summary:
* Returns the current hardware mouse button state on the primary
* input device.
*
* Discussion:
* In most cases, you should not use GetCurrentButtonState, but
* should use the GetCurrentEventButtonState function instead.
* GetCurrentEventButtonState is much faster than
* GetCurrentButtonState because it returns the locally cached
* button state; GetCurrentButtonState must get the mouse button
* state from the window server, which is slower. Using
* GetCurrentButtonState also can prevent your application from
* being operated by remote posting of events, since the hardware
* input device is not actually changing state in that case. Most
* commonly, you might need to use GetCurrentButtonState when your
* application is not the active application (as determined by the
* Process Manager function GetFrontProcess). In that case, the
* cached button state returned by GetCurrentEventButtonState is not
* valid because mouse button events are not flowing to your
* application, and you must use GetCurrentButtonState to determine
* the current hardware state.
*
* Result:
* The state of the mouse buttons on the mouse hardware. Bit zero
* indicates the state of the primary button, bit one the state of
* the secondary button, and so on.
*
* 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 )
GetCurrentButtonState(void);
/*--------------------------------------------------------------------------------------*/
/* o Helpful utilities */
/*--------------------------------------------------------------------------------------*/
/*
* GetCurrentEventTime()
*
* Discussion:
* Returns the current time since last system startup in seconds.
*
* Result:
* EventTime.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( EventTime )
GetCurrentEventTime(void);
/*--------------------------------------------------------------------------------------*/
/* o Timers */
/*--------------------------------------------------------------------------------------*/
/*
* EventLoopTimerRef
*
* Discussion:
* An EventLoopTimerRef represents what we term a 'timer'. A timer
* is a function that is called either once or at regular intervals.
* It executes at task level and should not be confused with Time
* Manager Tasks or any other interrupt-level callback. This means
* you can call Toolbox routines, allocate memory and draw. When a
* timer 'fires', it calls a callback that you specify when the
* timer is installed. Timers in general have two uses - as a
* timeout mechanism and as a periodic task. An everyday example of
* using a timer for a timeout might be a light that goes out if no
* motion is detected in a room for 5 minutes. For this, you might
* install a timer which will fire in 5 minutes. If motion is
* detected, you would reset the timer fire time and let the clock
* start over. If no motion is detected for the full 5 minutes, the
* timer will fire and you could power off the light. A periodic
* timer is one that fires at regular intervals (say every second or
* so). You might use such a timer to blink the insertion point in
* your editor, etc. One advantage of timers is that you can install
* the timer right from the code that wants the time. For example,
* the standard Toolbox Edit Text control can install a timer to
* blink the cursor when it's active, meaning that IdleControls is a
* no-op for that control and doesn't need to be called. When the
* control is inactive, it removes its timer and doesn't waste CPU
* time in that state. NOTE: Currently, if you do decide to draw
* when your timer is called, be sure to save and restore the
* current port so that calling your timer doesn't inadvertently
* change the port out from under someone.
*/
typedef struct __EventLoopTimer* EventLoopTimerRef;
/*
* EventLoopTimerProcPtr
*
* Discussion:
* Called when a timer fires.
*
* Parameters:
*
* inTimer:
* The timer that fired.
*
* inUserData:
* The data passed into InstallEventLoopTimer.
*/
typedef CALLBACK_API( void , EventLoopTimerProcPtr )(EventLoopTimerRef inTimer, void *inUserData);
/*
* Discussion:
* Event Loop Idle Timer Messages
*/
enum {
/*
* The user has gone idle (not touched an input device) for the
* duration specified in your idle timer. This is the first message
* you will receive. Start your engines!
*/
kEventLoopIdleTimerStarted = 1,
/*
* If you specified an interval on your idle timer, your idle timer
* proc will be called with this message, letting you know it is
* merely firing at the interval specified. If you did not specify an
* interval, this message is not sent.
*/
kEventLoopIdleTimerIdling = 2,
/*
* The user is back! Stop everything! This is your cue to stop any
* processing if you need to.
*/
kEventLoopIdleTimerStopped = 3
};
typedef UInt16 EventLoopIdleTimerMessage;
/*
* EventLoopIdleTimerProcPtr
*
* Discussion:
* Called when an idle timer fires.
*
* Parameters:
*
* inTimer:
* The timer that fired.
*
* inState:
* The current state of the timer.
*
* inUserData:
* The data passed into InstallEventLoopTimer.
*/
typedef CALLBACK_API( void , EventLoopIdleTimerProcPtr )(EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void *inUserData);
typedef STACK_UPP_TYPE(EventLoopTimerProcPtr) EventLoopTimerUPP;
typedef STACK_UPP_TYPE(EventLoopIdleTimerProcPtr) EventLoopIdleTimerUPP;
/*
* NewEventLoopTimerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( EventLoopTimerUPP )
NewEventLoopTimerUPP(EventLoopTimerProcPtr userRoutine);
#if !OPAQUE_UPP_TYPES
enum { uppEventLoopTimerProcInfo = 0x000003C0 }; /* pascal no_return_value Func(4_bytes, 4_bytes) */
#ifdef __cplusplus
inline DEFINE_API_C(EventLoopTimerUPP) NewEventLoopTimerUPP(EventLoopTimerProcPtr userRoutine) { return (EventLoopTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopTimerProcInfo, GetCurrentArchitecture()); }
#else
#define NewEventLoopTimerUPP(userRoutine) (EventLoopTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopTimerProcInfo, GetCurrentArchitecture())
#endif
#endif
#if CALL_NOT_IN_CARBON
/*
* NewEventLoopIdleTimerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: not available
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( EventLoopIdleTimerUPP )
NewEventLoopIdleTimerUPP(EventLoopIdleTimerProcPtr userRoutine);
#if !OPAQUE_UPP_TYPES
enum { uppEventLoopIdleTimerProcInfo = 0x00000EC0 }; /* pascal no_return_value Func(4_bytes, 2_bytes, 4_bytes) */
#ifdef __cplusplus
inline DEFINE_API_C(EventLoopIdleTimerUPP) NewEventLoopIdleTimerUPP(EventLoopIdleTimerProcPtr userRoutine) { return (EventLoopIdleTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopIdleTimerProcInfo, GetCurrentArchitecture()); }
#else
#define NewEventLoopIdleTimerUPP(userRoutine) (EventLoopIdleTimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventLoopIdleTimerProcInfo, GetCurrentArchitecture())
#endif
#endif
#endif /* CALL_NOT_IN_CARBON */
/*
* DisposeEventLoopTimerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void )
DisposeEventLoopTimerUPP(EventLoopTimerUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(void) DisposeEventLoopTimerUPP(EventLoopTimerUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
#else
#define DisposeEventLoopTimerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
#endif
#endif
#if CALL_NOT_IN_CARBON
/*
* DisposeEventLoopIdleTimerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: not available
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void )
DisposeEventLoopIdleTimerUPP(EventLoopIdleTimerUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(void) DisposeEventLoopIdleTimerUPP(EventLoopIdleTimerUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
#else
#define DisposeEventLoopIdleTimerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
#endif
#endif
#endif /* CALL_NOT_IN_CARBON */
/*
* InvokeEventLoopTimerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void )
InvokeEventLoopTimerUPP(
EventLoopTimerRef inTimer,
void * inUserData,
EventLoopTimerUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(void) InvokeEventLoopTimerUPP(EventLoopTimerRef inTimer, void * inUserData, EventLoopTimerUPP userUPP) { CALL_TWO_PARAMETER_UPP(userUPP, uppEventLoopTimerProcInfo, inTimer, inUserData); }
#else
#define InvokeEventLoopTimerUPP(inTimer, inUserData, userUPP) CALL_TWO_PARAMETER_UPP((userUPP), uppEventLoopTimerProcInfo, (inTimer), (inUserData))
#endif
#endif
#if CALL_NOT_IN_CARBON
/*
* InvokeEventLoopIdleTimerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: not available
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void )
InvokeEventLoopIdleTimerUPP(
EventLoopTimerRef inTimer,
EventLoopIdleTimerMessage inState,
void * inUserData,
EventLoopIdleTimerUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(void) InvokeEventLoopIdleTimerUPP(EventLoopTimerRef inTimer, EventLoopIdleTimerMessage inState, void * inUserData, EventLoopIdleTimerUPP userUPP) { CALL_THREE_PARAMETER_UPP(userUPP, uppEventLoopIdleTimerProcInfo, inTimer, inState, inUserData); }
#else
#define InvokeEventLoopIdleTimerUPP(inTimer, inState, inUserData, userUPP) CALL_THREE_PARAMETER_UPP((userUPP), uppEventLoopIdleTimerProcInfo, (inTimer), (inState), (inUserData))
#endif
#endif
#endif /* CALL_NOT_IN_CARBON */
#if CALL_NOT_IN_CARBON || OLDROUTINENAMES
/* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
#define NewEventLoopTimerProc(userRoutine) NewEventLoopTimerUPP(userRoutine)
#define NewEventLoopIdleTimerProc(userRoutine) NewEventLoopIdleTimerUPP(userRoutine)
#define CallEventLoopTimerProc(userRoutine, inTimer, inUserData) InvokeEventLoopTimerUPP(inTimer, inUserData, userRoutine)
#define CallEventLoopIdleTimerProc(userRoutine, inTimer, inState, inUserData) InvokeEventLoopIdleTimerUPP(inTimer, inState, inUserData, userRoutine)
#endif /* CALL_NOT_IN_CARBON */
/*
* InstallEventLoopTimer()
*
* Discussion:
* Installs a timer onto the event loop specified. The timer can
* either fire once or repeatedly at a specified interval depending
* on the parameters passed to this function.
*
* Parameters:
*
* inEventLoop:
* The event loop to add the timer.
*
* inFireDelay:
* The delay before first firing this timer (can be 0, to request
* that the timer be fired as soon as control returns to your
* event loop). In Mac OS X and CarbonLib 1.5 and later, you may
* pass kEventDurationForever to stop the timer from firing at all
* until SetEventLoopTimerNextFireTime is used to start it; in
* earlier CarbonLibs, to achieve the same effect, just pass zero
* and then immediately call SetEventLoopTimerNextFireTime( timer,
* kEventDurationForever ) before returning control to your event
* loop.
*
* inInterval:
* The timer interval (pass 0 for a one-shot timer, which executes
* once but does not repeat). In Mac OS X and CarbonLib 1.5 and
* later, you may also pass kEventDurationForever to create a
* one-shot timer.
*
* inTimerProc:
* The routine to call when the timer fires.
*
* inTimerData:
* Data to pass to the timer proc when called.
*
* outTimer:
* A reference to the newly installed timer.
*
* Result:
* An operating system status code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
InstallEventLoopTimer(
EventLoopRef inEventLoop,
EventTimerInterval inFireDelay,
EventTimerInterval inInterval,
EventLoopTimerUPP inTimerProc,
void * inTimerData,
EventLoopTimerRef * outTimer);
/*
* InstallEventLoopIdleTimer()
*
* Discussion:
* Installs a timer onto the event loop specified. Idle timers are
* only called when there is no user activity occuring in the
* application. This means that the user is not actively
* clicking/typing, and is also not in the middle of tracking a
* control, menu, or window. TrackMouseLocation actually disables
* all idle timers automatically for you.
*
* Parameters:
*
* inEventLoop:
* The event loop to add the timer.
*
* inDelay:
* The delay before firing this timer after a user input event has
* come in. For example, if you want to start your timer 2 seconds
* after the user stops typing, etc. you would pass 2.0 into this
* parameter. Each time the user types a key (or whatever), this
* timer is reset. If we are considered to be idle when an idle
* timer is installed, the first time it fires will be inDelay
* seconds from the time it is installed. So if you installed it
* in the middle of control tracking, say, it wouldn't fire until
* the user stopped tracking. But if you installed it at app
* startup and the user hasn't typed/clicked, it would fire in
* inDelay seconds.
*
* inInterval:
* The timer interval (pass 0 for a one-shot timer, which executes
* once but does not repeat). You may also pass
* kEventDurationForever to create a one-shot timer.
*
* inTimerProc:
* The routine to call when the timer fires.
*
* inTimerData:
* Data to pass to the timer proc when called.
*
* outTimer:
* A reference to the newly installed timer.
*
* Result:
* An operating system status code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
InstallEventLoopIdleTimer(
EventLoopRef inEventLoop,
EventTimerInterval inDelay,
EventTimerInterval inInterval,
EventLoopIdleTimerUPP inTimerProc,
void * inTimerData,
EventLoopTimerRef * outTimer);
/* GOING AWAY!!!! DO NOT CALL THIS API!!!!! USE INSTALLEVENTLOOPIDLETIMER ABOVE!!!! */
/*
* InstallIdleTimer()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
InstallIdleTimer(
EventLoopRef inEventLoop,
EventTimerInterval inDelay,
EventTimerInterval inInterval,
EventLoopTimerUPP inTimerProc,
void * inTimerData,
EventLoopTimerRef * outTimer);
/*
* RemoveEventLoopTimer()
*
* Discussion:
* Removes a timer that was previously installed by a call to
* InstallEventLoopTimer. You call this function when you are done
* using a timer.
*
* Parameters:
*
* inTimer:
* The timer to remove.
*
* Result:
* An operating system status code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
RemoveEventLoopTimer(EventLoopTimerRef inTimer);
/*
* SetEventLoopTimerNextFireTime()
*
* Discussion:
* This routine is used to 'reset' a timer. It controls the next
* time the timer fires. This will override any interval you might
* have set. For example, if you have a timer that fires every
* second, and you call this function setting the next time to five
* seconds from now, the timer will sleep for five seconds, then
* fire. It will then resume its one-second interval after that. It
* is as if you removed the timer and reinstalled it with a new
* first-fire delay.
*
* Parameters:
*
* inTimer:
* The timer to adjust
*
* inNextFire:
* The interval from the current time to wait until firing the
* timer again. You may pass kEventDurationForever to stop the
* timer from firing at all.
*
* Result:
* An operating system status code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
SetEventLoopTimerNextFireTime(
EventLoopTimerRef inTimer,
EventTimerInterval inNextFire);
/*======================================================================================*/
/* EVENT HANDLERS */
/*======================================================================================*/
typedef struct OpaqueEventHandlerRef* EventHandlerRef;
typedef struct OpaqueEventHandlerCallRef* EventHandlerCallRef;
/*--------------------------------------------------------------------------------------*/
/* o EventHandler specification */
/*--------------------------------------------------------------------------------------*/
/*
* EventHandlerProcPtr
*
* Discussion:
* Callback for receiving events sent to a target this callback is
* installed on.
*
* Parameters:
*
* inHandlerCallRef:
* A reference to the current handler call chain. This is sent to
* your handler so that you can call CallNextEventHandler if you
* need to.
*
* inEvent:
* The Event.
*
* inUserData:
* The app-specified data you passed in a call to
* InstallEventHandler.
*
* Result:
* An operating system result code. Returning noErr indicates you
* handled the event. Returning eventNotHandledErr indicates you did
* not handle the event and perhaps the toolbox should take other
* action.
*/
typedef CALLBACK_API( OSStatus , EventHandlerProcPtr )(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
typedef STACK_UPP_TYPE(EventHandlerProcPtr) EventHandlerUPP;
/*
* NewEventHandlerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( EventHandlerUPP )
NewEventHandlerUPP(EventHandlerProcPtr userRoutine);
#if !OPAQUE_UPP_TYPES
enum { uppEventHandlerProcInfo = 0x00000FF0 }; /* pascal 4_bytes Func(4_bytes, 4_bytes, 4_bytes) */
#ifdef __cplusplus
inline DEFINE_API_C(EventHandlerUPP) NewEventHandlerUPP(EventHandlerProcPtr userRoutine) { return (EventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventHandlerProcInfo, GetCurrentArchitecture()); }
#else
#define NewEventHandlerUPP(userRoutine) (EventHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppEventHandlerProcInfo, GetCurrentArchitecture())
#endif
#endif
/*
* DisposeEventHandlerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( void )
DisposeEventHandlerUPP(EventHandlerUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(void) DisposeEventHandlerUPP(EventHandlerUPP userUPP) { DisposeRoutineDescriptor((UniversalProcPtr)userUPP); }
#else
#define DisposeEventHandlerUPP(userUPP) DisposeRoutineDescriptor(userUPP)
#endif
#endif
/*
* InvokeEventHandlerUPP()
*
* Availability:
* Non-Carbon CFM: available as macro/inline
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API_C( OSStatus )
InvokeEventHandlerUPP(
EventHandlerCallRef inHandlerCallRef,
EventRef inEvent,
void * inUserData,
EventHandlerUPP userUPP);
#if !OPAQUE_UPP_TYPES
#ifdef __cplusplus
inline DEFINE_API_C(OSStatus) InvokeEventHandlerUPP(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData, EventHandlerUPP userUPP) { return (OSStatus)CALL_THREE_PARAMETER_UPP(userUPP, uppEventHandlerProcInfo, inHandlerCallRef, inEvent, inUserData); }
#else
#define InvokeEventHandlerUPP(inHandlerCallRef, inEvent, inUserData, userUPP) (OSStatus)CALL_THREE_PARAMETER_UPP((userUPP), uppEventHandlerProcInfo, (inHandlerCallRef), (inEvent), (inUserData))
#endif
#endif
#if CALL_NOT_IN_CARBON || OLDROUTINENAMES
/* support for pre-Carbon UPP routines: New...Proc and Call...Proc */
#define NewEventHandlerProc(userRoutine) NewEventHandlerUPP(userRoutine)
#define CallEventHandlerProc(userRoutine, inHandlerCallRef, inEvent, inUserData) InvokeEventHandlerUPP(inHandlerCallRef, inEvent, inUserData, userRoutine)
#endif /* CALL_NOT_IN_CARBON */
typedef struct OpaqueEventTargetRef* EventTargetRef;
/*--------------------------------------------------------------------------------------*/
/* o Installing Event Handlers */
/* */
/* Use these routines to install event handlers for a specific toolbox object. You may */
/* pass zero for inNumTypes and NULL for inList if you need to be in a situation where */
/* you know you will be receiving events, but not exactly which ones at the time you */
/* are installing the handler. Later, your application can call the Add/Remove routines */
/* listed below this section. */
/* */
/* You can only install a specific handler once. The combination of inHandler and */
/* inUserData is considered the 'signature' of a handler. Any attempt to install a new */
/* handler with the same proc and user data as an already-installed handler will result */
/* in eventHandlerAlreadyInstalledErr. Installing the same proc and user data on a */
/* different object is legal. */
/* */
/* Upon successful completion of this routine, you are returned an EventHandlerRef, */
/* which you can use in various other calls, and is passed to your event handler. You */
/* use it to extract information about the handler, such as the target (window, etc.) */
/* if you have the same handler installed for different objects and need to perform */
/* actions on the current target (say, call a window manager function). */
/*--------------------------------------------------------------------------------------*/
/*
* InstallEventHandler()
*
* Discussion:
* Installs an event handler on a specified target. Your handler
* proc will be called with the events you registered with when an
* event of the corresponding type and class are send to the target
* you are installing your handler on.
*
* Parameters:
*
* inTarget:
* The target to register your handler with.
*
* inHandler:
* A pointer to your handler function.
*
* inNumTypes:
* The number of events you are registering for.
*
* inList:
* A pointer to an array of EventTypeSpec entries representing the
* events you are interested in.
*
* inUserData:
* The value passed in this parameter is passed on to your event
* handler proc when it is called.
*
* outRef:
* Receives an EventHandlerRef, which you can use later to remove
* the handler. You can pass null if you don't want the reference
* - when the target is disposed, the handler will be disposed as
* well.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
InstallEventHandler(
EventTargetRef inTarget,
EventHandlerUPP inHandler,
UInt32 inNumTypes,
const EventTypeSpec * inList,
void * inUserData,
EventHandlerRef * outRef); /* can be NULL */
/*
* InstallStandardEventHandler()
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
InstallStandardEventHandler(EventTargetRef inTarget);
/*
* RemoveEventHandler()
*
* Discussion:
* Removes an event handler from the target it was bound to.
*
* Parameters:
*
* inHandlerRef:
* The handler ref to remove (returned in a call to
* InstallEventHandler). After you call this function, the handler
* ref is considered to be invalid and can no longer be used.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
RemoveEventHandler(EventHandlerRef inHandlerRef);
/*--------------------------------------------------------------------------------------*/
/* o Adjusting set of event types after a handler is created */
/* */
/* After installing a handler with the routine above, you can adjust the event type */
/* list telling the toolbox what events to send to that handler by calling the two */
/* routines below. If you add an event type twice for the same handler, your handler */
/* will only be called once, but it will take two RemoveEventType calls to stop your */
/* handler from being called with that event type. In other words, the install count */
/* for each event type is maintained by the toolbox. This might allow you, for example */
/* to have subclasses of a window object register for types without caring if the base */
/* class has already registered for that type. When the subclass removes its types, it */
/* can successfully do so without affecting the base class's reception of its event */
/* types, yielding eternal bliss. */
/*--------------------------------------------------------------------------------------*/
/*
* AddEventTypesToHandler()
*
* Discussion:
* Adds additional events to an event handler that has already been
* installed.
*
* Parameters:
*
* inHandlerRef:
* The event handler to add the additional events to.
*
* inNumTypes:
* The number of events to add.
*
* inList:
* A pointer to an array of EventTypeSpec entries.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
AddEventTypesToHandler(
EventHandlerRef inHandlerRef,
UInt32 inNumTypes,
const EventTypeSpec * inList);
/*
* RemoveEventTypesFromHandler()
*
* Discussion:
* Removes events from an event handler that has already been
* installed.
*
* Parameters:
*
* inHandlerRef:
* The event handler to remove the events from.
*
* inNumTypes:
* The number of events to remove.
*
* inList:
* A pointer to an array of EventTypeSpec entries.
*
* Result:
* An operating system status code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
RemoveEventTypesFromHandler(
EventHandlerRef inHandlerRef,
UInt32 inNumTypes,
const EventTypeSpec * inList);
/*--------------------------------------------------------------------------------------*/
/* o Explicit Propogation */
/* */
/* CallNextEventHandler can be used to call thru to all handlers below the current */
/* handler being called. You pass the EventHandlerCallRef passed to your EventHandler */
/* into this call so that we know how to properly forward the event. The result of */
/* this function should normally be the result of your own handler that you called */
/* this API from. The typical use of this routine would be to allow the toolbox to do */
/* its standard processing and then follow up with some type of embellishment. */
/*--------------------------------------------------------------------------------------*/
/*
* CallNextEventHandler()
*
* Discussion:
* Calls thru to the event handlers below you in the event handler
* stack of the target to which your handler is bound. You might use
* this to call thru to the default toolbox handling in order to
* post-process the event. You can only call this routine from
* within an event handler.
*
* Parameters:
*
* inCallRef:
* The event handler call ref passed into your event handler.
*
* inEvent:
* The event to pass thru.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
CallNextEventHandler(
EventHandlerCallRef inCallRef,
EventRef inEvent);
/*--------------------------------------------------------------------------------------*/
/* o Sending Events */
/*--------------------------------------------------------------------------------------*/
/*
* Discussion:
* EventTarget Send Options
*/
enum {
/*
* The event should be sent to the target given only, and should not
* propagate to any other target. CallNextEventHandler will do
* nothing in a handler which has received an event sent in this
* manner.
*/
kEventTargetDontPropagate = (1 << 0),
/*
* The event is a notification-style event, and should be received by
* all handlers. The result is usually meaningless when sent in this
* manner, though we do maintain the strongest result code while the
* event falls through each handler. This means that if the first
* handler to receive the event returned noErr, and the next returned
* eventNotHandledErr, the result returned would actually be noErr.
* No handler can stop this event from propagating, i.e. the result
* code does not alter event flow.
*/
kEventTargetSendToAllHandlers = (1 << 1)
};
/*
* SendEventToEventTarget()
*
* Discussion:
* Sends an event to the specified event target.
*
* Parameters:
*
* inEvent:
* The event to send.
*
* inTarget:
* The target to send it to.
*
* Result:
* An operating system result code.
*
* Availability:
* Non-Carbon CFM: not available
* CarbonLib: in CarbonLib 1.1 and later
* Mac OS X: in version 10.0 and later
*/
EXTERN_API( OSStatus )
SendEventToEventTarget(
EventRef inEvent,
EventTargetRef inTarget);
/*
* SendEventToEventTargetWithOptions()
*
* Discussion:
* Sends an event to the specified event target, optionally
* controlling how the event propagates. See the discussion of the
* event send options above for more detail.
*
* Parameters:
*
* inEvent:
* The event to send.
*
* inTarget:
* The target to send it to.
*
* inOptions:
* The options to modify the send behavior. Passing zero for this
* makes it behave just like SendEventToEventTarget.
*
* 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 )
SendEventToEventTargetWithOptions(
EventRef inEvent,
EventTargetRef inTarget,
OptionBits inOptions);
#if PRAGMA_STRUCT_ALIGN
#pragma options align=reset
#elif PRAGMA_STRUCT_PACKPUSH
#pragma pack(pop)
#elif PRAGMA_STRUCT_PACK
#pragma pack()
#endif
#ifdef PRAGMA_IMPORT_OFF
#pragma import off
#elif PRAGMA_IMPORT
#pragma import reset
#endif
#ifdef __cplusplus
}
#endif
#endif /* __CARBONEVENTSCORE__ */
|