#ifndef __DISPLAYMENU_H
#define __DISPLAYMENU_H

#include <vdr/skins.h>
#include "scroll.h"
#include "setup.h"

//for epgimages
#ifdef HAVE_IMAGEMAGICK
class cEpgImage : public cThread {
private:
    virtual void Action(void);
#if VDRVERSNUM >= 10344
    u_int32_t eventid;
#else
    u_int16_t eventid;
#endif
    int x, y, imagenumber, pid;
    bool moreimages;
    char *direventid;
    char *filename;
    const char *filetype;
    FILE *file;
public:
    cEpgImage(void);
    ~cEpgImage();
    cBitmap *bmpEpgImage;
    bool first;
    cTimeMs ShowTime;
    uint64 epgshowtime;
#if VDRVERSNUM >= 10344
    u_int32_t loading;
    u_int32_t imageready;
#else
    u_int16_t loading;
    u_int16_t imageready;
#endif
};
#endif
//

class cUpdate : public cThread {
private:
    virtual void Action(void);
    int pid;
public:
    cUpdate(void);
    ~cUpdate();
    void Update(void);
    cOsd *UpdateOsd;
    bool noflush;
    void lock();
    void unlock();
    cCondWait Wait;
};

class cSkinElchiDisplayMenu : public cSkinDisplayMenu {
private:
    cOsd *osd;
    void ReInit(int X1, int Y1, int X2, int Y2);
    void Show(void);
    const cFont *font;
    const cFont *smallfont;
//for epgimages
#ifdef HAVE_IMAGEMAGICK
    void ShowEpgImage(void);
#endif
//
    void SetScrollbar(void);
    bool message, showVolume, noflush;
    cTimeMs volume;
    int oldvolume, volumechange;
    int x0, x1, x2, /*x3,*/ x4, x5, x6, x7, x8;
    int y0, y1, y2, y3, y4, y5, y6, y7, y8, y9;
    int lh, roundness, menuTop, menuHeight, currentIndex, area;
    char *olddate;
    char *olditem;
#if VDRVERSNUM >= 10344
    u_int32_t eventID;
#else
    u_int16_t eventID;
#endif
    int timer;
//for epgimages
#ifdef HAVE_IMAGEMAGICK
#if VDRVERSNUM >= 10344
    u_int32_t loading;
#else
    u_int16_t loading;
#endif
    bool bit;
    int setitem, item1index, item2index;//for direct switching in epgsearch 0.9.3
    char * item1text;
    char * item2text;
    bool item1current, item2current, item1selectable, item2selectable;//END for direct switching in epgsearch 0.9.3
#endif
//
    void Update(void);
public:
    cSkinElchiDisplayMenu(void);
    virtual ~cSkinElchiDisplayMenu();
    virtual void Scroll(bool Up, bool Page);
    virtual int MaxItems(void);
    virtual void Clear(void);
    virtual void SetTitle(const char *Title);
    virtual void SetButtons(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL);
    virtual void SetMessage(eMessageType Type, const char *Text);
    virtual void SetItem(const char *Text, int Index, bool Current, bool Selectable);
    virtual void SetEvent(const cEvent *Event);
    virtual void SetRecording(const cRecording *Recording);
    virtual void SetText(const char *Text, bool FixedFont);
#if VDRVERSNUM >= 10342
    virtual int GetTextAreaWidth(void) const;
    virtual const cFont *GetTextAreaFont(bool FixedFont) const;
#endif
    virtual void Flush(void);
//for epgimages
#ifdef HAVE_IMAGEMAGICK
    cEpgImage *epgimage;
#endif
    cUpdate *update;
//
};

#endif //__DISPLAYMENU_H
