6
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
7
("Apple") in consideration of your agreement to the following terms, and your
8
use, installation, modification or redistribution of this Apple software
9
constitutes acceptance of these terms. If you do not agree with these terms,
10
please do not use, install, modify or redistribute this Apple software.
12
In consideration of your agreement to abide by the following terms, and subject
13
to these terms, Apple grants you a personal, non-exclusive license, under Apple�s
14
copyrights in this original Apple software (the "Apple Software"), to use,
15
reproduce, modify and redistribute the Apple Software, with or without
16
modifications, in source and/or binary forms; provided that if you redistribute
17
the Apple Software in its entirety and without modifications, you must retain
18
this notice and the following text and disclaimers in all such redistributions of
19
the Apple Software. Neither the name, trademarks, service marks or logos of
20
Apple Computer, Inc. may be used to endorse or promote products derived from the
21
Apple Software without specific prior written permission from Apple. Except as
22
expressly stated in this notice, no other rights or licenses, express or implied,
23
are granted by Apple herein, including but not limited to any patent rights that
24
may be infringed by your derivative works or by other works in which the Apple
25
Software may be incorporated.
27
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
28
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
29
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
31
COMBINATION WITH YOUR PRODUCTS.
33
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
34
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
35
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
37
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
38
(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
39
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
Copyright � 2000-2005 Apple Computer, Inc., All Rights Reserved
44
#include "TApplication.h"
47
// -----------------------------------------------------------------------------
49
// -----------------------------------------------------------------------------
52
// Our base class for creating a Mac OS application which is be Carbon Event-savvy.
54
// -----------------------------------------------------------------------------
55
// TApplication Nib creation constructor
56
// -----------------------------------------------------------------------------
58
TApplication::TApplication(
59
CFStringRef inMenuBarName,
60
CFStringRef inNibName )
62
Init( inMenuBarName, inNibName );
65
// -----------------------------------------------------------------------------
67
// -----------------------------------------------------------------------------
71
CFStringRef inMenuBarName,
72
CFStringRef inNibName )
78
EventTypeSpec kEvents[] =
80
{ kEventClassCommand, kEventProcessCommand },
83
err = RegisterForEvents( GetEventTypeCount( kEvents ), kEvents );
84
require_noerr( err, CantInit );
86
err = nib.Init( inNibName );
87
require_noerr( err, CantInit );
89
err = nib.SetMenuBar( inMenuBarName );
90
require_noerr( err, CantInit );
96
// -----------------------------------------------------------------------------
97
// TApplication destructor
98
// -----------------------------------------------------------------------------
100
TApplication::~TApplication()
104
// -----------------------------------------------------------------------------
106
// -----------------------------------------------------------------------------
109
TApplication::GetEventTarget()
111
return GetApplicationEventTarget();
114
// -----------------------------------------------------------------------------
116
// -----------------------------------------------------------------------------
121
RunApplicationEventLoop();
124
// -----------------------------------------------------------------------------
126
// -----------------------------------------------------------------------------
129
TApplication::Activated()
133
// -----------------------------------------------------------------------------
135
// -----------------------------------------------------------------------------
138
TApplication::Deactivated()
142
// -----------------------------------------------------------------------------
143
// UpdateCommandStatus
144
// -----------------------------------------------------------------------------
147
TApplication::UpdateCommandStatus(
148
const HICommandExtended& inCommand )
150
return false; // not handled
153
// -----------------------------------------------------------------------------
155
// -----------------------------------------------------------------------------
158
TApplication::HandleCommand(
159
const HICommandExtended& inCommand )
161
return false; // not handled
164
// -----------------------------------------------------------------------------
166
// -----------------------------------------------------------------------------
169
TApplication::HandleEvent(
170
EventHandlerCallRef inRef,
171
TCarbonEvent& inEvent )
173
OSStatus result = eventNotHandledErr;
174
HICommandExtended command;
176
switch ( inEvent.GetClass() )
178
case kEventClassCommand:
180
inEvent.GetParameter( kEventParamDirectObject, &command );
182
switch ( inEvent.GetKind() )
184
case kEventCommandProcess:
185
if ( this->HandleCommand( command ) )
189
case kEventCommandUpdateStatus:
190
if ( this->UpdateCommandStatus( command ) )