00001 /***************************************************************************** 00002 * popup.hpp 00003 ***************************************************************************** 00004 * Copyright (C) 2003 the VideoLAN team 00005 * $Id: d9419986da0264d0ebe7ce8c961ef074eeca591c $ 00006 * 00007 * Authors: Olivier Teulière <ipkiss@via.ecp.fr> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License along 00020 * with this program; if not, write to the Free Software Foundation, Inc., 00021 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef POPUP_HPP 00025 #define POPUP_HPP 00026 00027 #include "skin_common.hpp" 00028 #include "../utils/pointer.hpp" 00029 #include <string> 00030 #include <map> 00031 00032 class OSPopup; 00033 class TopWindow; 00034 class CmdGeneric; 00035 class WindowManager; 00036 class EvtMenu; 00037 00038 00039 /// Class handling a popup menu 00040 class Popup: public SkinObject 00041 { 00042 public: 00043 Popup( intf_thread_t *pIntf, WindowManager &rWindowManager ); 00044 virtual ~Popup() { } 00045 00046 void show( int xPos, int yPos ); 00047 void hide(); 00048 00049 // XXX: it would be nice to use a UString here, if X11 supports it for 00050 // its menu items (Windows doesn't, unfortunately) 00051 /// Insert a new menu item to the popup menu, at the position pos 00052 void addItem( const string &rLabel, CmdGeneric &rCmd, int pos ); 00053 00054 /// Create a dummy menu item to separate sections 00055 void addSeparator( int pos ); 00056 00057 /// Execute the action corresponding to the chosen menu item 00058 void handleEvent( const EvtMenu &rEvent ); 00059 00060 private: 00061 /// OS specific implementation 00062 OSPopup *m_pOsPopup; 00063 00064 /// Window manager 00065 WindowManager &m_rWindowManager; 00066 00067 /// Actions for the menu items, indexed by the position in the menu 00068 map<int, CmdGeneric *> m_actions; 00069 }; 00070 00071 typedef CountedPtr<Popup> PopupPtr; 00072 00073 00074 #endif
1.5.6