Changed two conflicting defines in defs.h

DnD multiformat fine-tuning


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4069 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-10-19 15:12:11 +00:00
parent 98f026a6e4
commit a3e7d24d21
7 changed files with 147 additions and 121 deletions

View File

@ -973,19 +973,19 @@ enum wxStretch
/* /*
* wxSpinButton flags * wxSpinButton flags
*/ */
#define wxSP_VERTICAL 0x0004 #define wxSP_HORIZONTAL wxHORIZONTAL // 4
#define wxSP_HORIZONTAL 0x0008 #define wxSP_VERTICAL wxVERTICAL // 8
#define wxSP_ARROW_KEYS 0x0010 #define wxSP_ARROW_KEYS 0x0010
#define wxSP_WRAP 0x0020 #define wxSP_WRAP 0x0020
/* /*
* wxSplitterWindow flags * wxSplitterWindow flags
*/ */
#define wxSP_NOBORDER 0x0000 #define wxSP_NOBORDER 0x0000
#define wxSP_3D 0x0004 #define wxSP_3D 0x0010
#define wxSP_BORDER 0x0008 #define wxSP_BORDER 0x0020
#define wxSP_PERMIT_UNSPLIT 0x0010 #define wxSP_PERMIT_UNSPLIT 0x0040
#define wxSP_LIVE_UPDATE 0x0020 #define wxSP_LIVE_UPDATE 0x0080
/* /*
* wxFrame extra flags * wxFrame extra flags
@ -997,14 +997,14 @@ enum wxStretch
* wxTabCtrl flags * wxTabCtrl flags
*/ */
#define wxTC_MULTILINE 0x0000 #define wxTC_MULTILINE 0x0000
#define wxTC_RIGHTJUSTIFY 0x0004 #define wxTC_RIGHTJUSTIFY 0x0010
#define wxTC_FIXEDWIDTH 0x0008 #define wxTC_FIXEDWIDTH 0x0020
#define wxTC_OWNERDRAW 0x0010 #define wxTC_OWNERDRAW 0x0040
/* /*
* wxNotebook flags * wxNotebook flags
*/ */
#define wxNB_FIXEDWIDTH 0x0008 #define wxNB_FIXEDWIDTH 0x0010
#define wxNB_LEFT 0x0020 #define wxNB_LEFT 0x0020
#define wxNB_RIGHT 0x0040 #define wxNB_RIGHT 0x0040
#define wxNB_BOTTOM 0x0080 #define wxNB_BOTTOM 0x0080
@ -1012,7 +1012,7 @@ enum wxStretch
/* /*
* wxStatusBar95 flags * wxStatusBar95 flags
*/ */
#define wxST_SIZEGRIP 0x0002 #define wxST_SIZEGRIP 0x0010
/* /*
* wxStaticLine flags * wxStaticLine flags

View File

@ -79,6 +79,9 @@ public:
/* fill data with data from the dragging source */ /* fill data with data from the dragging source */
bool GetData( wxDataObject *data ); bool GetData( wxDataObject *data );
virtual size_t GetFormatCount() const = 0;
virtual wxDataFormat GetFormat(size_t n) const = 0;
// implementation // implementation
void RegisterWidget( GtkWidget *widget ); void RegisterWidget( GtkWidget *widget );
@ -106,13 +109,15 @@ public:
wxTextDropTarget() {} wxTextDropTarget() {}
virtual bool OnMove( long x, long y );
virtual bool OnDrop( long x, long y );
virtual bool OnData( long x, long y ); virtual bool OnData( long x, long y );
/* you have to override OnDropData to get at the text */ /* you have to override OnDropData to get at the text */
virtual bool OnDropText( long x, long y, const wxChar *text ) = 0; virtual bool OnDropText( long x, long y, const wxChar *text ) = 0;
virtual size_t GetFormatCount() const
{ return 1; }
virtual wxDataFormat GetFormat(size_t n) const
{ return wxDF_TEXT; }
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -152,11 +157,14 @@ public:
wxFileDropTarget() {} wxFileDropTarget() {}
virtual bool OnMove( long x, long y );
virtual bool OnDrop( long x, long y );
virtual bool OnData( long x, long y ); virtual bool OnData( long x, long y );
virtual bool OnDropFiles( long x, long y, size_t nFiles, const wxChar * const aszFiles[] ) = 0; virtual bool OnDropFiles( long x, long y, size_t nFiles, const wxChar * const aszFiles[] ) = 0;
virtual size_t GetFormatCount() const
{ return 1; }
virtual wxDataFormat GetFormat(size_t n) const
{ return wxDF_FILENAME; }
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

View File

