Lots of things to make menus and submenus work.
Also added wxPopTransientWindow::CanDismiss() which will be needed for pop-up menus, although that actually still has to be done... git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -86,6 +86,10 @@ public:
|
|||||||
|
|
||||||
// hide the window
|
// hide the window
|
||||||
virtual void Dismiss();
|
virtual void Dismiss();
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool CanDismiss()
|
||||||
|
{ return TRUE; }
|
||||||
|
|
||||||
// called when a mouse is pressed while the popup is shown: return TRUE
|
// called when a mouse is pressed while the popup is shown: return TRUE
|
||||||
// from here to prevent its normal processing by the popup (which consists
|
// from here to prevent its normal processing by the popup (which consists
|
||||||
|
@@ -427,8 +427,6 @@ void wxPopupFocusHandler::OnKillFocus(wxFocusEvent& event)
|
|||||||
win = win->GetParent();
|
win = win->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "Dismiss now.\n" );
|
|
||||||
|
|
||||||
m_popup->DismissAndNotify();
|
m_popup->DismissAndNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// default margins around the image
|
// default margins around the image
|
||||||
static const wxCoord DEFAULT_BTN_MARGIN_X = 0;
|
static const wxCoord DEFAULT_BTN_MARGIN_X = 0; // We should give space for the border, at least.
|
||||||
static const wxCoord DEFAULT_BTN_MARGIN_Y = 0;
|
static const wxCoord DEFAULT_BTN_MARGIN_Y = 0;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@@ -123,6 +123,8 @@ class wxPopupMenuWindow : public wxPopupTransientWindow
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxPopupMenuWindow(wxWindow *parent, wxMenu *menu);
|
wxPopupMenuWindow(wxWindow *parent, wxMenu *menu);
|
||||||
|
|
||||||
|
~wxPopupMenuWindow();
|
||||||
|
|
||||||
// override the base class version to select the first item initially
|
// override the base class version to select the first item initially
|
||||||
virtual void Popup(wxWindow *focus = NULL);
|
virtual void Popup(wxWindow *focus = NULL);
|
||||||
@@ -308,6 +310,10 @@ wxPopupMenuWindow::wxPopupMenuWindow(wxWindow *parent, wxMenu *menu)
|
|||||||
SetCursor(wxCURSOR_ARROW);
|
SetCursor(wxCURSOR_ARROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPopupMenuWindow::~wxPopupMenuWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxPopupMenuWindow current item/node handling
|
// wxPopupMenuWindow current item/node handling
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1154,6 +1160,10 @@ wxWindow *wxMenu::GetRootWindow() const
|
|||||||
wxMenu *menu = GetParent();
|
wxMenu *menu = GetParent();
|
||||||
while ( menu )
|
while ( menu )
|
||||||
{
|
{
|
||||||
|
// We are a submenu of a menu of a menubar
|
||||||
|
if (menu->GetMenuBar())
|
||||||
|
return menu->GetMenuBar();
|
||||||
|
|
||||||
win = menu->GetInvokingWindow();
|
win = menu->GetInvokingWindow();
|
||||||
if ( win )
|
if ( win )
|
||||||
break;
|
break;
|
||||||
@@ -1164,7 +1174,7 @@ wxWindow *wxMenu::GetRootWindow() const
|
|||||||
// we're probably going to crash in the caller anyhow, but try to detect
|
// we're probably going to crash in the caller anyhow, but try to detect
|
||||||
// this error as soon as possible
|
// this error as soon as possible
|
||||||
wxASSERT_MSG( win, _T("menu without any associated window?") );
|
wxASSERT_MSG( win, _T("menu without any associated window?") );
|
||||||
|
|
||||||
// also remember it in this menu so that we don't have to search for it the
|
// also remember it in this menu so that we don't have to search for it the
|
||||||
// next time
|
// next time
|
||||||
wxConstCast(this, wxMenu)->m_invokingWindow = win;
|
wxConstCast(this, wxMenu)->m_invokingWindow = win;
|
||||||
@@ -2379,6 +2389,9 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
void wxWindow::DismissPopupMenu()
|
void wxWindow::DismissPopupMenu()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( ms_evtLoopPopup, _T("no popup menu shown") );
|
wxCHECK_RET( ms_evtLoopPopup, _T("no popup menu shown") );
|
||||||
|
|
||||||
|
char *crash = NULL;
|
||||||
|
(*crash) = 0;
|
||||||
|
|
||||||
ms_evtLoopPopup->Exit();
|
ms_evtLoopPopup->Exit();
|
||||||
}
|
}
|
||||||
|
@@ -647,23 +647,32 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
tlw = tlw->GetParent();
|
tlw = tlw->GetParent();
|
||||||
if (tlw && !tlw->IsEnabled())
|
if (tlw && !tlw->IsEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event->type == ButtonPress)
|
if (event->type == ButtonPress)
|
||||||
{
|
{
|
||||||
if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
|
if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
|
||||||
{
|
{
|
||||||
// This might actually be done in wxWindow::SetFocus()
|
// This might actually be done in wxWindow::SetFocus()
|
||||||
// and not here.
|
// and not here. TODO.
|
||||||
g_prevFocus = wxWindow::FindFocus();
|
g_prevFocus = wxWindow::FindFocus();
|
||||||
g_nextFocus = win;
|
g_nextFocus = win;
|
||||||
|
|
||||||
win->SetFocus();
|
win->SetFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !wxUSE_NANOX
|
||||||
|
if (event->type == LeaveNotify || event->type == EnterNotify)
|
||||||
|
{
|
||||||
|
// Throw out NotifyGrab and NotifyUngrab
|
||||||
|
if (event->xcrossing.mode != NotifyNormal)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
wxMouseEvent wxevent;
|
wxMouseEvent wxevent;
|
||||||
wxTranslateMouseEvent(wxevent, win, window, event);
|
wxTranslateMouseEvent(wxevent, win, window, event);
|
||||||
win->GetEventHandler()->ProcessEvent( wxevent );
|
win->GetEventHandler()->ProcessEvent( wxevent );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
Reference in New Issue
Block a user