]> git.saurik.com Git - wxWidgets.git/commitdiff
Changed two conflicting defines in defs.h
authorRobert Roebling <robert@roebling.de>
Tue, 19 Oct 1999 15:12:11 +0000 (15:12 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 19 Oct 1999 15:12:11 +0000 (15:12 +0000)
  DnD multiformat fine-tuning

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4069 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/defs.h
include/wx/gtk/dnd.h
include/wx/gtk1/dnd.h
samples/dnd/dnd.cpp
samples/scroll/scroll.cpp
src/gtk/dnd.cpp
src/gtk1/dnd.cpp

index ed28273f398be3a2f272ac2f7ae44349c4f19a24..fac77814675a603ecbadd0342c89cdef62297ac9 100644 (file)
@@ -973,19 +973,19 @@ enum wxStretch
 /*
  * wxSpinButton flags
  */
-#define wxSP_VERTICAL       0x0004
-#define wxSP_HORIZONTAL     0x0008
-#define wxSP_ARROW_KEYS     0x0010
-#define wxSP_WRAP           0x0020
+#define wxSP_HORIZONTAL       wxHORIZONTAL // 4
+#define wxSP_VERTICAL         wxVERTICAL   // 8
+#define wxSP_ARROW_KEYS       0x0010
+#define wxSP_WRAP             0x0020
 
 /*
  * wxSplitterWindow flags
  */
-#define wxSP_NOBORDER       0x0000
-#define wxSP_3D             0x0004
-#define wxSP_BORDER         0x0008
-#define wxSP_PERMIT_UNSPLIT 0x0010
-#define wxSP_LIVE_UPDATE    0x0020
+#define wxSP_NOBORDER         0x0000
+#define wxSP_3D               0x0010
+#define wxSP_BORDER           0x0020
+#define wxSP_PERMIT_UNSPLIT   0x0040
+#define wxSP_LIVE_UPDATE      0x0080
 
 /*
  * wxFrame extra flags
@@ -997,14 +997,14 @@ enum wxStretch
  * wxTabCtrl flags
  */
 #define wxTC_MULTILINE        0x0000
-#define wxTC_RIGHTJUSTIFY     0x0004
-#define wxTC_FIXEDWIDTH       0x0008
-#define wxTC_OWNERDRAW        0x0010
+#define wxTC_RIGHTJUSTIFY     0x0010
+#define wxTC_FIXEDWIDTH       0x0020
+#define wxTC_OWNERDRAW        0x0040
 
 /*
  * wxNotebook flags
  */
-#define wxNB_FIXEDWIDTH       0x0008
+#define wxNB_FIXEDWIDTH       0x0010
 #define wxNB_LEFT             0x0020
 #define wxNB_RIGHT            0x0040
 #define wxNB_BOTTOM           0x0080
@@ -1012,7 +1012,7 @@ enum wxStretch
 /*
  * wxStatusBar95 flags
  */
-#define wxST_SIZEGRIP         0x0002
+#define wxST_SIZEGRIP         0x0010
 
 /*
  * wxStaticLine flags
index 225c809209b456641d4298783c39b73e37857c98..52a4c8550b09910794cd91dce8fcbb6e66f12e49 100644 (file)
@@ -79,6 +79,9 @@ public:
   /* fill data with data from the dragging source */
   bool GetData( wxDataObject *data );
 
+  virtual size_t GetFormatCount() const = 0;
+  virtual wxDataFormat GetFormat(size_t n) const = 0;
+  
 // implementation
 
   void RegisterWidget( GtkWidget *widget );
@@ -106,13 +109,15 @@ public:
 
   wxTextDropTarget() {}
 
-  virtual bool OnMove( long x, long y );
-  virtual bool OnDrop( long x, long y );
   virtual bool OnData( long x, long y );
 
   /* you have to override OnDropData to get at the text */
   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() {}
 
-  virtual bool OnMove( long x, long y );
-  virtual bool OnDrop( 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 size_t GetFormatCount() const
+    { return 1; }
+  virtual wxDataFormat GetFormat(size_t n) const
+    { return wxDF_FILENAME; }
 };
 
 //-------------------------------------------------------------------------
index 225c809209b456641d4298783c39b73e37857c98..52a4c8550b09910794cd91dce8fcbb6e66f12e49 100644 (file)
@@ -79,6 +79,9 @@ public:
   /* fill data with data from the dragging source */
   bool GetData( wxDataObject *data );
 
+  virtual size_t GetFormatCount() const = 0;
+  virtual wxDataFormat GetFormat(size_t n) const = 0;
+  
 // implementation
 
   void RegisterWidget( GtkWidget *widget );
@@ -106,13 +109,15 @@ public:
 
   wxTextDropTarget() {}
 
-  virtual bool OnMove( long x, long y );
-  virtual bool OnDrop( long x, long y );
   virtual bool OnData( long x, long y );
 
   /* you have to override OnDropData to get at the text */
   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() {}
 
-  virtual bool OnMove( long x, long y );
-  virtual bool OnDrop( 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 size_t GetFormatCount() const
+    { return 1; }
+  virtual wxDataFormat GetFormat(size_t n) const
+    { return wxDF_FILENAME; }
 };
 
 //-------------------------------------------------------------------------
index 99267a4a7226b6ca77764c7a37e10517633fb5f2..9ce9518b12ac0b1fcf51f0d2dad4a82ce2509b75 100644 (file)
@@ -1064,6 +1064,7 @@ DnDShape *DnDShapeDialog::GetShape() const
 
 bool DnDShapeDialog::TransferDataToWindow()
 {
+
     if ( m_shape )
     {
         m_radio->SetSelection(m_shape->GetKind());
index 3567376359a8b2ff1f2c9270ea8c1c031f8d91a2..d1a03c1ab6289961c9415c79d0ce2dffb437788d 100644 (file)
@@ -96,7 +96,7 @@ IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow)
 
 BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
   EVT_PAINT(                  MyCanvas::OnPaint)
-  EVT_LEFT_DOWN(              MyCanvas::OnMouseDown)
+  EVT_MOUSE_EVENTS(                  MyCanvas::OnMouseDown)
   EVT_BUTTON( ID_QUERYPOS,    MyCanvas::OnQueryPosition)
   EVT_BUTTON( ID_ADDBUTTON,   MyCanvas::OnAddButton)
   EVT_BUTTON( ID_DELBUTTON,   MyCanvas::OnDeleteButton)
@@ -178,10 +178,19 @@ MyCanvas::~MyCanvas()
 
 void MyCanvas::OnMouseDown( wxMouseEvent &event )
 {
-    wxPoint pt( event.GetPosition() );
-    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.LeftDown())
+    {
+        wxPoint pt( event.GetPosition() );
+        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) )
index dbf3456d02d239b9dd87962c04dc059455698217..d8ba14eba0b47555ecc3543b3065db5dff0f3ea3 100644 (file)
@@ -289,7 +289,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
     /* Owen Taylor: "call gtk_drag_finish() with
        success == TRUE" */
 
-//    printf( "data received.\n" );
 
     if ((data->length <= 0) || (data->format != 8))
     {
@@ -297,11 +296,11 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
            qualifies for junk */
         gtk_drag_finish (context, FALSE, FALSE, time);
 
-//        printf( "no data.\n" );
-
         return;
     }
 
+    wxLogDebug( wxT( "Drop target: data received") );
+    
     /* inform the wxDropTarget about the current GtkSelectionData.
        this is only valid for the duration of this call */
     drop_target->SetDragData( data );
@@ -348,11 +347,32 @@ void wxDropTarget::OnLeave()
 
 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) )
 {
+    if (GetFormatCount() == 0)
+        return FALSE;
+       
+    for (size_t i = 0; i < GetFormatCount(); i++)
+    {
+        if (IsSupported( GetFormat(i) ))
+       {
+            RequestData( GetFormat(i) );
+           return TRUE;
+       }
+    }
+    
     return FALSE;
 }
 