@ -79,6 +79,9 @@ public:
/* fill data with data from the dragging source */ /* fill data with data from the dragging source */
bool GetData( wxDataObject *data ); bool GetData( wxDataObject *data );
virtual size_t GetFormatCount() const = 0;
virtual wxDataFormat GetFormat(size_t n) const = 0;
// implementation // implementation
void RegisterWidget( GtkWidget *widget ); void RegisterWidget( GtkWidget *widget );
@ -106,13 +109,15 @@ public:
wxTextDropTarget() {} wxTextDropTarget() {}
virtual bool OnMove( long x, long y );
virtual bool OnDrop( long x, long y );
virtual bool OnData( long x, long y ); virtual bool OnData( long x, long y );
/* you have to override OnDropData to get at the text */ /* you have to override OnDropData to get at the text */
virtual bool OnDropText( long x, long y, const wxChar *text ) = 0; virtual bool OnDropText( long x, long y, const wxChar *text ) = 0;
virtual size_t GetFormatCount() const
{ return 1; }
virtual wxDataFormat GetFormat(size_t n) const
{ return wxDF_TEXT; }
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -152,11 +157,14 @@ public:
wxFileDropTarget() {} wxFileDropTarget() {}
virtual bool OnMove( long x, long y );
virtual bool OnDrop( long x, long y );
virtual bool OnData( long x, long y ); virtual bool OnData( long x, long y );
virtual bool OnDropFiles( long x, long y, size_t nFiles, const wxChar * const aszFiles[] ) = 0; virtual bool OnDropFiles( long x, long y, size_t nFiles, const wxChar * const aszFiles[] ) = 0;
virtual size_t GetFormatCount() const
{ return 1; }
virtual wxDataFormat GetFormat(size_t n) const
{ return wxDF_FILENAME; }
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------

View File

