00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GRAPHICSWINDOW_H
00020 #define GRAPHICSWINDOW_H
00021
00022 #include "pandabase.h"
00023
00024 #include "graphicsWindowInputDevice.h"
00025 #include "windowProperties.h"
00026 #include "graphicsChannel.h"
00027 #include "graphicsPipe.h"
00028 #include "displayRegion.h"
00029 #include "graphicsStateGuardian.h"
00030 #include "clearableRegion.h"
00031
00032 #include "typedReferenceCount.h"
00033 #include "mouseData.h"
00034 #include "modifierButtons.h"
00035 #include "buttonEvent.h"
00036 #include "iterator_types.h"
00037 #include "notify.h"
00038 #include "pmutex.h"
00039
00040 #include "pvector.h"
00041 #include "pdeque.h"
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 class EXPCL_PANDA GraphicsWindow : public TypedReferenceCount, public ClearableRegion {
00060 protected:
00061 GraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg);
00062
00063 private:
00064 GraphicsWindow(const GraphicsWindow ©);
00065 void operator = (const GraphicsWindow ©);
00066
00067 PUBLISHED:
00068 virtual ~GraphicsWindow();
00069
00070 WindowProperties get_properties() const;
00071 WindowProperties get_requested_properties() const;
00072 void clear_rejected_properties();
00073 WindowProperties get_rejected_properties() const;
00074 void request_properties(const WindowProperties &requested_properties);
00075 INLINE bool is_closed() const;
00076 INLINE bool is_active() const;
00077 INLINE bool is_fullscreen() const;
00078
00079 void set_window_event(const string &window_event);
00080 string get_window_event() const;
00081
00082 INLINE GraphicsStateGuardian *get_gsg() const;
00083 INLINE GraphicsPipe *get_pipe() const;
00084
00085 GraphicsChannel *get_channel(int index);
00086 void remove_channel(int index);
00087
00088 int get_max_channel_index() const;
00089 bool is_channel_defined(int index) const;
00090
00091 int get_num_display_regions() const;
00092 DisplayRegion *get_display_region(int n) const;
00093
00094
00095 int get_num_input_devices() const;
00096 string get_input_device_name(int device) const;
00097 bool has_pointer(int device) const;
00098 bool has_keyboard(int device) const;
00099
00100 public:
00101
00102 MouseData get_mouse_data(int device) const;
00103 bool has_button_event(int device) const;
00104 ButtonEvent get_button_event(int device);
00105
00106 virtual int verify_window_sizes(int numsizes, int *dimen);
00107
00108 PT(DisplayRegion) make_scratch_display_region(int x_size, int y_size) const;
00109
00110 public:
00111
00112 INLINE void win_display_regions_changed();
00113
00114 public:
00115
00116
00117
00118 virtual bool begin_frame();
00119 void clear();
00120 virtual void end_frame();
00121
00122
00123
00124 virtual void make_current();
00125 virtual void release_gsg();
00126
00127
00128 virtual void begin_flip();
00129 virtual void end_flip();
00130
00131
00132
00133
00134 virtual void process_events();
00135 virtual void set_properties_now(WindowProperties &properties);
00136
00137 protected:
00138 virtual void close_window();
00139 virtual bool open_window();
00140 virtual bool do_reshape_request(int x_origin, int y_origin,
00141 int x_size, int y_size);
00142
00143 void declare_channel(int index, GraphicsChannel *chan);
00144
00145
00146
00147 void system_changed_properties(const WindowProperties &properties);
00148 void system_changed_size(int x_size, int y_size);
00149
00150 protected:
00151 typedef vector_GraphicsWindowInputDevice InputDevices;
00152 InputDevices _input_devices;
00153 Mutex _input_lock;
00154
00155 PT(GraphicsStateGuardian) _gsg;
00156 PT(GraphicsPipe) _pipe;
00157
00158 private:
00159 INLINE void determine_display_regions() const;
00160 void do_determine_display_regions();
00161
00162 protected:
00163 WindowProperties _properties;
00164
00165 private:
00166 Mutex _lock;
00167
00168
00169 typedef pvector< PT(GraphicsChannel) > Channels;
00170 Channels _channels;
00171
00172 typedef pvector<DisplayRegion *> DisplayRegions;
00173 DisplayRegions _display_regions;
00174 bool _display_regions_stale;
00175
00176 WindowProperties _requested_properties;
00177 WindowProperties _rejected_properties;
00178 string _window_event;
00179
00180 public:
00181 static TypeHandle get_class_type() {
00182 return _type_handle;
00183 }
00184 static void init_type() {
00185 TypedReferenceCount::init_type();
00186 register_type(_type_handle, "GraphicsWindow",
00187 TypedReferenceCount::get_class_type());
00188 }
00189 virtual TypeHandle get_type() const {
00190 return get_class_type();
00191 }
00192 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00193
00194 private:
00195 static TypeHandle _type_handle;
00196
00197 friend class GraphicsPipe;
00198 friend class GraphicsEngine;
00199 };
00200
00201 #include "graphicsWindow.I"
00202
00203 #endif