Show textarea.h syntax highlighted
/***************************************************************************
textarea.h - Area object with text
-------------------
begin : Tue Jan 7 2003
copyright : (C) 2003 by Mattias Jansson
email : mattias@realityrift.com
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the NeoEngine, NeoWTK, textarea.h
The Initial Developer of the Original Code is Mattias Jansson.
Portions created by Mattias Jansson are Copyright (C) 2002
Reality Rift Studios. All Rights Reserved.
***************************************************************************/
#ifndef __NEOWTKTEXTAREA_H
#define __NEOWTKTEXTAREA_H
#include "base.h"
#include "area.h"
#include <neoengine/font.h>
#ifdef HAVE_NEOCHUNKIO
# include <neochunkio/complex.h>
# include "chunktype.h"
#endif
/**
* \file textarea.h
* A textarea is a simple area object with a text
*/
namespace NeoWTK
{
/**
* \class TextArea
* \brief Area object with text
* \author Mattias Jansson (mattias@realityrift.com)
*/
class NEOWTK_API TextArea : public Area
{
protected:
/*! Font */
NeoEngine::FontPtr m_pkFont;
/*! Text padding */
Coord m_kPadding;
/*! Font color */
NeoEngine::Color m_kFontColor;
public:
/*! Text */
std::string m_strText;
/*! Password */
bool m_bPassword;
/**
* \param pkParent Parent object
* \param pkObject Reference object to copy values from
*/
TextArea( Object *pkParent, TextArea *pkObject = 0 );
/**
*/
virtual ~TextArea();
/**
* Set an attribute
* \param rkAttribute Attribute
*/
virtual void SetAttribute( const AttributeBase &rkAttribute );
/**
* Set text
* \param rstrText Text
*/
virtual void SetText( const std::string &rstrText );
/**
* \return Text
*/
virtual const std::string &GetText();
/**
* Set font
* \param pkFont New font
*/
virtual void SetFont( NeoEngine::FontPtr pkFont );
/**
* \return Current font
*/
virtual NeoEngine::FontPtr GetFont();
/**
* \param rkColor New font color to use
*/
virtual void SetFontColor( const NeoEngine::Color &rkColor );
/**
* \return Current font color
*/
const NeoEngine::Color &GetFontColor();
/**
* Render object, recurses on children
* \param pkFrustum Currently ignored
* \param bForce Force rendering
* \return true if rendered, false if not
*/
virtual bool Render( NeoEngine::Frustum *pkFrustum = 0, bool bForce = false );
/**
* Set text padding
* \param rkPadding Padding in pixels
*/
virtual void SetTextPadding( const Coord &rkPadding );
/**
* Get text padding
* \return Padding in pixels
*/
virtual const Coord &GetTextPadding();
/**
* Duplicate and/or copy this object
* \param pkParent Parent object to attach to
* \param pkObject Object to copy data into, if null will allocate new object
* \return New object that is duplicate of this object
*/
virtual Object *Duplicate( Object *pkParent = 0, Object *pkObject = 0 );
};
#ifdef HAVE_NEOCHUNKIO
/**
* \class TextAreaChunk
* \brief Base chunk for text area objects
* \author Mattias Jansson (mattias@realityrift.com)
*/
class NEOWTK_API TextAreaChunk : public AreaChunk
{
public:
/**
* Initialize chunk
* \param usType Chunk type
* \param rstrType Chunk type as string
* \param rstrID Chunk ID string
*/
TextAreaChunk( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID = "" ) : AreaChunk( usType, rstrType, rstrID ) {}
/**
* Deallocate data and subchunks
*/
virtual ~TextAreaChunk() {}
/**
* Parse chunk data
* \param uiFlags Parse flags
* \param pkFileManager File manager
* \return <0 if error, >0 if successful (0 reserved)
*/
virtual int ParseData( unsigned int uiFlags, NeoEngine::FileManager *pkFileManager );
/**
* Allocate new chunk
* \param usType Type identifier
* \param rstrType Type identifier as string
* \param rstrID ID string
* \return New chunk
*/
static NeoChunkIO::Chunk *Allocator( unsigned short usType, const NeoEngine::HashString &rstrType, const NeoEngine::HashString &rstrID ) { return new TextAreaChunk( usType, rstrType, rstrID ); }
};
#endif /*! HAVE_NEOCHUNKIO */
}; /*! namespace NeoWTK */
#endif
See more files for this project here