From 6e76b35d73fb5a043fd39af266bd452a6e20a861 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 7 Feb 2004 13:12:31 +0000 Subject: [PATCH 1/1] added wxDC::DrawPolyPolygon() (patch 882189) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25549 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 8 ++-- docs/latex/wx/dc.tex | 90 +++++++++++++++++++++++++++++++++++++++++++ include/wx/dc.h | 8 ++++ include/wx/msw/dc.h | 3 ++ src/generic/dcpsg.cpp | 70 ++++++++++++++++++++++++++++++++- src/msw/dc.cpp | 44 +++++++++++++++++++++ 6 files changed, 216 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 1f5ac83fc4..ebac708f26 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -33,6 +33,7 @@ INCOMPATIBLE CHANGES SINCE 2.4.x - wxApp::SendIdleEvent() now takes 2 arguments - wxTabView::GetLayers() changed return type from wxList& to wxTabLayerList& (when WXWIN_COMPATIBILITY_2_4 == 0) +- wxID_SEPARATOR (id used for the menu separators) value changed from -1 to -2 DEPRECATED METHODS SINCE 2.4.x @@ -122,12 +123,9 @@ All (GUI): - added wxStatusBar support to XRC (Brian Ravnsgaard Riis) - wxMenu::Append and etc. return a pointer to the wxMenuItem that was added or inserted, or NULL on failure. -- Using a -1 (wxID_ANY) for menu or toolbar item IDs will now generate - a new ID for the item using wxNewId(). As a consequence of this, - the value of wxID_SEPARATOR was changed from -1 to -2 in order to - not clash. +- using a -1 (wxID_ANY) for menu or toolbar item IDs will now generate new id - added option to generate C++ headers to wxrc utility (Eduardo Marques) - +- added wxDC::DrawPolyPolygon() for MSW/PS (Carl-Friedrich Braun) wxMSW: diff --git a/docs/latex/wx/dc.tex b/docs/latex/wx/dc.tex index 2dd9b7bb37..43b3a36bb8 100644 --- a/docs/latex/wx/dc.tex +++ b/docs/latex/wx/dc.tex @@ -30,18 +30,21 @@ them. \latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxDC::wxDC} \func{}{wxDC}{\void} Constructor. + \membersection{wxDC::\destruct{wxDC}} \func{}{\destruct{wxDC}}{\void} Destructor. + \membersection{wxDC::BeginDrawing}\label{wxdcbegindrawing} \func{void}{BeginDrawing}{\void} @@ -57,6 +60,7 @@ a retained device context associated with it, and selections such as pen and brush settings would be lost if the device context were obtained and released for each drawing operation. + \membersection{wxDC::Blit}\label{wxdcblit} \func{bool}{Blit}{\param{wxCoord}{ xdest}, \param{wxCoord}{ ydest}, \param{wxCoord}{ width}, \param{wxCoord}{ height}, @@ -129,6 +133,7 @@ See \helpref{wxMemoryDC}{wxmemorydc} for typical usage. \helpref{wxMemoryDC}{wxmemorydc}, \helpref{wxBitmap}{wxbitmap}, \helpref{wxMask}{wxmask} \begin{comment} + \membersection{wxDC::CacheEnabled}\label{wxdccacheenabled} \func{static bool}{CacheEnabled}{\void} @@ -146,6 +151,7 @@ wxUSE\_DC\_CACHEING preprocessor symbol for portability. \helpref{wxDC::EnableCache}{wxdcenablecache}, \helpref{wxDC::ClearCache} \end{comment} + \membersection{wxDC::CalcBoundingBox}\label{wxdccalcboundingbox} \func{void}{CalcBoundingBox}{\param{wxCoord }{x}, \param{wxCoord }{y}} @@ -158,6 +164,7 @@ Adds the specified point to the bounding box which can be retrieved with \helpref{ResetBoundingBox}{wxdcresetboundingbox} + \membersection{wxDC::Clear}\label{wxdcclear} \func{void}{Clear}{\void} @@ -165,6 +172,7 @@ Adds the specified point to the bounding box which can be retrieved with Clears the device context using the current background brush. \begin{comment} + \membersection{wxDC::ClearCache}\label{wxdcclearcache} \func{static void}{ClearCache}{\void} @@ -184,6 +192,7 @@ wxUSE\_DC\_CACHEING preprocessor symbol for portability. \helpref{wxDC::EnableCache}{wxdcenablecache}, \helpref{wxDC::CacheEnabled} \end{comment} + \membersection{wxDC::CrossHair}\label{wxdccrosshair} \func{void}{CrossHair}{\param{wxCoord}{ x}, \param{wxCoord}{ y}} @@ -192,6 +201,7 @@ Displays a cross hair using the current pen. This is a vertical and horizontal line the height and width of the window, centred on the given point. + \membersection{wxDC::DestroyClippingRegion}\label{wxdcdestroyclippingregion} \func{void}{DestroyClippingRegion}{\void} @@ -199,6 +209,7 @@ on the given point. Destroys the current clipping region so that none of the DC is clipped. See also \helpref{wxDC::SetClippingRegion}{wxdcsetclippingregion}. + \membersection{wxDC::DeviceToLogicalX}\label{wxdcdevicetologicalx} \func{wxCoord}{DeviceToLogicalX}{\param{wxCoord}{ x}} @@ -206,6 +217,7 @@ See also \helpref{wxDC::SetClippingRegion}{wxdcsetclippingregion}. Convert device X coordinate to logical coordinate, using the current mapping mode. + \membersection{wxDC::DeviceToLogicalXRel}\label{wxdcdevicetologicalxrel} \func{wxCoord}{DeviceToLogicalXRel}{\param{wxCoord}{ x}} @@ -214,6 +226,7 @@ Convert device X coordinate to relative logical coordinate, using the current mapping mode but ignoring the x axis orientation. Use this function for converting a width, for example. + \membersection{wxDC::DeviceToLogicalY}\label{wxdcdevicetologicaly} \func{wxCoord}{DeviceToLogicalY}{\param{wxCoord}{ y}} @@ -221,6 +234,7 @@ Use this function for converting a width, for example. Converts device Y coordinate to logical coordinate, using the current mapping mode. + \membersection{wxDC::DeviceToLogicalYRel}\label{wxdcdevicetologicalyrel} \func{wxCoord}{DeviceToLogicalYRel}{\param{wxCoord}{ y}} @@ -229,6 +243,7 @@ Convert device Y coordinate to relative logical coordinate, using the current mapping mode but ignoring the y axis orientation. Use this function for converting a height, for example. + \membersection{wxDC::DrawArc}\label{wxdcdrawarc} \func{void}{DrawArc}{\param{wxCoord}{ x1}, \param{wxCoord}{ y1}, \param{wxCoord}{ x2}, \param{wxCoord}{ y2}, \param{wxCoord}{ xc}, \param{wxCoord}{ yc}} @@ -239,6 +254,7 @@ and the current brush for filling the shape. The arc is drawn in an anticlockwise direction from the start point to the end point. + \membersection{wxDC::DrawBitmap}\label{wxdcdrawbitmap} \func{void}{DrawBitmap}{\param{const wxBitmap\&}{ bitmap}, \param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{bool}{ transparent}} @@ -251,6 +267,7 @@ of the bitmap (all bits set to 1), and the current text background colour to dra (all bits set to 0). See also \helpref{SetTextForeground}{wxdcsettextforeground}, \helpref{SetTextBackground}{wxdcsettextbackground} and \helpref{wxMemoryDC}{wxmemorydc}. + \membersection{wxDC::DrawCheckMark}\label{wxdcdrawcheckmark} \func{void}{DrawCheckMark}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} @@ -259,6 +276,7 @@ of the bitmap (all bits set to 1), and the current text background colour to dra Draws a check mark inside the given rectangle. + \membersection{wxDC::DrawCircle}\label{wxdcdrawcircle} \func{void}{DrawCircle}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ radius}} @@ -271,6 +289,7 @@ Draws a circle with the given centre and radius. \helpref{DrawEllipse}{wxdcdrawellipse} + \membersection{wxDC::DrawEllipse}\label{wxdcdrawellipse} \func{void}{DrawEllipse}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} @@ -287,6 +306,7 @@ outline and the current brush for filling the shape. \helpref{DrawCircle}{wxdcdrawcircle} + \membersection{wxDC::DrawEllipticArc}\label{wxdcdrawellipticarc} \func{void}{DrawEllipticArc}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}, @@ -307,6 +327,7 @@ in degrees (360 is a complete circle). Positive values mean counter-clockwise motion. If {\it start} is equal to {\it end}, a complete ellipse will be drawn. + \membersection{wxDC::DrawIcon}\label{wxdcdrawicon} \func{void}{DrawIcon}{\param{const wxIcon\&}{ icon}, \param{wxCoord}{ x}, \param{wxCoord}{ y}} @@ -314,6 +335,7 @@ complete ellipse will be drawn. Draw an icon on the display (does nothing if the device context is PostScript). This can be the simplest way of drawing bitmaps on a window. + \membersection{wxDC::DrawLine}\label{wxdcdrawline} \func{void}{DrawLine}{\param{wxCoord}{ x1}, \param{wxCoord}{ y1}, \param{wxCoord}{ x2}, \param{wxCoord}{ y2}} @@ -323,6 +345,7 @@ for drawing the line. Note that the point $(x2, y2)$ is {\emph not} part of the line and is not drawn by this function (this is consistent with the behaviour of many other toolkits). + \membersection{wxDC::DrawLines}\label{wxdcdrawlines} \func{void}{DrawLines}{\param{int}{ n}, \param{wxPoint}{ points[]}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0}} @@ -341,6 +364,7 @@ of wxPoint objects.} as its first parameter a reference to an array of wxPoint objects.} + \membersection{wxDC::DrawPolygon}\label{wxdcdrawpolygon} \func{void}{DrawPolygon}{\param{int}{ n}, \param{wxPoint}{ points[]}, \param{wxCoord}{ xoffset = 0}, \param{wxCoord}{ yoffset = 0},\\ @@ -368,12 +392,23 @@ of wxPoint objects.} as its first parameter a reference to an array of wxPoint objects.} + +\membersection{wxDC::DrawPolyPolygon}\label{wxdcdrawpolypolygon} + +\func{void}{DrawPolyPolygon}{\param{int }{n}, \param{int }{start\[\]}, \param{wxPoint }{points\[\]}, \param{wxCoord }{xoffset}, \param{wxCoord }{yoffset}, \param{int }{fillStyle = \texttt{wxODDEVEN\_RULE}}} + +Draw many polygons at once. For the platforms providing a native implementation +of this function (Windows and PostScript-based wxDC), this is more efficient +than using \helpref{DrawPolygon}{wxdcdrawpolygon} in a loop. + + \membersection{wxDC::DrawPoint}\label{wxdcdrawpoint} \func{void}{DrawPoint}{\param{wxCoord}{ x}, \param{wxCoord}{ y}} Draws a point using the current pen. + \membersection{wxDC::DrawRectangle}\label{wxdcdrawrectangle} \func{void}{DrawRectangle}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} @@ -382,6 +417,7 @@ Draws a rectangle with the given top left corner, and with the given size. The current pen is used for the outline and the current brush for filling the shape. + \membersection{wxDC::DrawRotatedText}\label{wxdcdrawrotatedtext} \func{void}{DrawRotatedText}{\param{const wxString\& }{text}, \param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{double}{ angle}} @@ -397,6 +433,7 @@ which is. \helpref{DrawText}{wxdcdrawtext} + \membersection{wxDC::DrawRoundedRectangle}\label{wxdcdrawroundedrectangle} \func{void}{DrawRoundedRectangle}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}, \param{double}{ radius = 20}} @@ -414,6 +451,7 @@ a sensible size relative to the size of the rectangle, and also avoids the strange effects X produces when the corners are too big for the rectangle. + \membersection{wxDC::DrawSpline}\label{wxdcdrawspline} \func{void}{DrawSpline}{\param{wxList *}{points}} @@ -433,6 +471,7 @@ of wxPoint objects.} \perlnote{The wxPerl version of this method accepts a reference to an array of wxPoint objects.} + \membersection{wxDC::DrawText}\label{wxdcdrawtext} \func{void}{DrawText}{\param{const wxString\& }{text}, \param{wxCoord}{ x}, \param{wxCoord}{ y}} @@ -451,6 +490,7 @@ but it is ignored by wxMSW. Thus, you should avoid using logical functions with this function in portable programs. \begin{comment} + \membersection{wxDC::EnableCache}\label{wxdcenablecache} \func{static void}{EnableCache}{\param{bool}{ enableCache}} @@ -467,12 +507,14 @@ wxUSE\_DC\_CACHEING preprocessor symbol for portability. \helpref{wxDC::CacheEnabled}{wxdccacheenabled}, \helpref{wxDC::ClearCache} \end{comment} + \membersection{wxDC::EndDoc}\label{wxdcenddoc} \func{void}{EndDoc}{\void} Ends a document (only relevant when outputting to a printer). + \membersection{wxDC::EndDrawing}\label{wxdcenddrawing} \func{void}{EndDrawing}{\void} @@ -481,12 +523,14 @@ Allows optimization of drawing code under MS Windows. Enclose drawing primitives between {\bf BeginDrawing} and {\bf EndDrawing}\rtfsp calls. + \membersection{wxDC::EndPage}\label{wxdcendpage} \func{void}{EndPage}{\void} Ends a document page (only relevant when outputting to a printer). + \membersection{wxDC::FloodFill}\label{wxdcfloodfill} \func{bool}{FloodFill}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{const wxColour\&}{ colour}, \param{int}{ style=wxFLOOD\_SURFACE}} @@ -505,6 +549,7 @@ Returns false if the operation failed. colour borders if the pixels do not match the colour exactly. However the function will still return true. + \membersection{wxDC::GetBackground}\label{wxdcgetbackground} \func{wxBrush\&}{GetBackground}{\void} @@ -513,6 +558,7 @@ function will still return true. Gets the brush used for painting the background (see \helpref{wxDC::SetBackground}{wxdcsetbackground}). + \membersection{wxDC::GetBackgroundMode}\label{wxdcgetbackgroundmode} \constfunc{int}{GetBackgroundMode}{\void} @@ -523,6 +569,7 @@ Returns the current background mode: {\tt wxSOLID} or {\tt wxTRANSPARENT}. \helpref{SetBackgroundMode}{wxdcsetbackgroundmode} + \membersection{wxDC::GetBrush}\label{wxdcgetbrush} \func{wxBrush\&}{GetBrush}{\void} @@ -531,18 +578,21 @@ Returns the current background mode: {\tt wxSOLID} or {\tt wxTRANSPARENT}. Gets the current brush (see \helpref{wxDC::SetBrush}{wxdcsetbrush}). + \membersection{wxDC::GetCharHeight}\label{wxdcgetcharheight} \func{wxCoord}{GetCharHeight}{\void} Gets the character height of the currently set font. + \membersection{wxDC::GetCharWidth}\label{wxdcgetcharwidth} \func{wxCoord}{GetCharWidth}{\void} Gets the average character width of the currently set font. + \membersection{wxDC::GetClippingBox}\label{wxdcgetclippingbox} \func{void}{GetClippingBox}{\param{wxCoord}{ *x}, \param{wxCoord}{ *y}, \param{wxCoord}{ *width}, \param{wxCoord}{ *height}} @@ -555,6 +605,7 @@ rectangle are returned as a tuple.} \perlnote{This method takes no arguments and returns a four element list {\tt ( x, y, width, height )}} + \membersection{wxDC::GetFont}\label{wxdcgetfont} \func{wxFont\&}{GetFont}{\void} @@ -563,18 +614,21 @@ rectangle are returned as a tuple.} Gets the current font (see \helpref{wxDC::SetFont}{wxdcsetfont}). + \membersection{wxDC::GetLogicalFunction}\label{wxdcgetlogicalfunction} \func{int}{GetLogicalFunction}{\void} Gets the current logical function (see \helpref{wxDC::SetLogicalFunction}{wxdcsetlogicalfunction}). + \membersection{wxDC::GetMapMode}\label{wxdcgetmapmode} \func{int}{GetMapMode}{\void} Gets the {\it mapping mode} for the device context (see \helpref{wxDC::SetMapMode}{wxdcsetmapmode}). + \membersection{wxDC::GetOptimization}\label{wxdcgetoptimization} \func{bool}{GetOptimization}{\void} @@ -582,6 +636,7 @@ Gets the {\it mapping mode} for the device context (see \helpref{wxDC::SetMapMod Returns true if device context optimization is on. See \helpref{wxDC::SetOptimization}{wxsetoptimization} for details. + \membersection{wxDC::GetPen}\label{wxdcgetpen} \func{wxPen\&}{GetPen}{\void} @@ -590,6 +645,7 @@ See \helpref{wxDC::SetOptimization}{wxsetoptimization} for details. Gets the current pen (see \helpref{wxDC::SetPen}{wxdcsetpen}). + \membersection{wxDC::GetPixel}\label{wxdcgetpixel} \func{bool}{GetPixel}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxColour *}{colour}} @@ -603,6 +659,7 @@ required as a parameter.} \perlnote{This method only takes the parameters {\tt x} and {\tt y} and returns a Wx::Colour value} + \membersection{wxDC::GetSize}\label{wxdcgetsize} \func{void}{GetSize}{\param{wxCoord *}{width}, \param{wxCoord *}{height}} @@ -641,6 +698,7 @@ implements the following methods:\par \end{twocollist} }} + \membersection{wxDC::GetTextBackground}\label{wxdcgettextbackground} \func{wxColour\&}{GetTextBackground}{\void} @@ -649,6 +707,7 @@ implements the following methods:\par Gets the current text background colour (see \helpref{wxDC::SetTextBackground}{wxdcsettextbackground}). + \membersection{wxDC::GetTextExtent}\label{wxdcgettextextent} \func{void}{GetTextExtent}{\param{const wxString\& }{string}, \param{wxCoord *}{w}, \param{wxCoord *}{h},\\ @@ -681,6 +740,7 @@ See also \helpref{wxFont}{wxfont}, \helpref{wxDC::SetFont}{wxdcsetfont}. array {\tt ( width, height, descent, externalLeading )} } + \membersection{wxDC::GetTextForeground}\label{wxdcgettextforeground} \func{wxColour\&}{GetTextForeground}{\void} @@ -690,6 +750,7 @@ See also \helpref{wxFont}{wxfont}, \helpref{wxDC::SetFont}{wxdcsetfont}. Gets the current text foreground colour (see \helpref{wxDC::SetTextForeground}{wxdcsettextforeground}). + \membersection{wxDC::GetUserScale}\label{wxdcgetuserscale} \func{void}{GetUserScale}{\param{double}{ *x}, \param{double}{ *y}} @@ -699,6 +760,7 @@ Gets the current user scale factor (set by \helpref{SetUserScale}{wxdcsetusersca \perlnote{In wxPerl this method takes no arguments and return a two element array {\tt ( x, y )}} + \membersection{wxDC::LogicalToDeviceX}\label{wxdclogicaltodevicex} \func{wxCoord}{LogicalToDeviceX}{\param{wxCoord}{ x}} @@ -706,6 +768,7 @@ Gets the current user scale factor (set by \helpref{SetUserScale}{wxdcsetusersca Converts logical X coordinate to device coordinate, using the current mapping mode. + \membersection{wxDC::LogicalToDeviceXRel}\label{wxdclogicaltodevicexrel} \func{wxCoord}{LogicalToDeviceXRel}{\param{wxCoord}{ x}} @@ -714,6 +777,7 @@ Converts logical X coordinate to relative device coordinate, using the current mapping mode but ignoring the x axis orientation. Use this for converting a width, for example. + \membersection{wxDC::LogicalToDeviceY}\label{wxdclogicaltodevicey} \func{wxCoord}{LogicalToDeviceY}{\param{wxCoord}{ y}} @@ -721,6 +785,7 @@ Use this for converting a width, for example. Converts logical Y coordinate to device coordinate, using the current mapping mode. + \membersection{wxDC::LogicalToDeviceYRel}\label{wxdclogicaltodeviceyrel} \func{wxCoord}{LogicalToDeviceYRel}{\param{wxCoord}{ y}} @@ -729,36 +794,42 @@ Converts logical Y coordinate to relative device coordinate, using the current mapping mode but ignoring the y axis orientation. Use this for converting a height, for example. + \membersection{wxDC::MaxX}\label{wxdcmaxx} \func{wxCoord}{MaxX}{\void} Gets the maximum horizontal extent used in drawing commands so far. + \membersection{wxDC::MaxY}\label{wxdcmaxy} \func{wxCoord}{MaxY}{\void} Gets the maximum vertical extent used in drawing commands so far. + \membersection{wxDC::MinX}\label{wxdcminx} \func{wxCoord}{MinX}{\void} Gets the minimum horizontal extent used in drawing commands so far. + \membersection{wxDC::MinY}\label{wxdcminy} \func{wxCoord}{MinY}{\void} Gets the minimum vertical extent used in drawing commands so far. + \membersection{wxDC::Ok}\label{wxdcok} \func{bool}{Ok}{\void} Returns true if the DC is ok to use. + \membersection{wxDC::ResetBoundingBox}\label{wxdcresetboundingbox} \func{void}{ResetBoundingBox}{\void} @@ -770,6 +841,7 @@ doesn't contain anything. \helpref{CalcBoundingBox}{wxdccalcboundingbox} + \membersection{wxDC::SetAxisOrientation}\label{wxdcsetaxisorientation} \func{void}{SetAxisOrientation}{\param{bool}{ xLeftRight}, @@ -787,6 +859,7 @@ left to right orientation, false to invert it.} \docparam{yBottomUp}{True to set the y axis orientation to the natural bottom up orientation, false to invert it.} + \membersection{wxDC::SetDeviceOrigin}\label{wxdcsetdeviceorigin} \func{void}{SetDeviceOrigin}{\param{wxCoord}{ x}, \param{wxCoord}{ y}} @@ -797,12 +870,14 @@ applied). This function may be useful in Windows printing operations for placing a graphic on a page. + \membersection{wxDC::SetBackground}\label{wxdcsetbackground} \func{void}{SetBackground}{\param{const wxBrush\& }{brush}} Sets the current background brush for the DC. + \membersection{wxDC::SetBackgroundMode}\label{wxdcsetbackgroundmode} \func{void}{SetBackgroundMode}{\param{int}{ mode}} @@ -810,6 +885,7 @@ Sets the current background brush for the DC. {\it mode} may be one of wxSOLID and wxTRANSPARENT. This setting determines whether text will be drawn with a background colour or not. + \membersection{wxDC::SetClippingRegion}\label{wxdcsetclippingregion} \func{void}{SetClippingRegion}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} @@ -834,6 +910,7 @@ when only a known area of the screen is damaged. \helpref{wxDC::DestroyClippingRegion}{wxdcdestroyclippingregion}, \helpref{wxRegion}{wxregion} + \membersection{wxDC::SetPalette}\label{wxdcsetpalette} \func{void}{SetPalette}{\param{const wxPalette\& }{palette}} @@ -845,6 +922,7 @@ restored. See \helpref{wxPalette}{wxpalette} for further details. + \membersection{wxDC::SetBrush}\label{wxdcsetbrush} \func{void}{SetBrush}{\param{const wxBrush\& }{brush}} @@ -860,6 +938,7 @@ See also \helpref{wxBrush}{wxbrush}. See also \helpref{wxMemoryDC}{wxmemorydc} for the interpretation of colours when drawing into a monochrome bitmap. + \membersection{wxDC::SetFont}\label{wxdcsetfont} \func{void}{SetFont}{\param{const wxFont\& }{font}} @@ -869,6 +948,7 @@ should not pass {\tt wxNullFont} to this method. See also \helpref{wxFont}{wxfont}. + \membersection{wxDC::SetLogicalFunction}\label{wxdcsetlogicalfunction} \func{void}{SetLogicalFunction}{\param{int}{ function}} @@ -906,6 +986,7 @@ The others combine the current colour and the background using a logical operation. wxINVERT is commonly used for drawing rubber bands or moving outlines, since drawing twice reverts to the original colour. + \membersection{wxDC::SetMapMode}\label{wxdcsetmapmode} \func{void}{SetMapMode}{\param{int}{ int}} @@ -936,6 +1017,7 @@ The mapping mode can be one of the following: \twocolitem{wxMM\_TEXT}{Each logical unit is 1 pixel.} \end{twocollist} + \membersection{wxDC::SetOptimization}\label{wxsetoptimization} \func{void}{SetOptimization}{\param{bool }{optimize}} @@ -950,6 +1032,7 @@ The wxWindows device context 'memory' will now be out of step with reality. Setting optimization off, drawing, then setting it back on again, is a trick that must occasionally be employed. + \membersection{wxDC::SetPen}\label{wxdcsetpen} \func{void}{SetPen}{\param{const wxPen\& }{pen}} @@ -962,12 +1045,14 @@ context, and the original pen restored. See also \helpref{wxMemoryDC}{wxmemorydc} for the interpretation of colours when drawing into a monochrome bitmap. + \membersection{wxDC::SetTextBackground}\label{wxdcsettextbackground} \func{void}{SetTextBackground}{\param{const wxColour\& }{colour}} Sets the current text background colour for the DC. + \membersection{wxDC::SetTextForeground}\label{wxdcsettextforeground} \func{void}{SetTextForeground}{\param{const wxColour\& }{colour}} @@ -977,6 +1062,7 @@ Sets the current text foreground colour for the DC. See also \helpref{wxMemoryDC}{wxmemorydc} for the interpretation of colours when drawing into a monochrome bitmap. + \membersection{wxDC::SetUserScale}\label{wxdcsetuserscale} \func{void}{SetUserScale}{\param{double}{ xScale}, \param{double}{ yScale}} @@ -984,6 +1070,7 @@ when drawing into a monochrome bitmap. Sets the user scaling factor, useful for applications which require `zooming'. + \membersection{wxDC::StartDoc}\label{wxdcstartdoc} \func{bool}{StartDoc}{\param{const wxString\& }{message}} @@ -991,6 +1078,7 @@ Sets the user scaling factor, useful for applications which require Starts a document (only relevant when outputting to a printer). Message is a message to show whilst printing. + \membersection{wxDC::StartPage}\label{wxdcstartpage} \func{bool}{StartPage}{\void} @@ -1017,6 +1105,7 @@ No base class \latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxDCClipper::wxDCClipper} \func{}{wxDCClipper}{\param{wxDC\& }{dc}, \param{wxCoord }{x},\param{wxCoord }{y},\param{wxCoord }{w},\param{wxCoord }{h},} @@ -1026,6 +1115,7 @@ No base class Constructor: sets the the clipping region for the given device context to the specified rectangle. + \membersection{wxDCClipper::\destruct{wxDCClipper}} \func{}{\destruct{wxDCClipper}}{\void} diff --git a/include/wx/dc.h b/include/wx/dc.h index b536b75d9e..cb7d80bd14 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -210,6 +210,11 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0, int fillStyle = wxODDEVEN_RULE); + void DrawPolyPolygon(int n, int start[], wxPoint points[], + wxCoord xoffset = 0, wxCoord yoffset = 0, + int fillStyle = wxODDEVEN_RULE) + { DoDrawPolyPolygon(n, start, points, xoffset, yoffset, fillStyle); } + void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { DoDrawRectangle(x, y, width, height); } void DrawRectangle(const wxPoint& pt, const wxSize& sz) @@ -684,6 +689,9 @@ protected: virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle = wxODDEVEN_RULE) = 0; + virtual void DoDrawPolyPolygon(int n, int start[], wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle); virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0; virtual void DoSetClippingRegion(wxCoord x, wxCoord y, diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index 1271d458c3..13a549c82e 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -190,6 +190,9 @@ protected: virtual void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle = wxODDEVEN_RULE); + virtual void DoDrawPolyPolygon(int n, int start[], wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle = wxODDEVEN_RULE); #if wxUSE_PALETTE diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index a4e87ee3d9..e3025e3f24 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -564,7 +564,7 @@ void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle)) +void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -597,7 +597,7 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx } if ( m_pstream ) - fprintf( m_pstream, "fill\n" ); + fprintf( m_pstream, (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n")); } if (m_pen.GetStyle () != wxTRANSPARENT) @@ -634,6 +634,72 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx } } +void wxPostScriptDC::DoDrawPolyPolygon (int n, int start[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) +{ + wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") ); + + if (n <= 0) return; + + if (m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush( m_brush ); + + fprintf( m_pstream, "newpath\n" ); + + int ofs = 0; + for (int i = 0; i < n; ofs += start[i++]) + { + wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset); + + fprintf( m_pstream, "%d %d moveto\n", xx, yy ); + + CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset ); + + for (int j = 1; j < start[i]; j++) + { + xx = LogicalToDeviceX(points[ofs+j].x + xoffset); + yy = LogicalToDeviceY(points[ofs+j].y + yoffset); + + fprintf( m_pstream, "%d %d lineto\n", xx, yy ); + + CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset); + } + } + fprintf( m_pstream, (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n")); + } + + if (m_pen.GetStyle () != wxTRANSPARENT) + { + SetPen( m_pen ); + + fprintf( m_pstream, "newpath\n" ); + + int ofs = 0; + for (int i = 0; i < n; ofs += start[i++]) + { + wxCoord xx = LogicalToDeviceX(points[ofs].x + xoffset); + wxCoord yy = LogicalToDeviceY(points[ofs].y + yoffset); + + fprintf( m_pstream, "%d %d moveto\n", xx, yy ); + + CalcBoundingBox( points[ofs].x + xoffset, points[ofs].y + yoffset ); + + for (int j = 1; j < start[i]; j++) + { + xx = LogicalToDeviceX(points[ofs+j].x + xoffset); + yy = LogicalToDeviceY(points[ofs+j].y + yoffset); + + fprintf( m_pstream, "%d %d lineto\n", xx, yy ); + + CalcBoundingBox( points[ofs+j].x + xoffset, points[ofs+j].y + yoffset); + } + } + fprintf( m_pstream, "closepath\n" ); + fprintf( m_pstream, "stroke\n" ); + } +} + void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index f7200155db..d8cc34d86e 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -793,6 +793,50 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffs } } +void +wxDC::DoDrawPolyPolygon(int n, + int start[], + wxPoint points[], + wxCoord xoffset, + wxCoord yoffset, + int fillStyle) +{ +#ifdef __WXMICROWIN__ + if (!GetHDC()) return; +#endif + + wxColourChanger cc(*this); // needed for wxSTIPPLE_MASK_OPAQUE handling + int i, cnt; + for (i = cnt = 0; i < n; i++) + cnt += start[i]; + + // Do things less efficiently if we have offsets + if (xoffset != 0 || yoffset != 0) + { + POINT *cpoints = new POINT[cnt]; + for (i = 0; i < cnt; i++) + { + cpoints[i].x = (int)(points[i].x + xoffset); + cpoints[i].y = (int)(points[i].y + yoffset); + + CalcBoundingBox(cpoints[i].x, cpoints[i].y); + } + int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); + (void)PolyPolygon(GetHdc(), cpoints, start, n); + SetPolyFillMode(GetHdc(),prev); + delete[] cpoints; + } + else + { + for (i = 0; i < cnt; i++) + CalcBoundingBox(points[i].x, points[i].y); + + int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); + (void)PolyPolygon(GetHdc(), (POINT*) points, start, n); + SetPolyFillMode(GetHdc(),prev); + } +} + void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { #ifdef __WXMICROWIN__ -- 2.45.2