00001 /* 00002 * Sudoku: A plug-in for the Video Disk Recorder 00003 * 00004 * Copyright (C) 2008, Thomas Günther <tom@toms-cafe.de> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00019 */ 00020 00021 #ifndef VDR_SUDOKU_COMMANDS_H 00022 #define VDR_SUDOKU_COMMANDS_H 00023 00024 #include "sudoku.h" 00025 #include <vdr/osdbase.h> 00026 00027 00028 namespace SudokuPlugin 00029 { 00030 class Menu; 00031 00032 /** Type of menu commands: pointer to member function of class Menu */ 00033 typedef eOSState (Menu::*CommandType)(); 00034 00035 00036 //--- class SudokuPlugin::CommandList ---------------------------------------- 00037 00038 class CommandList 00039 { 00040 /** List of commands - sorted for the commands menu */ 00041 struct List { int id; const char* text; CommandType cmd; }; 00042 static const struct List list[]; 00043 00044 public: 00045 00046 /** Command id of a command */ 00047 static int id(int index); 00048 00049 /** Translated text of a command */ 00050 static const char* text(int index); 00051 00052 /** Command type of a command */ 00053 static CommandType command(int index); 00054 00055 /** Count of commands */ 00056 static int count(); 00057 00058 /** List with translated texts of all commands */ 00059 static const char* const* texts(); 00060 00061 /** Search a command id. Return default index if not found. */ 00062 static int id_to_index(int id, int default_index = -1); 00063 00064 /** Default index for the red key */ 00065 static int key_red_default_index(); 00066 00067 /** Default index for the green key */ 00068 static int key_green_default_index(); 00069 00070 /** Default index for the yellow key */ 00071 static int key_yellow_default_index(); 00072 }; 00073 00074 00075 //--- class SudokuPlugin::CommandMenu ---------------------------------------- 00076 00077 /** Commands menu of the plugin */ 00078 class CommandMenu : public cOsdMenu 00079 { 00080 CommandType command; 00081 00082 public: 00083 00084 /** Constructor */ 00085 CommandMenu(); 00086 00087 /** Get the selected menu command. */ 00088 CommandType get_selected_command() const; 00089 00090 /** Process user events. */ 00091 virtual eOSState ProcessKey(eKeys key); 00092 }; 00093 00094 00095 //--- class SudokuPlugin::Command -------------------------------------------- 00096 00097 /** Item in commands menu */ 00098 class Command : public cOsdItem 00099 { 00100 CommandType command; 00101 00102 public: 00103 00104 /** Constructor */ 00105 Command(const char* text, CommandType command); 00106 00107 /** Get the menu command. */ 00108 CommandType get_command() const; 00109 }; 00110 00111 } // namespace SudokuPlugin 00112 00113 #endif // VDR_SUDOKU_COMMANDS_H