initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/private/addremovectrl.h
// Purpose: OS X specific wxAddRemoveImpl implementation
// Author: Vadim Zeitlin
// Created: 2015-02-05
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_PRIVATE_ADDREMOVECTRL_H_
#define _WX_OSX_PRIVATE_ADDREMOVECTRL_H_
#include "wx/artprov.h"
#include "wx/bmpbuttn.h"
#include "wx/panel.h"
#include "wx/osx/private.h"
// ----------------------------------------------------------------------------
// wxAddRemoveImpl itself
// ----------------------------------------------------------------------------
class wxAddRemoveImpl : public wxAddRemoveImplWithButtons
{
public:
wxAddRemoveImpl(wxAddRemoveAdaptor* adaptor,
wxAddRemoveCtrl* parent,
wxWindow* ctrlItems)
: wxAddRemoveImplWithButtons(adaptor, parent, ctrlItems),
m_ctrlItems(ctrlItems)
{
// This size is hard coded for now as this is what the system dialogs
// themselves (e.g. the buttons under the lists in the "Users" or
// "Network" panes of the "System Preferences") use under OS X 10.8.
const wxSize sizeBtn(25, 23);
m_btnAdd = new wxBitmapButton(parent, wxID_ADD,
wxArtProvider::GetBitmap("NSAddTemplate"),
wxDefaultPosition,
sizeBtn,
wxBORDER_SIMPLE);
m_btnRemove = new wxBitmapButton(parent, wxID_REMOVE,
wxArtProvider::GetBitmap("NSRemoveTemplate"),
wxDefaultPosition,
sizeBtn,
wxBORDER_SIMPLE);
// Under OS X the space to the right of the buttons is actually
// occupied by an inactive gradient button, so create one.
m_btnPlaceholder = new wxButton(parent, wxID_ANY, "",
wxDefaultPosition,
sizeBtn,
wxBORDER_SIMPLE);
m_btnPlaceholder->Disable();
// We need to lay out our windows manually under OS X as it is the only
// way to achieve the required, for the correct look, overlap between
// their borders -- sizers would never allow this.
parent->Bind(wxEVT_SIZE, &wxAddRemoveImpl::OnSize, this);
// We also have to ensure that the window with the items doesn't have
// any border as it wouldn't look correctly if it did.
long style = ctrlItems->GetWindowStyle();
style &= ~wxBORDER_MASK;
style |= wxBORDER_SIMPLE;
ctrlItems->SetWindowStyle(style);
SetUpEvents();
}
// As we don't use sizers, we also need to compute our best size ourselves.
virtual wxSize GetBestClientSize() const override
{
wxSize size = m_ctrlItems->GetBestSize();
const wxSize sizeBtn = m_btnAdd->GetSize();
size.y += sizeBtn.y;
size.IncTo(wxSize(3*sizeBtn.x, -1));
return size;
}
private:
void OnSize(wxSizeEvent& event)
{
const wxSize size = event.GetSize();
const wxSize sizeBtn = m_btnAdd->GetSize();
const int yBtn = size.y - sizeBtn.y;
// There is a vertical overlap which hides the items control bottom
// border.
m_ctrlItems->SetSize(0, 0, size.x, yBtn + 2);
// And there is also a horizontal 1px overlap between the buttons
// themselves, so subtract 1 from the next button position.
int x = 0;
m_btnAdd->Move(x, yBtn);
x += sizeBtn.x - 1;
m_btnRemove->Move(x, yBtn);
x += sizeBtn.x - 1;
// The last one needs to be resized to take up all the remaining space.
m_btnPlaceholder->SetSize(x, yBtn, size.x - x, sizeBtn.y);
}
wxWindow* m_ctrlItems;
wxButton* /* const */ m_btnPlaceholder;
};
#endif // _WX_OSX_PRIVATE_ADDREMOVECTRL_H_

View File

