Added private wxMenu::MSWNewFromHMENU() method.
Add a method allowing creation of a wxMenu object from a native menu handle. This will be used to implement access to the system menu in an upcoming commit but could also be useful for other purposes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -61,6 +61,14 @@ public:
|
|||||||
|
|
||||||
virtual void SetTitle(const wxString& title);
|
virtual void SetTitle(const wxString& title);
|
||||||
|
|
||||||
|
// MSW-only methods
|
||||||
|
// ----------------
|
||||||
|
|
||||||
|
// Create a new menu from the given native HMENU. Takes ownership of the
|
||||||
|
// menu handle and will delete it when this object is destroyed.
|
||||||
|
static wxMenu *MSWNewFromHMENU(WXHMENU hMenu) { return new wxMenu(hMenu); }
|
||||||
|
|
||||||
|
|
||||||
// implementation only from now on
|
// implementation only from now on
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
@@ -120,7 +128,14 @@ protected:
|
|||||||
virtual wxMenuItem* DoRemove(wxMenuItem *item);
|
virtual wxMenuItem* DoRemove(wxMenuItem *item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// common part of all ctors
|
// This constructor is private, use MSWNewFromHMENU() to use it.
|
||||||
|
wxMenu(WXHMENU hMenu);
|
||||||
|
|
||||||
|
// Common part of all ctors, it doesn't create a new HMENU.
|
||||||
|
void InitNoCreate();
|
||||||
|
|
||||||
|
// Common part of all ctors except of the one above taking a native menu
|
||||||
|
// handler: calls InitNoCreate() and also creates a new menu.
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// common part of Append/Insert (behaves as Append is pos == (size_t)-1)
|
// common part of Append/Insert (behaves as Append is pos == (size_t)-1)
|
||||||
|
@@ -260,7 +260,7 @@ inline bool IsGreaterThanStdSize(const wxBitmap& bmp)
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// Construct a menu with optional title (then use append)
|
// Construct a menu with optional title (then use append)
|
||||||
void wxMenu::Init()
|
void wxMenu::InitNoCreate()
|
||||||
{
|
{
|
||||||
m_radioData = NULL;
|
m_radioData = NULL;
|
||||||
m_doBreak = false;
|
m_doBreak = false;
|
||||||
@@ -270,6 +270,11 @@ void wxMenu::Init()
|
|||||||
m_maxBitmapWidth = 0;
|
m_maxBitmapWidth = 0;
|
||||||
m_maxAccelWidth = -1;
|
m_maxAccelWidth = -1;
|
||||||
#endif // wxUSE_OWNER_DRAWN
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMenu::Init()
|
||||||
|
{
|
||||||
|
InitNoCreate();
|
||||||
|
|
||||||
// create the menu
|
// create the menu
|
||||||
m_hMenu = (WXHMENU)CreatePopupMenu();
|
m_hMenu = (WXHMENU)CreatePopupMenu();
|
||||||
@@ -287,6 +292,24 @@ void wxMenu::Init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMenu::wxMenu(WXHMENU hMenu)
|
||||||
|
{
|
||||||
|
InitNoCreate();
|
||||||
|
|
||||||
|
m_hMenu = hMenu;
|
||||||
|
|
||||||
|
// Ensure that our internal idea of how many items we have corresponds to
|
||||||
|
// the real number of items in the menu.
|
||||||
|
//
|
||||||
|
// We could also retrieve the real labels of the items here but it doesn't
|
||||||
|
// seem to be worth the trouble.
|
||||||
|
const int numExistingItems = ::GetMenuItemCount(m_hMenu);
|
||||||
|
for ( int n = 0; n < numExistingItems; n++ )
|
||||||
|
{
|
||||||
|
wxMenuBase::DoAppend(wxMenuItem::New(this, wxID_SEPARATOR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The wxWindow destructor will take care of deleting the submenus.
|
// The wxWindow destructor will take care of deleting the submenus.
|
||||||
wxMenu::~wxMenu()
|
wxMenu::~wxMenu()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user