00001
00002
00003
00004 #ifndef COMPONENT_H
00005 #define COMPONENT_H
00006
00007 #include <windows.h>
00008 #include "Types.h"
00009 #include <vector>
00010 #include "String.h"
00011
00012
00014
00016
00017 LPSTR szCmdLine, int iCmdShow );
00018
00020
00021
00023
00024
00025 namespace wkgl {
00026
00027 extern HINSTANCE gInstance;
00028 extern HINSTANCE gPrevInstance;
00029 extern String gCmdLine;
00030 extern INT gCmdShow;
00031
00032
00033 class Component;
00034
00040 typedef struct
00041 {
00042 HWND *hwnd;
00043 Component *com;
00044 } REGCOMPONENT;
00045
00054 typedef BOOL (*COMCALLBACK)( Component* com, UINT message,
00055 WPARAM wParam, LPARAM lParam );
00056
00086 class CallBack
00087 {
00088 public:
00097 virtual BOOL callBack(Component* com, UINT message,
00098 WPARAM wParam, LPARAM lParam) = 0;
00099 };
00100
00107 class Component
00108 {
00109 protected:
00110 Component* parent;
00111 HINSTANCE hInstance;
00112 HWND hwnd;
00113
00121 struct CHILDCOMPONENT
00122 {
00123 Component *com;
00124 HWND *hwnd;
00125 };
00126
00132 std::vector < CHILDCOMPONENT > clisteners;
00133
00140 std::vector < COMCALLBACK > comlisteners;
00141
00148 std::vector < CallBack* > classlisteners;
00149
00150 public:
00154 Component();
00155
00159 virtual void registerComponent( HWND *hwnd, Component* com );
00160
00164 virtual void registerChild( HWND *hwnd, Component* com );
00165
00169 virtual LRESULT fireChildEvents( UINT message, WPARAM wParam,
00170 LPARAM lParam );
00171
00175 virtual Component* getParent();
00176
00180 virtual void setParent( Component* p );
00181
00185 virtual HINSTANCE getInstance();
00186
00190 virtual HWND getHwnd();
00191
00195 virtual void setHwnd( HWND h );
00196
00200 static UINT getWndProc();
00201
00205 virtual void addCallBack( COMCALLBACK callback );
00206
00210 virtual void addCallBack( CallBack *callback );
00211
00215 virtual LRESULT fireEvents( HWND hwnd, UINT message,
00216 WPARAM wParam, LPARAM lParam );
00217
00221 friend LRESULT CALLBACK globalProc( HWND hwnd,
00222 UINT message,
00223 WPARAM wParam,
00224 LPARAM lParam);
00225 };
00226 }
00227 #endif