00001 #ifndef _COPPER_WINDOW_H
00002 #define _COPPER_WINDOW_H
00003
00004 #include "MercuryObject.h"
00005 #include <map>
00006
00008 struct CopperKeypress
00009 {
00010 char cLetter;
00011 enum {
00012 KEY_DOWN,
00013 KEY_UP
00014 } pType;
00015 };
00016
00018 struct CopperMouseEvent
00019 {
00020 int x;
00021 int y;
00022 enum {
00023 MOUSE_MOVE,
00024 MOUSE_DOWN,
00025 MOUSE_UP,
00026 MOUSE_IN,
00027 MOUSE_OUT
00028 } pType;
00029 };
00030
00032 struct CSTMessagePair
00033 {
00034 MString Message;
00035 MString Data;
00036 bool Use() { return Message.length() != 0 || Data.length() != 0; }
00037 void Broadcast() { if (Use()) MESSAGEMAN->BroadcastMessage( Message, PStack(PSElement(Data) )); }
00038 };
00039
00040
00041 class ScreenCopper;
00042
00044 class CopperWindow : public MercuryObject
00045 {
00046 public:
00047 virtual ~CopperWindow();
00048 virtual void Init( CopperWindow * pParent, const MString & sName );
00049
00050 virtual void KeyPress( const CopperKeypress & pKeypress );
00051 virtual bool MouseEvent( const CopperMouseEvent & pMouseEvent );
00052 virtual bool IsMouseEventOnTarget( const CopperMouseEvent & pMouseEvent );
00053
00054 virtual bool IsFocusable() = 0;
00055
00056 MString GetFocus();
00057 void SetFocus( const MString & sFocus );
00058
00059 void SetWidth( float fWidth ) { m_fWidth = fWidth; }
00060 void SetHeight( float fHeight ) { m_fHeight = fHeight; }
00061
00062 float GetWidth() { return m_fWidth; }
00063 float GetHeight() { return m_fHeight; }
00064 CLASS_RTTI( CopperWindow, MercuryObject );
00065 protected:
00066 CSTMessagePair m_pBrdOverOn;
00067 CSTMessagePair m_pBrdOverOff;
00068 CSTMessagePair m_pBrdUpInTarget;
00069 CSTMessagePair m_pBrdUpOutTarget;
00070 CSTMessagePair m_pBrdDown;
00071
00072 CopperWindow * m_pParent;
00073 MVector < CopperWindow * > m_vWindows;
00074 int m_iCurrentFocus;
00075 float m_fHeight, m_fWidth;
00076 int m_iLastMouseWindow;
00077 };
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 typedef CopperWindow* (*NewCopperFunction)(const MString& sClassName);
00088 void RegisterCopperWindow( const MString& sClassName, NewCopperFunction pfn );
00089
00090 #define REGISTER_COPPER_CLASS( className ) \
00091 static CopperWindow* Create##className( const MString &sName ) \
00092 { CopperWindow *pRet = new className( ); return pRet; } \
00093 struct Register##className { \
00094 Register##className() { RegisterCopperWindow( #className,Create##className); } \
00095 }; \
00096 static Register##className register_##className;
00097
00098 extern std::map< MString, NewCopperFunction > *ToMakeWindows;
00099
00100 CopperWindow * GetCopperByClass( const MString & sClassName, const MString & sWindowName );
00101
00102
00103
00104 #endif
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133