Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CATGUI/CATWidget.h Source File

CATWidget.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /// \file CATWidget.h
00003 /// \brief GUI Widget object - parent class for all CATGuiObject's below
00004 ///        CATWindow
00005 /// \ingroup CATGUI
00006 ///
00007 /// Copyright (c) 2004-2008 by Michael Ellison.
00008 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00009 ///
00010 // $Author: mikeellison $
00011 // $Date: 2008-01-24 06:27:32 -0600 (Thu, 24 Jan 2008) $
00012 // $Revision:   $
00013 // $NoKeywords: $
00014 //---------------------------------------------------------------------------
00015 #ifndef CATWidget_H_
00016 #define CATWidget_H_
00017 
00018 #include "CATGuiObj.h"
00019 
00020 /// \class CATWidget CATWidget.h
00021 /// \brief GUI Widget object - parent class for all CATGuiObject's below
00022 ///        CATWindow
00023 /// \ingroup CATGUI
00024 class CATWidget : public CATGuiObj
00025 {
00026 public:
00027     /// Constructor - mirrors CATXMLObject() constructor for now.
00028     CATWidget(    const CATString& element, 
00029                   const CATString& rootDir)
00030     : CATGuiObj(element,rootDir)
00031     {
00032     }
00033 
00034     virtual ~CATWidget()
00035     {
00036     }
00037 
00038     /// MarkDirty() marks the control as dirty (needing to be redrawn)
00039     ///
00040     /// \param dirtyRect - if specified, marks only part of the rectangle
00041     /// as dirty. Should be in window coordinates - i.e. 0,0 is top left in window,
00042     /// not control.
00043     /// \param force - if true, invalidates rect even if control is not
00044     /// visible.  This should be done when initially hiding a control.  The
00045     /// rest of the time though, if a control already wasn't visible, it
00046     /// shouldn't cause an invalidation of the area its in when it changes.
00047     virtual void MarkDirty(CATRect* dirtyRect = 0, bool force = false)
00048     {  
00049         if (!force)
00050         {
00051             if (this->IsVisible() == false)
00052             {
00053                 return;
00054             }
00055         }
00056 
00057         CATRect invRect = fRect;
00058 
00059         if (dirtyRect)
00060         {
00061             invRect = *dirtyRect;
00062 
00063         }
00064 
00065         CATRect parRect = ((CATGuiObj*)this->GetParent())->GetRect();
00066         invRect.Offset( parRect.left, parRect.top );
00067         ((CATGuiObj*)this->GetParent())->MarkDirty(&invRect);
00068     }
00069 
00070     /// GetWindow() retrieves the parent window.
00071     virtual CATWindow*   GetWindow() const
00072     {
00073         return ((CATGuiObj*)fParent)->GetWindow();
00074     }
00075 
00076     virtual void PostDraw(CATDRAWCONTEXT context, const CATRect& dirtyRect) = 0;
00077     virtual void Draw(CATImage* image, const CATRect& dirtyRect)            = 0;
00078 
00079     /// OnParentCreate() is called when the parent window is created.
00080     /// 
00081     /// Most controls won't need this, but any that create their own
00082     /// windows should do so at this point.
00083     virtual void   OnParentCreate() = 0;
00084 
00085     /// OnParentDestroy() is called as the parent window is destroyed.
00086     ///
00087     /// Controls that create their own windows during OnParentCreate()
00088     /// should destroy them during OnParentDestroy()
00089     virtual void   OnParentDestroy() = 0;      
00090 };
00091 
00092 #endif // CATWidget_H_

Generated on Mon Feb 11 04:09:57 2008 for Game Accessibility Suite by doxygen 1.5.4