Commit Graph

65027 Commits

Author SHA1 Message Date
Vadim Zeitlin
ea00b0b603 Use SetFractionalPointSize() in wxMarkupParser code
Now that fractional sizes are supported, use them instead of rounding up
to integer size.
2018-09-17 15:24:42 +02:00
Vadim Zeitlin
e65381c8ee Show fractional point size and numeric weight in wxDumpFont()
Update to show the new wxFont fields.
2018-09-17 15:24:42 +02:00
Vadim Zeitlin
18d7801346 Fix wxMotif build after wxFont API changes
Run-time seems to be totally broken, but fonts are probably not the most
important problem in this port, so don't bother fixing it.
2018-09-17 15:24:42 +02:00
Vadim Zeitlin
90dd87ee65 Fix wxGTK1 build after wxFont API changes
Implement the new {Get,Set}{FractionalPointSize,NumericWeight} methods.

Also change wxLoadQueryFont() to use wxNativeFontInfo methods as a side
effect, to reduce code duplication and reuse the existing support for
numeric weights and fractional point sizes in wxNativeFontInfo.
2018-09-17 15:24:42 +02:00
Vadim Zeitlin
aff4b82663 Don't assert in wxNativeFontInfo::SetStyle() in wxGTK1
Add missing "break" statement.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
3e2fd136ff Disable tons of warnings given during wxGTK1 build
These warnings are not going to be fixed, so suppress them to at least
see the other ones more clearly.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
140b3c5e65 Disable wxGraphicsContext in wxGTK1 build, it doesn't compile
There is no chance of wxGraphicsContext ever being supported in this
legacy port, but at least disable it automatically instead of requiring
to specify --disable-graphics-ctx on the command line.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
468545943a Remove unnecessary line from the font sample
This was mistakenly left over in the commit adding private fonts support
(547e40b114).
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
720e1372e4 Allow leaving the point size unspecified for ports using XLFD
Rather than defaulting to the normal font size, just leave the font size
unspecified as it might result in better font size being chosen.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
22839b865d Fix bug with point sizes in wxX11 without Pango
XLFD strings specify size in tens of points, so add the missing factor
of 10.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
9627798496 More steps towards using wxFontInfo in all ports
Replace AccountForCompatValues() with InfoFromLegacyParams() which
directly constructs wxFontInfo from the old-style parameters, applying
all the compatibility hacks internally.

There are no real changes in this commit, just simplify the code further
and make wxFontInfo more central.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
7866c293e8 Add wxFontInfo::HasFaceName() and use it
No real changes, just simplify the code a little by adding this helper.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
03266b1091 Add wxFontRefData ctor from wxFontInfo to wxQt
This actually implements support for the fractional font sizes, as
previously the fractional part was lost when passing by the legacy
Create() taking only integer size.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
ce1e69cfa1 Implement wxNativeFontInfo::SetPixelSize() in wxQt
There doesn't seem to be any way to specify both font width and height
and pixels in Qt API, so just use QFont::setPixelSize() with the height.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
8715e56676 Remove unnecessary wxFontRefData::operator==() in wxQt
It wasn't used anywhere anyhow.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
d002acfec6 Add "Apply" button to the font sample
Live changes don't work correctly in all ports, notably wxQt, which
doesn't seem to generate the events correctly for wxSpinCtrl, so add a
button to apply the changes.

This could be seen as a better UI anyhow.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
2d8decd7f4 Improve mapping of font weights between Qt and wx
Support the entire [0, 99] range used by Qt instead of just some
selected values while still mapping all the predefined symbols to their
corresponding wx equivalents.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
f5cd9a7934 Update wxFont in wxQt after recent base class interface changes
Trivially implement the new wxFont::{Set,Get}{FractionalPointSize,
NumericWeight}() methods in terms of the corresponding wxNativeFontInfo
methods.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
9b661b918e Fix indentation of wxQt wxFontRefData declaration
No real changes.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
11c6009f68 Deprecate old wxFont(int, int, int, int) ctor in wxQt
It might be better to just remove it completely as legacy code is
unlikely to be built with wxQt, but for now at least deprecate it to
make this consistent with the other ports.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
de7ab2a45f Remove unnecessary wxFontRefData dtor in wxOSX too
Smart pointers will clean up the resources automatically, there is no
need to call Free() manually from the dtor.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
d9b62e0832 Initialize wxFontRefData::m_info directly in wxOSX code
Instead of using default ctor and Init() later, just use the appropriate
ctor directly.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
a860f5710b Change wxFontRefData ctor to take wxFontInfo in wxOSX too
Change wxOSX similarly to wxGTK and wxMSW in the two previous commits.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
34e01aa62d Change wxFontRefData ctor to take wxFontInfo in wxMSW
Apply the same change as was done for wxGTK in the previous commit to
wxMSW too, for the same reasons.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
7c9daf2e81 Change wxFontRefData ctor to take wxFontInfo in wxGTK
wxFontInfo is the preferred way to create wxFont objects, so rewrite the
internal classes to use it directly and implement the other ctors as
wrappers for the one taking wxFontInfo.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
c61fc16f96 Add wxFontInfo::Style() for consistency with Weight()
This will also be useful when changing the existing code to use
wxFontInfo().
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
11ab3b4786 Remove unnecessary wxFontRefData dtor
No real changes, just get rid of unnecessary code.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
a0d5b1e5da Get rid of wxDEFAULT_FONT_SIZE constant in wxGTK
Don't hardcode 12pt font size but use the size of the normal font
instead.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
f7a7fe6c4a Add wxNativeFontInfo::SetSizeOrDefault() and use it in all ports
Reuse the same code for determining the default font size to use if it
wasn't specified in all major ports.

