From: Julian Smart Date: Wed, 17 Apr 2002 11:48:11 +0000 (+0000) Subject: Added wxDF_HTML X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/387ebd3eb755ea6ca076708cfb25fe56249bf787 Added wxDF_HTML Added VC++/non-Unicode for setting HTML clipboard data Changed FloodFill to return a bool value git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/dataform.tex b/docs/latex/wx/dataform.tex index 292c086835..bf80cd95d0 100644 --- a/docs/latex/wx/dataform.tex +++ b/docs/latex/wx/dataform.tex @@ -29,6 +29,8 @@ functions taking a wxDataFormat argument sometimes} \twocolitem{wxDF\_BITMAP}{A bitmap (wxBitmap)} \twocolitem{wxDF\_METAFILE}{A metafile (wxMetafile, Windows only)} \twocolitem{wxDF\_FILENAME}{A list of filenames} +\twocolitem{wxDF\_HTML}{An HTML string. This is only valid when passed to wxSetClipboardData +when compiled with Visual C++ in non-Unicode mode} \end{twocollist} As mentioned above, these standard formats may be passed to any function taking diff --git a/docs/latex/wx/dc.tex b/docs/latex/wx/dc.tex index dc731b363d..caf0d997ae 100644 --- a/docs/latex/wx/dc.tex +++ b/docs/latex/wx/dc.tex @@ -487,7 +487,7 @@ Ends a document page (only relevant when outputting to a printer). \membersection{wxDC::FloodFill}\label{wxdcfloodfill} -\func{void}{FloodFill}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{const wxColour\&}{ colour}, \param{int}{ style=wxFLOOD\_SURFACE}} +\func{bool}{FloodFill}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{const wxColour\&}{ colour}, \param{int}{ style=wxFLOOD\_SURFACE}} Flood fills the device context starting from the given point, using the {\it current brush colour}, and using a style: @@ -497,8 +497,11 @@ the {\it current brush colour}, and using a style: \item wxFLOOD\_BORDER: the area to be flooded is bounded by the given colour. \end{itemize} +Returns FALSE if the operation failed. + {\it Note:} The present implementation for non-Windows platforms may fail to find -colour borders if the pixels do not match the colour exactly. +colour borders if the pixels do not match the colour exactly. However the +function will still return TRUE. \membersection{wxDC::GetBackground}\label{wxdcgetbackground} diff --git a/docs/latex/wx/valtext.tex b/docs/latex/wx/valtext.tex index c3c286ecc5..0973e9df20 100644 --- a/docs/latex/wx/valtext.tex +++ b/docs/latex/wx/valtext.tex @@ -48,7 +48,7 @@ checks if the user input is on the list, complaining if not.} checks if the user input is on the list, complaining if it is.} \twocolitem{{\bf wxFILTER\_INCLUDE\_CHAR\_LIST}}{Use an include list. The validator checks if each input character is in the list (one character per list element), complaining if not.} -\twocolitem{{\bf wxFILTER\_INCLUDE\_CHAR\_LIST}}{Use an include list. The validator +\twocolitem{{\bf wxFILTER\_EXCLUDE\_CHAR\_LIST}}{Use an include list. The validator checks if each input character is in the list (one character per list element), complaining if it is.} \end{twocollist} } diff --git a/include/wx/dc.h b/include/wx/dc.h index 8366a5c479..c14bbea8ae 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -147,12 +147,12 @@ public: CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); } - void FloodFill(wxCoord x, wxCoord y, const wxColour& col, + bool FloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE) - { DoFloodFill(x, y, col, style); } - void FloodFill(const wxPoint& pt, const wxColour& col, + { return DoFloodFill(x, y, col, style); } + bool FloodFill(const wxPoint& pt, const wxColour& col, int style = wxFLOOD_SURFACE) - { DoFloodFill(pt.x, pt.y, col, style); } + { return DoFloodFill(pt.x, pt.y, col, style); } bool GetPixel(wxCoord x, wxCoord y, wxColour *col) const { return DoGetPixel(x, y, col); } @@ -607,7 +607,7 @@ public: protected: // the pure virtual functions which should be implemented by wxDC - virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE) = 0; virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const = 0; diff --git a/include/wx/defs.h b/include/wx/defs.h index 80b4fbb845..a3ea865ebd 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1463,6 +1463,7 @@ enum wxDataFormatId wxDF_FILENAME = 15, /* CF_HDROP */ wxDF_LOCALE = 16, wxDF_PRIVATE = 20, + wxDF_HTML = 30, /* Note: does not correspond to CF_ constant */ wxDF_MAX }; diff --git a/include/wx/dragimag.h b/include/wx/dragimag.h index 0cee7e64cc..097edaacd3 100644 --- a/include/wx/dragimag.h +++ b/include/wx/dragimag.h @@ -3,6 +3,10 @@ #if wxUSE_DRAGIMAGE +class WXDLLEXPORT wxRect; +class WXDLLEXPORT wxMemoryDC; +class WXDLLEXPORT wxDC; + #if defined(__WXMSW__) #ifdef __WIN16__ #include "wx/generic/dragimgg.h" diff --git a/include/wx/generic/dcpsg.h b/include/wx/generic/dcpsg.h index fb1b61bce2..bbfcbba912 100644 --- a/include/wx/generic/dcpsg.h +++ b/include/wx/generic/dcpsg.h @@ -62,7 +62,7 @@ public: virtual void BeginDrawing() {} virtual void EndDrawing() {} - void DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); + bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE ); bool DoGetPixel(wxCoord x1, wxCoord y1, wxColour *col) const; void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index 77331532da..ab21e69e4a 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -42,7 +42,7 @@ public: protected: virtual void DoGetSize(int *width, int *height) const; - virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); + virtual bool DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const; virtual void DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ); diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h index 77331532da..ab21e69e4a 100644 --- a/include/wx/gtk1/dcclient.h +++ b/include/wx/gtk1/dcclient.h @@ -42,7 +42,7 @@ public: protected: virtual void DoGetSize(int *width, int *height) const; - virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); + virtual bool DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const; virtual void DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ); diff --git a/include/wx/mac/dc.h b/include/wx/mac/dc.h index cfc9958cf8..ead1ae68d9 100644 --- a/include/wx/mac/dc.h +++ b/include/wx/mac/dc.h @@ -189,7 +189,7 @@ class WXDLLEXPORT wxDC: public wxDCBase // protected: - virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; diff --git a/include/wx/mgl/dc.h b/include/wx/mgl/dc.h index d1559dc4ae..9e0cccd454 100644 --- a/include/wx/mgl/dc.h +++ b/include/wx/mgl/dc.h @@ -167,7 +167,7 @@ public: void SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC = FALSE); protected: - virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; diff --git a/include/wx/motif/dcclient.h b/include/wx/motif/dcclient.h index ec974c1bb3..5288b91763 100644 --- a/include/wx/motif/dcclient.h +++ b/include/wx/motif/dcclient.h @@ -90,7 +90,7 @@ public: void SetAutoSetting(bool flag) { m_autoSetting = flag; } protected: - virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index f28ffedd8d..dde2cf4246 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -135,7 +135,7 @@ public: #endif protected: - virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE); virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; diff --git a/include/wx/os2/dc.h b/include/wx/os2/dc.h index 87d00092a2..c3d383cd2a 100644 --- a/include/wx/os2/dc.h +++ b/include/wx/os2/dc.h @@ -202,7 +202,7 @@ public: #endif protected: - virtual void DoFloodFill( wxCoord vX + virtual bool DoFloodFill( wxCoord vX ,wxCoord vY ,const wxColour& rCol ,int nStyle = wxFLOOD_SURFACE diff --git a/include/wx/x11/dcclient.h b/include/wx/x11/dcclient.h index 0b35e74731..ce76814dca 100644 --- a/include/wx/x11/dcclient.h +++ b/include/wx/x11/dcclient.h @@ -46,7 +46,7 @@ public: protected: virtual void DoGetSize(int *width, int *height) const; - virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE ); + virtual bool DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style = wxFLOOD_SURFACE ); virtual bool DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const; virtual void DoDrawPoint(wxCoord x, wxCoord y); diff --git a/src/common/imagfill.cpp b/src/common/imagfill.cpp index b5a6c66a53..a3d595ccff 100644 --- a/src/common/imagfill.cpp +++ b/src/common/imagfill.cpp @@ -273,11 +273,11 @@ wxImageFloodFill(wxImage *image, } -void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour& col, int style) { if (dc->GetBrush().GetStyle() == wxTRANSPARENT) - return; + return TRUE; int height = 0; int width = 0; @@ -285,6 +285,9 @@ void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, //it would be nice to fail if we don't get a sensible size... wxCHECK_RET(width >= 1 && height >= 1, wxT("In FloodFill, dc.GetSize routine failed, method not supported by this DC")); + + if (width <= 1 || height <= 1) + return FALSE; //this is much faster than doing the individual pixels wxMemoryDC memdc; @@ -300,6 +303,8 @@ void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, memdc.SelectObject(bitmap); dc->Blit(0, 0, width, height, &memdc, 0, 0); memdc.SelectObject(wxNullBitmap); + + return TRUE; } #endif // wxUSE_IMAGE diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index a81806e5ac..359d8aafa6 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -441,9 +441,10 @@ void wxPostScriptDC::Clear() wxFAIL_MSG( wxT("wxPostScriptDC::Clear not implemented.") ); } -void wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) +bool wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) { wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") ); + return FALSE; } bool wxPostScriptDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 8ed9bff19b..fc69b408a9 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -401,13 +401,13 @@ void wxWindowDC::DoGetSize( int* width, int* height ) const m_owner->GetSize(width, height); } -extern void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -void wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(this, x, y, col, style); } bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 8ed9bff19b..fc69b408a9 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -401,13 +401,13 @@ void wxWindowDC::DoGetSize( int* width, int* height ) const m_owner->GetSize(width, height); } -extern void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -void wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(this, x, y, col, style); } bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 5778b90b07..0b9ac3ab1e 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -649,13 +649,13 @@ void wxDC::SetLogicalFunction( int function ) m_macPenInstalled = false ; } -extern void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -void wxDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(this, x, y, col, style); } bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 5778b90b07..0b9ac3ab1e 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -649,13 +649,13 @@ void wxDC::SetLogicalFunction( int function ) m_macPenInstalled = false ; } -extern void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -void wxDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(this, x, y, col, style); } bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp index 2409fcaaa2..410e1b4016 100644 --- a/src/mgl/dc.cpp +++ b/src/mgl/dc.cpp @@ -332,13 +332,13 @@ void wxDC::Clear() } } -extern void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -void wxDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(this, x, y, col, style); } bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index a5e57af9d1..7c1602b346 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -231,13 +231,13 @@ wxWindowDC::~wxWindowDC() m_userRegion = (WXRegion) 0; } -extern void wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, +extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, const wxColour & col, int style); -void wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, +bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) { - wxDoFloodFill(this, x, y, col, style); + return wxDoFloodFill(this, x, y, col, style); } bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const diff --git a/src/msw/clipbrd.cpp b/src/msw/clipbrd.cpp index a3b4611af4..7f07e896eb 100644 --- a/src/msw/clipbrd.cpp +++ b/src/msw/clipbrd.cpp @@ -298,6 +298,80 @@ 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) + case wxDF_HTML: + { + char* html = (char *)data; + + // Create temporary buffer for HTML header... + 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" + "StartHTML:00000000\r\n" + "EndHTML:00000000\r\n" + "StartFragment:00000000\r\n" + "EndFragment:00000000\r\n" + "\r\n" + "\r\n"); + + // Append the HTML... + strcat(buf, html); + strcat(buf, "\r\n"); + // Finish up the HTML format... + strcat(buf, + "\r\n" + "\r\n" + ""); + + // Now go back, calculate all the lengths, and write out the + // necessary header information. Note, wsprintf() truncates the + // 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); + *(ptr+10+8) = '\r'; + + ptr = strstr(buf, "EndHTML"); + wsprintf(ptr+8, "%08u", strlen(buf)); + *(ptr+8+8) = '\r'; + + ptr = strstr(buf, "StartFragment"); + wsprintf(ptr+14, "%08u", strstr(buf, "