wxMSW wxClipboard implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -729,18 +729,25 @@ typedef enum
 | 
			
		||||
// Don't do parent client adjustments (for implementation only)
 | 
			
		||||
#define wxSIZE_NO_ADJUSTMENTS   0x0008
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Data format for drag & drop and clipboard operations
 | 
			
		||||
 * numbers as per winuser.h */
 | 
			
		||||
 | 
			
		||||
enum wxDataFormat
 | 
			
		||||
{
 | 
			
		||||
  wxDF_INVALID =          0,
 | 
			
		||||
  wxDF_TEXT =             1,  /* CF_TEXT */
 | 
			
		||||
  wxDF_BITMAP =           2,  /* CF_BITMAP */
 | 
			
		||||
  wxDF_METAFILE =         3,  /* CF_METAFILEPICT */
 | 
			
		||||
  wxDF_DIB =              8,  /* CF_DIB */
 | 
			
		||||
  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
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ public:
 | 
			
		||||
  void SetText( const wxString& strText) 
 | 
			
		||||
    { m_strText = strText; }
 | 
			
		||||
    
 | 
			
		||||
  wxString GetText() 
 | 
			
		||||
  wxString GetText() const
 | 
			
		||||
    { return m_strText; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
@@ -95,7 +95,7 @@ public:
 | 
			
		||||
  void AddFile( const wxString &file )
 | 
			
		||||
    { m_files += file; m_files += (char)0; }
 | 
			
		||||
    
 | 
			
		||||
  wxString GetFiles()
 | 
			
		||||
  wxString GetFiles() const
 | 
			
		||||
    { return m_files; }
 | 
			
		||||
    
 | 
			
		||||
private:
 | 
			
		||||
@@ -121,7 +121,7 @@ public:
 | 
			
		||||
  void SetBitmap( const wxBitmap &bitmap )
 | 
			
		||||
    { m_bitmap = bitmap; }
 | 
			
		||||
    
 | 
			
		||||
  wxBitmap GetBitmap()
 | 
			
		||||
  wxBitmap GetBitmap() const
 | 
			
		||||
    { return m_bitmap; }
 | 
			
		||||
    
 | 
			
		||||
private:
 | 
			
		||||
@@ -154,16 +154,16 @@ public:
 | 
			
		||||
  void SetId( const wxString& id )
 | 
			
		||||
    { m_id = id; }
 | 
			
		||||
    
 | 
			
		||||
  wxString GetId()
 | 
			
		||||
  wxString GetId() const
 | 
			
		||||
    { return m_id; }
 | 
			
		||||
 | 
			
		||||
  // will make internal copy
 | 
			
		||||
  void SetData( const char *data, size_t size );
 | 
			
		||||
    
 | 
			
		||||
  size_t GetDataSize()
 | 
			
		||||
  size_t GetDataSize() const
 | 
			
		||||
    { return m_size; }
 | 
			
		||||
    
 | 
			
		||||
  char* GetData()
 | 
			
		||||
  char* GetData() const
 | 
			
		||||
    { return m_data; }
 | 
			
		||||
    
 | 
			
		||||
private:
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ public:
 | 
			
		||||
  void SetText( const wxString& strText) 
 | 
			
		||||
    { m_strText = strText; }
 | 
			
		||||
    
 | 
			
		||||
  wxString GetText() 
 | 
			
		||||
  wxString GetText() const
 | 
			
		||||
    { return m_strText; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
@@ -95,7 +95,7 @@ public:
 | 
			
		||||
  void AddFile( const wxString &file )
 | 
			
		||||
    { m_files += file; m_files += (char)0; }
 | 
			
		||||
    
 | 
			
		||||
  wxString GetFiles()
 | 
			
		||||
  wxString GetFiles() const
 | 
			
		||||
    { return m_files; }
 | 
			
		||||
    
 | 
			
		||||
private:
 | 
			
		||||
@@ -121,7 +121,7 @@ public:
 | 
			
		||||
  void SetBitmap( const wxBitmap &bitmap )
 | 
			
		||||
    { m_bitmap = bitmap; }
 | 
			
		||||
    
 | 
			
		||||
  wxBitmap GetBitmap()
 | 
			
		||||
  wxBitmap GetBitmap() const
 | 
			
		||||
    { return m_bitmap; }
 | 
			
		||||
    
 | 
			
		||||
private:
 | 
			
		||||
@@ -154,16 +154,16 @@ public:
 | 
			
		||||
  void SetId( const wxString& id )
 | 
			
		||||
    { m_id = id; }
 | 
			
		||||
    
 | 
			
		||||
  wxString GetId()
 | 
			
		||||
  wxString GetId() const
 | 
			
		||||
    { return m_id; }
 | 
			
		||||
 | 
			
		||||
  // will make internal copy
 | 
			
		||||
  void SetData( const char *data, size_t size );
 | 
			
		||||
    
 | 
			
		||||
  size_t GetDataSize()
 | 
			
		||||
  size_t GetDataSize() const
 | 
			
		||||
    { return m_size; }
 | 
			
		||||
    
 | 
			
		||||
  char* GetData()
 | 
			
		||||
  char* GetData() const
 | 
			
		||||
    { return m_data; }
 | 
			
		||||
    
 | 
			
		||||
private:
 | 
			
		||||
 
 | 
			
		||||
@@ -23,88 +23,59 @@
 | 
			
		||||
 | 
			
		||||
#include "wx/list.h"
 | 
			
		||||
 | 
			
		||||
// These functions superceded by wxClipboard, but retained in order to implement
 | 
			
		||||
// wxClipboard, and for compatibility.
 | 
			
		||||
WXDLLEXPORT bool wxOpenClipboard(void);
 | 
			
		||||
WXDLLEXPORT bool wxClipboardOpen(void);
 | 
			
		||||
WXDLLEXPORT bool wxCloseClipboard(void);
 | 
			
		||||
WXDLLEXPORT bool wxEmptyClipboard(void);
 | 
			
		||||
WXDLLEXPORT bool wxIsClipboardFormatAvailable(int dataFormat);
 | 
			
		||||
WXDLLEXPORT bool wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0);
 | 
			
		||||
WXDLLEXPORT wxObject* wxGetClipboardData(int dataFormat, long *len = NULL);
 | 
			
		||||
WXDLLEXPORT int  wxEnumClipboardFormats(int dataFormat);
 | 
			
		||||
WXDLLEXPORT bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
 | 
			
		||||
WXDLLEXPORT bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0);
 | 
			
		||||
WXDLLEXPORT wxObject* wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL);
 | 
			
		||||