@ -1064,6 +1064,7 @@ DnDShape *DnDShapeDialog::GetShape() const
bool DnDShapeDialog::TransferDataToWindow() bool DnDShapeDialog::TransferDataToWindow()
{ {
if ( m_shape ) if ( m_shape )
{ {
m_radio->SetSelection(m_shape->GetKind()); m_radio->SetSelection(m_shape->GetKind());

View File

@ -96,7 +96,7 @@ IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_PAINT( MyCanvas::OnPaint) EVT_PAINT( MyCanvas::OnPaint)
EVT_LEFT_DOWN( MyCanvas::OnMouseDown) EVT_MOUSE_EVENTS( MyCanvas::OnMouseDown)
EVT_BUTTON( ID_QUERYPOS, MyCanvas::OnQueryPosition) EVT_BUTTON( ID_QUERYPOS, MyCanvas::OnQueryPosition)
EVT_BUTTON( ID_ADDBUTTON, MyCanvas::OnAddButton) EVT_BUTTON( ID_ADDBUTTON, MyCanvas::OnAddButton)
EVT_BUTTON( ID_DELBUTTON, MyCanvas::OnDeleteButton) EVT_BUTTON( ID_DELBUTTON, MyCanvas::OnDeleteButton)
@ -178,10 +178,19 @@ MyCanvas::~MyCanvas()
void MyCanvas::OnMouseDown( wxMouseEvent &event ) void MyCanvas::OnMouseDown( wxMouseEvent &event )
{ {
wxPoint pt( event.GetPosition() ); if (event.LeftDown())
int x,y; {
CalcUnscrolledPosition( pt.x, pt.y, &x, &y ); wxPoint pt( event.GetPosition() );
wxLogMessage( "Mouse down event at: %d %d, scrolled: %d %d", pt.x, pt.y, x, y ); int x,y;
CalcUnscrolledPosition( pt.x, pt.y, &x, &y );
wxLogMessage( "Mouse down event at: %d %d, scrolled: %d %d", pt.x, pt.y, x, y );
}
if (event.LeftIsDown() &&
event.LeftDown())
{
wxLogMessage( "Error: both LeftDown() and LeftIsDown() are TRUE!" );
}
} }
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )

View File

@ -289,7 +289,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
/* Owen Taylor: "call gtk_drag_finish() with /* Owen Taylor: "call gtk_drag_finish() with
success == TRUE" */ success == TRUE" */
// printf( "data received.\n" );
if ((data->length <= 0) || (data->format != 8)) if ((data->length <= 0) || (data->format != 8))
{ {
@ -297,11 +296,11 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
qualifies for junk */ qualifies for junk */
gtk_drag_finish (context, FALSE, FALSE, time); gtk_drag_finish (context, FALSE, FALSE, time);
// printf( "no data.\n" );
return; return;
} }
wxLogDebug( wxT( "Drop target: data received") );
/* inform the wxDropTarget about the current GtkSelectionData. /* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */ this is only valid for the duration of this call */
drop_target->SetDragData( data ); drop_target->SetDragData( data );
@ -348,11 +347,32 @@ void wxDropTarget::OnLeave()
bool wxDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) ) bool wxDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
{ {
return TRUE; if (GetFormatCount() == 0)
return FALSE;
for (size_t i = 0; i < GetFormatCount(); i++)
{
if (IsSupported( GetFormat(i) ))
return TRUE;
}
return FALSE;
} }
bool wxDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) ) bool wxDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) )
{ {
if (GetFormatCount() == 0)
return FALSE;
for (size_t i = 0; i < GetFormatCount(); i++)
{
if (IsSupported( GetFormat(i) ))
{
RequestData( GetFormat(i) );
return TRUE;
}
}
return FALSE; return FALSE;
} }
@ -400,8 +420,10 @@ bool wxDropTarget::IsSupported( wxDataFormat format )
{ {
GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data); GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
// char *name = gdk_atom_name( formatAtom ); #ifdef __WXDEBUG__
// if (name) printf( "Format available: %s.\n", name ); char *name = gdk_atom_name( formatAtom );
if (name) wxLogDebug( "Drop target: drag has format: %s", name );
#endif
if (formatAtom == format) return TRUE; if (formatAtom == format) return TRUE;
child = child->next; child = child->next;
@ -491,22 +513,6 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
// wxTextDropTarget // wxTextDropTarget
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
bool wxTextDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
{
return IsSupported( wxDF_TEXT );
}
bool wxTextDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) )
{
if (IsSupported( wxDF_TEXT ))
{
RequestData( wxDF_TEXT );
return TRUE;
}
return FALSE;
}
bool wxTextDropTarget::OnData( long x, long y ) bool wxTextDropTarget::OnData( long x, long y )
{ {
wxTextDataObject data; wxTextDataObject data;
@ -565,22 +571,6 @@ bool wxPrivateDropTarget::OnData( long x, long y )
// A drop target which accepts files (dragged from File Manager or Explorer) // A drop target which accepts files (dragged from File Manager or Explorer)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool wxFileDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
{
return IsSupported( wxDF_FILENAME );
}
bool wxFileDropTarget::OnDrop( long x, long y )
{
if (IsSupported( wxDF_FILENAME ))
{
RequestData( wxDF_FILENAME );
return TRUE;
}
return FALSE;
}
bool wxFileDropTarget::OnData( long x, long y ) bool wxFileDropTarget::OnData( long x, long y )
{ {
wxFileDataObject data; wxFileDataObject data;
@ -627,10 +617,10 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
{ {
if (g_isIdle) wxapp_install_idle_handler(); if (g_isIdle) wxapp_install_idle_handler();
// printf( "Provide data!\n" ); #ifdef __WXDEBUG__
char *name = gdk_atom_name( selection_data->target );
// char *name = gdk_atom_name( selection_data->target ); if (name) wxLogDebug( wxT("Drop source: format requested: %s"), name );
// if (name) printf( "Format requested: %s.\n", name ); #endif
drop_source->m_retValue = wxDragCancel; drop_source->m_retValue = wxDragCancel;
@ -788,19 +778,29 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{ {
wxASSERT_MSG( m_data, wxT("wxDragSource: no data") ); wxASSERT_MSG( m_data, wxT("wxDragSource: no data") );
if (!m_data) return (wxDragResult) wxDragNone; if (!m_data)
return (wxDragResult) wxDragNone;
if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone;
g_blockEventsOnDrag = TRUE; g_blockEventsOnDrag = TRUE;
RegisterWindow(); RegisterWindow();
m_waiting = TRUE; m_waiting = TRUE;
GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
// printf( "atom id: %d.\n", (int)atom );
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 ); GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
gtk_target_list_add( target_list, atom, 0, 0 );
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
m_data->GetAllFormats( array, TRUE );
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
{
GdkAtom atom = array[i];
wxLogDebug( wxT("Supported atom %s"), gdk_atom_name( atom ) );
gtk_target_list_add( target_list, atom, 0, 0 );
}
delete[] array;
GdkEventMotion event; GdkEventMotion event;
event.window = m_widget->window; event.window = m_widget->window;

View File

@ -289,7 +289,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
/* Owen Taylor: "call gtk_drag_finish() with /* Owen Taylor: "call gtk_drag_finish() with
success == TRUE" */ success == TRUE" */
// printf( "data received.\n" );
if ((data->length <= 0) || (data->format != 8)) if ((data->length <= 0) || (data->format != 8))
{ {
@ -297,11 +296,11 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
qualifies for junk */ qualifies for junk */
gtk_drag_finish (context, FALSE, FALSE, time); gtk_drag_finish (context, FALSE, FALSE, time);
// printf( "no data.\n" );
return; return;
} }
wxLogDebug( wxT( "Drop target: data received") );
/* inform the wxDropTarget about the current GtkSelectionData. /* inform the wxDropTarget about the current GtkSelectionData.
this is only valid for the duration of this call */ this is only valid for the duration of this call */
drop_target->SetDragData( data ); drop_target->SetDragData( data );
@ -348,11 +347,32 @@ void wxDropTarget::OnLeave()
bool wxDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) ) bool wxDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
{ {
return TRUE; if (GetFormatCount() == 0)
return FALSE;
for (size_t i = 0; i < GetFormatCount(); i++)
{
if (IsSupported( GetFormat(i) ))
return TRUE;
}
return FALSE;
} }
bool wxDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) ) bool wxDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) )
{ {
if (GetFormatCount() == 0)
return FALSE;
for (size_t i = 0; i < GetFormatCount(); i++)
{
if (IsSupported( GetFormat(i) ))
{
RequestData( GetFormat(i) );
return TRUE;
}
}
return FALSE; return FALSE;
} }
@ -400,8 +420,10 @@ bool wxDropTarget::IsSupported( wxDataFormat format )
{ {
GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data); GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
// char *name = gdk_atom_name( formatAtom ); #ifdef __WXDEBUG__
// if (name) printf( "Format available: %s.\n", name ); char *name = gdk_atom_name( formatAtom );
if (name) wxLogDebug( "Drop target: drag has format: %s", name );
#endif
if (formatAtom == format) return TRUE; if (formatAtom == format) return TRUE;
child = child->next; child = child->next;
@ -491,22 +513,6 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
// wxTextDropTarget // wxTextDropTarget
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
bool wxTextDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
{
return IsSupported( wxDF_TEXT );
}
bool wxTextDropTarget::OnDrop( long WXUNUSED(x), long WXUNUSED(y) )
{
if (IsSupported( wxDF_TEXT ))
{
RequestData( wxDF_TEXT );
return TRUE;
}
return FALSE;
}
bool wxTextDropTarget::OnData( long x, long y ) bool wxTextDropTarget::OnData( long x, long y )
{ {
wxTextDataObject data; wxTextDataObject data;
@ -565,22 +571,6 @@ bool wxPrivateDropTarget::OnData( long x, long y )
// A drop target which accepts files (dragged from File Manager or Explorer) // A drop target which accepts files (dragged from File Manager or Explorer)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool wxFileDropTarget::OnMove( long WXUNUSED(x), long WXUNUSED(y) )
{
return IsSupported( wxDF_FILENAME );
}
bool wxFileDropTarget::OnDrop( long x, long y )
{
if (IsSupported( wxDF_FILENAME ))
{
RequestData( wxDF_FILENAME );
return TRUE;
}
return FALSE;
}
bool wxFileDropTarget::OnData( long x, long y ) bool wxFileDropTarget::OnData( long x, long y )
{ {
wxFileDataObject data; wxFileDataObject data;
@ -627,10 +617,10 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
{ {
if (g_isIdle) wxapp_install_idle_handler(); if (g_isIdle) wxapp_install_idle_handler();
// printf( "Provide data!\n" ); #ifdef __WXDEBUG__
char *name = gdk_atom_name( selection_data->target );
// char *name = gdk_atom_name( selection_data->target ); if (name) wxLogDebug( wxT("Drop source: format requested: %s"), name );
// if (name) printf( "Format requested: %s.\n", name ); #endif
drop_source->m_retValue = wxDragCancel; drop_source->m_retValue = wxDragCancel;
@ -788,19 +778,29 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{ {
wxASSERT_MSG( m_data, wxT("wxDragSource: no data") ); wxASSERT_MSG( m_data, wxT("wxDragSource: no data") );
if (!m_data) return (wxDragResult) wxDragNone; if (!m_data)
return (wxDragResult) wxDragNone;
if (m_data->GetFormatCount() == 0)
return (wxDragResult) wxDragNone;
g_blockEventsOnDrag = TRUE; g_blockEventsOnDrag = TRUE;
RegisterWindow(); RegisterWindow();
m_waiting = TRUE; m_waiting = TRUE;
GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
// printf( "atom id: %d.\n", (int)atom );
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 ); GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
gtk_target_list_add( target_list, atom, 0, 0 );
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
m_data->GetAllFormats( array, TRUE );
for (size_t i = 0; i < m_data->GetFormatCount(); i++)
{
GdkAtom atom = array[i];
wxLogDebug( wxT("Supported atom %s"), gdk_atom_name( atom ) );
gtk_target_list_add( target_list, atom, 0, 0 );
}
delete[] array;
GdkEventMotion event; GdkEventMotion event;
event.window = m_widget->window; event.window = m_widget->window;