EditWidget Class Reference

#include <EditWidget.h>

Inheritance diagram for EditWidget:

Gump Object List of all members.

Public Types

 EDIT_ENTER = 16
 EDIT_ESCAPE = 17
enum  Message { EDIT_ENTER = 16, EDIT_ESCAPE = 17 }

Public Member Functions

 ENABLE_RUNTIME_CLASSTYPE ()
 EditWidget (int X, int Y, std::string txt, bool gamefont, int fontnum, int width, int height, unsigned int maxlength=0, bool multiline=false)
virtual ~EditWidget (void)
virtual void InitGump (Gump *newparent, bool take_focus=true)
virtual void PaintThis (RenderSurface *, sint32 lerp_factor, bool scaled)
virtual void PaintComposited (RenderSurface *surf, sint32 lerp_factor, sint32 sx, sint32 sy)
virtual GumpOnMouseMotion (int mx, int my)
virtual bool OnKeyDown (int key, int mod)
virtual bool OnKeyUp (int key)
virtual bool OnTextInput (int unicode)
std::string getText () const
void setText (const std::string &t)

Protected Member Functions

void ensureCursorVisible ()
bool textFits (std::string &t)
void renderText ()
Pentagram::FontgetFont () const

Protected Attributes

std::string text
std::string::size_type cursor
bool gamefont
int fontnum
unsigned int maxlength
bool multiline
uint32 cursor_changed
bool cursor_visible
RenderedTextcached_text

Detailed Description

Definition at line 34 of file EditWidget.h.


Member Enumeration Documentation

enum EditWidget::Message

Enumerator:
EDIT_ENTER 
EDIT_ESCAPE 

Definition at line 58 of file EditWidget.h.


Constructor & Destructor Documentation

EditWidget::EditWidget ( int  X,
int  Y,
std::string  txt,
bool  gamefont,
int  fontnum,
int  width,
int  height,
unsigned int  maxlength = 0,
bool  multiline = false 
)

Definition at line 33 of file EditWidget.cpp.

References cursor, and text.

EditWidget::~EditWidget ( void   )  [virtual]

Definition at line 42 of file EditWidget.cpp.

References cached_text.


Member Function Documentation

EditWidget::ENABLE_RUNTIME_CLASSTYPE (  ) 

Reimplemented from Gump.

void EditWidget::ensureCursorVisible (  )  [protected]

Definition at line 83 of file EditWidget.cpp.

References cursor_changed, and cursor_visible.

Referenced by OnKeyDown().

Pentagram::Font * EditWidget::getFont (  )  const [protected]

Definition at line 68 of file EditWidget.cpp.

References fontnum, gamefont, FontManager::get_instance(), FontManager::getGameFont(), and FontManager::getTTFont().

Referenced by InitGump(), PaintComposited(), PaintThis(), renderText(), and textFits().

std::string EditWidget::getText (  )  const [inline]

get the current text

Definition at line 55 of file EditWidget.h.

References text.

Referenced by U8SaveGump::ChildNotify(), and MenuGump::ChildNotify().

void EditWidget::InitGump ( Gump newparent,
bool  take_focus = true 
) [virtual]

Init the gump and add it to parent; call after construction When newparent is 0, this will call GUIApp::addGump().

Parameters:
newparent The Gump's new parent or 0.
takefocus If true, set parent's focus_child to this

Reimplemented from Gump.

Definition at line 49 of file EditWidget.cpp.

References Gump::dims, font, gamefont, getFont(), Gump::InitGump(), Gump::ROUND_OUTSIDE, Gump::ScreenSpaceToGumpRect(), Gump::x, Pentagram::Rect::x, Gump::y, and Pentagram::Rect::y.

Referenced by U8SaveGump::InitGump().

bool EditWidget::OnKeyDown ( int  key,
int  mod 
) [virtual]

Reimplemented from Gump.

Definition at line 194 of file EditWidget.cpp.

References cached_text, Gump::ChildNotify(), cursor, EDIT_ENTER, EDIT_ESCAPE, ensureCursorVisible(), Gump::parent, and text.

bool EditWidget::OnKeyUp ( int  key  )  [virtual]

Reimplemented from Gump.

Definition at line 238 of file EditWidget.cpp.

Gump * EditWidget::OnMouseMotion ( int  mx,
int  my 
) [virtual]

Reimplemented from Gump.

Definition at line 189 of file EditWidget.cpp.

bool EditWidget::OnTextInput ( int  unicode  )  [virtual]