WXDLLEXPORT wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat);
 | 
			
		||||
WXDLLEXPORT int  wxRegisterClipboardFormat(char *formatName);
 | 
			
		||||
WXDLLEXPORT bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount);
 | 
			
		||||
WXDLLEXPORT bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount);
 | 
			
		||||
 | 
			
		||||
/* The following is Matthew Flatt's implementation of the MSW
 | 
			
		||||
 * side of generic clipboard functionality.
 | 
			
		||||
 */
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
// wxClipboard
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
/* A clipboard client holds data belonging to the clipboard.
 | 
			
		||||
   For plain text, a client is not necessary. */
 | 
			
		||||
class WXDLLEXPORT wxClipboardClient : public wxObject
 | 
			
		||||
{
 | 
			
		||||
  DECLARE_ABSTRACT_CLASS(wxClipboardClient)
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  /* This list should be filled in with strings indicating the formats
 | 
			
		||||
     this client can provide. Almost all clients will provide "TEXT".
 | 
			
		||||
     Format names should be 4 characters long, so things will work
 | 
			
		||||
     out on the Macintosh */
 | 
			
		||||
  wxStringList formats;
 | 
			
		||||
 | 
			
		||||
  /* This method is called when the client is losing the selection. */
 | 
			
		||||
  virtual void BeingReplaced(void) = 0;
 | 
			
		||||
 | 
			
		||||
  /* This method is called when someone wants the data this client is
 | 
			
		||||
     supplying to the clipboard. "format" is a string indicating the
 | 
			
		||||
     format of the data - one of the strings from the "formats"
 | 
			
		||||
     list. "*size" should be filled with the size of the resulting
 | 
			
		||||
     data. In the case of text, "*size" does not count the
 | 
			
		||||
     NULL terminator. */
 | 
			
		||||
  virtual char *GetData(char *format, long *size) = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* ONE instance of this class: */
 | 
			
		||||
class WXDLLEXPORT wxClipboard : public wxObject
 | 
			
		||||
class WXDLLEXPORT wxDataObject;
 | 
			
		||||
class WXDLLEXPORT wxClipboard: public wxObject
 | 
			
		||||
{
 | 
			
		||||
  DECLARE_DYNAMIC_CLASS(wxClipboard)
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  wxClipboardClient *clipOwner;
 | 
			
		||||
  char *cbString, *sentString, *receivedString;
 | 
			
		||||
  void *receivedTargets;
 | 
			
		||||
  long receivedLength;
 | 
			
		||||
#ifdef __XVIEW__
 | 
			
		||||
  long sel_owner;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
 
 | 
			
		||||
  wxClipboard();
 | 
			
		||||
  ~wxClipboard();
 | 
			
		||||
 | 
			
		||||
  /* Set the clipboard data owner. "time" comes from the event record. */
 | 
			
		||||
  void SetClipboardClient(wxClipboardClient *, long time);
 | 
			
		||||
  // open the clipboard before SetData() and GetData()
 | 
			
		||||
  virtual bool Open();
 | 
			
		||||
  
 | 
			
		||||
  // close the clipboard after SetData() and GetData()
 | 
			
		||||
  virtual void Close();
 | 
			
		||||
  
 | 
			
		||||
  // can be called several times
 | 
			
		||||
  virtual bool SetData( wxDataObject *data );
 | 
			
		||||
 | 
			
		||||
  /* Set the clipboard string; does not require a client. */
 | 
			
		||||
  void SetClipboardString(char *, long time);
 | 
			
		||||
  // format available on the clipboard ? 
 | 
			
		||||
  // supply ID if private format, the same as wxPrivateDataObject::SetId() 
 | 
			
		||||
  virtual bool IsSupportedFormat( wxDataFormat format, const wxString &id = wxEmptyString );
 | 
			
		||||
  
 | 
			
		||||
  // fill data with data on the clipboard (if available)
 | 
			
		||||
  virtual bool GetData( wxDataObject *data );
 | 
			
		||||
  
 | 
			
		||||
  // clears wxTheClipboard and the system's clipboard if possible
 | 
			
		||||
  virtual void Clear();
 | 
			
		||||
 | 
			
		||||
  /* Get data from the clipboard in the format "TEXT". */
 | 
			
		||||
  char *GetClipboardString(long time);
 | 
			
		||||
 | 
			
		||||
  /* Get data from the clipboard */
 | 
			
		||||
  char *GetClipboardData(char *format, long *length, long time);
 | 
			
		||||
 | 
			
		||||
  /* Get the clipboard client directly. Will be NULL if clipboard data
 | 
			
		||||
     is a string, or if some other application owns the clipboard. 
 | 
			
		||||
     This can be useful for shortcutting data translation, if the
 | 
			
		||||
     clipboard user can check for a specific client. (This is used
 | 
			
		||||
     by the wxMediaEdit class.) */
 | 
			
		||||
  wxClipboardClient *GetClipboardClient(void);
 | 
			
		||||
 // implementation 
 | 
			
		||||
 
 | 
			
		||||
  bool              m_open;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Initialize wxTheClipboard. Can be called repeatedly */
 | 
			
		||||
WXDLLEXPORT void wxInitClipboard(void);
 | 
			
		||||
 | 
			
		||||
/* The clipboard */
 | 
			
		||||
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
 | 
			
		||||
// WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
 | 
			
		||||
 | 
			
		||||
#endif // wxUSE_CLIPBOARD
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -21,69 +21,99 @@
 | 
			
		||||
 | 
			
		||||
#if wxUSE_METAFILE
 | 
			
		||||
#include "wx/dc.h"
 | 
			
		||||
#include "wx/gdiobj.h"
 | 
			
		||||
 | 
			
		||||
#if wxUSE_DRAG_AND_DROP
 | 
			
		||||
#include "wx/dataobj.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Metafile and metafile device context classes - work in Windows 3.1 only
 | 
			
		||||
 * Metafile and metafile device context classes
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
class WXDLLEXPORT wxDC;
 | 
			
		||||
class WXDLLEXPORT wxMetaFile: public wxObject
 | 
			
		||||
#define wxMetaFile wxMetafile
 | 
			
		||||
#define wxMetaFileDC wxMetafileDC
 | 
			
		||||
 | 
			
		||||
class WXDLLEXPORT wxMetafile;
 | 
			
		||||
 | 
			
		||||
class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
 | 
			
		||||
{
 | 
			
		||||
  DECLARE_DYNAMIC_CLASS(wxMetaFile)
 | 
			
		||||
    friend class WXDLLEXPORT wxMetafile;
 | 
			
		||||
public:
 | 
			
		||||
    wxMetafileRefData(void);
 | 
			
		||||
    ~wxMetafileRefData(void);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    WXHANDLE m_metafile;
 | 
			
		||||
    int m_windowsMappingMode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
 | 
			
		||||
 | 
			
		||||
class WXDLLEXPORT wxMetafile: public wxGDIObject
 | 
			
		||||
{
 | 
			
		||||
  DECLARE_DYNAMIC_CLASS(wxMetafile)
 | 
			
		||||
 public:
 | 
			
		||||
  wxMetaFile(const wxString& file = "");
 | 
			
		||||
  ~wxMetaFile(void);
 | 
			
		||||
  // Copy constructor
 | 
			
		||||
  inline wxMetafile(const wxMetafile& metafile)
 | 
			
		||||
  { Ref(metafile); }
 | 
			
		||||
 | 
			
		||||
  wxMetafile(const wxString& file = "");
 | 
			
		||||
  ~wxMetafile(void);
 | 
			
		||||
 | 
			
		||||
  // After this is called, the metafile cannot be used for anything
 | 
			
		||||
  // since it is now owned by the clipboard.
 | 
			
		||||
  virtual bool SetClipboard(int width = 0, int height = 0);
 | 
			
		||||
 | 
			
		||||
  virtual bool Play(wxDC *dc);
 | 
			
		||||
  inline bool Ok(void) { return m_metaFile != 0; };
 | 
			
		||||
  inline bool Ok(void) const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
 | 
			
		||||
 | 
			
		||||
  // Implementation
 | 
			
		||||
  inline WXHANDLE GetHMETAFILE(void) { return m_metaFile; }
 | 
			
		||||
  inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; }
 | 
			
		||||
  inline int GetWindowsMappingMode(void) { return m_windowsMappingMode; }
 | 
			
		||||
  inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
 | 
			
		||||
  inline WXHANDLE GetHMETAFILE(void) { return M_METAFILEDATA->m_metafile; }
 | 
			
		||||
  void SetHMETAFILE(WXHANDLE mf) ;
 | 
			
		||||
  inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
 | 
			
		||||
  void SetWindowsMappingMode(int mm);
 | 
			
		||||
 | 
			
		||||
  // Operators
 | 
			
		||||
  inline wxMetafile& operator = (const wxMetafile& metafile) { if (*this == metafile) return (*this); Ref(metafile); return *this; }
 | 
			
		||||
  inline bool operator == (const wxMetafile& metafile) { return m_refData == metafile.m_refData; }
 | 
			
		||||
  inline bool operator != (const wxMetafile& metafile) { return m_refData != metafile.m_refData; }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  WXHANDLE m_metaFile;
 | 
			
		||||
  int m_windowsMappingMode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class WXDLLEXPORT wxMetaFileDC: public wxDC
 | 
			
		||||
class WXDLLEXPORT wxMetafileDC: public wxDC
 | 
			
		||||
{
 | 
			
		||||
  DECLARE_DYNAMIC_CLASS(wxMetaFileDC)
 | 
			
		||||
  DECLARE_DYNAMIC_CLASS(wxMetafileDC)
 | 
			
		||||
 | 
			
		||||
 public:
 | 
			
		||||
  // Don't supply origin and extent
 | 
			
		||||
  // Supply them to wxMakeMetaFilePlaceable instead.
 | 
			
		||||
  wxMetaFileDC(const wxString& file = "");
 | 
			
		||||
  wxMetafileDC(const wxString& file = "");
 | 
			
		||||
 | 
			
		||||
  // Supply origin and extent (recommended).
 | 
			
		||||
  // Then don't need to supply them to wxMakeMetaFilePlaceable.
 | 
			
		||||
  wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
 | 
			
		||||
  wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg);
 | 
			
		||||
 | 
			
		||||
  ~wxMetaFileDC(void);
 | 
			
		||||
  ~wxMetafileDC(void);
 | 
			
		||||
 | 
			
		||||
  // Should be called at end of drawing
 | 
			
		||||
  virtual wxMetaFile *Close(void);
 | 
			
		||||
  virtual wxMetafile *Close(void);
 | 
			
		||||
  virtual void SetMapMode(int mode);
 | 
			
		||||
  virtual void GetTextExtent(const wxString& string, long *x, long *y,
 | 
			
		||||
                     long *descent = NULL, long *externalLeading = NULL,
 | 
			
		||||
                     wxFont *theFont = NULL, bool use16bit = FALSE) const;
 | 
			
		||||
 | 
			
		||||
  // Implementation
 | 
			
		||||
  inline wxMetaFile *GetMetaFile(void) { return m_metaFile; }
 | 
			
		||||
  inline void SetMetaFile(wxMetaFile *mf) { m_metaFile = mf; }
 | 
			
		||||
  inline int GetWindowsMappingMode(void) { return m_windowsMappingMode; }
 | 
			
		||||
  inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
 | 
			
		||||
  inline void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
 | 
			
		||||
  inline int GetWindowsMappingMode(void) const { return m_windowsMappingMode; }
 | 
			
		||||
  inline void SetWindowsMappingMode(int mm) { m_windowsMappingMode = mm; }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  int m_windowsMappingMode;
 | 
			
		||||
  wxMetaFile *m_metaFile;
 | 
			
		||||
  int           m_windowsMappingMode;
 | 
			
		||||
  wxMetafile*   m_metaFile;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -94,11 +124,55 @@ protected:
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// No origin or extent
 | 
			
		||||
bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, float scale = 1.0);
 | 
			
		||||
#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
 | 
			
		||||
bool WXDLLEXPORT wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0);
 | 
			
		||||
 | 
			
		||||
// Optional origin and extent
 | 
			
		||||
bool WXDLLEXPORT wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = TRUE);
 | 
			
		||||
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
// wxMetafileDataObject is a specialization of wxDataObject for metafile data
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// TODO: implement OLE side of things. At present, it's just for clipboard
 | 
			
		||||
