Commit Graph

17922 Commits

Author SHA1 Message Date
Vadim Zeitlin
cf02d15646 Merge branch 'appveyor-tests'
Fix several problems in tests under MSW (mostly with MinGW) and enable
building and running them on AppVeyor CI.
2017-11-25 19:18:14 +01:00
Maarten Bent
2156d29801 Add FindOrCreateFont overload accepting wxFontInfo 2017-11-25 17:52:03 +01:00
Vadim Zeitlin
471a771382 Fix built-in wxPrintf() for repeated positional parameters
Allow wxPrintf("%1$s %1$s", "foo") to work.

Take into account the possibility that the number of format specifiers
and the number of actual arguments can be different.

Closes #9367.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
778340a286 Merge branch 'private-fonts'
Add support for using application-private fonts.

Closes #13568.

Closes https://github.com/wxWidgets/wxWidgets/pull/591
2017-11-24 22:58:09 +01: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
d6af0236c5 Simplify GTK+ 2 version checks with a helper function
Use wx_is_at_least_gtk2(minor) instead of gtk_check_version(2, minor)
because it is more clear and also works as expected (i.e. returns true)
when using GTK+ 3 instead of creating difficult to notice bugs in the
code by failing the version check in this case.

See #18004.
2017-11-23 13:15:31 +01:00
Vadim Zeitlin
04209e3a3e Remove GetStandardCmdLineOptions() from wxGTK
Unfortunately there is no reasonable way to implement this function for all
glibc versions as the information we need is stored in the private
_GOptionGroup struct whose layout has already changed once (in 2.44) and could
change again, so we can't rely on it.

We really need a g_option_group_get_entries() in glib itself, but the request
to add it at http://bugzilla.gnome.org/show_bug.cgi?id=431021 hasn't been
touched since 10 years, so it seems unlikely to happen.

See 99367a1530 (commitcomment-25789514)
2017-11-22 22:02:36 +01:00
Vadim Zeitlin
020c598c18 Rename wxExternalField methods to not mention "Window"
This class doesn't have to be used with wxWindow or similar as object
type, so use a more neutral "Object" instead of "Window".
2017-11-22 03:05:03 +01:00
Vadim Zeitlin
1863f494f3 Use wxExternalField for gestures data in wxGTK too
Don't waste memory on gesture data in all windows.
2017-11-22 03:05:03 +01:00
Vadim Zeitlin
6fd435b83f Extract "external field" approach in a reusable class
Add wxExternalField<> template that can be used for other fields and/or
in other ports too.
2017-11-22 03:05:03 +01:00
Vadim Zeitlin
9cb1f25a25 Use global map for storing wxCocoaGesturesImpl
This decreases the speed of access to this struct (which shouldn't
matter that much) but avoids allocating an extra and almost always
unneeded pointer for each and every window, which seems like a good
trade-off.
2017-11-22 03:05:03 +01:00
Vadim Zeitlin
3aefb679e4 Encapsulate gestures-related data in wxCocoaGesturesImpl
Avoid allocating a lot of almost never used data for every window and
use just a single pointer for holding all of it instead.
2017-11-22 03:05:02 +01:00
Vadim Zeitlin
a8dfaa569b Allow enabling individual touch gesture events
Implement support for enabling just some gesture events instead of
having to choose between getting none or all of them.

Also make wxTOUCH_NONE really disable the gestures events generation
instead of just doing nothing as before.
2017-11-22 03:05:02 +01:00
Vadim Zeitlin
842dd1cfd9 Add wxWindow::EnableTouchEvents()
Don't request touch event generation for all windows by default, this
has an inherent overhead and is not needed for 99% of the application
windows, so require calling EnableTouchEvents() explicitly to do it
instead.

Note that this requires properly initializing gesture recognizers in
wxOSX now that they're not always allocated, otherwise releasing them
when destroying the window would crash.
2017-11-22 02:24:24 +01:00
Vadim Zeitlin
bb2887930f Use wxPoint instead of (x,y) pair in wxPanGestureEvent
Using higher level objects makes the code generating and using this
event shorter and more clear.
2017-11-21 17:45:34 +01:00
Vadim Zeitlin
b3e726faed Refactor MSW gesture events initialization
Don't repeat the same code for initializing events in several different
functions but put it in a helper InitGestureEvent() function and just
call it from the event-specific handlers.
2017-11-21 17:25:55 +01:00
Vadim Zeitlin
c3dee8b0bc Merge branch 'vector-enhancements'
Make wxVector<> more compatible with std::vector<>.
2017-11-21 13:50:26 +01:00
Lauri Nurmi
f2a5fd303b Declare wxInvalidSize also in wx/dir.h
wxInvalidSize is a documented return value for wxDir::GetTotalSize(),
yet it was not available by including just wx/dir.h as it was declared
in wx/filename.h only.