Reimplemented from Gump.

Definition at line 244 of file EditWidget.cpp.

References cached_text, cursor, maxlength, Pentagram::reverse_encoding, text, and textFits().

void EditWidget::PaintComposited ( RenderSurface surf,
sint32  lerp_factor,
sint32  sx,
sint32  sy 
) [virtual]

Overloadable method to Paint just this gumps unscaled components that require compositing (RenderSurface is relative to parent).

Reimplemented from Gump.

Definition at line 171 of file EditWidget.cpp.

References cached_text, Gump::dims, RenderedText::draw(), RenderSurface::FillAlpha(), font, gamefont, getFont(), Gump::GumpRectToScreenSpace(), Gump::GumpToScreenSpace(), Pentagram::Rect::h, Gump::ROUND_BOTTOMRIGHT, Gump::ROUND_OUTSIDE, Pentagram::Rect::w, Pentagram::Rect::x, Gump::x, Pentagram::Rect::y, and Gump::y.

void EditWidget::PaintThis ( RenderSurface ,
sint32  lerp_factor,
bool  scaled 
) [virtual]

Overloadable method to Paint just this Gump (RenderSurface is relative to this).

Reimplemented from Gump.

Definition at line 155 of file EditWidget.cpp.

References cached_text, Gump::dims, RenderedText::draw(), RenderSurface::FillAlpha(), gamefont, getFont(), Pentagram::Rect::h, Gump::PaintThis(), renderText(), Pentagram::Rect::w, Pentagram::Rect::x, and Pentagram::Rect::y.

void EditWidget::renderText (  )  [protected]

Definition at line 118 of file EditWidget.cpp.

References cached_text, cursor, cursor_changed, cursor_visible, Gump::dims, font, gamefont, getFont(), Gump::GumpRectToScreenSpace(), Pentagram::Rect::h, Gump::IsFocus(), multiline, Gump::ROUND_INSIDE, text, Pentagram::Font::TEXT_LEFT, Pentagram::Rect::w, Gump::x, and Gump::y.

Referenced by PaintThis().

void EditWidget::setText ( const std::string &  t  ) 

Definition at line 76 of file EditWidget.cpp.

References cached_text, cursor, and text.

Referenced by U8SaveGump::ChildNotify().

bool EditWidget::textFits ( std::string &  t  )  [protected]

Definition at line 89 of file EditWidget.cpp.

References Gump::dims, font, gamefont, getFont(), Gump::GumpRectToScreenSpace(), Pentagram::Rect::h, height, multiline, Gump::ROUND_INSIDE, Gump::ROUND_OUTSIDE, Gump::ScreenSpaceToGumpRect(), Pentagram::Font::TEXT_LEFT, Pentagram::Rect::w, width, Gump::x, and Gump::y.

Referenced by OnTextInput().


Member Data Documentation

RenderedText* EditWidget::cached_text [protected]

Definition at line 81 of file EditWidget.h.

Referenced by OnKeyDown(), OnTextInput(), PaintComposited(), PaintThis(), renderText(), setText(), and ~EditWidget().

std::string::size_type EditWidget::cursor [protected]

Definition at line 67 of file EditWidget.h.

Referenced by EditWidget(), OnKeyDown(), OnTextInput(), renderText(), and setText().

uint32 EditWidget::cursor_changed [protected]

Definition at line 73 of file EditWidget.h.

Referenced by ensureCursorVisible(), and renderText().

bool EditWidget::cursor_visible [protected]

Definition at line 74 of file EditWidget.h.

Referenced by ensureCursorVisible(), and renderText().

int EditWidget::fontnum [protected]

Definition at line 69 of file EditWidget.h.

Referenced by getFont().

bool EditWidget::gamefont [protected]

Definition at line 68 of file EditWidget.h.

Referenced by getFont(), InitGump(), PaintComposited(), PaintThis(), renderText(), and textFits().

unsigned int EditWidget::maxlength [protected]

Definition at line 70 of file EditWidget.h.

Referenced by OnTextInput().

bool EditWidget::multiline [protected]

Definition at line 71 of file EditWidget.h.

Referenced by renderText(), and textFits().

std::string EditWidget::text [protected]

Definition at line 66 of file EditWidget.h.

Referenced by EditWidget(), getText(), OnKeyDown(), OnTextInput(), renderText(), and setText().


The documentation for this class was generated from the following files:
Generated on Fri Jul 27 22:29:09 2007 for pentagram by  doxygen 1.4.7