Commit Graph

64652 Commits

Author SHA1 Message Date
Vadim Zeitlin
f54ac4e243 Merge branch 'searchctrl-improve'
Closes https://github.com/wxWidgets/wxWidgets/pull/851
2018-07-10 14:40:58 +02:00
Vadim Zeitlin
a0298f3149 Only drain all pending events when exiting outermost wxEventLoop
This is especially important under MSW, where the modality of the nested
event loops actually ends as soon as wxModalEventLoop::Exit() is called,
and so we must avoid dispatching any events in the current loop after it
happens or we risk reentering the same loop again, which could result in
e.g. parent modal dialog being closed before the child event loop
returns (because the event closing the former was dispatched from the
latter) and other unexpected sequences of events.

To prevent this from happening, only dispatch pending events after the
loop exit if it's the outermost loop, as there should be no danger in
doing it in this case. Conversely, we don't lose anything by not doing
this in nested event loops as the outer loop will take care of any
remaining pending events anyhow.

To make this work in an ABI-compatible way, add a global counter of the
currently existing event loops which is used to check if there is more
than one event loop currently running.

Closes #11273, #11573, #11269.
2018-07-10 14:40:05 +02:00
Vadim Zeitlin
cf966718e6 Add "hint" property support to XRC for wxComboBox too
It supports hints, as any/most wxTextEntry-derived classes.
2018-07-10 14:38:29 +02:00
Vadim Zeitlin
b6fde56e2e Allow "hint" property for wxSearchCtrl in the XRC schema
This should have been part of 652b4eb8ed
2018-07-10 14:37:31 +02:00
Vadim Zeitlin
a1e780f1b4 Remove mention of wxEVENTS_COMPATIBILITY_2_8 from the docs
This macro doesn't exist any more since almost 10 years (see commit
890d70ebea).
2018-07-10 12:42:51 +02:00
Anil
24820a5a67 Invalidate "hover" column index in wxHeaderCtrl if necessary
Don't leave "m_hover" invalid if the number of columns in wxHeaderCtrl
is reduced, as this would result in a crash later when it is used.

This notably fixes a crash after removing the last column from generic
wxDataViewCtrl.

Closes https://github.com/wxWidgets/wxWidgets/pull/852
2018-07-10 12:33:14 +02:00
Vadim Zeitlin
42ab122912 Shift the text control another pixel down in MSW wxSearchCtrl
It was too high otherwise, which was especially noticeable in high DPI.

This is still not perfect, as the default search bitmap is not centered
neither and is a couple of pixels too high, but better than before.
2018-07-09 20:50:48 +02:00
Vadim Zeitlin
4d4e95849a Fix size of wxSearchCtrl in the widgets sample in high DPI
Add missing FromDIP(), without it the control was too small.
2018-07-09 20:50:22 +02:00
Vadim Zeitlin
a38176c67a Make wxTextCtrl horizontal margins proportional to DPI
Add more FromDIP() calls.
2018-07-09 20:36:16 +02:00
Vadim Zeitlin
50aee9a0b3 Fix default size for wxSpinCtrl in high DPI
DEFAULT_ITEM_WIDTH is a constant, use FromDIP() around it to avoid
creating too narrow controls when using high DPI.
2018-07-09 20:35:42 +02:00
Vadim Zeitlin
9f04318720 Fix MSW EDIT_HEIGHT_FROM_CHAR_HEIGHT() for high DPI
Apply DPI scaling to the extra vertical margin added by this macro to
the font height.

This makes sense and results in wxTextCtrl (and other controls, e.g.
wxSearchCtrl) having the same height as native ones when using high DPI
too.

Note that this required adding wxGetEditHeightFromCharHeight() function
as one of the existing uses of EDIT_HEIGHT_FROM_CHAR_HEIGHT() wasn't
inside a wxWindow-derived class method and also adding wxUSE_GUI guard
around these GUI-only definitions as a function, unlike a macro, can't
be compiled without full wxWindow declaration in scope.
2018-07-09 20:24:58 +02:00
Vadim Zeitlin
c713bee7ea Remove unnecessary wxSearchCtrl::DoMoveWindow() override
There is no need to override this virtual function, if the control size
changes, a wxEVT_SIZE event is generated in any case, resulting in a
call to LayoutControls() without explicitly calling it from here.
2018-07-09 17:54:09 +02:00
Vadim Zeitlin
67bceedfda Get rid of m_searchButtonVisible and m_cancelButtonVisible
There doesn't seem to be any reason to have these flags, which duplicate
the visibility state of m_searchButton and m_cancelButton respectively.