// use.
 | 
			
		||||
 | 
			
		||||
#if wxUSE_DRAG_AND_DROP
 | 
			
		||||
class WXDLLEXPORT wxMetafileDataObject : public wxDataObject
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
  // ctors
 | 
			
		||||
  wxMetafileDataObject() { m_width = 0; m_height = 0; };
 | 
			
		||||
  wxMetafileDataObject(const wxMetafile& metafile, int width = 0, int height = 0):
 | 
			
		||||
    m_metafile(metafile), m_width(width), m_height(height) { }
 | 
			
		||||
 | 
			
		||||
  void SetMetafile(const wxMetafile& metafile, int w = 0, int h = 0)
 | 
			
		||||
    { m_metafile = metafile; m_width = w; m_height = h; }
 | 
			
		||||
  wxMetafile GetMetafile() const { return m_metafile; }
 | 
			
		||||
  int GetWidth() const { return m_width; }
 | 
			
		||||
  int GetHeight() const { return m_height; }
 | 
			
		||||
 | 
			
		||||
  virtual wxDataFormat GetFormat() const { return wxDF_METAFILE; }
 | 
			
		||||
 | 
			
		||||
/* ??
 | 
			
		||||
  // implement base class pure virtuals
 | 
			
		||||
  virtual wxDataFormat GetPreferredFormat() const
 | 
			
		||||
    { return (wxDataFormat) wxDataObject::Text; }
 | 
			
		||||
  virtual bool IsSupportedFormat(wxDataFormat format) const
 | 
			
		||||
    { return format == wxDataObject::Text || format == wxDataObject::Locale; }
 | 
			
		||||
  virtual size_t GetDataSize() const
 | 
			
		||||
    { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
 | 
			
		||||
  virtual void GetDataHere(void *pBuf) const
 | 
			
		||||
    { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  wxMetafile   m_metafile;
 | 
			
		||||
  int          m_width;
 | 
			
		||||
  int          m_height;
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif // wxUSE_METAFILE
 | 
			
		||||
#endif
 | 
			
		||||
    // _WX_METAFIILE_H_
 | 
			
		||||
 
 | 
			
		||||
@@ -73,6 +73,9 @@ public:
 | 
			
		||||
    // retrieve IDataObject interface (for other OLE related classes)
 | 
			
		||||
  IDataObject *GetInterface() const { return m_pIDataObject; }
 | 
			
		||||
 | 
			
		||||
  ////// wxGTK compatibility: hopefully to become the preferred API.
 | 
			
		||||
  virtual wxDataFormat GetFormat() const { return GetPreferredFormat(); }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  IDataObject *m_pIDataObject; // pointer to the COM interface
 | 
			
		||||
};
 | 
			
		||||
@@ -98,6 +101,11 @@ public:
 | 
			
		||||
  virtual void GetDataHere(void *pBuf) const
 | 
			
		||||
    { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
 | 
			
		||||
 | 
			
		||||
  ////// wxGTK compatibility: hopefully to become the preferred API.
 | 
			
		||||
  void SetText(const wxString& strText) { m_strText = strText; }
 | 
			
		||||
  wxString GetText() const { return m_strText; }
 | 
			
		||||
  virtual wxDataFormat GetFormat() const { return wxDF_TEXT; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  wxString  m_strText;
 | 
			
		||||
};
 | 
			
		||||
@@ -106,4 +114,42 @@ private:
 | 
			
		||||
// @@@ TODO: wx{Bitmap|Metafile|...}DataObject
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
// wxBitmapDataObject is a specialization of wxDataObject for bitmap data
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// TODO: implement OLE side of things. At present, it's just for clipboard
 | 
			
		||||
// use.
 | 
			
		||||
class WXDLLEXPORT wxBitmapDataObject : public wxDataObject
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
  // ctors
 | 
			
		||||
  wxBitmapDataObject() {};
 | 
			
		||||
  wxBitmapDataObject(const wxBitmap& bitmap): m_bitmap(bitmap) {}
 | 
			
		||||
  void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
 | 
			
		||||
  wxBitmap GetBitmap() const { return m_bitmap; }
 | 
			
		||||
 | 
			
		||||
  virtual wxDataFormat GetFormat() const { return wxDF_BITMAP; }
 | 
			
		||||
 | 
			
		||||
/* ??
 | 
			
		||||
  // implement base class pure virtuals
 | 
			
		||||
  virtual wxDataFormat GetPreferredFormat() const
 | 
			
		||||
    { return (wxDataFormat) wxDataObject::Text; }
 | 
			
		||||
  virtual bool IsSupportedFormat(wxDataFormat format) const
 | 
			
		||||
    { return format == wxDataObject::Text || format == wxDataObject::Locale; }
 | 
			
		||||
  virtual size_t GetDataSize() const
 | 
			
		||||
    { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
 | 
			
		||||
  virtual void GetDataHere(void *pBuf) const
 | 
			
		||||
    { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
  wxBitmap  m_bitmap;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
// wxMetaFileDataObject: see metafile.h is a specialization of wxDataObject for bitmap data
 | 
			
		||||
// ----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
#endif  //_WX_OLEDATAOBJ_H
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -142,6 +142,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
 | 
			
		||||
          m_strText("wxWindows drag & drop works :-)")
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
  SetBackgroundColour(* wxWHITE);
 | 
			
		||||
 | 
			
		||||
  // frame icon and status bar
 | 
			
		||||
  SetIcon(wxICON(mondrian));
 | 
			
		||||
@@ -233,7 +234,7 @@ void DnDFrame::OnPaint(wxPaintEvent& /*event*/)
 | 
			
		||||
 | 
			
		||||
  wxPaintDC dc(this);
 | 
			
		||||
  dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL ) );
 | 
			
		||||
  dc.DrawText( "Drag text from here!", 20, h-20 );
 | 
			
		||||
  dc.DrawText( "Drag text from here!", 20, h-30 );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DnDFrame::OnDrag(wxCommandEvent& /* event */)
 | 
			
		||||
 
 | 
			
		||||
