#ifndef __VDRICQOSD_H
#define __VDRICQOSD_H


#include <vdr/osd.h>
#include <vdr/menuitems.h>

#define STATUSCOUNT 8

static const cFont *font    = cFont::GetFont(fontOsd);
static const cFont *smlfont = cFont::GetFont(fontSml);
static const int LINEHEIGHT    = font->Height();
static const int SMLLINEHEIGHT = smlfont->Height();

class SimpleClient;
class cTitlebarWnd;
class cMessagelistWnd;
class cMessageWnd;
class cContactWnd;
class cStatusbarWnd;

enum ESelectedWindow { swTitlebar, swMessage, swMessageList, swContact };

class cVdrIcqOsd : public cThread, public cOsdObject {
private:
	cOsd *m_pOsd;
	SimpleClient *m_pIcqClient;
  bool m_bRunning;
  bool m_bShutdown;
  eKeys m_LastKey;
  bool  m_bInterrupted;
  bool  m_bWaiting;
  cBitmap *pStatusBitmaps[STATUSCOUNT];

  cTitlebarWnd    *m_pTitlebarWnd;
  cMessagelistWnd *m_pMessagelistWnd;
  cMessageWnd     *m_pMessageWnd;
  cContactWnd     *m_pContactWnd;
  cStatusbarWnd   *m_pStatusbarWnd;
  ESelectedWindow m_eSelectedWindow;
  ESelectedWindow m_eLastSelectedWindow;
  
public:
	cVdrIcqOsd(SimpleClient *pIcqClient);
	~cVdrIcqOsd();
	virtual void Show(void);
	virtual eOSState ProcessKey(eKeys Key);
	
  void SetSelectedWindow(ESelectedWindow eSelectedWindow);
  void SetLastSelectedWindow() { m_eSelectedWindow = m_eLastSelectedWindow; }
  ESelectedWindow GetSelectedWindow() { return m_eSelectedWindow; }
	void ClearBitmap(void);
	
	void DrawMenu();
	void DisplayBitmap(void); 
	static void *Run(void *process);

  void DrawTitlebarWnd();
  void DrawMessagelistWnd();
  void DrawMessageWnd();
  void DrawContactWnd();

  const cBitmap *GetStatusBitmap(int iBmpNr) { return pStatusBitmaps[iBmpNr]; }

  void Interrupt(void) { m_bInterrupted = true; }
  eKeys Wait(int Seconds, bool KeepChar = false);

  cMessageWnd *GetMessageWnd()         { return m_pMessageWnd; }
  cMessagelistWnd *GetMessagelistWnd() { return m_pMessagelistWnd; }
  cTitlebarWnd    *GetTitlebarWnd()    { return m_pTitlebarWnd;    }

  static cMutex OsdMutex;

protected:
	virtual void Action(void);
};



#endif // __VDRICQOSD_H
