Commit Graph

77 Commits

Author SHA1 Message Date
Vadim Zeitlin
8fcf46f65c Forbid creation of wxPaintEvent objects from user code
This doesn't work anyhow, so it's better to prevent the code doing this
from compiling instead of getting run-time asserts or worse.

Also simplify construction of these events inside wxWidgets by passing
the window itself to the ctor instead of passing just its ID and calling
SetEventObject() separately later.

For consistency, do the same thing for wxNcPaintEvent too.
2020-02-10 23:03:01 +01:00
Vadim Zeitlin
3a09975465 Create WXSendContextMenuEvent() helper function
Put common code from all the different ports into it.

This is not very useful right now, but it will allow to change this
function once, instead of applying the same change to all ports, in the
upcoming commit.
2020-01-07 18:22:09 +01:00
Matthew Griffin
f608b340c2 Send set cursor events whenever there is mouse movement
This is required in order to allow application code to change the cursor
dynamically.

Closes https://github.com/wxWidgets/wxWidgets/pull/1549
2019-09-27 14:00:02 +02:00
Graham Dawes
3668ff5170 Update menu UI before showing a popup menu in wxQt
Give the application code a possibility to disable or otherwise change
the menu items before the popup menu is shown, as in the other ports.

Closes https://github.com/wxWidgets/wxWidgets/pull/1532
2019-09-27 13:26:25 +02:00
Matthew Griffin
2c91463c81 Enable mouse tracking on construction of every wxQt widget
Not all controls use wxWindow::Create(), so move setMouseTracking() call
where it is always executed.

Closes https://github.com/wxWidgets/wxWidgets/pull/1528
2019-09-27 13:24:29 +02:00
Vadim Zeitlin
54c1359d1f Add precondition checks to Do{Get,Set}ClientSize()
Don't crash if these methods are called before the window is created.
2019-09-22 02:38:59 +02:00
Graham Dawes
cd7594e639 Don't include scrollbars in client area size
Return the size of just the viewport when using QScrollArea.

Closes https://github.com/wxWidgets/wxWidgets/pull/1418
2019-09-22 02:37:11 +02:00
Matthew Griffin
9434a443f5 Ensure that QCloseEvents can be vetoed by wx
These events use a different convention from all the other ones in Qt
and need to be ignored, rather than accepted, to prevent the default
action from occurring.

And these events are also sent to disabled windows, which are never
supposed to receive them in wx API.

Closes https://github.com/wxWidgets/wxWidgets/pull/1371
2019-09-22 02:05:32 +02:00
Matthew Griffin
0c7f261c4a Fix position for wxContextMenuEvent generated from keyboard
The position was wrong for the keyboard-triggered menu events in
wxWindows containing multiple sub-windows, such as wxListCtrl.

Closes https://github.com/wxWidgets/wxWidgets/pull/1352
2019-09-22 01:34:09 +02:00
Matthew Griffin
71ad73fdbe Fix wrong position in wxMouseEvent generated by sub-window
Use screen coordinates, as the window coordinates in QMouseEvent may be
relative to a different window.

Closes https://github.com/wxWidgets/wxWidgets/pull/1351
2019-09-22 01:29:52 +02:00
Jay Nabonne
be22e8fa95 Fix DoMoveWindow() to take into account the frame extent
Using "move" is correct for positioning, as it takes into account the
frame extent. Unfortunately, there is no corresponding API to set the
frame size. So we need to compute the effective client size and use
"resize". We can't use "setGeometry" for this purpose, since a widget's
"geometry" excludes the frame size. We would need to adjust the position
to go from frame to client coordinates. It's more straightforward to
simply have Qt do it with "move".

Closes https://github.com/wxWidgets/wxWidgets/pull/1349
2019-09-22 00:50:32 +02:00
Jay Nabonne
d66aa35254 Fix handling captured mouse events in a window with scrollbars
Handle some mouse events explicitly when a wxQtScrollArea is set as
"mouse captured".

The issue arises in that the QScrollArea has two methods: event() and
viewportEvent(). Normally a "QAbstractScrollAreaFilter" is set up by Qt
which routes any events to the viewportEvent() method. And the normal
event() method throws mouse events away (for reasons I'm not aware of -
but it is what it is). If a wx window with a scroll area (e.g.
wxRichTextCtrl) sets capture, the wxQtScrollArea (QScroll-derived) gets
set as the direct "mouse grabber", and all events then bypass the filter
and are sent directly to the "event" method, which throws them away. The
typical result is that the window setting capture no longer gets mouse
events, it keeps capture since it's looking for a mouse up that never
comes, and the app more or less locks up since all mouse events are
being effectively discarded.

