If you have comments or questions concerning this source file, discuss them in the forum.
/*
Copyright (c) 2002 Nicolai Haehnle

See the license.txt for details. If that file was not included in the
source distributions, please email <prefect@rtts.org>
*/
// gui_inputbox.h

#ifndef GUI_INPUTBOX_H
#define GUI_INPUTBOX_H

#include "gui_label.h"

/*
Note, the input box doesn't support multiline right now
*/

#define im_string       0
#define im_integer      1

class GInputBox : public GLabel {
public:
    int     m_iMaxLen;      // -1 means infinite
    int     m_iCursorPos;
    int     m_iCursorTime;  // for blinking

    int     m_iMode;
    int     m_iMin, m_iMax;

public:
    GInputBox(GPanel *pParent, int x, int y, int w, int h, const char *text = 0, int align = 0);

    LSignal Changed;

    void SetMaxLen(int iMaxLen);
    void SetModeInteger(int min, int max);

    bool IsValid();

    void BoundCursor();
    void InputChar(char c);
    void DeleteChar();
    void SetCursorPos(int pos);
    void MoveCursor(int n);

    virtual void Draw();

    virtual void GainFocus(bool bGain);
    virtual bool Key(int code, char c, bool down);

protected:
    void ScrollToCursor();
};

#endif // GUI_INPUTBOX_H