From bd77da975b1aeeb52c56d2aacb02beec039b5bc3 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 22 Oct 1999 15:49:39 +0000 Subject: [PATCH] Compile fix for wxDataFormat cast, Unfinished code for wxDragCopy vs. wxDragMove, Corrected key accel code for wxFrame as children of wxFrame. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4139 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dobjcmn.cpp | 4 ++++ src/gtk/dnd.cpp | 19 +++++++++++++++---- src/gtk/menu.cpp | 15 ++++++++------- src/gtk1/dnd.cpp | 19 +++++++++++++++---- src/gtk1/menu.cpp | 15 ++++++++------- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index 7faeca754c..de267315e2 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -97,7 +97,11 @@ wxDataObjectComposite::GetPreferredFormat(Direction WXUNUSED(dir)) const { wxSimpleDataObjectList::Node *node = m_dataObjects.Item( m_preferred ); +#ifdef __WXGTK__ + wxCHECK_MSG( node, wxDataFormat(wxDF_INVALID), wxT("no preferred format") ); +#else wxCHECK_MSG( node, wxDataFormat((unsigned short) wxDF_INVALID), wxT("no preferred format") ); +#endif wxDataObjectSimple* dataObj = node->GetData(); diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 6b411b3de9..8618f4de2d 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -188,8 +188,8 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), this is only valid for the duration of this call */ drop_target->SetDragContext( context ); - /* TODO: what should be the default behaviour? Copy or move? */ wxDragResult result = wxDragMove; + if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; if (drop_target->m_firstMotion) { @@ -202,12 +202,13 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), result = drop_target->OnDragOver( x, y, result ); } - /* we don't yet handle which "actions" (i.e. copy or move) - the target accepts. so far we simply accept the - suggested action. TODO. */ bool ret = result != wxDragNone; if (ret) + { + GdkDragAction action = GDK_ACTION_MOVE; + if (result == wxDragCopy) action == GDK_ACTION_COPY; gdk_drag_status( context, context->suggested_action, time ); + } /* after this, invalidate the drop_target's GdkDragContext */ drop_target->SetDragContext( (GdkDragContext*) NULL ); @@ -254,6 +255,11 @@ static gboolean target_drag_drop( GtkWidget *widget, this is only valid for the duration of this call */ drop_target->SetDragTime( time ); +/* + wxDragResult result = wxDragMove; + if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; +*/ + bool ret = drop_target->OnDrop( x, y ); if (!ret) @@ -278,6 +284,11 @@ static gboolean target_drag_drop( GtkWidget *widget, GdkAtom format = drop_target->GetMatchingPair(); wxASSERT( format ); +/* + GdkDragAction action = GDK_ACTION_MOVE; + if (result == wxDragCopy) action == GDK_ACTION_COPY; + context->action = action; +*/ /* this should trigger an "drag_data_received" event */ gtk_drag_get_data( widget, context, diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 8827eb6e8b..35a6a05cd0 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -113,7 +113,8 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) #if (GTK_MINOR_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native hot keys */ gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); @@ -135,8 +136,8 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) #if (GTK_MINOR_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) - top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native hot keys */ gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); @@ -157,8 +158,8 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) m_invokingWindow = win; #if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) - top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native key accelerators indicated by underscroes */ gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) ); @@ -178,8 +179,8 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) m_invokingWindow = (wxWindow*) NULL; #if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) - top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native key accelerators indicated by underscroes */ gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) ); diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 6b411b3de9..8618f4de2d 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -188,8 +188,8 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), this is only valid for the duration of this call */ drop_target->SetDragContext( context ); - /* TODO: what should be the default behaviour? Copy or move? */ wxDragResult result = wxDragMove; + if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; if (drop_target->m_firstMotion) { @@ -202,12 +202,13 @@ static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), result = drop_target->OnDragOver( x, y, result ); } - /* we don't yet handle which "actions" (i.e. copy or move) - the target accepts. so far we simply accept the - suggested action. TODO. */ bool ret = result != wxDragNone; if (ret) + { + GdkDragAction action = GDK_ACTION_MOVE; + if (result == wxDragCopy) action == GDK_ACTION_COPY; gdk_drag_status( context, context->suggested_action, time ); + } /* after this, invalidate the drop_target's GdkDragContext */ drop_target->SetDragContext( (GdkDragContext*) NULL ); @@ -254,6 +255,11 @@ static gboolean target_drag_drop( GtkWidget *widget, this is only valid for the duration of this call */ drop_target->SetDragTime( time ); +/* + wxDragResult result = wxDragMove; + if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; +*/ + bool ret = drop_target->OnDrop( x, y ); if (!ret) @@ -278,6 +284,11 @@ static gboolean target_drag_drop( GtkWidget *widget, GdkAtom format = drop_target->GetMatchingPair(); wxASSERT( format ); +/* + GdkDragAction action = GDK_ACTION_MOVE; + if (result == wxDragCopy) action == GDK_ACTION_COPY; + context->action = action; +*/ /* this should trigger an "drag_data_received" event */ gtk_drag_get_data( widget, context, diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 8827eb6e8b..35a6a05cd0 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -113,7 +113,8 @@ static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) #if (GTK_MINOR_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native hot keys */ gtk_accel_group_detach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); @@ -135,8 +136,8 @@ static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) #if (GTK_MINOR_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) - top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native hot keys */ gtk_accel_group_attach( menu->m_accel, GTK_OBJECT(top_frame->m_widget) ); @@ -157,8 +158,8 @@ void wxMenuBar::SetInvokingWindow( wxWindow *win ) m_invokingWindow = win; #if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) - top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native key accelerators indicated by underscroes */ gtk_accel_group_attach( m_accel, GTK_OBJECT(top_frame->m_widget) ); @@ -178,8 +179,8 @@ void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) m_invokingWindow = (wxWindow*) NULL; #if (GTK_MINOR_VERSION > 0) && (GTK_MICRO_VERSION > 0) wxWindow *top_frame = win; - while (top_frame->GetParent()) - top_frame = top_frame->GetParent(); + while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame)) + top_frame = top_frame->GetParent(); /* support for native key accelerators indicated by underscroes */ gtk_accel_group_detach( m_accel, GTK_OBJECT(top_frame->m_widget) ); -- 2.45.2