@@ -400,8 +420,10 @@ bool wxDropTarget::IsSupported( wxDataFormat format )
     {
         GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
 
-//        char *name = gdk_atom_name( formatAtom );
-//        if (name) printf( "Format available: %s.\n", name );
+#ifdef __WXDEBUG__
+        char *name = gdk_atom_name( formatAtom );
+        if (name) wxLogDebug( "Drop target: drag has format: %s", name );
+#endif
 
         if (formatAtom == format) return TRUE;
         child = child->next;
@@ -491,22 +513,6 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
 // 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 )
 {
     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)
 //----------------------------------------------------------------------------
 
-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 )
 {
     wxFileDataObject data;
@@ -627,10 +617,10 @@ source_drag_data_get  (GtkWidget          *WXUNUSED(widget),
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "Provide data!\n" );
-
-//    char *name = gdk_atom_name( selection_data->target );
-//    if (name) printf( "Format requested: %s.\n", name );
+#ifdef __WXDEBUG__
+    char *name = gdk_atom_name( selection_data->target );
+    if (name) wxLogDebug( wxT("Drop source: format requested: %s"), name );
+#endif
 
     drop_source->m_retValue = wxDragCancel;
     
@@ -788,19 +778,29 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
 {
     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;
 
     RegisterWindow();
 
     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 );
-    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;
     event.window = m_widget->window;
index dbf3456d02d239b9dd87962c04dc059455698217..d8ba14eba0b47555ecc3543b3065db5dff0f3ea3 100644 (file)
@@ -289,7 +289,6 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
     /* Owen Taylor: "call gtk_drag_finish() with
        success == TRUE" */
 
-//    printf( "data received.\n" );
 
     if ((data->length <= 0) || (data->format != 8))
     {
@@ -297,11 +296,11 @@ static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
            qualifies for junk */
         gtk_drag_finish (context, FALSE, FALSE, time);
 
-//        printf( "no data.\n" );
-
         return;
     }
 
+    wxLogDebug( wxT( "Drop target: data received") );
+    
     /* inform the wxDropTarget about the current GtkSelectionData.
        this is only valid for the duration of this call */
     drop_target->SetDragData( data );
@@ -348,11 +347,32 @@ void wxDropTarget::OnLeave()
 
 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) )
 {
+    if (GetFormatCount() == 0)
+        return FALSE;
+       
+    for (size_t i = 0; i < GetFormatCount(); i++)
+    {
+        if (IsSupported( GetFormat(i) ))
+       {
+            RequestData( GetFormat(i) );
+           return TRUE;
+       }
+    }
+    
     return FALSE;
 }
 
