Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

MUIWidget.h

00001 /**********************************************************************
00002 
00003 Copyright (c) 2005, TomTom B.V.
00004 
00005 All rights reserved
00006 
00007 
00008 ***********************************************************************/
00009 
00010 
00011 #ifndef __MUIWIDGET_H__
00012 #define __MUIWIDGET_H__
00013 
00014 #include "TTUIBase.h"
00015 #include "MColorScheme.h"
00016 #include "MInputReader.h"
00017 #include "MFont.h"
00018 #include "CDesktop.h"
00019 #include "MVirtualScreen.h"
00020 #include "MUISkin.h"
00021 
00022 class CUIWidgetGroup;
00023 
00032 class MUIWidget
00033 {
00034  public:
00040   class MUIWidgetEvents
00041   {
00042    public:
00048     virtual void FiredPressEvent( MUIWidget& aSource ) = 0;
00049 
00050     virtual ~MUIWidgetEvents() {}
00051   };
00052 
00053  public:
00064            MUIWidget( const CUIRect&         aRectangle, 
00065                       const char*            aTitle, 
00066                             MUIWidgetEvents* aObserver );
00067 
00068   virtual ~MUIWidget();
00069 
00070   // Principal methods
00071 
00079   virtual void Draw()                                                 = 0;
00080 
00097   virtual bool HandlePenEvent( MInputReader::TTouchEventData& aData ) = 0;
00098 
00109   virtual bool HandleKeyEvent( MInputReader::TKeyEventData& aData )   = 0;
00110 
00111   // Setter methods
00112   
00117   virtual void SetTitle( const char* aTitle );
00118 
00124   virtual void SetColorScheme( MColorScheme* aColorScheme );
00125 
00126 
00132   virtual void SetFont( MFont* aFont );
00133 
00139   virtual bool SetEnabled( bool aEnabled );
00140 
00145   virtual void SetToolTip( const char* aToolTip );
00146 
00154   virtual bool SetActive( bool aActive );
00155 
00161   virtual bool IsVisible();
00162 
00163  public:
00165   enum               { KRoundRadius = 4 };
00166 
00167 
00169   enum EDrawTextOption { KCenterX     = 0x01, 
00170                          KCenterY     = 0x02, 
00173                          KMultiLine   = 0x04, 
00176                          KSplitString = 0x08, 
00180   };
00181 
00182   typedef unsigned int EDrawTextOptions; 
00193   bool DrawText( const char* aText, const CUIPoint& aPoint, CDesktop::TColor aColor );
00194 
00205   bool DrawTextCentered( const char* aText, const CUIRect& aRect, CDesktop::TColor aColor, EDrawTextOptions aOptions );
00206 
00222   bool DrawTextEx( const char* aText, const CUIRect& aRect, CDesktop::TColor aColor, EDrawTextOptions aOptions  );
00223   
00224  private:
00225   enum { KMultiLinePixelOffset = 5 };
00226 
00227   unsigned int DrawMultiLine( unsigned int aX, unsigned int aY, unsigned int aSizeX, const CUIRect& aRect, char* aText, CDesktop::TColor aColor, EDrawTextOptions aOptions );
00228   
00229  public: 
00230         CUIRect              iRectangle;        
00231         MColorScheme const*  iColorScheme;      
00233         MUIWidgetEvents*     iObserver;         
00234   const char*                iTitle;            
00236         EDrawTextOptions     iTitleOptions;     
00237         MFont const*         iFont;             
00239         bool                 iEnabled;          
00240   const char*                iToolTip;          
00242         bool                 iActive;           
00243         MUISkin::EFontType   iSkinFontType;     
00244         int                  iTag;              
00245         MVirtualScreen&      iFrameBuffer;      
00247         CUIWidgetGroup*      iParent;           
00249  public:
00253   MFont*        GetFont()        const 
00254     { 
00255       return 
00256        ( NULL != iFont ) ?
00257         const_cast< MFont* >( iFont ):
00258         MUISkin::GetCurrentSkin()->GetFont( iSkinFontType );
00259   }
00260 
00264   MColorScheme* GetColorScheme() const 
00265   { 
00266    return 
00267     ( NULL != iColorScheme ) ?  
00268      const_cast< MColorScheme* >( iColorScheme ):
00269      MUISkin::GetCurrentSkin()->GetColorScheme();
00270   }
00271 };
00272 
00273 #endif
00274 

Generated on Fri Jul 15 16:46:44 2005 for TomTom GO User Interface library by doxygen 1.3.5