Commit Graph

5695 Commits

Author SHA1 Message Date
Vadim Zeitlin
10c51dbf28 Avoid spurious asserts when holding arrows in GTK wxSpinButton
The change in the value can be greater than 1 when the arrows are held
pressed, contrary to what the logic of determining the wraparound added
in 086793ceef supposed.

Replace this with a check of whether we switch from the min value
directly to the max one or vice versa, which mostly works and avoids
asserts, even if it can still fail and produces wrong events when the
arrows are held pressed for long enough to increase the delta to the
range of the control, in which case we just can't distinguish between
wraparound and passing from min to max (or vice versa) in a single step,
which means that we have no way to determine the right event to send.
But producing a wrong event is better than asserting, so this still
counts as an improvement.

Closes https://github.com/wxWidgets/wxWidgets/pull/1764

See #17957.

Closes #18695.
2020-03-19 01:11:06 +01:00
Paul Cornett
81309f083d Ensure that scrollbar GtkRange page increment is set to a positive value
It should not be less than the step increment, which is always one.
See #18688
2020-03-11 22:10:22 -07:00
Yuri D'Elia
f9b793f8d1 Check for valid entry in wxTextEntry::EnableTextChangedEvents()
GetTextObject() might return null, e.g. it does it for read-only
wxBitmapComboBox, so EnableTextChangedEvents() must account for this
possibility, as it's not really possible to avoid calling it in this
case, as it's called indirectly from e.g. SetSelection().

Check that the entry is valid before enabling or disabling events for it
to avoid several GLib assertion failures every time when e.g.
wxBitmapComboBox::SetValue() is called.