@@ -400,8 +420,10 @@ bool wxDropTarget::IsSupported( wxDataFormat format )
     {
         GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data);
 
-//        char *name = gdk_atom_name( formatAtom );
-//        if (name) printf( "Format available: %s.\n", name );
+#ifdef __WXDEBUG__
+        char *name = gdk_atom_name( formatAtom );
+        if (name) wxLogDebug( "Drop target: drag has format: %s", name );
+#endif
 
         if (formatAtom == format) return TRUE;
         child = child->next;
@@ -491,22 +513,6 @@ void wxDropTarget::RegisterWidget( GtkWidget *widget )
 // 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 )
 {
     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)
 //----------------------------------------------------------------------------
 
-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 )
 {
     wxFileDataObject data;
@@ -627,10 +617,10 @@ source_drag_data_get  (GtkWidget          *WXUNUSED(widget),
 {
     if (g_isIdle) wxapp_install_idle_handler();
 
-//    printf( "Provide data!\n" );
-
-//    char *name = gdk_atom_name( selection_data->target );
-//    if (name) printf( "Format requested: %s.\n", name );
+#ifdef __WXDEBUG__
+    char *name = gdk_atom_name( selection_data->target );
+    if (name) wxLogDebug( wxT("Drop source: format requested: %s"), name );
+#endif
 
     drop_source->m_retValue = wxDragCancel;
     
@@ -788,19 +778,29 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
 {
     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;
 
     RegisterWindow();
 
     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 );
-    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;
     event.window = m_widget->window;