/* $Id: areaitem.hpp,v 1.5 2005/06/28 13:55:16 chfreund Exp $ */ #ifndef _AREAITEM_HPP_ #define _AREAITEM_HPP_ /**********************************************************/ #include "itemset.hpp" /**********************************************************/ class AreaItem : public Item { public: //! default constructor AreaItem(); //! copy constructor AreaItem( const AreaItem &item ); //! constructor with values for RECTANGLE AreaItem( const Sint32 ID, const Sint32 x, const Sint32 y, const Sint32 w, const Sint32 h ); //! constructor with values for CIRCLE AreaItem( const Sint32 ID, const Sint32 x, const Sint32 y, const Sint32 r ); virtual ~AreaItem(); //! \name data access //@{ //! returns the ID (enumeration constant for area type) Sint32 getID() const { return m_AreaID; } //! returns the ID string const char* getIDString() const { return m_IDStrings[m_AreaID]; } //! returns the x coordinate Sint32 getX() const { return m_x; } //! returns the y coordinate Sint32 getY() const { return m_y; } //! returns the width value Sint32 getWidth() const { return m_width; } //! returns the height value Sint32 getHeight() const { return m_height; } //! returns the radius value Sint32 getRadius() const { return m_radius; } //! returns the content of the area real getContent() const; //@} //! \name operations //@{ //! shift the area by the passed coordinates void shift( const Sint32 dx, const Sint32 dy ); //@} //! \name analyse methods //@{ //! returns true, if the passed point lies inside this area bool isInside( const Sint32 x, const Sint32 y ) const; //! returns true, if the passed rectangle touches this area bool touchesRect( const Sint32 x, const Sint32 y, const Sint32 w, const Sint32 h ) const; //@} //! virtual bool readFromSettings( SettingDataBase &settings, Sint32 &pos ); //! returns a pointer to the setting definitions static const SettingDef* getSettingDef() { return m_SettingDef; } //! constants for area type enum { INVALID_AREA = -1, RECTANGLE, CIRCLE, NUM_AREAS }; protected: Sint32 m_AreaID, m_x, m_y, m_width, m_height, m_radius; static const SettingDef m_SettingDef[NUM_AREAS+1]; static const char* m_IDStrings[NUM_AREAS]; }; /**********************************************************/ typedef ItemSet AreaSet; /**********************************************************/ #endif // _AREAITEM_HPP_