Applied patch which solved conflicts between wxWidgets

and GTK+'s context menu code.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31393 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2005-01-16 15:27:15 +00:00
parent 7c2f14eeb8
commit ac103441d1
6 changed files with 85 additions and 42 deletions

View File

@@ -125,8 +125,7 @@ protected:
void OnUpdateSubMenuRadio(wxUpdateUIEvent& event);
#if USE_CONTEXT_MENU
void OnContextMenu(wxContextMenuEvent& event)
{ ShowContextMenu(ScreenToClient(event.GetPosition())); }
void OnContextMenu(wxContextMenuEvent& event);
#else
void OnRightUp(wxMouseEvent& event)
{ ShowContextMenu(event.GetPosition()); }
@@ -1000,6 +999,22 @@ void MyFrame::OnUpdateSubMenuRadio(wxUpdateUIEvent& event)
event.Check(false);
}
#if USE_CONTEXT_MENU
void MyFrame::OnContextMenu(wxContextMenuEvent& event)
{
wxPoint point = event.GetPosition();
// If from keyboard
if (point.x == -1 && point.y == -1) {
wxSize size = GetSize();
point.x = size.x / 2;
point.y = size.y / 2;
} else {
point = ScreenToClient(point);
}
ShowContextMenu(point);
}
#endif
void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event))
{
#if USE_LOG_WINDOW

View File

@@ -136,7 +136,6 @@ BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
EVT_TREE_ITEM_EXPANDING(TreeTest_Ctrl, MyTreeCtrl::OnItemExpanding)
EVT_TREE_ITEM_COLLAPSED(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsed)
EVT_TREE_ITEM_COLLAPSING(TreeTest_Ctrl, MyTreeCtrl::OnItemCollapsing)
//EVT_TREE_ITEM_RIGHT_CLICK(TreeTest_Ctrl, MyTreeCtrl::OnItemRightClick)
EVT_CONTEXT_MENU(MyTreeCtrl::OnContextMenu)
EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, MyTreeCtrl::OnSelChanged)
@@ -1147,11 +1146,6 @@ void MyTreeCtrl::OnItemActivated(wxTreeEvent& event)
wxLogMessage(wxT("OnItemActivated"));
}
void MyTreeCtrl::OnItemRightClick(wxTreeEvent& event)
{
ShowMenu(event.GetItem(), event.GetPoint());
}
void MyTreeCtrl::OnContextMenu(wxContextMenuEvent& event)
{
wxPoint pt = event.GetPosition();

View File

@@ -76,7 +76,6 @@ public:
void OnContextMenu(wxContextMenuEvent& event);
void OnGetInfo(wxTreeEvent& event);
void OnTreeRMouseClick(wxTreeEvent& event);
void OnItemRightClick(wxTreeEvent& event);
void OnSetInfo(wxTreeEvent& event);
void OnItemExpanded(wxTreeEvent& event);
void OnItemExpanding(wxTreeEvent& event);

View File

@@ -3177,11 +3177,12 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
if ( event.RightDown() )
{
DoSelectItem(item, true, false);
wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, GetId());
nevent.m_item = item;
nevent.m_pointDrag = CalcScrolledPosition(pt);
nevent.SetEventObject(this);
GetEventHandler()->ProcessEvent(nevent);
event.Skip(!GetEventHandler()->ProcessEvent(nevent));
}
else if ( event.LeftUp() )
{

View File

@@ -1693,21 +1693,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
// a chance to correct this
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
if ( event_type == wxEVT_RIGHT_DOWN )
{
// generate a "context menu" event: this is similar to right mouse
// click under many GUIs except that it is generated differently
// (right up under MSW, ctrl-click under Mac, right down here) and
//
// (a) it's a command event and so is propagated to the parent
// (b) under MSW it can be generated from kbd too
// (c) it uses screen coords (because of (a))
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
win->GetId(),
win->ClientToScreen(event.GetPosition()));
(void)win->GetEventHandler()->ProcessEvent(evtCtx);
}
// find the correct window to send the event too: it may be a different one
// from the one which got it at GTK+ level because some control don't have
// their own X window and thus cannot get any events.
@@ -1736,6 +1721,23 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
return TRUE;
}
if (event_type == wxEVT_RIGHT_DOWN)
{
// generate a "context menu" event: this is similar to right mouse
// click under many GUIs except that it is generated differently
// (right up under MSW, ctrl-click under Mac, right down here) and
//
// (a) it's a command event and so is propagated to the parent
// (b) under some ports it can be generated from kbd too
// (c) it uses screen coords (because of (a))
wxContextMenuEvent evtCtx(
wxEVT_CONTEXT_MENU,
win->GetId(),
win->ClientToScreen(event.GetPosition()));
evtCtx.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(evtCtx);
}
return FALSE;
}
@@ -1928,7 +1930,20 @@ static gint gtk_window_wheel_callback (GtkWidget * widget,
return FALSE;
}
#endif
//-----------------------------------------------------------------------------
// "popup-menu"
//-----------------------------------------------------------------------------
static gboolean wxgtk_window_popup_menu_callback(GtkWidget*, wxWindowGTK* win)
{
wxContextMenuEvent event(
wxEVT_CONTEXT_MENU,
win->GetId(),
wxPoint(-1, -1));
event.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(event);
}
#endif // __WXGTK20__
//-----------------------------------------------------------------------------
// "focus_in_event"
@@ -2907,6 +2922,8 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
#ifdef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(widget), "scroll_event",
GTK_SIGNAL_FUNC(gtk_window_wheel_callback), (gpointer)this );
g_signal_connect(widget, "popup_menu",
G_CALLBACK(wxgtk_window_popup_menu_callback), this);
#endif
gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event",