Closes https://github.com/wxWidgets/wxWidgets/pull/1756
2020-03-11 22:30:55 +01:00
Jouk
c42715f0c9 define WXBUILDING when compiling the library on OpenVMS 2020-03-05 08:15:04 +01:00
Paul Cornett
05d19797a5 Revert to using our own drag-move code for wxGTK wxMiniFrame with non-Wayland backends
At least one WM (KDE's KWin) does not generate X11 configure events when dragging
a window using gtk_window_begin_move_drag(). We need the configure events so we
can generate wxMoveEvent, which AUI needs in order to re-attach a floating pane.
This is functionally a revert of b8789b9d6f for backends other than Wayland.
See #18372 #18669
2020-02-19 20:26:08 -08:00
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
Paul Cornett
edc47d8fed Fix appearance of GTK3 single-line wxTextCtrl with non-default background
...and more text than will fit. See #18663
2020-02-09 08:13:01 -08:00
Vadim Zeitlin
a2b39f782b Don't call gtk_disable_setlocale() more than once
This is useless and just results in GTK warnings.
2020-02-06 15:59:45 +01:00
Paul Cornett
0ca45d1a59 Remove redundant checks for NULL before calling delete 2020-02-02 23:51:39 -08:00
Paul Cornett
948ddc6e0f Eliminate -Wcast-qual warnings with GCC and Clang
Use const_cast, mutable, and various other changes to avoid -Wcast-qual
2020-02-02 22:50:32 -08:00
Paul Cornett
0a56399f3c Fix TLW decorations when GTK3 is using Client Side Decorations
We need to avoid setting Window Manager decorations or using deferred show
See #17971
2020-01-30 01:05:45 -08:00
Lauri Nurmi
4901b3784a Fix wxGTK build when configured with --disable-intl
That is, #include scopedptr.h explicitly in nonownedwnd.cpp.
2020-01-20 22:18:55 +02:00
Vadim Zeitlin
59111e0d11 Suppress warnings due to use of deprecated WebKit functions
This is not the best solution, but getting dozens of lines of warnings
when compiling this file is not great neither and there doesn't seem to
be anything else to do about this.
2020-01-10 19:20:26 +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
Vadim Zeitlin
826cc882dc Merge branch 'gtk-srchctrl'
Add native wxSearchCtrl implementation for wxGTK.

Closes https://github.com/wxWidgets/wxWidgets/pull/1688
2020-01-07 03:16:02 +01:00
ali kettab
020b6ebcb8 Derive from wxTextEntry instead of wxTextCtrlBase 2020-01-07 03:15:39 +01:00
AliKet
c09db9c23d Add native wxSearchCtrl for GTK+ port 2020-01-07 03:15:35 +01:00
Paul Cornett
833ae03c6a Draw bitmap in disabled state when wxStaticBitmap control is not enabled on GTK3
See #18638
2019-12-29 09:14:08 -08:00
Paul Cornett
8db62d179c Move code for creating a disabled bitmap to wxBitmap
To allow using it from multiple places
2019-12-29 09:08:40 -08:00
Vadim Zeitlin
8b90073c83 Send kill focus events to modal dialogs earlier in wxGTK
Ensure that the dialog is still alive when it gets the kill focus event
for its child which had focus just before the dialog was closed (or any
other events generated by this child when it detects that it's losing
focus, such as wxEVT_SPINCTRL) by resetting focus when the dialog is
being hidden and not when it's being destroyed.

This makes the events order more consistent with wxMSW but also, most
importantly, safer, as wxEVT_KILL_FOCUS handlers could previously easily
reference the fields of an already half-destroyed wxDialog-derived
object by the time they were run during wxTopLevelWindowGTK destructor
execution.

Closes #18145.
2019-12-29 01:40:28 +01:00
Paul Cornett
8b2f413b42 Fix wxStaticBitmap with HiDPI bitmaps for GTK3
See #18638
2019-12-28 13:07:28 -08:00
Vadim Zeitlin
7b8cdd441d Return (0, 0) from wxMDIChildFrame::GetPosition() in wxGTK
This makes more sense for a page of a GtkNotebook, which is always
positioned at (0, 0) relative to its client area, and is also more
compatible with wxMSW.

Closes #18548.

Closes https://github.com/wxWidgets/wxWidgets/pull/1670
2019-12-10 22:42:00 +01:00
Vadim Zeitlin
36546b6f3f Merge branch 'grid-editors-placement'
Fix positions of the checkboxes drawn by wxGridCellBoolRenderer and
shown by wxGridCellBoolEditor so that there is no jump when starting or
stopping to edit grid cells with boolean values.

See https://github.com/wxWidgets/wxWidgets/pull/1662
2019-11-29 16:24:07 +01:00
Vadim Zeitlin
eadee05729 Don't change CSS for wxCheckNox with wxNO_BORDER in wxGTK 3
This makes the checkbox look ugly as it's clearly not supposed to be
rendered without the border at all, so it's better to do nothing than
mangle its CSS.

It could be better to add some virtual GTKTurnOffBorder() method that
could be overridden to do nothing in wxCheckBox and we should consider
doing this if there are other classes for which wxNO_BORDER breaks their
appearance, but for now, as long as it's the only case in which we need
to do this, just turn wxNO_BORDER off when calling PostCreation().
2019-11-29 04:31:14 +01:00
Vadim Zeitlin
edd0d9b68f Ensure DrawCheckBox() fits inside the rectangle passed to it
This results in rather ugly checkboxes when the rectangle is too small,
and even "critical" GTK warnings with wxGTK 3, but is still arguably
better than drawing outside of the provided rectangle.
2019-11-28 23:57:15 +01:00
Paul Cornett
632363775d Fix -Wclass-memaccess warning from previous change 2019-11-28 09:12:48 -08:00
Paul Cornett
9c5ec2f959 Restore resetting of wxMiniFrame cached decor size
This was inadvertently lost in 8cdd20667f, apparently causing wxRESIZE_BORDER
functionality to stop working on some platforms. See #18591
2019-11-28 09:03:38 -08:00
Vadim Zeitlin
e2bb8b05bf Factor out common checkbox-related code into CheckBoxInfo
No real changes, just extract the same code used in both GTK 2 and GTK 3
implementations of GetCheckBoxSize() and DrawCheckBox() in a helper
class which is now just used from both places.

This makes the code more clear and hopefully easier to maintain in the
future.
2019-11-28 02:14:50 +01:00
Vadim Zeitlin
9ae808dc86 Synchronize structure of DrawCheckBox() and GetCheckBoxSize()
Put GTK 3 version first in both functions instead of putting it in the
middle (!) of GTK 2 code in the former one for some reason.

No real changes, the code was just moved around (this commit is best
viewed with "git diff --color-moved").
2019-11-28 02:14:50 +01:00
Ilya Sinitsyn
dacf25ac99 Support wxNO_BORDER for wxCheckBox under GTK2 2019-11-28 02:14:50 +01:00
Ilya Sinitsyn
53ffbf6cf5 Allow ignoring margins in wxRendererNative::GetCheckBoxSize()
Add ability to get the size of the checkbox without any margins by
passing wxCONTROL_CELL flag: this can be useful when the checkbox is
part of some "cell", e.g. wxGrid one, and doesn't need any extra margins
around it.

Currently wxCONTROL_CELL is only really used by wxGTK2 implementation.
2019-11-28 02:14:50 +01:00
Vadim Zeitlin
8997d06397 Fix build with GTK 3 < 3.20
Restore a check removed in d85794e87f as
it's still needed: AddTreeviewHeaderButton() is only defined for 3.20
or later.
2019-11-27 23:21:45 +01:00
Vadim Zeitlin
5ad2470504 Avoid disabling -Wcast-function-type when not using gcc 8
The changes of 173f035bc2 resulted in

unknown warning group '-Wcast-function-type', ignored [-Wunknown-warning-option]

diagnostics from clang (even clang-10) and, presumably, also from
versions of gcc earlier than 8, which added this option, so use the
special wxGCC_WARNING_SUPPRESS_CAST_FUNCTION_TYPE() macro added in
ed01fede2e just for this instead.

No real changes.
2019-11-27 17:39:21 +01:00
Paul Cornett
d3ea00b40f Remove an extraneous semicolon 2019-11-25 20:59:21 -08:00
Paul Cornett
173f035bc2 Suppress a GCC -Wcast-function-type warning
We're setting the same event handler GTK uses internally, so the warning isn't helpful
2019-11-25 20:58:16 -08:00
Paul Cornett
d85794e87f Remove some unnecessary GTK preprocessor version checks
The contained code no longer uses anything version-specific
2019-11-25 20:54:51 -08:00
Paul Cornett
0fab5eb071 Allow scrollwheel events when mouse is captured with GTK3, see #18593 2019-11-25 20:52:12 -08:00
Paul Cornett
abaccbc2e2 Fixes for checkbox rendering with GTK3
Size should include border and padding. Margin values seem to be for a checkbox with text
label, so don't include margin. Check mark should be drawn inside border and padding.
2019-11-24 23:31:09 -08:00
Paul Cornett
fee30940b6 Take wxDC transformations into account when resetting clipping with GTK3
The paint update region is in device coordinates, it needs to be converted to
current logical coordinates to apply correctly. See #18584, #18560
2019-11-23 08:41:31 -08:00
Vadim Zeitlin
34f26bd18f Don't change max number of digits in wxSpinCtrl code
This doesn't seem to affect anything, i.e. the function returns the same
results whether we do it or not, so just don't.
2019-11-13 15:46:16 +01:00
Vadim Zeitlin
b472a791c1 Return fitting size from wxSpinCtrl::GetSizeFromTextSize() in GTK
Previously we added the extent of the text to the preferred size of a
spin button with 0 digits, but this didn't account for the fact that the
control still reserved enough space for 3 digits in this case, and so
the returned size was always too big than the required size by the width
needed to show 3 digits.

Fix this by directly asking for the size required to show the number of
digits corresponding to the given text size.

Note that ideal would be to provide GTK API at wx level directly, i.e.
allow to just specify the number of digits instead of the text extent.
But we still need to fix the already existing GetSizeFromTextSize()
anyhow, so do this for now.

See #18568.
2019-11-13 15:46:16 +01:00
Vadim Zeitlin
7f368872d7 Adjust entry width of wxSpinCtrl in wxGTK to its range
Ensure that the entry is always (just) big enough to show any value
valid in this spin control.

This also ensures that GetBestSize() doesn't need to be overridden to
use GetSizeFromTextSize() any longer as the best size will be determined
correctly by GTK itself.
2019-11-13 15:46:16 +01:00
Vadim Zeitlin
eb3d8395c2 Rename wxSpinCtrl helper functions
Put them in wxSpinCtrlImpl namespace and remove "wxSpinCtrl" prefix from
the function names themselves, this was ugly.

No real changes.
2019-11-13 15:46:16 +01:00
Vadim Zeitlin
4444694043 Move private wxSpinCtrl helpers into a private header
Np real changes, just don't put these functions in the public
wx/spinctrl.h, they have nothing to do there.
2019-11-13 02:59:42 +01:00
Paul Cornett
df9f4af357 Improve our estimate of GtkEntry margins
For GTK2, get the "inner border" the same way GTK does it. And for GTK3,
provide an actual implementation. Also, don't return a wxPoint for a size.
See #18567
2019-11-11 08:29:28 -08:00
Vadim Zeitlin
a2ff49eeeb Initialize wxWindowDCImpl::m_window for hidden windows too
Ensure that we set m_window in case of early return from wxWindowDCImpl
ctor, so that using e.g. wxDC::GetSize() works for wxClientDC created
for windows that hadn't been realized yet.

It might be possible to avoid this early return completely as the
comment explaining why we're doing it seems to be out of date: our
SetBackground() doesn't call wxWindow::SetBackground() (and it would be
exceedingly strange if it did), but for now just the bug without
changing anything else.

Closes #18569.
2019-11-10 00:35:07 +01:00
Paul Cornett
e87ea7389b Avoid inadvertently destroying a shared PangoContext on GTK2
wxMemoryDC and wxScreenDC dtors were freeing a context they didn't own, potentially
causing a crash. Fixed by having the base wxWindowDC dtor free the context.
See #18566
2019-11-07 11:26:10 -08:00
Ian McInerney
3a668b4d0a GTK: Use wxID_NONE for unhighlight events 2019-11-05 12:09:26 +00:00
Vadim Zeitlin
6421ddb9b2 Only use underline-rgba property with GTK > 3.16
This avoids glib warnings

object class 'GtkTextTag' has no property named 'underline-rgba-set'

when calling g_object_get() with older GTK and just avoids doing useless
work.
2019-11-04 22:57:46 +01:00
Paul Cornett
4697ce23d9 Don't allow DestroyClippingRegion() to remove paint update area clipping with GTK3
See #18560
2019-10-31 23:30:18 -07:00