Avoid creating a default wxGraphicsContext unnecessarily, only to
immediately delete it and replace it with the provided one.
This was at best unnecessary and at worst resulted in a crash if the
default context couldn't be created, as happened on a headless system
(where wxImage-based wxGraphicsContext can still be created
successfully).
If nothing else, this avoids 2 calls to each of wxGetDisplaySize() and
wxGetDisplaySizeMM() on each and every wxGCDC construction which are
completely unnecessary as wxGCDCImpl uses its own hardcoded resolution
of 72 DPI, as do some other classes deriving from wxDCImpl.
And even for the classes which do compute these fields using the display
resolution, it may still be unnecessary to do it as they can be never
used if neither GetSizeMM() nor SetLogicalScale() are called on the
corresponding wxDC object.
Finally, this is more than an optimization as when using Cairo-based
wxGCDC without display (which is explicitly supported), calling
wxGetDisplaySize() simply doesn't work at all.
Removing a page from wxToolbook could result in crashes due to
dereferencing the now invalid page index. Fix this by not assuming that
the page index is the same as its tool ID, but adding functions to
explicitly map one to the other.
Also fix inserting pages into wxToolbook, which worked as appending them
before.
Closes https://github.com/wxWidgets/wxWidgets/pull/1042Closes#18275.
Update the colours used when the system theme changes.
This is especially important to use the colour scheme compatible with
macOS 10.14+ dark mode.
Note that this commit is best viewed with "git diff --color-moved".
Closes https://github.com/wxWidgets/wxWidgets/pull/916
Add functions to enable or disable pages inside wxToolbook.
Using the new functions you can present disabled icons so that the user
can expect more functionality and you do not need to add/remove pages in
different states.
Closes https://github.com/wxWidgets/wxWidgets/pull/1038
private field 'm_dwCookie' is not used
'return' will never be executed
result of comparison of unsigned enum expression < 0 is always false
'FlushDC' overrides a member function but is not marked 'override'
potentially uninitialized local variable 'bound' used
Under wxMSW this method is re-entered due to triggering EVT_ACTIVATE when EVT_LEFT_UP is being already handled.
We need to prevent this to avoid generating spurious EVT_TEXT events and raising errors on calling SetFocus().
Closes#18260.
Dragging a column header in a wxHeaderCtrl and dropping it past the
rightmost column resulted in a crash due to accessing a column with
invalid index.
Fix this and correctly move the column to the last position when this
happens instead.
This bug notably affected dragging columns in wxGrid.
Closes https://github.com/wxWidgets/wxWidgets/pull/972
This fixes the access specifier effectively used for the members
following these macros, as it's changed to "public" inside them, meaning
that e.g. m_privateContextMenu was actually public even though it was
ostensibly declared in the private section and the intention was for it
to be private.
Closes#16038.
Defining a Mac-specific Create(wxMemoryBuffer) overload hid the other
Create() overloads, which are actually part of the public API, so they
couldn't be used any longer since the changes of
e7d21f6638
Fix this by renaming this Create() to OSXCreate(), to avoid hiding the
base class methods.
Also remove Mac-specific ctor taking wxMemoryBuffer, this is confusing
and can be avoided by just calling OSXCreate() directly in the only
place where it is used.
This method allows to retrieve the window this context is associated
with, if any.
Add "wxWindow*" argument to wxGraphicsContext ctor and provide the
window pointer to it when available, i.e. when creating the context from
a wxWindow directly or from wxWindowDC, which is also associated with a
window, in platform-specific code.
No real changes yet.
As SendEvent() not only sends the event about clicking on the link, but
also opens the link in the default browser if this event was not
processed (which wasn't really obvious from its name, so at least
mention it in its comment), the event is actually always handled and so
MSWOnNotify() must return true, not false (and definitely not 0) to
indicate it.
Closes#18266.
The documentation comment belongs to interface/wx/math.h, not the header
under include.
Also change the argument type to wxUint32 as the non-gcc version only
works for 32 bit values.
Generate wxJoystickEvent with the same fields under all platforms by
making the Linux and macOS versions follow MSW convention of using
"1 << N" for the changed button.
Add GetButtonOrdinal() accessor which can be used to retrieve just N.
Closes#18233.
There doesn't seem to be any point in storing pointers to wxBitmap or
wxIcon and storing the objects directly allows to avoid an extra heap
allocation and all the code dealing with freeing memory when replacing
or removing images from the list, making things much simpler.
Also use wxVector<> for storage instead of the obsolete and ugly
wxObjectList.
There shouldn't be any user-visible changes.
Cache labels for "Next>" or "Finish" button in wxWizard so that their
translations stay consistent throughout wizard's lifetime: previously,
this button could use a label in a different language if the currently
used translations have changed since the wizard creation, as this label
was recreated on every page change, unlike the other labels which were
only translated once in the very beginning.
Closes https://github.com/wxWidgets/wxWidgets/pull/1000
Under macOS colors can be patterns, then accessors for RGB values are useless, IsSolid returns true if the color can be expressed in RGB values at all.
Get rid of wxOSX wxImageList implementation as it was 99% identical to
the generic version and the non-identical parts should really have been
made part of the generic version too from the beginning.
Notably, use GetScaled{Width,Height}() in Add() method in the generic
version too now.
This is not necessary as wxIcon is implicitly convertible to wxBitmap
anyhow, so calling Add(icon) works using the existing Add(wxBitmap)
overload, and is actually harmful because of the wrong icon size check
in this function, which used physical bitmap size instead of the logical
(scaled) size.
Closes#18188.
We need to account for the scale factor under GTK+ (and, presumably,
under macOS) to compute the correct PPI value as it must use the number
of physical and not logical pixels.
Reimplement wxPopupWindow using WS_POPUP instead of WS_CHILD window in
wxMSW as the new approach allows using the controls inside the popup
normally, unlike the old one.
See https://github.com/wxWidgets/wxWidgets/pull/986Closes#18243.
As wxCollapsiblePane doesn't use sizers for layout (and while this could
be changed for the generic version, it still wouldn't fix the problem
for the native one), default InformFirstDirection() implementation
forwarding it to the window sizer doesn't work for it and we need to
explicitly let the contents of wxCollapsiblePane know about the
available size.
InformFirstDirection() is required to let wxWrapSizer calculate its best
height from its current width (or vice versa, but usually in this
sense), but it only worked if wxWrapSizer was an immediate child of
another size doing layout but not if wxWrapSizer was inside another
wxBoxSizer which was contained in a top-level sizer.
Explicitly forward calls to InformFirstDirection() to wxBoxSizer
children to fix this and make wxWrapSizers nested in wxBoxSizer work.
Note that there are still many problems in this code, including but not
limited to:
- Doing this forwarding for the sizer minor direction only.
- Not passing the correct value of "availableOtherDir".
- Still calling InformFirstDirection() from RecalcSizes(), when it's too
late to change the min size returned by CalcMin().
- Inconsistency: wxGridSizer calls InformFirstDirection() from its
CalcMin(), wxFlexGridSizer calls it from its RecalcSizes(),
wxGridBagSizer doesn't call it at all.
All this size-in-first-direction logic really needs to be completely
reviewed, but for now at least make wxWrapSizer inside a wxBoxSizer work
as well, or as badly, as wxWrapSizer on its own.
Don't use the child window of the desktop window for popup windows under
MSW, while this worked in simplest cases, it didn't allow having
functional controls inside a wxPopupWindow as e.g. wxTextCtrl didn't
accept input it at all if created as a child of such window.
Instead, switch to using a top-level window, with WS_POPUP style, and
fix the problem with the loss of activation by explicitly pretending to
still be active in the owner window when losing activation to our own
popup (thanks to Barmak Shemirani for providing this solution).
Also use an MSW-specific and much simpler implementation of detecting
when the popup should be dismissed in wxPopupTransientWindow: instead of
capturing mouse or tracking focus, just react to activation loss
directly.
Add a wxTextCtrl to the popup in samples/popup to show that editing it
works now.
Change GTKGetEntryTextLength() to return a signed value, as it's always
either assigned to or compared with the signed variables anyhow.
This avoids a couple of -Wsign-compare warnings when building with g++
5.4 from Ubuntu 16.04.
This function has to be called from a GTK+ callback, so make it public
and also rename to GTKColumnToWX() to conform to the naming convention
mandating the use of "GTK" prefix for the public methods which are not
part of the public API.
While this is not done for all the ports yet, the new API allows
returning different PPI values for different monitors, unlike the old
(and still existing, but implemented in terms of the new one) global
function.
Allow getting the depth of any display, not just the primary one, even
though this is not implemented for Unix ports currently.
Mostly do this for consistency with the other display-related functions.
This makes src/unix/displayx11.cpp almost readable as it's not littered
by "#ifndef __WXGTK20__" checks everywhere any more -- instead this file
is just not compiled as part of wxGTK2 at all any longer (it is still
included in wxGTK1 as well as wxX11 itself and wxMotif).
wxGTK code also can just include the new wx/unix/private/displayx11.h
instead of having to declare all the X11 functions it uses manually.
There should be no changes in behaviour, this is just a clean up.
Simplify the code by not making this function pure virtual as all the
ports except MSW had to override it just to return an empty string.
Instead, just return empty string by default as it's not critical to
force the derived classes to override this function.
Centralize all display-related code in wxDisplay class and avoid
duplicating or reimplementing it in wxDisplaySize() and
wxClientDisplayRect() functions.
See https://github.com/wxWidgets/wxWidgets/pull/955
Instead of forwarding to these functions from wxDisplay implementation
in wxUSE_DISPLAY==0 case, make the functions themselves wrappers around
wxDisplay, which may, or not, depending on the platform, have a simpler
implementation in wxUSE_DISPLAY==0 case, but is always available in any
case.
As part of this change, only use src/osx/core/display.cpp in macOS
builds, not iOS ones and update the Xcode project accordingly too.
This cuts down on code duplication, especially in wxGTK, and facilitates
further additions to wxDisplay API.
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.
Avoid a heap allocation on every wxDisplay creation by caching the
wxDisplayImpl objects once they're created.
Currently we never invalidate the cache, but we should add a way to do
it in the future.
This speeds up wxDisplay::GetGeometry() benchmark by a factor of 4.
This is more consistent with the other headers, which are safe to
include even when the corresponding feature is turned off.
Also remove the now redundant wxUSE_ENH_METAFILE checks in the source
code including this header.
See https://github.com/wxWidgets/wxWidgets/pull/951
Code doing "bitmap = image" compiled in the other ports, but not in
wxMSW with WXWIN_COMPATIBILITY_3_0==1 as there was an ambiguity between
converting wxImage to wxBitmap, as intended, or converting wxImage to
wxCursor and then assigning it to wxBitmap using operator=(wxCursor)
overload.
Resolve this ambiguity by providing operator=() overload taking wxImage
directly.
This fixes widgets sample compilation under MSW after the changes of
455a45f5a8
See https://github.com/wxWidgets/wxWidgets/pull/946
Mark the function as deprecated. It should not be part of the public API. It
cannot be overridden and manually calling it has no lasting effect because
DrawCaption calls it as well.
Closes https://github.com/wxWidgets/wxWidgets/pull/943
The code handling the mouse events assumed the drop down button with was
10px, but wxAuiMSWToolBarArt uses a different width (14px). So clicking
on the left-most 4 pixels was not registered as a drop down click.
Allow the get (and set) the width of the drop down button of the
ToolBarArt.
Increase the detection area for drop down events, because the drop down
button is drawn 1 pixel larger than the actual size.
Rename some variables where dropdown was used instead of overflow.
Closes https://github.com/wxWidgets/wxWidgets/pull/939
Add an explicit cast to avoid warnings when compiling with this option.
While just casting double to float is not the best idea, it seems quite
unlikely that anybody would pass a value outside of float range to this
ctor.
wxTreebook is supposed to allow not specifying any valid window for the
top-level pages, but this didn't work any longer, probably since the
changes of 02a92e23f3 (see #4379), as a
possibly null page was dereferenced without checking, resulting in a
crash.
Fix this by adding a missing check.
Also rename DoGetNonNullPage() to TryGetNonNullPage() to make it more
clear that this function can return null and add a unit test checking
that calling AddPage(NULL) really works (or at least doesn't crash).
See https://github.com/wxWidgets/wxWidgets/pull/921
Remove SetWindowMenuLabelTranslated() which was only called once and so
didn't seem to be worth having. Also get rid of WINDOW_MENU_LABEL for
the same reason: it was used only once and imposed the use of
gettext_noop() which is not needed any longer.
Rename GetWindowMenuLabelTranslated() to have a MSW prefix in order to
indicate that it's a private MSW function and not part of the public wx
API.
Also renamed "Translated" to "Current" to (hopefully) more clearly
indicate why do we need to keep this variable.
Include both <algorithm>, to get std::swap() declaration when using
C++98, and <utility>, to do the same thing when using C++11.
This is not pretty but simpler than using preprocessor tests (which
would need to take MSVS into account in a special way) and virtually
guaranteed not to break anything.
Closes#18220.
Complete support for fractional point sizes and font weights other than
light/bold.
Also harmonize wxFont API and implementation among all ports (fixing
compilation of those of them that were broken by recent changes).
See https://github.com/wxWidgets/wxWidgets/pull/919
Window initial/minimum/maximum sizes are now treated as logical pixels.
Furthermore, many margins and paddings are now converted using
wxWindow::FromDIP() to allow their growth in accord with screen DPI.
This places buttons on toolbars more apart on high DPI screens providing
space for easier touch operations.
Closes https://github.com/wxWidgets/wxWidgets/pull/933
Use wxVector<wxListLineData*> instead of WX_DECLARE_OBJARRAY().
This modernizes the code and allows to get rid of the static variables
previously used for sorting as now we can use std::sort().
Closes https://github.com/wxWidgets/wxWidgets/pull/924
This is a preliminary ARM64 platform support for wxWidgets at "it
compiles" stage. This will allow building and testing wxWidgets based
apps for oncoming Windows 10 ARM64.
Requirements:
- Visual Studio 2017 Update 4 or later with Visual C++ compilers and
libraries for ARM64 component installed
Building:
1. Open command prompt.
2. Change directory to build\msw subfolder.
3. Run "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat" once.
4. Use `nmake TARGET_CPU=ARM64 ...` to build required flavor of wxWidget
libraries.
Notes:
1. Building of *.sln/*.vcxproj files does not support ARM64 yet. This
requires to hardcode Windows SDK to 10.0.15063.0 or later in
*.vcxproj files, which would render them non-compilable in older
Visual Studio versions. Microsoft is aware of this issue and is
planning a fix in the next version of Visual Studio.
2. wxmsw31ud_gl.dll does not build yet. Awaiting Microsoft to deliver
missing opengl32.lib for ARM64. Please, specify USE_OPENGL=0.
Closes https://github.com/wxWidgets/wxWidgets/pull/923
Implement the new {Get,Set}{FractionalPointSize,NumericWeight} methods.
Also change wxLoadQueryFont() to use wxNativeFontInfo methods as a side
effect, to reduce code duplication and reuse the existing support for
numeric weights and fractional point sizes in wxNativeFontInfo.
Replace AccountForCompatValues() with InfoFromLegacyParams() which
directly constructs wxFontInfo from the old-style parameters, applying
all the compatibility hacks internally.
There are no real changes in this commit, just simplify the code further
and make wxFontInfo more central.