// Don't do parent client adjustments (for implementation only)
#define wxSIZE_NO_ADJUSTMENTS 0x0008
+#ifndef __WXGTK__
+
enum wxDataFormat
{
wxDF_INVALID = 0,
wxDF_PRIVATE = 20
};
+#endif
+
/* Virtual keycodes */
enum wxKeyCode
static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
- /* this may have to be overwritten when special, non-default visuals have
- to be set. it is also platform dependent as only X knows about displays
- and visuals. */
- virtual bool InitVisual();
-
- virtual bool OnInit();
+ /* override for altering the way wxGTK intializes the GUI (palette/visual/colorcube).
+ * under wxMSW, OnInitGui() does nothing by default. when overriding this method,
+ * the code in it is likely to be platform dependent, otherwise use OnInit(). */
virtual bool OnInitGui();
- virtual int OnRun();
- virtual int OnExit();
+
+ /* override to create top level frame, display splash screen etc. */
+ virtual bool OnInit() { return FALSE; }
+
+ virtual int OnRun() { return MainLoop(); }
+ virtual int OnExit() { return 0; }
wxWindow *GetTopWindow();
void SetTopWindow( wxWindow *win );
void SetPrintMode(int WXUNUSED(mode) ) {};
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; };
- // override this function to create default log target of arbitrary
- // user-defined classv (default implementation creates a wxLogGui object)
+ /* override this function to create default log target of arbitrary
+ * user-defined classv (default implementation creates a wxLogGui object) */
virtual wxLog *CreateLogTarget();
- // GTK implementation
+ /* GTK implementation */
- static void CommonInit();
- static void CommonCleanUp();
+ static bool Initialize();
+ static bool InitialzeVisual();
+ static void CleanUp();
bool ProcessIdle();
void DeletePendingObjects();
wxClipboard();
~wxClipboard();
- // open the clipboard before SetData() and GetData()
+ /* open the clipboard before SetData() and GetData() */
virtual bool Open();
- // close the clipboard after SetData() and GetData()
+ /* close the clipboard after SetData() and GetData() */
virtual void Close();
- // can be called several times
- virtual bool SetData( wxDataObject *data );
+ /* set the clipboard data. the clipboard will delete the broker later */
+ virtual bool SetData( wxDataBroker *data );
- // format available on the clipboard ?
- // supply ID if private format, the same as wxPrivateDataObject::SetId()
- virtual bool IsSupportedFormat( wxDataFormat format, const wxString &id = "" );
-
- // fill data with data on the clipboard (if available)
+ /* fill data with data on the clipboard (if available) */
virtual bool GetData( wxDataObject *data );
- // clears wxTheClipboard and the system's clipboard if possible
+ /* clears wxTheClipboard and the system's clipboard if possible */
virtual void Clear();
- // implementation
-
- GdkAtom GetTargetAtom( wxDataFormat format, const wxString &id = "" );
+ /* implementation */
bool m_open;
bool m_ownsClipboard;
bool m_ownsPrimarySelection;
- wxList m_dataObjects;
+ wxDataBroker *m_dataBroker;
GtkWidget *m_clipboardWidget;
bool m_formatSupported;
// classes
//-------------------------------------------------------------------------
+class wxDataFormat;
+class wxDataBroker;
class wxDataObject;
class wxTextDataObject;
class wxBitmapDataObject;
class wxFileDataObject;
//-------------------------------------------------------------------------
-// wxDataObject
+// wxDataFormat
//-------------------------------------------------------------------------
-class wxDataObject: public wxObject
+enum wxDataType
{
- DECLARE_ABSTRACT_CLASS( wxDataObject )
+ wxDF_INVALID = 0,
+ wxDF_TEXT = 1, /* CF_TEXT */
+ wxDF_BITMAP = 2, /* CF_BITMAP */
+ wxDF_METAFILE = 3, /* CF_METAFILEPICT */
+ wxDF_SYLK = 4,
+ wxDF_DIF = 5,
+ wxDF_TIFF = 6,
+ wxDF_OEMTEXT = 7, /* CF_OEMTEXT */
+ wxDF_DIB = 8, /* CF_DIB */
+ wxDF_PALETTE = 9,
+ wxDF_PENDATA = 10,
+ wxDF_RIFF = 11,
+ wxDF_WAVE = 12,
+ wxDF_UNICODETEXT = 13,
+ wxDF_ENHMETAFILE = 14,
+ wxDF_FILENAME = 15, /* CF_HDROP */
+ wxDF_LOCALE = 16,
+ wxDF_PRIVATE = 20
+};
+class wxDataFormat : public wxObject
+{
+ DECLARE_CLASS( wxDataFormat )
+
public:
+
+ wxDataFormat( wxDataType type );
+ wxDataFormat( const wxString &id );
+ wxDataFormat( wxDataFormat &format );
+ wxDataFormat( const GdkAtom atom );
+
+ int GetType() const;
+ wxString GetId() const;
+ void SetId( const wxString &id );
+ GdkAtom GetAtom();
+
+private:
- wxDataObject() {}
- ~wxDataObject() {}
+ int m_type;
+ wxString m_id;
+ bool m_hasAtom;
+ GdkAtom m_atom;
+};
- virtual wxDataFormat GetFormat() const = 0;
+//-------------------------------------------------------------------------
+// wxDataBroker handles data and ormat negotiation for clipboard and DnD
+//-------------------------------------------------------------------------
+
+class wxDataBroker : public wxObject
+{
+ DECLARE_CLASS( wxDataBroker )
+
+public:
+
+ /* constructor */
+ wxDataBroker();
- // implementation
+ /* add data object */
+ void Add( wxDataObject *dataObject, bool preferred = FALSE );
+
+private:
+
+ /* OLE implementation, the methods don't need to be overridden */
- GdkAtom m_formatAtom;
+ /* get number of supported formats */
+ virtual size_t GetFormatCount() const;
+
+ /* return nth supported format */
+ virtual wxDataFormat &GetNthFormat( size_t nth ) const;
+
+ /* return preferrd/best supported format */
+ virtual wxDataFormat &GetPreferredFormat() const;
+
+ /* search through m_dataObjects, return TRUE if found */
+ virtual bool IsSupportedFormat( wxDataFormat &format ) const;
+
+ /* search through m_dataObjects and call child's GetSize() */
+ virtual size_t GetSize( wxDataFormat& format ) const;
+
+ /* search through m_dataObjects and call child's WriteData(dest) */
+ virtual void WriteData( wxDataFormat& format, void *dest ) const;
+
+ /* implementation */
+
+public:
+
+ wxList m_dataObjects;
+ size_t m_preferred;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+// wxDataObject to be placed in wxDataBroker
+//----------------------------------------------------------------------------
+
+class wxDataObject : public wxObject
+{
+ DECLARE_DYNAMIC_CLASS( wxDataObject )
+
+public:
+
+ /* constructor */
+ wxDataObject();
+
+ /* destructor */
+ ~wxDataObject();
+
+ /* write data to dest */
+ virtual void WriteData( void *dest ) const = 0;
+
+ /* get size of data */
+ virtual size_t GetSize() const = 0;
+
+ /* implementation */
+
+ virtual wxDataFormat &GetFormat() const;
+
+ wxDataFormat *m_format;
+};
+
+//----------------------------------------------------------------------------
// wxTextDataObject is a specialization of wxDataObject for text data
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxTextDataObject : public wxDataObject
{
public:
- wxTextDataObject() {}
- wxTextDataObject( const wxString& strText )
- : m_strText(strText) { }
+ /* default constructor. call SetText() later or override
+ WriteData() and GetSize() for working on-demand */
+ wxTextDataObject();
- virtual wxDataFormat GetFormat() const
- { return wxDF_TEXT; }
-
- void SetText( const wxString& strText)
- { m_strText = strText; }
+ /* constructor */
+ wxTextDataObject( const wxString& data );
+
+ /* set current text data */
+ void SetText( const wxString& data );
- wxString GetText() const
- { return m_strText; }
+ /* get current text data */
+ wxString GetText() const;
-private:
- wxString m_strText;
+ /* by default calls WriteString() with string set by constructor or
+ by SetText(). can be overridden for working on-demand */
+ virtual void WriteData( void *dest ) const;
+
+ /* by default, returns length of string as set by constructor or
+ by SetText(). can be overridden for working on-demand */
+ virtual size_t GetSize() const;
+
+ /* write string to dest */
+ void WriteString( const wxString &str, void *dest ) const;
+
+ /* implementation */
+ wxString m_data;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// wxFileDataObject is a specialization of wxDataObject for file names
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxFileDataObject : public wxDataObject
{
public:
- wxFileDataObject(void) {}
-
- virtual wxDataFormat GetFormat() const
- { return wxDF_FILENAME; }
+ /* default constructor */
+ wxFileDataObject();
- void AddFile( const wxString &file )
- { m_files += file; m_files += (char)0; }
+ /* add file name to list */
+ void AddFile( const wxString &file );
- wxString GetFiles() const
- { return m_files; }
+ /* get all filename as one string. each file name is 0 terminated,
+ the list is double zero terminated */
+ wxString GetFiles() const;
-private:
- wxString m_files;
+ /* write list of filenames */
+ virtual void WriteData( void *dest ) const;
+
+ /* return length of list of filenames */
+ virtual size_t GetSize() const;
+ /* implementation */
+
+ wxString m_files;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxBitmapDataObject : public wxDataObject
{
public:
- wxBitmapDataObject(void) {}
+ /* see wxTextDataObject for explanation */
+
+ wxBitmapDataObject();
+ wxBitmapDataObject( const wxBitmap& bitmap );
- wxBitmapDataObject( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
+ void SetBitmap( const wxBitmap &bitmap );
+ wxBitmap GetBitmap() const;
- virtual wxDataFormat GetFormat() const
- { return wxDF_BITMAP; }
-
- void SetBitmap( const wxBitmap &bitmap )
- { m_bitmap = bitmap; }
-
- wxBitmap GetBitmap() const
- { return m_bitmap; }
+ virtual void WriteData( void *dest ) const;
+ virtual size_t GetSize() const;
+
+ void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
-private:
+ // implementation
+
wxBitmap m_bitmap;
+
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// wxPrivateDataObject is a specialization of wxDataObject for app specific data
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxPrivateDataObject : public wxDataObject
{
public:
+ /* see wxTextDataObject for explanation of functions */
+
wxPrivateDataObject();
-
~wxPrivateDataObject();
- virtual wxDataFormat GetFormat() const
- { return wxDF_PRIVATE; }
-
- // 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 "WXWORD_FORMAT".
+ /* 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", an
+ * image manipulation program would put a wxBitmapDataObject and a
+ * wxPrivateDataObject to the clipboard - the latter with "image/png". */
- void SetId( const wxString& id )
- { m_id = id; }
+ void SetId( const wxString& id );
- wxString GetId() const
- { return m_id; }
+ /* get id */
+ wxString GetId() const;
- // will make internal copy
+ /* set data. will make internal copy. */
void SetData( const char *data, size_t size );
- size_t GetDataSize() const
- { return m_size; }
-
- char* GetData() const
- { return m_data; }
+ /* returns pointer to data */
+ char* GetData() const;
+
+ virtual void WriteData( void *dest ) const;
+ virtual size_t GetSize() const;
+
+ void WriteData( const char *data, void *dest ) const;
-private:
+ // implementation
+
size_t m_size;
char* m_data;
wxString m_id;
// Override these to indicate what kind of data you support:
virtual size_t GetFormatCount() const = 0;
- virtual wxDataFormat GetFormat(size_t n) const = 0;
+ virtual wxDataFormat &GetFormat(size_t n) const;
// implementation
void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget );
+
+ wxDataFormat *m_format;
};
//-------------------------------------------------------------------------
{
public:
- wxTextDropTarget() {};
+ 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;
- virtual wxDataFormat GetFormat(size_t n) const;
};
//-------------------------------------------------------------------------
// 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 "WXWORD_FORMAT".
+ // to the clipboard - the latter with the Id "application/wxword" or
+ // "image/png".
- void SetId( const wxString& id )
- { m_id = id; }
+ void SetId( const wxString& id );
wxString GetId()
{ return m_id; }
private:
virtual size_t GetFormatCount() const;
- virtual wxDataFormat GetFormat(size_t n) const;
wxString m_id;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxFileDropTarget: public wxDropTarget
{
public:
- wxFileDropTarget() {};
+ wxFileDropTarget();
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropFiles( long x, long y,
protected:
virtual size_t GetFormatCount() const;
- virtual wxDataFormat GetFormat(size_t n) 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
+ wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
{
public:
+ /* constructor. set data later with SetData() */
wxDropSource( wxWindow *win );
- wxDropSource( wxDataObject &data, wxWindow *win );
+
+ /* constructor for setting one data object */
+ wxDropSource( wxDataObject *data, wxWindow *win );
+
+ /* constructor for setting several data objects via wxDataBroker */
+ wxDropSource( wxDataBroker *data, wxWindow *win );
~wxDropSource(void);
- void SetData( wxDataObject &data );
+ /* set one dataobject */
+ void SetData( wxDataBroker *data );
+
+ /* set severa dataobjects via wxDataBroker */
+ void SetData( wxDataObject *data );
+
+ /* start drag action */
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
- virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
+ /* override to give feedback */
+ virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
- // implementation
+ /* GTK implementation */
void RegisterWindow(void);
void UnregisterWindow(void);
GtkWidget *m_widget;
wxWindow *m_window;
wxDragResult m_retValue;
- wxDataObject *m_data;
+ wxDataBroker *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
- /* this may have to be overwritten when special, non-default visuals have
- to be set. it is also platform dependent as only X knows about displays
- and visuals. */
- virtual bool InitVisual();
-
- virtual bool OnInit();
+ /* override for altering the way wxGTK intializes the GUI (palette/visual/colorcube).
+ * under wxMSW, OnInitGui() does nothing by default. when overriding this method,
+ * the code in it is likely to be platform dependent, otherwise use OnInit(). */
virtual bool OnInitGui();
- virtual int OnRun();
- virtual int OnExit();
+
+ /* override to create top level frame, display splash screen etc. */
+ virtual bool OnInit() { return FALSE; }
+
+ virtual int OnRun() { return MainLoop(); }
+ virtual int OnExit() { return 0; }
wxWindow *GetTopWindow();
void SetTopWindow( wxWindow *win );
void SetPrintMode(int WXUNUSED(mode) ) {};
int GetPrintMode() const { return wxPRINT_POSTSCRIPT; };
- // override this function to create default log target of arbitrary
- // user-defined classv (default implementation creates a wxLogGui object)
+ /* override this function to create default log target of arbitrary
+ * user-defined classv (default implementation creates a wxLogGui object) */
virtual wxLog *CreateLogTarget();
- // GTK implementation
+ /* GTK implementation */
- static void CommonInit();
- static void CommonCleanUp();
+ static bool Initialize();
+ static bool InitialzeVisual();
+ static void CleanUp();
bool ProcessIdle();
void DeletePendingObjects();
wxClipboard();
~wxClipboard();
- // open the clipboard before SetData() and GetData()
+ /* open the clipboard before SetData() and GetData() */
virtual bool Open();
- // close the clipboard after SetData() and GetData()
+ /* close the clipboard after SetData() and GetData() */
virtual void Close();
- // can be called several times
- virtual bool SetData( wxDataObject *data );
+ /* set the clipboard data. the clipboard will delete the broker later */
+ virtual bool SetData( wxDataBroker *data );
- // format available on the clipboard ?
- // supply ID if private format, the same as wxPrivateDataObject::SetId()
- virtual bool IsSupportedFormat( wxDataFormat format, const wxString &id = "" );
-
- // fill data with data on the clipboard (if available)
+ /* fill data with data on the clipboard (if available) */
virtual bool GetData( wxDataObject *data );
- // clears wxTheClipboard and the system's clipboard if possible
+ /* clears wxTheClipboard and the system's clipboard if possible */
virtual void Clear();
- // implementation
-
- GdkAtom GetTargetAtom( wxDataFormat format, const wxString &id = "" );
+ /* implementation */
bool m_open;
bool m_ownsClipboard;
bool m_ownsPrimarySelection;
- wxList m_dataObjects;
+ wxDataBroker *m_dataBroker;
GtkWidget *m_clipboardWidget;
bool m_formatSupported;
// classes
//-------------------------------------------------------------------------
+class wxDataFormat;
+class wxDataBroker;
class wxDataObject;
class wxTextDataObject;
class wxBitmapDataObject;
class wxFileDataObject;
//-------------------------------------------------------------------------
-// wxDataObject
+// wxDataFormat
//-------------------------------------------------------------------------
-class wxDataObject: public wxObject
+enum wxDataType
{
- DECLARE_ABSTRACT_CLASS( wxDataObject )
+ wxDF_INVALID = 0,
+ wxDF_TEXT = 1, /* CF_TEXT */
+ wxDF_BITMAP = 2, /* CF_BITMAP */
+ wxDF_METAFILE = 3, /* CF_METAFILEPICT */
+ wxDF_SYLK = 4,
+ wxDF_DIF = 5,
+ wxDF_TIFF = 6,
+ wxDF_OEMTEXT = 7, /* CF_OEMTEXT */
+ wxDF_DIB = 8, /* CF_DIB */
+ wxDF_PALETTE = 9,
+ wxDF_PENDATA = 10,
+ wxDF_RIFF = 11,
+ wxDF_WAVE = 12,
+ wxDF_UNICODETEXT = 13,
+ wxDF_ENHMETAFILE = 14,
+ wxDF_FILENAME = 15, /* CF_HDROP */
+ wxDF_LOCALE = 16,
+ wxDF_PRIVATE = 20
+};
+class wxDataFormat : public wxObject
+{
+ DECLARE_CLASS( wxDataFormat )
+
public:
+
+ wxDataFormat( wxDataType type );
+ wxDataFormat( const wxString &id );
+ wxDataFormat( wxDataFormat &format );
+ wxDataFormat( const GdkAtom atom );
+
+ int GetType() const;
+ wxString GetId() const;
+ void SetId( const wxString &id );
+ GdkAtom GetAtom();
+
+private:
- wxDataObject() {}
- ~wxDataObject() {}
+ int m_type;
+ wxString m_id;
+ bool m_hasAtom;
+ GdkAtom m_atom;
+};
- virtual wxDataFormat GetFormat() const = 0;
+//-------------------------------------------------------------------------
+// wxDataBroker handles data and ormat negotiation for clipboard and DnD
+//-------------------------------------------------------------------------
+
+class wxDataBroker : public wxObject
+{
+ DECLARE_CLASS( wxDataBroker )
+
+public:
+
+ /* constructor */
+ wxDataBroker();
- // implementation
+ /* add data object */
+ void Add( wxDataObject *dataObject, bool preferred = FALSE );
+
+private:
+
+ /* OLE implementation, the methods don't need to be overridden */
- GdkAtom m_formatAtom;
+ /* get number of supported formats */
+ virtual size_t GetFormatCount() const;
+
+ /* return nth supported format */
+ virtual wxDataFormat &GetNthFormat( size_t nth ) const;
+
+ /* return preferrd/best supported format */
+ virtual wxDataFormat &GetPreferredFormat() const;
+
+ /* search through m_dataObjects, return TRUE if found */
+ virtual bool IsSupportedFormat( wxDataFormat &format ) const;
+
+ /* search through m_dataObjects and call child's GetSize() */
+ virtual size_t GetSize( wxDataFormat& format ) const;
+
+ /* search through m_dataObjects and call child's WriteData(dest) */
+ virtual void WriteData( wxDataFormat& format, void *dest ) const;
+
+ /* implementation */
+
+public:
+
+ wxList m_dataObjects;
+ size_t m_preferred;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+// wxDataObject to be placed in wxDataBroker
+//----------------------------------------------------------------------------
+
+class wxDataObject : public wxObject
+{
+ DECLARE_DYNAMIC_CLASS( wxDataObject )
+
+public:
+
+ /* constructor */
+ wxDataObject();
+
+ /* destructor */
+ ~wxDataObject();
+
+ /* write data to dest */
+ virtual void WriteData( void *dest ) const = 0;
+
+ /* get size of data */
+ virtual size_t GetSize() const = 0;
+
+ /* implementation */
+
+ virtual wxDataFormat &GetFormat() const;
+
+ wxDataFormat *m_format;
+};
+
+//----------------------------------------------------------------------------
// wxTextDataObject is a specialization of wxDataObject for text data
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxTextDataObject : public wxDataObject
{
public:
- wxTextDataObject() {}
- wxTextDataObject( const wxString& strText )
- : m_strText(strText) { }
+ /* default constructor. call SetText() later or override
+ WriteData() and GetSize() for working on-demand */
+ wxTextDataObject();
- virtual wxDataFormat GetFormat() const
- { return wxDF_TEXT; }
-
- void SetText( const wxString& strText)
- { m_strText = strText; }
+ /* constructor */
+ wxTextDataObject( const wxString& data );
+
+ /* set current text data */
+ void SetText( const wxString& data );
- wxString GetText() const
- { return m_strText; }
+ /* get current text data */
+ wxString GetText() const;
-private:
- wxString m_strText;
+ /* by default calls WriteString() with string set by constructor or
+ by SetText(). can be overridden for working on-demand */
+ virtual void WriteData( void *dest ) const;
+
+ /* by default, returns length of string as set by constructor or
+ by SetText(). can be overridden for working on-demand */
+ virtual size_t GetSize() const;
+
+ /* write string to dest */
+ void WriteString( const wxString &str, void *dest ) const;
+
+ /* implementation */
+ wxString m_data;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// wxFileDataObject is a specialization of wxDataObject for file names
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxFileDataObject : public wxDataObject
{
public:
- wxFileDataObject(void) {}
-
- virtual wxDataFormat GetFormat() const
- { return wxDF_FILENAME; }
+ /* default constructor */
+ wxFileDataObject();
- void AddFile( const wxString &file )
- { m_files += file; m_files += (char)0; }
+ /* add file name to list */
+ void AddFile( const wxString &file );
- wxString GetFiles() const
- { return m_files; }
+ /* get all filename as one string. each file name is 0 terminated,
+ the list is double zero terminated */
+ wxString GetFiles() const;
-private:
- wxString m_files;
+ /* write list of filenames */
+ virtual void WriteData( void *dest ) const;
+
+ /* return length of list of filenames */
+ virtual size_t GetSize() const;
+ /* implementation */
+
+ wxString m_files;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxBitmapDataObject : public wxDataObject
{
public:
- wxBitmapDataObject(void) {}
+ /* see wxTextDataObject for explanation */
+
+ wxBitmapDataObject();
+ wxBitmapDataObject( const wxBitmap& bitmap );
- wxBitmapDataObject( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
+ void SetBitmap( const wxBitmap &bitmap );
+ wxBitmap GetBitmap() const;
- virtual wxDataFormat GetFormat() const
- { return wxDF_BITMAP; }
-
- void SetBitmap( const wxBitmap &bitmap )
- { m_bitmap = bitmap; }
-
- wxBitmap GetBitmap() const
- { return m_bitmap; }
+ virtual void WriteData( void *dest ) const;
+ virtual size_t GetSize() const;
+
+ void WriteBitmap( const wxBitmap &bitmap, void *dest ) const;
-private:
+ // implementation
+
wxBitmap m_bitmap;
+
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// wxPrivateDataObject is a specialization of wxDataObject for app specific data
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxPrivateDataObject : public wxDataObject
{
public:
+ /* see wxTextDataObject for explanation of functions */
+
wxPrivateDataObject();
-
~wxPrivateDataObject();
- virtual wxDataFormat GetFormat() const
- { return wxDF_PRIVATE; }
-
- // 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 "WXWORD_FORMAT".
+ /* 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", an
+ * image manipulation program would put a wxBitmapDataObject and a
+ * wxPrivateDataObject to the clipboard - the latter with "image/png". */
- void SetId( const wxString& id )
- { m_id = id; }
+ void SetId( const wxString& id );
- wxString GetId() const
- { return m_id; }
+ /* get id */
+ wxString GetId() const;
- // will make internal copy
+ /* set data. will make internal copy. */
void SetData( const char *data, size_t size );
- size_t GetDataSize() const
- { return m_size; }
-
- char* GetData() const
- { return m_data; }
+ /* returns pointer to data */
+ char* GetData() const;
+
+ virtual void WriteData( void *dest ) const;
+ virtual size_t GetSize() const;
+
+ void WriteData( const char *data, void *dest ) const;
-private:
+ // implementation
+
size_t m_size;
char* m_data;
wxString m_id;
// Override these to indicate what kind of data you support:
virtual size_t GetFormatCount() const = 0;
- virtual wxDataFormat GetFormat(size_t n) const = 0;
+ virtual wxDataFormat &GetFormat(size_t n) const;
// implementation
void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget );
+
+ wxDataFormat *m_format;
};
//-------------------------------------------------------------------------
{
public:
- wxTextDropTarget() {};
+ 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;
- virtual wxDataFormat GetFormat(size_t n) const;
};
//-------------------------------------------------------------------------
// 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 "WXWORD_FORMAT".
+ // to the clipboard - the latter with the Id "application/wxword" or
+ // "image/png".
- void SetId( const wxString& id )
- { m_id = id; }
+ void SetId( const wxString& id );
wxString GetId()
{ return m_id; }
private:
virtual size_t GetFormatCount() const;
- virtual wxDataFormat GetFormat(size_t n) const;
wxString m_id;
};
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
-// ----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
class wxFileDropTarget: public wxDropTarget
{
public:
- wxFileDropTarget() {};
+ wxFileDropTarget();
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropFiles( long x, long y,
protected:
virtual size_t GetFormatCount() const;
- virtual wxDataFormat GetFormat(size_t n) 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
+ wxDragMove, // the data was successfully moved (MSW only)
wxDragCancel // the operation was cancelled by user (not an error)
};
{
public:
+ /* constructor. set data later with SetData() */
wxDropSource( wxWindow *win );
- wxDropSource( wxDataObject &data, wxWindow *win );
+
+ /* constructor for setting one data object */
+ wxDropSource( wxDataObject *data, wxWindow *win );
+
+ /* constructor for setting several data objects via wxDataBroker */
+ wxDropSource( wxDataBroker *data, wxWindow *win );
~wxDropSource(void);
- void SetData( wxDataObject &data );
+ /* set one dataobject */
+ void SetData( wxDataBroker *data );
+
+ /* set severa dataobjects via wxDataBroker */
+ void SetData( wxDataObject *data );
+
+ /* start drag action */
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
- virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
+ /* override to give feedback */
+ virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }
- // implementation
+ /* GTK implementation */
void RegisterWindow(void);
void UnregisterWindow(void);
GtkWidget *m_widget;
wxWindow *m_window;
wxDragResult m_retValue;
- wxDataObject *m_data;
+ wxDataBroker *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
#include "wx/object.h"
#include "wx/string.h"
+enum wxIPCFormat
+{
+ wxIPC_INVALID = 0,
+ wxIPC_TEXT = 1, /* CF_TEXT */
+ wxIPC_BITMAP = 2, /* CF_BITMAP */
+ wxIPC_METAFILE = 3, /* CF_METAFILEPICT */
+ wxIPC_SYLK = 4,
+ wxIPC_DIF = 5,
+ wxIPC_TIFF = 6,
+ wxIPC_OEMTEXT = 7, /* CF_OEMTEXT */
+ wxIPC_DIB = 8, /* CF_DIB */
+ wxIPC_PALETTE = 9,
+ wxIPC_PENDATA = 10,
+ wxIPC_RIFF = 11,
+ wxIPC_WAVE = 12,
+ wxIPC_UNICODETEXT = 13,
+ wxIPC_ENHMETAFILE = 14,
+ wxIPC_FILENAME = 15, /* CF_HDROP */
+ wxIPC_LOCALE = 16,
+ wxIPC_PRIVATE = 20
+};
+
class WXDLLEXPORT wxDDEServerBase;
class WXDLLEXPORT wxDDEClientBase;
inline ~wxConnectionBase(void) {}
// Calls that CLIENT can make
- virtual bool Execute(char *data, int size = -1, wxDataFormat format = wxDF_TEXT ) = 0;
- virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxDF_TEXT); }
- virtual char *Request(const wxString& item, int *size = (int *) NULL, wxDataFormat format = wxDF_TEXT) = 0;
- virtual bool Poke(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT) = 0;
+ virtual bool Execute(char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
+ virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxIPC_TEXT); }
+ virtual char *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0;
+ virtual bool Poke(const wxString& item, char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
virtual bool StartAdvise(const wxString& item) = 0;
virtual bool StopAdvise(const wxString& item) = 0;
// Calls that SERVER can make
- virtual bool Advise(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT) = 0;
+ virtual bool Advise(const wxString& item, char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
// Calls that both can make
virtual bool Disconnect(void) = 0;
~wxDDEConnection(void);
// Calls that CLIENT can make
- virtual bool Execute(char *data, int size = -1, wxDataFormat format = wxDF_TEXT);
- virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxDF_TEXT); }
- virtual char *Request(const wxString& item, int *size = NULL, wxDataFormat format = wxDF_TEXT);
- virtual bool Poke(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT);
+ virtual bool Execute(char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
+ virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxIPC_TEXT); }
+ virtual char *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
+ virtual bool Poke(const wxString& item, char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
virtual bool StartAdvise(const wxString& item);
virtual bool StopAdvise(const wxString& item);
// Calls that SERVER can make
- virtual bool Advise(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT);
+ virtual bool Advise(const wxString& item, char *data, int size = -1, wxIPCFormat format = wxIPC_TEXT);
// Calls that both can make
virtual bool Disconnect(void);
// Callbacks to SERVER - override at will
- virtual bool OnExecute(const wxString& topic, char *data, int size, wxDataFormat format) { return FALSE; };
- virtual char *OnRequest(const wxString& topic, const wxString& item, int *size, wxDataFormat format) { return NULL; };
- virtual bool OnPoke(const wxString& topic, const wxString& item, char *data, int size, wxDataFormat format) { return FALSE; };
+ virtual bool OnExecute(const wxString& topic, char *data, int size, wxIPCFormat format) { return FALSE; };
+ virtual char *OnRequest(const wxString& topic, const wxString& item, int *size, wxIPCFormat format) { return NULL; };
+ virtual bool OnPoke(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format) { return FALSE; };
virtual bool OnStartAdvise(const wxString& topic, const wxString& item) { return FALSE; };
virtual bool OnStopAdvise(const wxString& topic, const wxString& item) { return FALSE; };
// Callbacks to CLIENT - override at will
- virtual bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxDataFormat format) { return FALSE; };
+ virtual bool OnAdvise(const wxString& topic, const wxString& item, char *data, int size, wxIPCFormat format) { return FALSE; };
// Callbacks to BOTH
WXHCONV m_hConv;
char* m_sendingData;
int m_dataSize;
- wxDataFormat m_dataType;
+ wxIPCFormat m_dataType;
};
class WXDLLEXPORT wxDDEServer: public wxServerBase
// Calls that CLIENT can make
bool Execute(char *data, int size = -1,
- wxDataFormat format = wxDF_TEXT);
+ wxIPCFormat format = wxIPC_TEXT);
char *Request(const wxString& item, int *size = NULL,
- wxDataFormat format = wxDF_TEXT);
+ wxIPCFormat format = wxIPC_TEXT);
bool Poke(const wxString& item, char *data, int size = -1,
- wxDataFormat format = wxDF_TEXT);
+ wxIPCFormat format = wxIPC_TEXT);
bool StartAdvise(const wxString& item);
bool StopAdvise(const wxString& item);
// Calls that SERVER can make
bool Advise(const wxString& item, char *data, int size = -1,
- wxDataFormat format = wxDF_TEXT);
+ wxIPCFormat format = wxIPC_TEXT);
// Calls that both can make
bool Disconnect();
{
#ifdef __WXGTK__
- if (!wxTheClipboard->IsSupportedFormat( wxDF_TEXT ))
- {
- *m_text << "The clipboard doesn't contain any data in the requested format." << "\n";
-
- return;
- }
-
if (!wxTheClipboard->Open())
{
*m_text << "Error opening the clipboard." << "\n";
if (text.IsEmpty()) return;
- wxTextDataObject *data = new wxTextDataObject( text );
-
if (!wxTheClipboard->Open())
{
*m_text << "Error opening the clipboard." << "\n";
*m_text << "Successfully opened the clipboard." << "\n";
}
- if (!wxTheClipboard->SetData( data ))
+ wxTextDataObject *data = new wxTextDataObject( text );
+ wxDataBroker *broker = new wxDataBroker();
+ broker->Add( data );
+
+ if (!wxTheClipboard->SetData( broker ))
{
*m_text << "Error while copying to the clipboard." << "\n";
}
// The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s"
// to achieve a single row (in this case the first name in alphabetical order).
- Contact->whereStr.Printf("NAME = 'Robert'",Contact->tableName);
-/*
Contact->whereStr.Printf("NAME = (SELECT MIN(NAME) FROM %s)",Contact->tableName);
-*/
// NOTE: (const char*) returns a pointer which may not be valid later, so this is short term use only
Contact->where = (char*) (const char*) Contact->whereStr;
}
// Previous record not available, retrieve first record in table
- Contact->whereStr = "NAME = 'Robert' ";
-/*
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += Contact->tableName;
Contact->whereStr += ")";
-*/
Contact->where = (char*) (const char*) Contact->whereStr;
if (!Contact->Query())
{
if (strcmp(qryWhere, (const char*) Contact->qryWhereStr))
{
Contact->orderBy = "NAME";
-/*
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += CONTACT_TABLE_NAME;
-*/
+
// Append the query where string (if there is one)
Contact->qryWhereStr = qryWhere;
if (strlen(qryWhere))
// Query the first record in the table
Contact->orderBy = "NAME";
- Contact->whereStr = "NAME = 'Robert' ";
-/*
+
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += CONTACT_TABLE_NAME;
Contact->whereStr += ")";
-*/
+
Contact->where = (char*) (const char*) Contact->whereStr;
if (!Contact->Query())
{
{
wxString w;
-/*
+
w = "NAME = (SELECT MIN(NAME) FROM ";
-*/
- w = "NAME = (SELECT NAME FROM ";
w += Contact->tableName;
w += " WHERE NAME > '";
w += Contact->Name;
// Name of the table to be created/opened
-const char CONTACT_TABLE_NAME[] = "CONTACTS";
+const char CONTACT_TABLE_NAME[] = "contacts";
// Nuber of columns in the above table
const int CONTACT_NO_COLS = 12; // 0-11
{
// start drag operation
- wxTextDataObject data(m_strText);
- wxDropSource dragSource(data, this);
+ wxDropSource dragSource( new wxTextDataObject (m_strText), this );
const char *pc;
switch ( dragSource.DoDragDrop(TRUE) )
return TRUE;
}
-bool wxTCPConnection::Execute (char *data, int size, wxDataFormat format)
+bool wxTCPConnection::Execute (char *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
return FALSE;
return TRUE;
}
-char *wxTCPConnection::Request (const wxString& item, int *size, wxDataFormat format)
+char *wxTCPConnection::Request (const wxString& item, int *size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
return NULL;
}
}
-bool wxTCPConnection::Poke (const wxString& item, char *data, int size, wxDataFormat format)
+bool wxTCPConnection::Poke (const wxString& item, char *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
return FALSE;
// Calls that SERVER can make
bool wxTCPConnection::Advise (const wxString& item,
- char *data, int size, wxDataFormat format)
+ char *data, int size, wxIPCFormat format)
{
if (!m_sock->IsConnected())
return FALSE;
case IPC_EXECUTE: {
char *data;
size_t size;
- wxDataFormat format;
+ wxIPCFormat format;
- format = (wxDataFormat)codeci->Read8();
+ format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
codeci->Read(data, size);
case IPC_ADVISE: {
char *data;
size_t size;
- wxDataFormat format;
+ wxIPCFormat format;
item = codeci->ReadString();
- format = (wxDataFormat)codeci->Read8();
+ format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
codeci->Read(data, size);
break;
}
case IPC_POKE: {
- wxDataFormat format;
+ wxIPCFormat format;
size_t size;
char *data;
item = codeci->ReadString();
- format = (wxDataFormat)codeci->Read8();
+ format = (wxIPCFormat)codeci->Read8();
size = codeci->Read32();
data = new char[size];
codeci->Read(data, size);
break;
}
case IPC_REQUEST: {
- wxDataFormat format;
+ wxIPCFormat format;
item = codeci->ReadString();
- format = (wxDataFormat)codeci->Read8();
+ format = (wxIPCFormat)codeci->Read8();
int user_size = -1;
char *user_data = connection->OnRequest (topic_name, item, &user_size, format);
#include "wx/memory.h"
#include "wx/font.h"
#include "wx/settings.h"
+#include "wx/dialog.h"
#if wxUSE_WX_RESOURCES
#include "wx/resource.h"
#endif
wxApp::wxApp()
{
- m_idleTag = 0;
+ wxTheApp = this;
+
m_topWindow = (wxWindow *) NULL;
m_exitOnFrameDelete = TRUE;
+
+ m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
+
m_colorCube = (unsigned char*) NULL;
- wxTheApp = this;
}
wxApp::~wxApp(void)
if (m_colorCube) free(m_colorCube);
}
-bool wxApp::InitVisual()
+bool wxApp::OnInitGui()
{
/* Nothing to do for 15, 16, 24, 32 bit displays */
GdkVisual *visual = gdk_visual_get_system();
if (visual->depth > 8) return TRUE;
-
- /* this initiates the standard palette as defined by GdkImlib
- in the GNOME libraries. it ensures that all GNOME applications
- use the same 64 colormap entries on 8-bit displays so you
- can use several rather graphics-heavy applications at the
- same time */
- /*
- GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
+ /* this initiates the standard palette as defined by GdkImlib
+ in the GNOME libraries. it ensures that all GNOME applications
+ use the same 64 colormap entries on 8-bit displays so you
+ can use several rather graphics-heavy applications at the
+ same time.
+ NOTE: this doesn't really seem to work this way... */
- for (int i = 0; i < 64; i++)
- {
- GdkColor col;
- col.red = g_palette[i*3 + 0] << 8;
- col.green = g_palette[i*3 + 1] << 8;
- col.blue = g_palette[i*3 + 2] << 8;
- col.pixel = 0;
+ /*
+ GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
- gdk_color_alloc( cmap, &col );
- }
+ for (int i = 0; i < 64; i++)
+ {
+ GdkColor col;
+ col.red = g_palette[i*3 + 0] << 8;
+ col.green = g_palette[i*3 + 1] << 8;
+ col.blue = g_palette[i*3 + 2] << 8;
+ col.pixel = 0;
+
+ gdk_color_alloc( cmap, &col );
+ }
- gtk_widget_set_default_colormap( cmap );
- */
+ gtk_widget_set_default_colormap( cmap );
+ */
/* initialize color cube for 8-bit color reduction dithering */
}
}
}
-
- return TRUE;
-}
-bool wxApp::OnInitGui(void)
-{
- m_idleTag = gtk_idle_add( wxapp_idle_callback, NULL );
return TRUE;
}
-bool wxApp::OnInit(void)
-{
- return TRUE;
-}
-
-int wxApp::OnRun(void)
-{
- return MainLoop();
-}
-
bool wxApp::ProcessIdle(void)
{
wxIdleEvent event;
return needMore ;
}
-int wxApp::OnExit(void)
-{
- return 0;
-}
-
int wxApp::MainLoop(void)
{
gtk_main();
m_topWindow = win;
}
-void wxApp::CommonInit(void)
+bool wxApp::Initialize(void)
{
- wxSystemSettings::Init();
+ wxBuffer = new char[BUFSIZ + 512];
+
+ wxClassInfo::InitializeClasses();
+
+ wxSystemSettings::Init();
- wxTheFontNameDirectory = new wxFontNameDirectory;
- wxTheFontNameDirectory->Initialize();
+ wxTheFontNameDirectory = new wxFontNameDirectory;
+ wxTheFontNameDirectory->Initialize();
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
+ wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
+ wxTheColourDatabase->Initialize();
- wxInitializeStockLists();
- wxInitializeStockObjects();
+ wxInitializeStockLists();
+ wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES
- wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
+ wxTheResourceCache = new wxResourceCache( wxKEY_STRING );
- wxInitializeResourceSystem();
+ wxInitializeResourceSystem();
#endif
- wxImage::InitStandardHandlers();
+ wxImage::InitStandardHandlers();
-// g_globalCursor = new wxCursor;
+ /* no global cursor under X
+ g_globalCursor = new wxCursor; */
+
+ wxModule::RegisterModules();
+ if (!wxModule::InitializeModules()) return FALSE;
+
+ return TRUE;
}
-void wxApp::CommonCleanUp(void)
+void wxApp::CleanUp(void)
{
- if (wxTheColourDatabase) delete wxTheColourDatabase;
- wxTheColourDatabase = (wxColourDatabase*) NULL;
-
- if (wxTheFontNameDirectory) delete wxTheFontNameDirectory;
- wxTheFontNameDirectory = (wxFontNameDirectory*) NULL;
-
- wxDeleteStockObjects();
+ wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES
wxFlushResources();
wxCleanUpResourceSystem();
#endif
+ if (wxTheColourDatabase) delete wxTheColourDatabase;
+ wxTheColourDatabase = (wxColourDatabase*) NULL;
+
+ if (wxTheFontNameDirectory) delete wxTheFontNameDirectory;
+ wxTheFontNameDirectory = (wxFontNameDirectory*) NULL;
+
+ wxDeleteStockObjects();
+
wxDeleteStockLists();
wxImage::CleanUpHandlers();
+ delete wxTheApp;
+ wxTheApp = (wxApp*) NULL;
+
+ /* check for memory leaks */
+#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
+ if (wxDebugContext::CountObjectsLeft() > 0)
+ {
+ wxLogDebug("There were memory leaks.\n");
+ wxDebugContext::Dump();
+ wxDebugContext::PrintStatistics();
+ }
+#endif
+
+ /* do this as the very last thing because everything else can log messages */
+ wxLog::DontCreateOnDemand();
+
+ wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
+ if (oldLog) delete oldLog;
+
wxSystemSettings::Done();
+
+ wxClassInfo::CleanUpClasses();
+
+ delete[] wxBuffer;
}
wxLog *wxApp::CreateLogTarget()
{
- return new wxLogGui;
+ return new wxLogGui;
}
//-----------------------------------------------------------------------------
int wxEntry( int argc, char *argv[] )
{
- wxBuffer = new char[BUFSIZ + 512];
+ gtk_set_locale();
- wxClassInfo::InitializeClasses();
+ gtk_init( &argc, &argv );
+ if (!wxApp::Initialize()) return 0;
if (!wxTheApp)
{
wxStripExtension( name );
wxTheApp->SetAppName( name );
- gtk_set_locale();
-
- gtk_init( &argc, &argv );
-
- if (!wxTheApp->InitVisual()) return 0;
-
- wxApp::CommonInit();
-
if (!wxTheApp->OnInitGui()) return 0;
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
-
- // Here frames insert themselves automatically
- // into wxTopLevelWindows by getting created
- // in OnInit().
+ /* Here frames insert themselves automatically
+ * into wxTopLevelWindows by getting created
+ * in OnInit(). */
if (!wxTheApp->OnInit()) return 0;
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
- wxTheApp->DeletePendingObjects();
-
- wxTheApp->OnExit();
-
- wxModule::CleanUpModules();
-
- wxApp::CommonCleanUp();
-
- delete wxTheApp;
- wxTheApp = (wxApp*) NULL;
-
- wxClassInfo::CleanUpClasses();
-
- delete[] wxBuffer;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
-
- if (wxDebugContext::CountObjectsLeft() > 0)
+ wxWindow *topWindow = wxTheApp->GetTopWindow();
+ if (topWindow)
{
- wxLogDebug("There were memory leaks.\n");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
+ /* Forcibly delete the window. */
+ if (topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
+ topWindow->IsKindOf(CLASSINFO(wxDialog)) )
+ {
+ topWindow->Close( TRUE );
+ wxTheApp->DeletePendingObjects();
+ }
+ else
+ {
+ delete topWindow;
+ wxTheApp->SetTopWindow( (wxWindow*) NULL );
+ }
}
-#endif
+ wxTheApp->OnExit();
- wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
- if (oldLog) delete oldLog;
+ /* flush the logged messages if any */
+ wxLog *log = wxLog::GetActiveTarget();
+ if (log != NULL && log->HasPendingMessages())
+ log->Flush();
+
+ wxApp::CleanUp();
return retValue;
}
// make sure we got the data in the correct format
- if (data_object->m_formatAtom != selection_data->target) return;
+ if (data_object->GetFormat().GetAtom() != selection_data->target) return;
// make sure we got the data in the correct form (selection type).
// if so, copy data to target object
- switch (data_object->GetFormat())
+ switch (data_object->GetFormat().GetType())
{
case wxDF_TEXT:
{
if ((!wxTheClipboard->m_ownsPrimarySelection) &&
(!wxTheClipboard->m_ownsClipboard))
{
- // the clipboard is no longer in our hands. we can the
- // clipboard data.
-
- wxTheClipboard->m_dataObjects.Clear();
+ /* the clipboard is no longer in our hands. we can the clipboard data. */
+
+ if (wxTheClipboard->m_dataBroker)
+ {
+ delete wxTheClipboard->m_dataBroker;
+ wxTheClipboard->m_dataBroker = (wxDataBroker*) NULL;
+ }
}
return TRUE;
{
if (!wxTheClipboard) return;
- wxNode *node = wxTheClipboard->m_dataObjects.First();
+ if (!wxTheClipboard->m_dataBroker) return;
+
+ wxNode *node = wxTheClipboard->m_dataBroker->m_dataObjects.First();
while (node)
{
wxDataObject *data_object = (wxDataObject *)node->Data();
- if (data_object->m_formatAtom != selection_data->target)
+ if (data_object->GetFormat().GetAtom() != selection_data->target)
{
node = node->Next();
break;
}
- switch (data_object->GetFormat())
+ switch (data_object->GetFormat().GetType())
{
case wxDF_TEXT:
{
{
wxPrivateDataObject *private_object = (wxPrivateDataObject*) data_object;
- if (private_object->GetDataSize() == 0) return;
+ if (private_object->GetSize() == 0) return;
gtk_selection_data_set(
selection_data,
GDK_SELECTION_TYPE_STRING,
8*sizeof(gchar),
(unsigned char*) private_object->GetData(),
- (int) private_object->GetDataSize() );
+ (int) private_object->GetSize() );
}
default:
m_ownsClipboard = FALSE;
m_ownsPrimarySelection = FALSE;
- m_dataObjects.DeleteContents( TRUE );
+ m_dataBroker = (wxDataBroker*) NULL;
m_receivedData = (wxDataObject*) NULL;
void wxClipboard::Clear()
{
- if (m_dataObjects.GetCount())
+ if (m_dataBroker)
{
/* As we have data we also own the clipboard. Once we no longer own
it, clear_selection is called which will set m_data to zero */
gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
}
- m_dataObjects.Clear();
+ if (m_dataBroker)
+ {
+ delete m_dataBroker;
+ m_dataBroker = (wxDataBroker*) NULL;
+ }
}
m_targetRequested = 0;
return TRUE;
}
-bool wxClipboard::SetData( wxDataObject *data )
+bool wxClipboard::SetData( wxDataBroker *data )
{
wxCHECK_MSG( data, FALSE, "data is invalid" );
- wxNode *node = m_dataObjects.First();
-
- while (node)
- {
- wxDataObject *d = (wxDataObject*)node->Data();
-
- if (d->GetFormat() == data->GetFormat())
- {
- m_dataObjects.DeleteNode( node );
-
- break;
- }
-
- node = node->Next();
- }
+ Clear();
+
+ m_dataBroker = data;
- m_dataObjects.Append( data );
+ if (!m_dataBroker) return FALSE;
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
- if (data->GetFormat() == wxDF_PRIVATE)
+ wxNode *node = m_dataBroker->m_dataObjects.First();
+ while (node)
{
- wxPrivateDataObject* pd = (wxPrivateDataObject*) data;
+ wxDataObject *dobj = (wxDataObject*)node->Data();
- wxCHECK_MSG( !pd->GetId().IsEmpty(), FALSE, "private clipboard format requires ID string" );
+ GdkAtom format = dobj->GetFormat().GetAtom();
- data->m_formatAtom = GetTargetAtom( data->GetFormat(), pd->GetId() );
- }
- else
- {
- data->m_formatAtom = GetTargetAtom( data->GetFormat() );
- }
-
- // This should happen automatically
+ if (format != (GdkAtom) 0)
+ {
+ /* This should happen automatically */
- m_ownsClipboard = FALSE;
- m_ownsPrimarySelection = FALSE;
+ m_ownsClipboard = FALSE;
+ m_ownsPrimarySelection = FALSE;
- // Add handlers if someone requests data
+ /* Add handlers if someone requests data */
- gtk_selection_add_handler( m_clipboardWidget,
+ gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
- data->m_formatAtom,
+ format,
selection_handler,
- NULL );
+ (gpointer) NULL );
- gtk_selection_add_handler( m_clipboardWidget,
+ gtk_selection_add_handler( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
- data->m_formatAtom,
+ format,
selection_handler,
- NULL );
+ (gpointer) NULL );
- // Tell the world we offer clipboard data
+ /* Tell the world we offer clipboard data */
- if (!gtk_selection_owner_set( m_clipboardWidget,
+ if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
GDK_CURRENT_TIME ))
- {
- return FALSE;
- }
- m_ownsClipboard = TRUE;
+ {
+ return FALSE;
+ }
+ m_ownsClipboard = TRUE;
- if (!gtk_selection_owner_set( m_clipboardWidget,
+ if (!gtk_selection_owner_set( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME ))
- {
- return FALSE;
+ {
+ return FALSE;
+ }
+ m_ownsPrimarySelection = TRUE;
+ }
+
+ node = node->Next();
}
- m_ownsPrimarySelection = TRUE;
return TRUE;
}
m_open = FALSE;
}
-bool wxClipboard::IsSupportedFormat( wxDataFormat format, const wxString &id )
+bool wxClipboard::GetData( wxDataObject *data )
{
- m_targetRequested = GetTargetAtom( format, id );
+ wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
+
+ m_receivedData = data;
+
+ wxCHECK_MSG( m_receivedData, FALSE, "invalid data object" );
+
+ /* STEP ONE: check if there is such data in the clipboard */
+
+ m_targetRequested = data->GetFormat().GetAtom();
+ wxCHECK_MSG( m_targetRequested, FALSE, "invalid clipboard format" );
+
if (m_targetRequested == 0) return FALSE;
- // add handler for target (= format) query
+ /* add handler for target (= format) query */
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_received",
m_formatSupported = FALSE;
- // perform query. this will set m_formatSupported to
- // TRUE if m_targetRequested is supported
+ /* perform query. this will set m_formatSupported to
+ * TRUE if m_targetRequested is supported */
gtk_selection_convert( m_clipboardWidget,
g_clipboardAtom,
if (!m_formatSupported) return FALSE;
- return TRUE;
-}
-
-bool wxClipboard::GetData( wxDataObject *data )
-{
- wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
-
- m_receivedData = data;
-
- wxCHECK_MSG( m_receivedData, FALSE, "invalid data object" );
+ /* STEP TWO: get the data from the clipboard */
- if (m_receivedData->GetFormat() == wxDF_PRIVATE)
- {
- wxPrivateDataObject* pd = (wxPrivateDataObject*) m_receivedData;
-
- wxCHECK_MSG( !pd->GetId().IsEmpty(), FALSE, "private clipboard format requires ID string" );
-
- m_targetRequested = GetTargetAtom( m_receivedData->GetFormat(), pd->GetId() );
- }
- else
- {
- m_targetRequested = GetTargetAtom( m_receivedData->GetFormat() );
- }
-
- data->m_formatAtom = m_targetRequested;
-
- wxCHECK_MSG( m_targetRequested, FALSE, "unsupported clipboard format" );
-
m_formatSupported = FALSE;
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
GTK_SIGNAL_FUNC( selection_received ),
(gpointer) this );
+ /* this is a true error as we checked for the presence of such data before */
+
wxCHECK_MSG( m_formatSupported, FALSE, "error retrieving data from clipboard" );
return TRUE;
}
-GdkAtom wxClipboard::GetTargetAtom( wxDataFormat format, const wxString &id )
-{
- // What is X representation of that format?
-
- switch (format)
- {
- case wxDF_TEXT:
- {
- return GDK_TARGET_STRING;
- // g_textAtom
- }
-
- case wxDF_BITMAP:
- {
- return GDK_TARGET_BITMAP;
- break;
- }
-
- case wxDF_PRIVATE:
- {
- // we create our own X representation
-
- return gdk_atom_intern( WXSTRINGCAST( id ), FALSE );
- }
-
- default:
- {
- return (GdkAtom) 0;
- }
- }
-
- return (GdkAtom) 0;
-}
-
//-----------------------------------------------------------------------------
// wxClipboardModule
//-----------------------------------------------------------------------------
#include "wx/dataobj.h"
#include "wx/app.h"
+#include "wx/debug.h"
+
+#include "gdk/gdk.h"
+
+//-------------------------------------------------------------------------
+// wxDataFormat
+//-------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxDataFormat, wxObject)
+
+wxDataFormat::wxDataFormat( wxDataType type )
+{
+ m_type = type;
+
+ if (m_type == wxDF_TEXT)
+ {
+ m_id = "STRING";
+ }
+ else
+ if (m_type == wxDF_BITMAP)
+ {
+ m_id = "BITMAP";
+ }
+ else
+ if (m_type == wxDF_FILENAME)
+ {
+ m_id = "file:ALL";
+ }
+ else
+ {
+ wxFAIL_MSG( "invalid dataformat" )
+ }
+
+ m_hasAtom = FALSE;
+}
+
+wxDataFormat::wxDataFormat( const wxString &id )
+{
+ m_type = wxDF_PRIVATE;
+ m_id = id;
+ m_hasAtom = FALSE;
+}
+
+wxDataFormat::wxDataFormat( wxDataFormat &format )
+{
+ m_type = format.GetType();
+ m_id = format.GetId();
+ m_hasAtom = TRUE;
+ m_atom = format.GetAtom();
+}
+
+wxDataFormat::wxDataFormat( const GdkAtom atom )
+{
+ m_hasAtom = TRUE;
+
+ m_atom = atom;
+
+ if (m_atom == GDK_TARGET_STRING)
+ {
+ m_type = wxDF_TEXT;
+ } else
+ if (m_atom == GDK_TARGET_BITMAP)
+ {
+ m_type = wxDF_BITMAP;
+ } else
+ {
+ m_type = wxDF_PRIVATE;
+ m_id = gdk_atom_name( m_atom );
+
+ if (m_id == "file:ALL")
+ {
+ m_type = wxDF_FILENAME;
+ }
+ }
+}
+
+int wxDataFormat::GetType() const
+{
+ return m_type;
+}
+
+wxString wxDataFormat::GetId() const
+{
+ return m_id;
+}
+
+void wxDataFormat::SetId( const wxString &id )
+{
+ m_type = wxDF_PRIVATE;
+ m_id = id;
+ m_hasAtom = FALSE;
+}
+
+GdkAtom wxDataFormat::GetAtom()
+{
+ if (!m_hasAtom)
+ {
+ m_hasAtom = TRUE;
+
+ if (m_type == wxDF_TEXT)
+ {
+ m_atom = GDK_TARGET_STRING;
+ }
+ else
+ if (m_type == wxDF_BITMAP)
+ {
+ m_atom = GDK_TARGET_BITMAP;
+ }
+ else
+ if (m_type == wxDF_PRIVATE)
+ {
+ m_atom = gdk_atom_intern( WXSTRINGCAST( m_id ), FALSE );
+ }
+ else
+ if (m_type == wxDF_FILENAME)
+ {
+ m_atom = gdk_atom_intern( "file:ALL", FALSE );
+ }
+ else
+ {
+ m_hasAtom = FALSE;
+ m_atom = (GdkAtom) 0;
+ }
+ }
+
+ return m_atom;
+}
+
+//-------------------------------------------------------------------------
+// wxDataBroker
+//-------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxDataBroker,wxObject)
+
+wxDataBroker::wxDataBroker()
+{
+ m_dataObjects.DeleteContents(TRUE);
+ m_preferred = 0;
+}
+
+void wxDataBroker::Add( wxDataObject *dataObject, bool preferred )
+{
+ if (preferred) m_preferred = m_dataObjects.GetCount();
+ m_dataObjects.Append( dataObject );
+}
+
+size_t wxDataBroker::GetFormatCount() const
+{
+ return m_dataObjects.GetCount();
+}
+
+wxDataFormat &wxDataBroker::GetPreferredFormat() const
+{
+ wxNode *node = m_dataObjects.Nth( m_preferred );
+
+ wxASSERT( node );
+
+ wxDataObject* data_obj = (wxDataObject*)node->Data();
+
+ return data_obj->GetFormat();
+}
+
+wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
+{
+ wxNode *node = m_dataObjects.Nth( nth );
+
+ wxASSERT( node );
+
+ wxDataObject* data_obj = (wxDataObject*)node->Data();
+
+ return data_obj->GetFormat();
+}
+
+bool wxDataBroker::IsSupportedFormat( wxDataFormat &format ) const
+{
+ wxNode *node = m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ if (dobj->GetFormat().GetAtom() == format.GetAtom())
+ {
+ return TRUE;
+ }
+
+ node = node->Next();
+ }
+
+ return FALSE;
+}
+
+size_t wxDataBroker::GetSize( wxDataFormat& format ) const
+{
+ wxNode *node = m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ if (dobj->GetFormat().GetAtom() == format.GetAtom())
+ {
+ return dobj->GetSize();
+ }
+
+ node = node->Next();
+ }
+
+ return 0;
+}
+
+void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const
+{
+ wxNode *node = m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ if (dobj->GetFormat().GetAtom() == format.GetAtom())
+ {
+ return dobj->WriteData( dest );
+ }
+
+ node = node->Next();
+ }
+}
//-------------------------------------------------------------------------
// wxDataObject
IMPLEMENT_ABSTRACT_CLASS( wxDataObject, wxObject )
+wxDataObject::wxDataObject()
+{
+ m_format = (wxDataFormat*) NULL;
+}
+
+wxDataObject::~wxDataObject()
+{
+ if (m_format) delete m_format;
+}
+
+wxDataFormat &wxDataObject::GetFormat() const
+{
+ wxASSERT( m_format );
+
+ return (*m_format);
+}
+
// ----------------------------------------------------------------------------
// wxTextDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxTextDataObject, wxDataObject )
+wxTextDataObject::wxTextDataObject()
+{
+ m_format = new wxDataFormat( wxDF_TEXT );
+}
+
+wxTextDataObject::wxTextDataObject( const wxString& data )
+{
+ m_format = new wxDataFormat( wxDF_TEXT );
+
+ m_data = data;
+}
+
+void wxTextDataObject::SetText( const wxString& data )
+{
+ m_data = data;
+}
+
+wxString wxTextDataObject::GetText() const
+{
+ return m_data;
+}
+
+void wxTextDataObject::WriteData( void *dest ) const
+{
+ WriteString( m_data, dest );
+}
+
+size_t wxTextDataObject::GetSize() const
+{
+ return m_data.Len() + 1;
+}
+
+void wxTextDataObject::WriteString( const wxString &str, void *dest ) const
+{
+ memcpy( dest, m_data.c_str(), GetSize() );
+}
+
// ----------------------------------------------------------------------------
// wxFileDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxFileDataObject, wxDataObject )
+wxFileDataObject::wxFileDataObject(void)
+{
+ m_format = new wxDataFormat( wxDF_FILENAME );
+}
+
+void wxFileDataObject::AddFile( const wxString &file )
+{
+ m_files += file;
+ m_files += (char)0;
+}
+
+wxString wxFileDataObject::GetFiles() const
+{
+ return m_files;
+}
+
+void wxFileDataObject::WriteData( void *dest ) const
+{
+ memcpy( dest, m_files.c_str(), GetSize() );
+}
+
+size_t wxFileDataObject::GetSize() const
+{
+ return m_files.Len() + 1;
+}
+
// ----------------------------------------------------------------------------
// wxBitmapDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxBitmapDataObject, wxDataObject )
+wxBitmapDataObject::wxBitmapDataObject()
+{
+ m_format = new wxDataFormat( wxDF_BITMAP );
+}
+
+wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap )
+{
+ m_format = new wxDataFormat( wxDF_BITMAP );
+
+ m_bitmap = bitmap;
+}
+
+void wxBitmapDataObject::SetBitmap( const wxBitmap &bitmap )
+{
+ m_bitmap = bitmap;
+}
+
+wxBitmap wxBitmapDataObject::GetBitmap() const
+{
+ return m_bitmap;
+}
+
+void wxBitmapDataObject::WriteData( void *dest ) const
+{
+ WriteBitmap( m_bitmap, dest );
+}
+
+size_t wxBitmapDataObject::GetSize() const
+{
+ return 0;
+}
+
+void wxBitmapDataObject::WriteBitmap( const wxBitmap &bitmap, void *dest ) const
+{
+ memcpy( dest, m_bitmap.GetPixmap(), GetSize() );
+}
+
// ----------------------------------------------------------------------------
// wxPrivateDataObject
// ----------------------------------------------------------------------------
wxPrivateDataObject::wxPrivateDataObject()
{
+ m_id = "application/";
+ m_id += wxTheApp->GetAppName();
+
+ m_format = new wxDataFormat( m_id );
+
m_size = 0;
m_data = (char*) NULL;
- m_id = wxTheApp->GetAppName();
}
wxPrivateDataObject::~wxPrivateDataObject()
if (m_data) delete[] m_data;
}
+void wxPrivateDataObject::SetId( const wxString& id )
+{
+ m_id = id;
+ m_format->SetId( m_id );
+}
+
+wxString wxPrivateDataObject::GetId() const
+{
+ return m_id;
+}
+
void wxPrivateDataObject::SetData( const char *data, size_t size )
{
m_size = size;
memcpy( m_data, data, size );
}
+char* wxPrivateDataObject::GetData() const
+{
+ return m_data;
+}
+
+void wxPrivateDataObject::WriteData( void *dest ) const
+{
+ WriteData( m_data, dest );
+}
+
+size_t wxPrivateDataObject::GetSize() const
+{
+ return m_size;
+}
+
+void wxPrivateDataObject::WriteData( const char *data, void *dest ) const
+{
+ memcpy( dest, data, GetSize() );
+}
+
wxDialog::~wxDialog()
{
wxTopLevelWindows.DeleteObject( this );
- if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
+
+ if (wxTheApp->GetTopWindow() == this)
+ {
+ wxTheApp->SetTopWindow( (wxWindow*) NULL );
+ }
+
+ if (wxTopLevelWindows.Number() == 0)
+ {
+ wxTheApp->ExitMainLoop();
+ }
}
void wxDialog::SetTitle( const wxString& title )
break;
case wxDF_PRIVATE:
wxPrivateDropTarget *pdt = (wxPrivateDropTarget *)this;
- strcpy( buf, "applications/" );
- strcat( buf, WXSTRINGCAST pdt->GetID() );
+ strcpy( buf, WXSTRINGCAST pdt->GetID() );
format.target = buf;
valid++;
default:
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 )
for ( size_t i = 0; i < GetFormatCount(); i++ )
{
- wxDataFormat df = GetFormat( i );
- switch (df)
+ switch (GetFormat(i).GetType())
{
case wxDF_TEXT:
{
{
if (i > 0) formats += ";";
wxPrivateDropTarget *pdt = (wxPrivateDropTarget *)this;
- formats += "applications/";
formats += pdt->GetId();
valid++;
break;
// 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 1;
}
-wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
-{
- return wxDF_TEXT;
-}
-
// ----------------------------------------------------------------------------
// wxPrivateDropTarget
// ----------------------------------------------------------------------------
wxPrivateDropTarget::wxPrivateDropTarget()
{
m_id = wxTheApp->GetAppName();
+ m_format = new wxDataFormat( m_id );
}
-size_t wxPrivateDropTarget::GetFormatCount() const
+void wxPrivateDropTarget::SetId( const wxString& id )
{
- return 1;
+ m_id = id;
+ m_format->SetId( id );
}
-wxDataFormat wxPrivateDropTarget::GetFormat(size_t WXUNUSED(n)) const
+size_t wxPrivateDropTarget::GetFormatCount() const
{
- return wxDF_PRIVATE;
+ 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 );
return 1;
}
-wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
-{
- return wxDF_FILENAME;
-}
-
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
GdkEventMotion * /*event*/);
//-----------------------------------------------------------------------------
-// drag request
+// "drag_request_event"
+//-----------------------------------------------------------------------------
-void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source )
+void gtk_drag_callback( GtkWidget *widget, GdkEventDragRequest *event, wxDropSource *source )
{
- wxDataObject *data = source->m_data;
-
- switch (data->GetFormat())
+ wxDataBroker *data = source->m_data;
+
+ if (!data) return;
+
+ wxNode *node = data->m_dataObjects.First();
{
- case wxDF_PRIVATE:
- {
- wxPrivateDataObject *pdo = (wxPrivateDataObject*) data;
-
- gtk_widget_dnd_data_set( widget,
- event,
- (unsigned char*) pdo->GetData(),
- (int) pdo->GetDataSize() );
-
- break;
- }
- case wxDF_TEXT:
+ wxDataObject *dobj = (wxDataObject*) node->Data();
+
+ if ((strcmp(event->data_type,"file:ALL") == 0) &&
+ (dobj->GetFormat().GetType() == wxDF_FILENAME))
{
- wxTextDataObject *text_object = (wxTextDataObject*) data;
+ wxFileDataObject *file_object = (wxFileDataObject*) dobj;
- wxString text = text_object->GetText();
+ wxString text = file_object->GetFiles();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
- event,
+ (GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
- break;
+ source->m_retValue = wxDragCopy;
+
+ return;
}
- case wxDF_FILENAME:
+ if ((strcmp(event->data_type,"text/plain") == 0) &&
+ (dobj->GetFormat().GetType() == wxDF_TEXT))
{
- wxFileDataObject *file_object = (wxFileDataObject*) data;
+ wxTextDataObject *text_object = (wxTextDataObject*) dobj;
- wxString text = file_object->GetFiles();
+ wxString text = text_object->GetText();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
- event,
+ (GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
- break;
+ source->m_retValue = wxDragCopy;
+
+ return;
}
- default:
+ if (dobj->GetFormat().GetType() == wxDF_PRIVATE)
{
- return;
+ 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();
}
-
- source->m_retValue = wxDragCopy;
}
wxDropSource::wxDropSource( wxWindow *win )
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
- m_data = (wxDataObject *) NULL;
+ m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}
-wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
+wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
- m_data = &data;
+ 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 );
}
-void wxDropSource::SetData( wxDataObject &data )
+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 )
{
- m_data = &data;
+ if (m_data) delete m_data;
+
+ m_data = data;
}
wxDropSource::~wxDropSource(void)
{
-// if (m_data) delete m_data;
+ if (m_data) delete m_data;
g_blockEventsOnDrag = FALSE;
}
wxString formats;
- wxDataFormat df = m_data->GetFormat();
-
- switch (df)
+ wxNode *node = m_data->m_dataObjects.First();
+ while (node)
{
- case wxDF_TEXT:
- {
- formats += "text/plain";
- break;
- }
- case wxDF_FILENAME:
- {
- formats += "file:ALL";
- break;
- }
- case wxDF_PRIVATE:
- {
- wxPrivateDataObject* pdo = (wxPrivateDataObject*) m_data;
- formats += "applications/";
- formats += pdo->GetId();
- break;
+ 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;
}
- default:
- break;
+ node = node->Next();
}
char *str = WXSTRINGCAST formats;
if (m_frameToolBar) delete m_frameToolBar;
wxTopLevelWindows.DeleteObject( this );
- if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
+
+ if (wxTheApp->GetTopWindow() == this)
+ {
+ wxTheApp->SetTopWindow( (wxWindow*) NULL );
+ }
+
+ if (wxTopLevelWindows.Number() == 0)
+ {
+ wxTheApp->ExitMainLoop();
+ }
}
bool wxFrame::Show( bool show )
#include "wx/memory.h"
#include "wx/font.h"
#include "wx/settings.h"
+#include "wx/dialog.h"
#if wxUSE_WX_RESOURCES
#include "wx/resource.h"
#endif
wxApp::wxApp()
{
- m_idleTag = 0;
+ wxTheApp = this;
+
m_topWindow = (wxWindow *) NULL;
m_exitOnFrameDelete = TRUE;
+
+ m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
+
m_colorCube = (unsigned char*) NULL;
- wxTheApp = this;
}
wxApp::~wxApp(void)
if (m_colorCube) free(m_colorCube);
}
-bool wxApp::InitVisual()
+bool wxApp::OnInitGui()
{
/* Nothing to do for 15, 16, 24, 32 bit displays */
GdkVisual *visual = gdk_visual_get_system();
if (visual->depth > 8) return TRUE;
-
- /* this initiates the standard palette as defined by GdkImlib
- in the GNOME libraries. it ensures that all GNOME applications
- use the same 64 colormap entries on 8-bit displays so you
- can use several rather graphics-heavy applications at the
- same time */
- /*
- GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
+ /* this initiates the standard palette as defined by GdkImlib
+ in the GNOME libraries. it ensures that all GNOME applications
+ use the same 64 colormap entries on 8-bit displays so you
+ can use several rather graphics-heavy applications at the
+ same time.
+ NOTE: this doesn't really seem to work this way... */
- for (int i = 0; i < 64; i++)
- {
- GdkColor col;
- col.red = g_palette[i*3 + 0] << 8;
- col.green = g_palette[i*3 + 1] << 8;
- col.blue = g_palette[i*3 + 2] << 8;
- col.pixel = 0;
+ /*
+ GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
- gdk_color_alloc( cmap, &col );
- }
+ for (int i = 0; i < 64; i++)
+ {
+ GdkColor col;
+ col.red = g_palette[i*3 + 0] << 8;
+ col.green = g_palette[i*3 + 1] << 8;
+ col.blue = g_palette[i*3 + 2] << 8;
+ col.pixel = 0;
+
+ gdk_color_alloc( cmap, &col );
+ }
- gtk_widget_set_default_colormap( cmap );
- */
+ gtk_widget_set_default_colormap( cmap );
+ */
/* initialize color cube for 8-bit color reduction dithering */
}
}
}
-
- return TRUE;
-}
-bool wxApp::OnInitGui(void)
-{
- m_idleTag = gtk_idle_add( wxapp_idle_callback, NULL );
return TRUE;
}
-bool wxApp::OnInit(void)
-{
- return TRUE;
-}
-
-int wxApp::OnRun(void)
-{
- return MainLoop();
-}
-
bool wxApp::ProcessIdle(void)
{
wxIdleEvent event;
return needMore ;
}
-int wxApp::OnExit(void)
-{
- return 0;
-}
-
int wxApp::MainLoop(void)
{
gtk_main();
m_topWindow = win;
}
-void wxApp::CommonInit(void)
+bool wxApp::Initialize(void)
{
- wxSystemSettings::Init();
+ wxBuffer = new char[BUFSIZ + 512];
+
+ wxClassInfo::InitializeClasses();
+
+ wxSystemSettings::Init();
- wxTheFontNameDirectory = new wxFontNameDirectory;
- wxTheFontNameDirectory->Initialize();
+ wxTheFontNameDirectory = new wxFontNameDirectory;
+ wxTheFontNameDirectory->Initialize();
- wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
- wxTheColourDatabase->Initialize();
+ wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
+ wxTheColourDatabase->Initialize();
- wxInitializeStockLists();
- wxInitializeStockObjects();
+ wxInitializeStockLists();
+ wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES
- wxTheResourceCache = new wxResourceCache(wxKEY_STRING);
+ wxTheResourceCache = new wxResourceCache( wxKEY_STRING );
- wxInitializeResourceSystem();
+ wxInitializeResourceSystem();
#endif
- wxImage::InitStandardHandlers();
+ wxImage::InitStandardHandlers();
-// g_globalCursor = new wxCursor;
+ /* no global cursor under X
+ g_globalCursor = new wxCursor; */
+
+ wxModule::RegisterModules();
+ if (!wxModule::InitializeModules()) return FALSE;
+
+ return TRUE;
}
-void wxApp::CommonCleanUp(void)
+void wxApp::CleanUp(void)
{
- if (wxTheColourDatabase) delete wxTheColourDatabase;
- wxTheColourDatabase = (wxColourDatabase*) NULL;
-
- if (wxTheFontNameDirectory) delete wxTheFontNameDirectory;
- wxTheFontNameDirectory = (wxFontNameDirectory*) NULL;
-
- wxDeleteStockObjects();
+ wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES
wxFlushResources();
wxCleanUpResourceSystem();
#endif
+ if (wxTheColourDatabase) delete wxTheColourDatabase;
+ wxTheColourDatabase = (wxColourDatabase*) NULL;
+
+ if (wxTheFontNameDirectory) delete wxTheFontNameDirectory;
+ wxTheFontNameDirectory = (wxFontNameDirectory*) NULL;
+
+ wxDeleteStockObjects();
+
wxDeleteStockLists();
wxImage::CleanUpHandlers();
+ delete wxTheApp;
+ wxTheApp = (wxApp*) NULL;
+
+ /* check for memory leaks */
+#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
+ if (wxDebugContext::CountObjectsLeft() > 0)
+ {
+ wxLogDebug("There were memory leaks.\n");
+ wxDebugContext::Dump();
+ wxDebugContext::PrintStatistics();
+ }
+#endif
+
+ /* do this as the very last thing because everything else can log messages */
+ wxLog::DontCreateOnDemand();
+
+ wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
+ if (oldLog) delete oldLog;
+
wxSystemSettings::Done();
+
+ wxClassInfo::CleanUpClasses();
+
+ delete[] wxBuffer;
}
wxLog *wxApp::CreateLogTarget()
{
- return new wxLogGui;
+ return new wxLogGui;
}
//-----------------------------------------------------------------------------
int wxEntry( int argc, char *argv[] )
{
- wxBuffer = new char[BUFSIZ + 512];
+ gtk_set_locale();
- wxClassInfo::InitializeClasses();
+ gtk_init( &argc, &argv );
+ if (!wxApp::Initialize()) return 0;
if (!wxTheApp)
{
wxStripExtension( name );
wxTheApp->SetAppName( name );
- gtk_set_locale();
-
- gtk_init( &argc, &argv );
-
- if (!wxTheApp->InitVisual()) return 0;
-
- wxApp::CommonInit();
-
if (!wxTheApp->OnInitGui()) return 0;
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules()) return FALSE;
-
- // Here frames insert themselves automatically
- // into wxTopLevelWindows by getting created
- // in OnInit().
+ /* Here frames insert themselves automatically
+ * into wxTopLevelWindows by getting created
+ * in OnInit(). */
if (!wxTheApp->OnInit()) return 0;
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
- wxTheApp->DeletePendingObjects();
-
- wxTheApp->OnExit();
-
- wxModule::CleanUpModules();
-
- wxApp::CommonCleanUp();
-
- delete wxTheApp;
- wxTheApp = (wxApp*) NULL;
-
- wxClassInfo::CleanUpClasses();
-
- delete[] wxBuffer;
-
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
-
- if (wxDebugContext::CountObjectsLeft() > 0)
+ wxWindow *topWindow = wxTheApp->GetTopWindow();
+ if (topWindow)
{
- wxLogDebug("There were memory leaks.\n");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
+ /* Forcibly delete the window. */
+ if (topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
+ topWindow->IsKindOf(CLASSINFO(wxDialog)) )
+ {
+ topWindow->Close( TRUE );
+ wxTheApp->DeletePendingObjects();
+ }
+ else
+ {
+ delete topWindow;
+ wxTheApp->SetTopWindow( (wxWindow*) NULL );
+ }
}
-#endif
+ wxTheApp->OnExit();
- wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
- if (oldLog) delete oldLog;
+ /* flush the logged messages if any */
+ wxLog *log = wxLog::GetActiveTarget();
+ if (log != NULL && log->HasPendingMessages())
+ log->Flush();
+
+ wxApp::CleanUp();
return retValue;
}
// make sure we got the data in the correct format
- if (data_object->m_formatAtom != selection_data->target) return;
+ if (data_object->GetFormat().GetAtom() != selection_data->target) return;
// make sure we got the data in the correct form (selection type).
// if so, copy data to target object
- switch (data_object->GetFormat())
+ switch (data_object->GetFormat().GetType())
{
case wxDF_TEXT:
{
if ((!wxTheClipboard->m_ownsPrimarySelection) &&
(!wxTheClipboard->m_ownsClipboard))
{
- // the clipboard is no longer in our hands. we can the
- // clipboard data.
-
- wxTheClipboard->m_dataObjects.Clear();
+ /* the clipboard is no longer in our hands. we can the clipboard data. */
+
+ if (wxTheClipboard->m_dataBroker)
+ {
+ delete wxTheClipboard->m_dataBroker;
+ wxTheClipboard->m_dataBroker = (wxDataBroker*) NULL;
+ }
}
return TRUE;
{
if (!wxTheClipboard) return;
- wxNode *node = wxTheClipboard->m_dataObjects.First();
+ if (!wxTheClipboard->m_dataBroker) return;
+
+ wxNode *node = wxTheClipboard->m_dataBroker->m_dataObjects.First();
while (node)
{
wxDataObject *data_object = (wxDataObject *)node->Data();
- if (data_object->m_formatAtom != selection_data->target)
+ if (data_object->GetFormat().GetAtom() != selection_data->target)
{
node = node->Next();
break;
}
- switch (data_object->GetFormat())
+ switch (data_object->GetFormat().GetType())
{
case wxDF_TEXT:
{
{
wxPrivateDataObject *private_object = (wxPrivateDataObject*) data_object;
- if (private_object->GetDataSize() == 0) return;
+ if (private_object->GetSize() == 0) return;
gtk_selection_data_set(
selection_data,
GDK_SELECTION_TYPE_STRING,
8*sizeof(gchar),
(unsigned char*) private_object->GetData(),
- (int) private_object->GetDataSize() );
+ (int) private_object->GetSize() );
}
default:
m_ownsClipboard = FALSE;
m_ownsPrimarySelection = FALSE;
- m_dataObjects.DeleteContents( TRUE );
+ m_dataBroker = (wxDataBroker*) NULL;
m_receivedData = (wxDataObject*) NULL;
void wxClipboard::Clear()
{
- if (m_dataObjects.GetCount())
+ if (m_dataBroker)
{
/* As we have data we also own the clipboard. Once we no longer own
it, clear_selection is called which will set m_data to zero */
gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME );
}
- m_dataObjects.Clear();
+ if (m_dataBroker)
+ {
+ delete m_dataBroker;
+ m_dataBroker = (wxDataBroker*) NULL;
+ }
}
m_targetRequested = 0;
return TRUE;
}
-bool wxClipboard::SetData( wxDataObject *data )
+bool wxClipboard::SetData( wxDataBroker *data )
{
wxCHECK_MSG( data, FALSE, "data is invalid" );
- wxNode *node = m_dataObjects.First();
-
- while (node)
- {
- wxDataObject *d = (wxDataObject*)node->Data();
-
- if (d->GetFormat() == data->GetFormat())
- {
- m_dataObjects.DeleteNode( node );
-
- break;
- }
-
- node = node->Next();
- }
+ Clear();
+
+ m_dataBroker = data;
- m_dataObjects.Append( data );
+ if (!m_dataBroker) return FALSE;
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
- if (data->GetFormat() == wxDF_PRIVATE)
+ wxNode *node = m_dataBroker->m_dataObjects.First();
+ while (node)
{
- wxPrivateDataObject* pd = (wxPrivateDataObject*) data;
+ wxDataObject *dobj = (wxDataObject*)node->Data();
- wxCHECK_MSG( !pd->GetId().IsEmpty(), FALSE, "private clipboard format requires ID string" );
+ GdkAtom format = dobj->GetFormat().GetAtom();
- data->m_formatAtom = GetTargetAtom( data->GetFormat(), pd->GetId() );
- }
- else
- {
- data->m_formatAtom = GetTargetAtom( data->GetFormat() );
- }
-
- // This should happen automatically
+ if (format != (GdkAtom) 0)
+ {
+ /* This should happen automatically */
- m_ownsClipboard = FALSE;
- m_ownsPrimarySelection = FALSE;
+ m_ownsClipboard = FALSE;
+ m_ownsPrimarySelection = FALSE;
- // Add handlers if someone requests data
+ /* Add handlers if someone requests data */
- gtk_selection_add_handler( m_clipboardWidget,
+ gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
- data->m_formatAtom,
+ format,
selection_handler,
- NULL );
+ (gpointer) NULL );
- gtk_selection_add_handler( m_clipboardWidget,
+ gtk_selection_add_handler( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
- data->m_formatAtom,
+ format,
selection_handler,
- NULL );
+ (gpointer) NULL );
- // Tell the world we offer clipboard data
+ /* Tell the world we offer clipboard data */
- if (!gtk_selection_owner_set( m_clipboardWidget,
+ if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
GDK_CURRENT_TIME ))
- {
- return FALSE;
- }
- m_ownsClipboard = TRUE;
+ {
+ return FALSE;
+ }
+ m_ownsClipboard = TRUE;
- if (!gtk_selection_owner_set( m_clipboardWidget,
+ if (!gtk_selection_owner_set( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME ))
- {
- return FALSE;
+ {
+ return FALSE;
+ }
+ m_ownsPrimarySelection = TRUE;
+ }
+
+ node = node->Next();
}
- m_ownsPrimarySelection = TRUE;
return TRUE;
}
m_open = FALSE;
}
-bool wxClipboard::IsSupportedFormat( wxDataFormat format, const wxString &id )
+bool wxClipboard::GetData( wxDataObject *data )
{
- m_targetRequested = GetTargetAtom( format, id );
+ wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
+
+ m_receivedData = data;
+
+ wxCHECK_MSG( m_receivedData, FALSE, "invalid data object" );
+
+ /* STEP ONE: check if there is such data in the clipboard */
+
+ m_targetRequested = data->GetFormat().GetAtom();
+ wxCHECK_MSG( m_targetRequested, FALSE, "invalid clipboard format" );
+
if (m_targetRequested == 0) return FALSE;
- // add handler for target (= format) query
+ /* add handler for target (= format) query */
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_received",
m_formatSupported = FALSE;
- // perform query. this will set m_formatSupported to
- // TRUE if m_targetRequested is supported
+ /* perform query. this will set m_formatSupported to
+ * TRUE if m_targetRequested is supported */
gtk_selection_convert( m_clipboardWidget,
g_clipboardAtom,
if (!m_formatSupported) return FALSE;
- return TRUE;
-}
-
-bool wxClipboard::GetData( wxDataObject *data )
-{
- wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
-
- m_receivedData = data;
-
- wxCHECK_MSG( m_receivedData, FALSE, "invalid data object" );
+ /* STEP TWO: get the data from the clipboard */
- if (m_receivedData->GetFormat() == wxDF_PRIVATE)
- {
- wxPrivateDataObject* pd = (wxPrivateDataObject*) m_receivedData;
-
- wxCHECK_MSG( !pd->GetId().IsEmpty(), FALSE, "private clipboard format requires ID string" );
-
- m_targetRequested = GetTargetAtom( m_receivedData->GetFormat(), pd->GetId() );
- }
- else
- {
- m_targetRequested = GetTargetAtom( m_receivedData->GetFormat() );
- }
-
- data->m_formatAtom = m_targetRequested;
-
- wxCHECK_MSG( m_targetRequested, FALSE, "unsupported clipboard format" );
-
m_formatSupported = FALSE;
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
GTK_SIGNAL_FUNC( selection_received ),
(gpointer) this );
+ /* this is a true error as we checked for the presence of such data before */
+
wxCHECK_MSG( m_formatSupported, FALSE, "error retrieving data from clipboard" );
return TRUE;
}
-GdkAtom wxClipboard::GetTargetAtom( wxDataFormat format, const wxString &id )
-{
- // What is X representation of that format?
-
- switch (format)
- {
- case wxDF_TEXT:
- {
- return GDK_TARGET_STRING;
- // g_textAtom
- }
-
- case wxDF_BITMAP:
- {
- return GDK_TARGET_BITMAP;
- break;
- }
-
- case wxDF_PRIVATE:
- {
- // we create our own X representation
-
- return gdk_atom_intern( WXSTRINGCAST( id ), FALSE );
- }
-
- default:
- {
- return (GdkAtom) 0;
- }
- }
-
- return (GdkAtom) 0;
-}
-
//-----------------------------------------------------------------------------
// wxClipboardModule
//-----------------------------------------------------------------------------
#include "wx/dataobj.h"
#include "wx/app.h"
+#include "wx/debug.h"
+
+#include "gdk/gdk.h"
+
+//-------------------------------------------------------------------------
+// wxDataFormat
+//-------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxDataFormat, wxObject)
+
+wxDataFormat::wxDataFormat( wxDataType type )
+{
+ m_type = type;
+
+ if (m_type == wxDF_TEXT)
+ {
+ m_id = "STRING";
+ }
+ else
+ if (m_type == wxDF_BITMAP)
+ {
+ m_id = "BITMAP";
+ }
+ else
+ if (m_type == wxDF_FILENAME)
+ {
+ m_id = "file:ALL";
+ }
+ else
+ {
+ wxFAIL_MSG( "invalid dataformat" )
+ }
+
+ m_hasAtom = FALSE;
+}
+
+wxDataFormat::wxDataFormat( const wxString &id )
+{
+ m_type = wxDF_PRIVATE;
+ m_id = id;
+ m_hasAtom = FALSE;
+}
+
+wxDataFormat::wxDataFormat( wxDataFormat &format )
+{
+ m_type = format.GetType();
+ m_id = format.GetId();
+ m_hasAtom = TRUE;
+ m_atom = format.GetAtom();
+}
+
+wxDataFormat::wxDataFormat( const GdkAtom atom )
+{
+ m_hasAtom = TRUE;
+
+ m_atom = atom;
+
+ if (m_atom == GDK_TARGET_STRING)
+ {
+ m_type = wxDF_TEXT;
+ } else
+ if (m_atom == GDK_TARGET_BITMAP)
+ {
+ m_type = wxDF_BITMAP;
+ } else
+ {
+ m_type = wxDF_PRIVATE;
+ m_id = gdk_atom_name( m_atom );
+
+ if (m_id == "file:ALL")
+ {
+ m_type = wxDF_FILENAME;
+ }
+ }
+}
+
+int wxDataFormat::GetType() const
+{
+ return m_type;
+}
+
+wxString wxDataFormat::GetId() const
+{
+ return m_id;
+}
+
+void wxDataFormat::SetId( const wxString &id )
+{
+ m_type = wxDF_PRIVATE;
+ m_id = id;
+ m_hasAtom = FALSE;
+}
+
+GdkAtom wxDataFormat::GetAtom()
+{
+ if (!m_hasAtom)
+ {
+ m_hasAtom = TRUE;
+
+ if (m_type == wxDF_TEXT)
+ {
+ m_atom = GDK_TARGET_STRING;
+ }
+ else
+ if (m_type == wxDF_BITMAP)
+ {
+ m_atom = GDK_TARGET_BITMAP;
+ }
+ else
+ if (m_type == wxDF_PRIVATE)
+ {
+ m_atom = gdk_atom_intern( WXSTRINGCAST( m_id ), FALSE );
+ }
+ else
+ if (m_type == wxDF_FILENAME)
+ {
+ m_atom = gdk_atom_intern( "file:ALL", FALSE );
+ }
+ else
+ {
+ m_hasAtom = FALSE;
+ m_atom = (GdkAtom) 0;
+ }
+ }
+
+ return m_atom;
+}
+
+//-------------------------------------------------------------------------
+// wxDataBroker
+//-------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxDataBroker,wxObject)
+
+wxDataBroker::wxDataBroker()
+{
+ m_dataObjects.DeleteContents(TRUE);
+ m_preferred = 0;
+}
+
+void wxDataBroker::Add( wxDataObject *dataObject, bool preferred )
+{
+ if (preferred) m_preferred = m_dataObjects.GetCount();
+ m_dataObjects.Append( dataObject );
+}
+
+size_t wxDataBroker::GetFormatCount() const
+{
+ return m_dataObjects.GetCount();
+}
+
+wxDataFormat &wxDataBroker::GetPreferredFormat() const
+{
+ wxNode *node = m_dataObjects.Nth( m_preferred );
+
+ wxASSERT( node );
+
+ wxDataObject* data_obj = (wxDataObject*)node->Data();
+
+ return data_obj->GetFormat();
+}
+
+wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
+{
+ wxNode *node = m_dataObjects.Nth( nth );
+
+ wxASSERT( node );
+
+ wxDataObject* data_obj = (wxDataObject*)node->Data();
+
+ return data_obj->GetFormat();
+}
+
+bool wxDataBroker::IsSupportedFormat( wxDataFormat &format ) const
+{
+ wxNode *node = m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ if (dobj->GetFormat().GetAtom() == format.GetAtom())
+ {
+ return TRUE;
+ }
+
+ node = node->Next();
+ }
+
+ return FALSE;
+}
+
+size_t wxDataBroker::GetSize( wxDataFormat& format ) const
+{
+ wxNode *node = m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ if (dobj->GetFormat().GetAtom() == format.GetAtom())
+ {
+ return dobj->GetSize();
+ }
+
+ node = node->Next();
+ }
+
+ return 0;
+}
+
+void wxDataBroker::WriteData( wxDataFormat& format, void *dest ) const
+{
+ wxNode *node = m_dataObjects.First();
+ while (node)
+ {
+ wxDataObject *dobj = (wxDataObject*)node->Data();
+
+ if (dobj->GetFormat().GetAtom() == format.GetAtom())
+ {
+ return dobj->WriteData( dest );
+ }
+
+ node = node->Next();
+ }
+}
//-------------------------------------------------------------------------
// wxDataObject
IMPLEMENT_ABSTRACT_CLASS( wxDataObject, wxObject )
+wxDataObject::wxDataObject()
+{
+ m_format = (wxDataFormat*) NULL;
+}
+
+wxDataObject::~wxDataObject()
+{
+ if (m_format) delete m_format;
+}
+
+wxDataFormat &wxDataObject::GetFormat() const
+{
+ wxASSERT( m_format );
+
+ return (*m_format);
+}
+
// ----------------------------------------------------------------------------
// wxTextDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxTextDataObject, wxDataObject )
+wxTextDataObject::wxTextDataObject()
+{
+ m_format = new wxDataFormat( wxDF_TEXT );
+}
+
+wxTextDataObject::wxTextDataObject( const wxString& data )
+{
+ m_format = new wxDataFormat( wxDF_TEXT );
+
+ m_data = data;
+}
+
+void wxTextDataObject::SetText( const wxString& data )
+{
+ m_data = data;
+}
+
+wxString wxTextDataObject::GetText() const
+{
+ return m_data;
+}
+
+void wxTextDataObject::WriteData( void *dest ) const
+{
+ WriteString( m_data, dest );
+}
+
+size_t wxTextDataObject::GetSize() const
+{
+ return m_data.Len() + 1;
+}
+
+void wxTextDataObject::WriteString( const wxString &str, void *dest ) const
+{
+ memcpy( dest, m_data.c_str(), GetSize() );
+}
+
// ----------------------------------------------------------------------------
// wxFileDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxFileDataObject, wxDataObject )
+wxFileDataObject::wxFileDataObject(void)
+{
+ m_format = new wxDataFormat( wxDF_FILENAME );
+}
+
+void wxFileDataObject::AddFile( const wxString &file )
+{
+ m_files += file;
+ m_files += (char)0;
+}
+
+wxString wxFileDataObject::GetFiles() const
+{
+ return m_files;
+}
+
+void wxFileDataObject::WriteData( void *dest ) const
+{
+ memcpy( dest, m_files.c_str(), GetSize() );
+}
+
+size_t wxFileDataObject::GetSize() const
+{
+ return m_files.Len() + 1;
+}
+
// ----------------------------------------------------------------------------
// wxBitmapDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxBitmapDataObject, wxDataObject )
+wxBitmapDataObject::wxBitmapDataObject()
+{
+ m_format = new wxDataFormat( wxDF_BITMAP );
+}
+
+wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap )
+{
+ m_format = new wxDataFormat( wxDF_BITMAP );
+
+ m_bitmap = bitmap;
+}
+
+void wxBitmapDataObject::SetBitmap( const wxBitmap &bitmap )
+{
+ m_bitmap = bitmap;
+}
+
+wxBitmap wxBitmapDataObject::GetBitmap() const
+{
+ return m_bitmap;
+}
+
+void wxBitmapDataObject::WriteData( void *dest ) const
+{
+ WriteBitmap( m_bitmap, dest );
+}
+
+size_t wxBitmapDataObject::GetSize() const
+{
+ return 0;
+}
+
+void wxBitmapDataObject::WriteBitmap( const wxBitmap &bitmap, void *dest ) const
+{
+ memcpy( dest, m_bitmap.GetPixmap(), GetSize() );
+}
+
// ----------------------------------------------------------------------------
// wxPrivateDataObject
// ----------------------------------------------------------------------------
wxPrivateDataObject::wxPrivateDataObject()
{
+ m_id = "application/";
+ m_id += wxTheApp->GetAppName();
+
+ m_format = new wxDataFormat( m_id );
+
m_size = 0;
m_data = (char*) NULL;
- m_id = wxTheApp->GetAppName();
}
wxPrivateDataObject::~wxPrivateDataObject()
if (m_data) delete[] m_data;
}
+void wxPrivateDataObject::SetId( const wxString& id )
+{
+ m_id = id;
+ m_format->SetId( m_id );
+}
+
+wxString wxPrivateDataObject::GetId() const
+{
+ return m_id;
+}
+
void wxPrivateDataObject::SetData( const char *data, size_t size )
{
m_size = size;
memcpy( m_data, data, size );
}
+char* wxPrivateDataObject::GetData() const
+{
+ return m_data;
+}
+
+void wxPrivateDataObject::WriteData( void *dest ) const
+{
+ WriteData( m_data, dest );
+}
+
+size_t wxPrivateDataObject::GetSize() const
+{
+ return m_size;
+}
+
+void wxPrivateDataObject::WriteData( const char *data, void *dest ) const
+{
+ memcpy( dest, data, GetSize() );
+}
+
wxDialog::~wxDialog()
{
wxTopLevelWindows.DeleteObject( this );
- if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
+
+ if (wxTheApp->GetTopWindow() == this)
+ {
+ wxTheApp->SetTopWindow( (wxWindow*) NULL );
+ }
+
+ if (wxTopLevelWindows.Number() == 0)
+ {
+ wxTheApp->ExitMainLoop();
+ }
}
void wxDialog::SetTitle( const wxString& title )
break;
case wxDF_PRIVATE:
wxPrivateDropTarget *pdt = (wxPrivateDropTarget *)this;
- strcpy( buf, "applications/" );
- strcat( buf, WXSTRINGCAST pdt->GetID() );
+ strcpy( buf, WXSTRINGCAST pdt->GetID() );
format.target = buf;
valid++;
default:
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 )
for ( size_t i = 0; i < GetFormatCount(); i++ )
{
- wxDataFormat df = GetFormat( i );
- switch (df)
+ switch (GetFormat(i).GetType())
{
case wxDF_TEXT:
{
{
if (i > 0) formats += ";";
wxPrivateDropTarget *pdt = (wxPrivateDropTarget *)this;
- formats += "applications/";
formats += pdt->GetId();
valid++;
break;
// 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 1;
}
-wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
-{
- return wxDF_TEXT;
-}
-
// ----------------------------------------------------------------------------
// wxPrivateDropTarget
// ----------------------------------------------------------------------------
wxPrivateDropTarget::wxPrivateDropTarget()
{
m_id = wxTheApp->GetAppName();
+ m_format = new wxDataFormat( m_id );
}
-size_t wxPrivateDropTarget::GetFormatCount() const
+void wxPrivateDropTarget::SetId( const wxString& id )
{
- return 1;
+ m_id = id;
+ m_format->SetId( id );
}
-wxDataFormat wxPrivateDropTarget::GetFormat(size_t WXUNUSED(n)) const
+size_t wxPrivateDropTarget::GetFormatCount() const
{
- return wxDF_PRIVATE;
+ 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 );
return 1;
}
-wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
-{
- return wxDF_FILENAME;
-}
-
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
GdkEventMotion * /*event*/);
//-----------------------------------------------------------------------------
-// drag request
+// "drag_request_event"
+//-----------------------------------------------------------------------------
-void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source )
+void gtk_drag_callback( GtkWidget *widget, GdkEventDragRequest *event, wxDropSource *source )
{
- wxDataObject *data = source->m_data;
-
- switch (data->GetFormat())
+ wxDataBroker *data = source->m_data;
+
+ if (!data) return;
+
+ wxNode *node = data->m_dataObjects.First();
{
- case wxDF_PRIVATE:
- {
- wxPrivateDataObject *pdo = (wxPrivateDataObject*) data;
-
- gtk_widget_dnd_data_set( widget,
- event,
- (unsigned char*) pdo->GetData(),
- (int) pdo->GetDataSize() );
-
- break;
- }
- case wxDF_TEXT:
+ wxDataObject *dobj = (wxDataObject*) node->Data();
+
+ if ((strcmp(event->data_type,"file:ALL") == 0) &&
+ (dobj->GetFormat().GetType() == wxDF_FILENAME))
{
- wxTextDataObject *text_object = (wxTextDataObject*) data;
+ wxFileDataObject *file_object = (wxFileDataObject*) dobj;
- wxString text = text_object->GetText();
+ wxString text = file_object->GetFiles();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
- event,
+ (GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
- break;
+ source->m_retValue = wxDragCopy;
+
+ return;
}
- case wxDF_FILENAME:
+ if ((strcmp(event->data_type,"text/plain") == 0) &&
+ (dobj->GetFormat().GetType() == wxDF_TEXT))
{
- wxFileDataObject *file_object = (wxFileDataObject*) data;
+ wxTextDataObject *text_object = (wxTextDataObject*) dobj;
- wxString text = file_object->GetFiles();
+ wxString text = text_object->GetText();
char *s = WXSTRINGCAST text;
gtk_widget_dnd_data_set( widget,
- event,
+ (GdkEvent*)event,
(unsigned char*) s,
(int) text.Length()+1 );
- break;
+ source->m_retValue = wxDragCopy;
+
+ return;
}
- default:
+ if (dobj->GetFormat().GetType() == wxDF_PRIVATE)
{
- return;
+ 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();
}
-
- source->m_retValue = wxDragCopy;
}
wxDropSource::wxDropSource( wxWindow *win )
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
- m_data = (wxDataObject *) NULL;
+ m_data = (wxDataBroker*) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}
-wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
+wxDropSource::wxDropSource( wxDataObject *data, wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
- m_data = &data;
+ 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 );
}
-void wxDropSource::SetData( wxDataObject &data )
+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 )
{
- m_data = &data;
+ if (m_data) delete m_data;
+
+ m_data = data;
}
wxDropSource::~wxDropSource(void)
{
-// if (m_data) delete m_data;
+ if (m_data) delete m_data;
g_blockEventsOnDrag = FALSE;
}
wxString formats;
- wxDataFormat df = m_data->GetFormat();
-
- switch (df)
+ wxNode *node = m_data->m_dataObjects.First();
+ while (node)
{
- case wxDF_TEXT:
- {
- formats += "text/plain";
- break;
- }
- case wxDF_FILENAME:
- {
- formats += "file:ALL";
- break;
- }
- case wxDF_PRIVATE:
- {
- wxPrivateDataObject* pdo = (wxPrivateDataObject*) m_data;
- formats += "applications/";
- formats += pdo->GetId();
- break;
+ 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;
}
- default:
- break;
+ node = node->Next();
}
char *str = WXSTRINGCAST formats;
if (m_frameToolBar) delete m_frameToolBar;
wxTopLevelWindows.DeleteObject( this );
- if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
+
+ if (wxTheApp->GetTopWindow() == this)
+ {
+ wxTheApp->SetTopWindow( (wxWindow*) NULL );
+ }
+
+ if (wxTopLevelWindows.Number() == 0)
+ {
+ wxTheApp->ExitMainLoop();
+ }
}
bool wxFrame::Show( bool show )
return (DdeDisconnect((HCONV) m_hConv) != 0);
}
-bool wxDDEConnection::Execute(char *data, int size, wxDataFormat format)
+bool wxDDEConnection::Execute(char *data, int size, wxIPCFormat format)
{
DWORD result;
if (size < 0)
NULL, format, XTYP_EXECUTE, 5000, &result) ? TRUE : FALSE);
}
-char *wxDDEConnection::Request(const wxString& item, int *size, wxDataFormat format)
+char *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat format)
{
DWORD result;
HSZ atom = DDEGetAtom(item);
else return NULL;
}
-bool wxDDEConnection::Poke(const wxString& item, char *data, int size, wxDataFormat format)
+bool wxDDEConnection::Poke(const wxString& item, char *data, int size, wxIPCFormat format)
{
DWORD result;
if (size < 0)
}
// Calls that SERVER can make
-bool wxDDEConnection::Advise(const wxString& item, char *data, int size, wxDataFormat format)
+bool wxDDEConnection::Advise(const wxString& item, char *data, int size, wxIPCFormat format)
{
if (size < 0)
size = strlen(data);
{
DWORD len = DdeGetData(hData, (LPBYTE)(connection->m_bufPtr), connection->m_bufSize, 0);
DdeFreeDataHandle(hData);
- if (connection->OnExecute(connection->m_topicName, connection->m_bufPtr, (int)len, (wxDataFormat) wFmt))
+ if (connection->OnExecute(connection->m_topicName, connection->m_bufPtr, (int)len, (wxIPCFormat) wFmt))
return (DDERETURN)DDE_FACK;
else
return (DDERETURN)DDE_FNOTPROCESSED;
CP_WINANSI);
int user_size = -1;
- char *data = connection->OnRequest(connection->m_topicName, wxString(item_name), &user_size, (wxDataFormat) wFmt);
+ char *data = connection->OnRequest(connection->m_topicName, wxString(item_name), &user_size, (wxIPCFormat) wFmt);
if (data)
{
if (user_size < 0) user_size = strlen(data);
CP_WINANSI);
DWORD len = DdeGetData(hData, (LPBYTE)(connection->m_bufPtr), connection->m_bufSize, 0);
DdeFreeDataHandle(hData);
- connection->OnPoke(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxDataFormat) wFmt);
+ connection->OnPoke(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxIPCFormat) wFmt);
return (DDERETURN)DDE_FACK;
} else return (DDERETURN)DDE_FNOTPROCESSED;
break;
DWORD len = DdeGetData(hData, (LPBYTE)(connection->m_bufPtr), connection->m_bufSize, 0);
DdeFreeDataHandle(hData);
- if (connection->OnAdvise(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxDataFormat) wFmt))
+ if (connection->OnAdvise(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxIPCFormat) wFmt))
return (DDERETURN)DDE_FACK;
else
return (DDERETURN)DDE_FNOTPROCESSED;