Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

Radio.H

Go to the documentation of this file.
00001 
00018 #ifndef _RADIOCONTROL_H
00019 #define _RADIOCONTROL_H
00020 
00021 #include <UserInterface.H>
00022 #include <KeyBoard.H>
00023 #include <Menu.H>
00024 
00025 namespace xchen
00026 {
00027   class UI :: Radio
00028   {
00029       typedef int RadioID;       
00030       
00031       enum { max_buttons_per_radio = 10000 };
00032       static vector<Radio*> radios; 
00033 
00034       static Radio* GetRadio(ButtonID id)                          { return radios[id / max_buttons_per_radio]; }
00035   public:
00036       static  void radio_keyboard_cb(ConvertedKeyValue btn_id, int, int);
00037 
00038   public:
00039       Radio(Menu* menu, const string radio_name);
00040       ~Radio();
00041       
00042       ButtonID AddButton(const string& btn, KeyValue k=0);
00043       void Set(ButtonID id)                                { pressed_btn = buttonID2name.find(id); assert(pressed_btn == buttonID2name.end()); }
00044       const string& Get() const                            { return pressed_btn->second; }
00045 
00046   private:
00047       RadioID id;
00048       
00049       map<ButtonID, string, less<int> > buttonID2name;
00050       map<ButtonID, string, less<int> >::iterator pressed_btn;
00051 
00052       Menu* menu;
00053   };
00054 
00055 
00056   
00057 
00058 }//end namespace xchen
00059 
00060 
00061 #endif

Generated on Wed Apr 7 21:40:49 2004 by doxygen1.2.18