From 8a126fcc3438c6b2693090e8c97761fa12d8ca7a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 20 Apr 1999 10:09:15 +0000 Subject: [PATCH] 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 --- docs/gtk/install.txt | 8 +- docs/gtk/readme.txt | 4 +- docs/gtk/todo.txt | 2 +- include/wx/defs.h | 22 +- include/wx/gtk/dataobj.h | 3 +- include/wx/gtk/dnd.h | 182 +++------- include/wx/gtk1/dataobj.h | 3 +- include/wx/gtk1/dnd.h | 182 +++------- include/wx/version.h | 2 +- setup/maketmpl.in | 4 +- src/gtk/dataobj.cpp | 8 +- src/gtk/dialog.cpp | 16 +- src/gtk/dnd.cpp | 707 +------------------------------------- src/gtk/frame.cpp | 11 +- src/gtk1/dataobj.cpp | 8 +- src/gtk1/dialog.cpp | 16 +- src/gtk1/dnd.cpp | 707 +------------------------------------- src/gtk1/frame.cpp | 11 +- wxGTK.spec | 2 +- 19 files changed, 162 insertions(+), 1736 deletions(-) diff --git a/docs/gtk/install.txt b/docs/gtk/install.txt index b0eb9dfff2..9c7b33dde0 100644 --- a/docs/gtk/install.txt +++ b/docs/gtk/install.txt @@ -57,10 +57,10 @@ this has no effect, but I tried... ----------------------- 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 -work with the 1.0 series, but I didn't test that any longer. - -wxWindows/GTK does NOT work with the 1.1.X versions of the GTK+ library. +It has to be a stable version, preferebly version 1.2.1. You can use +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 +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 at diff --git a/docs/gtk/readme.txt b/docs/gtk/readme.txt index 0268ca3eaf..ebd06716ad 100644 --- a/docs/gtk/readme.txt +++ b/docs/gtk/readme.txt @@ -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 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 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 make diff --git a/docs/gtk/todo.txt b/docs/gtk/todo.txt index 92462df4e5..1db16e96c2 100644 --- a/docs/gtk/todo.txt +++ b/docs/gtk/todo.txt @@ -2,7 +2,7 @@ -------------------- High priority --------------------- DnD - -> Must be rewritten for GTK+ 1.2 + -> Must be rewritten for GTK+ 1.2. Much done. -------------------- Medium priority --------------------- diff --git a/include/wx/defs.h b/include/wx/defs.h index 7a7d2dc2fc..a19d19b1c2 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1122,18 +1122,20 @@ typedef struct _GdkWindow GdkBitmap; typedef struct _GdkWindow GdkPixmap; typedef struct _GdkCursor GdkCursor; typedef struct _GdkRegion GdkRegion; +typedef struct _GdkDragContext GdkDragContext; /* Stand-ins for GTK types */ -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkStyle GtkStyle; -typedef struct _GtkAdjustment GtkAdjustment; -typedef struct _GtkList GtkList; -typedef struct _GtkToolbar GtkToolbar; -typedef struct _GtkTooltips GtkTooltips; -typedef struct _GtkNotebook GtkNotebook; -typedef struct _GtkNotebookPage GtkNotebookPage; -typedef struct _GtkAccelGroup GtkAccelGroup; -typedef struct _GtkItemFactory GtkItemFactory; +typedef struct _GtkWidget GtkWidget; +typedef struct _GtkStyle GtkStyle; +typedef struct _GtkAdjustment GtkAdjustment; +typedef struct _GtkList GtkList; +typedef struct _GtkToolbar GtkToolbar; +typedef struct _GtkTooltips GtkTooltips; +typedef struct _GtkNotebook GtkNotebook; +typedef struct _GtkNotebookPage GtkNotebookPage; +typedef struct _GtkAccelGroup GtkAccelGroup; +typedef struct _GtkItemFactory GtkItemFactory; +typedef struct _GtkSelectionData GtkSelectionData; #endif diff --git a/include/wx/gtk/dataobj.h b/include/wx/gtk/dataobj.h index 42233e4494..b360614805 100644 --- a/include/wx/gtk/dataobj.h +++ b/include/wx/gtk/dataobj.h @@ -70,6 +70,7 @@ public: wxDataFormat(); wxDataFormat( wxDataType type ); wxDataFormat( const wxString &id ); + wxDataFormat( const char *id ); wxDataFormat( wxDataFormat &format ); wxDataFormat( const GdkAtom atom ); @@ -77,7 +78,7 @@ public: wxDataType GetType() const; wxString GetId() const; - void SetId( const wxString &id ); + void SetId( const char *id ); GdkAtom GetAtom(); diff --git a/include/wx/gtk/dnd.h b/include/wx/gtk/dnd.h index f57083b7db..cf5ff44913 100644 --- a/include/wx/gtk/dnd.h +++ b/include/wx/gtk/dnd.h @@ -39,68 +39,6 @@ class wxPrivateDropTarget; 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 //------------------------------------------------------------------------- @@ -229,105 +167,65 @@ public: }; -#else - -//------------------------------------------------------------------------- -// wxDropTarget -//------------------------------------------------------------------------- - -class wxDropTarget: public wxObject -{ - public: - - wxDropTarget(); - ~wxDropTarget(); - - virtual void OnEnter() { } - virtual void OnLeave() { } - 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: - - virtual size_t GetFormatCount() const = 0; - virtual wxDataFormat &GetFormat(size_t n) const; - - // implementation - - void RegisterWidget( GtkWidget *widget ); - void UnregisterWidget( GtkWidget *widget ); - - wxDataFormat *m_format; -}; - //------------------------------------------------------------------------- -// wxTextDropTarget +// wxDropSource //------------------------------------------------------------------------- -class wxTextDropTarget: public wxDropTarget +enum wxDragResult { - 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; + 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) }; -//------------------------------------------------------------------------- -// wxPrivateDropTarget -//------------------------------------------------------------------------- - -class wxPrivateDropTarget: public wxDropTarget +class wxDropSource: public wxObject { 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". + /* constructor. set data later with SetData() */ + wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon ); - void SetId( const wxString& id ); + /* constructor for setting one data object */ + wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon ); - wxString GetId() - { return m_id; } - -private: + /* constructor for setting several data objects via wxDataBroker */ + wxDropSource( wxDataBroker *data, wxWindow *win ); - virtual size_t GetFormatCount() const; + ~wxDropSource(); - wxString m_id; -}; + /* set several dataobjects via wxDataBroker */ + void SetData( wxDataBroker *data ); -//---------------------------------------------------------------------------- -// A drop target which accepts files (dragged from File Manager or Explorer) -//---------------------------------------------------------------------------- + /* set one dataobject */ + void SetData( wxDataObject *data ); -class wxFileDropTarget: public wxDropTarget -{ - public: - - wxFileDropTarget(); + /* start drag action */ + wxDragResult DoDragDrop( bool bAllowMove = FALSE ); - 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: + /* override to give feedback */ + virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; } - virtual size_t GetFormatCount() const; + /* 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; }; -#endif - - #endif // wxUSE_DRAG_AND_DROP diff --git a/include/wx/gtk1/dataobj.h b/include/wx/gtk1/dataobj.h index 42233e4494..b360614805 100644 --- a/include/wx/gtk1/dataobj.h +++ b/include/wx/gtk1/dataobj.h @@ -70,6 +70,7 @@ public: wxDataFormat(); wxDataFormat( wxDataType type ); wxDataFormat( const wxString &id ); + wxDataFormat( const char *id ); wxDataFormat( wxDataFormat &format ); wxDataFormat( const GdkAtom atom ); @@ -77,7 +78,7 @@ public: wxDataType GetType() const; wxString GetId() const; - void SetId( const wxString &id ); + void SetId( const char *id ); GdkAtom GetAtom(); diff --git a/include/wx/gtk1/dnd.h b/include/wx/gtk1/dnd.h index f57083b7db..cf5ff44913 100644 --- a/include/wx/gtk1/dnd.h +++ b/include/wx/gtk1/dnd.h @@ -39,68 +39,6 @@ class wxPrivateDropTarget; 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 //------------------------------------------------------------------------- @@ -229,105 +167,65 @@ public: }; -#else - -//------------------------------------------------------------------------- -// wxDropTarget -//------------------------------------------------------------------------- - -class wxDropTarget: public wxObject -{ - public: - - wxDropTarget(); - ~wxDropTarget(); - - virtual void OnEnter() { } - virtual void OnLeave() { } - 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: - - virtual size_t GetFormatCount() const = 0; - virtual wxDataFormat &GetFormat(size_t n) const; - - // implementation - - void RegisterWidget( GtkWidget *widget ); - void UnregisterWidget( GtkWidget *widget ); - - wxDataFormat *m_format; -}; - //------------------------------------------------------------------------- -// wxTextDropTarget +// wxDropSource //------------------------------------------------------------------------- -class wxTextDropTarget: public wxDropTarget +enum wxDragResult { - 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; + 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) }; -//------------------------------------------------------------------------- -// wxPrivateDropTarget -//------------------------------------------------------------------------- - -class wxPrivateDropTarget: public wxDropTarget +class wxDropSource: public wxObject { 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". + /* constructor. set data later with SetData() */ + wxDropSource( wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon ); - void SetId( const wxString& id ); + /* constructor for setting one data object */ + wxDropSource( wxDataObject *data, wxWindow *win, const wxIcon &go = wxNullIcon, const wxIcon &stop = wxNullIcon ); - wxString GetId() - { return m_id; } - -private: + /* constructor for setting several data objects via wxDataBroker */ + wxDropSource( wxDataBroker *data, wxWindow *win ); - virtual size_t GetFormatCount() const; + ~wxDropSource(); - wxString m_id; -}; + /* set several dataobjects via wxDataBroker */ + void SetData( wxDataBroker *data ); -//---------------------------------------------------------------------------- -// A drop target which accepts files (dragged from File Manager or Explorer) -//---------------------------------------------------------------------------- + /* set one dataobject */ + void SetData( wxDataObject *data ); -class wxFileDropTarget: public wxDropTarget -{ - public: - - wxFileDropTarget(); + /* start drag action */ + wxDragResult DoDragDrop( bool bAllowMove = FALSE ); - 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: + /* override to give feedback */ + virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; } - virtual size_t GetFormatCount() const; + /* 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; }; -#endif - - #endif // wxUSE_DRAG_AND_DROP diff --git a/include/wx/version.h b/include/wx/version.h index 9f9b60d0a0..62606f98c7 100644 --- a/include/wx/version.h +++ b/include/wx/version.h @@ -18,7 +18,7 @@ #define wxRELEASE_NUMBER 0 #define wxVERSION_STRING "wxWindows 2.1.0" #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) #endif diff --git a/setup/maketmpl.in b/setup/maketmpl.in index 507dc7b6be..a97349e8a5 100644 --- a/setup/maketmpl.in +++ b/setup/maketmpl.in @@ -94,11 +94,13 @@ POSIX4_LINK=@POSIX4_LINK@ # INCLUDES WX_INCLUDES = \ +-I$(WXBASEDIR)/src/zlib \ +-I$(WXBASEDIR)/src/png \ +-I$(WXBASEDIR)/src/jpeg \ $(TOOLKIT_DEF) \ -I$(WXBASEDIR)/include \ -I. \ $(GUI_TK_INCLUDE) \ --I$(WXBASEDIR)/src/zlib \ -I$(WXBASEDIR)/src/iodbc \ $(X_CFLAGS) diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index 161a6b5e3e..913ee2eca3 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -44,6 +44,12 @@ wxDataFormat::wxDataFormat( wxDataType 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 ) { if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); @@ -121,7 +127,7 @@ wxString wxDataFormat::GetId() const return m_id; } -void wxDataFormat::SetId( const wxString &id ) +void wxDataFormat::SetId( const char *id ) { m_type = wxDF_PRIVATE; m_id = id; diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index deab62ab69..7edb2940c8 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -149,14 +149,13 @@ bool wxDialog::Create( wxWindow *parent, recognized by other WM as well. not tested. */ long decor = (long) GDK_DECOR_ALL; long func = (long) GDK_FUNC_ALL; + if ((m_windowStyle & wxCAPTION) == 0) decor |= GDK_DECOR_TITLE; -/* - if ((m_windowStyle & wxMINIMIZE) == 0) +/* if ((m_windowStyle & wxMINIMIZE) == 0) func |= GDK_FUNC_MINIMIZE; if ((m_windowStyle & wxMAXIMIZE) == 0) - func |= GDK_FUNC_MAXIMIZE; -*/ + func |= GDK_FUNC_MAXIMIZE; */ if ((m_windowStyle & wxSYSTEM_MENU) == 0) decor |= GDK_DECOR_MENU; if ((m_windowStyle & wxMINIMIZE_BOX) == 0) @@ -165,9 +164,16 @@ bool wxDialog::Create( wxWindow *parent, decor |= GDK_DECOR_MAXIMIZE; if ((m_windowStyle & wxRESIZE_BORDER) == 0) func |= GDK_FUNC_RESIZE; + gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); 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_FUNC(gtk_dialog_size_callback), (gpointer)this ); diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index a86abfa51c..225318a235 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -25,7 +25,8 @@ #include "gtk/gtk.h" #include "gdk/gdkprivate.h" -#include +#include "gtk/gtkdnd.h" +#include "gtk/gtkselection.h" //---------------------------------------------------------------------------- // 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" @@ -846,705 +842,6 @@ void wxDropSource::UnregisterWindow() 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 // wxUSE_DRAG_AND_DROP diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 40fd665182..e93a313d95 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -120,7 +120,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge // "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; @@ -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_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_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_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. */ gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index 161a6b5e3e..913ee2eca3 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -44,6 +44,12 @@ wxDataFormat::wxDataFormat( wxDataType 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 ) { if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE ); @@ -121,7 +127,7 @@ wxString wxDataFormat::GetId() const return m_id; } -void wxDataFormat::SetId( const wxString &id ) +void wxDataFormat::SetId( const char *id ) { m_type = wxDF_PRIVATE; m_id = id; diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index deab62ab69..7edb2940c8 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -149,14 +149,13 @@ bool wxDialog::Create( wxWindow *parent, recognized by other WM as well. not tested. */ long decor = (long) GDK_DECOR_ALL; long func = (long) GDK_FUNC_ALL; + if ((m_windowStyle & wxCAPTION) == 0) decor |= GDK_DECOR_TITLE; -/* - if ((m_windowStyle & wxMINIMIZE) == 0) +/* if ((m_windowStyle & wxMINIMIZE) == 0) func |= GDK_FUNC_MINIMIZE; if ((m_windowStyle & wxMAXIMIZE) == 0) - func |= GDK_FUNC_MAXIMIZE; -*/ + func |= GDK_FUNC_MAXIMIZE; */ if ((m_windowStyle & wxSYSTEM_MENU) == 0) decor |= GDK_DECOR_MENU; if ((m_windowStyle & wxMINIMIZE_BOX) == 0) @@ -165,9 +164,16 @@ bool wxDialog::Create( wxWindow *parent, decor |= GDK_DECOR_MAXIMIZE; if ((m_windowStyle & wxRESIZE_BORDER) == 0) func |= GDK_FUNC_RESIZE; + gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor); 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_FUNC(gtk_dialog_size_callback), (gpointer)this ); diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index a86abfa51c..225318a235 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -25,7 +25,8 @@ #include "gtk/gtk.h" #include "gdk/gdkprivate.h" -#include +#include "gtk/gtkdnd.h" +#include "gtk/gtkselection.h" //---------------------------------------------------------------------------- // 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" @@ -846,705 +842,6 @@ void wxDropSource::UnregisterWindow() 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 // wxUSE_DRAG_AND_DROP diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 40fd665182..e93a313d95 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -120,7 +120,7 @@ static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidge // "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; @@ -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_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_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_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. */ gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); diff --git a/wxGTK.spec b/wxGTK.spec index c88d82b05e..a1da773fe5 100644 --- a/wxGTK.spec +++ b/wxGTK.spec @@ -1,7 +1,7 @@ Summary: The GTK+ 1.2 port of wxWindows library Name: wxGTK Version: 2.1.0 -Release: 1 +Release: 2 Copyright: wxWindows Licence Group: X11/Libraries Source: ftp://wesley.informatik.uni-freiburg.de/pub/linux/wxxt/source/wxGTK21b.tgz -- 2.45.2