little doc updates

removed GTK 1.0 Drag'n'Drop
  added (const char*) constructor to wxDataFormat
  added -I pointing to embedded /png and /jpeg dirs
  corrected frame/dialog resizing


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-04-20 10:09:15 +00:00
parent 75737d0570
commit 8a126fcc34
19 changed files with 174 additions and 1748 deletions

View File

@@ -57,10 +57,10 @@ this has no effect, but I tried...
----------------------- -----------------------
wxWindows/GTK requires the GTK+ library to be installed on your system. wxWindows/GTK requires the GTK+ library to be installed on your system.
It has to be a stable version, preferebly version 1.2.1. It might also It has to be a stable version, preferebly version 1.2.1. You can use
work with the 1.0 series, but I didn't test that any longer. GTK 1.0.X in connection with wxWindows, but we don't support Drag'n'Drop
for GTK 1.0.X so you have to "configure --without-dnd". wxWindows does
wxWindows/GTK does NOT work with the 1.1.X versions of the GTK+ library. NOT work with the 1.1.X versions of the GTK+ library.
You can get the newest version of the GTK+ from the GTK homepage You can get the newest version of the GTK+ from the GTK homepage
at at

View File

@@ -1,5 +1,5 @@
Welcome to wxWindows/Gtk 2.1 beta 1, Welcome to wxWindows/Gtk 2.1 beta 2,
you have downloaded version 2.1 of the GTK+ 1.2 port of you have downloaded version 2.1 of the GTK+ 1.2 port of
the wxWindows GUI library. This is a developers release the wxWindows GUI library. This is a developers release
@@ -19,7 +19,7 @@ at Julian Smart's homepage at:
Information on how to install can be found in the file Information on how to install can be found in the file
INSTALL.txt, but if you cannot wait, this should work on INSTALL.txt, but if you cannot wait, this should work on
all systems many systems (when using GTK 1.0 read the INSTALL.txt):
./configure ./configure
make make

View File

@@ -2,7 +2,7 @@
-------------------- High priority --------------------- -------------------- High priority ---------------------
DnD DnD
-> Must be rewritten for GTK+ 1.2 -> Must be rewritten for GTK+ 1.2. Much done.
-------------------- Medium priority --------------------- -------------------- Medium priority ---------------------

View File

@@ -1122,6 +1122,7 @@ typedef struct _GdkWindow GdkBitmap;
typedef struct _GdkWindow GdkPixmap; typedef struct _GdkWindow GdkPixmap;
typedef struct _GdkCursor GdkCursor; typedef struct _GdkCursor GdkCursor;
typedef struct _GdkRegion GdkRegion; typedef struct _GdkRegion GdkRegion;
typedef struct _GdkDragContext GdkDragContext;
/* Stand-ins for GTK types */ /* Stand-ins for GTK types */
typedef struct _GtkWidget GtkWidget; typedef struct _GtkWidget GtkWidget;
@@ -1134,6 +1135,7 @@ typedef struct _GtkNotebook GtkNotebook;
typedef struct _GtkNotebookPage GtkNotebookPage; typedef struct _GtkNotebookPage GtkNotebookPage;
typedef struct _GtkAccelGroup GtkAccelGroup; typedef struct _GtkAccelGroup GtkAccelGroup;
typedef struct _GtkItemFactory GtkItemFactory; typedef struct _GtkItemFactory GtkItemFactory;
typedef struct _GtkSelectionData GtkSelectionData;
#endif #endif

View File

@@ -70,6 +70,7 @@ public:
wxDataFormat(); wxDataFormat();
wxDataFormat( wxDataType type ); wxDataFormat( wxDataType type );
wxDataFormat( const wxString &id ); wxDataFormat( const wxString &id );
wxDataFormat( const char *id );
wxDataFormat( wxDataFormat &format ); wxDataFormat( wxDataFormat &format );
wxDataFormat( const GdkAtom atom ); wxDataFormat( const GdkAtom atom );
@@ -77,7 +78,7 @@ public:
wxDataType GetType() const; wxDataType GetType() const;
wxString GetId() const; wxString GetId() const;
void SetId( const wxString &id ); void SetId( const char *id );
GdkAtom GetAtom(); GdkAtom GetAtom();

View File