Also update the buttons visibility immediately in ShowSearchButton() and
ShowCancelButton() instead of doing it in LayoutControls() as before,
which was confusing as laying out is not supposed to show/hide anything.

Finally, return true, not false, from IsSearchButtonVisible() if the
button is actually visible because there is an associated menu, even if
ShowSearchButton(false) had been called. This seems more logical and
makes the code simpler, but we need to check whether the native Mac
version also behaves like this or not.

No other changes in behaviour.
2018-07-09 17:12:02 +02:00
Vadim Zeitlin
ed8ac7059c Use more descriptive symbolic constants in wxSearchCtrl code
Replace LIGHT_STEP macro and 20 magic number with
SEARCH_BITMAP_LIGHTNESS and CANCEL_BITMAP_LIGHTNESS constants which are
a bit more clear, hopefully.

No real changes.
2018-07-09 16:50:10 +02:00
Vadim Zeitlin
587e0d8e64 Fix search button height in generic wxSearchCtrl
Make this button of exactly the bitmap size instead of using the full
control height for it, even if/when the bitmap is smaller.

This fixes some random junk being shown in the bottom two pixels of the
search button sometimes: this was due to only redrawing the part covered
by the bitmap in wxSearchButton::OnPaint(), leaving the rest of the
button unpainted (because wxSearchButton uses wxBG_STYLE_PAINT).
2018-07-09 14:37:43 +02:00
Vadim Zeitlin
7f1d08d5bd Ignore all changes to g++ ABI version since 1002
Checking for the exact match of __GXX_ABI_VERSION created more problems
(including for both Fedora and Debian packagers, see
https://github.com/wxWidgets/wxWidgets/pull/828) than it solved
(approximately 0), so relax it and assume that future g++ versions will
remain broadly compatible with the current ABI, which seems like a safe
assumption so far.

It's not really clear if there is any value in having this ABI check at
all, or if we should remove CheckBuildOptions() and all the code calling
it entirely, as it seems that there is no way to trigger this check
during run-time without getting a link error first. But keep it for now,
just because it's simpler to keep it than to remove it.
2018-07-09 00:40:55 +02:00
Artur Wieczorek
42932d4670 Limit the scope of a temporary variable 2018-07-07 20:30:38 +02:00
Artur Wieczorek
54c5584c65 Don't set column title if wxPG header is going to be hidden
wxPropertyGridManager::SetColumnTitle() shouldn't be called when we going
to hide the header because it makes the header visible.
2018-07-07 20:29:37 +02:00
Artur Wieczorek
0ee25cce3a Don't use external flag to determine if wxPG header is visible
Check if wxPG header really exists and is visible prior to any operation.

Closes #18128.
2018-07-07 20:28:11 +02:00
Vadim Zeitlin
03b7491bea Remove unnecessary DoUpdateWindowUI() override in wxSearchCtrl
There is no need to override this virtual method just to call the base
class version.
2018-07-07 00:57:44 +02:00
Vadim Zeitlin
18899ce4bc Replace WXMAX() macro in wxSearchCtrl code with wxMax()
Don't invent yet another std::max-macro. We probably could just use the
standard function instead but for now use wxMax(), for consistency with
the rest of the code base.

No real changes.
2018-07-07 00:55:35 +02:00
Vadim Zeitlin
6ed3865925 Remove commented out stream operations in wxSearchCtrl
Just remove unused and unnecessary declarations.
2018-07-07 00:54:30 +02:00
Vadim Zeitlin
df4d1d456f Make wxSearchCtrl margins proportional to DPI
Use FromDIP() in wxSearchCtrl implementation to make the margins of the
same size, proportionally, at any DPI.
2018-07-07 00:52:26 +02:00
Artur Wieczorek
81cac4e46b Simplify getting current wxPG editor control
We can just return the pointer, whether it is NULL or not.
2018-07-06 22:57:53 +02:00
Artur Wieczorek
858b5e7222 Prevent losing the focus by active editor when error dialog box is closed
Displaying error dialog can cause on some platforms native focus changes
what triggers unwanted focus change events in wxPG and disturbs expected
sequence of events. To prevent this from happening (regardless of platform),
we need to save focused window before dialog box is displayed and restore
it after closing the dialog.

Closes #18046.
2018-07-06 22:56:55 +02:00
Vadim Zeitlin
5766280311 Fix recent regression in wxMSW wxTopLevelWindow::IsMaximized()
Recent 3518f1a7d8 broke IsMaximized()
return value when the window was visible and had been previously
maximized by calling Maximize(), but wasn't actually maximized any
longer because it started to always return true when m_showCmd was set
to SW_MAXIMIZE.

Fix this by only using m_showCmd when the window is hidden, as it
shouldn't matter what it is when it's shown. Also simplify/optimize the
logic of IsMaximized() to use either ::IsZoomed() or m_showCmd depending
on whether the window is shown or not, but not both.

See https://github.com/wxWidgets/wxWidgets/pull/842

Closes #18163.
2018-07-06 19:04:09 +02:00
PB
c93ccda035 Fix building docview sample with CMake
Should have been part of 64fc4dc
2018-07-06 12:33:59 +02:00
Vadim Zeitlin
9121b906e8 Restore initial wxEVT_SIZE generation for hidden frames in wxMSW
Changes of commit cf20a9ced5 suppressed
the generation of the initial wxEVT_SIZE for hidden wxFrames, as the
initial WM_SIZE was ignored. This went unnoticed for "normal" frames,
which got another WM_SIZE when they were shown in any case, but broke
frames with wxFRAME_TOOL_WINDOW style as they're shown using SW_SHOWNA
command and in addition to suppressing activation, it also suppresses
the generation of WM_SIZE, so such frames didn't get any wxEVT_SIZE at
all and appeared without being laid out properly, as could be seen, for
example, in the splash sample.

Fix this by continuing to generate the size events even for hidden
frames, just as we did before, while still skipping all the other stuff
which is not necessary for the hidden windows.

See https://github.com/wxWidgets/wxWidgets/pull/842

Closes #18161.
2018-07-05 19:42:33 +02:00
Vadim Zeitlin
6d02c45867 Don't write spurious </font> to wxRichText HTML output
The opening <font> tag was only written to the output if the style had a
non-default font, but the matching closing tag wasn't guarded by the
same check.

Do add the check now to ensure that the tags are always balanced.

Closes #18157.
2018-07-04 20:09:49 +02:00
Vadim Zeitlin
5e5f878db0 Improve wxWindow::FindWindowByName() documentation
Mention that the "name" is interpreted as the label if no window with
such name is found.

Also document that both this and FindWindowByLabel() functions do
recurse into child TLWs, unlike FindWindow().
2018-07-03 18:54:19 +02:00
Vadim Zeitlin
64ae76fadd Merge branch 'mac-lbox-sel-events'
Fix Mac wxListBox selection behaviour and events.

See https://github.com/wxWidgets/wxWidgets/pull/847
2018-07-03 18:31:37 +02:00
pavel-t
99ea06203a Fix clobbering warning 2018-07-03 13:33:03 +03:00
Artur Wieczorek
9acb2fe3a0 Fix AddArcToPoint when no current point is set on wxGraphicsPath
Current behavior of AddArcToPoint() when there is no current point is not
documented and moreover it is not the same in native macOS and in generic
implementation. Under macOS nothing is done and "no current point" error
is raised but under other ports (generic implementation) only arc
is drawn (without initial line).
When there is no current point, in similar functions AddCurveToPoint(),
AddQuadCurveToPoint() it is initially set to the some known control point
of the curve but this approach cannot be applied to AddArcToPoint().
The only well defined fallback point seems to be (0, 0) and this option
is implemented here.

See #18086.
2018-07-02 22:31:24 +02:00
Artur Wieczorek
fd5576a326 Explicitly return (0,0) if no current point is set for graphics path (macOS)
This is to suppress a harmless warning displayed in the console
if CGPathGetCurrentPoint() is called when no current point is set.
2018-07-02 20:50:44 +02:00
Artur Wieczorek
534b8840d2 Fix AddCurveToPoint and AddQuadCurveToPoint if no current point is set (macOS)
If current point is not yet set, these functions should behave
as if they were preceded by a call to MoveToPoint(cx1, cy1).

Closes #18111.
2018-07-02 20:39:42 +02:00
Artur Wieczorek
8349c4bf7f Fix AddLineToPoint() if no current point is set (macOS)
AddLineToPoint() should behave as MoveToPoint() if there is no current point.

See #18111.
2018-07-02 20:32:30 +02:00
Artur Wieczorek
f258dc4c64 Fix setting current point of wxGraphicsPath (GDI+)
After executing native operations on the graphics path, the native
current point is updated properly and should be used instead
of manually maintained logical point.

See #18111.
2018-07-02 20:24:43 +02:00
Artur Wieczorek
fc53007ab4 Add unit test for current point of wxGraphicsPath
Verify that last point is properly positioned after the operations
on wxGraphicsPath.

See #18111.
2018-07-02 20:08:30 +02:00
Vadim Zeitlin
c53524a59b Also check the old selection index for validity
It's not totally clear if the old selection is always guaranteed to be
valid so prefer to check it explicitly.
2018-06-30 23:18:28 +02:00
Vadim Zeitlin
30c798b70a Fix row validity check in MacHandleSelectionChange()
Valid indices must be in [0, count[ half-open interval.
2018-06-30 23:17:37 +02:00
Vadim Zeitlin
f51cb52004 Reformat comments and code in MacHandleSelectionChange()
No real changes, just trying to make the code more clear.
2018-06-30 23:17:03 +02:00
Vadim Zeitlin
eadcd93bf9 Remove wxListBox::MacGetBlockEvents()
Just test m_blockEvents directly, there doesn't seem to be any gain in
using an accessor here.

Also test it only once instead of doing it twice in
MacHandleSelectionChange().
2018-06-30 23:14:36 +02:00
Vadim Zeitlin
dde6f662fc Move wxListBox selection event generation to wxListBox itself
This allows to avoid making DoChangeSingleSelection() and
CalcAndSendEvent() public.

No real changes, this is just a refactoring.
2018-06-30 23:13:33 +02:00
Vadim Zeitlin
1eee7a8a3c Slightly improve the assertion failure message
Also remove the unnecessary wxT().
2018-06-30 23:10:02 +02:00
Vadim Zeitlin
0084fb94be Use wxDynamicCast() instead of static_cast<>
This is safer as it really checks if the pointer is of the correct type.
2018-06-30 23:09:06 +02:00
ikamakj
c369c792a3 Fix selection event generation in wxMac wxListBox
Prevents deselecting the selected item in single-selection listbox.

Also generate correct events in the multi-selection case by reusing the
existing wxListBoxBase::CalcAndSendEvent() method.

Closes #15603.
2018-06-30 23:05:57 +02:00
Stefan Csomor
2ab430965c Fixing wxGLCanvas under 10.14, preparing for layer based drawing
see https://github.com/wxWidgets/wxWidgets/pull/846 , thanks to dkulp
2018-06-30 16:57:57 +02:00
Stefan Csomor
24dbe9775c Switching colorspace according to Apple's recommendation 2018-06-29 15:40:23 +02:00
Vadim Zeitlin
17c7048f36 Fix crash when appending items of empty vector to wxItemContainer
Passing an empty std::vector<wxString> to Append() or Insert() methods
of any wxItemContainer-derived classes, such as e.g. wxComboBox,
resulted in undefined behaviour due to accessing the first element of an
empty vector.

Fix this by avoiding using it when the vector is empty.
2018-06-29 14:33:56 +02:00
Paul Cornett
32db375e46 Avoid assertion failure in wxGLContext ctor
Check for NULL pointers directly rather than making assumptions based
on a version check.
See #18155
2018-06-28 10:38:14 -07:00