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:
@@ -877,6 +877,11 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
|
|||||||
{
|
{
|
||||||
// start drag operation
|
// start drag operation
|
||||||
wxTextDataObject textData(m_strText);
|
wxTextDataObject textData(m_strText);
|
||||||
|
/*
|
||||||
|
wxFileDataObject textData;
|
||||||
|
textData.AddFile( "/file1.txt" );
|
||||||
|
textData.AddFile( "/file2.txt" );
|
||||||
|
*/
|
||||||
wxDropSource source(textData, this
|
wxDropSource source(textData, this
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
,wxCURSOR_PENCIL, // for copy
|
,wxCURSOR_PENCIL, // for copy
|
||||||
|
@@ -49,6 +49,9 @@ bool g_blockEventsOnDrag = FALSE;
|
|||||||
/* Don't allow mouse event propagation during scroll */
|
/* Don't allow mouse event propagation during scroll */
|
||||||
bool g_blockEventsOnScroll = FALSE;
|
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
|
/* TRUE when the message queue is empty. this gets set to
|
||||||
FALSE by all event callbacks before anything else is done */
|
FALSE by all event callbacks before anything else is done */
|
||||||
bool g_isIdle = FALSE;
|
bool g_isIdle = FALSE;
|
||||||
|
@@ -197,13 +197,23 @@ size_t wxFileDataObject::GetDataSize() const
|
|||||||
return res + 1;
|
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 */
|
const char *filenames = (const char*) buf;
|
||||||
|
size_t pos = 0;
|
||||||
AddFile( file );
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
extern void wxapp_install_idle_handler();
|
extern void wxapp_install_idle_handler();
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
extern int g_openDialogs;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// data
|
// data
|
||||||
@@ -76,7 +77,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win )
|
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win )
|
||||||
#else
|
#else
|
||||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
|
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 (!win->m_hasVMT) return FALSE;
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
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,
|
const wxPoint &pos, const wxSize &size,
|
||||||
long style, const wxString &name )
|
long style, const wxString &name )
|
||||||
{
|
{
|
||||||
|
g_openDialogs++;
|
||||||
|
|
||||||
wxTopLevelWindows.Append( this );
|
wxTopLevelWindows.Append( this );
|
||||||
|
|
||||||
m_needParent = FALSE;
|
m_needParent = FALSE;
|
||||||
@@ -322,6 +325,8 @@ wxDialog::~wxDialog()
|
|||||||
{
|
{
|
||||||
wxTheApp->ExitMainLoop();
|
wxTheApp->ExitMainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_openDialogs--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialog::SetTitle( const wxString& title )
|
void wxDialog::SetTitle( const wxString& title )
|
||||||
|
@@ -426,20 +426,6 @@ bool wxDropTarget::GetData()
|
|||||||
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
||||||
return FALSE;
|
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 );
|
m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -713,7 +699,7 @@ void wxDropSource::PrepareIcon( int hot_x, int hot_y, GdkDragContext *context )
|
|||||||
|
|
||||||
wxDragResult wxDropSource::DoDragDrop( bool allowMove )
|
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)
|
if (!m_data)
|
||||||
return (wxDragResult) wxDragNone;
|
return (wxDragResult) wxDragNone;
|
||||||
@@ -734,7 +720,7 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove )
|
|||||||
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
||||||
{
|
{
|
||||||
GdkAtom atom = array[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 );
|
gtk_target_list_add( target_list, atom, 0, 0 );
|
||||||
}
|
}
|
||||||
delete[] array;
|
delete[] array;
|
||||||
|
@@ -45,6 +45,7 @@ const int wxPLACE_HOLDER = 0;
|
|||||||
|
|
||||||
extern void wxapp_install_idle_handler();
|
extern void wxapp_install_idle_handler();
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
extern int g_openDialogs;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// data
|
// data
|
||||||
@@ -101,7 +102,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
|
|||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
win->Close();
|
if (g_openDialogs == 0)
|
||||||
|
win->Close();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -165,7 +167,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win )
|
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win )
|
||||||
#else
|
#else
|
||||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
|
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)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
if (!win->m_hasVMT) return FALSE;
|
if (!win->m_hasVMT)
|
||||||
|
return FALSE;
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
|
||||||
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||||
|
@@ -49,6 +49,9 @@ bool g_blockEventsOnDrag = FALSE;
|
|||||||
/* Don't allow mouse event propagation during scroll */
|
/* Don't allow mouse event propagation during scroll */
|
||||||
bool g_blockEventsOnScroll = FALSE;
|
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
|
/* TRUE when the message queue is empty. this gets set to
|
||||||
FALSE by all event callbacks before anything else is done */
|
FALSE by all event callbacks before anything else is done */
|
||||||
bool g_isIdle = FALSE;
|
bool g_isIdle = FALSE;
|
||||||
|
@@ -197,13 +197,23 @@ size_t wxFileDataObject::GetDataSize() const
|
|||||||
return res + 1;
|
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 */
|
const char *filenames = (const char*) buf;
|
||||||
|
size_t pos = 0;
|
||||||
AddFile( file );
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
extern void wxapp_install_idle_handler();
|
extern void wxapp_install_idle_handler();
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
extern int g_openDialogs;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// data
|
// data
|
||||||
@@ -76,7 +77,7 @@ static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win )
|
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDialog *win )
|
||||||
#else
|
#else
|
||||||
gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxDialog *win )
|
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 (!win->m_hasVMT) return FALSE;
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
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,
|
const wxPoint &pos, const wxSize &size,
|
||||||
long style, const wxString &name )
|
long style, const wxString &name )
|
||||||
{
|
{
|
||||||
|
g_openDialogs++;
|
||||||
|
|
||||||
wxTopLevelWindows.Append( this );
|
wxTopLevelWindows.Append( this );
|
||||||
|
|
||||||
m_needParent = FALSE;
|
m_needParent = FALSE;
|
||||||
@@ -322,6 +325,8 @@ wxDialog::~wxDialog()
|
|||||||
{
|
{
|
||||||
wxTheApp->ExitMainLoop();
|
wxTheApp->ExitMainLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_openDialogs--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDialog::SetTitle( const wxString& title )
|
void wxDialog::SetTitle( const wxString& title )
|
||||||
|
@@ -426,20 +426,6 @@ bool wxDropTarget::GetData()
|
|||||||
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
if (!m_dataObject->IsSupportedFormat( dragFormat ))
|
||||||
return FALSE;
|
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 );
|
m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -713,7 +699,7 @@ void wxDropSource::PrepareIcon( int hot_x, int hot_y, GdkDragContext *context )
|
|||||||
|
|
||||||
wxDragResult wxDropSource::DoDragDrop( bool allowMove )
|
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)
|
if (!m_data)
|
||||||
return (wxDragResult) wxDragNone;
|
return (wxDragResult) wxDragNone;
|
||||||
@@ -734,7 +720,7 @@ wxDragResult wxDropSource::DoDragDrop( bool allowMove )
|
|||||||
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
|
||||||
{
|
{
|
||||||
GdkAtom atom = array[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 );
|
gtk_target_list_add( target_list, atom, 0, 0 );
|
||||||
}
|
}
|
||||||
delete[] array;
|
delete[] array;
|
||||||
|
@@ -45,6 +45,7 @@ const int wxPLACE_HOLDER = 0;
|
|||||||
|
|
||||||
extern void wxapp_install_idle_handler();
|
extern void wxapp_install_idle_handler();
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
extern int g_openDialogs;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// data
|
// data
|
||||||
@@ -101,7 +102,8 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
|
|||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
win->Close();
|
if (g_openDialogs == 0)
|
||||||
|
win->Close();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -165,7 +167,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win )
|
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxFrame *win )
|
||||||
#else
|
#else
|
||||||
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
|
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)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
if (!win->m_hasVMT) return FALSE;
|
if (!win->m_hasVMT)
|
||||||
|
return FALSE;
|
||||||
#if (GTK_MINOR_VERSON > 0)
|
|
||||||
|
#if (GTK_MINOR_VERSION > 0)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
gdk_window_get_root_origin( win->m_widget->window, &x, &y );
|
||||||
|
Reference in New Issue
Block a user