Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TCarbonEvent.h

Go to the documentation of this file.
00001 /* 00002 File: TCarbonEvent.h 00003 00004 Version: 1.0 00005 00006 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 00007 ("Apple") in consideration of your agreement to the following terms, and your 00008 use, installation, modification or redistribution of this Apple software 00009 constitutes acceptance of these terms. If you do not agree with these terms, 00010 please do not use, install, modify or redistribute this Apple software. 00011 00012 In consideration of your agreement to abide by the following terms, and subject 00013 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs 00014 copyrights in this original Apple software (the "Apple Software"), to use, 00015 reproduce, modify and redistribute the Apple Software, with or without 00016 modifications, in source and/or binary forms; provided that if you redistribute 00017 the Apple Software in its entirety and without modifications, you must retain 00018 this notice and the following text and disclaimers in all such redistributions of 00019 the Apple Software. Neither the name, trademarks, service marks or logos of 00020 Apple Computer, Inc. may be used to endorse or promote products derived from the 00021 Apple Software without specific prior written permission from Apple. Except as 00022 expressly stated in this notice, no other rights or licenses, express or implied, 00023 are granted by Apple herein, including but not limited to any patent rights that 00024 may be infringed by your derivative works or by other works in which the Apple 00025 Software may be incorporated. 00026 00027 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 00028 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 00029 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00030 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 00031 COMBINATION WITH YOUR PRODUCTS. 00032 00033 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 00034 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00035 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00036 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 00037 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 00038 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 00039 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00040 00041 Copyright © 2002 Apple Computer, Inc., All Rights Reserved 00042 */ 00043 00044 #ifndef TCarbonEvent_H_ 00045 #define TCarbonEvent_H_ 00046 00047 #include <Carbon/Carbon.h> 00048 00049 struct InvalidEventParameterType {}; 00050 00051 template <class T> EventParamType EventDataType() throw( InvalidEventParameterType ) 00052 { throw InvalidEventParameterType(); return 0; } 00053 00054 template <> inline EventParamType EventDataType<WindowRef>() { return typeWindowRef; } 00055 template <> inline EventParamType EventDataType<ControlRef>() { return typeControlRef; } 00056 template <> inline EventParamType EventDataType<MenuRef>() { return typeMenuRef; } 00057 template <> inline EventParamType EventDataType<DragRef>() { return typeDragRef; } 00058 00059 template <> inline EventParamType EventDataType<HIPoint>() { return typeHIPoint; } 00060 template <> inline EventParamType EventDataType<HISize>() { return typeHISize; } 00061 template <> inline EventParamType EventDataType<HIRect>() { return typeHIRect; } 00062 template <> inline EventParamType EventDataType<Point>() { return typeQDPoint; } 00063 template <> inline EventParamType EventDataType<Rect>() { return typeQDRectangle; } 00064 template <> inline EventParamType EventDataType<RgnHandle>() { return typeQDRgnHandle; } 00065 00066 template <> inline EventParamType EventDataType<Boolean>() { return typeBoolean; } 00067 template <> inline EventParamType EventDataType<UInt32>() { return typeUInt32; } 00068 00069 template <> inline EventParamType EventDataType<HICommand>() { return typeHICommand; } 00070 00071 class TCarbonEvent 00072 { 00073 public: 00074 // Construction/Destruction 00075 TCarbonEvent( 00076 UInt32 inClass, 00077 UInt32 inKind ); 00078 TCarbonEvent( 00079 EventRef inEvent ); 00080 virtual ~TCarbonEvent(); 00081 00082 UInt32 GetClass() const 00083 { return ::GetEventClass( fEvent ); } 00084 UInt32 GetKind() const 00085 { return ::GetEventKind( fEvent ); }; 00086 00087 // Time 00088 void SetTime( 00089 EventTime inTime ) 00090 { ::SetEventTime( fEvent, inTime ); } 00091 EventTime GetTime() const 00092 { return ::GetEventTime( fEvent ); } 00093 UInt32 GetTimeAsTicks() const 00094 { return EventTimeToTicks( GetTime() ); } 00095 00096 // Retention 00097 void Retain() 00098 { ::RetainEvent( fEvent ); } 00099 void Release() 00100 { ::ReleaseEvent( fEvent ); } 00101 00102 // Accessors 00103 operator EventRef&() 00104 { return fEvent; }; 00105 EventRef GetEventRef() 00106 { return fEvent; } 00107 00108 // Posting 00109 OSStatus PostToQueue( 00110 EventQueueRef inQueue, 00111 EventPriority inPriority = kEventPriorityStandard ); 00112 00113 // Parameters 00114 OSStatus SetParameter( 00115 EventParamName inName, 00116 EventParamType inType, 00117 UInt32 inSize, 00118 const void* inData ); 00119 OSStatus GetParameter( 00120 EventParamName inName, 00121 EventParamType inType, 00122 UInt32 inBufferSize, 00123 void* outData ); 00124 00125 OSStatus GetParameterType( 00126 EventParamName inName, 00127 EventParamType* outType ); 00128 OSStatus GetParameterSize( 00129 EventParamName inName, 00130 UInt32* outSize ); 00131 00132 // Simple parameters 00133 OSStatus SetParameter( 00134 EventParamName inName, 00135 Boolean inValue ); 00136 OSStatus GetParameter( 00137 EventParamName inName, 00138 Boolean* outValue ); 00139 00140 OSStatus SetParameter( 00141 EventParamName inName, 00142 bool inValue ); 00143 OSStatus GetParameter( 00144 EventParamName inName, 00145 bool* outValue ); 00146 00147 OSStatus SetParameter( 00148 EventParamName inName, 00149 Point inPt ); 00150 OSStatus GetParameter( 00151 EventParamName inName, 00152 Point* outPt ); 00153 00154 OSStatus SetParameter( 00155 EventParamName inName, 00156 const HIPoint& inPt ); 00157 00158 OSStatus GetParameter( 00159 EventParamName inName, 00160 HIPoint* outPt ); 00161 00162 OSStatus SetParameter( 00163 EventParamName inName, 00164 const Rect& inRect ); 00165 OSStatus GetParameter( 00166 EventParamName inName, 00167 Rect* outRect ); 00168 00169 OSStatus SetParameter( 00170 EventParamName inName, 00171 const HIRect& inRect ); 00172 OSStatus GetParameter( 00173 EventParamName inName, 00174 HIRect* outRect ); 00175 00176 OSStatus SetParameter( 00177 EventParamName inName, 00178 const HISize& inSize ); 00179 OSStatus GetParameter( 00180 EventParamName inName, 00181 HISize* outSize ); 00182 00183 OSStatus SetParameter( 00184 EventParamName inName, 00185 RgnHandle inRegion ); 00186 OSStatus GetParameter( 00187 EventParamName inName, 00188 RgnHandle* outRegion ); 00189 00190 OSStatus SetParameter( 00191 EventParamName inName, 00192 WindowRef inWindow ); 00193 OSStatus GetParameter( 00194 EventParamName inName, 00195 WindowRef* outWindow ); 00196 00197 OSStatus SetParameter( 00198 EventParamName inName, 00199 ControlRef inControl ); 00200 OSStatus GetParameter( 00201 EventParamName inName, 00202 ControlRef* outControl ); 00203 00204 OSStatus SetParameter( 00205 EventParamName inName, 00206 MenuRef inMenu ); 00207 OSStatus GetParameter( 00208 EventParamName inName, 00209 MenuRef* outMenu ); 00210 00211 OSStatus SetParameter( 00212 EventParamName inName, 00213 DragRef inDrag ); 00214 OSStatus GetParameter( 00215 EventParamName inName, 00216 DragRef* outDrag ); 00217 00218 OSStatus SetParameter( 00219 EventParamName inName, 00220 UInt32 inValue ); 00221 OSStatus GetParameter( 00222 EventParamName inName, 00223 UInt32* outValue ); 00224 00225 OSStatus SetParameter( 00226 EventParamName inName, 00227 const HICommand& inValue ); 00228 OSStatus GetParameter( 00229 EventParamName inName, 00230 HICommand* outValue ); 00231 00232 OSStatus SetParameter( 00233 EventParamName inName, 00234 const ControlPartCode& inValue ); 00235 OSStatus GetParameter( 00236 EventParamName inName, 00237 ControlPartCode* outValue ); 00238 00239 // Template parameters 00240 template <class T> OSStatus SetParameter( 00241 EventParamName inName, 00242 EventParamType inType, 00243 const T& inValue ) 00244 { 00245 return SetParameter( inName, inType, sizeof( T ), &inValue ); 00246 } 00247 00248 template <class T> OSStatus GetParameter( 00249 EventParamName inName, 00250 EventParamType inType, 00251 T* outValue ) 00252 { 00253 return GetParameter( inName, inType, sizeof( T ), outValue ); 00254 } 00255 00256 template <class T> T GetParameter( 00257 EventParamName inName ) 00258 { 00259 T outValue; 00260 00261 verify_noerr( GetParameter( inName, EventDataType<T>(), sizeof( T ), &outValue ) ); 00262 00263 return outValue; 00264 } 00265 00266 template <class T> void SetParameter( 00267 EventParamName inName, 00268 const T& inValue ) 00269 { 00270 verify_noerr( SetParameter( inName, EventDataType<T>(), sizeof( T ), &inValue ) ); 00271 } 00272 00273 template <class T> T GetParameter( 00274 EventParamName inName, EventParamType inType ) 00275 { 00276 T outValue; 00277 00278 verify_noerr( GetParameter( inName, inType, sizeof( T ), &outValue ) ); 00279 00280 return outValue; 00281 } 00282 00283 private: 00284 EventRef fEvent; 00285 }; 00286 00287 #endif // TCarbonEvent_H_





Generated on Sun May 23 09:05:17 2004 for AUGUI Framework by doxygen1.3.7

hosted on SourceForge.net Logo