Fix this by declaring it in wx/dir.h too.

Closes https://github.com/wxWidgets/wxWidgets/pull/609
2017-11-21 13:49:21 +01:00
Artur Wieczorek
1033a1636d Process HDN_ITEMCHANGING notifications only when column is being resized
When column resizing is finished, after HDN_ENDTRACK notification there is
also sent one (and last) HDN_ITEMCHANGING notification. We have to skip it
to prevent from sending EVT_HEADER_RESIZING after EVT_HEADER_END_RESIZE
because EVT_HEADER_END_RESIZE should be really the last one event
in the sequence of resizing events (like it's assumed in wxGrid).

Closes #16390.
2017-11-20 21:57:05 +01:00
Vadim Zeitlin
53443b5370 Add wxVector::shrink_to_fit() for C++11 compatibility
Also use this for wxArray::Shrink() implementation as it's more
efficient than the old swap-based implementation which requires an extra
memory allocation instead of really shrinking the existing one.
2017-11-19 22:09:37 +01:00
Vadim Zeitlin
9e714fdb5e Fix wxVector::assign() for integer parameters
Using assign() with int (in fact, any integral type) should select the
(size_type count, const T& value) overload, but didn't, which was
incompatible with std::vector<>.

Fix this by adding the same tag-dispatching technique as used by the
real std::vector<> implementations themselves, except that we dispatch
on integer types because we can't be totally certain that
std::iterator_traits<> are specialized for whatever iterator-like object
could be used with wxVector.
2017-11-19 22:08:54 +01:00
Vadim Zeitlin
8246c922af Add wxVector::insert() overload taking count of items to insert
Generalize the existing insert() to be more compatible with std::vector.
2017-11-19 22:08:54 +01:00
Vadim Zeitlin
25a7c70631 Implement wxVector::reverse_iterator::operator-()
Make wxVector reverse iterators (and const versions of them) more
compatible with the std::vector ones.
2017-11-19 22:08:54 +01:00
Vadim Zeitlin
5669e8dbe9 Add wxVector::operator==() and !=()
Make this class more consistent with std::vector<>.
2017-11-19 22:08:54 +01:00
Vadim Zeitlin
876090aeea Remove maximal reallocation size in wxVector
This dramatically pessimizes performance for large vector sizes and
doesn't actually save that much memory because all intermediate
allocations are still being used by the process, so follow stdlibc++
example and just double the allocated buffer size without limit.
2017-11-19 21:56:24 +01:00
Vadim Zeitlin
7b1dc191be Move wxGTK gesture-related data in a private opaque struct
This is a first step towards enabling gesture events only for the
windows that are interested in them as it will make it possible to avoid
wasting space on unused data in the windows that don't need it.

No real changes so far.
2017-11-17 18:06:06 +01:00
prashantkn94
261b04b5a3 Merge multi-touch gestures event branch
This is a squashed commit of the SOC2017_GESTURES branch from
https://github.com/prashantkn94/wxWidgets.git

Closes https://github.com/wxWidgets/wxWidgets/pull/551
2017-11-17 18:06:06 +01:00
Vadim Zeitlin
7481c74365 Make other wxGenericProgressDialog methods virtual too
Solve the same problem as was recently with hiding, instead of
overriding, Resume() in the native MSW wxProgressDialog class for all
the other methods which were also affected by it.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
dc5802746d Set wxProgressDialog::m_parent too
This, in addition to the previous commit, allows Centre() to work
correctly as it needs to retrieve the parent window rectangle.

See #17768.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
a8eccd21c7 Implement wxProgressDialog::DoGetSize() for the native dialog too
DoGetPosition() was done in 1ef1f8fda6,
implement DoGetSize() too now in order to give a chance Centre() (which
needs both position and size to work).

See #17768.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
ffe84cfb99 Factor out wxProgressDialog::GetTaskDialogRect()
No real changes, just prepare for implementing DoGetSize() in this class
by extracting the common part between the existing DoGetPosition() and
it in a new function.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
fdfd8efa83 Factor out wxTopLevelWindow::MSWEnableCloseButton()
Make it possible to reuse this code for other, non-wx, windows.

No real changes, this is just a pure refactoring.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
6818d0909e Factor out wxGenericProgressDialog::EnsureActiveEventLoopExists()
Make this function reusable in order to allow it to be called from the
native MSW wxProgressDialog implementation in the upcoming commit.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
0b96d3b905 Dispatch events from the native MSW wxProgressDialog too
Do this for compatibility with wxGenericProgressDialog, which always did
this and can't really do otherwise as it needs to react to the clicks on
its buttons, and also because not doing it results in the other
application windows being marked as "not responding" by MSW, which looks
bad.

Closes #17768.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
046d3be215 Don't require calling DoNativeBeforeUpdate() with locked CS
Acquire the lock in wxProgressDialog::DoNativeBeforeUpdate() itself
instead of relying on the caller to do it.

This is just a refactoring in preparation for further changes.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
8c5dae9491 Make wxGenericProgressDialog::Resume() virtual
It needs to be overridden in the native MSW wxProgressDialog
implementation, but was only hidden by the function with the same name
in the derived class, making it impossible to call the right function
via the base class pointer, for example.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
27110bfa72 Gracefully handle parent disappearance in wxGenericProgressDialog
Use a weak reference to the parent instead of a pointer to avoid
crashing if the parent TLW is destroyed before wxGenericProgressDialog
itself is. This is unlikely to happen in C++ code, where objects of this
class are typically created on the stack, but can happen in e.g.
wxPython where this is not the case.

Closes #16378.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
0473d14ef1 Make wxProgressDialog::Fit() work in native MSW version
This method is supposed to adjust the dialog size to its contents and
while the dialog increases automatically when using native
implementation under MSW, it doesn't shrink back on its own and so it's
still useful to allow Fit() to do it.

Update the sample to test Fit() too.
2017-11-16 01:35:49 +01:00
Paul Cornett
21620da3e5 Move GTK3 wxNO_BORDER handling to wxControl
So wxNO_BORDER works with other controls, such as wxBitmapButton.
Also use GTK prefix on ApplyCssStyle(), and add an overload that
creates the GtkCssProvider.
2017-11-15 10:51:38 -08:00
Vadim Zeitlin
ef0309c141 Fix wxTypeIdentifier::operator==() to be const
Comparing things doesn't change them.

Also rewrite operator!=() in terms of operator==() to ensure
consistency.
2017-11-14 15:58:17 +01:00
Vadim Zeitlin
283f5a4d56 Remove useless wxFont::ActivatePrivateFonts()
Just "activate" the font immediately when adding it using
AddPrivateFont(), nothing seems to be gained from having two functions
and it just makes things more complicated both when implementing and
when using the API.
2017-11-13 22:29:30 +01:00
Vadim Zeitlin
3158a46ce7 Require fontconfig >= 2.8 and change its guard macro name
FcConfigAppFontAddFile() that we use is only available since 2.8, so
check for at least this version of the library in configure.

Also change the macro guarding its use to the more semantically
appropriate "wxHAVE" rather than "wxUSE" and make it more precise by
adding "2_8_0" suffix to it.
2017-11-13 22:29:30 +01:00
Vadim Zeitlin
ed655bfcde Add wxFontEnumerator::InvalidateCache()
This is necessary to recognize new fonts, for example those added using
AddPrivateFont(), as being valid: otherwise they were not found in the
cache and couldn't be used in wxGTK.
2017-11-13 22:29:29 +01:00
Vadim Zeitlin
ac4f99fa0d Test for FontConfig availability in configure when using wxGTK
This library is now needed in order to implement wxFont private font
methods.
2017-11-13 22:29:29 +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
f65a608993 Remove declared but not implemented wxFont::Unshare() in wxGTK
No real changes, just remove a method which was never defined nor used.
2017-11-13 22:16:10 +01:00
Paul Cornett
65cc4c1624 Avoid ifdef-ed override specification
Instead, add the base class functions so the derived class always
overrides. If/when wxX11 and wxMotif are removed there won't be an
ifdef that no one ever notices isn't needed anymore.
2017-11-12 09:33:37 -08:00
Scott Furry
3653b753d3 Fix clang -Winconsistent-missing-override in wxGLApp
Use "override" for wxGLApp::GetXVisualInfo(), but only for wxGTK2 where
it really overrides it, unlike in wxX11.

Closes #17995.
2017-11-12 17:02:43 +01:00
Vadim Zeitlin
c98fa0ca98 Add wxWindowBase::SetDoubleBuffered() stub
This method was already provided by wxGTK and wxMSW, but not wxOSX nor
any other ports.

Provide a stub for it in wxWindowBase to allow user code to call it on
all platforms, there is no harm in that even if it doesn't (and can't)
do anything under macOS.
2017-11-11 11:47:56 +01:00
Vadim Zeitlin
66c644fe20 Merge branch 'text-stream-nuls'
Fixes for wxTextInputStream and wxMBConvUTF{7,16} classes bug fixes.
2017-11-10 03:14:01 +01:00