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

CATControlWnd.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /// \file CATControlWnd.h
00003 /// \brief Window / OS based control class - base object for OS dependant 
00004 /// controls.
00005 /// \ingroup CATGUI
00006 /// 
00007 /// Copyright (c) 2003-2008 by Michael Ellison.
00008 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00009 ///
00010 // $Author: mikeellison $
00011 // $Date: 2008-01-23 01:43:25 -0600 (Wed, 23 Jan 2008) $
00012 // $Revision:   $
00013 // $NoKeywords: $
00014 //---------------------------------------------------------------------------
00015 #ifndef _CATControlWnd_H_
00016 #define _CATControlWnd_H_
00017 
00018 #include "CATControl.h"
00019 
00020 class CATWindow;
00021 class CATControlWnd;
00022 
00023 /// \class CATControlWnd
00024 /// \brief Window / OS based control class - base object for OS dependant 
00025 /// controls.
00026 /// \ingroup CATGUI
00027 class CATControlWnd : public CATControl
00028 {
00029    public:
00030       /// Constructor - mirrors CATXMLObject() constructor for now.
00031       CATControlWnd(  const CATString&               element, 
00032                       const CATString&               rootDir);
00033 
00034       virtual ~CATControlWnd();
00035 
00036       virtual CATWND GetControlWndHndl()
00037       {
00038          return fControlWnd;
00039       }
00040       
00041       /// SetFocused() sets the control's focused state.
00042       ///
00043       /// \param focused - if true, then the control is given focus.
00044       ///                  if false, focus is removed.      
00045         virtual void        SetFocused(bool focused);
00046 
00047       /// MarkDirty() marks the control as dirty (needing to be redrawn)
00048       ///
00049       /// \param dirtyRect - if specified, marks only part of the rectangle
00050         /// \param force - if true, forces invalidation even if the control isn't visible
00051       virtual void        MarkDirty(CATRect* dirtyRect = 0, bool force = false);
00052 
00053       /// Draw() draws the control into the parent's image
00054       /// \param image - image to draw into
00055       /// \param dirtyRect - portion of control (in window coordinates)
00056       ///        that requires redrawing.
00057       virtual void Draw(CATImage* image, const CATRect& dirtyRect);
00058 
00059       /// Event handler
00060       virtual CATResult OnEvent(const CATEvent& event, CATInt32& retVal);
00061 
00062       /// PostDraw() draws any stuff that requires an OS-specific draw
00063       /// context.
00064       virtual void   PostDraw(CATDRAWCONTEXT drawContext, const CATRect& dirtyRect);
00065 
00066       // Retrieve post-draw exclusion rects
00067       virtual bool         GetPostRects(CATStack<CATRect>& rectStack);
00068 
00069       /// OnParentCreate() is called when the parent window is created.
00070       /// 
00071       /// Most controls won't need this, but any that create their own
00072       /// windows should do so at this point.
00073       virtual void   OnParentCreate();
00074 
00075       /// OnParentDestroy() is called as the parent window is destroyed.
00076       ///
00077       /// Controls that create their own windows during OnParentCreate()
00078       /// should destroy them during OnParentDestroy()
00079       virtual void   OnParentDestroy();
00080 
00081         virtual void   SetVisible(bool visible);
00082 
00083       /// RectFromAttribs() recalculates the control's rectangle from
00084       /// the attributes.  This can only be called after ParseAttributes() has
00085       /// loaded the images.
00086       virtual CATResult    RectFromAttribs();
00087       
00088       /// GetColorFore() retrieves the foreground color for the control
00089       /// \return CATColor - foreground color
00090       virtual CATColor     GetColorFore() const;
00091 
00092       /// GetColorBack() retrieves the background color for the control
00093       /// \return CATColor - background color
00094       virtual CATColor     GetColorBack() const;
00095 
00096 
00097       /// Win-32 specific control stuff
00098       #ifdef CAT_CONFIG_WIN32
00099          HBRUSH   GetBGBrush();
00100 
00101          static LRESULT WINAPI CustomControlProc( HWND hWnd, 
00102                                                    UINT message, 
00103                                                    WPARAM wParam, 
00104                                                    LPARAM lParam);
00105 
00106          // Foreground brush
00107          HBRUSH   fFGBrush;
00108          HBRUSH   fFGFocBrush;
00109          HBRUSH   fFGDisBrush;
00110 
00111          // Background brush
00112          HBRUSH   fBGBrush;         
00113          HBRUSH   fBGFocBrush;
00114          HBRUSH   fBGDisBrush;
00115 
00116          
00117 
00118 
00119          /// Old window proc
00120          CATInt32 fOldWndProc;
00121 
00122          CATString fWindowType;
00123          CATUInt32  fWindowStyle;
00124       
00125       #endif // CAT_CONFIG_WIN32
00126 
00127       /// Load() loads the skin in
00128       virtual        CATResult Load(    CATPROGRESSCB               progressCB   = 0,
00129                                                 void*                           progressParam= 0,
00130                                                 CATFloat32                      progMin      = 0.0f,
00131                                                 CATFloat32                      progMax      = 1.0f);   
00132 
00133       /// OnEscapeChange() is called if a control looses focus by
00134       /// the user pressing the ESC key.  If the control supports it,
00135       /// it should reset the value to its previous one.
00136       virtual void            OnEscapeChange() {}
00137 
00138       virtual void   SetEnabled(bool enabled);
00139       virtual void   OSSetText(const CATString& newText);
00140       virtual void   OSGetText(CATString& getText);
00141 
00142       virtual CATString GetHint() const;
00143 
00144    protected:            
00145       CATRect   fWndRect;
00146       
00147       /// Draw a border around the control
00148       virtual void OSDrawBorderRect(CATDRAWCONTEXT drawContext, CATRect& rect);
00149 
00150       /// ParseAttributes() parses the known attributes for an object.
00151       virtual CATResult ParseAttributes();
00152 
00153       /// OS-specific control creation / cleanup
00154       virtual CATResult OSCreate();
00155       virtual void OSCleanup();
00156 
00157       CATWND       fControlWnd;
00158 
00159       // member event handler that can be overridden.
00160       // returns true if the event is handled by the control.
00161       virtual bool OnControlEvent(const CATEvent& event, CATInt32& returnVal);
00162 
00163       // Create the control's window
00164       CATResult CreateControlWnd( const CATString&   windowClass, 
00165                                  CATUInt32           style );
00166 
00167             
00168       /// Foreground color - selected
00169       CATColor     fFGColor_focus;
00170       CATColor     fBGColor_focus;
00171 
00172       /// Foreground color - border
00173       CATColor     fFGColor_border;
00174       CATColor     fBGColor_border;
00175 
00176       bool        fFocusSet;
00177       bool        fBorderSet;
00178 
00179       bool        fCaptured;
00180 };
00181 
00182 #endif // _CATControlWnd_H_
00183 
00184 

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