#ifndef __VDRICQTOOLS_H
#define __VDRICQTOOLS_H

#include <string>
#include <vdr/osd.h>
#include <vdr/menuitems.h>
#include <vdr/thread.h>
#include "Window.h"

using namespace std;

#define MAXTEXTLENGHT 512

class cStatusbarWnd;


class cEditField
{
public:
  cEditField(int iLeft, int iTop, int iWidth, int iHeight, int iLength, cWnd *pParent, cOsd *pOsd, 
             cStatusbarWnd *pStatusbarWnd, int iTextInputmode = 0);
  virtual ~cEditField(void);

  void Draw(void);
  eOSState ProcessKey(eKeys Key);
	void SetText(char *pText);
  void SetStyle(tColor iBorderColor, tColor iFocusedBorderColor, tColor iBGColor, tColor iTextColor, cFont *pFont);
  string GetText();
  void SetFocused(bool bFocused);
  bool IsFocused();
  bool Editing() { return (m_iPos >= 0); };

  virtual bool OnTextChanged(string& sText);

private:
  int     m_iLeft;
  int     m_iTop;
  int     m_iWidth;
  int     m_iHeight;
  int     m_iLength;
  cWnd    *m_pParent;
  cOsd  *m_pOsd;
  int     m_iTextInputmode;
  int     m_iCursorPos;
  int     m_iScrollPos;
  char    m_Value[MAXTEXTLENGHT];
  char    m_OutValue[MAXTEXTLENGHT + 5];
  int     m_iPos;
  bool    m_bInsert, m_bNewchar, m_bUppercase;
  tKey*   m_pSelectedkey;
  int     m_iSelectedchar;
  int     m_iSelectedkeyinfo;
  tColor  m_iBorderColor;
  tColor  m_iFocusedBorderColor;
  tColor  m_iBGColor;
  tColor  m_iTextColor;
  cFont   *m_pFont;
  bool    m_bFocused;
  cStatusbarWnd *m_pStatusbarWnd;

  void SelectChar(int CharPos);
  void KeyRightPressed();
  void Set(void);
  void SetHelpKeys(void);
  char Inc(char c, bool Up);

};


#endif // __VDRICQTOOLS_H