@@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/private/available.h
// Purpose: Helper for checking API availability under macOS.
// Author: Vadim Zeitlin
// Created: 2019-04-17
// Copyright: (c) 2019 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_PRIVATE_AVAILABLE_H_
#define _WX_OSX_PRIVATE_AVAILABLE_H_
// Xcode 9 adds new @available keyword and the corresponding __builtin_available
// builtin which should be used instead of manual checks for API availability
// as using this builtin suppresses the compiler -Wunguarded-availability
// warnings, so use it if possible for the implementation of our own macro.
#if defined(__clang__) && __has_builtin(__builtin_available)
#define WX_IS_MACOS_AVAILABLE(major, minor) \
__builtin_available(macOS major ## . ## minor, *)
#define WX_IS_MACOS_OR_IOS_AVAILABLE(macmajor, macminor, imajor, iminor) \
__builtin_available(macOS macmajor ## . ## macminor, iOS imajor ##. ## iminor, *)
#define WX_IS_MACOS_AVAILABLE_FULL(major, minor, micro) \
__builtin_available(macOS major ## . ## minor ## . ## micro, *)
// Note that we can't easily forward to API_AVAILABLE macro here, so go
// directly to its expansion instead.
#define WX_API_AVAILABLE_MACOS(major, minor) \
__attribute__((availability(macos,introduced=major ## . ## minor)))
#else // Not clang or old clang version without __builtin_available
#include "wx/platinfo.h"
#define WX_IS_MACOS_AVAILABLE(major, minor) \
wxPlatformInfo::Get().CheckOSVersion(major, minor)
#ifdef wxOSX_USE_IPHONE
#define WX_IS_MACOS_OR_IOS_AVAILABLE(macmajor, macminor, imajor, iminor) \
wxPlatformInfo::Get().CheckOSVersion(imajor, iminor)
#else
#define WX_IS_MACOS_OR_IOS_AVAILABLE(macmajor, macminor, imajor, iminor) \
wxPlatformInfo::Get().CheckOSVersion(macmajor, macminor)
#endif
#define WX_IS_MACOS_AVAILABLE_FULL(major, minor, micro) \
wxPlatformInfo::Get().CheckOSVersion(major, minor, micro)
#define WX_API_AVAILABLE_MACOS(major, minor)
#endif
#endif // _WX_OSX_PRIVATE_AVAILABLE_H_

View File

@@ -0,0 +1,113 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/private/datatransfer.h
// Purpose: OS X specific data transfer implementation
// Author: Stefan Csomor
// Created: 2019-03-29
// Copyright: (c) 2019 Stefan Csomor <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_PRIVATE_DATATRANSFER_H_
#define _WX_OSX_PRIVATE_DATATRANSFER_H_
#include "wx/osx/private.h"
#include "wx/osx/dataform.h"
class WXDLLIMPEXP_FWD_CORE wxDataObject;
class WXDLLIMPEXP_CORE wxOSXDataSourceItem
{
public:
virtual ~wxOSXDataSourceItem();
virtual wxDataFormat::NativeFormat AvailableType(CFArrayRef types) const = 0;
virtual bool GetData( const wxDataFormat& dataFormat, wxMemoryBuffer& target) = 0;
virtual bool GetData( wxDataFormat::NativeFormat type, wxMemoryBuffer& target) = 0;
virtual CFDataRef DoGetData(wxDataFormat::NativeFormat type) const = 0;
};
class WXDLLIMPEXP_CORE wxOSXDataSource
{
public:
// the number of source items
virtual size_t GetItemCount() const = 0;
// get source item by index, needs to be deleted after use
virtual const wxOSXDataSourceItem* GetItem(size_t pos) const = 0;
// returns true if there is any data in this source conforming to dataFormat
virtual bool IsSupported(const wxDataFormat &dataFormat);
// returns true if there is any data in this source supported by dataobj
virtual bool IsSupported(const wxDataObject &dataobj);
// returns true if there is any data in this source of types
virtual bool HasData(CFArrayRef types) const = 0;
};
class WXDLLIMPEXP_CORE wxOSXDataSinkItem
{
public:
virtual ~wxOSXDataSinkItem();
virtual void SetFilename(const wxString& filename);
// translating from wx into native representation
virtual void SetData(const wxDataFormat& format, const void *buf, size_t size) = 0;
// translating from wx into native representation
virtual void SetData(wxDataFormat::NativeFormat format, const void *buf, size_t size) = 0;
// native implementation for setting data
virtual void DoSetData(wxDataFormat::NativeFormat format, CFDataRef data) = 0;
};
class WXDLLIMPEXP_CORE wxOSXDataSink
{
public:
// delete all created sink items
virtual void Clear() = 0;
// create a new sink item
virtual wxOSXDataSinkItem* CreateItem() = 0;
// flush the created sink items into the system sink representation
virtual void Flush() = 0 ;
};
class WXDLLIMPEXP_CORE wxOSXPasteboard : public wxOSXDataSink, public wxOSXDataSource
{
public:
wxOSXPasteboard(OSXPasteboard native);
~wxOSXPasteboard();
// sink methods
virtual wxOSXDataSinkItem* CreateItem() override;
void Clear() override;
void Flush() override;
// source methods
virtual size_t GetItemCount() const override;
virtual const wxOSXDataSourceItem* GetItem(size_t pos) const override;
virtual bool HasData(CFArrayRef types) const override;
static wxOSXPasteboard* GetGeneralClipboard();
private:
void DeleteSinkItems();
OSXPasteboard m_pasteboard;
wxVector<wxOSXDataSinkItem*> m_sinkItems;
};
#endif

View File

@@ -0,0 +1 @@
#include "wx/osx/carbon/private/print.h"

View File

@@ -0,0 +1,3 @@
#if 1 // revert to wxOSX_USE_COCOA_OR_IPHONE in case of problems
#include "wx/osx/core/private/timer.h"
#endif

View File

@@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/private/uilocale.h
// Purpose: Helper for making pointer to current NSLocale available
// for locale-dependent controls under macOS.
// Author: Ulrich Telle
// Created: 2023-10-13
// Copyright: (c) 2023 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_PRIVATE_UILOCALE_H_
#define _WX_OSX_PRIVATE_UILOCALE_H_
#if wxUSE_INTL
// Function returning a pointer to the current NSLocale
WXDLLIMPEXP_BASE NSLocale* wxGetCurrentNSLocale();
#endif
#endif // _WX_OSX_PRIVATE_UILOCALE_H_

View File

@@ -0,0 +1,215 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/webrequest_urlsession.h
// Purpose: wxWebRequest implementation using URLSession
// Author: Tobias Taschner
// Created: 2018-10-25
// Copyright: (c) 2018 wxWidgets development team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_WEBREQUEST_URLSESSION_H
#define _WX_OSX_WEBREQUEST_URLSESSION_H
#if wxUSE_WEBREQUEST_URLSESSION
#include "wx/private/webrequest.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSError);
DECLARE_WXCOCOA_OBJC_CLASS(NSURLComponents);
DECLARE_WXCOCOA_OBJC_CLASS(NSURLCredential);
DECLARE_WXCOCOA_OBJC_CLASS(NSURLSession);
DECLARE_WXCOCOA_OBJC_CLASS(NSURLSessionTask);
DECLARE_WXCOCOA_OBJC_CLASS(wxWebSessionDelegate);
class wxWebSessionURLSession;
class wxWebRequestURLSession;
class wxWebResponseURLSession;
class wxWebAuthChallengeURLSession : public wxWebAuthChallengeImpl
{
public:
wxWebAuthChallengeURLSession(wxWebAuthChallenge::Source source,
wxWebRequestURLSession& request)
: wxWebAuthChallengeImpl(source),
m_request(request)
{
}
~wxWebAuthChallengeURLSession();
void SetCredentials(const wxWebCredentials& cred) override;
WX_NSURLCredential GetURLCredential() const { return m_cred; }
private:
wxWebRequestURLSession& m_request;
WX_NSURLCredential m_cred = nullptr;
wxDECLARE_NO_COPY_CLASS(wxWebAuthChallengeURLSession);
};
class wxWebResponseURLSession : public wxWebResponseImpl
{
public:
wxWebResponseURLSession(wxWebRequestURLSession& request, WX_NSURLSessionTask task);
~wxWebResponseURLSession();
wxFileOffset GetContentLength() const override;
wxString GetURL() const override;
wxString GetHeader(const wxString& name) const override;
std::vector<wxString> GetAllHeaderValues(const wxString& name) const override;
int GetStatus() const override;
wxString GetStatusText() const override;
wxString GetSuggestedFileName() const override;
void HandleData(WX_NSData data);
private:
WX_NSURLSessionTask m_task;
wxDECLARE_NO_COPY_CLASS(wxWebResponseURLSession);
};
class wxWebRequestURLSession : public wxWebRequestImpl
{
public:
// Ctor for asynchronous requests.
wxWebRequestURLSession(wxWebSession& session,
wxWebSessionURLSession& sessionImpl,
wxEvtHandler* handler,
const wxString& url,
int winid);
// Ctor for synchronous requests.
wxWebRequestURLSession(wxWebSessionURLSession& sessionImpl,
const wxString& url);
~wxWebRequestURLSession();
Result Execute() override;
void Start() override;
wxWebResponseImplPtr GetResponse() const override
{ return m_response; }
wxWebAuthChallengeImplPtr GetAuthChallenge() const override
{ return m_authChallenge; }
wxFileOffset GetBytesSent() const override;
wxFileOffset GetBytesExpectedToSend() const override;
wxFileOffset GetBytesReceived() const override;
wxFileOffset GetBytesExpectedToReceive() const override;
wxWebRequestHandle GetNativeHandle() const override
{
return (wxWebRequestHandle)m_task;
}
Result GetResultAfterCompletion(WX_NSError error);
void HandleCompletion(WX_NSError error);
void HandleChallenge(wxWebAuthChallengeURLSession* challenge);
void OnSetCredentials(const wxWebCredentials& cred);
wxWebResponseURLSession* GetResponseImplPtr() const
{ return m_response.get(); }
wxWebAuthChallengeURLSession* GetAuthChallengeImplPtr() const
{ return m_authChallenge.get(); }
private:
void DoCancel() override;
// This is a blatant ODR-violation, but there doesn't seem to be any way to
// declare a function taking a block in (non-Objective) C++, so just skip
// its declaration when compiling pure C++ code.
#if defined(__OBJC__)
// Common part of Execute() and Start(), used for both synchronous and
// asynchronous requests, but for the completion handler can only be
// non-nil in the synchronous case.
Result
DoPrepare(void (^completionHandler)(NSData*, NSURLResponse*, NSError*));
#endif // __OBJC__
wxWebSessionURLSession& m_sessionImpl;
wxString m_url;
WX_NSURLSessionTask m_task;
wxObjectDataPtr<wxWebResponseURLSession> m_response;
wxObjectDataPtr<wxWebAuthChallengeURLSession> m_authChallenge;
wxDECLARE_NO_COPY_CLASS(wxWebRequestURLSession);
};
class wxWebSessionURLSession : public wxWebSessionImpl
{
public:
explicit wxWebSessionURLSession(Mode mode);
~wxWebSessionURLSession();
wxWebRequestImplPtr
CreateRequest(wxWebSession& session,
wxEvtHandler* handler,
const wxString& url,
int winid = wxID_ANY) override;
wxWebRequestImplPtr
CreateRequestSync(wxWebSessionSync& session,
const wxString& url) override;
wxVersionInfo GetLibraryVersionInfo() const override;
wxWebSessionHandle GetNativeHandle() const override
{
return (wxWebSessionHandle)m_session;
}
bool SetProxy(const wxWebProxy& proxy) override;
bool EnablePersistentStorage(bool enable) override;
WX_NSURLSession GetSession();
WX_wxWebSessionDelegate GetDelegate() { return m_delegate; }
private:
WX_NSURLSession m_session = nullptr;
WX_wxWebSessionDelegate m_delegate;
#if !wxOSX_USE_IPHONE
WX_NSURLComponents m_proxyURL = nullptr;
#endif // !wxOSX_USE_IPHONE
bool m_persistentStorageEnabled = false;
wxDECLARE_NO_COPY_CLASS(wxWebSessionURLSession);
};
class wxWebSessionFactoryURLSession : public wxWebSessionFactory
{
public:
wxWebSessionImpl* Create() override
{
return new wxWebSessionURLSession(wxWebSessionImpl::Mode::Async);
}
wxWebSessionImpl* CreateSync() override
{
return new wxWebSessionURLSession(wxWebSessionImpl::Mode::Sync);
}
};
#endif // wxUSE_WEBREQUEST_URLSESSION
#endif // _WX_OSX_WEBREQUEST_URLSESSION_H

View File

@@ -0,0 +1,25 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/private/webview_chromium.h
// Purpose: Functions used in wxWebViewChromium Mac implementation
// Author: Vadim Zeitlin
// Created: 2023-09-05
// Copyright: (c) 2023 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_PRIVATE_WEBVIEW_CHROMIUM_H_
#define _WX_OSX_PRIVATE_WEBVIEW_CHROMIUM_H_
wxGCC_WARNING_SUPPRESS(unused-parameter)
#include "include/cef_base.h"
wxGCC_WARNING_RESTORE(unused-parameter)
// Called during startup to add CefAppProtocol support to wxNSApplication.
void wxWebViewChromium_InitOSX();
// Called to resize the given NSView to fit its parent.
void wxWebViewChromium_Resize(cef_window_handle_t handle, wxSize size);
#endif // _WX_OSX_PRIVATE_WEBVIEW_CHROMIUM_H_