X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/794fe8cd2ff46a78b37cde13ac75cd5f1fb44b4c..ad653fa23069c5d9378247084f03c9a718c3ad62:/src/msw/clipbrd.cpp diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index 8955fe8840..bd929dcac3 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: clipbrd.cpp +// Name: src/msw/clipbrd.cpp // Purpose: Clipboard functionality // Author: Julian Smart // Modified by: @@ -17,10 +17,6 @@ // headers // --------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "clipbrd.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -30,6 +26,8 @@ #if wxUSE_CLIPBOARD +#include "wx/clipbrd.h" + #ifndef WX_PRECOMP #include "wx/object.h" #include "wx/event.h" @@ -38,14 +36,14 @@ #include "wx/bitmap.h" #include "wx/utils.h" #include "wx/intl.h" + #include "wx/log.h" + #include "wx/dataobj.h" #endif #if wxUSE_METAFILE #include "wx/metafile.h" #endif -#include "wx/log.h" -#include "wx/clipbrd.h" #include @@ -60,10 +58,6 @@ // the functions using wxDataObject in wxClipboard //#define wxUSE_DATAOBJ wxUSE_DRAG_AND_DROP -#if wxUSE_DATAOBJ - #include "wx/dataobj.h" -#endif - #if wxUSE_OLE && !defined(__WXWINCE__) // use OLE clipboard #define wxUSE_OLE_CLIPBOARD 1 @@ -85,6 +79,7 @@ // --------------------------------------------------------------------------- static bool gs_wxClipboardIsOpen = false; +static int gs_htmlcfid = 0; bool wxOpenClipboard() { @@ -96,13 +91,15 @@ bool wxOpenClipboard() gs_wxClipboardIsOpen = ::OpenClipboard((HWND)win->GetHWND()) != 0; if ( !gs_wxClipboardIsOpen ) + { wxLogSysError(_("Failed to open the clipboard.")); + } return gs_wxClipboardIsOpen; } else { - wxLogDebug(wxT("Can not open clipboard without a main window.")); + wxLogDebug(wxT("Cannot open clipboard without a main window.")); return false; } @@ -143,7 +140,9 @@ bool wxIsClipboardOpened() bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat) { - wxDataFormat::NativeFormat cf = dataFormat.GetFormatId(); + wxDataFormat::NativeFormat cf = dataFormat.GetFormatId(); + if (cf == wxDF_HTML) + cf = gs_htmlcfid; if ( ::IsClipboardFormatAvailable(cf) ) { @@ -218,7 +217,7 @@ bool wxSetClipboardData(wxDataFormat dataFormat, { wxBitmap *bitmap = (wxBitmap *)data; - if ( bitmap && bitmap->Ok() ) + if ( bitmap && bitmap->IsOk() ) { wxDIB dib(*bitmap); if ( dib.IsOk() ) @@ -298,8 +297,8 @@ bool wxSetClipboardData(wxDataFormat dataFormat, handle = SetClipboardData(dataFormat, hGlobalMemory); break; } - // Only tested with non-Unicode, Visual C++ 6.0 so far -#if defined(__VISUALC__) && !defined(UNICODE) + // Only tested with Visual C++ 6.0 so far +#if defined(__VISUALC__) case wxDF_HTML: { char* html = (char *)data; @@ -308,10 +307,6 @@ bool wxSetClipboardData(wxDataFormat dataFormat, char *buf = new char [400 + strlen(html)]; if(!buf) return false; - // Get clipboard id for HTML format... - static int cfid = 0; - if(!cfid) cfid = RegisterClipboardFormat(wxT("HTML Format")); - // Create a template string for the HTML header... strcpy(buf, "Version:0.9\r\n" @@ -336,19 +331,19 @@ bool wxSetClipboardData(wxDataFormat dataFormat, // string when you overwrite it so you follow up with code to replace // the 0 appended at the end with a '\r'... char *ptr = strstr(buf, "StartHTML"); - wsprintf(ptr+10, "%08u", strstr(buf, "") - buf); + sprintf(ptr+10, "%08u", (unsigned)(strstr(buf, "") - buf)); *(ptr+10+8) = '\r'; ptr = strstr(buf, "EndHTML"); - wsprintf(ptr+8, "%08u", strlen(buf)); + sprintf(ptr+8, "%08u", (unsigned)strlen(buf)); *(ptr+8+8) = '\r'; ptr = strstr(buf, "StartFragment"); - wsprintf(ptr+14, "%08u", strstr(buf, "