{
// 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
/* 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;
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;
}
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
+extern int g_openDialogs;
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
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 )
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 );
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
+ g_openDialogs++;
+
wxTopLevelWindows.Append( this );
m_needParent = FALSE;
{
wxTheApp->ExitMainLoop();
}
+
+ g_openDialogs--;
}
void wxDialog::SetTitle( const wxString& title )
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;
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;
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;
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
+extern int g_openDialogs;
//-----------------------------------------------------------------------------
// data
if (g_isIdle)
wxapp_install_idle_handler();
- win->Close();
+ if (g_openDialogs == 0)
+ win->Close();
return TRUE;
}
//-----------------------------------------------------------------------------
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 )
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 );
/* 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;
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;
}
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
+extern int g_openDialogs;
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
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 )
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 );
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
{
+ g_openDialogs++;
+
wxTopLevelWindows.Append( this );
m_needParent = FALSE;
{
wxTheApp->ExitMainLoop();
}
+
+ g_openDialogs--;
}
void wxDialog::SetTitle( const wxString& title )
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;
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;
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;
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
+extern int g_openDialogs;
//-----------------------------------------------------------------------------
// data
if (g_isIdle)
wxapp_install_idle_handler();
- win->Close();
+ if (g_openDialogs == 0)
+ win->Close();
return TRUE;
}
//-----------------------------------------------------------------------------
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 )
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 );