@@ -39,68 +39,6 @@ class wxPrivateDropTarget;
class wxDropSource; class wxDropSource;
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
enum wxDragResult
{
wxDragError, // error prevented the d&d operation from completing
wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
class wxDropSource: public wxObject
{
public:
/* constructor. set data later with SetData() */
wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
/* constructor for setting one data object */
wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
/* constructor for setting several data objects via wxDataBroker */
wxDropSource( wxDataBroker *data, wxWindow *win );
~wxDropSource();
/* set several dataobjects via wxDataBroker */
void SetData( wxDataBroker *data );
/* set one dataobject */
void SetData( wxDataObject *data );
/* start drag action */
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
/* override to give feedback */
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
/* GTK implementation */
void RegisterWindow();
void UnregisterWindow();
GtkWidget *m_widget;
wxWindow *m_window;
wxDragResult m_retValue;
wxDataBroker *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
wxIcon m_goIcon;
wxIcon m_stopIcon;
bool m_waiting;
};
#include "gtk/gtk.h"
#if (GTK_MINOR_VERSION > 0)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDropTarget // wxDropTarget
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -229,105 +167,65 @@ public:
}; };
#else
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDropTarget // wxDropSource
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class wxDropTarget: public wxObject enum wxDragResult
{
wxDragError, // error prevented the d&d operation from completing
wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
class wxDropSource: public wxObject
{ {
public: public:
wxDropTarget(); /* constructor. set data later with SetData() */
~wxDropTarget(); wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
virtual void OnEnter() { } /* constructor for setting one data object */
virtual void OnLeave() { } wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
virtual void OnMouseMove( long WXUNUSED(x), long WXUNUSED(y) ) { }
virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
// Override these to indicate what kind of data you support: /* constructor for setting several data objects via wxDataBroker */
wxDropSource( wxDataBroker *data, wxWindow *win );
virtual size_t GetFormatCount() const = 0; ~wxDropSource();
virtual wxDataFormat &GetFormat(size_t n) const;
// implementation /* set several dataobjects via wxDataBroker */
void SetData( wxDataBroker *data );
void RegisterWidget( GtkWidget *widget ); /* set one dataobject */
void UnregisterWidget( GtkWidget *widget ); void SetData( wxDataObject *data );
wxDataFormat *m_format; /* start drag action */
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
/* override to give feedback */
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
/* GTK implementation */
void RegisterWindow();
void UnregisterWindow();
GtkWidget *m_widget;
wxWindow *m_window;
wxDragResult m_retValue;
wxDataBroker *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
wxIcon m_goIcon;
wxIcon m_stopIcon;
bool m_waiting;
}; };
//-------------------------------------------------------------------------
// wxTextDropTarget
//-------------------------------------------------------------------------
class wxTextDropTarget: public wxDropTarget
{
public:
wxTextDropTarget();
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropText( long x, long y, const char *psz );
protected:
virtual size_t GetFormatCount() const;
};
//-------------------------------------------------------------------------
// wxPrivateDropTarget
//-------------------------------------------------------------------------
class wxPrivateDropTarget: public wxDropTarget
{
public:
wxPrivateDropTarget();
// you have to override OnDrop to get at the data
// the string ID identifies the format of clipboard or DnD data. a word
// processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
// to the clipboard - the latter with the Id "application/wxword" or
// "image/png".
void SetId( const wxString& id );
wxString GetId()
{ return m_id; }
private:
virtual size_t GetFormatCount() const;
wxString m_id;
};
//----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
//----------------------------------------------------------------------------
class wxFileDropTarget: public wxDropTarget
{
public:
wxFileDropTarget();
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropFiles( long x, long y,
size_t nFiles, const char * const aszFiles[] );
protected:
virtual size_t GetFormatCount() const;
};
#endif
#endif #endif
// wxUSE_DRAG_AND_DROP // wxUSE_DRAG_AND_DROP

View File

@@ -70,6 +70,7 @@ public:
wxDataFormat(); wxDataFormat();
wxDataFormat( wxDataType type ); wxDataFormat( wxDataType type );
wxDataFormat( const wxString &id ); wxDataFormat( const wxString &id );
wxDataFormat( const char *id );
wxDataFormat( wxDataFormat &format ); wxDataFormat( wxDataFormat &format );
wxDataFormat( const GdkAtom atom ); wxDataFormat( const GdkAtom atom );
@@ -77,7 +78,7 @@ public:
wxDataType GetType() const; wxDataType GetType() const;
wxString GetId() const; wxString GetId() const;
void SetId( const wxString &id ); void SetId( const char *id );
GdkAtom GetAtom(); GdkAtom GetAtom();

View File

@@ -39,68 +39,6 @@ class wxPrivateDropTarget;
class wxDropSource; class wxDropSource;
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
enum wxDragResult
{
wxDragError, // error prevented the d&d operation from completing
wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
class wxDropSource: public wxObject
{
public:
/* constructor. set data later with SetData() */
wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
/* constructor for setting one data object */
wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
/* constructor for setting several data objects via wxDataBroker */
wxDropSource( wxDataBroker *data, wxWindow *win );
~wxDropSource();
/* set several dataobjects via wxDataBroker */
void SetData( wxDataBroker *data );
/* set one dataobject */
void SetData( wxDataObject *data );
/* start drag action */
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
/* override to give feedback */
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
/* GTK implementation */
void RegisterWindow();
void UnregisterWindow();
GtkWidget *m_widget;
wxWindow *m_window;
wxDragResult m_retValue;
wxDataBroker *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
wxIcon m_goIcon;
wxIcon m_stopIcon;
bool m_waiting;
};
#include "gtk/gtk.h"
#if (GTK_MINOR_VERSION > 0)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDropTarget // wxDropTarget
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -229,105 +167,65 @@ public:
}; };
#else
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// wxDropTarget // wxDropSource
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class wxDropTarget: public wxObject enum wxDragResult
{
wxDragError, // error prevented the d&d operation from completing
wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
class wxDropSource: public wxObject
{ {
public: public:
wxDropTarget(); /* constructor. set data later with SetData() */
~wxDropTarget(); wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
virtual void OnEnter() { } /* constructor for setting one data object */
virtual void OnLeave() { } wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon );
virtual void OnMouseMove( long WXUNUSED(x), long WXUNUSED(y) ) { }
virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
// Override these to indicate what kind of data you support: /* constructor for setting several data objects via wxDataBroker */
wxDropSource( wxDataBroker *data, wxWindow *win );
virtual size_t GetFormatCount() const = 0; ~wxDropSource();
virtual wxDataFormat &GetFormat(size_t n) const;
// implementation /* set several dataobjects via wxDataBroker */
void SetData( wxDataBroker *data );
void RegisterWidget( GtkWidget *widget ); /* set one dataobject */
void UnregisterWidget( GtkWidget *widget ); void SetData( wxDataObject *data );
wxDataFormat *m_format; /* start drag action */
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
/* override to give feedback */
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
/* GTK implementation */
void RegisterWindow();
void UnregisterWindow();
GtkWidget *m_widget;
wxWindow *m_window;
wxDragResult m_retValue;
wxDataBroker *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
wxIcon m_goIcon;
wxIcon m_stopIcon;
bool m_waiting;
}; };
//-------------------------------------------------------------------------
// wxTextDropTarget
//-------------------------------------------------------------------------
class wxTextDropTarget: public wxDropTarget
{
public:
wxTextDropTarget();
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropText( long x, long y, const char *psz );
protected:
virtual size_t GetFormatCount() const;
};
//-------------------------------------------------------------------------
// wxPrivateDropTarget
//-------------------------------------------------------------------------
class wxPrivateDropTarget: public wxDropTarget
{
public:
wxPrivateDropTarget();
// you have to override OnDrop to get at the data
// the string ID identifies the format of clipboard or DnD data. a word
// processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
// to the clipboard - the latter with the Id "application/wxword" or
// "image/png".
void SetId( const wxString& id );
wxString GetId()
{ return m_id; }
private:
virtual size_t GetFormatCount() const;
wxString m_id;
};
//----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
//----------------------------------------------------------------------------
class wxFileDropTarget: public wxDropTarget
{
public:
wxFileDropTarget();
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropFiles( long x, long y,
size_t nFiles, const char * const aszFiles[] );
protected:
virtual size_t GetFormatCount() const;
};
#endif
#endif #endif
// wxUSE_DRAG_AND_DROP // wxUSE_DRAG_AND_DROP

