Commit Graph

167 Commits

Author SHA1 Message Date
Robin Dunn
b10c7a982f Remove misplaced wxOVERRIDE 2019-09-11 12:59:27 -07:00
Robin Dunn
53d3888180 Add another missed wxOVERRIDE 2019-09-05 17:51:51 -07:00
Robin Dunn
a8a19e25ee Various typo and coding style fixes 2019-09-05 13:33:15 -07:00
Robin Dunn
f7896d4dff Use new parameter names in the existing CreateRadialGradientBrush methods too 2019-09-04 14:19:24 -07:00
Robin Dunn
80f24d9e74 User more easily understandable names for the radial gradient coordinate parameters in wxGraphicsPenInfo 2019-09-04 14:19:24 -07:00
Robin Dunn
1e37cca162 Like Direct2D inverting the matrix is needed for gradient transforms 2019-09-04 14:19:24 -07:00
Robin Dunn
8478c97ecb Add support for gradient pens for GDI+. API also updated for gradient transforms, but that is not working yet. 2019-09-04 14:19:24 -07:00
Robin Dunn
2008d443a8 Set the wrap mode for linear gradient brushes,
so the areas beyond the end points are properly filled with the end point colors
2019-09-04 14:19:24 -07:00
Maarten Bent
d10ed0b991 Implement wxPolygonFillMode in GDI+ and D2D graphics contexts
Honour "fillStyle" parameter, which was previously ignored.

Closes https://github.com/wxWidgets/wxWidgets/pull/1478
2019-08-20 13:32:29 +02:00
Vadim Zeitlin
bf515d769a Fix size of text drawing using wxGraphicsContext when printing
When using both wxEnhMetaFileDC (used for print preview) and
wxPrinterDC, a global scale factor was applied to the graphics context
in wxGDIPlusPrintingContext ctor and this changes size of the text
rendered using size specified in point units.

To prevent this from happening, stop applying this scale factor in the
base class GetTextExtent() and apply it instead when setting fonts in
the derived wxGDIPlusPrintingContext only. This ensures that the results
are consistent between GetTextExtent() and DrawText() and also keeps
the font scale hack entirely in wxGDIPlusPrintingContext without
affecting the base class.

It's still not totally clear why do we have to do this at all even
although we specify the font sizes in UnitPoint units which ought to be
DPI-independent -- but somehow are not. But at least the output is
correct now and the code is arguably more clear than before.

This fixes a regression with text size when printing or previewing
introduced by d5020362ff

Closes #18338.
2019-02-08 16:49:38 +01:00
Vadim Zeitlin
21661d51d8 Remove unnecessary wxGDIPlusPrintingContext dtor
No real changes.
2019-02-08 16:16:02 +01:00
Vadim Zeitlin
c08ea68b4a Avoid unnecessary calls in wxGDIPlusContext::GetTextExtent()
Don't always call several GDI+ functions when we often don't need their
results: only retrieve the cell descent, ascent and the line spacing if
we are going to really use any of these values.
2019-02-03 22:46:02 +01:00
Vadim Zeitlin
5e53b22bd4 Add wxGraphicsContext::GetWindow()
This method allows to retrieve the window this context is associated
with, if any.

Add "wxWindow*" argument to wxGraphicsContext ctor and provide the
window pointer to it when available, i.e. when creating the context from
a wxWindow directly or from wxWindowDC, which is also associated with a
window, in platform-specific code.

No real changes yet.
2018-11-06 03:36:53 +01:00
Vadim Zeitlin
713a7ab895 Move wxUSE_ENH_METAFILE check inside wx/msw/enhmeta.h itself
This is more consistent with the other headers, which are safe to
include even when the corresponding feature is turned off.

Also remove the now redundant wxUSE_ENH_METAFILE checks in the source
code including this header.

See https://github.com/wxWidgets/wxWidgets/pull/951
2018-09-26 14:47:45 +02:00
Vadim Zeitlin
d5020362ff Handle fractional point sizes in GDI+ wxGraphicsFont
Also switch to using UnitPoint when creating GDI+ fonts as it's not
clear at all why should we use UnitPixel here.
2018-09-17 15:24:42 +02:00
Vadim Zeitlin
d605405ca1 Fix building wxMSW GDI+ graphics code in non-Unicode build
Use wc_str() with GDI+ function which always takes wide strings, even in
non-Unicode build.

Closes #18172.
2018-07-21 14:08:45 +02:00
Artur Wieczorek
f258dc4c64 Fix setting current point of wxGraphicsPath (GDI+)
After executing native operations on the graphics path, the native
current point is updated properly and should be used instead
of manually maintained logical point.

