summaryrefslogtreecommitdiff
path: root/menu.h
blob: 002bad8f3853064fadfd7cca1e28ee5ea740efea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef __MENU_DVDSWITCH_H
#define __MENU_DVDSWITCH_H

#include <vdr/osdbase.h>
#include "menu-item.h"
#include "dvdlist.h"

enum eMainMenuState
{
  mmsNone,
  mmsReInit,
  mmsReInitCur,
  mmsImgRename,
};

class cCMDImage;

class cMainMenu : public cOsdMenu
{
  private:
    int FirstSelectable;
    eMainMenuState State;
    cCMDImage *CMDImg;

    void Init(void);
    void SetMenuTitle(void);
    void Build(char *dir);
    void BuildDisp0(char *dir);
    void BuildDisp1(char *dir);
    void BuildDisp2(char *dir);
    eOSState MenuMove(eKeys Key);
    eOSState SelectItem(void);
    eOSState Commands(eKeys Key);
  public:
    cMainMenu(void);
    ~cMainMenu(void);
    void SetHelp(void);
    virtual eOSState ProcessKey(eKeys Key);

    static char *CreateOSDName(eMainMenuItem itype, char *file = NULL);
    void SetState(eMainMenuState state);
    eMainMenuState GetState(void) { return State; };
};

class cDirHandlingOpt
{
  char *IDir;
  char *CDir;
  char *PDir;
  char *LSDir;
  char *LSItemName;
  eMainMenuItem LSItemType;

  public:
    cDirHandlingOpt(void)
    {
      IDir = NULL;
      CDir = NULL;
      PDir = NULL;
      LSDir = NULL;
      LSItemName = NULL;
      LSItemType = iCat;
    }
    ~cDirHandlingOpt(void)
    {
      free(IDir);
      free(CDir);
      free(PDir);
      free(LSDir);
      free(LSItemName);
    }
    char *ImageDir(char *dir = NULL)
    {
      if(dir)
      {
        FREENULL(IDir);
        IDir = strdup(dir);
      }
      return IDir;
    }
    char *CurrentDir(char *dir = NULL)
    {
      if(dir)
      {
        FREENULL(CDir);
        CDir = strdup(dir);
      }
      return CDir;
    }
    char *ParentDir(char *dir = NULL)
    {
      if(dir)
      {
        FREENULL(PDir);
        PDir = strdup(dir);
      }
      return PDir;
    }
    char *LastSelDir(char *dir = NULL)
    {
      if(dir)
      {
        FREENULL(LSDir);
        LSDir = strdup(dir);
      }
      return LSDir;
    }
    bool isParent(char *dir)
    {
      if(dir && PDir && strcasecmp(dir, PDir))
        return true;
      return false;
    }
    bool isLastSel(char *dir)
    {
      if(dir && LSDir && !strcasecmp(dir, LSDir))
        return true;
      return false;
    }
    void setLastSelectItemName(char *filename = NULL)
    {
      FREENULL(LSItemName);
      if(filename)
        LSItemName = strdup(filename);
    };
    char *getLastSelectItemName(void) { return LSItemName; }
    eMainMenuItem LastSelectItemType(eMainMenuItem type = iCat)
    {
      if(type != iCat)
        LSItemType = type;
      return LSItemType;
    }
};

class cDirHandling
{
  private:
    cOsdMenu *OsdObject;
    cDirHandlingOpt *DirObject;
  public:
    cDirHandling(cOsdMenu *osdobject, cDirHandlingOpt *dirobject);

    int Build(char *dir, bool emptydirs);
    void ProcessKey(cMainMenuItem *mItem);
};

extern cDirHandlingOpt MainMenuOptions;

#endif // __MENU_DVDSWITCH_H