ManaPlus
Public Member Functions | Protected Attributes
PasswordField Class Reference

#include <passwordfield.h>

Inheritance diagram for PasswordField:
TextField Widget FocusListener KeyListener MouseListener WidgetListener Widget2

Public Member Functions

 PasswordField (const Widget2 *const widget, const std::string &text)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
- Public Member Functions inherited from TextField
 TextField (const Widget2 *const widget, const std::string &text, const LoseFocusOnTab loseFocusOnTab, ActionListener *const listener, const std::string &eventId, const bool sendAlwaysEvents)
 
 ~TextField ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void updateAlpha ()
 
void drawFrame (Graphics *const graphics)
 
void safeDrawFrame (Graphics *const graphics)
 
void setNumeric (const bool numeric)
 
void setRange (const int min, const int max)
 
void keyPressed (KeyEvent &event)
 
void setMinimum (const int min)
 
void setMaximum (const int max)
 
int getValue () const
 
void setSendAlwaysEvents (const bool b)
 
void adjustSize ()
 
void adjustHeight ()
 
void setCaretPosition (unsigned int position)
 
void mousePressed (MouseEvent &event)
 
void handlePaste ()
 
void handleCopy () const
 
void focusGained (const Event &event)
 
void focusLost (const Event &event)
 
void moveCaretBack ()
 
void moveCaretForward ()
 
void moveCaretWordBack ()
 
void moveCaretWordForward ()
 
void caretDelete ()
 
void caretDeleteToStart ()
 
void caretDeleteWord ()
 
void setAllowSpecialActions (const bool b)
 
std::string getTextBeforeCaret () const
 
void setText (const std::string &text)
 
const std::string & getText () const
 
unsigned int getCaretPosition () const
 
void mouseDragged (MouseEvent &event)
 
void widgetHidden (const Event &event)
 
void setParent (Widget *widget)
 
void setWindow (Widget *const widget)
 
void signalEvent ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
virtual void logic ()
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
FontgetFont () const
 
void setFont (Font *const font)
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
virtual WidgetgetWidgetAt (int x, int y)
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
- Public Member Functions inherited from FocusListener
virtual ~FocusListener ()
 
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mouseExited (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseMoved (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Protected Attributes

char mPasswordChar
 
- Protected Attributes inherited from TextField
std::string mText
 
TextChunk mTextChunk
 
unsigned int mCaretPosition
 
int mXScroll
 
const ColormCaretColor
 
int mMinimum
 
int mMaximum
 
time_t mLastEventPaste
 
int mPadding
 
bool mNumeric
 
LoseFocusOnTab mLoseFocusOnTab
 
bool mAllowSpecialActions
 
bool mSendAlwaysEvents
 
bool mTextChanged
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from TextField
void drawCaret (Graphics *graphics, int x)
 
void fixScroll ()
 
void fontChanged ()
 
bool handleNormalKeys (const InputActionT action, bool &consumed)
 
void handleCtrlKeys (const InputActionT action, bool &consumed)
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from FocusListener
 FocusListener ()
 
- Protected Member Functions inherited from KeyListener
 KeyListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Static Protected Attributes inherited from TextField
static SkinmSkin
 
static int instances = 0
 
static float mAlpha = 1.0
 
static ImageRect skin
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A password field.

Definition at line 34 of file passwordfield.h.

Constructor & Destructor Documentation

◆ PasswordField()

PasswordField::PasswordField ( const Widget2 *const  widget,
const std::string &  text 
)

Constructor, initializes the password field with the given string.

Definition at line 30 of file passwordfield.cpp.

31  :
32  TextField(widget, text,
33  LoseFocusOnTab_true, nullptr, std::string(), false),
34  mPasswordChar(mSkin != nullptr ? CAST_8(
35  mSkin->getOption("passwordChar", 42)) : CAST_8(42))
36 {
37 }
#define CAST_8
Definition: cast.h:25
int getOption(const std::string &name) const
Definition: skin.h:106
static Skin * mSkin
Definition: textfield.h:258
TextField(const Widget2 *const widget, const std::string &text, const LoseFocusOnTab loseFocusOnTab, ActionListener *const listener, const std::string &eventId, const bool sendAlwaysEvents)
Definition: textfield.cpp:109
const bool LoseFocusOnTab_true

Member Function Documentation

◆ draw()

void PasswordField::draw ( Graphics *const  graphics)
virtual

Draws the password field.

Implements Widget.

Definition at line 39 of file passwordfield.cpp.

40 {
41  BLOCK_START("PasswordField::draw")
42  // std::string uses cow, thus cheap copy
43  const std::string original = mText;
44  if (mPasswordChar != 0)
45  mText.assign(mText.length(), mPasswordChar);
46  else
47  mText.clear();
48  TextField::draw(graphics);
49  mText = original;
51 }
void draw(Graphics *const graphics)
std::string mText
Definition: textfield.h:263
if(!vert) return
void clear()
Definition: playerinfo.cpp:452
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, TextField::draw(), mPasswordChar, and TextField::mText.

Referenced by safeDraw().

◆ safeDraw()

void PasswordField::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 53 of file passwordfield.cpp.

54 {
55  PasswordField::draw(graphics);
56 }

References draw().

Field Documentation

◆ mPasswordChar

char PasswordField::mPasswordChar
protected

Definition at line 53 of file passwordfield.h.

Referenced by draw().


The documentation for this class was generated from the following files: