1 /*****************************************************************************
2  * win32_popup.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id: 97380e3aa1aaadea39a5dcedc49f89612800661e $
6  *
7  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8  *
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.
13  *
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.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef WIN32_POPUP_HPP
25 #define WIN32_POPUP_HPP
26 
27 #include "../src/os_popup.hpp"
28 #include <windows.h>
29 
30 
31 /// Win32 implementation of OSPopup
32 class Win32Popup: public OSPopup
33 {
34 public:
35     Win32Popup( intf_thread_t *pIntf, HWND hAssociatedWindow );
36 
37     virtual ~Win32Popup();
38 
39     /// Show the popup menu at the given (absolute) corrdinates
40     virtual void show( int xPos, int yPos );
41 
42     /// Hide the popup menu
43     virtual void hide();
44 
45     /// Append a new menu item with the given label to the popup menu
46     virtual void addItem( const std::string &rLabel, int pos );
47 
48     /// Create a dummy menu item to separate sections
49     virtual void addSeparator( int pos );
50 
51     /// Return the position of the item identified by the given id
getPosFromId(int id) const52     virtual int getPosFromId( int id ) const { return id; }
53 
54 private:
55     /// Menu handle
56     HMENU m_hMenu;
57     /// Handle of the window which will receive the menu events
58     HWND m_hWnd;
59 
60     /**
61      * Find the item before which to insert another item so that the
62      * newly added item is at the position pos _when the whole menu has
63      * been built_ (no assumption is made for the order of insertion of
64      * the items)
65      */
66     unsigned int findInsertionPoint( unsigned int pos ) const;
67 };
68 
69 
70 #endif
71