00001 /* 00002 * CComponent.h 00003 * 00004 * Created on: 14.04.2010 00005 * Author: vdv 00006 */ 00007 00008 #ifndef LIBGUI_COMPONENT_H_ 00009 #define LIBGUI_COMPONENT_H_ 00010 00011 #include "integer.h" 00012 #include "UIStructs.h" 00013 00014 class CGraphics; 00015 class ILayoutManager; 00016 class CFont; 00017 00028 /* abstract */class CComponent 00029 { 00030 public: 00035 CComponent(); 00036 ~CComponent(); 00040 CComponent(const CComponent& c); 00041 //*********************************************************** 00042 // action 00043 public: 00049 void DispatchEvent(SKeyEvent* e); 00055 void SetCommandAction(void* obj, void(*action)(void*, CComponent*)); 00059 void PerformAction(); 00060 protected: 00061 //void ProcessKeyEvent(SKeyEvent* e); 00069 virtual void PreviewProcessComponentKeyEvent(SKeyEvent* e); 00076 virtual void ProcessComponentKeyEvent(SKeyEvent* e); 00077 private: 00083 CComponent* GetActive(); 00084 //BOOL IsActive(); 00085 public: 00093 BOOL IsFocusOwner(); 00101 BOOL IsFocusable(); 00109 void SetFocusable(BOOL focusable); 00113 void TransferFocus(); 00117 void TransferFocusBackward(); 00126 void TransferFocusUpCycle(); 00127 private: 00136 CComponent* GetFocusCycleRootAncestor(); 00137 BOOL TransferFocus(CComponent* root); 00138 BOOL TransferFocusBackward(CComponent* root); 00144 void SetFirstFocusComponent(CComponent* root); 00150 void SetLastFocusComponent(CComponent* root); 00151 private: 00158 BOOL m_focusable; 00162 INT8 m_active; 00166 void* m_businessObject; 00172 void(*BusinessFunction)(void*, CComponent*); 00173 //*********************************************************** 00174 // timing 00175 public: 00194 virtual void OnTimer(); 00195 //*********************************************************** 00196 // painting 00197 public: 00198 //virtual void SetEnabled(BOOL bEnable); 00202 void Repaint(); 00215 void Redraw(CGraphics* g); 00225 virtual void Paint(CGraphics* g); 00230 void Bordered(BOOL b) { m_bordered = b; } 00231 private: 00240 void Repaint(INT16 x, INT16 y, INT16 width, INT16 height); 00241 protected: 00246 void PaintBorder(CGraphics* g); 00247 protected: 00251 INT32 m_background; 00255 INT32 m_foreground; 00259 BOOL m_bordered; 00260 //*********************************************************** 00261 // position and size 00262 public: 00273 virtual void SetSize(INT16 width, INT16 height); 00284 virtual void SetLocation(INT16 x, INT16 y); 00292 SPoint GetScreenPosition(); 00293 protected: 00297 INT16 m_x; 00301 INT16 m_y; 00305 INT16 m_sx; 00309 INT16 m_sy; 00313 INT16 m_width; 00317 INT16 m_height; 00321 INT16 m_swidth; 00325 INT16 m_sheight; 00326 //*********************************************************** 00327 public: 00334 CFont* GetFont(); 00340 void SetFont(CFont* font); 00341 private: 00349 CFont* m_font; 00350 //*********************************************************** 00351 // hierarchical addressing 00352 public: 00357 CComponent* GetParent(); 00358 private: 00364 CComponent* m_parent; 00365 //*********************************************************** 00366 // layout manager functions 00367 //*********************************************************** 00368 public: 00373 void SetLayout(ILayoutManager* layout); 00387 virtual void Add(CComponent* component); 00392 INT8 GetComponentCount(); 00393 protected: 00408 void Remove(CComponent* component); 00409 private: 00414 CComponent** m_component; 00419 INT8 m_componentlength; 00424 INT8 m_nComponents; 00429 ILayoutManager* m_layout; 00430 //*********************************************************** 00431 public: 00440 virtual void Invalidate(); 00457 void Validate(); 00467 BOOL IsValid(); 00468 protected: 00477 void ValidateTree(); 00478 private: 00488 BOOL m_valid; 00489 //*********************************************************** 00490 }; 00491 00492 #endif /* LIBGUI_COMPONENT_H_ */