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
This commit is contained in:
Robert Roebling 1999-11-06 11:21:51 +00:00
parent 6e47faf150
commit 2d68e1b4f4
11 changed files with 75 additions and 56 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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 )

View File

@ -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;

View File

@ -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 );

View File

@ -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;

View File

@ -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;
}

View File

@ -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 )

View File

@ -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;

View File

@ -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 );