Panda3D
|
00001 // Filename: callbackGraphicsWindow.I 00002 // Created by: drose (06Jan11) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: CallbackGraphicsWindow::set_events_callback 00018 // Access: Published 00019 // Description: Sets the CallbackObject that will be notified when 00020 // this window is polled for window events, including 00021 // mouse and keyboard events, as well as window resize 00022 // events and other system-generated events. 00023 // 00024 // This callback will receive a 00025 // CallbackGraphicsWindow::EventsCallbackData. 00026 // 00027 // This callback should process any system-generated 00028 // events, and call data->upcall() to process requested 00029 // property change requests made via 00030 // request_properties(). 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE void CallbackGraphicsWindow:: 00033 set_events_callback(CallbackObject *object) { 00034 _events_callback = object; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: CallbackGraphicsWindow::clear_events_callback 00039 // Access: Published 00040 // Description: Removes the callback set by an earlier call to 00041 // set_events_callback(). 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE void CallbackGraphicsWindow:: 00044 clear_events_callback() { 00045 set_events_callback(NULL); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: CallbackGraphicsWindow::get_events_callback 00050 // Access: Published 00051 // Description: Returns the CallbackObject set by set_events_callback(). 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE CallbackObject *CallbackGraphicsWindow:: 00054 get_events_callback() const { 00055 return _events_callback; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: CallbackGraphicsWindow::set_properties_callback 00060 // Access: Published 00061 // Description: Sets the CallbackObject that will be notified when 00062 // this window receives a property change request from 00063 // user code (e.g. via request_properties). 00064 // 00065 // This callback will receive a 00066 // CallbackGraphicsWindow::PropertiesCallbackData, which 00067 // provides a get_properties() method that returns a 00068 // modifiable reference to a WindowsProperties object. 00069 // This object will contain only those properties 00070 // requested by user code. The callback should handle 00071 // any of the requests it finds, including and 00072 // especially set_open(), and remove them from the 00073 // object when it has handled them. Any unhandled 00074 // properties should be left unchanged in the properties 00075 // object. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE void CallbackGraphicsWindow:: 00078 set_properties_callback(CallbackObject *object) { 00079 _properties_callback = object; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: CallbackGraphicsWindow::clear_properties_callback 00084 // Access: Published 00085 // Description: Removes the callback set by an earlier call to 00086 // set_properties_callback(). 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE void CallbackGraphicsWindow:: 00089 clear_properties_callback() { 00090 set_properties_callback(NULL); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: CallbackGraphicsWindow::get_properties_callback 00095 // Access: Published 00096 // Description: Returns the CallbackObject set by set_properties_callback(). 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE CallbackObject *CallbackGraphicsWindow:: 00099 get_properties_callback() const { 00100 return _properties_callback; 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: CallbackGraphicsWindow::set_render_callback 00105 // Access: Published 00106 // Description: Sets the CallbackObject that will be notified when 00107 // this window is invoked (in the draw thread) to render 00108 // its contents, and/or flip the graphics buffers. 00109 // 00110 // This callback will actually serve several different 00111 // functions. It receivces a RenderCallbackData, and 00112 // you can query data->get_callback_type() to return the 00113 // actual function of each particular callback. 00114 //////////////////////////////////////////////////////////////////// 00115 INLINE void CallbackGraphicsWindow:: 00116 set_render_callback(CallbackObject *object) { 00117 _render_callback = object; 00118 } 00119 00120 //////////////////////////////////////////////////////////////////// 00121 // Function: CallbackGraphicsWindow::clear_render_callback 00122 // Access: Published 00123 // Description: Removes the callback set by an earlier call to 00124 // set_render_callback(). 00125 //////////////////////////////////////////////////////////////////// 00126 INLINE void CallbackGraphicsWindow:: 00127 clear_render_callback() { 00128 set_render_callback(NULL); 00129 } 00130 00131 //////////////////////////////////////////////////////////////////// 00132 // Function: CallbackGraphicsWindow::get_render_callback 00133 // Access: Published 00134 // Description: Returns the CallbackObject set by set_render_callback(). 00135 //////////////////////////////////////////////////////////////////// 00136 INLINE CallbackObject *CallbackGraphicsWindow:: 00137 get_render_callback() const { 00138 return _render_callback; 00139 } 00140 00141 //////////////////////////////////////////////////////////////////// 00142 // Function: CallbackGraphicsWindow::WindowCallbackData::Constructor 00143 // Access: Public 00144 // Description: 00145 //////////////////////////////////////////////////////////////////// 00146 INLINE CallbackGraphicsWindow::WindowCallbackData:: 00147 WindowCallbackData(CallbackGraphicsWindow *window) : _window(window) { 00148 } 00149 00150 //////////////////////////////////////////////////////////////////// 00151 // Function: CallbackGraphicsWindow::WindowCallbackData::get_window 00152 // Access: Published 00153 // Description: Returns the window this callback was triggered from. 00154 //////////////////////////////////////////////////////////////////// 00155 INLINE CallbackGraphicsWindow *CallbackGraphicsWindow::WindowCallbackData:: 00156 get_window() const { 00157 return _window; 00158 } 00159 00160 //////////////////////////////////////////////////////////////////// 00161 // Function: CallbackGraphicsWindow::EventsCallbackData::Constructor 00162 // Access: Public 00163 // Description: 00164 //////////////////////////////////////////////////////////////////// 00165 INLINE CallbackGraphicsWindow::EventsCallbackData:: 00166 EventsCallbackData(CallbackGraphicsWindow *window) : 00167 WindowCallbackData(window) 00168 { 00169 } 00170 00171 00172 //////////////////////////////////////////////////////////////////// 00173 // Function: CallbackGraphicsWindow::PropertiesCallbackData::Constructor 00174 // Access: Public 00175 // Description: 00176 //////////////////////////////////////////////////////////////////// 00177 INLINE CallbackGraphicsWindow::PropertiesCallbackData:: 00178 PropertiesCallbackData(CallbackGraphicsWindow *window, WindowProperties &properties) : 00179 WindowCallbackData(window), 00180 _properties(properties) 00181 { 00182 } 00183 00184 //////////////////////////////////////////////////////////////////// 00185 // Function: CallbackGraphicsWindow::PropertiesCallbackData::get_properties 00186 // Access: Published 00187 // Description: Returns the WindowProperties object that this 00188 // callback should process. Any properties that are 00189 // handled should be removed from this object; 00190 // properties that are unhandled should be left alone. 00191 //////////////////////////////////////////////////////////////////// 00192 INLINE WindowProperties &CallbackGraphicsWindow::PropertiesCallbackData:: 00193 get_properties() const { 00194 return _properties; 00195 } 00196 00197 //////////////////////////////////////////////////////////////////// 00198 // Function: CallbackGraphicsWindow::RenderCallbackData::Constructor 00199 // Access: Public 00200 // Description: 00201 //////////////////////////////////////////////////////////////////// 00202 INLINE CallbackGraphicsWindow::RenderCallbackData:: 00203 RenderCallbackData(CallbackGraphicsWindow *window, RenderCallbackType callback_type, FrameMode frame_mode) : 00204 WindowCallbackData(window), 00205 _callback_type(callback_type), 00206 _frame_mode(frame_mode), 00207 _render_flag(true) 00208 { 00209 } 00210 00211 //////////////////////////////////////////////////////////////////// 00212 // Function: CallbackGraphicsWindow::RenderCallbackData::get_callback_type 00213 // Access: Published 00214 // Description: Since the render callback is shared for several 00215 // functions, this method is needed to indicate which 00216 // particular function is being invoked with this 00217 // callback. 00218 //////////////////////////////////////////////////////////////////// 00219 INLINE CallbackGraphicsWindow::RenderCallbackType CallbackGraphicsWindow::RenderCallbackData:: 00220 get_callback_type() const { 00221 return _callback_type; 00222 } 00223 00224 //////////////////////////////////////////////////////////////////// 00225 // Function: CallbackGraphicsWindow::RenderCallbackData::get_frame_mode 00226 // Access: Published 00227 // Description: If the callback type (returned by get_callback_type) 00228 // is RCT_begin_frame or RCT_end_frame, then this method 00229 // will return the particular frame mode indicating 00230 // what, precisely, we want to do this frame. 00231 //////////////////////////////////////////////////////////////////// 00232 INLINE GraphicsOutput::FrameMode CallbackGraphicsWindow::RenderCallbackData:: 00233 get_frame_mode() const { 00234 return _frame_mode; 00235 } 00236 00237 //////////////////////////////////////////////////////////////////// 00238 // Function: CallbackGraphicsWindow::RenderCallbackData::set_render_flag 00239 // Access: Published 00240 // Description: If the callback type is RCT_begin_frame, this call is 00241 // available to specify the return value from the 00242 // begin_frame() call. If this is true (the default), 00243 // the frame is rendered normally; if it is false, the 00244 // frame is omitted. 00245 //////////////////////////////////////////////////////////////////// 00246 INLINE void CallbackGraphicsWindow::RenderCallbackData:: 00247 set_render_flag(bool render_flag) { 00248 _render_flag = render_flag; 00249 } 00250 00251 //////////////////////////////////////////////////////////////////// 00252 // Function: CallbackGraphicsWindow::RenderCallbackData::get_render_flag 00253 // Access: Published 00254 // Description: Returns the current setting of the render flag. See 00255 // set_render_flag(). 00256 //////////////////////////////////////////////////////////////////// 00257 INLINE bool CallbackGraphicsWindow::RenderCallbackData:: 00258 get_render_flag() const { 00259 return _render_flag; 00260 }