Font selection now generates and saves a TGA sample.
1 /*******************************
2 Mac support for HID Test GUI
7 Some of this code is from Apple Documentation, most notably
8 http://developer.apple.com/legacy/mac/library/documentation/AppleScript/Conceptual/AppleEvents/AppleEvents.pdf
9 *******************************/
11 #include <Carbon/Carbon.h>
15 extern FXMainWindow *g_main_window;
17 static pascal OSErr HandleQuitMessage(const AppleEvent *theAppleEvent, AppleEvent
18 *reply, long handlerRefcon)
21 FXApp::instance()->exit();
25 static pascal OSErr HandleReopenMessage(const AppleEvent *theAppleEvent, AppleEvent
26 *reply, long handlerRefcon)
29 g_main_window->show();
33 static pascal OSErr HandleWildCardMessage(const AppleEvent *theAppleEvent, AppleEvent
34 *reply, long handlerRefcon)
40 OSStatus AEHandler(EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon)
42 Boolean release = false;
43 EventRecord eventRecord;
44 OSErr ignoreErrForThisSample;
46 // Events of type kEventAppleEvent must be removed from the queue
47 // before being passed to AEProcessAppleEvent.
48 if (IsEventInQueue(GetMainEventQueue(), inEvent))
50 // RemoveEventFromQueue will release the event, which will
51 // destroy it if we don't retain it first.
54 RemoveEventFromQueue(GetMainEventQueue(), inEvent);
56 // Convert the event ref to the type AEProcessAppleEvent expects.
57 ConvertEventRefToEventRecord(inEvent, &eventRecord);
58 ignoreErrForThisSample = AEProcessAppleEvent(&eventRecord);
60 ReleaseEvent(inEvent);
61 // This Carbon event has been handled, even if no AppleEvent handlers
62 // were installed for the Apple event.
66 static void HandleEvent(EventRecord *event)
68 //printf("What: %d message %x\n", event->what, event->message);
69 if (event->what == osEvt) {
70 if (((event->message >> 24) & 0xff) == suspendResumeMessage) {
71 if (event->message & resumeFlag) {
72 g_main_window->show();
81 //HandleMouseDown(event);
85 //HandleKeyPress(event);
88 puts("Calling ProcessAppleEvent\n");
89 AEProcessAppleEvent(event);
96 init_apple_message_system()
99 static const EventTypeSpec appleEvents[] =
101 { kEventClassAppleEvent, kEventAppleEvent }
104 /* Install the handler for Apple Events */
105 InstallApplicationEventHandler(NewEventHandlerUPP(AEHandler),
106 GetEventTypeCount(appleEvents), appleEvents, 0, NULL);
108 /* Install handlers for the individual Apple Events that come
109 from the Dock icon: the Reopen (click), and the Quit messages. */
110 err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
111 NewAEEventHandlerUPP(HandleQuitMessage), 0, false);
112 err = AEInstallEventHandler(kCoreEventClass, kAEReopenApplication,
113 NewAEEventHandlerUPP(HandleReopenMessage), 0, false);
115 // Left as an example of a wild card match.
116 err = AEInstallEventHandler(kCoreEventClass, typeWildCard,
117 NewAEEventHandlerUPP(HandleWildMessage), 0, false);
124 RgnHandle cursorRgn = NULL;
125 Boolean gotEvent=TRUE;
129 gotEvent = WaitNextEvent(everyEvent, &event, 0L/*timeout*/, cursorRgn);