See #18111.
2018-07-02 20:24:43 +02:00
Vadim Zeitlin
b040dab0ca Add wxUSE_PRIVATE_FONTS and drop wxHAS_PRIVATE_FONTS
Handle this feature as all the other ones and provide a configure switch
and a setup.h option to disable it if necessary, as it may be desirable
to do it, especially under Linux, to avoid extra dependency on pangoft2
if this functionality is unnecessary.
2017-11-24 22:56:17 +01:00
Vadim Zeitlin
4f5f4af3b1 Compilation fixes for wxUSE_STL==1 build
Add an explicit call to wc_str() in one place where conversion to
wchar_t* is needed and use wxString::operator==() instead of lstrcmp()
to avoid having to perform this conversion explicitly in another place.
2017-11-13 22:29:29 +01:00
Vadim Zeitlin
149807db26 Move wxMSW wxFont private font methods to src/msw/font.cpp
This ensures that they will be defined and work even when building with
wxUSE_GRAPHICS_CONTEXT==0 (as can happen even by default with old MinGW
versions).

Private fonts are still made available to wxGraphicsContext as well by
providing access to them from GDI+ code via wxGetPrivateFontFileNames().
2017-11-13 22:29:28 +01:00
Arthur Norman
547e40b114 Add support for loading fonts from files.
wxFont::AddPrivateFont() can now be used to load a font from a file for the
applications private use. Update the font sample to show this.

Closes #13568.
2017-11-13 22:29:28 +01:00
Vadim Zeitlin
76fd05b147 Leave only wxGraphicsRenderer::CreatePen(wxGraphicsPenInfo) overload
It doesn't make much sense to require all the graphics backends to
create wxGraphicsPen from either wxPen or wxGraphicsPenInfo when the
former can be handled just once in the common code.

So do just this, leaving CreatePen() overload taking wxGraphicsPenInfo
where the real pen construction takes place and implementing
wxGraphicsPen creation from wxPen in the common wxGraphicsContext code.

This is not 100% backwards-compatible as any code inheriting from
wxGraphicsRenderer and overriding its CreatePen() will now be broken,
however this should be extremely rare (there is no good reason to
inherit from this class in the user code) and result in compile errors
if it does happen.
2017-09-10 01:48:30 +02:00
Vadim Zeitlin
cc91a7d6d4 Minor formatting and style changes in wxPenInfo code
Use more standard formatting, wrap some overlong lines.
2017-09-10 01:11:06 +02:00
Adrien Tétar
999c750ca7 Review feedback 2017-09-10 01:02:21 +02:00
Adrien Tétar
2305604565 Introduce wxGraphicsPenInfo class 2017-09-10 01:02:20 +02:00
Václav Slavík
e71be91ebe Add API to create wxGraphicsContext from win32 HDC
Add wxGraphicsContext::CreateFromNativeHDC() and wxGraphicsRenderer::
CreateContextFromNativeHDC() to allow creation not only from native
renderer object, but also from HDC, which is something universally
supported by win32 implementations.
2017-01-06 14:35:09 +01:00
Paul Cornett
9b19a6e529 use wxOVERRIDE in wxMSW sources 2016-09-23 07:59:11 -07:00
Artur Wieczorek
e68bd5a319 Fix compilation breakage due to missing FLT_MAX, FLT_MIN
Include <float.h> header file unconditionally.
2016-08-22 21:04:38 +02:00
Artur Wieczorek
1222a9d769 Fix for PCH-less build for wxGDIPlusContext
Including <float.h> header is required for FLT_MAX, FLT_MIN.
2016-08-22 00:03:28 +02:00
Artur Wieczorek
92557dad1c Define REAL_MIN, REAL_MAX if GDI+ headers don't do it
This should fix compilation with MinGW.
2016-08-21 23:44:59 +02:00
Artur Wieczorek
480a003c00 Add wxGraphicsContext::GetClipBox() function
This method returns bounding box of the current clipping region.
Added declaration, documentation and implemented for GDI+, Direct2D, Cairo renderers.
2016-08-21 20:57:40 +02:00
Artur Wieczorek
edabb01032 Add initial line segment when adding arc to wxGraphicsPath with GDI+
For the sake of compatibility with Cairo (and Direct2D) an initial line segment should be added to the path from the current point (if set) to the beginning of the arc.

Closes #17557
2016-06-05 19:00:13 +02:00
Artur Wieczorek
1f49c4bf40 Fixed adding arc to wxGraphicsPath with GDI+ renderer.
To handle properly all combinations of the start and end angles and to ensure consistency with Cairo renderer behaviour there is necessary:
1. To normalize angle values the same way as it is done in Cairo.
and
2. When end angle equals start angle then actually no arc should be added but current point of the path has to be updated.
3. When difference between end angle and start angle >= 2*pi then in addition to the arc itself also one or more full circles have to be added to the path.

Closes #17558
2016-06-04 11:13:13 +02:00
Artur Wieczorek
d81fb0be63 Use native methods to draw some geometric figures using GDI+ renderer
Use native methods provided by GDI+ renderer to draw circles and ellipses.

Closes #17554
2016-05-31 21:31:16 +02:00
Artur Wieczorek
43be7073cd Make closing sub-path of wxGraphicsPath with GDI+ renderer compatible with Cairo renderer.
Cairo renderer places MOVE_TO element into the path immediately after after the CLOSE_PATH element so to ensure that GDI+ will behave in the same way the new sub-path should be started at the joined endpoint of the current just closed sub-path.