View File

@@ -18,7 +18,7 @@
#define wxRELEASE_NUMBER 0 #define wxRELEASE_NUMBER 0
#define wxVERSION_STRING "wxWindows 2.1.0" #define wxVERSION_STRING "wxWindows 2.1.0"
#define wxVERSION_NUMBER (wxMAJOR_VERSION * 1000) + (wxMINOR_VERSION * 100) + wxRELEASE_NUMBER #define wxVERSION_NUMBER (wxMAJOR_VERSION * 1000) + (wxMINOR_VERSION * 100) + wxRELEASE_NUMBER
#define wxBETA_NUMBER 1 #define wxBETA_NUMBER 2
#define wxVERSION_FLOAT wxMAJOR_VERSION + (wxMINOR_VERSION/10.0) + (wxRELEASE_NUMBER/100.0) + (wxBETA_NUMBER/10000.0) #define wxVERSION_FLOAT wxMAJOR_VERSION + (wxMINOR_VERSION/10.0) + (wxRELEASE_NUMBER/100.0) + (wxBETA_NUMBER/10000.0)
#endif #endif

View File

@@ -94,11 +94,13 @@ POSIX4_LINK=@POSIX4_LINK@
# INCLUDES # INCLUDES
WX_INCLUDES = \ WX_INCLUDES = \
-I$(WXBASEDIR)/src/zlib \
-I$(WXBASEDIR)/src/png \
-I$(WXBASEDIR)/src/jpeg \
$(TOOLKIT_DEF) \ $(TOOLKIT_DEF) \
-I$(WXBASEDIR)/include \ -I$(WXBASEDIR)/include \
-I. \ -I. \
$(GUI_TK_INCLUDE) \ $(GUI_TK_INCLUDE) \
-I$(WXBASEDIR)/src/zlib \
-I$(WXBASEDIR)/src/iodbc \ -I$(WXBASEDIR)/src/iodbc \
$(X_CFLAGS) $(X_CFLAGS)

View File

