1 2 #ifndef _DIALOG_H 3 #define _DIALOG_H 4 5 #include "options.h" 6 7 #include <vector> 8 namespace Options 9 { 10 11 struct ODItem; 12 13 enum OD_TYPES 14 { 15 OD_ACTIVATED, 16 OD_SEPARATOR, 17 OD_DISMISS, 18 OD_CHOICE, 19 OD_DISABLED, 20 }; 21 22 class Dialog : public FocusHolder 23 { 24 public: 25 Dialog(); 26 ~Dialog(); 27 28 int DLG_X; 29 int DLG_Y; 30 int DLG_W; 31 int DLG_H; 32 33 ODItem *AddItem(const char *text, void (*activate)(ODItem *, int) = NULL, void (*update)(ODItem *) = NULL, 34 int id = -1, int type = OD_ACTIVATED); 35 ODItem *AddSeparator(); 36 ODItem *AddDisabledItem(const char *text); 37 ODItem *AddDismissalItem(const char *text = NULL); 38 39 void Draw(); 40 void RunInput(); 41 void Dismiss(); 42 void Clear(); 43 void Refresh(); 44 45 void UpdateSizePos(); 46 void SetSize(int w, int h); 47 void offset(int xd, int yd); 48 49 void SetSelection(int sel); GetSelection()50 unsigned int GetSelection() 51 { 52 return fCurSel; 53 } ShowFull()54 void ShowFull() 55 { 56 fNumShown = 99; 57 } 58 59 void (*onclear)(); 60 void (*ondismiss)(); 61 std::vector<ODItem *> &Items(); 62 63 private: 64 void DrawItem(int x, int y, ODItem *item); 65 66 int fCurSel; 67 unsigned int fNumShown; // for text-draw animation on entry 68 int fRepeatTimer; 69 std::vector<ODItem *> fItems; 70 71 struct 72 { 73 int x, y, w, h; 74 } fCoords; 75 int fTextX; 76 }; 77 78 struct ODItem 79 { 80 char text[100]; 81 char suffix[32]; 82 char righttext[64]; 83 char raligntext[32]; 84 int type, id; 85 86 void (*update)(ODItem *item); 87 void (*activate)(ODItem *item, int dir); 88 }; 89 90 } // namespace Options 91 92 #endif 93