@@ -35,18 +35,27 @@
 | 
			
		||||
#include "wx/utils.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if wxUSE_METAFILE
 | 
			
		||||
#include "wx/metafile.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "wx/clipbrd.h"
 | 
			
		||||
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
 | 
			
		||||
HICON myIcon;
 | 
			
		||||
 | 
			
		||||
#include "wx/msw/private.h"
 | 
			
		||||
#include "wx/msw/dib.h"
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#if !USE_SHARED_LIBRARY
 | 
			
		||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
 | 
			
		||||
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
 | 
			
		||||
// wxDataObject is tied to OLE/drag and drop implementation,
 | 
			
		||||
// therefore so is wxClipboard :-(
 | 
			
		||||
#if wxUSE_DRAG_AND_DROP
 | 
			
		||||
#include "wx/dataobj.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
bool wxClipboardIsOpen = FALSE;
 | 
			
		||||
 | 
			
		||||
bool wxOpenClipboard(void)
 | 
			
		||||
@@ -78,12 +87,12 @@ bool wxClipboardOpen(void)
 | 
			
		||||
  return wxClipboardIsOpen;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxIsClipboardFormatAvailable(int dataFormat)
 | 
			
		||||
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
 | 
			
		||||
{
 | 
			
		||||
  return (::IsClipboardFormatAvailable(dataFormat) != 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
 | 
			
		||||
bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width, int height)
 | 
			
		||||
{
 | 
			
		||||
  switch (dataFormat)
 | 
			
		||||
  {
 | 
			
		||||
@@ -135,7 +144,7 @@ bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
 | 
			
		||||
#if wxUSE_METAFILE
 | 
			
		||||
    case wxDF_METAFILE:
 | 
			
		||||
    {
 | 
			
		||||
      wxMetaFile *wxMF = (wxMetaFile *)obj;
 | 
			
		||||
      wxMetafile *wxMF = (wxMetafile *)obj;
 | 
			
		||||
      HANDLE data = GlobalAlloc(GHND, sizeof(METAFILEPICT) + 1);
 | 
			
		||||
#ifdef __WINDOWS_386__
 | 
			
		||||
      METAFILEPICT *mf = (METAFILEPICT *)MK_FP32(GlobalLock(data));
 | 
			
		||||
@@ -200,7 +209,7 @@ bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
 | 
			
		||||
  return FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxObject *wxGetClipboardData(int dataFormat, long *len)
 | 
			
		||||
wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
 | 
			
		||||
{
 | 
			
		||||
  switch (dataFormat)
 | 
			
		||||
  {
 | 
			
		||||
@@ -299,9 +308,9 @@ wxObject *wxGetClipboardData(int dataFormat, long *len)
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int  wxEnumClipboardFormats(int dataFormat)
 | 
			
		||||
wxDataFormat  wxEnumClipboardFormats(wxDataFormat dataFormat)
 | 
			
		||||
{
 | 
			
		||||
  return ::EnumClipboardFormats(dataFormat);
 | 
			
		||||
  return (wxDataFormat) ::EnumClipboardFormats(dataFormat);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int  wxRegisterClipboardFormat(char *formatName)
 | 
			
		||||
@@ -309,158 +318,166 @@ int  wxRegisterClipboardFormat(char *formatName)
 | 
			
		||||
  return ::RegisterClipboardFormat(formatName);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
 | 
			
		||||
bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount)
 | 
			
		||||
{
 | 
			
		||||
  return (::GetClipboardFormatName(dataFormat, formatName, maxCount) > 0);
 | 
			
		||||
  return (::GetClipboardFormatName((int) dataFormat, formatName, maxCount) > 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Generalized clipboard implementation by Matthew Flatt
 | 
			
		||||
 * wxClipboard
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
wxClipboard *wxTheClipboard = NULL;
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
// wxClipboard
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
void wxInitClipboard(void)
 | 
			
		||||
{
 | 
			
		||||
  if (!wxTheClipboard)
 | 
			
		||||
    wxTheClipboard = new wxClipboard;
 | 
			
		||||
}
 | 
			
		||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
 | 
			
		||||
 | 
			
		||||
wxClipboard::wxClipboard()
 | 
			
		||||
{
 | 
			
		||||
  clipOwner = NULL;
 | 
			
		||||
  cbString = NULL;
 | 
			
		||||
    m_open = FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxClipboard::~wxClipboard()
 | 
			
		||||
{
 | 
			
		||||
  if (clipOwner)
 | 
			
		||||
    clipOwner->BeingReplaced();
 | 
			
		||||
  if (cbString)
 | 
			
		||||
    delete[] cbString;
 | 
			
		||||
    Clear();  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int FormatStringToID(char *str)
 | 
			
		||||
void wxClipboard::Clear()
 | 
			
		||||
{
 | 
			
		||||
  if (!strcmp(str, "TEXT"))
 | 
			
		||||
    return wxDF_TEXT;
 | 
			
		||||
 | 
			
		||||
  return wxRegisterClipboardFormat(str);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
 | 
			
		||||
bool wxClipboard::Open()
 | 
			
		||||
{
 | 
			
		||||
  bool got_selection;
 | 
			
		||||
 | 
			
		||||
  if (clipOwner)
 | 
			
		||||
    clipOwner->BeingReplaced();
 | 
			
		||||
  clipOwner = client;
 | 
			
		||||
  if (cbString) {
 | 
			
		||||
    delete[] cbString;
 | 
			
		||||
    cbString = NULL;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (wxOpenClipboard()) {
 | 
			
		||||
    char **formats, *data;
 | 
			
		||||
         int i;
 | 
			
		||||
    int ftype;
 | 
			
		||||
    long size;
 | 
			
		||||
 | 
			
		||||
    formats = clipOwner->formats.ListToArray(FALSE);
 | 
			
		||||
    for (i = clipOwner->formats.Number(); i--; ) {
 | 
			
		||||
      ftype = FormatStringToID(formats[i]);
 | 
			
		||||
      data = clipOwner->GetData(formats[i], &size);
 | 
			
		||||
      if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
 | 
			
		||||
        got_selection = FALSE;
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (i < 0)
 | 
			
		||||
      got_selection = wxCloseClipboard();
 | 
			
		||||
  } else
 | 
			
		||||
    got_selection = FALSE;
 | 
			
		||||
    wxCHECK_MSG( !m_open, FALSE, "clipboard already open" );
 | 
			
		||||
  
 | 
			
		||||
  got_selection = FALSE; // Assume another process takes over
 | 
			
		||||
    m_open = TRUE;
 | 
			
		||||
 | 
			
		||||
  if (!got_selection) {
 | 
			
		||||
    clipOwner->BeingReplaced();
 | 
			
		||||
         clipOwner = NULL;
 | 
			
		||||
  }
 | 
			
		||||
    return wxOpenClipboard();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxClipboardClient *wxClipboard::GetClipboardClient()
 | 
			
		||||
bool wxClipboard::SetData( wxDataObject *data )
 | 
			
		||||
{
 | 
			
		||||
  return clipOwner;
 | 
			
		||||
#if wxUSE_DRAG_AND_DROP
 | 
			
		||||
    wxCHECK_MSG( data, FALSE, "data is invalid" );
 | 
			
		||||
    wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
 | 
			
		||||
 | 
			
		||||
    switch (data->GetFormat())
 | 
			
		||||
    {
 | 
			
		||||
        case wxDF_TEXT:
 | 
			
		||||
        case wxDF_OEMTEXT:
 | 
			
		||||
        {
 | 
			
		||||
            wxTextDataObject* textDataObject = (wxTextDataObject*) data;
 | 
			
		||||
            wxString str(textDataObject->GetText());
 | 
			
		||||
            return wxSetClipboardData(data->GetFormat(), (wxObject*) (const char*) str);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case wxDF_BITMAP:
 | 
			
		||||
        case wxDF_DIB:
 | 
			
		||||
        {
 | 
			
		||||
            wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
 | 
			
		||||
            wxBitmap bitmap(bitmapDataObject->GetBitmap());
 | 
			
		||||
            return wxSetClipboardData(data->GetFormat(), & bitmap);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
#if wxUSE_METAFILE
 | 
			
		||||
        case wxDF_METAFILE:
 | 
			
		||||
        {
 | 
			
		||||
            wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data;
 | 
			
		||||
            wxMetafile metaFile = metaFileDataObject->GetMetafile();
 | 
			
		||||
            return wxSetClipboardData(wxDF_METAFILE, & metaFile, metaFileDataObject->GetWidth(), metaFileDataObject->GetHeight());
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
        default:
 | 
			
		||||
        {
 | 
			
		||||
            return FALSE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
    return FALSE;
 | 
			
		||||
#else
 | 
			
		||||
    return FALSE;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxClipboard::SetClipboardString(char *str, long time)
 | 
			
		||||
void wxClipboard::Close()
 | 
			
		||||
{
 | 
			
		||||
  bool got_selection;
 | 
			
		||||
 | 
			
		||||
  if (clipOwner) {
 | 
			
		||||
    clipOwner->BeingReplaced();
 | 
			
		||||
    clipOwner = NULL;
 | 
			
		||||
  }
 | 
			
		||||
  if (cbString)
 | 
			
		||||
    delete[] cbString;
 | 
			
		||||
 | 
			
		||||
  cbString = str;
 | 
			
		||||
 | 
			
		||||
  if (wxOpenClipboard()) {
 | 
			
		||||
    if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
 | 
			
		||||
      got_selection = FALSE;
 | 
			
		||||
    else
 | 
			
		||||
                got_selection = wxCloseClipboard();
 | 
			
		||||
  } else
 | 
			
		||||
    got_selection = FALSE;
 | 
			
		||||
 | 
			
		||||
  got_selection = FALSE; // Assume another process takes over
 | 
			
		||||
 | 
			
		||||
  if (!got_selection) {
 | 
			
		||||
    delete[] cbString;
 | 
			
		||||
    cbString = NULL;
 | 
			
		||||
  }
 | 
			
		||||
    wxCHECK_RET( m_open, "clipboard not open" );
 | 
			
		||||
    
 | 
			
		||||
    m_open = FALSE;
 | 
			
		||||
    wxCloseClipboard();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *wxClipboard::GetClipboardString(long time)
 | 
			
		||||
bool wxClipboard::IsSupportedFormat( wxDataFormat format, const wxString& WXUNUSED(id) )
 | 
			
		||||
{
 | 
			
		||||
  char *str;
 | 
			
		||||
  long length;
 | 
			
		||||
 | 
			
		||||
  str = GetClipboardData("TEXT", &length, time);
 | 
			
		||||
  if (!str) {
 | 
			
		||||
    str = new char[1];
 | 
			
		||||
    *str = 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return str;
 | 
			
		||||
    return wxIsClipboardFormatAvailable(format);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
 | 
			
		||||
bool wxClipboard::GetData( wxDataObject *data )
 | 
			
		||||
{
 | 
			
		||||
  if (clipOwner)  {
 | 
			
		||||
         if (clipOwner->formats.Member(format))
 | 
			
		||||
      return clipOwner->GetData(format, length);
 | 
			
		||||
    else
 | 
			
		||||
      return NULL;
 | 
			
		||||
  } else if (cbString) {
 | 
			
		||||
    if (!strcmp(format, "TEXT"))
 | 
			
		||||
      return copystring(cbString);
 | 
			
		||||
    else
 | 
			
		||||
      return NULL;
 | 
			
		||||
  } else {
 | 
			
		||||
    if (wxOpenClipboard()) {
 | 
			
		||||
      receivedString = (char *)wxGetClipboardData(FormatStringToID(format), 
 | 
			
		||||
                                                  length);
 | 
			
		||||
      wxCloseClipboard();
 | 
			
		||||
    } else
 | 
			
		||||
      receivedString = NULL;
 | 
			
		||||
    wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
 | 
			
		||||
    
 | 
			
		||||
#if wxUSE_DRAG_AND_DROP
 | 
			
		||||
    switch (data->GetFormat())
 | 
			
		||||
    {
 | 
			
		||||
        case wxDF_TEXT:
 | 
			
		||||
        case wxDF_OEMTEXT:
 | 
			
		||||
        {
 | 
			
		||||
            wxTextDataObject* textDataObject = (wxTextDataObject*) data;
 | 
			
		||||
            char* s = (char*) wxGetClipboardData(data->GetFormat());
 | 
			
		||||
            if (s)
 | 
			
		||||
            {
 | 
			
		||||
                textDataObject->SetText(s);
 | 
			
		||||
                delete[] s;
 | 
			
		||||
                return TRUE;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                return FALSE;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case wxDF_BITMAP:
 | 
			
		||||
        case wxDF_DIB:
 | 
			
		||||
        {
 | 
			
		||||
            wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
 | 
			
		||||
            wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetFormat());
 | 
			
		||||
            if (bitmap)
 | 
			
		||||
            {
 | 
			
		||||
                bitmapDataObject->SetBitmap(* bitmap);
 | 
			
		||||
                delete bitmap;
 | 
			
		||||
                return TRUE;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                return FALSE;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
#if wxUSE_METAFILE
 | 
			
		||||
        case wxDF_METAFILE:
 | 
			
		||||
        {
 | 
			
		||||
            wxMetafileDataObject* metaFileDataObject = (wxMetafileDataObject*) data;
 | 
			
		||||
            wxMetafile* metaFile = (wxMetafile*) wxGetClipboardData(wxDF_METAFILE);
 | 
			
		||||
            if (metaFile)
 | 
			
		||||
            {
 | 
			
		||||
                metaFileDataObject->SetMetafile(* metaFile);
 | 
			
		||||
                delete metaFile;
 | 
			
		||||
                return TRUE;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
                return FALSE;
 | 
			
		||||
 | 
			
		||||
    return receivedString;
 | 
			
		||||
  }
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
        default:
 | 
			
		||||
        {
 | 
			
		||||
            return FALSE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return FALSE;
 | 
			
		||||
#else
 | 
			
		||||
    return FALSE;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // wxUSE_CLIPBOARD
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1626,10 +1626,10 @@ $(DOCDIR)\html\wx\wx.htm:         $(DOCDIR)\latex\wx\classes.tex $(DOCDIR)\latex
 | 
			
		||||
        -mkdir $(DOCDIR)\html\wx
 | 
			
		||||
        -start /w tex2rtf $(DOCDIR)\latex\wx\manual.tex $(DOCDIR)\html\wx\wx.htm -twice -html
 | 
			
		||||
        -erase $(DOCDIR)\html\wx\*.con
 | 
			
		||||
#        -erase $(DOCDIR)\html\wx\*.ref
 | 
			
		||||
#        -erase $(DOCDIR)\latex\wx\*.con
 | 
			
		||||
#        -erase $(DOCDIR)\latex\wx\*.ref
 | 
			
		||||
#        cd $(THISDIR)
 | 
			
		||||
        -erase $(DOCDIR)\html\wx\*.ref
 | 
			
		||||
        -erase $(DOCDIR)\latex\wx\*.con
 | 
			
		||||
        -erase $(DOCDIR)\latex\wx\*.ref
 | 
			
		||||
         cd $(THISDIR)
 | 
			
		||||
 | 
			
		||||
$(DOCDIR)\html\porting\port.htm:         $(DOCDIR)\latex\porting\porting.tex
 | 
			
		||||
        cd $(DOCDIR)\latex\porting
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// Name:        metafile.cpp
 | 
			
		||||
// Purpose:     wxMetaFileDC etc.
 | 
			
		||||
// Purpose:     wxMetafileDC etc.
 | 
			
		||||
// Author:      Julian Smart
 | 
			
		||||
// Modified by:
 | 
			
		||||
// Created:     04/01/98
 | 
			
		||||
@@ -41,53 +41,90 @@
 | 
			
		||||
extern bool wxClipboardIsOpen;
 | 
			
		||||
 | 
			
		||||
#if !USE_SHARED_LIBRARY
 | 
			
		||||
IMPLEMENT_DYNAMIC_CLASS(wxMetaFile, wxObject)
 | 
			
		||||
IMPLEMENT_ABSTRACT_CLASS(wxMetaFileDC, wxDC)
 | 
			
		||||
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
 | 
			
		||||
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Metafiles - Windows 3.1 only
 | 
			
		||||
 * Metafiles
 | 
			
		||||
 * Currently, the only purpose for making a metafile is to put
 | 
			
		||||
 * it on the clipboard.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
wxMetaFile::wxMetaFile(const wxString& file)
 | 
			
		||||
wxMetafileRefData::wxMetafileRefData(void)
 | 
			
		||||
{
 | 
			
		||||
  m_windowsMappingMode = MM_ANISOTROPIC;
 | 
			
		||||
  m_metaFile = 0;
 | 
			
		||||
  if (!file.IsNull() && file == "")
 | 
			
		||||
    m_metaFile = (WXHANDLE) GetMetaFile(file);
 | 
			
		||||
    m_metafile = 0;
 | 
			
		||||
    m_windowsMappingMode = MM_ANISOTROPIC;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxMetaFile::~wxMetaFile(void)
 | 
			
		||||
wxMetafileRefData::~wxMetafileRefData(void)
 | 
			
		||||
{
 | 
			
		||||
  if (m_metaFile)
 | 
			
		||||
    { DeleteMetaFile((HMETAFILE) m_metaFile); m_metaFile = 0; }
 | 
			
		||||
    if (m_metafile)
 | 
			
		||||
    {
 | 
			
		||||
        DeleteMetaFile((HMETAFILE) m_metafile);
 | 
			
		||||
        m_metafile = 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxMetaFile::SetClipboard(int width, int height)
 | 
			
		||||
wxMetafile::wxMetafile(const wxString& file)
 | 
			
		||||
{
 | 
			
		||||
  bool alreadyOpen=wxClipboardOpen();
 | 
			
		||||
  if (!alreadyOpen)
 | 
			
		||||
  {
 | 
			
		||||
    wxOpenClipboard();
 | 
			
		||||
    if (!wxEmptyClipboard()) return FALSE;
 | 
			
		||||
  }
 | 
			
		||||
  bool success = wxSetClipboardData(wxDF_METAFILE,this, width,height);
 | 
			
		||||
  if (!alreadyOpen) wxCloseClipboard();
 | 
			
		||||
  return (bool) success;
 | 
			
		||||
    m_refData = new wxMetafileRefData;
 | 
			
		||||
 | 
			
		||||
    M_METAFILEDATA->m_windowsMappingMode = MM_ANISOTROPIC;
 | 
			
		||||
    M_METAFILEDATA->m_metafile = 0;
 | 
			
		||||
    if (!file.IsNull() && file == "")
 | 
			
		||||
        M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxMetaFile::Play(wxDC *dc)
 | 
			
		||||
wxMetafile::~wxMetafile(void)
 | 
			
		||||
{
 | 
			
		||||
  dc->BeginDrawing();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  if (dc->GetHDC() && m_metaFile)
 | 
			
		||||
    PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) m_metaFile);
 | 
			
		||||
bool wxMetafile::SetClipboard(int width, int height)
 | 
			
		||||
{
 | 
			
		||||
    if (!m_refData)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
  dc->EndDrawing();
 | 
			
		||||
    bool alreadyOpen=wxClipboardOpen();
 | 
			
		||||
    if (!alreadyOpen)
 | 
			
		||||
    {
 | 
			
		||||
        wxOpenClipboard();
 | 
			
		||||
        if (!wxEmptyClipboard()) return FALSE;
 | 
			
		||||
    }
 | 
			
		||||
    bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
 | 
			
		||||
    if (!alreadyOpen) wxCloseClipboard();
 | 
			
		||||
    return (bool) success;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  return TRUE;
 | 
			
		||||
bool wxMetafile::Play(wxDC *dc)
 | 
			
		||||
{
 | 
			
		||||
    if (!m_refData)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    dc->BeginDrawing();
 | 
			
		||||
 | 
			
		||||
    if (dc->GetHDC() && M_METAFILEDATA->m_metafile)
 | 
			
		||||
        PlayMetaFile((HDC) dc->GetHDC(), (HMETAFILE) M_METAFILEDATA->m_metafile);
 | 
			
		||||
 | 
			
		||||
    dc->EndDrawing();
 | 
			
		||||
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxMetafile::SetHMETAFILE(WXHANDLE mf)
 | 
			
		||||
{
 | 
			
		||||
    if (m_refData)
 | 
			
		||||
        m_refData = new wxMetafileRefData;
 | 
			
		||||
 | 
			
		||||
    M_METAFILEDATA->m_metafile = mf;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxMetafile::SetWindowsMappingMode(int mm)
 | 
			
		||||
{
 | 
			
		||||
    if (m_refData)
 | 
			
		||||
        m_refData = new wxMetafileRefData;
 | 
			
		||||
 | 
			
		||||
    M_METAFILEDATA->m_windowsMappingMode = mm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -96,8 +133,8 @@ bool wxMetaFile::Play(wxDC *dc)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Original constructor that does not takes origin and extent. If you use this,
 | 
			
		||||
// *DO* give origin/extent arguments to wxMakeMetaFilePlaceable.
 | 
			
		||||
wxMetaFileDC::wxMetaFileDC(const wxString& file)
 | 
			
		||||
// *DO* give origin/extent arguments to wxMakeMetafilePlaceable.
 | 
			
		||||
wxMetafileDC::wxMetafileDC(const wxString& file)
 | 
			
		||||
{
 | 
			
		||||
  m_metaFile = NULL;
 | 
			
		||||
  m_minX = 10000;
 | 
			
		||||
@@ -123,8 +160,8 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// New constructor that takes origin and extent. If you use this, don't
 | 
			
		||||
// give origin/extent arguments to wxMakeMetaFilePlaceable.
 | 
			
		||||
wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
 | 
			
		||||
// give origin/extent arguments to wxMakeMetafilePlaceable.
 | 
			
		||||
wxMetafileDC::wxMetafileDC(const wxString& file, int xext, int yext, int xorg, int yorg)
 | 
			
		||||
{
 | 
			
		||||
  m_minX = 10000;
 | 
			
		||||
  m_minY = 10000;
 | 
			
		||||
@@ -144,12 +181,12 @@ wxMetaFileDC::wxMetaFileDC(const wxString& file, int xext, int yext, int xorg, i
 | 
			
		||||
  SetMapMode(MM_TEXT); // NOTE: does not set HDC mapmode (this is correct)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxMetaFileDC::~wxMetaFileDC(void)
 | 
			
		||||
wxMetafileDC::~wxMetafileDC(void)
 | 
			
		||||
{
 | 
			
		||||
  m_hDC = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxMetaFileDC::GetTextExtent(const wxString& string, long *x, long *y,
 | 
			
		||||
void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
 | 
			
		||||
                                 long *descent, long *externalLeading, wxFont *theFont, bool use16bit) const
 | 
			
		||||
{
 | 
			
		||||
  wxFont *fontToUse = theFont;
 | 
			
		||||
@@ -171,14 +208,14 @@ void wxMetaFileDC::GetTextExtent(const wxString& string, long *x, long *y,
 | 
			
		||||
  if (externalLeading) *externalLeading = tm.tmExternalLeading;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxMetaFile *wxMetaFileDC::Close(void)
 | 
			
		||||
wxMetafile *wxMetafileDC::Close(void)
 | 
			
		||||
{
 | 
			
		||||
  SelectOldObjects(m_hDC);
 | 
			
		||||
  HANDLE mf = CloseMetaFile((HDC) m_hDC);
 | 
			
		||||
  m_hDC = 0;
 | 
			
		||||
  if (mf)
 | 
			
		||||
  {
 | 
			
		||||
    wxMetaFile *wx_mf = new wxMetaFile;
 | 
			
		||||
    wxMetafile *wx_mf = new wxMetafile;
 | 
			
		||||
    wx_mf->SetHMETAFILE((WXHANDLE) mf);
 | 
			
		||||
    wx_mf->SetWindowsMappingMode(m_windowsMappingMode);
 | 
			
		||||
    return wx_mf;
 | 
			
		||||
@@ -186,7 +223,7 @@ wxMetaFile *wxMetaFileDC::Close(void)
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wxMetaFileDC::SetMapMode(int mode)
 | 
			
		||||
void wxMetafileDC::SetMapMode(int mode)
 | 
			
		||||
{
 | 
			
		||||
  m_mappingMode = mode;
 | 
			
		||||
 | 
			
		||||
@@ -271,12 +308,12 @@ struct mfPLACEABLEHEADER {
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
bool wxMakeMetaFilePlaceable(const wxString& filename, float scale)
 | 
			
		||||
bool wxMakeMetafilePlaceable(const wxString& filename, float scale)
 | 
			
		||||
{
 | 
			
		||||
  return wxMakeMetaFilePlaceable(filename, 0, 0, 0, 0, scale, FALSE);
 | 
			
		||||
  return wxMakeMetafilePlaceable(filename, 0, 0, 0, 0, scale, FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent)
 | 
			
		||||
bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale, bool useOriginAndExtent)
 | 
			
		||||
{
 | 
			
		||||
  // I'm not sure if this is the correct way of suggesting a scale
 | 
			
		||||
  // to the client application, but it's the only way I can find.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user