This change catches any event that comes in via the event() method and,
when the mouse is captured by the widget, forwards it on to the
viewportEvent method instead, performing what the filter would do via
the normal event routing.

It doesn't forward on "mouse press" events because the initial event
that causes the capture ends up being fed back again, resulting in a
"captured twice" error. The underlying reason I can see for this "being
fed back again" is that, for some inexplicable reason, the
wxRichTextCtrl "skips" the event even though it has actually processed
it and taken capture. That means this solution isn't 100%, but it does
fix the 99%+ cases where the capture is only gotten to redirect mouse
moves and button ups.

Perhaps an alternative solution might be to stop grabbing the mouse in
wxQtScrollArea, but this would require more changes.

Closes https://github.com/wxWidgets/wxWidgets/pull/1346
2019-09-20 02:59:13 +02:00
Vadim Zeitlin
b8d5c85ecb Make Reparent() work for wxFrame in wxQt
Use the correct parent window, i.e. the one of the central widget and
not of the frame itself.
2019-09-15 01:35:54 +02:00
Graham Dawes
e5ba6d9393 Implement SetForegroundColour and SetBackgroundColour for wxQt
Closes https://github.com/wxWidgets/wxWidgets/pull/1373
2019-07-03 13:25:55 +02:00
Paul Cornett
5629f71c32 Remove unused/redundant assignments 2019-04-04 10:28:42 -07:00
Cătălin Răceanu
c42bda6bd5 Avoid crashes due to signals/events when destroying wxWindowQT
Don't handle any pending signals or events for the windows about to be
destroyed.

Closes https://github.com/wxWidgets/wxWidgets/pull/1253
2019-03-13 17:42:23 +01:00
Vadim Zeitlin
d841f7b34e Merge branch 'wxQt-memory-leaks' of https://github.com/catalinr/wxWidgets
Fix many memory leaks in wxQt port.

See https://github.com/wxWidgets/wxWidgets/pull/1243
2019-03-05 23:36:41 +01:00
Cătălin Răceanu
934698d8ac Change Qt smart pointers with wx ones to fix compilation 2019-02-27 22:06:47 +02:00
Cătălin Răceanu
66f6559a58 Replace accessor with an older version 2019-02-27 17:46:02 +02:00
Cătălin Răceanu
1578240b6e Change a couple of data types and simplify code a bit 2019-02-27 17:42:01 +02:00
Cătălin Răceanu
82523b3d3b Do not initialize base class variable and do not leak old allocation 2019-02-27 01:39:14 +02:00
Cătălin Răceanu
315a9460c0 Remove memory leaks by using smart pointers or explicit delete 2019-02-27 01:12:03 +02:00
Paul Cornett
cd045cc490 Add missing break statements 2019-02-25 00:41:50 -08:00
Graham Dawes
1e875c8ddc Set the event object and ID in events generated by wxQt
Add missing SetEventObject() calls and ID parameters in the ctor calls
for several events generated by wxQt.

Closes https://github.com/wxWidgets/wxWidgets/pull/1230
2019-02-21 04:35:51 +01:00
chris2oph
f8c345ca95 Fix painting logic in wxQt wxClientDC implementation
The original drawing mechanism was generating lots of QWarning messages
when running samples (e.g. htlbox, caret, etc.) and in some cases was
not actually completely drawing every element of the sample. The issue
was that the QPicture was being shared incorrectly between wxWindow and
wxClientDC and attempts to start painting, update, etc. were generating
console warnings.

Closes https://github.com/wxWidgets/wxWidgets/pull/1152
2019-02-02 16:23:49 +01:00
Vadim Zeitlin
6370662cc8 Merge branch 'qt-dnd'
Initial drag-and-drop implementation for wxQt.

Closes https://github.com/wxWidgets/wxWidgets/pull/1205
2019-02-02 15:54:21 +01:00
phowstan
89e5663a75 Handle calling wxWindow::Hide() before Create() in wxQt
Hide the window explicitly once it's created. This is not very useful,
as the real purpose of calling Hide() before Create() is to prevent the
window from being initially shown at all to avoid flicker, but better
than not hiding it at all.

Closes https://github.com/wxWidgets/wxWidgets/pull/1203
2019-02-02 15:11:42 +01:00
phowstan
e831703aae Handled null cursor correctly in wxQt SetCursor()
Make passing invalid wxCursor object to SetCursor() work and reset any
previously specified cursor.

Closes https://github.com/wxWidgets/wxWidgets/pull/1197
2019-02-02 14:15:11 +01:00
Vadim Zeitlin
8fbca5cb70 Remove all trailing spaces
No real changes, just clean up sources by removing trailing spaces from
all the non-generated files.

