1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 #include "os_factory.hpp"
26 #include "os_popup.hpp"
27 #include "window_manager.hpp"
28 #include "../commands/cmd_generic.hpp"
29 #include "../events/evt_menu.hpp"
32 Popup::Popup( intf_thread_t
*pIntf
, WindowManager
&rWindowManager
)
33 : SkinObject( pIntf
), m_rWindowManager( rWindowManager
)
36 OSFactory
*pOsFactory
= OSFactory::instance( getIntf() );
38 // Create an OSPopup to handle OS specific processing
39 m_pOsPopup
= pOsFactory
->createOSPopup();
43 void Popup::show( int xPos
, int yPos
)
45 // Notify that we are the active popup menu, so that the window which
46 // receives our menu events knows whom to forward them
47 m_rWindowManager
.setActivePopup( *this );
49 m_pOsPopup
->show( xPos
, yPos
);
59 void Popup::addItem( const string
&rLabel
, CmdGeneric
&rCmd
, int pos
)
61 m_pOsPopup
->addItem( rLabel
, pos
);
62 m_actions
[pos
] = &rCmd
;
66 void Popup::addSeparator( int pos
)
68 m_pOsPopup
->addSeparator( pos
);
69 m_actions
[pos
] = NULL
;
73 void Popup::handleEvent( const EvtMenu
&rEvent
)
75 unsigned int n
= m_pOsPopup
->getPosFromId( rEvent
.getItemId() );
76 if( (n
< m_actions
.size()) && m_actions
[n
] )
78 m_actions
[n
]->execute();
82 // Should never happen
83 msg_Warn( getIntf(), "problem in the popup implementation" );