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
This commit is contained in:
Julian Smart
2002-04-17 11:48:11 +00:00
parent 4101db8100
commit 387ebd3eb7
28 changed files with 142 additions and 47 deletions

View File

@@ -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

View File

@@ -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}

View File

@@ -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}
}

View File

@@ -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;

View File

@@ -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
};

View File

@@ -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"

View File

@@ -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);

View File

@@ -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 );

View File

@@ -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 );

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
@@ -286,6 +286,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;
wxBitmap bitmap(width, height);
@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"
"<html><body>\r\n"
"<!--StartFragment -->\r\n");
// Append the HTML...
strcat(buf, html);
strcat(buf, "\r\n");
// Finish up the HTML format...
strcat(buf,
"<!--EndFragment-->\r\n"
"</body>\r\n"
"</html>");
// 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, "<html>") - 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, "<!--StartFrag") - buf);
*(ptr+14+8) = '\r';
ptr = strstr(buf, "EndFragment");
wsprintf(ptr+12, "%08u", strstr(buf, "<!--EndFrag") - buf);
*(ptr+12+8) = '\r';
// Now you have everything in place ready to put on the
// clipboard.
// Allocate global memory for transfer...
HGLOBAL hText = GlobalAlloc(GMEM_MOVEABLE |GMEM_DDESHARE, strlen(buf)+4);
// Put your string in the global memory...
ptr = (char *)GlobalLock(hText);
strcpy(ptr, buf);
GlobalUnlock(hText);
handle = ::SetClipboardData(cfid, hText);
// Free memory...
GlobalFree(hText);
// Clean up...
delete [] buf;
break;
}
#endif
}
if ( handle == 0 )

View File

@@ -468,16 +468,17 @@ void wxDC::Clear()
::SetWindowOrgEx(GetHdc(), (int)m_logicalOriginX, (int)m_logicalOriginY, NULL);
}
void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
{
#ifdef __WXMICROWIN__
if (!GetHDC()) return;
if (!GetHDC()) return FALSE;
#endif
if ( !::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
bool success = (0 != ::ExtFloodFill(GetHdc(), XLOG2DEV(x), YLOG2DEV(y),
col.GetPixel(),
style == wxFLOOD_SURFACE ? FLOODFILLSURFACE
: FLOODFILLBORDER) )
: FLOODFILLBORDER) ) ;
if (!success)
{
// quoting from the MSDN docs:
//
@@ -495,6 +496,8 @@ void wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style)
}
CalcBoundingBox(x, y);
return success;
}
bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const

View File

@@ -557,7 +557,7 @@ void wxDC::Clear()
::GpiErase(m_hPS);
} // end of wxDC::Clear
void wxDC::DoFloodFill(
bool wxDC::DoFloodFill(
wxCoord vX
, wxCoord vY
, const wxColour& rCol
@@ -577,6 +577,8 @@ void wxDC::DoFloodFill(
lOptions = FF_SURFACE;
::GpiFloodFill(m_hPS, lOptions, lColor);
return TRUE;
} // end of wxDC::DoFloodFill
bool wxDC::DoGetPixel(

View File

@@ -512,7 +512,7 @@ void wxControlRenderer::DrawBitmap(wxDC &dc,
else if ( stretch & wxEXPAND )
{
// stretch bitmap to fill the entire control
bmp = wxImage(bmp.ConvertToImage()).Scale(rect.width, rect.height);
bmp = wxBitmap(wxImage(bmp.ConvertToImage()).Scale(rect.width, rect.height));
}
else // not stretched, not tiled
{

View File

@@ -313,13 +313,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