In particular, make wxGTK behaviour compatible with the rest and use the
normal font size in this case instead of the hardcoded value of 12pt.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
24c83625f6 Remove Mac-specific wxFont ctors and fix strikethrough support
Only accept fractional point sizes and numeric weights via wxFont ctor
using wxFontInfo and avoid having specific ctor/Create() overloads for
the different combinations of font properties: this is not portable (as
these ctors don't exist in the other ports) and unsustainable due to the
very real potential of combinatorial explosion as more properties are
added.

As a side-effect, fix support for stricken-through fonts under Mac,
which was broken, by adding the missing wxFontInfo::IsStrikethrough()
call.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
cb8dc4d745 Allow changing the values of font properties in the sample
Use new wxFontInfo methods to allow testing setting fractional font
sizes and arbitrary numeric weight values in the sample.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
cfa37fefae Fix initial size of the font sample main window
Don't hard code main frame size in pixels, this is simple but wrong.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
a79bbf7348 Show font properties in controls in the font sample
This is done in preparation for allowing to change these control values,
although for now this is not implemented yet.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
09fdd090fa Exchange the font and test panels in the font sample
No real changes, but it seems to make more sense to show the font
information first and less important text sample below.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
6415bd553f Partially revert "CMake: Fix building and running samples"
This reverts part of 573e887a4c, see
https://github.com/wxWidgets/wxWidgets/pull/666 because it broke the use
of the generic dialogs in the sample under MSW (they were not used any
more, even if they were supposed to) and the explanation in the original
commit message doesn't seem correct: the WXUSINGDLL check is precisely
supposed to check if we're using a static build of wxWidgets (presumably
because of DLL export complications when not using it) and seems to work
as expected.

This allows to test generic dialogs in the sample again under MSW.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
ad9ef5f24d Remove unused variable from the font sample
No real changes.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
054c5c4af7 Implement support for numeric weights specified in wxFontInfo
Update the major ports to use wxFontInfo::GetNumericWeight() instead of
GetWeight().
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
23f2929eb4 Add wxFontInfo::Weight()
Also add not yet used wxFontInfo::GetNumericWeight().
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
ff5766a8fb Move GetWeightClosestToNumericValue() to wxFontInfo too
This is similar to a recent commit which moved float to int point size
conversions to wxFontInfo and is done for the same reasons: wxFont and
wxNativeFontInfo can depend on wxFontInfo, but the converse is not true.

No real changes.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
0a23e8dfbe Use portable wxFont ctor instead of Mac-specific one
No real changes, just use wxFont ctor taking wxFontInfo instead of a
Mac-specific ctor.

This is more clear and will continue to work after Mac-specific ctor is
removed.
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
27434db911 Add wxFontInfo ctor taking fractional font size in points
And implement support for it in the major ports.

Also add wxFontInfo::GetFractionalPointSize().
2018-09-17 15:24:41 +02:00
Vadim Zeitlin
2823e289d8 Store fractional point size in wxMSW wxNativeFontInfo
We can't losslessly recover the fractional point size from LOGFONT, so
store it in parallel.
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
4be459d98e Use wxNativeFontInfo ctor instead of manually setting its fields
This will be important when new fields are added to wxNativeFontInfo as
the ctor will be extended to initialize them, while this code wouldn't
do it.

No real changes yet.
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
5a6b7681d8 Refactor float to int point size conversions once again
They will be also needed in wxFontInfo soon, so move them there and use
these functions from both wxFont and wxNativeFontInfo, as they can
depend on wxFontInfo but not the other way round.

No real changes.
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
7500a999bd Add numeric weights support for ports using XLFD-based fonts
Translate numeric weight to the symbolic name too instead of only doing
it in the other direction in GetNumericWeight().
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
6dd9f4208e Make converters between wxFontWeight and raw values public
These functions can be useful outside of src/common/fontcmn.cpp and,
potentially, even in the user code, so make them public methods of
wxFont.

No real changes, just add asserts verifying input argument value to
GetWeightClosestToNumericValue().
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
4e0b4e5939 Fix wxDFB build after the font changes
Implement the new wxFont pure virtual methods in this port version of
this class.

Neither arbitrary weights nor fractional point sizes are actually
supported in this port however.
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
1f95a041e9 Fix arbitrary numeric weights in the generic wxNativeFontInfo
Store the weight as int, not wxFontWeight, and rely on the same wrappers
as all the other ports in the port not having native wxNativeFontInfo.

This is a prerequisite for fixing wxDFB and other Unix ports not using
Pango.
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
8955b4b2fb Fix wxX11 build after fractional point size changes
Define {Get,Set}FractionalPointSize() in wxX11 wxFont implementation.

Note that only Pango-based version really supports floating point sizes
as XLFD can't express them.
2018-09-17 15:24:40 +02:00
Vadim Zeitlin
c98879e379 Add wxFont::SetFractionalPointSize()
Changing SetPointSize() argument type from int to float wasn't 100%
backwards-compatible as it notably started resulting in warnings (from
at least MSVC) about conversions from int to float in the existing code.

To avoid these warnings and for symmetry with GetFractionalPointSize(),
add SetFractionalPointSize() taking float argument and preserve the
argument of type int in SetPointSize() for compatibility.

SetPointSize() is now just a wrapper forwarding to the more general
SetFractionalPointSize().

Notice that the other ports still remain broken, this commit only
updates the currently working wxGTK, wxMac and wxMSW.
2018-09-17 15:24:40 +02:00