View File

@@ -1693,21 +1693,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
// a chance to correct this
win->FixUpMouseEvent(widget, event.m_x, event.m_y);
if ( event_type == wxEVT_RIGHT_DOWN )
{
// generate a "context menu" event: this is similar to right mouse
// click under many GUIs except that it is generated differently
// (right up under MSW, ctrl-click under Mac, right down here) and
//
// (a) it's a command event and so is propagated to the parent
// (b) under MSW it can be generated from kbd too
// (c) it uses screen coords (because of (a))
wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU,
win->GetId(),
win->ClientToScreen(event.GetPosition()));
(void)win->GetEventHandler()->ProcessEvent(evtCtx);
}
// find the correct window to send the event too: it may be a different one
// from the one which got it at GTK+ level because some control don't have
// their own X window and thus cannot get any events.
@@ -1736,6 +1721,23 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
return TRUE;
}
if (event_type == wxEVT_RIGHT_DOWN)
{
// generate a "context menu" event: this is similar to right mouse
// click under many GUIs except that it is generated differently
// (right up under MSW, ctrl-click under Mac, right down here) and
//
// (a) it's a command event and so is propagated to the parent
// (b) under some ports it can be generated from kbd too
// (c) it uses screen coords (because of (a))
wxContextMenuEvent evtCtx(
wxEVT_CONTEXT_MENU,
win->GetId(),
win->ClientToScreen(event.GetPosition()));
evtCtx.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(evtCtx);
}
return FALSE;
}
@@ -1928,7 +1930,20 @@ static gint gtk_window_wheel_callback (GtkWidget * widget,
return FALSE;
}
#endif
//-----------------------------------------------------------------------------
// "popup-menu"
//-----------------------------------------------------------------------------
static gboolean wxgtk_window_popup_menu_callback(GtkWidget*, wxWindowGTK* win)
{
wxContextMenuEvent event(
wxEVT_CONTEXT_MENU,
win->GetId(),
wxPoint(-1, -1));
event.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(event);
}
#endif // __WXGTK20__
//-----------------------------------------------------------------------------
// "focus_in_event"
@@ -2907,6 +2922,8 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
#ifdef __WXGTK20__
gtk_signal_connect( GTK_OBJECT(widget), "scroll_event",
GTK_SIGNAL_FUNC(gtk_window_wheel_callback), (gpointer)this );
g_signal_connect(widget, "popup_menu",
G_CALLBACK(wxgtk_window_popup_menu_callback), this);
#endif
gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event",