Commit Graph

63623 Commits

Author SHA1 Message Date
Vadim Zeitlin
5f5c5b8f29 Remove hard TAB from event sample bakefile
No real changes.
2017-11-22 03:05:03 +01:00
Vadim Zeitlin
7535854ec4 Embed the image into the event sample
Don't load it from the image sample directory, this doesn't necessarily
work under Unix if the image sample hadn't been built.

Just embed an XPM image directly into the sample, this is good enough
for demonstration purposes.
2017-11-22 03:05:03 +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
fd3a3e607b Extract SetupCoordinates() from wxWidgetCocoaImpl
Add a free function that can be used from outside wxWidgetCocoaImpl
class too and keep the old method as a trivial wrapper around it.

No changes, this is a pure refactoring.
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
2ee40f8a60 Add a build using GTK+ 3 to Travis
We need to test both wxGTK2 and wxGTK3 builds.
2017-11-22 02:33:53 +01:00
Vadim Zeitlin
38e441bdd8 Don't install libcppunit-dev under Travis CI any more
It is not needed since the switch to Catch for unit tests.
2017-11-22 02:31:47 +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
e7f4e232fa Use "class" for wxGTK wxWindowGesturesData definition
No real changes, just be consistent with wxWindowGesturesData forward
declaration as "class", clang (and MSVC) warn about mismatching keywords
being used for declaration and definition.
2017-11-21 18:45:53 +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
db71a10b29 Set rotation angle for the initial rotate gesture event in MSW
According to MSDN, for the initial rotation even the angle is just
passed directly, so use it.
2017-11-21 17:27:42 +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
989dd36405 Style fixes in the MSW gestures code
No real changes, just reformat code and comments to fit in 80 column
lines.
2017-11-21 16:12:37 +01:00
Vadim Zeitlin
daf19c652c Use WinStruct<> to initialize GESTUREINFO
This is more concise and clear than initializing it manually.
2017-11-21 16:12:35 +01:00
Vadim Zeitlin
7ffb897810 Remove unnecessary assignments in WM_GESTURE handler code
The "processed" flag is false by default, no need to explicitly reset
it, this was just confusing.
2017-11-21 16:12:32 +01:00
Vadim Zeitlin
59f428d25e Slightly simplify GestureFuncs code
Document that the users of this class always must call IsOk() first, as
they already do, and remove the checks for ms_gestureSymbolsLoaded and
calls to LoadGestureSymbols() from all the other methods, which are
unnecessary in this case.
2017-11-21 16:12:30 +01:00
Vadim Zeitlin
bf929f9868 Use wxLoadedDLL for loading user32.dll dynamically
This avoids unnecessarily loading and unloading (except that it's not
really unloaded) a DLL which is always available anyhow.
2017-11-21 16:05:33 +01:00
Vadim Zeitlin
f7d9098f1f Fix building wxVector unit tests in STL build without C++11
There is no shrink_to_fit() in wxVector in this case.

Arguably, we shouldn't be building wxVector unit tests in STL build at
all as there is no point in testing the standard class, but OTOH it
could be useful for checking that the tests themselves are correct, so
keep them for now.
2017-11-21 14:44:06 +01:00
Vadim Zeitlin
4ccda3959e Show more information for wxImage::Scale() unit test failures
Output the maximal difference between the differing images pixels to
show just how far are they from each other, exactly. And show the image
file name as well, for convenience.

Also run all checks instead of stopping after the first failing one.
2017-11-21 14:27:29 +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
8f9c4470d7 Merge branch 'arrays-alloc-optimise'
Reduce the number of memory allocations in wxArrayString and wxVector.
2017-11-19 23:13:43 +01:00
Vadim Zeitlin
7ba4832c0f Merge branch 'sound-async-unix'
Minor fixes to Unix wxSound implementation, including async API and OSS
backend tweaks.
2017-11-19 22:59:14 +01:00
Vadim Zeitlin
3590273503 Document that osspd requirement for using OSS under Linux
Without SDL, wxSound doesn't work out of the box on most (all?)
contemporary Linux systems, so at least document this.