See #17532
2016-05-12 21:26:25 +02:00
Artur Wieczorek
49a634e63f Fixed closing sub-path of wxGraphicsPath with GDI+ renderer.
Add additional point to the sub-path being closed only if this sub-path is empty (its native current point is not set).
2016-05-12 21:18:24 +02:00
Artur Wieczorek
5ffbc7c175 Fixed applying transformation to wxGraphicsPath with GDI+ renderer.
Auxiliary points as well as the native path points have to be the subject of the transformation.
2016-05-12 21:16:51 +02:00
Artur Wieczorek
08cb54c4c1 Fixed wxGraphicsPath concatenation with GDI+ renderer.
Since resulting wxGraphicPath should have the same state as appended path so we have to grab in wxGraphicsPath::AddPath also auxiliary data from appended wxGraphicsPath.

See #17532
2016-05-12 21:15:19 +02:00
Artur Wieczorek
22c520e3e8 Fixed adding a Bezier curve to wxGraphicsPath with GDI+ renderer.
When current point is not set before the call to wxGraphicsPath::AddCurveToPoint() then it should be set at first control point prior to adding a curve (function should behave as if preceded by MoveToPoint).

See #17526
2016-05-09 18:40:10 +02:00
Artur Wieczorek
24dfd62fc0 Fixed closing sub-path of wxGraphicsPath with GDI+ renderer.
Ensure that sub-path being closed contains at least one point.

See #17525.
2016-05-08 21:52:04 +02:00
Artur Wieczorek
17e24fec73 Fixed adding a line to wxGraphicsPath with GDI+ renderer.
When current point is not yet set then wxGraphicsPath::AddLineToPoint() should behave as MoveToPoint().

See #17525
2016-05-08 21:51:01 +02:00
Artur Wieczorek
fab6d0e757 Fixed closing sub-path of wxGraphicsPath with GDI+ renderer.
Close sub-path only if it is really open.
2016-05-06 18:51:01 +02:00
Artur Wieczorek
984e54ffdd Fixed closing sub-paths of wxGraphicsPath with GDI+ renderer.
When sub-path is closed with CloseSubpath() then current point should be moved to the joined endpoint of the sub-path (what is equivalent of moving it to the starting point of the sub-path). Native CloseFigure() doesn't move the native current point to the starting point of the figure so we need to maintain it on our own in this case.
To implement this behaviour we need to store the starting point of the figure in a dedicate data member and use it to update the current point when the figure is closed.
But native GDI+ renderer doesn't offer any support for updating directly the current point (only explicit drawing operations update its value) so we need also to remember our "logical" current point (being the result of calling CloseSubPath, MoveToPoint, etc.) in a dedicated data member and use it instead of the native current point in the next operation which requires current point location.

Closes #17520
2016-05-05 13:52:12 +02:00
Artur Wieczorek
6879311b98 Fixed appending a line to wxGraphicsPath with GDI+ renderer.
New line appended to the path should be started explicitly at the current point.

See #17520
2016-05-05 13:50:52 +02:00
Kolya Kosenko
bb2b48f2ba Handle negative width size in GDI+ DrawRectangle() and document it
Apparently it's a common convention to allow width and/or height of a
rectangle to be negative as both GDI and Cairo handle this natively, so also
allow this for GDI+ and document this as the expected behaviour.

Closes #17495.
2016-04-23 18:31:01 +02:00
Artur Wieczorek
9c83dd8d3e Added checking parameters of wxGDIPlusRenderer::CreateSubBitmap method.
Check if source bitmap is valid and whether sub-bitmap is entirely within it.
2016-03-24 22:24:55 +01:00
David Vanderson
ccd361c98f Fix strike-through support in wxFont with GDI+
Pass down the strike-through flag to GDI+ (see #9907).

Closes #17372.
2016-02-13 12:49:21 +01:00
Artur Wieczorek
976e3115b7 Always use DIBs in wxMSW wxGCDC.
Ensure that 32bpp bitmaps selected in wxMemoryDC use DIB for their internal
representation as GDI+ functions don't seem to work correctly with DDBs.

Note: Code responsible for converting and fixing the bitmap has been moved
from wxGCDCImpl::wxGCDCImpl to wxGDIPlusRenderer::CreateContext because this
is the common entry point for creating context for GDI+.

Closes #17324.
2016-01-16 13:20:06 +01:00
Artur Wieczorek
527c25b898 Store alpha channel in the output wxImage only if internal GDI+ bitmap contains it.
When converting internal bitmap to wxImage in wxGDIPlusBitmapData::ConvertToImage set up output alpha channel buffer only if source bitmap contains alpha channel values.
2016-01-04 22:59:44 +01:00
Artur Wieczorek
ca8f5eae93 Optimize converting internal GDI+ bitmap to wxImage
Write retrieved pixel data directly to the internal buffers of destination wxImage.
2016-01-03 15:13:39 +01:00