00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef freecloth_gfx_gfxWindow_h
00020 #define freecloth_gfx_gfxWindow_h
00021
00022 #ifndef freecloth_gfx_package_h
00023 #include <freecloth/gfx/package.h>
00024 #endif
00025
00026 #ifndef freecloth_resmgt_rcBase_h
00027 #include <freecloth/resmgt/rcBase.h>
00028 #endif
00029
00030 #ifndef freecloth_base_list
00031 #include <freecloth/base/list>
00032 #endif
00033
00034
00035
00036
00037 class GfxWindowObserver;
00038
00039
00040
00041
00042
00043
00044
00045 class GfxWindow : public RCBase {
00046 public:
00047
00048
00049
00050
00051 enum KeyID {
00052
00053
00054
00055
00056 KB_NONE = 0,
00057
00058 KB_BACKSPACE = 0x08,
00059 KB_TAB = '\t',
00060 KB_RETURN = '\n',
00061 KB_ENTER = KB_RETURN,
00062 KB_ESCAPE = 0x1B,
00063 KB_SPACE = ' ',
00064
00065 KB_LEFT,
00066 KB_RIGHT,
00067 KB_UP,
00068 KB_DOWN,
00069
00070
00071 KB_0 = '0', KB_1 = '1', KB_2 = '2', KB_3 = '3',
00072 KB_4 = '4', KB_5 = '5', KB_6 = '6', KB_7 = '7',
00073 KB_8 = '8', KB_9 = '9',
00074
00075
00076 KB_A = 'A', KB_B = 'B', KB_C = 'C', KB_D = 'D',
00077 KB_E = 'E', KB_F = 'F', KB_G = 'G', KB_H = 'H',
00078 KB_I = 'I', KB_J = 'J', KB_K = 'K', KB_L = 'L',
00079 KB_M = 'M', KB_N = 'N', KB_O = 'O', KB_P = 'P',
00080 KB_Q = 'Q', KB_R = 'R', KB_S = 'S', KB_T = 'T',
00081 KB_U = 'U', KB_V = 'V', KB_W = 'W', KB_X = 'X',
00082 KB_Y = 'Y', KB_Z = 'Z'
00083 };
00084
00085 enum {
00086 KBM_ALT = 0x01,
00087 KBM_CONTROL = 0x02,
00088 KBM_SHIFT = 0x04
00089 };
00090
00091
00092 enum ButtonID {
00093 MBN_NONE = 0,
00094
00095 MBN_LEFT,
00096 MBN_RIGHT,
00097 MBN_MIDDLE
00098 };
00099
00100
00101 typedef UInt32 ModBitfield;
00102
00103
00104
00105
00106
00107
00108
00109
00110 static void addStaticObserver( GfxWindowObserver& );
00111 static void removeStaticObserver( GfxWindowObserver& );
00112
00113
00114
00115
00116 GfxWindow();
00117
00118 virtual ~GfxWindow();
00119
00120 virtual UInt32 getWidth() const = 0;
00121 virtual UInt32 getHeight() const = 0;
00122 Float getAspectRatio() const;
00123 virtual void close() = 0;
00124
00125
00126
00127
00128
00129 virtual void addObserver( GfxWindowObserver& );
00130 virtual void removeObserver( GfxWindowObserver& );
00131
00132 protected:
00133
00134
00135
00136 void closeReceived();
00137
00138 void displayReceived();
00139 void idleReceived();
00140 void keyPressed( KeyID, ModBitfield );
00141 void keyDownReceived( KeyID, ModBitfield );
00142 void keyUpReceived( KeyID, ModBitfield );
00143 void mouseDownReceived( UInt32 x, UInt32 y, ButtonID );
00144 void mouseUpReceived( UInt32 x, UInt32 y, ButtonID );
00145 void mouseMoveReceived( UInt32 x, UInt32 y );
00146 void windowResized( UInt32 x, UInt32 y, UInt32 width, UInt32 height );
00147 void uiReceived( UInt32 uid );
00148
00149 private:
00150
00151
00152 class ObserverIterator;
00153
00154
00155 friend class ObserverIterator;
00156
00157
00158 typedef std::list<GfxWindowObserver*> ObserverList;
00159
00160
00161 ObserverIterator allObserversBegin();
00162 ObserverIterator allObserversEnd();
00163
00164
00165
00166
00167
00168 GfxWindow( GfxWindow const& );
00169 GfxWindow& operator=( GfxWindow const& );
00170
00171
00172 ObserverList _observers;
00173
00174
00175
00176 static ObserverList _staticObservers;
00177 };
00178 #endif