From 2d68e1b4f42c2c021a2a45bd9ea385153fbcbbf4 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 6 Nov 1999 11:21:51 +0000 Subject: [PATCH] Fixed typos in frame and dialog, Some improvemnts to DnD, It's no longer possible to close any frame if there is a dialog open. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/dnd/dnd.cpp | 5 +++++ src/gtk/data.cpp | 3 +++ src/gtk/dataobj.cpp | 20 +++++++++++++++----- src/gtk/dialog.cpp | 9 +++++++-- src/gtk/dnd.cpp | 18 ++---------------- src/gtk/frame.cpp | 13 ++++++++----- src/gtk1/data.cpp | 3 +++ src/gtk1/dataobj.cpp | 20 +++++++++++++++----- src/gtk1/dialog.cpp | 9 +++++++-- src/gtk1/dnd.cpp | 18 ++---------------- src/gtk1/frame.cpp | 13 ++++++++----- 11 files changed, 75 insertions(+), 56 deletions(-) diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 820f0c1beb..f747e454a3 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -877,6 +877,11 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) ) { // start drag operation wxTextDataObject textData(m_strText); +/* + wxFileDataObject textData; + textData.AddFile( "/file1.txt" ); + textData.AddFile( "/file2.txt" ); +*/ wxDropSource source(textData, this #ifdef __WXMSW__ ,wxCURSOR_PENCIL, // for copy diff --git a/src/gtk/data.cpp b/src/gtk/data.cpp index 4ac9238294..df4a1638a4 100644 --- a/src/gtk/data.cpp +++ b/src/gtk/data.cpp @@ -49,6 +49,9 @@ bool g_blockEventsOnDrag = FALSE; /* Don't allow mouse event propagation during scroll */ bool g_blockEventsOnScroll = FALSE; +/* Don't allow window closing if there are open dialogs */ +int g_openDialogs = 0; + /* TRUE when the message queue is empty. this gets set to FALSE by all event callbacks before anything else is done */ bool g_isIdle = FALSE; diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index c7d29816cb..fd40e35976 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -197,13 +197,23 @@ size_t wxFileDataObject::GetDataSize() const return res + 1; } -bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf) +bool wxFileDataObject::SetData(size_t size, const void *buf) { - /* TODO */ + // filenames are stores as a string with #0 as deliminators - wxString file( (const char *)buf ); /* char, not wxChar */ - - AddFile( file ); + const char *filenames = (const char*) buf; + size_t pos = 0; + for(;;) + { + if (filenames[0] == 0) + break; + if (pos >= size) + break; + wxString file( filenames ); // this returns the first file + AddFile( file ); + pos += file.Len()+1; + filenames += file.Len()+1; + } return TRUE; } diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index cef4cc3a70..8739c60b35 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -31,6 +31,7 @@ extern void wxapp_install_idle_handler(); extern bool g_isIdle; +extern int g_openDialogs; //----------------------------------------------------------------------------- // data @@ -76,7 +77,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation //----------------------------------------------------------------------------- static gint -#if (GTK_MINOR_VERSON > 0) +#if (GTK_MINOR_VERSION > 0) gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win ) #else gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win ) @@ -87,7 +88,7 @@ gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *e if (!win->m_hasVMT) return FALSE; -#if (GTK_MINOR_VERSON > 0) +#if (GTK_MINOR_VERSION > 0) int x = 0; int y = 0; gdk_window_get_root_origin( win->m_widget->window, &x, &y ); @@ -254,6 +255,8 @@ bool wxDialog::Create( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + g_openDialogs++; + wxTopLevelWindows.Append( this ); m_needParent = FALSE; @@ -322,6 +325,8 @@ wxDialog::~wxDialog() { wxTheApp->ExitMainLoop(); } + + g_openDialogs--; } void wxDialog::SetTitle( const wxString& title ) diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index ad29403fb1..0b15ec2040 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -426,20 +426,6 @@ bool wxDropTarget::GetData() if (!m_dataObject->IsSupportedFormat( dragFormat )) return FALSE; - if (dragFormat.GetType() == wxDF_TEXT) - { - wxTextDataObject *text_object = (wxTextDataObject*)m_dataObject; - text_object->SetText( (const char*)m_dragData->data ); - return TRUE; - } - - if (dragFormat.GetType() == wxDF_FILENAME) - { - wxFileDataObject *file_object = (wxFileDataObject*)m_dataObject; - file_object->SetData( 0, (const char*)m_dragData->data ); - return TRUE; - } - m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data ); return TRUE; @@ -713,7 +699,7 @@ void wxDropSource::PrepareIcon( int hot_x, int hot_y, GdkDragContext *context ) wxDragResult wxDropSource::DoDragDrop( bool allowMove ) { - wxASSERT_MSG( m_data, wxT("wxDragSource: no data") ); + wxASSERT_MSG( m_data, wxT("Drop source: no data") ); if (!m_data) return (wxDragResult) wxDragNone; @@ -734,7 +720,7 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove ) for (size_t i = 0; i < m_data->GetFormatCount(); i++) { GdkAtom atom = array[i]; - wxLogDebug( wxT("Supported atom %s"), gdk_atom_name( atom ) ); + wxLogDebug( wxT("Drop source: Supported atom %s"), gdk_atom_name( atom ) ); gtk_target_list_add( target_list, atom, 0, 0 ); } delete[] array; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 369cb25161..9b7aa4a001 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -45,6 +45,7 @@ const int wxPLACE_HOLDER = 0; extern void wxapp_install_idle_handler(); extern bool g_isIdle; +extern int g_openDialogs; //----------------------------------------------------------------------------- // data @@ -101,7 +102,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX if (g_isIdle) wxapp_install_idle_handler(); - win->Close(); + if (g_openDialogs == 0) + win->Close(); return TRUE; } @@ -165,7 +167,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge //----------------------------------------------------------------------------- static gint -#if (GTK_MINOR_VERSON > 0) +#if (GTK_MINOR_VERSION > 0) gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win ) #else gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) @@ -174,9 +176,10 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *ev if (g_isIdle) wxapp_install_idle_handler(); - if (!win->m_hasVMT) return FALSE; - -#if (GTK_MINOR_VERSON > 0) + if (!win->m_hasVMT) + return FALSE; + +#if (GTK_MINOR_VERSION > 0) int x = 0; int y = 0; gdk_window_get_root_origin( win->m_widget->window, &x, &y ); diff --git a/src/gtk1/data.cpp b/src/gtk1/data.cpp index 4ac9238294..df4a1638a4 100644 --- a/src/gtk1/data.cpp +++ b/src/gtk1/data.cpp @@ -49,6 +49,9 @@ bool g_blockEventsOnDrag = FALSE; /* Don't allow mouse event propagation during scroll */ bool g_blockEventsOnScroll = FALSE; +/* Don't allow window closing if there are open dialogs */ +int g_openDialogs = 0; + /* TRUE when the message queue is empty. this gets set to FALSE by all event callbacks before anything else is done */ bool g_isIdle = FALSE; diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index c7d29816cb..fd40e35976 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -197,13 +197,23 @@ size_t wxFileDataObject::GetDataSize() const return res + 1; } -bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf) +bool wxFileDataObject::SetData(size_t size, const void *buf) { - /* TODO */ + // filenames are stores as a string with #0 as deliminators - wxString file( (const char *)buf ); /* char, not wxChar */ - - AddFile( file ); + const char *filenames = (const char*) buf; + size_t pos = 0; + for(;;) + { + if (filenames[0] == 0) + break; + if (pos >= size) + break; + wxString file( filenames ); // this returns the first file + AddFile( file ); + pos += file.Len()+1; + filenames += file.Len()+1; + } return TRUE; } diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index cef4cc3a70..8739c60b35 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -31,6 +31,7 @@ extern void wxapp_install_idle_handler(); extern bool g_isIdle; +extern int g_openDialogs; //----------------------------------------------------------------------------- // data @@ -76,7 +77,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation //----------------------------------------------------------------------------- static gint -#if (GTK_MINOR_VERSON > 0) +#if (GTK_MINOR_VERSION > 0) gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win ) #else gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win ) @@ -87,7 +88,7 @@ gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *e if (!win->m_hasVMT) return FALSE; -#if (GTK_MINOR_VERSON > 0) +#if (GTK_MINOR_VERSION > 0) int x = 0; int y = 0; gdk_window_get_root_origin( win->m_widget->window, &x, &y ); @@ -254,6 +255,8 @@ bool wxDialog::Create( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + g_openDialogs++; + wxTopLevelWindows.Append( this ); m_needParent = FALSE; @@ -322,6 +325,8 @@ wxDialog::~wxDialog() { wxTheApp->ExitMainLoop(); } + + g_openDialogs--; } void wxDialog::SetTitle( const wxString& title ) diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index ad29403fb1..0b15ec2040 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -426,20 +426,6 @@ bool wxDropTarget::GetData() if (!m_dataObject->IsSupportedFormat( dragFormat )) return FALSE; - if (dragFormat.GetType() == wxDF_TEXT) - { - wxTextDataObject *text_object = (wxTextDataObject*)m_dataObject; - text_object->SetText( (const char*)m_dragData->data ); - return TRUE; - } - - if (dragFormat.GetType() == wxDF_FILENAME) - { - wxFileDataObject *file_object = (wxFileDataObject*)m_dataObject; - file_object->SetData( 0, (const char*)m_dragData->data ); - return TRUE; - } - m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data ); return TRUE; @@ -713,7 +699,7 @@ void wxDropSource::PrepareIcon( int hot_x, int hot_y, GdkDragContext *context ) wxDragResult wxDropSource::DoDragDrop( bool allowMove ) { - wxASSERT_MSG( m_data, wxT("wxDragSource: no data") ); + wxASSERT_MSG( m_data, wxT("Drop source: no data") ); if (!m_data) return (wxDragResult) wxDragNone; @@ -734,7 +720,7 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove ) for (size_t i = 0; i < m_data->GetFormatCount(); i++) { GdkAtom atom = array[i]; - wxLogDebug( wxT("Supported atom %s"), gdk_atom_name( atom ) ); + wxLogDebug( wxT("Drop source: Supported atom %s"), gdk_atom_name( atom ) ); gtk_target_list_add( target_list, atom, 0, 0 ); } delete[] array; diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 369cb25161..9b7aa4a001 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -45,6 +45,7 @@ const int wxPLACE_HOLDER = 0; extern void wxapp_install_idle_handler(); extern bool g_isIdle; +extern int g_openDialogs; //----------------------------------------------------------------------------- // data @@ -101,7 +102,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX if (g_isIdle) wxapp_install_idle_handler(); - win->Close(); + if (g_openDialogs == 0) + win->Close(); return TRUE; } @@ -165,7 +167,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge //----------------------------------------------------------------------------- static gint -#if (GTK_MINOR_VERSON > 0) +#if (GTK_MINOR_VERSION > 0) gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win ) #else gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) @@ -174,9 +176,10 @@ gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *ev if (g_isIdle) wxapp_install_idle_handler(); - if (!win->m_hasVMT) return FALSE; - -#if (GTK_MINOR_VERSON > 0) + if (!win->m_hasVMT) + return FALSE; + +#if (GTK_MINOR_VERSION > 0) int x = 0; int y = 0; gdk_window_get_root_origin( win->m_widget->window, &x, &y ); -- 2.45.2