@@ -44,6 +44,12 @@ wxDataFormat::wxDataFormat( wxDataType type )
SetType( type ); SetType( type );
} }
wxDataFormat::wxDataFormat( const char *id )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
SetId( id );
}
wxDataFormat::wxDataFormat( const wxString &id ) wxDataFormat::wxDataFormat( const wxString &id )
{ {
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
@@ -121,7 +127,7 @@ wxString wxDataFormat::GetId() const
return m_id; return m_id;
} }
void wxDataFormat::SetId( const wxString &id ) void wxDataFormat::SetId( const char *id )
{ {
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
m_id = id; m_id = id;

View File

@@ -149,14 +149,13 @@ bool wxDialog::Create( wxWindow *parent,
recognized by other WM as well. not tested. */ recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL; long decor = (long) GDK_DECOR_ALL;
long func = (long) GDK_FUNC_ALL; long func = (long) GDK_FUNC_ALL;
if ((m_windowStyle & wxCAPTION) == 0) if ((m_windowStyle & wxCAPTION) == 0)
decor |= GDK_DECOR_TITLE; decor |= GDK_DECOR_TITLE;
/* /* if ((m_windowStyle & wxMINIMIZE) == 0)
if ((m_windowStyle & wxMINIMIZE) == 0)
func |= GDK_FUNC_MINIMIZE; func |= GDK_FUNC_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE) == 0) if ((m_windowStyle & wxMAXIMIZE) == 0)
func |= GDK_FUNC_MAXIMIZE; func |= GDK_FUNC_MAXIMIZE; */
*/
if ((m_windowStyle & wxSYSTEM_MENU) == 0) if ((m_windowStyle & wxSYSTEM_MENU) == 0)
decor |= GDK_DECOR_MENU; decor |= GDK_DECOR_MENU;
if ((m_windowStyle & wxMINIMIZE_BOX) == 0) if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
@@ -165,9 +164,16 @@ bool wxDialog::Create( wxWindow *parent,
decor |= GDK_DECOR_MAXIMIZE; decor |= GDK_DECOR_MAXIMIZE;
if ((m_windowStyle & wxRESIZE_BORDER) == 0) if ((m_windowStyle & wxRESIZE_BORDER) == 0)
func |= GDK_FUNC_RESIZE; func |= GDK_FUNC_RESIZE;
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func); gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
else
gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );

View File

@@ -25,7 +25,8 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include <X11/Xlib.h> #include "gtk/gtkdnd.h"
#include "gtk/gtkselection.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// global data // global data
@@ -123,11 +124,6 @@ static char * page_xpm[] = {
" ......................... "}; " ......................... "};
#if (GTK_MINOR_VERSION > 0)
#include "gtk/gtkdnd.h"
#include "gtk/gtkselection.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// "drag_leave" // "drag_leave"
@@ -846,705 +842,6 @@ void wxDropSource::UnregisterWindow()
GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this ); GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
} }
#else // NEW_CODE
//----------------------------------------------------------------------------
// forward
//----------------------------------------------------------------------------
GtkWidget *shape_create_icon ( const wxIcon &shape,
gint x,
gint y,
gint px,
gint py,
gint window_type);
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------
wxDropSource *gs_currentDropSource = (wxDropSource*) NULL;
//-----------------------------------------------------------------------------
// "drop_enter_event"
//-----------------------------------------------------------------------------
static void gtk_target_enter_callback( GtkWidget *WXUNUSED(widget),
GdkEventDropEnter *WXUNUSED(event),
wxDropTarget *target )
{
if (target)
target->OnEnter();
}
//-----------------------------------------------------------------------------
// "drop_leave_event"
//-----------------------------------------------------------------------------
static void gtk_target_leave_callback( GtkWidget *WXUNUSED(widget),
GdkEventDropLeave *WXUNUSED(event),
wxDropTarget *target )
{
if (target)
target->OnLeave();
}
//-----------------------------------------------------------------------------
// "drop_data_available_event"
//-----------------------------------------------------------------------------
static void gtk_target_callback( GtkWidget *widget,
GdkEventDropDataAvailable *event,
wxDropTarget *target )
{
if (target)
{
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
/*
printf( "Drop data is of type %s.\n", event->data_type );
*/
target->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes );
}
/*
g_free (event->data);
g_free (event->data_type);
*/
}
// ----------------------------------------------------------------------------
// wxDropTarget
// ----------------------------------------------------------------------------
wxDropTarget::wxDropTarget()
{
m_format = (wxDataFormat*) NULL;
}
wxDropTarget::~wxDropTarget()
{
if (m_format) delete m_format;
}
wxDataFormat &wxDropTarget::GetFormat(size_t n) const
{
return (*m_format);
}
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
if (!widget) return;
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
GTK_SIGNAL_FUNC(gtk_target_callback), (gpointer) this );
gtk_widget_dnd_drop_set( widget, FALSE, (gchar **) NULL, 0, FALSE );
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
{
wxString formats;
int valid = 0;
for ( size_t i = 0; i < GetFormatCount(); i++ )
{
switch (GetFormat(i).GetType())
{
case wxDF_TEXT:
{
if (i > 0) formats += ";";
formats += "text/plain";
valid++;
break;
}
case wxDF_FILENAME:
{
if (i > 0) formats += ";";
formats += "file:ALL";
valid++;
break;
}
case wxDF_PRIVATE:
{
if (i > 0) formats += ";";
wxPrivateDropTarget *pdt = (wxPrivateDropTarget *)this;
formats += pdt->GetId();
valid++;
break;
}
default:
break;
}
}
char *str = WXSTRINGCAST formats;
gtk_widget_dnd_drop_set( widget, TRUE, &str, valid, FALSE );
gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
GTK_SIGNAL_FUNC(gtk_target_callback), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drop_enter_event",
GTK_SIGNAL_FUNC(gtk_target_enter_callback), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drop_leave_event",
GTK_SIGNAL_FUNC(gtk_target_leave_callback), (gpointer) this );
}
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
wxTextDropTarget::wxTextDropTarget()
{
m_format = new wxDataFormat( wxDF_TEXT );
}
bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
{
OnDropText( x, y, (const char*)data );
return TRUE;
}
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
{
/*
printf( "Got dropped text: %s.\n", psz );
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
*/
return TRUE;
}
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
}
// ----------------------------------------------------------------------------
// wxPrivateDropTarget
// ----------------------------------------------------------------------------
wxPrivateDropTarget::wxPrivateDropTarget()
{
m_id = wxTheApp->GetAppName();
m_format = new wxDataFormat( m_id );
}
void wxPrivateDropTarget::SetId( const wxString& id )
{
m_id = id;
m_format->SetId( id );
}
size_t wxPrivateDropTarget::GetFormatCount() const
{
return 1;
}
// ----------------------------------------------------------------------------
// wxFileDropTarget
// ----------------------------------------------------------------------------
wxFileDropTarget::wxFileDropTarget()
{
m_format = new wxDataFormat( wxDF_FILENAME );
}
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
{
printf( "Got %d dropped files.\n", (int)nFiles );
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
for (size_t i = 0; i < nFiles; i++)
{
printf( aszFiles[i] );
printf( "\n" );
}
return TRUE;
}
bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
{
size_t number = 0;
size_t i;
char *text = (char*) data;
for ( i = 0; i < size; i++)
if (text[i] == 0) number++;
if (number == 0) return TRUE;
char **files = new char*[number];
text = (char*) data;
for (i = 0; i < number; i++)
{
files[i] = text;
int len = strlen( text );
text += len+1;
}
bool ret = OnDropFiles( x, y, 1, files );
free( files );
return ret;
}
size_t wxFileDropTarget::GetFormatCount() const
{
return 1;
}
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
static void
shape_motion (GtkWidget *widget,
GdkEventMotion * /*event*/);
//-----------------------------------------------------------------------------
// "drag_request_event"
//-----------------------------------------------------------------------------
void gtk_drag_callback( GtkWidget *widget, GdkEventDragRequest *event, wxDropSource *source )
{
wxDataBroker *data = source->m_data;
if (!data) return;
wxNode *node = data->m_dataObjects.First();
{
wxDataObject *dobj = (wxDataObject*) node->Data();
if ((strcmp(event->data_type,"file:ALL") == 0) &&
(dobj->GetFormat().GetType() == wxDF_FILENAME))
{
wxFileDataObject *file_object = (wxFileDataObject*) dobj;
wxString text = file_object->GetFiles();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
(GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
source->m_retValue = wxDragCopy;
return;
}
if ((strcmp(event->data_type,"text/plain") == 0) &&
(dobj->GetFormat().GetType() == wxDF_TEXT))
{
wxTextDataObject *text_object = (wxTextDataObject*) dobj;
wxString text = text_object->GetText();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
(GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
source->m_retValue = wxDragCopy;
return;
}
if (dobj->GetFormat().GetType() == wxDF_PRIVATE)
{
wxPrivateDataObject *pdo = (wxPrivateDataObject*) dobj;
if (pdo->GetId() == event->data_type)
{
gtk_widget_dnd_data_set( widget,
(GdkEvent*)event,
(unsigned char*) pdo->GetData(),
(int) pdo->GetSize() );
source->m_retValue = wxDragCopy;
return;
}
}
node = node->Next();
}
}
wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_data = data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}
void wxDropSource::SetData( wxDataObject *data )
{
if (m_data) delete m_data;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
}
void wxDropSource::SetData( wxDataBroker *data )
{
if (m_data) delete m_data;
m_data = data;
}
wxDropSource::~wxDropSource(void)
{
if (m_data) delete m_data;
g_blockEventsOnDrag = FALSE;
}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
if (gdk_dnd.dnd_grabbed) return (wxDragResult) wxDragNone;
if (gdk_dnd.drag_really) return (wxDragResult) wxDragNone;
wxASSERT_MSG( m_data, "wxDragSource: no data" );
if (!m_data) return (wxDragResult) wxDragNone;
static GtkWidget *drag_icon = (GtkWidget*) NULL;
static GtkWidget *drop_icon = (GtkWidget*) NULL;
GdkPoint hotspot_1 = {0,-5 };
if (!drag_icon)
{
drag_icon = shape_create_icon ( m_stopIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drag_icon);
gtk_widget_hide (drag_icon);
}
GdkPoint hotspot_2 = {-5,-5};
if (!drop_icon)
{
drop_icon = shape_create_icon ( m_goIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drop_icon);
gtk_widget_hide (drop_icon);
}
gdk_dnd_set_drag_shape( drag_icon->window,
&hotspot_1,
drop_icon->window,
&hotspot_2);
GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window;
RegisterWindow();
gdk_dnd.drag_perhaps = TRUE;
gdk_dnd.dnd_drag_start.x = 5;
gdk_dnd.dnd_drag_start.y = 5;
gdk_dnd.real_sw = wp;
if (gdk_dnd.drag_startwindows)
{
g_free( gdk_dnd.drag_startwindows );
gdk_dnd.drag_startwindows = (GdkWindow **) NULL;
}
gdk_dnd.drag_numwindows = gdk_dnd.drag_really = 0;
XWindowAttributes dnd_winattr;
XGetWindowAttributes( gdk_display, wp->xwindow, &dnd_winattr );
wp->dnd_drag_savedeventmask = dnd_winattr.your_event_mask;
gdk_dnd_drag_addwindow( m_widget->window );
GdkEventDragBegin ev;
ev.type = GDK_DRAG_BEGIN;
ev.window = m_widget->window;
ev.u.allflags = 0;
ev.u.flags.protocol_version = DND_PROTOCOL_VERSION;
gdk_event_put( (GdkEvent*)&ev );
XGrabPointer( gdk_display, wp->xwindow, False,
ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, gdk_root_window, None, CurrentTime );
gdk_dnd_set_drag_cursors( m_defaultCursor.GetCursor(), m_goaheadCursor.GetCursor() );
gdk_dnd.dnd_grabbed = TRUE;
gdk_dnd.drag_really = 1;
int x = 0;
int y = 0;
wxGetMousePosition( &x, &y );
gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
gs_currentDropSource = this;
while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
gs_currentDropSource = (wxDropSource*) NULL;
UnregisterWindow();
g_blockEventsOnDrag = FALSE;
return m_retValue;
}
void wxDropSource::RegisterWindow(void)
{
if (!m_data) return;
wxString formats;
wxNode *node = m_data->m_dataObjects.First();
while (node)
{
wxDataObject* dobj = (wxDataObject*) node->Data();
switch (dobj->GetFormat().GetType())
{
case wxDF_TEXT:
{
formats += "text/plain";
break;
}
case wxDF_FILENAME:
{
formats += "file:ALL";
break;
}
case wxDF_PRIVATE:
{
wxPrivateDataObject* pdo = (wxPrivateDataObject*) m_data;
formats += pdo->GetId();
break;
}
default:
break;
}
node = node->Next();
}
char *str = WXSTRINGCAST formats;
gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this );
}
void wxDropSource::UnregisterWindow(void)
{
if (!m_widget) return;
gtk_widget_dnd_drag_set( m_widget, FALSE, (gchar **) NULL, 0 );
gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this );
}
/*
* Shaped Windows
*/
static GdkWindow *root_win = (GdkWindow*) NULL;
typedef struct _cursoroffset {gint x,y;} CursorOffset;
static void
shape_pressed (GtkWidget *widget, GdkEventButton *event)
{
CursorOffset *p;
/* ignore double and triple click */
if (event->type != GDK_BUTTON_PRESS)
return;
p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT(widget));
p->x = (int) event->x;
p->y = (int) event->y;
gtk_grab_add (widget);
gdk_pointer_grab (widget->window, TRUE,
(GdkEventMask)
(GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK),
(GdkWindow*)NULL,
(GdkCursor*) NULL, 0);
}
static void
shape_released (GtkWidget *widget)
{
gtk_grab_remove (widget);
gdk_pointer_ungrab (0);
}
static void
shape_motion (GtkWidget *widget,
GdkEventMotion * /*event*/ )
{
gint xp, yp;
CursorOffset * p;
GdkModifierType mask;
p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT (widget));
/*
* Can't use event->x / event->y here
* because I need absolute coordinates.
*/
gdk_window_get_pointer (root_win, &xp, &yp, &mask);
gtk_widget_set_uposition (widget, xp - p->x, yp - p->y);
if (gs_currentDropSource) gs_currentDropSource->GiveFeedback( wxDragCopy, FALSE );
}
GtkWidget *
shape_create_icon (const wxIcon &shape,
gint x,
gint y,
gint px,
gint py,
gint window_type)
{
/*
* GDK_WINDOW_TOPLEVEL works also, giving you a title border
*/
GtkWidget *window = gtk_window_new ((GtkWindowType)window_type);
GtkWidget *fixed = gtk_fixed_new ();
gtk_widget_set_usize (fixed, 100,100);
gtk_container_add (GTK_CONTAINER (window), fixed);
gtk_widget_show (fixed);
gtk_widget_set_events (window,
gtk_widget_get_events (window) |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK);
gtk_widget_realize (window);
GdkBitmap *mask = (GdkBitmap*) NULL;
if (shape.GetMask()) mask = shape.GetMask()->GetBitmap();
GtkWidget *pixmap = gtk_pixmap_new (shape.GetPixmap(), mask);
gtk_fixed_put (GTK_FIXED (fixed), pixmap, px,py);
gtk_widget_show (pixmap);
gtk_widget_shape_combine_mask (window, mask, px,py);
gtk_signal_connect (GTK_OBJECT (window), "button_press_event",
GTK_SIGNAL_FUNC (shape_pressed),NULL);
gtk_signal_connect (GTK_OBJECT (window), "button_release_event",
GTK_SIGNAL_FUNC (shape_released),NULL);
gtk_signal_connect (GTK_OBJECT (window), "motion_notify_event",
GTK_SIGNAL_FUNC (shape_motion),NULL);
CursorOffset*icon_pos = g_new (CursorOffset, 1);
gtk_object_set_user_data(GTK_OBJECT(window), icon_pos);
gtk_widget_set_uposition (window, x, y);
gtk_widget_show (window);
return window;
}
#endif
// NEW_GTK_DND_CODE
#endif #endif
// wxUSE_DRAG_AND_DROP // wxUSE_DRAG_AND_DROP