This should hopefully avoid future commits mixing significant changes
with insignificant whitespace ones.
2019-01-30 17:35:54 +01:00
Jay Nabonne
6ba6d9967a Change Qt wxDropTarget to remember widget and disconnect self when necessary. Clean up naming a bit. 2019-01-29 17:11:09 +00:00
Jay Nabonne
e995618a3a Be sure drop target is disconnected before destructing window. 2019-01-29 17:07:14 +00:00
Jay Nabonne
87f6707123 Fix some spacing transgressions. 2019-01-29 16:58:52 +00:00
Jay Nabonne
8c63c40953 Clean up wxDropTarget and wxWindow a bit more by moving DnD stuff fully into drop target (besides connecting and disconnecting).
Window doesn't have to know more than how to hook itself up.
Impl now performs function of event filter/adapter.
2019-01-29 16:55:31 +00:00
Jay Nabonne
323cbdabdb Implement initial try of wxDropTarget.
The drop target needs to use an event filter to capture drag-and-drop events from the window.
2019-01-29 16:13:41 +00:00
ali kettab
84fc5c1714 Fix changing tooltip via wxToolTip::SetTip() in wxQt
Update the actual tool tip used by Qt and not just the internal variable
when SetTip() is called.

Also implement wxToolTip::SetWindow().

Closes https://github.com/wxWidgets/wxWidgets/pull/1175
2019-01-25 14:39:37 +01:00
ali kettab
3c369af2e6 Translate QFocusEvent to wxFocusEvent correctly
Set the ID, object and the associated window.

Closes https://github.com/wxWidgets/wxWidgets/pull/1177
2019-01-25 03:31:22 +01:00
ali kettab
515031cf6b Set event object for wxKeyEvents generated in wxQt
Not setting the event object broke the code expecting it to be set,
notably in our own validators code.

Closes https://github.com/wxWidgets/wxWidgets/pull/1176
2019-01-24 22:47:26 +01:00
Vadim Zeitlin
5bb683bcfe Fix harmless -Wunused-parameter warnings in wxQt code
Note that other such warnings remain where they indicate important
missing functionality (notably in wxCairoContext ctor from wxPrinterDC).
2019-01-20 02:59:46 +01:00
Richard Smith
fc65bd92a6 Fix leaks/crashes related to window scrollbars in wxQt
Closes https://github.com/wxWidgets/wxWidgets/pull/1135
2019-01-11 14:28:39 +01:00
Graham Dawes
aa422c6be2 Make scrollbar private to wxWindow under wxQt
Use QScrollbar directly instead of wxScrollbar for the window scrollbars
to ensure that wxWindow::GetChildren() doesn't return these scrollbars.

Closes https://github.com/wxWidgets/wxWidgets/pull/1124
2019-01-10 03:55:19 +01:00
Graham Dawes
34ecc6efc4 Generate wxWindowCreateEvent when creating windows in wxQt
Send the expected event at the very end of window creation process.

Closes https://github.com/wxWidgets/wxWidgets/pull/1119
2019-01-10 03:50:43 +01:00
Graham Dawes
172a97e411 Erase event now is now sent with a valid event object 2018-12-20 13:40:18 +00:00
Liam Treacy
94a58121f7 Fix crash on setting the accelerator table in wxQt
Check whether m_qtShortcuts is non-null before dereferencing it.

Closes https://github.com/wxWidgets/wxWidgets/pull/1040
2018-12-05 03:04:17 +01:00
Vadim Zeitlin
309f942aa6 Merge branch 'qt-build'
Minor wxQt API fixes and simplifications.

See https://github.com/wxWidgets/wxWidgets/pull/962
2018-10-07 19:55:37 +02:00
Vadim Zeitlin
b368fa2de5 Remove casts from wxString to "const char*" in wxQt code
These casts didn't compile in Unicode build and were completely
unnecessary anyhow, just remove them.
2018-10-06 14:07:47 +02:00
Maarten Bent
7f0d7ef520 Fix several build errors in WXQT
Move declaration of wxOwnerDrawnBase::ms_defaultMargin to correct file.
Do not include headers when wxUSE_UIACTIONSIMULATOR is disabled.
Add guards for wxUSE_DRAG_AND_DROP.
Use a different wxFont constructor in printing sample, which is also available in WXQT.
2018-09-30 17:23:58 +02:00
Sean D'Epagnier
169d61edb7 wxqt: correct formatting and casting, no functional change 2017-11-06 02:05:40 +01:00
Sean D'Epagnier
2a2e17c050 correct small errors in wxqt implementation 2017-11-06 02:05:40 +01:00
Sean D'Epagnier
5261d3eb05 correct null reference if set flags is called in Init 2017-11-06 02:05:40 +01:00
Sean D'Epagnier
52a7a1c5e6 windows should not be destroyed just because the close event succeeds 2017-11-06 02:05:40 +01:00