See #14899.
2017-11-19 22:51:51 +01:00
Vadim Zeitlin
2558c91ae8 Don't fail to okay all mono WAVs in OSS wxSound backend
Ever since the changes of 544c4a3bde
(almost 14 years ago), playing mono WAVs with wxSound completely failed
if setting the sound device to mono using SNDCTL_DSP_STEREO ioctl
failed. This doesn't look like a wise thing to do, so don't consider
this as a fatal failure, but just play mono as stereo (and even possibly
stereo as mono) instead.

This fixes the sound sample being broken out of the box on many (all?)
Linux systems.
2017-11-19 22:44:57 +01:00
Vadim Zeitlin
d788588cfc Use wxMutexLocker instead of manual Lock/Unlock() calls
This is safer and also makes the code simpler and shorter.
2017-11-19 22:37:36 +01:00
Vadim Zeitlin
6c1a557a0f Lock and unlock mutex in both wxSound threads using it
The code was completely broken as it locked the mutex in only one thread
and then tried to unlock it in another one, which made no sense, didn't
protect against anything and resulted in errors and assert failures.

Fix this by locking and unlocking the mutex in both threads before
accessing shared data or playing sound.

Closes #17990.
2017-11-19 22:37:36 +01:00
Vadim Zeitlin
6ebc56939f Acquire mutex before modifying variable in wxSoundSyncOnlyAdaptor
The mutex must be locked to avoid data races with the thread actually
playing the sound.
2017-11-19 22:37:36 +01:00
Vadim Zeitlin
f7e5fb61b1 Remove unused wxSoundSyncOnlyAdaptor::m_playing variable
It seems to have been replaced by wxSoundPlaybackStatus::m_playing a
long time ago but was still kept, resulting in confusion and always
returning false from IsPlaying() as it tested a wrong variable.

Fix this by removing this one completely and always using the other one
everywhere.
2017-11-19 22:37:36 +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
abce2a9428 Use the same growth strategy in wxArrayString as in wxVector
Remove maximal reallocation size in wxArrayString too, as it was done
for wxVector a commit ago, and increase its size by 100% and not 50%
when it needs to grow.

There is no real reason to use different growth strategies in the two
classes and wxVector one seems to be better.
2017-11-19 22:02:26 +01:00
Vadim Zeitlin
d3132b114c Optimize memory allocation in wxArrayString ctors
Call assign() instead of Add() in a loop: this is not only shorter, but
also ensures that reserve() is called before starting the loop and all
the required memory is allocated at once.
2017-11-19 21:59:02 +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
6ba3db7753 Destroy GtkGestures objects we create
We seem to be leaking memory otherwise.
2017-11-17 18:06:06 +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
Vadim Zeitlin
06d936f3f7 Make tests for gestures in wxGTK code more clear
Use wxGTK_HAS_GESTURES_SUPPORT to guard gesture-related code instead of
checking for the 3.14 GTK+ version explicitly in several places.

No real changes.
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
aef4edb969 Merge branch 'progress-dialog-fixes'
Make native MSW wxProgressDialog much more usable and some minor
improvements to the generic version.
2017-11-17 18:00:16 +01:00
Vadim Zeitlin
ca0557a6eb Merge branch 'release-scripts' 2017-11-17 17:56:41 +01:00
Vadim Zeitlin
dc751d3f33 Add a hint about making wxProgressDialog initially wide enough
Using unbreakable spaces to achieve this looks like a hack, but seems to
be the only thing working well in practice.
2017-11-16 23:52:36 +01:00
Vadim Zeitlin
d4d3222466 Split initial wxProgressDialog message consistently with updates
Native wxMSW dialog split the provided message into the title and body
in Update(), but didn't do it for the initial message specified when
constructing the dialog, resulting in weird jumps, due to the font size
change between the body and title dialog elements, if the updated
message differed just slightly from the initial one.

Fix this and refactor the code to reuse the same function for doing this
splitting in both places.
2017-11-16 23:52:33 +01:00