Use custom configuration name in objects dir path with MSBuild When using MSBuild, use the custom configuration name (property wxCfg) in the object files folder name (property wxIntRootDir), just as it is already done in the NMake makefile. Closes #26135. Closes #26136.
Fix marking wrong item as being deleted in wxOSX wxDataViewCtrl The comment in wxDataViewCtrl::IsClearing() said that the item being deleted should be invalid only when the entire model is being cleared, but this wasn't the case in ItemDeleted() as its "parent" argument could be invalid (e.g. when using a flat list model) even if "item" itself is valid. Use "item", not "parent", to set the item being deleted to the correct value to fix this. Closes #26138. Closes #26139.
Fix MSVS 2015 build using original Platform SDK The Windows headers bundled with MSVS 2015 do not define WINHTTP_OPTION_HTTP_PROTOCOL_USED, an option flag required after 9a76757 (Add wxWebRequestDebugLogger for details logging of HTTP transfers, 2026-01-15). Fix this by defining the option flag by ourselves when needed. Closes #26144.
Document wxGLAttributes::Default no longer using multi-sampling This was changed in 46857a73ba (Don't use multi-sampling in wxGLAttributes::Defaults(), 2023-02-14) but the documentation wasn't updated. Closes #26143.
Rename wxOSXDVCDeleting::m_parent to m_item No real changes, just don't use "parent" for the name of the item being deleted, this is confusing as it's really the item itself and not its parent. See #26139.
Get rid of multiline macros in wxArray unit test Use template functions instead. There is still TestArrayOf() macro left but it's trivial now. No real changes.
Remove unnecessary wxWebViewConfigurationDefault class This class didn't do anything, base wxWebViewConfigurationImpl can be used directly instead of it.
Fix crash when using wxWebViewConfiguration for IE backend Implement CreateConfiguration() in wxWebViewFactoryIE to return an object using IE backend name, otherwise using this configuration could create the backend of a wrong type (e.g. Edge, which is the default backend if it is enabled) and result in a crash when that backend tried to cast the configuration pointer to its own type. Closes #26152.
Assert that index is valid in wxArray::operator[] Restore compatibility with all the previous wxWidgets versions that had this assert and make sure that errors in the code using this operator don't go unnoticed, as it happened with #26148. Closes #26149.
Make wxWebViewFactory::CreateConfiguration() pure virtual As the parent commit shows, this function must be overridden even for the backends not using any special configuration type, just to ensure the returned object has the correct backend string, so having a default implementation for it was dangerous and could never work. Force the derived classes to implement this function instead, even if trivially, as in wxWebViewFactoryIE and wxWebViewFactoryWebKit when not using WebKit2. See #26152.
Document wxGetStockHelpString() function It was added back in 345319d60c (fixes to menu stock items support (patch 1547639), 2006-09-05) and even if it's not particularly useful, it still should be documented, so add documentation for it. See #8090.
Minor corrections to standard IDs documentation Remove misleading Doxygen comments copied from the comments in C++ header which didn't make sense here. Improve the documentation of menu ID ranges.
Fix initial focus in wxWebView Edge backend Ensure keyboard focus is inside the document if the WebView window gets focus before MS Webview2 is fully initialized. If focus moved to the wxWebView window before the Edge instance was fully created, we couldn't call m_webViewController->MoveFocus at that time. If focus is on the wxWebview at the time we get the wxWebViewEdgeImpl::OnWebViewCreated callback, we now call MoveFocus to ensure that focus is inside of the web content window. This helps screen readers, since they use the focus window to influence their behavior. Closes #26155. Closes #26156.
Fix wxPropertyGridInterface::SetPropertyImage() documentation It takes wxBitmapBundle by const reference, but "const" was omitted. Closes #26158.
Merge branch 'fix-webview-ie-conf' Fix using webview configurations for selecting IE backend. See #26153.
Merge branch 'array-assert-invalid-index' Restore wxArray assert checking index validity. See #26154.
Refactor to reuse common code in wxOSX wxFileDialog Add wxFileDialog::CommonShow() instead of duplicating the same code in both ShowWindowModal() and ShowModal(). No real changes, this is just a refactoring. This commit is best viewed using Git --color-moved option.
Fix using invalid filter index in wxOSX wxFileDialog Ensure we use the valid index in m_filterExtensions when m_firstFileTypeFilter was set to -1. Closes #26148.
Refactor code in wxOSX wxFileDialog to be more readable No real changes, just try to make the logic of the code more clear (such as it is, it's still not totally clear why are we doing this, i.e. what does setting m_firstFileTypeFilter to -1 when m_useFileTypeFilter is false actually achieve, but at least it's now more obvious that this is what we do).
| ... | ... | @@ -65,16 +65,16 @@ |
| 65 | 65 | <wxOutDir>..\..\lib\$(wxOutDirName)\</wxOutDir>
|
| 66 | 66 | </PropertyGroup>
|
| 67 | 67 | <PropertyGroup Label="UserMacros" Condition="'$(Configuration)'=='DLL Debug'">
|
| 68 | - <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)dll\</wxIntRootDir>
|
|
| 68 | + <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)dll$(wxCfg)\</wxIntRootDir>
|
|
| 69 | 69 | </PropertyGroup>
|
| 70 | 70 | <PropertyGroup Label="UserMacros" Condition="'$(Configuration)'=='DLL Release'">
|
| 71 | - <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)dll\</wxIntRootDir>
|
|
| 71 | + <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)dll$(wxCfg)\</wxIntRootDir>
|
|
| 72 | 72 | </PropertyGroup>
|
| 73 | 73 | <PropertyGroup Label="UserMacros" Condition="'$(Configuration)'=='Debug'">
|
| 74 | - <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)\</wxIntRootDir>
|
|
| 74 | + <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)$(wxCfg)\</wxIntRootDir>
|
|
| 75 | 75 | </PropertyGroup>
|
| 76 | 76 | <PropertyGroup Label="UserMacros" Condition="'$(Configuration)'=='Release'">
|
| 77 | - <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)\</wxIntRootDir>
|
|
| 77 | + <wxIntRootDir>$(wxCompilerPrefix)$(wxArchSuffix)_$(wxToolkitPrefix)u$(wxSuffixDebug)$(wxCfg)\</wxIntRootDir>
|
|
| 78 | 78 | </PropertyGroup>
|
| 79 | 79 | <PropertyGroup Label="UserMacros">
|
| 80 | 80 | <wxIncSubDir>$(wxToolkitPrefix)u$(wxSuffixDebug)</wxIncSubDir>
|
| ... | ... | @@ -122,6 +122,18 @@ public: |
| 122 | 122 | bool IsEmpty() const { return this->empty(); }
|
| 123 | 123 | size_t Count() const { return this->size(); }
|
| 124 | 124 | |
| 125 | + T& operator[](size_t uiIndex)
|
|
| 126 | + {
|
|
| 127 | + wxASSERT( uiIndex < this->size() );
|
|
| 128 | + return base_vec::operator[](uiIndex);
|
|
| 129 | + }
|
|
| 130 | + |
|
| 131 | + const T& operator[](size_t uiIndex) const
|
|
| 132 | + {
|
|
| 133 | + wxASSERT( uiIndex < this->size() );
|
|
| 134 | + return base_vec::operator[](uiIndex);
|
|
| 135 | + }
|
|
| 136 | + |
|
| 125 | 137 | T& Item(size_t uiIndex) const
|
| 126 | 138 | {
|
| 127 | 139 | wxASSERT( uiIndex < this->size() );
|
| ... | ... | @@ -230,9 +230,10 @@ public: |
| 230 | 230 | return nullptr;
|
| 231 | 231 | }
|
| 232 | 232 | |
| 233 | + virtual wxWebViewConfiguration CreateConfiguration() override;
|
|
| 234 | + |
|
| 233 | 235 | #if wxUSE_WEBVIEW_WEBKIT2
|
| 234 | 236 | virtual wxVersionInfo GetVersionInfo(wxVersionContext context) override;
|
| 235 | - virtual wxWebViewConfiguration CreateConfiguration() override;
|
|
| 236 | 237 | virtual wxWebView* CreateWithConfig(const wxWebViewConfiguration& config) override;
|
| 237 | 238 | #endif
|
| 238 | 239 | };
|
| ... | ... | @@ -193,6 +193,7 @@ public: |
| 193 | 193 | const wxString& name = wxASCII_STR(wxWebViewNameStr)) override
|
| 194 | 194 | { return new wxWebViewIE(parent, id, url, pos, size, style, name); }
|
| 195 | 195 | virtual wxVersionInfo GetVersionInfo(wxVersionContext context) override;
|
| 196 | + virtual wxWebViewConfiguration CreateConfiguration() override;
|
|
| 196 | 197 | };
|
| 197 | 198 | |
| 198 | 199 | #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
| ... | ... | @@ -100,6 +100,7 @@ protected: |
| 100 | 100 | private:
|
| 101 | 101 | // Common part of all ctors.
|
| 102 | 102 | void Init();
|
| 103 | + void CommonShow();
|
|
| 103 | 104 | };
|
| 104 | 105 | |
| 105 | 106 | #endif // _WX_FILEDLG_H_ |
| ... | ... | @@ -200,7 +200,7 @@ public: |
| 200 | 200 | {
|
| 201 | 201 | return wxVersionInfo();
|
| 202 | 202 | }
|
| 203 | - virtual wxWebViewConfiguration CreateConfiguration();
|
|
| 203 | + virtual wxWebViewConfiguration CreateConfiguration() = 0;
|
|
| 204 | 204 | };
|
| 205 | 205 | |
| 206 | 206 | using wxStringWebViewFactoryMap = std::unordered_map<wxString, wxSharedPtr<wxWebViewFactory>>;
|
| ... | ... | @@ -655,7 +655,7 @@ enum wxStandardID |
| 655 | 655 | wxID_FILE8,
|
| 656 | 656 | wxID_FILE9,
|
| 657 | 657 | |
| 658 | - /** Standard button and menu IDs */
|
|
| 658 | + // Standard button and menu IDs
|
|
| 659 | 659 | wxID_OK = 5100,
|
| 660 | 660 | wxID_CANCEL,
|
| 661 | 661 | wxID_APPLY,
|
| ... | ... | @@ -718,16 +718,15 @@ enum wxStandardID |
| 718 | 718 | wxID_SPELL_CHECK,
|
| 719 | 719 | wxID_STRIKETHROUGH,
|
| 720 | 720 | |
| 721 | - /** System menu IDs (used by wxUniv): */
|
|
| 722 | - wxID_SYSTEM_MENU = 5200,
|
|
| 723 | - wxID_CLOSE_FRAME,
|
|
| 724 | - wxID_MOVE_FRAME,
|
|
| 725 | - wxID_RESIZE_FRAME,
|
|
| 726 | - wxID_MAXIMIZE_FRAME,
|
|
| 727 | - wxID_ICONIZE_FRAME,
|
|
| 728 | - wxID_RESTORE_FRAME,
|
|
| 721 | + wxID_SYSTEM_MENU = 5200,///< System menu ID (used only by wxUniv).
|
|
| 722 | + wxID_CLOSE_FRAME, ///< System menu close item ID (used only by wxUniv).
|
|
| 723 | + wxID_MOVE_FRAME, ///< System menu move item ID (used only by wxUniv).
|
|
| 724 | + wxID_RESIZE_FRAME, ///< System menu size item ID (used only by wxUniv).
|
|
| 725 | + wxID_MAXIMIZE_FRAME, ///< System menu maximize item ID (used only by wxUniv).
|
|
| 726 | + wxID_ICONIZE_FRAME, ///< System menu minimize item ID (used only by wxUniv).
|
|
| 727 | + wxID_RESTORE_FRAME, ///< System menu restore item ID (used only by wxUniv).
|
|
| 729 | 728 | |
| 730 | - /** MDI window menu ids */
|
|
| 729 | + /// Start of the range of IDs reserved for MDI menu commands.
|
|
| 731 | 730 | wxID_MDI_WINDOW_FIRST = 5230,
|
| 732 | 731 | wxID_MDI_WINDOW_CASCADE = wxID_MDI_WINDOW_FIRST,
|
| 733 | 732 | wxID_MDI_WINDOW_TILE_HORZ,
|
| ... | ... | @@ -735,12 +734,13 @@ enum wxStandardID |
| 735 | 734 | wxID_MDI_WINDOW_ARRANGE_ICONS,
|
| 736 | 735 | wxID_MDI_WINDOW_PREV,
|
| 737 | 736 | wxID_MDI_WINDOW_NEXT,
|
| 737 | + /// End of the range of IDs reserved for MDI menu commands.
|
|
| 738 | 738 | wxID_MDI_WINDOW_LAST = wxID_MDI_WINDOW_NEXT,
|
| 739 | 739 | |
| 740 | - /** IDs used by generic file dialog (13 consecutive starting from this value) */
|
|
| 740 | + /** Start of IDs used by generic file dialog (13 consecutive starting from this value) */
|
|
| 741 | 741 | wxID_FILEDLGG = 5900,
|
| 742 | 742 | |
| 743 | - /** IDs used by generic file ctrl (4 consecutive starting from this value) */
|
|
| 743 | + /** Start of IDs used by generic file control (4 consecutive starting from this value) */
|
|
| 744 | 744 | wxID_FILECTRL = 5950,
|
| 745 | 745 | |
| 746 | 746 | /**
|
| ... | ... | @@ -259,7 +259,7 @@ public: |
| 259 | 259 | |
| 260 | 260 | /**
|
| 261 | 261 | wxWidgets defaults:
|
| 262 | - RGBA, Z-depth 16 bits, double buffering, 1 sample buffer, 4 samplers.
|
|
| 262 | + RGBA, Z-depth 16 bits, double buffering.
|
|
| 263 | 263 | |
| 264 | 264 | @see PlatformDefaults()
|
| 265 | 265 | */
|
| ... | ... | @@ -1026,7 +1026,7 @@ public: |
| 1026 | 1026 | @remarks Bitmap will be scaled to a size returned by
|
| 1027 | 1027 | wxPropertyGrid::GetImageSize();
|
| 1028 | 1028 | */
|
| 1029 | - void SetPropertyImage( wxPGPropArg id, wxBitmapBundle& bmp );
|
|
| 1029 | + void SetPropertyImage( wxPGPropArg id, const wxBitmapBundle& bmp );
|
|
| 1030 | 1030 | |
| 1031 | 1031 | /**
|
| 1032 | 1032 | Sets maximum length of text in property text editor.
|
| ... | ... | @@ -81,3 +81,30 @@ wxString wxGetStockLabel(wxWindowID id, long flags = wxSTOCK_WITH_MNEMONIC); |
| 81 | 81 | |
| 82 | 82 | ///@}
|
| 83 | 83 | |
| 84 | +/** @addtogroup group_funcmacro_misc */
|
|
| 85 | +///@{
|
|
| 86 | + |
|
| 87 | +/**
|
|
| 88 | + Return help string associated with given stock @a id and @a client.
|
|
| 89 | + |
|
| 90 | + This function uses the default help string shown in the status bar when the
|
|
| 91 | + item with the given @a id is selected in a menu, e.g. for ::wxID_EXIT the
|
|
| 92 | + returned string is "Quit this program".
|
|
| 93 | + |
|
| 94 | + @param id
|
|
| 95 | + The stock item identifier to get the help string for.
|
|
| 96 | + @param client
|
|
| 97 | + The client context for which the help string is requested, currently
|
|
| 98 | + can only be `wxSTOCK_MENU`, which is the default value for this
|
|
| 99 | + parameter.
|
|
| 100 | + @return
|
|
| 101 | + The translated help string for the given stock item identifier and
|
|
| 102 | + client context, or an empty string if no default help string is
|
|
| 103 | + available for this @a id.
|
|
| 104 | + |
|
| 105 | + @header{wx/stockitem.h}
|
|
| 106 | + */
|
|
| 107 | +wxString wxGetStockHelpString(wxWindowID id,
|
|
| 108 | + wxStockHelpStringClient client = wxSTOCK_MENU);
|
|
| 109 | + |
|
| 110 | +///@} |
| ... | ... | @@ -60,16 +60,6 @@ wxDEFINE_EVENT( wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, wxWebViewEvent); |
| 60 | 60 | wxDEFINE_EVENT( wxEVT_WEBVIEW_SCRIPT_RESULT, wxWebViewEvent);
|
| 61 | 61 | wxDEFINE_EVENT( wxEVT_WEBVIEW_BROWSING_DATA_CLEARED, wxWebViewEvent);
|
| 62 | 62 | |
| 63 | -// wxWebViewConfigurationDefault
|
|
| 64 | -class wxWebViewConfigurationImplDefault : public wxWebViewConfigurationImpl
|
|
| 65 | -{
|
|
| 66 | -public:
|
|
| 67 | - virtual void* GetNativeConfiguration() const override
|
|
| 68 | - {
|
|
| 69 | - return nullptr;
|
|
| 70 | - }
|
|
| 71 | -};
|
|
| 72 | - |
|
| 73 | 63 | // wxWebViewConfiguration
|
| 74 | 64 | wxWebViewConfiguration::wxWebViewConfiguration(const wxString& backend, wxWebViewConfigurationImpl* impl):
|
| 75 | 65 | m_backend(backend), m_impl(impl)
|
| ... | ... | @@ -495,7 +485,7 @@ wxWebViewConfiguration wxWebView::NewConfiguration(const wxString& backend) |
| 495 | 485 | if (iter != m_factoryMap.end())
|
| 496 | 486 | return iter->second->CreateConfiguration();
|
| 497 | 487 | else
|
| 498 | - return wxWebViewConfiguration(backend, new wxWebViewConfigurationImplDefault);
|
|
| 488 | + return wxWebViewConfiguration(backend, new wxWebViewConfigurationImpl);
|
|
| 499 | 489 | }
|
| 500 | 490 | |
| 501 | 491 | // static
|
| ... | ... | @@ -545,9 +535,4 @@ void wxWebView::InitFactoryMap() |
| 545 | 535 | #endif
|
| 546 | 536 | }
|
| 547 | 537 | |
| 548 | -wxWebViewConfiguration wxWebViewFactory::CreateConfiguration()
|
|
| 549 | -{
|
|
| 550 | - return wxWebViewConfiguration(wxWebViewBackendDefault, new wxWebViewConfigurationImplDefault);
|
|
| 551 | -}
|
|
| 552 | - |
|
| 553 | 538 | #endif // wxUSE_WEBVIEW |
| ... | ... | @@ -18,6 +18,9 @@ |
| 18 | 18 | #include "wx/filesys.h"
|
| 19 | 19 | #include "wx/base64.h"
|
| 20 | 20 | #include "wx/log.h"
|
| 21 | + |
|
| 22 | +#include "wx/private/webview.h"
|
|
| 23 | + |
|
| 21 | 24 | #include <webkit/webkit.h>
|
| 22 | 25 | |
| 23 | 26 | // ----------------------------------------------------------------------------
|
| ... | ... | @@ -1033,5 +1036,14 @@ wxWebViewWebKit::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) |
| 1033 | 1036 | return GetDefaultAttributesFromGTKWidget(webkit_web_view_new());
|
| 1034 | 1037 | }
|
| 1035 | 1038 | |
| 1039 | +// ----------------------------------------------------------------------------
|
|
| 1040 | +// wxWebViewFactoryWebKit
|
|
| 1041 | +// ----------------------------------------------------------------------------
|
|
| 1042 | + |
|
| 1043 | +wxWebViewConfiguration wxWebViewFactoryWebKit::CreateConfiguration()
|
|
| 1044 | +{
|
|
| 1045 | + return wxWebViewConfiguration(wxWebViewBackendWebKit,
|
|
| 1046 | + new wxWebViewConfigurationImpl);
|
|
| 1047 | +}
|
|
| 1036 | 1048 | |
| 1037 | 1049 | #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT |
| ... | ... | @@ -140,6 +140,9 @@ wxWinHTTP::WinHttpSetTimeouts_t wxWinHTTP::WinHttpSetTimeouts; |
| 140 | 140 | #ifndef WINHTTP_OPTION_ENABLE_HTTP_PROTOCOL
|
| 141 | 141 | #define WINHTTP_OPTION_ENABLE_HTTP_PROTOCOL 133
|
| 142 | 142 | #endif
|
| 143 | +#ifndef WINHTTP_OPTION_HTTP_PROTOCOL_USED
|
|
| 144 | +#define WINHTTP_OPTION_HTTP_PROTOCOL_USED 134
|
|
| 145 | +#endif
|
|
| 143 | 146 | #ifndef WINHTTP_DECOMPRESSION_FLAG_ALL
|
| 144 | 147 | #define WINHTTP_DECOMPRESSION_FLAG_GZIP 0x00000001
|
| 145 | 148 | #define WINHTTP_DECOMPRESSION_FLAG_DEFLATE 0x00000002
|
| ... | ... | @@ -856,6 +856,14 @@ HRESULT wxWebViewEdgeImpl::OnWebViewCreated(HRESULT result, ICoreWebView2Control |
| 856 | 856 | m_webViewController->put_IsVisible(true);
|
| 857 | 857 | m_ctrl->NotifyWebViewCreated();
|
| 858 | 858 | |
| 859 | + // If focus moved to the WebView window before the Edge instance was fully
|
|
| 860 | + // created, we couldn't call m_webViewController->MoveFocus at that time. If focus is
|
|
| 861 | + // there now, call MoveFocus to ensure that focus is inside of the web
|
|
| 862 | + // content window. This helps screen readers, since they use the focus
|
|
| 863 | + // window to influence their behavior.
|
|
| 864 | + if (m_ctrl && m_ctrl->HasFocus())
|
|
| 865 | + m_webViewController->MoveFocus(COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC);
|
|
| 866 | + |
|
| 859 | 867 | // Connect and handle the various WebView events
|
| 860 | 868 | m_webView->add_NavigationStarting(
|
| 861 | 869 | Callback<ICoreWebView2NavigationStartingEventHandler>(
|
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | #include "wx/msw/private.h"
|
| 26 | 26 | #include "wx/msw/private/webview_ie.h"
|
| 27 | 27 | #include "wx/private/jsscriptwrapper.h"
|
| 28 | +#include "wx/private/webview.h"
|
|
| 28 | 29 | |
| 29 | 30 | #include <initguid.h>
|
| 30 | 31 | #include <exdispid.h>
|
| ... | ... | @@ -83,6 +84,11 @@ wxVersionInfo wxWebViewFactoryIE::GetVersionInfo(wxVersionContext context) |
| 83 | 84 | return {};
|
| 84 | 85 | }
|
| 85 | 86 | |
| 87 | +wxWebViewConfiguration wxWebViewFactoryIE::CreateConfiguration()
|
|
| 88 | +{
|
|
| 89 | + return wxWebViewConfiguration(wxWebViewBackendIE, new wxWebViewConfigurationImpl);
|
|
| 90 | +}
|
|
| 91 | + |
|
| 86 | 92 | //Convenience function for error conversion
|
| 87 | 93 | #define WX_ERROR_CASE(error, wxerror) \
|
| 88 | 94 | case error: \
|
| ... | ... | @@ -247,10 +247,6 @@ NSArray* GetTypesFromFilter( const wxString& filter, wxArrayString& names, wxArr |
| 247 | 247 | |
| 248 | 248 | void wxFileDialog::ShowWindowModal()
|
| 249 | 249 | {
|
| 250 | - wxCFStringRef cf( m_message );
|
|
| 251 | - wxCFStringRef dir( m_dir );
|
|
| 252 | - wxCFStringRef file( m_fileName );
|
|
| 253 | - |
|
| 254 | 250 | wxNonOwnedWindow* parentWindow = nullptr;
|
| 255 | 251 | |
| 256 | 252 | m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
|
| ... | ... | @@ -260,80 +256,13 @@ void wxFileDialog::ShowWindowModal() |
| 260 | 256 | |
| 261 | 257 | wxCHECK_RET(parentWindow, "Window modal display requires parent.");
|
| 262 | 258 | |
| 263 | - NSArray* allTypes = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions, m_currentExtensions ) ;
|
|
| 264 | - |
|
| 265 | - m_useFileTypeFilter = m_filterExtensions.GetCount() > 1;
|
|
| 266 | - |
|
| 267 | - // native behaviour on macos is to enable just every file type
|
|
| 268 | - // in a file open dialog that could be handled, without a file
|
|
| 269 | - // filter choice control
|
|
| 270 | - // wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES allows to override
|
|
| 271 | - // that and get the same behaviour as other platforms have ...
|
|
| 272 | - |
|
| 273 | - if( HasFlag(wxFD_OPEN) )
|
|
| 274 | - {
|
|
| 275 | - if ( !(wxSystemOptions::HasOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES ) && (wxSystemOptions::GetOptionInt( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES ) == 1)) )
|
|
| 276 | - m_useFileTypeFilter = false;
|
|
| 277 | - }
|
|
| 278 | - |
|
| 279 | - m_firstFileTypeFilter = -1;
|
|
| 280 | - |
|
| 281 | - if ( m_useFileTypeFilter
|
|
| 282 | - && m_filterIndex >= 0 && (size_t)m_filterIndex < m_filterExtensions.GetCount() )
|
|
| 283 | - {
|
|
| 284 | - m_firstFileTypeFilter = m_filterIndex;
|
|
| 285 | - }
|
|
| 286 | - else if ( m_useFileTypeFilter )
|
|
| 287 | - {
|
|
| 288 | - m_firstFileTypeFilter = GetMatchingFilterExtension(m_fileName);
|
|
| 289 | - }
|
|
| 259 | + CommonShow();
|
|
| 290 | 260 | |
| 291 | 261 | if ( HasFlag(wxFD_SAVE) )
|
| 292 | 262 | {
|
| 293 | 263 | NSSavePanel* sPanel = [NSSavePanel savePanel];
|
| 294 | 264 | |
| 295 | - SetupExtraControls(sPanel);
|
|
| 296 | - |
|
| 297 | - // makes things more convenient:
|
|
| 298 | - [sPanel setCanCreateDirectories:YES];
|
|
| 299 | - [sPanel setMessage:cf.AsNSString()];
|
|
| 300 | - // if we should be able to descend into pacakges we must somehow
|
|
| 301 | - // be able to pass this in
|
|
| 302 | - [sPanel setTreatsFilePackagesAsDirectories:NO];
|
|
| 303 | - [sPanel setCanSelectHiddenExtension:YES];
|
|
| 304 | - [sPanel setAllowedFileTypes:allTypes];
|
|
| 305 | - [sPanel setAllowsOtherFileTypes:NO];
|
|
| 306 | - [sPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
|
| 307 | - |
|
| 308 | - /*
|
|
| 309 | - Let the file dialog know what file type should be used initially.
|
|
| 310 | - If this is not done then when setting the filter index
|
|
| 311 | - programmatically to 1 the file will still have the extension
|
|
| 312 | - of the first file type instead of the second one. E.g. when file
|
|
| 313 | - types are foo and bar, a filename "myletter" with SetDialogIndex(1)
|
|
| 314 | - would result in saving as myletter.foo, while we want myletter.bar.
|
|
| 315 | - */
|
|
| 316 | - if(m_firstFileTypeFilter > 0)
|
|
| 317 | - {
|
|
| 318 | - DoOnFilterSelected(m_firstFileTypeFilter);
|
|
| 319 | - }
|
|
| 320 | - else
|
|
| 321 | - {
|
|
| 322 | - NSArray* types = GetTypesFromExtension(m_filterExtensions[m_firstFileTypeFilter], m_currentExtensions);
|
|
| 323 | - if ( m_delegate )
|
|
| 324 | - [(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
|
| 325 | - else
|
|
| 326 | - {
|
|
| 327 | - [sPanel setAllowedFileTypes: types];
|
|
| 328 | - }
|
|
| 329 | - }
|
|
| 330 | - |
|
| 331 | 265 | NSWindow* nativeParent = parentWindow->GetWXWindow();
|
| 332 | - if ( !m_dir.IsEmpty() )
|
|
| 333 | - [sPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString()
|
|
| 334 | - isDirectory:YES]];
|
|
| 335 | - if ( !m_fileName.IsEmpty() )
|
|
| 336 | - [sPanel setNameFieldStringValue: file.AsNSString()];
|
|
| 337 | 266 | |
| 338 | 267 | [sPanel beginSheetModalForWindow:nativeParent completionHandler:
|
| 339 | 268 | ^(NSModalResponse returnCode)
|
| ... | ... | @@ -345,36 +274,8 @@ void wxFileDialog::ShowWindowModal() |
| 345 | 274 | {
|
| 346 | 275 | NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
| 347 | 276 | |
| 348 | - SetupExtraControls(oPanel);
|
|
| 349 | - |
|
| 350 | - [oPanel setTreatsFilePackagesAsDirectories:NO];
|
|
| 351 | - [oPanel setCanChooseDirectories:NO];
|
|
| 352 | - [oPanel setResolvesAliases:HasFlag(wxFD_NO_FOLLOW) ? NO : YES];
|
|
| 353 | - [oPanel setCanChooseFiles:YES];
|
|
| 354 | - [oPanel setMessage:cf.AsNSString()];
|
|
| 355 | - [oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
|
|
| 356 | - [oPanel setAllowedFileTypes:allTypes];
|
|
| 357 | - [oPanel setAllowsOtherFileTypes:NO];
|
|
| 358 | - [oPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
|
| 359 | - |
|
| 360 | - // Note that the test here is intentionally different from the one
|
|
| 361 | - // above, in the wxFD_SAVE case: we need to call DoOnFilterSelected()
|
|
| 362 | - // even for m_firstFileTypeFilter == 0, i.e. when using the default
|
|
| 363 | - // filter.
|
|
| 364 | - if ( m_firstFileTypeFilter >= 0 )
|
|
| 365 | - {
|
|
| 366 | - DoOnFilterSelected(m_firstFileTypeFilter);
|
|
| 367 | - }
|
|
| 368 | - else
|
|
| 369 | - {
|
|
| 370 | - if ( m_delegate )
|
|
| 371 | - [(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
|
| 372 | - }
|
|
| 373 | - |
|
| 374 | 277 | NSWindow* nativeParent = parentWindow->GetWXWindow();
|
| 375 | - if ( !m_dir.IsEmpty() )
|
|
| 376 | - [oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString()
|
|
| 377 | - isDirectory:YES]];
|
|
| 278 | + |
|
| 378 | 279 | [oPanel beginSheetModalForWindow:nativeParent completionHandler:
|
| 379 | 280 | ^(NSModalResponse returnCode)
|
| 380 | 281 | {
|
| ... | ... | @@ -561,16 +462,9 @@ int wxFileDialog::GetMatchingFilterExtension(const wxString& filename) |
| 561 | 462 | return index;
|
| 562 | 463 | }
|
| 563 | 464 | |
| 564 | -int wxFileDialog::ShowModal()
|
|
| 465 | +void wxFileDialog::CommonShow()
|
|
| 565 | 466 | {
|
| 566 | - WX_HOOK_MODAL_DIALOG();
|
|
| 567 | - |
|
| 568 | - wxCFEventLoopPauseIdleEvents pause;
|
|
| 569 | - |
|
| 570 | - wxMacAutoreleasePool autoreleasepool;
|
|
| 571 | - |
|
| 572 | 467 | wxCFStringRef cf( m_message );
|
| 573 | - |
|
| 574 | 468 | wxCFStringRef dir( m_dir );
|
| 575 | 469 | wxCFStringRef file( m_fileName );
|
| 576 | 470 | |
| ... | ... | @@ -578,8 +472,6 @@ int wxFileDialog::ShowModal() |
| 578 | 472 | m_fileNames.Clear();
|
| 579 | 473 | m_paths.Clear();
|
| 580 | 474 | |
| 581 | - int returnCode = -1;
|
|
| 582 | - |
|
| 583 | 475 | NSArray* allTypes = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions, m_currentExtensions ) ;
|
| 584 | 476 | |
| 585 | 477 | m_useFileTypeFilter = m_filterExtensions.GetCount() > 1;
|
| ... | ... | @@ -596,20 +488,18 @@ int wxFileDialog::ShowModal() |
| 596 | 488 | m_useFileTypeFilter = false;
|
| 597 | 489 | }
|
| 598 | 490 | |
| 599 | - m_firstFileTypeFilter = -1;
|
|
| 600 | - |
|
| 601 | - if ( m_useFileTypeFilter
|
|
| 602 | - && m_filterIndex >= 0 && (size_t)m_filterIndex < m_filterExtensions.GetCount() )
|
|
| 491 | + if ( m_useFileTypeFilter )
|
|
| 603 | 492 | {
|
| 604 | - m_firstFileTypeFilter = m_filterIndex;
|
|
| 493 | + if ( m_filterIndex >= 0 && (size_t)m_filterIndex < m_filterExtensions.GetCount() )
|
|
| 494 | + m_firstFileTypeFilter = m_filterIndex;
|
|
| 495 | + else
|
|
| 496 | + m_firstFileTypeFilter = GetMatchingFilterExtension(m_fileName);
|
|
| 605 | 497 | }
|
| 606 | - else if ( m_useFileTypeFilter )
|
|
| 498 | + else
|
|
| 607 | 499 | {
|
| 608 | - m_firstFileTypeFilter = GetMatchingFilterExtension(m_fileName);
|
|
| 500 | + m_firstFileTypeFilter = -1;
|
|
| 609 | 501 | }
|
| 610 | 502 | |
| 611 | - OSXBeginModalDialog();
|
|
| 612 | - |
|
| 613 | 503 | if ( HasFlag(wxFD_SAVE) )
|
| 614 | 504 | {
|
| 615 | 505 | NSSavePanel* sPanel = [NSSavePanel savePanel];
|
| ... | ... | @@ -645,7 +535,11 @@ int wxFileDialog::ShowModal() |
| 645 | 535 | }
|
| 646 | 536 | else
|
| 647 | 537 | {
|
| 648 | - NSArray* types = GetTypesFromExtension(m_filterExtensions[m_firstFileTypeFilter], m_currentExtensions);
|
|
| 538 | + // m_firstFileTypeFilter may be -1 here if we're not using the
|
|
| 539 | + // combobox for selecting the filter, use the first filter in this
|
|
| 540 | + // case
|
|
| 541 | + const int filterIndex = m_useFileTypeFilter ? m_firstFileTypeFilter : 0;
|
|
| 542 | + NSArray* types = GetTypesFromExtension(m_filterExtensions[filterIndex], m_currentExtensions);
|
|
| 649 | 543 | if ( m_delegate )
|
| 650 | 544 | [(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
| 651 | 545 | else
|
| ... | ... | @@ -658,9 +552,6 @@ int wxFileDialog::ShowModal() |
| 658 | 552 | |
| 659 | 553 | if ( !m_fileName.IsEmpty() )
|
| 660 | 554 | [sPanel setNameFieldStringValue: file.AsNSString()];
|
| 661 | - |
|
| 662 | - returnCode = [sPanel runModal];
|
|
| 663 | - ModalFinishedCallback(sPanel, returnCode);
|
|
| 664 | 555 | }
|
| 665 | 556 | else
|
| 666 | 557 | {
|
| ... | ... | @@ -700,6 +591,35 @@ int wxFileDialog::ShowModal() |
| 700 | 591 | if ( !m_dir.IsEmpty() )
|
| 701 | 592 | [oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString()
|
| 702 | 593 | isDirectory:YES]];
|
| 594 | + }
|
|
| 595 | +}
|
|
| 596 | + |
|
| 597 | +int wxFileDialog::ShowModal()
|
|
| 598 | +{
|
|
| 599 | + WX_HOOK_MODAL_DIALOG();
|
|
| 600 | + |
|
| 601 | + wxCFEventLoopPauseIdleEvents pause;
|
|
| 602 | + |
|
| 603 | + wxMacAutoreleasePool autoreleasepool;
|
|
| 604 | + |
|
| 605 | + int returnCode = -1;
|
|
| 606 | + |
|
| 607 | + CommonShow();
|
|
| 608 | + |
|
| 609 | + OSXBeginModalDialog();
|
|
| 610 | + |
|
| 611 | + if ( HasFlag(wxFD_SAVE) )
|
|
| 612 | + {
|
|
| 613 | + NSSavePanel* sPanel = [NSSavePanel savePanel];
|
|
| 614 | + |
|
| 615 | + returnCode = [sPanel runModal];
|
|
| 616 | + |
|
| 617 | + ModalFinishedCallback(sPanel, returnCode);
|
|
| 618 | + }
|
|
| 619 | + else
|
|
| 620 | + {
|
|
| 621 | + NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
|
| 622 | + |
|
| 703 | 623 | returnCode = [oPanel runModal];
|
| 704 | 624 | |
| 705 | 625 | ModalFinishedCallback(oPanel, returnCode);
|
| ... | ... | @@ -55,11 +55,11 @@ wxString ConcatenateDataViewItemValues(wxDataViewCtrl const* dataViewCtrlPtr, wx |
| 55 | 55 | |
| 56 | 56 | struct wxOSXDVCDeleting
|
| 57 | 57 | {
|
| 58 | - explicit wxOSXDVCDeleting(const wxDataViewItem& parent) : m_parent(parent)
|
|
| 58 | + explicit wxOSXDVCDeleting(const wxDataViewItem& item) : m_item(item)
|
|
| 59 | 59 | {
|
| 60 | 60 | }
|
| 61 | 61 | |
| 62 | - const wxDataViewItem m_parent;
|
|
| 62 | + const wxDataViewItem m_item;
|
|
| 63 | 63 | |
| 64 | 64 | wxDECLARE_NO_COPY_CLASS(wxOSXDVCDeleting);
|
| 65 | 65 | };
|
| ... | ... | @@ -68,11 +68,11 @@ struct wxOSXDVCDeleting |
| 68 | 68 | class wxOSXDVCScopedDeleter
|
| 69 | 69 | {
|
| 70 | 70 | public:
|
| 71 | - wxOSXDVCScopedDeleter(wxDataViewCtrl* dvc, const wxDataViewItem& parent) :
|
|
| 71 | + wxOSXDVCScopedDeleter(wxDataViewCtrl* dvc, const wxDataViewItem& item) :
|
|
| 72 | 72 | m_dvc(dvc),
|
| 73 | 73 | m_valueOrig(m_dvc->m_Deleting)
|
| 74 | 74 | {
|
| 75 | - m_dvc->m_Deleting = new wxOSXDVCDeleting(parent);
|
|
| 75 | + m_dvc->m_Deleting = new wxOSXDVCDeleting(item);
|
|
| 76 | 76 | }
|
| 77 | 77 | |
| 78 | 78 | ~wxOSXDVCScopedDeleter()
|
| ... | ... | @@ -236,7 +236,7 @@ bool wxOSXDataViewModelNotifier::ItemDeleted(wxDataViewItem const& parent, wxDat |
| 236 | 236 | // not to be identical because the being edited item might be below the passed item in the hierarchy);
|
| 237 | 237 | // to prevent the control trying to ask the model to update an already deleted item the control is informed that currently a deleting process
|
| 238 | 238 | // has been started and that variables can currently not be updated even when requested by the system:
|
| 239 | - wxOSXDVCScopedDeleter setDeleting(m_DataViewCtrlPtr, parent);
|
|
| 239 | + wxOSXDVCScopedDeleter setDeleting(m_DataViewCtrlPtr, item);
|
|
| 240 | 240 | |
| 241 | 241 | bool ok = m_DataViewCtrlPtr->GetDataViewPeer()->Remove(parent);
|
| 242 | 242 | |
| ... | ... | @@ -429,7 +429,7 @@ bool wxDataViewCtrl::IsClearing() const |
| 429 | 429 | {
|
| 430 | 430 | // We only set the item being deleted to an invalid item when we're
|
| 431 | 431 | // clearing the entire model.
|
| 432 | - return m_Deleting != nullptr && !m_Deleting->m_parent.IsOk();
|
|
| 432 | + return m_Deleting != nullptr && !m_Deleting->m_item.IsOk();
|
|
| 433 | 433 | }
|
| 434 | 434 | |
| 435 | 435 | bool wxDataViewCtrl::Create(wxWindow *parent,
|
| ... | ... | @@ -113,38 +113,35 @@ int wxCMPFUNC_CONV StringLenCompare(const wxString& first, |
| 113 | 113 | return first.length() - second.length();
|
| 114 | 114 | }
|
| 115 | 115 | |
| 116 | -#define DEFINE_COMPARE(name, T) \
|
|
| 117 | - \
|
|
| 118 | -int wxCMPFUNC_CONV name ## CompareValues(T first, T second) \
|
|
| 119 | -{ \
|
|
| 120 | - return first - second; \
|
|
| 121 | -} \
|
|
| 122 | - \
|
|
| 123 | -int wxCMPFUNC_CONV name ## Compare(T* first, T* second) \
|
|
| 124 | -{ \
|
|
| 125 | - return *first - *second; \
|
|
| 126 | -} \
|
|
| 127 | - \
|
|
| 128 | -int wxCMPFUNC_CONV name ## RevCompare(T* first, T* second) \
|
|
| 129 | -{ \
|
|
| 130 | - return *second - *first; \
|
|
| 131 | -} \
|
|
| 116 | +template <typename T>
|
|
| 117 | +int wxCMPFUNC_CONV CompareValues(T first, T second)
|
|
| 118 | +{
|
|
| 119 | + return first - second;
|
|
| 120 | +}
|
|
| 132 | 121 | |
| 133 | -typedef unsigned short ushort;
|
|
| 122 | +template <typename T>
|
|
| 123 | +int wxCMPFUNC_CONV Compare(T* first, T* second)
|
|
| 124 | +{
|
|
| 125 | + return *first - *second;
|
|
| 126 | +}
|
|
| 134 | 127 | |
| 135 | -DEFINE_COMPARE(Char, char)
|
|
| 136 | -DEFINE_COMPARE(UShort, ushort)
|
|
| 137 | -DEFINE_COMPARE(Int, int)
|
|
| 128 | +template <typename T>
|
|
| 129 | +int wxCMPFUNC_CONV RevCompare(T* first, T* second)
|
|
| 130 | +{
|
|
| 131 | + return *second - *first;
|
|
| 132 | +}
|
|
| 133 | + |
|
| 134 | +typedef unsigned short ushort;
|
|
| 138 | 135 | |
| 139 | 136 | WX_DEFINE_ARRAY_CHAR(char, wxArrayChar);
|
| 140 | 137 | WX_DEFINE_SORTED_ARRAY_CHAR(char, wxSortedArrayCharNoCmp);
|
| 141 | -WX_DEFINE_SORTED_ARRAY_CMP_CHAR(char, CharCompareValues, wxSortedArrayChar);
|
|
| 138 | +WX_DEFINE_SORTED_ARRAY_CMP_CHAR(char, CompareValues<char>, wxSortedArrayChar);
|
|
| 142 | 139 | |
| 143 | 140 | WX_DEFINE_ARRAY_SHORT(ushort, wxArrayUShort);
|
| 144 | 141 | WX_DEFINE_SORTED_ARRAY_SHORT(ushort, wxSortedArrayUShortNoCmp);
|
| 145 | -WX_DEFINE_SORTED_ARRAY_CMP_SHORT(ushort, UShortCompareValues, wxSortedArrayUShort);
|
|
| 142 | +WX_DEFINE_SORTED_ARRAY_CMP_SHORT(ushort, CompareValues<ushort>, wxSortedArrayUShort);
|
|
| 146 | 143 | |
| 147 | -WX_DEFINE_SORTED_ARRAY_CMP_INT(int, IntCompareValues, wxSortedArrayInt);
|
|
| 144 | +WX_DEFINE_SORTED_ARRAY_CMP_INT(int, CompareValues<int>, wxSortedArrayInt);
|
|
| 148 | 145 | |
| 149 | 146 | struct Item
|
| 150 | 147 | {
|
| ... | ... | @@ -324,6 +321,11 @@ TEST_CASE("wxArrayString", "[dynarray]") |
| 324 | 321 | CHECK( a5.size() == 3 );
|
| 325 | 322 | CHECK( a5[2] == "Foo" );
|
| 326 | 323 | |
| 324 | + // This is undefined behaviour but because the array has just been resized
|
|
| 325 | + // down, its memory hopefully hasn't been reallocated yet, so we shouldn't
|
|
| 326 | + // crash accessing it. But we must assert due to the index being invalid.
|
|
| 327 | + WX_ASSERT_FAILS_WITH_ASSERT( a5[3].clear() );
|
|
| 328 | + |
|
| 327 | 329 | wxArrayString a6;
|
| 328 | 330 | a6.Add("Foo");
|
| 329 | 331 | a6.Insert(a6[0], 1, 100);
|
| ... | ... | @@ -649,44 +651,50 @@ TEST_CASE("wxObjArrayPtr", "[dynarray]") |
| 649 | 651 | \
|
| 650 | 652 | TEST_CASE("wxDynArray::" #name, "[dynarray]") \
|
| 651 | 653 | { \
|
| 652 | - wxArray##name a; \
|
|
| 653 | - a.Add(1); \
|
|
| 654 | - a.Add(17,2); \
|
|
| 655 | - a.Add(5,3); \
|
|
| 656 | - a.Add(3,4); \
|
|
| 657 | - \
|
|
| 658 | - CHECK((COMPARE_10_VALUES(a,1,17,17,5,5,5,3,3,3,3))); \
|
|
| 659 | - CHECK( COMPARE_COUNT( a , 10 ) ); \
|
|
| 660 | - \
|
|
| 661 | - a.Sort(name ## Compare); \
|
|
| 662 | - \
|
|
| 663 | - CHECK((COMPARE_10_VALUES(a,1,3,3,3,3,5,5,5,17,17))); \
|
|
| 664 | - CHECK( COMPARE_COUNT( a , 10 ) ); \
|
|
| 665 | - \
|
|
| 666 | - a.Sort(name ## RevCompare); \
|
|
| 667 | - \
|
|
| 668 | - CHECK((COMPARE_10_VALUES(a,17,17,5,5,5,3,3,3,3,1))); \
|
|
| 669 | - CHECK( COMPARE_COUNT( a , 10 ) ); \
|
|
| 670 | - \
|
|
| 671 | - wxSortedArray##name b; \
|
|
| 672 | - \
|
|
| 673 | - b.Add(1); \
|
|
| 674 | - b.Add(17); \
|
|
| 675 | - b.Add(5); \
|
|
| 676 | - b.Add(3); \
|
|
| 677 | - \
|
|
| 678 | - CHECK((COMPARE_4_VALUES(b,1,3,5,17))); \
|
|
| 679 | - CHECK( COMPARE_COUNT( b , 4 ) ); \
|
|
| 680 | - CHECK( b.Index( 0 ) == wxNOT_FOUND ); \
|
|
| 681 | - CHECK( b.Index( 1 ) == 0 ); \
|
|
| 682 | - CHECK( b.Index( 3 ) == 1 ); \
|
|
| 683 | - CHECK( b.Index( 4 ) == wxNOT_FOUND ); \
|
|
| 684 | - CHECK( b.Index( 5 ) == 2 ); \
|
|
| 685 | - CHECK( b.Index( 6 ) == wxNOT_FOUND ); \
|
|
| 686 | - CHECK( b.Index( 17 ) == 3 ); \
|
|
| 687 | - \
|
|
| 688 | - wxArray##name c({1,2,3}); \
|
|
| 689 | - CHECK(c.size() == 3); \
|
|
| 654 | + DoTest<wxArray##name, wxSortedArray##name>(); \
|
|
| 655 | +}
|
|
| 656 | + |
|
| 657 | +template <typename wxArrayT, typename wxSortedArrayT>
|
|
| 658 | +void DoTest()
|
|
| 659 | +{
|
|
| 660 | + wxArrayT a;
|
|
| 661 | + a.Add(1);
|
|
| 662 | + a.Add(17,2);
|
|
| 663 | + a.Add(5,3);
|
|
| 664 | + a.Add(3,4);
|
|
| 665 | + |
|
| 666 | + CHECK((COMPARE_10_VALUES(a,1,17,17,5,5,5,3,3,3,3)));
|
|
| 667 | + CHECK( COMPARE_COUNT( a , 10 ) );
|
|
| 668 | + |
|
| 669 | + a.Sort(Compare<typename wxArrayT::value_type>);
|
|
| 670 | + |
|
| 671 | + CHECK((COMPARE_10_VALUES(a,1,3,3,3,3,5,5,5,17,17)));
|
|
| 672 | + CHECK( COMPARE_COUNT( a , 10 ) );
|
|
| 673 | + |
|
| 674 | + a.Sort(RevCompare<typename wxArrayT::value_type>);
|
|
| 675 | + |
|
| 676 | + CHECK((COMPARE_10_VALUES(a,17,17,5,5,5,3,3,3,3,1)));
|
|
| 677 | + CHECK( COMPARE_COUNT( a , 10 ) );
|
|
| 678 | + |
|
| 679 | + wxSortedArrayT b;
|
|
| 680 | + |
|
| 681 | + b.Add(1);
|
|
| 682 | + b.Add(17);
|
|
| 683 | + b.Add(5);
|
|
| 684 | + b.Add(3);
|
|
| 685 | + |
|
| 686 | + CHECK((COMPARE_4_VALUES(b,1,3,5,17)));
|
|
| 687 | + CHECK( COMPARE_COUNT( b , 4 ) );
|
|
| 688 | + CHECK( b.Index( 0 ) == wxNOT_FOUND );
|
|
| 689 | + CHECK( b.Index( 1 ) == 0 );
|
|
| 690 | + CHECK( b.Index( 3 ) == 1 );
|
|
| 691 | + CHECK( b.Index( 4 ) == wxNOT_FOUND );
|
|
| 692 | + CHECK( b.Index( 5 ) == 2 );
|
|
| 693 | + CHECK( b.Index( 6 ) == wxNOT_FOUND );
|
|
| 694 | + CHECK( b.Index( 17 ) == 3 );
|
|
| 695 | + |
|
| 696 | + wxArrayT c({1,2,3});
|
|
| 697 | + CHECK(c.size() == 3);
|
|
| 690 | 698 | }
|
| 691 | 699 | |
| 692 | 700 | TestArrayOf(UShort)
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help