View File

@@ -120,7 +120,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
// "child_detached" of tool bar // "child_detached" of tool bar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
@@ -271,9 +271,6 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
/* needed ? */
gtk_window_set_policy( GTK_WINDOW(m_widget), 1, 1, 0 );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
@@ -319,6 +316,12 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func); gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
else
gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
/* the user resized the frame by dragging etc. */ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );

View File

@@ -44,6 +44,12 @@ wxDataFormat::wxDataFormat( wxDataType type )
SetType( type ); SetType( type );
} }
wxDataFormat::wxDataFormat( const char *id )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
SetId( id );
}
wxDataFormat::wxDataFormat( const wxString &id ) wxDataFormat::wxDataFormat( const wxString &id )
{ {
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
@@ -121,7 +127,7 @@ wxString wxDataFormat::GetId() const
return m_id; return m_id;
} }
void wxDataFormat::SetId( const wxString &id ) void wxDataFormat::SetId( const char *id )
{ {
m_type = wxDF_PRIVATE; m_type = wxDF_PRIVATE;
m_id = id; m_id = id;

View File

@@ -149,14 +149,13 @@ bool wxDialog::Create( wxWindow *parent,
recognized by other WM as well. not tested. */ recognized by other WM as well. not tested. */
long decor = (long) GDK_DECOR_ALL; long decor = (long) GDK_DECOR_ALL;
long func = (long) GDK_FUNC_ALL; long func = (long) GDK_FUNC_ALL;
if ((m_windowStyle & wxCAPTION) == 0) if ((m_windowStyle & wxCAPTION) == 0)
decor |= GDK_DECOR_TITLE; decor |= GDK_DECOR_TITLE;
/* /* if ((m_windowStyle & wxMINIMIZE) == 0)
if ((m_windowStyle & wxMINIMIZE) == 0)
func |= GDK_FUNC_MINIMIZE; func |= GDK_FUNC_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE) == 0) if ((m_windowStyle & wxMAXIMIZE) == 0)
func |= GDK_FUNC_MAXIMIZE; func |= GDK_FUNC_MAXIMIZE; */
*/
if ((m_windowStyle & wxSYSTEM_MENU) == 0) if ((m_windowStyle & wxSYSTEM_MENU) == 0)
decor |= GDK_DECOR_MENU; decor |= GDK_DECOR_MENU;
if ((m_windowStyle & wxMINIMIZE_BOX) == 0) if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
@@ -165,9 +164,16 @@ bool wxDialog::Create( wxWindow *parent,
decor |= GDK_DECOR_MAXIMIZE; decor |= GDK_DECOR_MAXIMIZE;
if ((m_windowStyle & wxRESIZE_BORDER) == 0) if ((m_windowStyle & wxRESIZE_BORDER) == 0)
func |= GDK_FUNC_RESIZE; func |= GDK_FUNC_RESIZE;
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func); gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
else
gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );

View File

@@ -25,7 +25,8 @@
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "gdk/gdkprivate.h" #include "gdk/gdkprivate.h"
#include <X11/Xlib.h> #include "gtk/gtkdnd.h"
#include "gtk/gtkselection.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// global data // global data
@@ -123,11 +124,6 @@ static char * page_xpm[] = {
" ......................... "}; " ......................... "};
#if (GTK_MINOR_VERSION > 0)
#include "gtk/gtkdnd.h"
#include "gtk/gtkselection.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// "drag_leave" // "drag_leave"
@@ -846,705 +842,6 @@ void wxDropSource::UnregisterWindow()
GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this ); GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this );
} }
#else // NEW_CODE
//----------------------------------------------------------------------------
// forward
//----------------------------------------------------------------------------
GtkWidget *shape_create_icon ( const wxIcon &shape,
gint x,
gint y,
gint px,
gint py,
gint window_type);
//-----------------------------------------------------------------------------
// globals
//-----------------------------------------------------------------------------
wxDropSource *gs_currentDropSource = (wxDropSource*) NULL;
//-----------------------------------------------------------------------------
// "drop_enter_event"
//-----------------------------------------------------------------------------
static void gtk_target_enter_callback( GtkWidget *WXUNUSED(widget),
GdkEventDropEnter *WXUNUSED(event),
wxDropTarget *target )
{
if (target)
target->OnEnter();
}
//-----------------------------------------------------------------------------
// "drop_leave_event"
//-----------------------------------------------------------------------------
static void gtk_target_leave_callback( GtkWidget *WXUNUSED(widget),
GdkEventDropLeave *WXUNUSED(event),
wxDropTarget *target )
{
if (target)
target->OnLeave();
}
//-----------------------------------------------------------------------------
// "drop_data_available_event"
//-----------------------------------------------------------------------------
static void gtk_target_callback( GtkWidget *widget,
GdkEventDropDataAvailable *event,
wxDropTarget *target )
{
if (target)
{
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
/*
printf( "Drop data is of type %s.\n", event->data_type );
*/
target->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes );
}
/*
g_free (event->data);
g_free (event->data_type);
*/
}
// ----------------------------------------------------------------------------
// wxDropTarget
// ----------------------------------------------------------------------------
wxDropTarget::wxDropTarget()
{
m_format = (wxDataFormat*) NULL;
}
wxDropTarget::~wxDropTarget()
{
if (m_format) delete m_format;
}
wxDataFormat &wxDropTarget::GetFormat(size_t n) const
{
return (*m_format);
}
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
if (!widget) return;
gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
GTK_SIGNAL_FUNC(gtk_target_callback), (gpointer) this );
gtk_widget_dnd_drop_set( widget, FALSE, (gchar **) NULL, 0, FALSE );
}
void wxDropTarget::RegisterWidget( GtkWidget *widget )
{
wxString formats;
int valid = 0;
for ( size_t i = 0; i < GetFormatCount(); i++ )
{
switch (GetFormat(i).GetType())
{
case wxDF_TEXT:
{
if (i > 0) formats += ";";
formats += "text/plain";
valid++;
break;
}
case wxDF_FILENAME:
{
if (i > 0) formats += ";";
formats += "file:ALL";
valid++;
break;
}
case wxDF_PRIVATE:
{
if (i > 0) formats += ";";
wxPrivateDropTarget *pdt = (wxPrivateDropTarget *)this;
formats += pdt->GetId();
valid++;
break;
}
default:
break;
}
}
char *str = WXSTRINGCAST formats;
gtk_widget_dnd_drop_set( widget, TRUE, &str, valid, FALSE );
gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
GTK_SIGNAL_FUNC(gtk_target_callback), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drop_enter_event",
GTK_SIGNAL_FUNC(gtk_target_enter_callback), (gpointer) this );
gtk_signal_connect( GTK_OBJECT(widget), "drop_leave_event",
GTK_SIGNAL_FUNC(gtk_target_leave_callback), (gpointer) this );
}
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
wxTextDropTarget::wxTextDropTarget()
{
m_format = new wxDataFormat( wxDF_TEXT );
}
bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
{
OnDropText( x, y, (const char*)data );
return TRUE;
}
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
{
/*
printf( "Got dropped text: %s.\n", psz );
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
*/
return TRUE;
}
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
}
// ----------------------------------------------------------------------------
// wxPrivateDropTarget
// ----------------------------------------------------------------------------
wxPrivateDropTarget::wxPrivateDropTarget()
{
m_id = wxTheApp->GetAppName();
m_format = new wxDataFormat( m_id );
}
void wxPrivateDropTarget::SetId( const wxString& id )
{
m_id = id;
m_format->SetId( id );
}
size_t wxPrivateDropTarget::GetFormatCount() const
{
return 1;
}
// ----------------------------------------------------------------------------
// wxFileDropTarget
// ----------------------------------------------------------------------------
wxFileDropTarget::wxFileDropTarget()
{
m_format = new wxDataFormat( wxDF_FILENAME );
}
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
{
printf( "Got %d dropped files.\n", (int)nFiles );
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
for (size_t i = 0; i < nFiles; i++)
{
printf( aszFiles[i] );
printf( "\n" );
}
return TRUE;
}
bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
{
size_t number = 0;
size_t i;
char *text = (char*) data;
for ( i = 0; i < size; i++)
if (text[i] == 0) number++;
if (number == 0) return TRUE;
char **files = new char*[number];
text = (char*) data;
for (i = 0; i < number; i++)
{
files[i] = text;
int len = strlen( text );
text += len+1;
}
bool ret = OnDropFiles( x, y, 1, files );
free( files );
return ret;
}
size_t wxFileDropTarget::GetFormatCount() const
{
return 1;
}
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
static void
shape_motion (GtkWidget *widget,
GdkEventMotion * /*event*/);
//-----------------------------------------------------------------------------
// "drag_request_event"
//-----------------------------------------------------------------------------
void gtk_drag_callback( GtkWidget *widget, GdkEventDragRequest *event, wxDropSource *source )
{
wxDataBroker *data = source->m_data;
if (!data) return;
wxNode *node = data->m_dataObjects.First();
{
wxDataObject *dobj = (wxDataObject*) node->Data();
if ((strcmp(event->data_type,"file:ALL") == 0) &&
(dobj->GetFormat().GetType() == wxDF_FILENAME))
{
wxFileDataObject *file_object = (wxFileDataObject*) dobj;
wxString text = file_object->GetFiles();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
(GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
source->m_retValue = wxDragCopy;
return;
}
if ((strcmp(event->data_type,"text/plain") == 0) &&
(dobj->GetFormat().GetType() == wxDF_TEXT))
{
wxTextDataObject *text_object = (wxTextDataObject*) dobj;
wxString text = text_object->GetText();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
(GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
source->m_retValue = wxDragCopy;
return;
}
if (dobj->GetFormat().GetType() == wxDF_PRIVATE)
{
wxPrivateDataObject *pdo = (wxPrivateDataObject*) dobj;
if (pdo->GetId() == event->data_type)
{
gtk_widget_dnd_data_set( widget,
(GdkEvent*)event,
(unsigned char*) pdo->GetData(),
(int) pdo->GetSize() );
source->m_retValue = wxDragCopy;
return;
}
}
node = node->Next();
}
}
wxDropSource::wxDropSource( wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go, const wxIcon &stop )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
m_goIcon = go;
if (wxNullIcon == go) m_goIcon = wxIcon( page_xpm );
m_stopIcon = stop;
if (wxNullIcon == stop) m_stopIcon = wxIcon( gv_xpm );
}
wxDropSource::wxDropSource( wxDataBroker *data, wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_data = data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}
void wxDropSource::SetData( wxDataObject *data )
{
if (m_data) delete m_data;
if (data)
{
m_data = new wxDataBroker();
m_data->Add( data );
}
else
{
m_data = (wxDataBroker*) NULL;
}
}
void wxDropSource::SetData( wxDataBroker *data )
{
if (m_data) delete m_data;
m_data = data;
}
wxDropSource::~wxDropSource(void)
{
if (m_data) delete m_data;
g_blockEventsOnDrag = FALSE;
}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
if (gdk_dnd.dnd_grabbed) return (wxDragResult) wxDragNone;
if (gdk_dnd.drag_really) return (wxDragResult) wxDragNone;
wxASSERT_MSG( m_data, "wxDragSource: no data" );
if (!m_data) return (wxDragResult) wxDragNone;
static GtkWidget *drag_icon = (GtkWidget*) NULL;
static GtkWidget *drop_icon = (GtkWidget*) NULL;
GdkPoint hotspot_1 = {0,-5 };
if (!drag_icon)
{
drag_icon = shape_create_icon ( m_stopIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drag_icon);
gtk_widget_hide (drag_icon);
}
GdkPoint hotspot_2 = {-5,-5};
if (!drop_icon)
{
drop_icon = shape_create_icon ( m_goIcon,
440, 140, 0,0, GTK_WINDOW_POPUP);
gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&drop_icon);
gtk_widget_hide (drop_icon);
}
gdk_dnd_set_drag_shape( drag_icon->window,
&hotspot_1,
drop_icon->window,
&hotspot_2);
GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window;
RegisterWindow();
gdk_dnd.drag_perhaps = TRUE;
gdk_dnd.dnd_drag_start.x = 5;
gdk_dnd.dnd_drag_start.y = 5;
gdk_dnd.real_sw = wp;
if (gdk_dnd.drag_startwindows)
{
g_free( gdk_dnd.drag_startwindows );
gdk_dnd.drag_startwindows = (GdkWindow **) NULL;
}
gdk_dnd.drag_numwindows = gdk_dnd.drag_really = 0;
XWindowAttributes dnd_winattr;
XGetWindowAttributes( gdk_display, wp->xwindow, &dnd_winattr );
wp->dnd_drag_savedeventmask = dnd_winattr.your_event_mask;
gdk_dnd_drag_addwindow( m_widget->window );
GdkEventDragBegin ev;
ev.type = GDK_DRAG_BEGIN;
ev.window = m_widget->window;
ev.u.allflags = 0;
ev.u.flags.protocol_version = DND_PROTOCOL_VERSION;
gdk_event_put( (GdkEvent*)&ev );
XGrabPointer( gdk_display, wp->xwindow, False,
ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, gdk_root_window, None, CurrentTime );
gdk_dnd_set_drag_cursors( m_defaultCursor.GetCursor(), m_goaheadCursor.GetCursor() );
gdk_dnd.dnd_grabbed = TRUE;
gdk_dnd.drag_really = 1;
int x = 0;
int y = 0;
wxGetMousePosition( &x, &y );
gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
gs_currentDropSource = this;
while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
gs_currentDropSource = (wxDropSource*) NULL;
UnregisterWindow();
g_blockEventsOnDrag = FALSE;
return m_retValue;
}
void wxDropSource::RegisterWindow(void)
{
if (!m_data) return;
wxString formats;
wxNode *node = m_data->m_dataObjects.First();
while (node)
{
wxDataObject* dobj = (wxDataObject*) node->Data();
switch (dobj->GetFormat().GetType())
{
case wxDF_TEXT:
{
formats += "text/plain";
break;
}
case wxDF_FILENAME:
{
formats += "file:ALL";
break;
}
case wxDF_PRIVATE:
{
wxPrivateDataObject* pdo = (wxPrivateDataObject*) m_data;
formats += pdo->GetId();
break;
}
default:
break;
}
node = node->Next();
}
char *str = WXSTRINGCAST formats;
gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this );
}
void wxDropSource::UnregisterWindow(void)
{
if (!m_widget) return;
gtk_widget_dnd_drag_set( m_widget, FALSE, (gchar **) NULL, 0 );
gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this );
}
/*
* Shaped Windows
*/
static GdkWindow *root_win = (GdkWindow*) NULL;
typedef struct _cursoroffset {gint x,y;} CursorOffset;
static void
shape_pressed (GtkWidget *widget, GdkEventButton *event)
{
CursorOffset *p;
/* ignore double and triple click */
if (event->type != GDK_BUTTON_PRESS)
return;
p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT(widget));
p->x = (int) event->x;
p->y = (int) event->y;
gtk_grab_add (widget);
gdk_pointer_grab (widget->window, TRUE,
(GdkEventMask)
(GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK),
(GdkWindow*)NULL,
(GdkCursor*) NULL, 0);
}
static void
shape_released (GtkWidget *widget)
{
gtk_grab_remove (widget);
gdk_pointer_ungrab (0);
}
static void
shape_motion (GtkWidget *widget,
GdkEventMotion * /*event*/ )
{
gint xp, yp;
CursorOffset * p;
GdkModifierType mask;
p = (CursorOffset *)gtk_object_get_user_data (GTK_OBJECT (widget));
/*
* Can't use event->x / event->y here
* because I need absolute coordinates.
*/
gdk_window_get_pointer (root_win, &xp, &yp, &mask);
gtk_widget_set_uposition (widget, xp - p->x, yp - p->y);
if (gs_currentDropSource) gs_currentDropSource->GiveFeedback( wxDragCopy, FALSE );
}
GtkWidget *
shape_create_icon (const wxIcon &shape,
gint x,
gint y,
gint px,
gint py,
gint window_type)
{
/*
* GDK_WINDOW_TOPLEVEL works also, giving you a title border
*/
GtkWidget *window = gtk_window_new ((GtkWindowType)window_type);
GtkWidget *fixed = gtk_fixed_new ();
gtk_widget_set_usize (fixed, 100,100);
gtk_container_add (GTK_CONTAINER (window), fixed);
gtk_widget_show (fixed);
gtk_widget_set_events (window,
gtk_widget_get_events (window) |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK);
gtk_widget_realize (window);
GdkBitmap *mask = (GdkBitmap*) NULL;
if (shape.GetMask()) mask = shape.GetMask()->GetBitmap();
GtkWidget *pixmap = gtk_pixmap_new (shape.GetPixmap(), mask);
gtk_fixed_put (GTK_FIXED (fixed), pixmap, px,py);
gtk_widget_show (pixmap);
gtk_widget_shape_combine_mask (window, mask, px,py);
gtk_signal_connect (GTK_OBJECT (window), "button_press_event",
GTK_SIGNAL_FUNC (shape_pressed),NULL);
gtk_signal_connect (GTK_OBJECT (window), "button_release_event",
GTK_SIGNAL_FUNC (shape_released),NULL);
gtk_signal_connect (GTK_OBJECT (window), "motion_notify_event",
GTK_SIGNAL_FUNC (shape_motion),NULL);
CursorOffset*icon_pos = g_new (CursorOffset, 1);
gtk_object_set_user_data(GTK_OBJECT(window), icon_pos);
gtk_widget_set_uposition (window, x, y);
gtk_widget_show (window);
return window;
}
#endif
// NEW_GTK_DND_CODE
#endif #endif
// wxUSE_DRAG_AND_DROP // wxUSE_DRAG_AND_DROP

View File

@@ -120,7 +120,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
// "child_detached" of tool bar // "child_detached" of tool bar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) static void gtk_toolbar_detached_callback( GtkWidget *widget, GtkWidget *WXUNUSED(child), wxFrame *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
@@ -271,9 +271,6 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
/* needed ? */
gtk_window_set_policy( GTK_WINDOW(m_widget), 1, 1, 0 );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
@@ -319,6 +316,12 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func); gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
/* GTK's shrinking/growing policy */
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
else
gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
/* the user resized the frame by dragging etc. */ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );

View File

@@ -1,7 +1,7 @@
Summary: The GTK+ 1.2 port of wxWindows library Summary: The GTK+ 1.2 port of wxWindows library
Name: wxGTK Name: wxGTK
Version: 2.1.0 Version: 2.1.0
Release: 1 Release: 2
Copyright: wxWindows Licence Copyright: wxWindows Licence
Group: X11/Libraries Group: X11/Libraries
Source: ftp://wesley.informatik.uni-freiburg.de/pub/linux/wxxt/source/wxGTK21b.tgz Source: ftp://wesley.informatik.uni-freiburg.de/pub/linux/wxxt/source/wxGTK21b.tgz