00001 #if !defined( __ARSWINDOW_H__ ) 00002 #define __ARSWINDOW_H__ 00003 00004 namespace Ars 00005 { 00006 class XToolTip; 00007 00008 class Window : public Painter , public std::list<Window *> { 00009 private: 00010 00011 bool paintAlreadySent; 00012 00014 std::string text; 00015 00017 Window *parentWindow; 00018 XToolTip *toolTip; 00019 00020 icstring soundName; 00021 00022 SDL_Surface *bkgnd; 00023 00024 protected: 00025 00026 friend class View; 00027 friend class XBox; 00028 00029 XRect clientRect; 00030 00031 unsigned int m_MouseButton; 00032 00033 public: 00034 Window( void ); 00035 00036 virtual ~Window( void ); 00037 00038 // Initialize the window 00040 virtual const bool SetupWindow( const Message &msg ); 00041 00046 virtual void Init( icstring &aStr ); 00047 00050 const bool IsVisible(void) const { return (GetFlags() & F_HIDETREE) == 0; } 00051 00053 virtual const bool ShowWindow( void ); 00054 00056 virtual const bool HideWindow( void ); 00057 00063 XRect GetClientRect( void ); 00064 00065 // Thing Overrides 00066 virtual void SetWindowRect( const XRect &WindowRect ) 00067 { 00068 Thing::SetWindowRect( WindowRect ); 00069 clientRect.w = Width(); 00070 clientRect.h = Height(); 00071 } 00072 00075 virtual const bool SetParent( Window *pNewParent ); 00076 00078 virtual const bool ResetChildren( void ); 00079 00080 virtual Window *GetParent( void ) const { return parentWindow; } 00081 00082 Window *GetRoot( void ) const; 00083 00086 virtual void SetWndText( const std::string &sText ) { text = sText; SetDirty(); } 00087 virtual void SetWndText( const int val ) { char tmp[20]; SetWndText( itoa( val , tmp , 10 ) ); } 00088 00091 virtual std::string GetWindowText(void) { return text; } 00092 00094 virtual void UpdateWindow( const bool aNow = false ); 00095 00098 virtual void DrawBG( void ); 00099 00101 virtual void Draw( void ); 00102 00104 virtual void DrawChildren( void ); 00105 00108 virtual const bool DrawProc(void); 00109 00111 virtual const bool wmPaint( const Message &msg ); 00112 00113 virtual void AdjustColors( void ) {}; 00114 virtual void RestoreColors( void ) {}; 00115 00116 00121 virtual const bool HandleMessage( const Message &msg ); 00122 00123 virtual const bool evMouseButtonUp( const MouseMessage &msg ); 00124 virtual const bool evMouseButtonDown( const MouseMessage &msg ); 00125 00126 Window *FindWindow( const XPoint *Pt ); 00127 00128 const bool IsChild( Window *wnd ); 00129 protected: 00130 // Registering and Deregistering child windows is automatically handled by the constructors and destructors 00131 00134 void RegisterChildWindow( Window *pWindow ); 00135 00138 void DeregisterChildWindow( Window *pWindow ); 00139 00140 virtual const bool DeregChild( const CtrlMessage &msg ); 00141 00142 const bool RelposInside( const XPoint *p ); 00143 }; 00144 00145 } 00146 00147 #endif