Merge branch 'peninfo'
Add wxPenInfo and wxGraphicsPenInfo which allows to specify fractional pen widths when using wxGraphicsContext. Closes #17087. Closes https://github.com/wxWidgets/wxWidgets/pull/472
This commit is contained in:
@@ -3908,6 +3908,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \
|
|||||||
wx/collheaderctrl.h \
|
wx/collheaderctrl.h \
|
||||||
wx/generic/collheaderctrl.h \
|
wx/generic/collheaderctrl.h \
|
||||||
wx/itemattr.h \
|
wx/itemattr.h \
|
||||||
|
wx/peninfobase.h \
|
||||||
$(LOWLEVEL_HDR) \
|
$(LOWLEVEL_HDR) \
|
||||||
$(GUI_CORE_HEADERS) \
|
$(GUI_CORE_HEADERS) \
|
||||||
$(ADVANCED_HDR) \
|
$(ADVANCED_HDR) \
|
||||||
|
@@ -1188,6 +1188,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
|||||||
wx/collheaderctrl.h
|
wx/collheaderctrl.h
|
||||||
wx/generic/collheaderctrl.h
|
wx/generic/collheaderctrl.h
|
||||||
wx/itemattr.h
|
wx/itemattr.h
|
||||||
|
wx/peninfobase.h
|
||||||
</set>
|
</set>
|
||||||
|
|
||||||
<!-- ====================================================================== -->
|
<!-- ====================================================================== -->
|
||||||
|
@@ -946,6 +946,7 @@ GUI_CMN_HDR =
|
|||||||
wx/palette.h
|
wx/palette.h
|
||||||
wx/panel.h
|
wx/panel.h
|
||||||
wx/pen.h
|
wx/pen.h
|
||||||
|
wx/peninfobase.h
|
||||||
wx/position.h
|
wx/position.h
|
||||||
wx/preferences.h
|
wx/preferences.h
|
||||||
wx/radiobox.h
|
wx/radiobox.h
|
||||||
|
@@ -1382,6 +1382,7 @@
|
|||||||
<ClInclude Include="..\..\include\wx\generic\collheaderctrl.h" />
|
<ClInclude Include="..\..\include\wx\generic\collheaderctrl.h" />
|
||||||
<ClInclude Include="..\..\include\wx\msw\rt\utils.h" />
|
<ClInclude Include="..\..\include\wx\msw\rt\utils.h" />
|
||||||
<ClInclude Include="..\..\include\wx\itemattr.h" />
|
<ClInclude Include="..\..\include\wx\itemattr.h" />
|
||||||
|
<ClInclude Include="..\..\include\wx\peninfobase.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@@ -1714,6 +1714,9 @@
|
|||||||
<ClInclude Include="..\..\include\wx\pen.h">
|
<ClInclude Include="..\..\include\wx\pen.h">
|
||||||
<Filter>Common Headers</Filter>
|
<Filter>Common Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\include\wx\peninfobase.h">
|
||||||
|
<Filter>Common Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\include\wx\persist.h">
|
<ClInclude Include="..\..\include\wx\persist.h">
|
||||||
<Filter>Common Headers</Filter>
|
<Filter>Common Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "wx_vc7_wxregex.vcproj", "{7A1A5354-6DB4-53F1-B75C-FE909D796167}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "wx_vc7_wxregex.vcproj", "{7A1A5354-6DB4-53F1-B75C-FE909D796167}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@@ -2393,6 +2393,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\pen.h">
|
RelativePath="..\..\include\wx\pen.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\peninfobase.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\persist.h">
|
RelativePath="..\..\include\wx\persist.h">
|
||||||
</File>
|
</File>
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
# Visual Studio 2005
|
# Visual Studio 2005
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "wx_vc8_wxregex.vcproj", "{078F4E39-D258-54B5-B1B1-4905D10E06DC}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "wx_vc8_wxregex.vcproj", "{078F4E39-D258-54B5-B1B1-4905D10E06DC}"
|
||||||
|
@@ -3692,6 +3692,10 @@
|
|||||||
RelativePath="..\..\include\wx\pen.h"
|
RelativePath="..\..\include\wx\pen.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\peninfobase.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\persist.h"
|
RelativePath="..\..\include\wx\persist.h"
|
||||||
>
|
>
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
# Visual Studio 2008
|
# Visual Studio 2008
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "wx_vc9_wxregex.vcproj", "{56A4B526-BB81-5D01-AAA9-16D23BBB169D}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxregex", "wx_vc9_wxregex.vcproj", "{56A4B526-BB81-5D01-AAA9-16D23BBB169D}"
|
||||||
|
@@ -3688,6 +3688,10 @@
|
|||||||
RelativePath="..\..\include\wx\pen.h"
|
RelativePath="..\..\include\wx\pen.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\peninfobase.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\persist.h"
|
RelativePath="..\..\include\wx\persist.h"
|
||||||
>
|
>
|
||||||
|
@@ -58,6 +58,10 @@ Changes in behaviour which may result in build errors
|
|||||||
- Never documented and not always available private wxGetClipboardData()
|
- Never documented and not always available private wxGetClipboardData()
|
||||||
function now doesn't exist at all any more in wxMSW, use wxClipboard instead.
|
function now doesn't exist at all any more in wxMSW, use wxClipboard instead.
|
||||||
|
|
||||||
|
- wxGraphicsRenderer::CreatePen() now takes wxGraphicsPenInfo and not a wxPen.
|
||||||
|
This only affects code defining its own custom renderers, code just using
|
||||||
|
wxGraphicsContext::CreatePen() continues to compile and work as before.
|
||||||
|
|
||||||
|
|
||||||
3.1.1: (not released yet)
|
3.1.1: (not released yet)
|
||||||
----------------------------
|
----------------------------
|
||||||
@@ -97,6 +101,7 @@ All:
|
|||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
|
- Allow using fractional pen widths with wxGraphicsContext (Adrien Tétar).
|
||||||
- Improve wxSVGFileDC to support more of wxDC API (Maarten Bent).
|
- Improve wxSVGFileDC to support more of wxDC API (Maarten Bent).
|
||||||
- Add support for wxAuiManager and wxAuiPaneInfo to XRC (Andrea Zanellato).
|
- Add support for wxAuiManager and wxAuiPaneInfo to XRC (Andrea Zanellato).
|
||||||
- Add support for wxSL_MIN_MAX_LABELS and wxSL_VALUE_LABEL to XRC (ousnius).
|
- Add support for wxSL_MIN_MAX_LABELS and wxSL_VALUE_LABEL to XRC (ousnius).
|
||||||
|
@@ -35,6 +35,8 @@ public:
|
|||||||
|
|
||||||
wxPen(const wxBitmap& stipple, int width);
|
wxPen(const wxBitmap& stipple, int width);
|
||||||
|
|
||||||
|
wxPen(const wxPenInfo& info);
|
||||||
|
|
||||||
bool operator==(const wxPen& pen) const;
|
bool operator==(const wxPen& pen) const;
|
||||||
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
#include "wx/font.h"
|
#include "wx/font.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
|
#include "wx/peninfobase.h"
|
||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
|
|
||||||
enum wxAntialiasMode
|
enum wxAntialiasMode
|
||||||
@@ -132,6 +133,34 @@ protected:
|
|||||||
wxDECLARE_DYNAMIC_CLASS(wxGraphicsObject);
|
wxDECLARE_DYNAMIC_CLASS(wxGraphicsObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGraphicsPenInfo describes a wxGraphicsPen
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxGraphicsPenInfo : public wxPenInfoBase<wxGraphicsPenInfo>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit wxGraphicsPenInfo(const wxColour& colour = wxColour(),
|
||||||
|
wxDouble width = 1.0,
|
||||||
|
wxPenStyle style = wxPENSTYLE_SOLID)
|
||||||
|
: wxPenInfoBase(colour, style)
|
||||||
|
{
|
||||||
|
m_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Width(wxDouble width)
|
||||||
|
{ m_width = width; return *this; }
|
||||||
|
|
||||||
|
// Accessors
|
||||||
|
|
||||||
|
wxDouble GetWidth() const { return m_width; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDouble m_width;
|
||||||
|
};
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject
|
class WXDLLIMPEXP_CORE wxGraphicsPen : public wxGraphicsObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -479,7 +508,10 @@ public:
|
|||||||
|
|
||||||
wxGraphicsPath CreatePath() const;
|
wxGraphicsPath CreatePath() const;
|
||||||
|
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
|
wxGraphicsPen CreatePen(const wxPen& pen) const;
|
||||||
|
|
||||||
|
wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) const
|
||||||
|
{ return DoCreatePen(info); }
|
||||||
|
|
||||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const;
|
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) const;
|
||||||
|
|
||||||
@@ -744,6 +776,8 @@ protected:
|
|||||||
// implementations of overloaded public functions: we use different names
|
// implementations of overloaded public functions: we use different names
|
||||||
// for them to avoid the virtual function hiding problems in the derived
|
// for them to avoid the virtual function hiding problems in the derived
|
||||||
// classes
|
// classes
|
||||||
|
virtual wxGraphicsPen DoCreatePen(const wxGraphicsPenInfo& info) const;
|
||||||
|
|
||||||
virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y) = 0;
|
virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y) = 0;
|
||||||
virtual void DoDrawRotatedText(const wxString& str, wxDouble x, wxDouble y,
|
virtual void DoDrawRotatedText(const wxString& str, wxDouble x, wxDouble y,
|
||||||
wxDouble angle);
|
wxDouble angle);
|
||||||
@@ -861,7 +895,7 @@ public:
|
|||||||
|
|
||||||
// Paints
|
// Paints
|
||||||
|
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
|
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) = 0;
|
||||||
|
|
||||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0;
|
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) = 0;
|
||||||
|
|
||||||
|
@@ -20,6 +20,8 @@ public:
|
|||||||
|
|
||||||
wxPen( const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID );
|
wxPen( const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID );
|
||||||
|
|
||||||
|
wxPen( const wxPenInfo& info );
|
||||||
|
|
||||||
virtual ~wxPen();
|
virtual ~wxPen();
|
||||||
|
|
||||||
bool operator==(const wxPen& pen) const;
|
bool operator==(const wxPen& pen) const;
|
||||||
|
@@ -38,6 +38,8 @@ public:
|
|||||||
|
|
||||||
wxPen( const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID );
|
wxPen( const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID );
|
||||||
|
|
||||||
|
wxPen( const wxPenInfo& info );
|
||||||
|
|
||||||
bool operator==(const wxPen& pen) const;
|
bool operator==(const wxPen& pen) const;
|
||||||
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
||||||
|
|
||||||
|
@@ -25,6 +25,9 @@ public:
|
|||||||
wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
|
wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
|
||||||
|
|
||||||
wxPen(const wxBitmap& stipple, int width);
|
wxPen(const wxBitmap& stipple, int width);
|
||||||
|
|
||||||
|
wxPen(const wxPenInfo& info);
|
||||||
|
|
||||||
virtual ~wxPen() { }
|
virtual ~wxPen() { }
|
||||||
|
|
||||||
bool operator==(const wxPen& pen) const;
|
bool operator==(const wxPen& pen) const;
|
||||||
|
@@ -23,6 +23,9 @@ public:
|
|||||||
wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
|
wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
|
||||||
|
|
||||||
wxPen(const wxBitmap& stipple, int width);
|
wxPen(const wxBitmap& stipple, int width);
|
||||||
|
|
||||||
|
wxPen(const wxPenInfo& info);
|
||||||
|
|
||||||
virtual ~wxPen();
|
virtual ~wxPen();
|
||||||
|
|
||||||
bool operator==(const wxPen& pen) const;
|
bool operator==(const wxPen& pen) const;
|
||||||
|
@@ -12,51 +12,34 @@
|
|||||||
#define _WX_PEN_H_BASE_
|
#define _WX_PEN_H_BASE_
|
||||||
|
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/peninfobase.h"
|
||||||
|
|
||||||
enum wxPenStyle
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxPenInfo contains all parameters describing a wxPen
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxPenInfo : public wxPenInfoBase<wxPenInfo>
|
||||||
{
|
{
|
||||||
wxPENSTYLE_INVALID = -1,
|
public:
|
||||||
|
explicit wxPenInfo(const wxColour& colour = wxColour(),
|
||||||
|
int width = 1,
|
||||||
|
wxPenStyle style = wxPENSTYLE_SOLID)
|
||||||
|
: wxPenInfoBase(colour, style)
|
||||||
|
{
|
||||||
|
m_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
wxPENSTYLE_SOLID = wxSOLID,
|
// Setters
|
||||||
wxPENSTYLE_DOT = wxDOT,
|
|
||||||
wxPENSTYLE_LONG_DASH = wxLONG_DASH,
|
|
||||||
wxPENSTYLE_SHORT_DASH = wxSHORT_DASH,
|
|
||||||
wxPENSTYLE_DOT_DASH = wxDOT_DASH,
|
|
||||||
wxPENSTYLE_USER_DASH = wxUSER_DASH,
|
|
||||||
|
|
||||||
wxPENSTYLE_TRANSPARENT = wxTRANSPARENT,
|
wxPenInfo& Width(int width)
|
||||||
|
{ m_width = width; return *this; }
|
||||||
|
|
||||||
wxPENSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
|
// Accessors
|
||||||
wxPENSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
|
|
||||||
wxPENSTYLE_STIPPLE = wxSTIPPLE,
|
|
||||||
|
|
||||||
wxPENSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL,
|
int GetWidth() const { return m_width; }
|
||||||
wxPENSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG,
|
|
||||||
wxPENSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL,
|
|
||||||
wxPENSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS,
|
|
||||||
wxPENSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL,
|
|
||||||
wxPENSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL,
|
|
||||||
wxPENSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST,
|
|
||||||
wxPENSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST
|
|
||||||
};
|
|
||||||
|
|
||||||
enum wxPenJoin
|
private:
|
||||||
{
|
int m_width;
|
||||||
wxJOIN_INVALID = -1,
|
|
||||||
|
|
||||||
wxJOIN_BEVEL = 120,
|
|
||||||
wxJOIN_MITER,
|
|
||||||
wxJOIN_ROUND
|
|
||||||
};
|
|
||||||
|
|
||||||
enum wxPenCap
|
|
||||||
{
|
|
||||||
wxCAP_INVALID = -1,
|
|
||||||
|
|
||||||
wxCAP_ROUND = 130,
|
|
||||||
wxCAP_PROJECTING,
|
|
||||||
wxCAP_BUTT
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
130
include/wx/peninfobase.h
Normal file
130
include/wx/peninfobase.h
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/peninfobase.h
|
||||||
|
// Purpose: Declaration of wxPenInfoBase class and related constants
|
||||||
|
// Author: Adrien Tétar, Vadim Zeitlin
|
||||||
|
// Created: 2017-09-10
|
||||||
|
// Copyright: (c) 2017 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_PENINFOBASE_H_
|
||||||
|
#define _WX_PENINFOBASE_H_
|
||||||
|
|
||||||
|
#include "wx/bitmap.h"
|
||||||
|
#include "wx/colour.h"
|
||||||
|
#include "wx/gdicmn.h" // for wxDash
|
||||||
|
|
||||||
|
enum wxPenStyle
|
||||||
|
{
|
||||||
|
wxPENSTYLE_INVALID = -1,
|
||||||
|
|
||||||
|
wxPENSTYLE_SOLID = wxSOLID,
|
||||||
|
wxPENSTYLE_DOT = wxDOT,
|
||||||
|
wxPENSTYLE_LONG_DASH = wxLONG_DASH,
|
||||||
|
wxPENSTYLE_SHORT_DASH = wxSHORT_DASH,
|
||||||
|
wxPENSTYLE_DOT_DASH = wxDOT_DASH,
|
||||||
|
wxPENSTYLE_USER_DASH = wxUSER_DASH,
|
||||||
|
|
||||||
|
wxPENSTYLE_TRANSPARENT = wxTRANSPARENT,
|
||||||
|
|
||||||
|
wxPENSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
|
||||||
|
wxPENSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
|
||||||
|
wxPENSTYLE_STIPPLE = wxSTIPPLE,
|
||||||
|
|
||||||
|
wxPENSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL,
|
||||||
|
wxPENSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG,
|
||||||
|
wxPENSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL,
|
||||||
|
wxPENSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS,
|
||||||
|
wxPENSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL,
|
||||||
|
wxPENSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL,
|
||||||
|
wxPENSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST,
|
||||||
|
wxPENSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
enum wxPenJoin
|
||||||
|
{
|
||||||
|
wxJOIN_INVALID = -1,
|
||||||
|
|
||||||
|
wxJOIN_BEVEL = 120,
|
||||||
|
wxJOIN_MITER,
|
||||||
|
wxJOIN_ROUND
|
||||||
|
};
|
||||||
|
|
||||||
|
enum wxPenCap
|
||||||
|
{
|
||||||
|
wxCAP_INVALID = -1,
|
||||||
|
|
||||||
|
wxCAP_ROUND = 130,
|
||||||
|
wxCAP_PROJECTING,
|
||||||
|
wxCAP_BUTT
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxPenInfoBase is a common base for wxPenInfo and wxGraphicsPenInfo
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// This class uses CRTP, the template parameter is the derived class itself.
|
||||||
|
template <class T>
|
||||||
|
class wxPenInfoBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Setters for the various attributes. All of them return the object itself
|
||||||
|
// so that the calls to them could be chained.
|
||||||
|
|
||||||
|
T& Colour(const wxColour& colour)
|
||||||
|
{ m_colour = colour; return This(); }
|
||||||
|
|
||||||
|
T& Style(wxPenStyle style)
|
||||||
|
{ m_style = style; return This(); }
|
||||||
|
T& Stipple(const wxBitmap& stipple)
|
||||||
|
{ m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return This(); }
|
||||||
|
T& Dashes(int nb_dashes, const wxDash *dash)
|
||||||
|
{ m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return This(); }
|
||||||
|
T& Join(wxPenJoin join)
|
||||||
|
{ m_join = join; return This(); }
|
||||||
|
T& Cap(wxPenCap cap)
|
||||||
|
{ m_cap = cap; return This(); }
|
||||||
|
|
||||||
|
// Accessors are mostly meant to be used by wxWidgets itself.
|
||||||
|
|
||||||
|
wxColour GetColour() const { return m_colour; }
|
||||||
|
wxBitmap GetStipple() const { return m_stipple; }
|
||||||
|
wxPenStyle GetStyle() const { return m_style; }
|
||||||
|
wxPenJoin GetJoin() const { return m_join; }
|
||||||
|
wxPenCap GetCap() const { return m_cap; }
|
||||||
|
int GetDashes(wxDash **ptr) const { *ptr = m_dash; return m_nb_dashes; }
|
||||||
|
|
||||||
|
int GetDashCount() const { return m_nb_dashes; }
|
||||||
|
wxDash* GetDash() const { return m_dash; }
|
||||||
|
|
||||||
|
// Convenience
|
||||||
|
|
||||||
|
bool IsTransparent() const { return m_style == wxPENSTYLE_TRANSPARENT; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxPenInfoBase(const wxColour& colour, wxPenStyle style)
|
||||||
|
{
|
||||||
|
m_nb_dashes = 0;
|
||||||
|
m_dash = NULL;
|
||||||
|
m_join = wxJOIN_ROUND;
|
||||||
|
m_cap = wxCAP_ROUND;
|
||||||
|
|
||||||
|
m_colour = colour;
|
||||||
|
m_style = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Helper to return this object itself cast to its real type T.
|
||||||
|
T& This() { return static_cast<T&>(*this); }
|
||||||
|
|
||||||
|
wxColour m_colour;
|
||||||
|
wxBitmap m_stipple;
|
||||||
|
wxPenStyle m_style;
|
||||||
|
wxPenJoin m_join;
|
||||||
|
wxPenCap m_cap;
|
||||||
|
|
||||||
|
int m_nb_dashes;
|
||||||
|
wxDash* m_dash;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_PENINFOBASE_H_
|
@@ -36,6 +36,9 @@ public:
|
|||||||
wxPen( const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID );
|
wxPen( const wxColour &colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID );
|
||||||
|
|
||||||
wxPen( const wxBitmap &stipple, int width );
|
wxPen( const wxBitmap &stipple, int width );
|
||||||
|
|
||||||
|
wxPen( const wxPenInfo& info );
|
||||||
|
|
||||||
virtual ~wxPen();
|
virtual ~wxPen();
|
||||||
|
|
||||||
bool operator == ( const wxPen& pen ) const;
|
bool operator == ( const wxPen& pen ) const;
|
||||||
|
@@ -677,8 +677,19 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a native pen from a wxPen.
|
Creates a native pen from a wxPen.
|
||||||
|
|
||||||
|
Prefer to use the overload taking wxGraphicsPenInfo unless you already
|
||||||
|
have a wxPen as constructing one only to pass it to this method is
|
||||||
|
wasteful.
|
||||||
*/
|
*/
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
|
wxGraphicsPen CreatePen(const wxPen& pen) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates a native pen from a wxGraphicsPenInfo.
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the pen used for stroking.
|
Sets the pen used for stroking.
|
||||||
@@ -1415,9 +1426,11 @@ public:
|
|||||||
virtual wxGraphicsPath CreatePath() = 0;
|
virtual wxGraphicsPath CreatePath() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a native pen from a wxPen.
|
Creates a native pen from its description.
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
*/
|
*/
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) = 0;
|
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a native brush with a radial gradient.
|
Creates a native brush with a radial gradient.
|
||||||
@@ -1528,6 +1541,51 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class wxGraphicsPenInfo
|
||||||
|
|
||||||
|
This class is a helper used for wxGraphicsPen creation using named parameter
|
||||||
|
idiom: it allows to specify various wxGraphicsPen attributes using the chained
|
||||||
|
calls to its clearly named methods instead of passing them in the fixed
|
||||||
|
order to wxGraphicsPen constructors.
|
||||||
|
|
||||||
|
Typically you would use wxGraphicsPenInfo with a wxGraphicsContext, e.g. to
|
||||||
|
start drawing with a dotted blue pen slightly wider than normal you could
|
||||||
|
write the following:
|
||||||
|
@code
|
||||||
|
wxGraphicsContext ctx = wxGraphicsContext::Create(dc);
|
||||||
|
|
||||||
|
ctx.SetPen(wxGraphicsPenInfo(*wxBLUE).Width(1.25).Style(wxPENSTYLE_DOT));
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
class wxGraphicsPenInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit wxGraphicsPenInfo(const wxColour& colour = wxColour(),
|
||||||
|
wxDouble width = 1.0,
|
||||||
|
wxPenStyle style = wxPENSTYLE_SOLID);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Colour(const wxColour& col);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Width(wxDouble width);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Style(wxPenStyle style);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Style(wxPenStyle style);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Stipple(const wxBitmap& stipple);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Dashes(int nb_dashes, const wxDash *dash);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Join(wxPenJoin join);
|
||||||
|
|
||||||
|
wxGraphicsPenInfo& Cap(wxPenCap cap);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxGraphicsPen
|
@class wxGraphicsPen
|
||||||
|
|
||||||
|
@@ -101,6 +101,48 @@ enum wxPenCap
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@class wxPenInfo
|
||||||
|
|
||||||
|
This class is a helper used for wxPen creation using named parameter
|
||||||
|
idiom: it allows to specify various wxPen attributes using the chained
|
||||||
|
calls to its clearly named methods instead of passing them in the fixed
|
||||||
|
order to wxPen constructors.
|
||||||
|
|
||||||
|
For instance, to create a dotted blue pen with the given join style you
|
||||||
|
could do
|
||||||
|
@code
|
||||||
|
wxPen pen(wxPenInfo(*wxBLUE).Style(wxPENSTYLE_DOT).Join(wxJOIN_BEVEL));
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
class wxPenInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit wxPenInfo(const wxColour& colour = wxColour(),
|
||||||
|
int width = 1,
|
||||||
|
wxPenStyle style = wxPENSTYLE_SOLID);
|
||||||
|
|
||||||
|
wxPenInfo& Colour(const wxColour& col);
|
||||||
|
|
||||||
|
wxPenInfo& Width(int width);
|
||||||
|
|
||||||
|
wxPenInfo& Style(wxPenStyle style);
|
||||||
|
|
||||||
|
wxPenInfo& Style(wxPenStyle style);
|
||||||
|
|
||||||
|
wxPenInfo& Stipple(const wxBitmap& stipple);
|
||||||
|
|
||||||
|
wxPenInfo& Dashes(int nb_dashes, const wxDash *dash);
|
||||||
|
|
||||||
|
wxPenInfo& Join(wxPenJoin join);
|
||||||
|
|
||||||
|
wxPenInfo& Cap(wxPenCap cap);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class wxPen
|
@class wxPen
|
||||||
|
|
||||||
@@ -157,6 +199,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxPen();
|
wxPen();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates a pen object using the specified pen description.
|
||||||
|
*/
|
||||||
|
wxPen(const wxPenInfo& info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructs a pen from a colour object, pen width and style.
|
Constructs a pen from a colour object, pen width and style.
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
#include "wx/dcprint.h"
|
#include "wx/dcprint.h"
|
||||||
#include "wx/math.h"
|
#include "wx/math.h"
|
||||||
|
#include "wx/pen.h"
|
||||||
#include "wx/region.h"
|
#include "wx/region.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -824,7 +825,25 @@ wxGraphicsPath wxGraphicsContext::CreatePath() const
|
|||||||
|
|
||||||
wxGraphicsPen wxGraphicsContext::CreatePen(const wxPen& pen) const
|
wxGraphicsPen wxGraphicsContext::CreatePen(const wxPen& pen) const
|
||||||
{
|
{
|
||||||
return GetRenderer()->CreatePen(pen);
|
if ( !pen.IsOk() )
|
||||||
|
return wxGraphicsPen();
|
||||||
|
|
||||||
|
wxDash *dashes;
|
||||||
|
int nb_dashes = pen.GetDashes(&dashes);
|
||||||
|
|
||||||
|
return DoCreatePen(wxGraphicsPenInfo()
|
||||||
|
.Colour(pen.GetColour())
|
||||||
|
.Width(pen.GetWidth())
|
||||||
|
.Style(pen.GetStyle())
|
||||||
|
.Stipple(*pen.GetStipple())
|
||||||
|
.Dashes(nb_dashes, dashes)
|
||||||
|
.Join(pen.GetJoin())
|
||||||
|
.Cap(pen.GetCap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGraphicsPen wxGraphicsContext::DoCreatePen(const wxGraphicsPenInfo& info) const
|
||||||
|
{
|
||||||
|
return GetRenderer()->CreatePen(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsBrush wxGraphicsContext::CreateBrush(const wxBrush& brush ) const
|
wxGraphicsBrush wxGraphicsContext::CreateBrush(const wxBrush& brush ) const
|
||||||
|
@@ -79,6 +79,11 @@ wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
|
|||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPen::wxPen(const wxPenInfo& info)
|
||||||
|
{
|
||||||
|
m_refData = new wxPenRefData(info.GetColour(), info.GetStyle());
|
||||||
|
}
|
||||||
|
|
||||||
bool wxPen::operator==(const wxPen& pen) const
|
bool wxPen::operator==(const wxPen& pen) const
|
||||||
{
|
{
|
||||||
#warning "this is incorrect"
|
#warning "this is incorrect"
|
||||||
|
@@ -284,7 +284,7 @@ private:
|
|||||||
class WXDLLIMPEXP_CORE wxCairoPenData : public wxCairoPenBrushBaseData
|
class WXDLLIMPEXP_CORE wxCairoPenData : public wxCairoPenBrushBaseData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||||
~wxCairoPenData();
|
~wxCairoPenData();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
@@ -733,15 +733,15 @@ void wxCairoPenData::Init()
|
|||||||
m_count = 0;
|
m_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info )
|
||||||
: wxCairoPenBrushBaseData(renderer, pen.GetColour(), pen.IsTransparent())
|
: wxCairoPenBrushBaseData(renderer, info.GetColour(), info.IsTransparent())
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_width = pen.GetWidth();
|
m_width = info.GetWidth();
|
||||||
if (m_width <= 0.0)
|
if (m_width <= 0.0)
|
||||||
m_width = 0.1;
|
m_width = 0.1;
|
||||||
|
|
||||||
switch ( pen.GetCap() )
|
switch ( info.GetCap() )
|
||||||
{
|
{
|
||||||
case wxCAP_ROUND :
|
case wxCAP_ROUND :
|
||||||
m_cap = CAIRO_LINE_CAP_ROUND;
|
m_cap = CAIRO_LINE_CAP_ROUND;
|
||||||
@@ -760,7 +760,7 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( pen.GetJoin() )
|
switch ( info.GetJoin() )
|
||||||
{
|
{
|
||||||
case wxJOIN_BEVEL :
|
case wxJOIN_BEVEL :
|
||||||
m_join = CAIRO_LINE_JOIN_BEVEL;
|
m_join = CAIRO_LINE_JOIN_BEVEL;
|
||||||
@@ -797,7 +797,7 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
|||||||
9.0 , 6.0 , 3.0 , 3.0
|
9.0 , 6.0 , 3.0 , 3.0
|
||||||
};
|
};
|
||||||
|
|
||||||
switch ( pen.GetStyle() )
|
switch ( info.GetStyle() )
|
||||||
{
|
{
|
||||||
case wxPENSTYLE_SOLID :
|
case wxPENSTYLE_SOLID :
|
||||||
break;
|
break;
|
||||||
@@ -827,7 +827,7 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
|||||||
case wxPENSTYLE_USER_DASH :
|
case wxPENSTYLE_USER_DASH :
|
||||||
{
|
{
|
||||||
wxDash *wxdashes ;
|
wxDash *wxdashes ;
|
||||||
m_count = pen.GetDashes( &wxdashes ) ;
|
m_count = info.GetDashes( &wxdashes ) ;
|
||||||
if ((wxdashes != NULL) && (m_count > 0))
|
if ((wxdashes != NULL) && (m_count > 0))
|
||||||
{
|
{
|
||||||
m_userLengths = new double[m_count] ;
|
m_userLengths = new double[m_count] ;
|
||||||
@@ -848,14 +848,17 @@ wxCairoPenData::wxCairoPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
|||||||
case wxPENSTYLE_STIPPLE :
|
case wxPENSTYLE_STIPPLE :
|
||||||
case wxPENSTYLE_STIPPLE_MASK :
|
case wxPENSTYLE_STIPPLE_MASK :
|
||||||
case wxPENSTYLE_STIPPLE_MASK_OPAQUE :
|
case wxPENSTYLE_STIPPLE_MASK_OPAQUE :
|
||||||
InitStipple(pen.GetStipple());
|
{
|
||||||
|
wxBitmap stipple = info.GetStipple();
|
||||||
|
InitStipple(&stipple);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
if ( pen.GetStyle() >= wxPENSTYLE_FIRST_HATCH
|
if ( info.GetStyle() >= wxPENSTYLE_FIRST_HATCH
|
||||||
&& pen.GetStyle() <= wxPENSTYLE_LAST_HATCH )
|
&& info.GetStyle() <= wxPENSTYLE_LAST_HATCH )
|
||||||
{
|
{
|
||||||
InitHatch(static_cast<wxHatchStyle>(pen.GetStyle()));
|
InitHatch(static_cast<wxHatchStyle>(info.GetStyle()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2900,7 +2903,7 @@ public :
|
|||||||
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
||||||
|
|
||||||
|
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE ;
|
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE ;
|
||||||
|
|
||||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
||||||
|
|
||||||
@@ -3076,13 +3079,13 @@ wxGraphicsMatrix wxCairoRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDouble
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsPen wxCairoRenderer::CreatePen(const wxPen& pen)
|
wxGraphicsPen wxCairoRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||||
{
|
{
|
||||||
wxGraphicsPen p;
|
wxGraphicsPen p;
|
||||||
ENSURE_LOADED_OR_RETURN(p);
|
ENSURE_LOADED_OR_RETURN(p);
|
||||||
if (pen.IsOk() && pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
|
if (info.GetStyle() != wxPENSTYLE_TRANSPARENT)
|
||||||
{
|
{
|
||||||
p.SetRefData(new wxCairoPenData( this, pen ));
|
p.SetRefData(new wxCairoPenData( this, info ));
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,16 @@ public:
|
|||||||
m_dash = data.m_dash;
|
m_dash = data.m_dash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPenRefData( const wxPenInfo& info )
|
||||||
|
{
|
||||||
|
m_width = info.GetWidth();
|
||||||
|
m_style = info.GetStyle();
|
||||||
|
m_joinStyle = info.GetJoin();
|
||||||
|
m_capStyle = info.GetCap();
|
||||||
|
m_colour = info.GetColour();
|
||||||
|
m_countDashes = info.GetDashes((wxDash**)&m_dash);
|
||||||
|
}
|
||||||
|
|
||||||
bool operator == (const wxPenRefData& data) const
|
bool operator == (const wxPenRefData& data) const
|
||||||
{
|
{
|
||||||
if ( m_countDashes != data.m_countDashes )
|
if ( m_countDashes != data.m_countDashes )
|
||||||
@@ -89,18 +99,20 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject);
|
|||||||
|
|
||||||
wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
|
wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData(wxPenInfo(colour, width).Style(style));
|
||||||
M_PENDATA->m_width = width;
|
|
||||||
M_PENDATA->m_style = style;
|
|
||||||
M_PENDATA->m_colour = colour;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxColour& colour, int width, int style)
|
wxPen::wxPen(const wxColour& colour, int width, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData
|
||||||
M_PENDATA->m_width = width;
|
(
|
||||||
M_PENDATA->m_style = (wxPenStyle)style;
|
wxPenInfo(colour, width).Style((wxPenStyle)style)
|
||||||
M_PENDATA->m_colour = colour;
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPen::wxPen(const wxPenInfo& info)
|
||||||
|
{
|
||||||
|
m_refData = new wxPenRefData(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::~wxPen()
|
wxPen::~wxPen()
|
||||||
|
@@ -46,6 +46,18 @@ public:
|
|||||||
m_dash = data.m_dash;
|
m_dash = data.m_dash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPenRefData( const wxPenInfo& info )
|
||||||
|
{
|
||||||
|
m_width = info.GetWidth();
|
||||||
|
m_style = info.GetStyle();
|
||||||
|
m_joinStyle = info.GetJoin();
|
||||||
|
m_capStyle = info.GetCap();
|
||||||
|
m_colour = info.GetColour();
|
||||||
|
wxDash* dash;
|
||||||
|
m_countDashes = info.GetDashes(&dash);
|
||||||
|
m_dash = (wxGTKDash*)dash;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator == (const wxPenRefData& data) const
|
bool operator == (const wxPenRefData& data) const
|
||||||
{
|
{
|
||||||
if ( m_countDashes != data.m_countDashes )
|
if ( m_countDashes != data.m_countDashes )
|
||||||
@@ -89,18 +101,20 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject);
|
|||||||
|
|
||||||
wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
|
wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData(wxPenInfo(colour, width).Style(style));
|
||||||
M_PENDATA->m_width = width;
|
|
||||||
M_PENDATA->m_style = style;
|
|
||||||
M_PENDATA->m_colour = colour;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxColour& colour, int width, int style)
|
wxPen::wxPen(const wxColour& colour, int width, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData
|
||||||
M_PENDATA->m_width = width;
|
(
|
||||||
M_PENDATA->m_style = (wxPenStyle)style;
|
wxPenInfo(colour, width).Style((wxPenStyle)style)
|
||||||
M_PENDATA->m_colour = colour;
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPen::wxPen(const wxPenInfo& info)
|
||||||
|
{
|
||||||
|
m_refData = new wxPenRefData(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIRefData *wxPen::CreateGDIRefData() const
|
wxGDIRefData *wxPen::CreateGDIRefData() const
|
||||||
|
@@ -260,7 +260,7 @@ private:
|
|||||||
class wxGDIPlusPenData : public wxGraphicsObjectRefData
|
class wxGDIPlusPenData : public wxGraphicsObjectRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo &info );
|
||||||
~wxGDIPlusPenData();
|
~wxGDIPlusPenData();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
@@ -573,7 +573,7 @@ public :
|
|||||||
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
||||||
|
|
||||||
|
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE;
|
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& pen) wxOVERRIDE;
|
||||||
|
|
||||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE;
|
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE;
|
||||||
|
|
||||||
@@ -643,18 +643,19 @@ void wxGDIPlusPenData::Init()
|
|||||||
m_penBrush = NULL;
|
m_penBrush = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &pen )
|
wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer,
|
||||||
: wxGraphicsObjectRefData(renderer)
|
const wxGraphicsPenInfo &info )
|
||||||
|
: wxGraphicsObjectRefData(renderer)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_width = pen.GetWidth();
|
m_width = info.GetWidth();
|
||||||
if (m_width <= 0.0)
|
if (m_width <= 0.0)
|
||||||
m_width = 0.1;
|
m_width = 0.1;
|
||||||
|
|
||||||
m_pen = new Pen(wxColourToColor(pen.GetColour()), m_width );
|
m_pen = new Pen(wxColourToColor(info.GetColour()), m_width );
|
||||||
|
|
||||||
LineCap cap;
|
LineCap cap;
|
||||||
switch ( pen.GetCap() )
|
switch ( info.GetCap() )
|
||||||
{
|
{
|
||||||
case wxCAP_ROUND :
|
case wxCAP_ROUND :
|
||||||
cap = LineCapRound;
|
cap = LineCapRound;
|
||||||
@@ -675,7 +676,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
|||||||
m_pen->SetLineCap(cap,cap, DashCapFlat);
|
m_pen->SetLineCap(cap,cap, DashCapFlat);
|
||||||
|
|
||||||
LineJoin join;
|
LineJoin join;
|
||||||
switch ( pen.GetJoin() )
|
switch ( info.GetJoin() )
|
||||||
{
|
{
|
||||||
case wxJOIN_BEVEL :
|
case wxJOIN_BEVEL :
|
||||||
join = LineJoinBevel;
|
join = LineJoinBevel;
|
||||||
@@ -699,7 +700,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
|||||||
m_pen->SetDashStyle(DashStyleSolid);
|
m_pen->SetDashStyle(DashStyleSolid);
|
||||||
|
|
||||||
DashStyle dashStyle = DashStyleSolid;
|
DashStyle dashStyle = DashStyleSolid;
|
||||||
switch ( pen.GetStyle() )
|
switch ( info.GetStyle() )
|
||||||
{
|
{
|
||||||
case wxPENSTYLE_SOLID :
|
case wxPENSTYLE_SOLID :
|
||||||
break;
|
break;
|
||||||
@@ -723,7 +724,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
|||||||
{
|
{
|
||||||
dashStyle = DashStyleCustom;
|
dashStyle = DashStyleCustom;
|
||||||
wxDash *dashes;
|
wxDash *dashes;
|
||||||
int count = pen.GetDashes( &dashes );
|
int count = info.GetDashes( &dashes );
|
||||||
if ((dashes != NULL) && (count > 0))
|
if ((dashes != NULL) && (count > 0))
|
||||||
{
|
{
|
||||||
REAL *userLengths = new REAL[count];
|
REAL *userLengths = new REAL[count];
|
||||||
@@ -738,12 +739,12 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
|||||||
break;
|
break;
|
||||||
case wxPENSTYLE_STIPPLE :
|
case wxPENSTYLE_STIPPLE :
|
||||||
{
|
{
|
||||||
wxBitmap* bmp = pen.GetStipple();
|
wxBitmap bmp = info.GetStipple();
|
||||||
if ( bmp && bmp->IsOk() )
|
if ( bmp.IsOk() )
|
||||||
{
|
{
|
||||||
m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp->GetHBITMAP(),
|
m_penImage = Bitmap::FromHBITMAP((HBITMAP)bmp.GetHBITMAP(),
|
||||||
#if wxUSE_PALETTE
|
#if wxUSE_PALETTE
|
||||||
(HPALETTE)bmp->GetPalette()->GetHPALETTE()
|
(HPALETTE)bmp.GetPalette()->GetHPALETTE()
|
||||||
#else
|
#else
|
||||||
NULL
|
NULL
|
||||||
#endif
|
#endif
|
||||||
@@ -755,11 +756,11 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
if ( pen.GetStyle() >= wxPENSTYLE_FIRST_HATCH &&
|
if ( info.GetStyle() >= wxPENSTYLE_FIRST_HATCH &&
|
||||||
pen.GetStyle() <= wxPENSTYLE_LAST_HATCH )
|
info.GetStyle() <= wxPENSTYLE_LAST_HATCH )
|
||||||
{
|
{
|
||||||
HatchStyle style;
|
HatchStyle style;
|
||||||
switch( pen.GetStyle() )
|
switch( info.GetStyle() )
|
||||||
{
|
{
|
||||||
case wxPENSTYLE_BDIAGONAL_HATCH :
|
case wxPENSTYLE_BDIAGONAL_HATCH :
|
||||||
style = HatchStyleBackwardDiagonal;
|
style = HatchStyleBackwardDiagonal;
|
||||||
@@ -785,7 +786,7 @@ wxGDIPlusPenData::wxGDIPlusPenData( wxGraphicsRenderer* renderer, const wxPen &p
|
|||||||
m_penBrush = new HatchBrush
|
m_penBrush = new HatchBrush
|
||||||
(
|
(
|
||||||
style,
|
style,
|
||||||
wxColourToColor(pen.GetColour()),
|
wxColourToColor(info.GetColour()),
|
||||||
Color::Transparent
|
Color::Transparent
|
||||||
);
|
);
|
||||||
m_pen->SetBrush( m_penBrush );
|
m_pen->SetBrush( m_penBrush );
|
||||||
@@ -2448,15 +2449,15 @@ wxGraphicsMatrix wxGDIPlusRenderer::CreateMatrix( wxDouble a, wxDouble b, wxDoub
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxPen& pen)
|
wxGraphicsPen wxGDIPlusRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||||
{
|
{
|
||||||
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
|
ENSURE_LOADED_OR_RETURN(wxNullGraphicsPen);
|
||||||
if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||||
return wxNullGraphicsPen;
|
return wxNullGraphicsPen;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxGraphicsPen p;
|
wxGraphicsPen p;
|
||||||
p.SetRefData(new wxGDIPlusPenData( this, pen ));
|
p.SetRefData(new wxGDIPlusPenData( this, info ));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2458,7 +2458,9 @@ wxBrushStyle wxConvertPenStyleToBrushStyle(wxPenStyle penStyle)
|
|||||||
class wxD2DPenData : public wxGraphicsObjectRefData, public wxD2DManagedGraphicsData
|
class wxD2DPenData : public wxGraphicsObjectRefData, public wxD2DManagedGraphicsData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxD2DPenData(wxGraphicsRenderer* renderer, ID2D1Factory* direct2dFactory, const wxPen& pen);
|
wxD2DPenData(wxGraphicsRenderer* renderer,
|
||||||
|
ID2D1Factory* direct2dFactory,
|
||||||
|
const wxGraphicsPenInfo& info);
|
||||||
|
|
||||||
void CreateStrokeStyle(ID2D1Factory* const direct2dfactory);
|
void CreateStrokeStyle(ID2D1Factory* const direct2dfactory);
|
||||||
|
|
||||||
@@ -2474,9 +2476,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// We store the source pen for later when we need to recreate the
|
// We store the original pen description for later when we need to recreate
|
||||||
// device-dependent resources.
|
// the device-dependent resources.
|
||||||
const wxPen m_sourcePen;
|
const wxGraphicsPenInfo m_penInfo;
|
||||||
|
|
||||||
// A stroke style is a device-independent resource.
|
// A stroke style is a device-independent resource.
|
||||||
// Describes the caps, miter limit, line join, and dash information.
|
// Describes the caps, miter limit, line join, and dash information.
|
||||||
@@ -2496,26 +2498,28 @@ private:
|
|||||||
wxD2DPenData::wxD2DPenData(
|
wxD2DPenData::wxD2DPenData(
|
||||||
wxGraphicsRenderer* renderer,
|
wxGraphicsRenderer* renderer,
|
||||||
ID2D1Factory* direct2dFactory,
|
ID2D1Factory* direct2dFactory,
|
||||||
const wxPen& pen)
|
const wxGraphicsPenInfo& info)
|
||||||
: wxGraphicsObjectRefData(renderer), m_sourcePen(pen), m_width(pen.GetWidth())
|
: wxGraphicsObjectRefData(renderer),
|
||||||
|
m_penInfo(info),
|
||||||
|
m_width(info.GetWidth())
|
||||||
{
|
{
|
||||||
CreateStrokeStyle(direct2dFactory);
|
CreateStrokeStyle(direct2dFactory);
|
||||||
|
|
||||||
wxBrush strokeBrush;
|
wxBrush strokeBrush;
|
||||||
|
|
||||||
if (m_sourcePen.GetStyle() == wxPENSTYLE_STIPPLE)
|
if (m_penInfo.GetStyle() == wxPENSTYLE_STIPPLE)
|
||||||
{
|
{
|
||||||
strokeBrush.SetStipple(*(m_sourcePen.GetStipple()));
|
strokeBrush.SetStipple(m_penInfo.GetStipple());
|
||||||
strokeBrush.SetStyle(wxBRUSHSTYLE_STIPPLE);
|
strokeBrush.SetStyle(wxBRUSHSTYLE_STIPPLE);
|
||||||
}
|
}
|
||||||
else if(wxIsHatchPenStyle(m_sourcePen.GetStyle()))
|
else if(wxIsHatchPenStyle(m_penInfo.GetStyle()))
|
||||||
{
|
{
|
||||||
strokeBrush.SetStyle(wxConvertPenStyleToBrushStyle(m_sourcePen.GetStyle()));
|
strokeBrush.SetStyle(wxConvertPenStyleToBrushStyle(m_penInfo.GetStyle()));
|
||||||
strokeBrush.SetColour(m_sourcePen.GetColour());
|
strokeBrush.SetColour(m_penInfo.GetColour());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strokeBrush.SetColour(m_sourcePen.GetColour());
|
strokeBrush.SetColour(m_penInfo.GetColour());
|
||||||
strokeBrush.SetStyle(wxBRUSHSTYLE_SOLID);
|
strokeBrush.SetStyle(wxBRUSHSTYLE_SOLID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2524,21 +2528,21 @@ wxD2DPenData::wxD2DPenData(
|
|||||||
|
|
||||||
void wxD2DPenData::CreateStrokeStyle(ID2D1Factory* const direct2dfactory)
|
void wxD2DPenData::CreateStrokeStyle(ID2D1Factory* const direct2dfactory)
|
||||||
{
|
{
|
||||||
D2D1_CAP_STYLE capStyle = wxD2DConvertPenCap(m_sourcePen.GetCap());
|
D2D1_CAP_STYLE capStyle = wxD2DConvertPenCap(m_penInfo.GetCap());
|
||||||
D2D1_LINE_JOIN lineJoin = wxD2DConvertPenJoin(m_sourcePen.GetJoin());
|
D2D1_LINE_JOIN lineJoin = wxD2DConvertPenJoin(m_penInfo.GetJoin());
|
||||||
D2D1_DASH_STYLE dashStyle = wxD2DConvertPenStyle(m_sourcePen.GetStyle());
|
D2D1_DASH_STYLE dashStyle = wxD2DConvertPenStyle(m_penInfo.GetStyle());
|
||||||
|
|
||||||
int dashCount = 0;
|
int dashCount = 0;
|
||||||
FLOAT* dashes = NULL;
|
FLOAT* dashes = NULL;
|
||||||
|
|
||||||
if (dashStyle == D2D1_DASH_STYLE_CUSTOM)
|
if (dashStyle == D2D1_DASH_STYLE_CUSTOM)
|
||||||
{
|
{
|
||||||
dashCount = m_sourcePen.GetDashCount();
|
dashCount = m_penInfo.GetDashCount();
|
||||||
dashes = new FLOAT[dashCount];
|
dashes = new FLOAT[dashCount];
|
||||||
|
|
||||||
for (int i = 0; i < dashCount; ++i)
|
for (int i = 0; i < dashCount; ++i)
|
||||||
{
|
{
|
||||||
dashes[i] = m_sourcePen.GetDash()[i];
|
dashes[i] = m_penInfo.GetDash()[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4384,7 +4388,7 @@ public :
|
|||||||
wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0, wxDouble d = 1.0,
|
wxDouble a = 1.0, wxDouble b = 0.0, wxDouble c = 0.0, wxDouble d = 1.0,
|
||||||
wxDouble tx = 0.0, wxDouble ty = 0.0) wxOVERRIDE;
|
wxDouble tx = 0.0, wxDouble ty = 0.0) wxOVERRIDE;
|
||||||
|
|
||||||
wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE;
|
wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE;
|
||||||
|
|
||||||
wxGraphicsBrush CreateBrush(const wxBrush& brush) wxOVERRIDE;
|
wxGraphicsBrush CreateBrush(const wxBrush& brush) wxOVERRIDE;
|
||||||
|
|
||||||
@@ -4553,16 +4557,16 @@ wxGraphicsMatrix wxD2DRenderer::CreateMatrix(
|
|||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsPen wxD2DRenderer::CreatePen(const wxPen& pen)
|
wxGraphicsPen wxD2DRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||||
{
|
{
|
||||||
if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
if ( info.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
||||||
{
|
{
|
||||||
return wxNullGraphicsPen;
|
return wxNullGraphicsPen;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxGraphicsPen p;
|
wxGraphicsPen p;
|
||||||
wxD2DPenData* penData = new wxD2DPenData(this, m_direct2dFactory, pen);
|
wxD2DPenData* penData = new wxD2DPenData(this, m_direct2dFactory, info);
|
||||||
p.SetRefData(penData);
|
p.SetRefData(penData);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@@ -46,8 +46,7 @@ public:
|
|||||||
|
|
||||||
wxPenRefData();
|
wxPenRefData();
|
||||||
wxPenRefData(const wxPenRefData& data);
|
wxPenRefData(const wxPenRefData& data);
|
||||||
wxPenRefData(const wxColour& col, int width, wxPenStyle style);
|
wxPenRefData(const wxPenInfo& info);
|
||||||
wxPenRefData(const wxBitmap& stipple, int width);
|
|
||||||
virtual ~wxPenRefData();
|
virtual ~wxPenRefData();
|
||||||
|
|
||||||
bool operator==(const wxPenRefData& data) const
|
bool operator==(const wxPenRefData& data) const
|
||||||
@@ -170,24 +169,17 @@ wxPenRefData::wxPenRefData(const wxPenRefData& data)
|
|||||||
m_hPen = 0;
|
m_hPen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPenRefData::wxPenRefData(const wxColour& col, int width, wxPenStyle style)
|
wxPenRefData::wxPenRefData(const wxPenInfo& info)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
m_style = style;
|
m_style = info.GetStyle();
|
||||||
m_width = width;
|
m_width = info.GetWidth();
|
||||||
|
m_join = info.GetJoin();
|
||||||
m_colour = col;
|
m_cap = info.GetCap();
|
||||||
}
|
m_stipple = info.GetStipple();
|
||||||
|
m_nbDash = info.GetDashes(&m_dash);
|
||||||
wxPenRefData::wxPenRefData(const wxBitmap& stipple, int width)
|
m_colour = info.GetColour();
|
||||||
{
|
|
||||||
Init();
|
|
||||||
|
|
||||||
m_style = wxPENSTYLE_STIPPLE;
|
|
||||||
m_width = width;
|
|
||||||
|
|
||||||
m_stipple = stipple;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPenRefData::~wxPenRefData()
|
wxPenRefData::~wxPenRefData()
|
||||||
@@ -401,17 +393,25 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject);
|
|||||||
|
|
||||||
wxPen::wxPen(const wxColour& col, int width, wxPenStyle style)
|
wxPen::wxPen(const wxColour& col, int width, wxPenStyle style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData(col, width, style);
|
m_refData = new wxPenRefData(wxPenInfo(col, width).Style(style));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxColour& colour, int width, int style)
|
wxPen::wxPen(const wxColour& colour, int width, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData(colour, width, (wxPenStyle)style);
|
m_refData = new wxPenRefData
|
||||||
|
(
|
||||||
|
wxPenInfo(colour, width).Style((wxPenStyle)style)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxBitmap& stipple, int width)
|
wxPen::wxPen(const wxBitmap& stipple, int width)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData(stipple, width);
|
m_refData = new wxPenRefData(wxPenInfo().Stipple(stipple).Width(width));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPen::wxPen(const wxPenInfo& info)
|
||||||
|
{
|
||||||
|
m_refData = new wxPenRefData(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPen::operator==(const wxPen& pen) const
|
bool wxPen::operator==(const wxPen& pen) const
|
||||||
|
@@ -304,7 +304,7 @@ protected :
|
|||||||
class wxMacCoreGraphicsPenData : public wxGraphicsObjectRefData
|
class wxMacCoreGraphicsPenData : public wxGraphicsObjectRefData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen );
|
wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxGraphicsPenInfo& info );
|
||||||
~wxMacCoreGraphicsPenData();
|
~wxMacCoreGraphicsPenData();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
@@ -329,19 +329,20 @@ protected :
|
|||||||
CGFloat* m_patternColorComponents;
|
CGFloat* m_patternColorComponents;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer, const wxPen &pen ) :
|
wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer,
|
||||||
wxGraphicsObjectRefData( renderer )
|
const wxGraphicsPenInfo& info )
|
||||||
|
: wxGraphicsObjectRefData( renderer )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
m_color.reset( wxMacCreateCGColor( pen.GetColour() ) ) ;
|
m_color.reset( wxMacCreateCGColor( info.GetColour() ) ) ;
|
||||||
|
|
||||||
// TODO: * m_dc->m_scaleX
|
// TODO: * m_dc->m_scaleX
|
||||||
m_width = pen.GetWidth();
|
m_width = info.GetWidth();
|
||||||
if (m_width <= 0.0)
|
if (m_width <= 0.0)
|
||||||
m_width = (CGFloat) 0.1;
|
m_width = (CGFloat) 0.1;
|
||||||
|
|
||||||
switch ( pen.GetCap() )
|
switch ( info.GetCap() )
|
||||||
{
|
{
|
||||||
case wxCAP_ROUND :
|
case wxCAP_ROUND :
|
||||||
m_cap = kCGLineCapRound;
|
m_cap = kCGLineCapRound;
|
||||||
@@ -360,7 +361,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( pen.GetJoin() )
|
switch ( info.GetJoin() )
|
||||||
{
|
{
|
||||||
case wxJOIN_BEVEL :
|
case wxJOIN_BEVEL :
|
||||||
m_join = kCGLineJoinBevel;
|
m_join = kCGLineJoinBevel;
|
||||||
@@ -386,7 +387,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
|||||||
static const CGFloat dashed[] = { (CGFloat) 19.0 , (CGFloat) 9.0 };
|
static const CGFloat dashed[] = { (CGFloat) 19.0 , (CGFloat) 9.0 };
|
||||||
static const CGFloat dotted_dashed[] = { (CGFloat) 9.0 , (CGFloat) 6.0 , (CGFloat) 3.0 , (CGFloat) 3.0 };
|
static const CGFloat dotted_dashed[] = { (CGFloat) 9.0 , (CGFloat) 6.0 , (CGFloat) 3.0 , (CGFloat) 3.0 };
|
||||||
|
|
||||||
switch ( pen.GetStyle() )
|
switch ( info.GetStyle() )
|
||||||
{
|
{
|
||||||
case wxPENSTYLE_SOLID:
|
case wxPENSTYLE_SOLID:
|
||||||
break;
|
break;
|
||||||
@@ -415,7 +416,7 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
|||||||
|
|
||||||
case wxPENSTYLE_USER_DASH:
|
case wxPENSTYLE_USER_DASH:
|
||||||
wxDash *dashes;
|
wxDash *dashes;
|
||||||
m_count = pen.GetDashes( &dashes );
|
m_count = info.GetDashes( &dashes );
|
||||||
if ((dashes != NULL) && (m_count > 0))
|
if ((dashes != NULL) && (m_count > 0))
|
||||||
{
|
{
|
||||||
m_userLengths = new CGFloat[m_count];
|
m_userLengths = new CGFloat[m_count];
|
||||||
@@ -434,11 +435,11 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
|||||||
|
|
||||||
case wxPENSTYLE_STIPPLE:
|
case wxPENSTYLE_STIPPLE:
|
||||||
{
|
{
|
||||||
wxBitmap* bmp = pen.GetStipple();
|
wxBitmap bmp = info.GetStipple();
|
||||||
if ( bmp && bmp->IsOk() )
|
if ( bmp.IsOk() )
|
||||||
{
|
{
|
||||||
m_colorSpace.reset( CGColorSpaceCreatePattern( NULL ) );
|
m_colorSpace.reset( CGColorSpaceCreatePattern( NULL ) );
|
||||||
m_pattern.reset( (CGPatternRef) *( new ImagePattern( bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
m_pattern.reset( (CGPatternRef) *( new ImagePattern( &bmp , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
||||||
m_patternColorComponents = new CGFloat[1] ;
|
m_patternColorComponents = new CGFloat[1] ;
|
||||||
m_patternColorComponents[0] = (CGFloat) 1.0;
|
m_patternColorComponents[0] = (CGFloat) 1.0;
|
||||||
m_isPattern = true;
|
m_isPattern = true;
|
||||||
@@ -450,12 +451,12 @@ wxMacCoreGraphicsPenData::wxMacCoreGraphicsPenData( wxGraphicsRenderer* renderer
|
|||||||
{
|
{
|
||||||
m_isPattern = true;
|
m_isPattern = true;
|
||||||
m_colorSpace.reset( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
|
m_colorSpace.reset( CGColorSpaceCreatePattern( wxMacGetGenericRGBColorSpace() ) );
|
||||||
m_pattern.reset( (CGPatternRef) *( new HatchPattern( pen.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
m_pattern.reset( (CGPatternRef) *( new HatchPattern( info.GetStyle() , CGAffineTransformMakeScale( 1,-1 ) ) ) );
|
||||||
m_patternColorComponents = new CGFloat[4] ;
|
m_patternColorComponents = new CGFloat[4] ;
|
||||||
m_patternColorComponents[0] = (CGFloat) (pen.GetColour().Red() / 255.0);
|
m_patternColorComponents[0] = (CGFloat) (info.GetColour().Red() / 255.0);
|
||||||
m_patternColorComponents[1] = (CGFloat) (pen.GetColour().Green() / 255.0);
|
m_patternColorComponents[1] = (CGFloat) (info.GetColour().Green() / 255.0);
|
||||||
m_patternColorComponents[2] = (CGFloat) (pen.GetColour().Blue() / 255.0);
|
m_patternColorComponents[2] = (CGFloat) (info.GetColour().Blue() / 255.0);
|
||||||
m_patternColorComponents[3] = (CGFloat) (pen.GetColour().Alpha() / 255.0);
|
m_patternColorComponents[3] = (CGFloat) (info.GetColour().Alpha() / 255.0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2536,7 +2537,7 @@ public :
|
|||||||
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
wxDouble tx=0.0, wxDouble ty=0.0) wxOVERRIDE;
|
||||||
|
|
||||||
|
|
||||||
virtual wxGraphicsPen CreatePen(const wxPen& pen) wxOVERRIDE ;
|
virtual wxGraphicsPen CreatePen(const wxGraphicsPenInfo& info) wxOVERRIDE ;
|
||||||
|
|
||||||
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
virtual wxGraphicsBrush CreateBrush(const wxBrush& brush ) wxOVERRIDE ;
|
||||||
|
|
||||||
@@ -2705,14 +2706,14 @@ wxGraphicsMatrix wxMacCoreGraphicsRenderer::CreateMatrix( wxDouble a, wxDouble b
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxPen& pen)
|
wxGraphicsPen wxMacCoreGraphicsRenderer::CreatePen(const wxGraphicsPenInfo& info)
|
||||||
{
|
{
|
||||||
if ( !pen.IsOk() || pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
|
if ( info.IsTransparent() )
|
||||||
return wxNullGraphicsPen;
|
return wxNullGraphicsPen;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxGraphicsPen p;
|
wxGraphicsPen p;
|
||||||
p.SetRefData(new wxMacCoreGraphicsPenData( this, pen ));
|
p.SetRefData(new wxMacCoreGraphicsPenData( this, info ));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ class WXDLLEXPORT wxPenRefData : public wxGDIRefData
|
|||||||
public:
|
public:
|
||||||
wxPenRefData();
|
wxPenRefData();
|
||||||
wxPenRefData(const wxPenRefData& data);
|
wxPenRefData(const wxPenRefData& data);
|
||||||
|
wxPenRefData(const wxPenInfo& info);
|
||||||
virtual ~wxPenRefData();
|
virtual ~wxPenRefData();
|
||||||
|
|
||||||
wxPenRefData& operator=(const wxPenRefData& data);
|
wxPenRefData& operator=(const wxPenRefData& data);
|
||||||
@@ -79,6 +80,16 @@ wxPenRefData::wxPenRefData(const wxPenRefData& data)
|
|||||||
m_colour = data.m_colour;
|
m_colour = data.m_colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPenRefData::wxPenRefData(const wxPenInfo& info)
|
||||||
|
{
|
||||||
|
m_style = info.GetStyle();
|
||||||
|
m_width = info.GetWidth();
|
||||||
|
m_join = info.GetJoin();
|
||||||
|
m_cap = info.GetCap();
|
||||||
|
m_nbDash = info.GetDashes(&m_dash);
|
||||||
|
m_colour = info.GetColour();
|
||||||
|
}
|
||||||
|
|
||||||
wxPenRefData::~wxPenRefData()
|
wxPenRefData::~wxPenRefData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -98,45 +109,28 @@ wxPen::~wxPen()
|
|||||||
// Should implement Create
|
// Should implement Create
|
||||||
wxPen::wxPen(const wxColour& col, int Width, wxPenStyle Style)
|
wxPen::wxPen(const wxColour& col, int Width, wxPenStyle Style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
m_refData = new wxPenRefData(wxPenInfo(col, Width).Style(Style));
|
||||||
|
|
||||||
M_PENDATA->m_colour = col;
|
|
||||||
M_PENDATA->m_width = Width;
|
|
||||||
M_PENDATA->m_style = Style;
|
|
||||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_nbDash = 0 ;
|
|
||||||
M_PENDATA->m_dash = 0 ;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxColour& col, int Width, int Style)
|
wxPen::wxPen(const wxColour& col, int Width, int Style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
m_refData = new wxPenRefData(wxPenInfo(col, Width).Style((wxPenStyle)Style));
|
||||||
|
|
||||||
M_PENDATA->m_colour = col;
|
|
||||||
M_PENDATA->m_width = Width;
|
|
||||||
M_PENDATA->m_style = (wxPenStyle)Style;
|
|
||||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_nbDash = 0 ;
|
|
||||||
M_PENDATA->m_dash = 0 ;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxBitmap& stipple, int Width)
|
wxPen::wxPen(const wxBitmap& stipple, int width)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
m_refData = new wxPenRefData(wxPenInfo().Stipple(stipple).Width(width));
|
||||||
|
|
||||||
M_PENDATA->m_stipple = stipple;
|
RealizeResource();
|
||||||
M_PENDATA->m_width = Width;
|
}
|
||||||
M_PENDATA->m_style = wxPENSTYLE_STIPPLE;
|
|
||||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
wxPen::wxPen(const wxPenInfo& info)
|
||||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
{
|
||||||
M_PENDATA->m_nbDash = 0 ;
|
m_refData = new wxPenRefData(info);
|
||||||
M_PENDATA->m_dash = 0 ;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,18 @@ public:
|
|||||||
m_stipple = data.m_stipple;
|
m_stipple = data.m_stipple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPenRefData( const wxPenInfo& info )
|
||||||
|
{
|
||||||
|
m_width = info.GetWidth();
|
||||||
|
m_style = info.GetStyle();
|
||||||
|
m_joinStyle = info.GetJoin();
|
||||||
|
m_capStyle = info.GetCap();
|
||||||
|
m_colour = info.GetColour();
|
||||||
|
wxDash* dash;
|
||||||
|
m_countDashes = info.GetDashes(&dash);
|
||||||
|
m_dash = (wxX11Dash*)dash;
|
||||||
|
}
|
||||||
|
|
||||||
bool operator == (const wxPenRefData& data) const
|
bool operator == (const wxPenRefData& data) const
|
||||||
{
|
{
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
@@ -79,18 +91,20 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject);
|
|||||||
|
|
||||||
wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
|
wxPen::wxPen( const wxColour &colour, int width, wxPenStyle style )
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData(wxPenInfo(colour, width).Style(style));
|
||||||
M_PENDATA->m_width = width;
|
|
||||||
M_PENDATA->m_style = style;
|
|
||||||
M_PENDATA->m_colour = colour;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxColour& colour, int width, int style)
|
wxPen::wxPen(const wxColour& colour, int width, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData();
|
m_refData = new wxPenRefData
|
||||||
M_PENDATA->m_width = width;
|
(
|
||||||
M_PENDATA->m_style = (wxPenStyle)style;
|
wxPenInfo(colour, width).Style((wxPenStyle)style)
|
||||||
M_PENDATA->m_colour = colour;
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPen::wxPen(const wxPenInfo& info)
|
||||||
|
{
|
||||||
|
m_refData = new wxPenRefData(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::~wxPen()
|
wxPen::~wxPen()
|
||||||
|
Reference in New Issue
Block a user