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,30 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/accel.h
// Purpose: wxAcceleratorTable class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCEL_H_
#define _WX_ACCEL_H_
#include "wx/string.h"
#include "wx/event.h"
class WXDLLIMPEXP_CORE wxAcceleratorTable: public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wxAcceleratorTable);
public:
wxAcceleratorTable();
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); // Load from array
bool Ok() const { return IsOk(); }
bool IsOk() const;
int GetCommand( wxKeyEvent &event );
};
#endif
// _WX_ACCEL_H_

View File

@@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/activityindicator.h
// Purpose: Declaration of wxActivityIndicator for wxOSX (Cocoa only).
// Author: Vadim Zeitlin
// Created: 2015-03-08
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_ACTIVITYINDICATOR_H_
#define _WX_OSX_ACTIVITYINDICATOR_H_
// ----------------------------------------------------------------------------
// wxActivityIndicator: implementation using GtkSpinner.
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxActivityIndicator : public wxActivityIndicatorBase
{
public:
wxActivityIndicator()
{
Init();
}
explicit
wxActivityIndicator(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxActivityIndicatorNameStr)
{
Init();
Create(parent, winid, pos, size, style, name);
}
bool Create(wxWindow* parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxActivityIndicatorNameStr);
virtual void Start() override;
virtual void Stop() override;
virtual bool IsRunning() const override;
private:
// Common part of all ctors.
void Init() { m_isRunning = false; }
bool m_isRunning;
wxDECLARE_DYNAMIC_CLASS(wxActivityIndicator);
wxDECLARE_NO_COPY_CLASS(wxActivityIndicator);
};
#endif // _WX_OSX_ACTIVITYINDICATOR_H_

View File

@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: anybutton.h
// Purpose: wxAnyButton class
// Author: Stefan Csomor
// Created: 1998-01-01 (extracted from button.h)
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_ANYBUTTON_H_
#define _WX_OSX_ANYBUTTON_H_
// Any button
class WXDLLIMPEXP_CORE wxAnyButton : public wxAnyButtonBase
{
public:
wxAnyButton() = default;
static wxSize GetDefaultSize();
virtual void SetLabel(const wxString& label) override;
protected:
virtual wxSize DoGetBestSize() const override;
void OnEnterWindow( wxMouseEvent& event);
void OnLeaveWindow( wxMouseEvent& event);
virtual wxBitmap DoGetBitmap(State which) const override;
virtual void DoSetBitmap(const wxBitmapBundle& bitmapBundle, State which) override;
virtual void DoSetBitmapPosition(wxDirection dir) override;
virtual void DoSetBitmapMargins(int x, int y) override
{
m_marginX = x;
m_marginY = y;
InvalidateBestSize();
}
#if wxUSE_MARKUP && wxOSX_USE_COCOA
virtual bool DoSetLabelMarkup(const wxString& markup) override;
#endif // wxUSE_MARKUP && wxOSX_USE_COCOA
// the margins around the bitmap
int m_marginX;
int m_marginY;
// the bitmaps for the different state of the buttons, all of them may be
// invalid and the button only shows a bitmap at all if State_Normal bitmap
// is valid
wxBitmapBundle m_bitmaps[State_Max];
wxDECLARE_NO_COPY_CLASS(wxAnyButton);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_OSX_ANYBUTTON_H_

View File

@@ -0,0 +1,178 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/app.h
// Purpose: wxApp class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APP_H_
#define _WX_APP_H_
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/gdicmn.h"
#include "wx/event.h"
class WXDLLIMPEXP_FWD_CORE wxFrame;
class WXDLLIMPEXP_FWD_CORE wxWindowMac;
class WXDLLIMPEXP_FWD_CORE wxApp ;
class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
class WXDLLIMPEXP_FWD_BASE wxLog;
class WXDLLIMPEXP_FWD_CORE wxMacAutoreleasePool;
// Force an exit from main loop
void WXDLLIMPEXP_CORE wxExit();
// Yield to other apps/messages
bool WXDLLIMPEXP_CORE wxYield();
// Represents the application. Derive OnInit and declare
// a new App object to start application
class WXDLLIMPEXP_CORE wxApp: public wxAppBase
{
wxDECLARE_DYNAMIC_CLASS(wxApp);
wxApp();
virtual ~wxApp();
virtual void WakeUpIdle() override;
virtual void SetPrintMode(int mode) override { m_printMode = mode; }
virtual int GetPrintMode() const { return m_printMode; }
virtual AppearanceResult SetAppearance(Appearance appearance) override;
// calling OnInit with an auto-release pool ready ...
virtual bool CallOnInit() override;
#if wxUSE_GUI
// setting up all MacOS Specific Event-Handlers etc
virtual bool OnInitGui() override;
#endif // wxUSE_GUI
virtual int OnRun() override;
virtual bool ProcessIdle() override;
// implementation only
void OnIdle(wxIdleEvent& event);
void OnEndSession(wxCloseEvent& event);
void OnQueryEndSession(wxCloseEvent& event);
protected:
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
wxMacAutoreleasePool* m_macPool;
public:
static bool sm_isEmbedded;
// Implementation
virtual bool Initialize(int& argc, wxChar **argv) override;
virtual void CleanUp() override;
// the installed application event handler
WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
void MacSetCurrentEvent( WXEVENTREF event , WXEVENTHANDLERCALLREF handler )
{ m_macCurrentEvent = event ; m_macCurrentEventHandlerCallRef = handler ; }
// adding a CFType object to be released only at the end of the current event cycle (increases the
// refcount of the object passed), needed in case we are in the middle of an event concerning an object
// we want to delete and cannot do it immediately
// TODO change semantics to be in line with cocoa (make autrelease NOT increase the count)
void MacAddToAutorelease( void* cfrefobj );
void MacReleaseAutoreleasePool();
public:
static wxWindow* s_captureWindow ;
static long s_lastModifiers ;
int m_nCmdShow;
// mac specifics
protected:
#if wxOSX_USE_COCOA
// override for support of custom app controllers
virtual WX_NSObject OSXCreateAppController();
#endif
private:
virtual bool DoInitGui();
virtual void DoCleanUp();
WXEVENTHANDLERREF m_macEventHandler ;
WXEVENTHANDLERCALLREF m_macCurrentEventHandlerCallRef ;
WXEVENTREF m_macCurrentEvent ;
public:
static long s_macAboutMenuItemId ;
static long s_macPreferencesMenuItemId ;
static long s_macExitMenuItemId ;
static wxString s_macHelpMenuTitleName ;
static wxString s_macWindowMenuTitleName ;
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
// For embedded use. By default does nothing.
virtual void MacHandleUnhandledEvent( WXEVENTREF ev );
bool MacSendKeyDownEvent( wxWindow* focus , long keyval , long modifiers , long when , wxChar uniChar ) ;
bool MacSendKeyUpEvent( wxWindow* focus , long keyval , long modifiers , long when , wxChar uniChar ) ;
bool MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers , long when , wxChar uniChar ) ;
void MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymessage , long modifiers , long when , wxChar uniChar ) ;
// in response of an openFiles message with Cocoa and an
// open-document apple event
virtual void MacOpenFiles(const wxArrayString &fileNames) ;
// called by MacOpenFiles for each file.
virtual void MacOpenFile(const wxString &fileName) ;
// in response of a get-url apple event
virtual void MacOpenURL(const wxString &url) ;
// in response of a print-document apple event
virtual void MacPrintFiles(const wxArrayString &fileNames) ;
// called by MacPrintFiles for each file
virtual void MacPrintFile(const wxString &fileName) ;
// in response of an open-application apple event
virtual void MacNewFile() ;
// in response of a reopen-application apple event
virtual void MacReopenApp() ;
// override this to return false from a non-bundled console app in order to stay in background ...
virtual bool OSXIsGUIApplication() { return true; }
// Allow the user to disable the tab bar support in the application
void OSXEnableAutomaticTabbing(bool enable);
#if wxOSX_USE_COCOA_OR_IPHONE
// immediately before the native event loop launches
virtual void OSXOnWillFinishLaunching();
// immediately when the native event loop starts, no events have been served yet
virtual void OSXOnDidFinishLaunching();
// OS asks to terminate app, return no to stay running
virtual bool OSXOnShouldTerminate();
// before application terminates
virtual void OSXOnWillTerminate();
private:
bool m_onInitResult;
bool m_inited;
wxArrayString m_openFiles;
wxArrayString m_printFiles;
wxString m_getURL;
public:
bool OSXInitWasCalled() { return m_inited; }
void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; }
void OSXStorePrintFiles(const wxArrayString &files ) { m_printFiles = files ; }
void OSXStoreOpenURL(const wxString &url ) { m_getURL = url ; }
#endif
// Hide the application windows the same as the system hide command would do it.
void MacHideApp();
wxDECLARE_EVENT_TABLE();
};
#endif
// _WX_APP_H_

View File

@@ -0,0 +1,36 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/appprogress.h
// Purpose: wxAppProgressIndicator OS X implementation
// Author: Tobias Taschner
// Created: 2014-10-22
// Copyright: (c) 2014 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_APPPROG_H_
#define _WX_OSX_APPPROG_H_
#include "wx/window.h"
class WXDLLIMPEXP_CORE wxAppProgressIndicator
: public wxAppProgressIndicatorBase
{
public:
wxAppProgressIndicator(wxWindow* parent = nullptr, int maxValue = 100);
virtual ~wxAppProgressIndicator();
virtual bool IsAvailable() const override;
virtual void SetValue(int value) override;
virtual void SetRange(int range) override;
virtual void Pulse() override;
virtual void Reset() override;
private:
int m_maxValue;
void *m_dockIcon;
wxDECLARE_NO_COPY_CLASS(wxAppProgressIndicator);
};
#endif // _WX_OSX_APPPROG_H_

View File

@@ -0,0 +1,239 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/bitmap.h
// Purpose: wxBitmap class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BITMAP_H_
#define _WX_BITMAP_H_
#include "wx/palette.h"
// Bitmap
class wxBitmapRefData ;
// A mask is a bitmap used for drawing bitmaps
// Internally it is stored as a 8 bit deep memory chunk, 0 = black means the source will be drawn
// 255 = white means the source will not be drawn, no other values will be present
// 8 bit is chosen only for performance reasons, note also that this is the inverse value range
// from alpha, where 0 = invisible , 255 = fully drawn
class WXDLLIMPEXP_CORE wxMask: public wxMaskBase
{
wxDECLARE_DYNAMIC_CLASS(wxMask);
public:
wxMask();
// Copy constructor
wxMask(const wxMask& mask);
// Construct a mask from a bitmap and a colour indicating
// the transparent area
wxMask(const wxBitmap& bitmap, const wxColour& colour);
// Construct a mask from a mono bitmap (black meaning show pixels, white meaning transparent)
wxMask(const wxBitmap& bitmap);
virtual ~wxMask();
wxBitmap GetBitmap() const;
// Implementation below
void Init() ;
// a 8 bit depth mask
void* GetRawAccess() const;
int GetBytesPerRow() const;
int GetWidth() const;
int GetHeight() const;
// renders/updates native representation when necessary
void RealizeNative() ;
WXHBITMAP GetHBITMAP() const ;
// implementation helper only : construct a mask from a 8 bpp memory buffer
bool OSXCreate(const wxMemoryBuffer& buf, int width , int height , int bytesPerRow ) ;
protected:
// this function is called from Create() to free the existing mask data
virtual void FreeData() override;
// these functions must be overridden to implement the corresponding public
// Create() methods, they shouldn't call FreeData() as it's already called
// by the public wrappers
virtual bool InitFromColour(const wxBitmap& bitmap,
const wxColour& colour) override;
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) override;
private:
void DoCreateMaskBitmap(int width, int height, int bytesPerRow = -1);
wxCFRef<CGContextRef> m_maskBitmap ;
};
class WXDLLIMPEXP_CORE wxBitmap: public wxBitmapBase
{
wxDECLARE_DYNAMIC_CLASS(wxBitmap);
friend class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
public:
wxBitmap() = default; // Platform-specific
// Initialize with raw data.
wxBitmap(const char bits[], int width, int height, int depth = 1);
// Initialize with XPM data
wxBitmap(const char* const* bits);
// Load a file or resource
wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
// Constructor for generalised creation from data
wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1);
// creates an bitmap from the native image format
wxBitmap(CGImageRef image, double scale = 1.0);
wxBitmap(WXImage image);
wxBitmap(CGContextRef bitmapcontext);
// Create a bitmap compatible with the given DC
wxBitmap(int width, int height, const wxDC& dc);
// If depth is omitted, will create a bitmap compatible with the display
wxBitmap(int width, int height, int depth = -1) { (void)Create(width, height, depth); }
wxBitmap(const wxSize& sz, int depth = -1) { (void)Create(sz, depth); }
// Convert from wxImage:
wxBitmap(const wxImage& image, int depth = -1, double scale = 1.0);
wxBitmap(const wxImage& image, const wxDC& dc);
// Convert from wxIcon
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
#if wxOSX_USE_COCOA
// Convert from wxCursor
wxBitmap(const wxCursor &cursor);
#endif
wxImage ConvertToImage() const override;
// get the given part of bitmap
wxBitmap GetSubBitmap( const wxRect& rect ) const override;
bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) final;
bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) final
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
bool Create( CGImageRef image, double scale = 1.0 );
bool Create( WXImage image );
bool Create( CGContextRef bitmapcontext);
// Create a bitmap compatible with the given DC, inheriting its magnification factor
bool Create(int width, int height, const wxDC& dc);
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE) override;
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = nullptr) const override;
const wxBitmapRefData *GetBitmapData() const
{ return (const wxBitmapRefData *)m_refData; }
wxBitmapRefData *GetBitmapData()
{ return (wxBitmapRefData *)m_refData; }
int GetWidth() const override;
int GetHeight() const override;
int GetDepth() const override;
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetWidth(int width) override;
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetHeight(int height) override;
wxDEPRECATED_MSG("this value is determined during creation, this method could lead to inconsistencies")
void SetDepth(int depth) override;
#endif
#if wxUSE_PALETTE
wxPalette* GetPalette() const override;
void SetPalette(const wxPalette& palette) override;
#endif // wxUSE_PALETTE
wxMask *GetMask() const override;
void SetMask(wxMask *mask) override;
static void InitStandardHandlers();
// raw bitmap access support functions, for internal use only
void *GetRawData(wxPixelDataBase& data, int bpp);
void UngetRawData(wxPixelDataBase& data);
bool HasAlpha() const override;
bool UseAlpha(bool use = true) override;
// returns the 'native' implementation, a GWorldPtr for the content and one for the mask
WXHBITMAP GetHBITMAP( WXHBITMAP * mask = nullptr ) const;
// returns a CGImageRef which must released after usage with CGImageRelease
CGImageRef CreateCGImage() const ;
// returns nil for invalid bitmap
WXImage OSXGetImage() const;
#if wxOSX_USE_COCOA
// returns an autoreleased version of the image
WX_NSImage GetNSImage() const
{ return OSXGetImage(); }
#endif
#if wxOSX_USE_IPHONE
// returns an autoreleased version of the image
WX_UIImage GetUIImage() const
{ return OSXGetImage(); }
#endif
#if WXWIN_COMPATIBILITY_3_0
#if wxOSX_USE_ICONREF
// returns a IconRef which must be retained before and released after usage
wxDEPRECATED_MSG("IconRefs are deprecated, this will be removed in the future")
IconRef GetIconRef() const;
// returns a IconRef which must be released after usage
wxDEPRECATED_MSG("IconRefs are deprecated, this will be removed in the future")
IconRef CreateIconRef() const;
#endif
// get read only access to the underlying buffer
wxDEPRECATED_MSG("use GetRawData for accessing the buffer")
const void *GetRawAccess() const;
// brackets to the underlying OS structure for read/write access
// makes sure that no cached images will be constructed until terminated
wxDEPRECATED_MSG("use GetRawData for accessing the buffer")
void *BeginRawAccess();
wxDEPRECATED_MSG("use GetRawData for accessing the buffer")
void EndRawAccess();
#endif
void SetScaleFactor(double scale) override;
double GetScaleFactor() const override;
void SetSelectedInto(wxDC *dc);
wxDC *GetSelectedInto() const;
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
virtual bool DoCreate(const wxSize& sz, double scale, int depth) override;
private:
void InitFromImage(const wxImage& image, int depth, double scale);
};
#endif // _WX_BITMAP_H_

View File

@@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/bmpbuttn.h
// Purpose: wxBitmapButton class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_BMPBUTTN_H_
#define _WX_OSX_BMPBUTTN_H_
#include "wx/button.h"
#define wxDEFAULT_BUTTON_MARGIN 4
class WXDLLIMPEXP_CORE wxBitmapButton : public wxBitmapButtonBase
{
public:
wxBitmapButton()
{
}
wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmapBundle& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr))
{
Create(parent, id, bitmap, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxBitmapBundle& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr));
bool CreateCloseButton(wxWindow* parent,
wxWindowID winid,
const wxString& name = wxString());
protected:
virtual wxSize DoGetBestSize() const override;
wxDECLARE_DYNAMIC_CLASS(wxBitmapButton);
};
#endif // _WX_OSX_BMPBUTTN_H_

View File

@@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/brush.h
// Purpose: wxBrush class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BRUSH_H_
#define _WX_BRUSH_H_
#include "wx/gdicmn.h"
#include "wx/gdiobj.h"
#include "wx/bitmap.h"
class WXDLLIMPEXP_FWD_CORE wxBrush;
// Brush
class WXDLLIMPEXP_CORE wxBrush: public wxBrushBase
{
public:
wxBrush();
wxBrush(const wxColour& col, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
wxBrush(const wxBitmap& stipple);
virtual void SetColour(const wxColour& col) override;
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) override;
virtual void SetStyle(wxBrushStyle style) override;
virtual void SetStipple(const wxBitmap& stipple) override;
bool operator==(const wxBrush& brush) const;
bool operator!=(const wxBrush& brush) const { return !(*this == brush); }
wxColour GetColour() const override;
wxBrushStyle GetStyle() const override;
wxBitmap *GetStipple() const override;
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants")
wxBrush(const wxColour& col, int style);
wxDEPRECATED_MSG("use wxBRUSHSTYLE_XXX constants")
void SetStyle(int style) { SetStyle((wxBrushStyle)style); }
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
wxDECLARE_DYNAMIC_CLASS(wxBrush);
};
#endif // _WX_BRUSH_H_

View File

@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/button.h
// Purpose: wxButton class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_BUTTON_H_
#define _WX_OSX_BUTTON_H_
#include "wx/control.h"
#include "wx/gdicmn.h"
// Pushbutton
class WXDLLIMPEXP_CORE wxButton : public wxButtonBase
{
public:
wxButton() = default;
wxButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr))
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxButtonNameStr));
virtual void SetLabel(const wxString& label) override;
virtual wxWindow *SetDefault() override;
virtual void Command(wxCommandEvent& event) override;
// osx specific event handling common for all osx-ports
virtual bool OSXHandleClicked(double timestampsec) override;
#if wxOSX_USE_COCOA
void OSXUpdateAfterLabelChange(const wxString& label);
#endif
protected:
wxDECLARE_DYNAMIC_CLASS(wxButton);
};
#endif // _WX_OSX_BUTTON_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/carbon/private/print.h
// Purpose: private implementation for printing on OS X
// Author: Stefan Csomor
// Created: 03/02/99
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_PRIVATE_PRINT_H_
#define _WX_MAC_PRIVATE_PRINT_H_
#include "wx/cmndata.h"
#include "wx/print.h"
// for PrintingManager
#include "ApplicationServices/ApplicationServices.h"
class WXDLLIMPEXP_CORE wxOSXPrintData : public wxPrintNativeDataBase
{
public:
wxOSXPrintData();
virtual ~wxOSXPrintData();
virtual bool TransferTo( wxPrintData &data ) override;
virtual bool TransferFrom( const wxPrintData &data ) override;
virtual bool IsOk() const override;
virtual void TransferFrom( const wxPageSetupDialogData * ) override;
virtual void TransferTo( wxPageSetupDialogData * ) override;
virtual void TransferFrom( const wxPrintDialogData * );
virtual void TransferTo( wxPrintDialogData * );
PMPrintSession GetPrintSession() { return m_macPrintSession; }
PMPageFormat GetPageFormat() { return m_macPageFormat; }
PMPrintSettings GetPrintSettings() { return m_macPrintSettings; }
protected :
virtual void TransferPrinterNameFrom( const wxPrintData &data );
virtual void TransferPaperInfoFrom( const wxPrintData &data );
virtual void TransferResolutionFrom( const wxPrintData &data );
virtual void TransferPrinterNameTo( wxPrintData &data );
virtual void TransferPaperInfoTo( wxPrintData &data );
virtual void TransferResolutionTo( wxPrintData &data );
virtual void UpdateFromPMState();
virtual void UpdateToPMState();
PMPrintSession m_macPrintSession ;
PMPageFormat m_macPageFormat ;
PMPrintSettings m_macPrintSettings ;
PMPaper m_macPaper;
private:
wxDECLARE_DYNAMIC_CLASS(wxOSXPrintData);
} ;
WXDLLIMPEXP_CORE wxPrintNativeDataBase* wxOSXCreatePrintData();
#if wxOSX_USE_COCOA
class WXDLLIMPEXP_CORE wxOSXCocoaPrintData : public wxOSXPrintData
{
public:
wxOSXCocoaPrintData();
virtual ~wxOSXCocoaPrintData();
WX_NSPrintInfo GetNSPrintInfo() { return m_macPrintInfo; }
protected:
virtual void UpdateFromPMState() override;
virtual void UpdateToPMState() override;
WX_NSPrintInfo m_macPrintInfo;
private:
wxDECLARE_DYNAMIC_CLASS(wxOSXCocoaPrintData);
} ;
#endif
#endif // _WX_MAC_PRIVATE_PRINT_H_

View File

@@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/carbon/region.h
// Purpose: wxRegion class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_CARBON_REGION_H_
#define _WX_MAC_CARBON_REGION_H_
#include "wx/list.h"
class WXDLLIMPEXP_CORE wxRegion : public wxRegionWithCombine
{
public:
wxRegion() = default;
wxRegion(long x, long y, long w, long h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect);
wxRegion( WXHRGN hRegion );
wxRegion(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle = wxODDEVEN_RULE );
#if wxUSE_IMAGE
wxRegion(const wxBitmap& bmp)
{
Union(bmp);
}
wxRegion(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0)
{
Union(bmp, transColour, tolerance);
}
#endif
virtual ~wxRegion();
// wxRegionBase methods
virtual void Clear() override;
virtual bool IsEmpty() const override;
// Internal
WXHRGN GetWXHRGN() const ;
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
virtual bool DoIsEqual(const wxRegion& region) const override;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const override;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const override;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const override;
virtual bool DoOffset(wxCoord x, wxCoord y) override;
virtual bool DoCombine(const wxRegion& region, wxRegionOp op) override;
virtual bool DoUnionWithRect(const wxRect& rect) override;
private:
wxDECLARE_DYNAMIC_CLASS(wxRegion);
friend class WXDLLIMPEXP_FWD_CORE wxRegionIterator;
};
class WXDLLIMPEXP_CORE wxRegionIterator : public wxObject
{
public:
wxRegionIterator();
wxRegionIterator(const wxRegion& region);
wxRegionIterator(const wxRegionIterator& iterator);
virtual ~wxRegionIterator();
wxRegionIterator& operator=(const wxRegionIterator& iterator);
void Reset() { m_current = 0; }
void Reset(const wxRegion& region);
operator bool () const { return m_current < m_numRects; }
bool HaveRects() const { return m_current < m_numRects; }
wxRegionIterator& operator++();
wxRegionIterator operator++(int);
long GetX() const;
long GetY() const;
long GetW() const;
long GetWidth() const { return GetW(); }
long GetH() const;
long GetHeight() const { return GetH(); }
wxRect GetRect() const { return wxRect((int)GetX(), (int)GetY(), (int)GetWidth(), (int)GetHeight()); }
private:
void SetRects(long numRects, wxRect *rects);
long m_current;
long m_numRects;
wxRegion m_region;
wxRect* m_rects;
wxDECLARE_DYNAMIC_CLASS(wxRegionIterator);
};
#endif // _WX_MAC_CARBON_REGION_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/checkbox.h
// Purpose: wxCheckBox class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKBOX_H_
#define _WX_CHECKBOX_H_
// Checkbox item (single checkbox)
class WXDLLIMPEXP_CORE wxCheckBox : public wxCheckBoxBase
{
public:
wxCheckBox() = default;
wxCheckBox(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCheckBoxNameStr))
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCheckBoxNameStr));
virtual void SetValue(bool) override;
virtual bool GetValue() const override;
virtual void Command(wxCommandEvent& event) override;
// osx specific event handling common for all osx-ports
virtual bool OSXHandleClicked( double timestampsec ) override;
protected:
void DoSet3StateValue(wxCheckBoxState val) override;
virtual wxCheckBoxState DoGet3StateValue() const override;
wxDECLARE_DYNAMIC_CLASS(wxCheckBox);
};
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_CORE wxBitmapCheckBox: public wxCheckBox
{
public:
int checkWidth;
int checkHeight;
wxBitmapCheckBox()
: checkWidth(-1), checkHeight(-1)
{ }
wxBitmapCheckBox(wxWindow *parent, wxWindowID id, const wxBitmap *label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCheckBoxNameStr))
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxBitmap *bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxCheckBoxNameStr));
virtual void SetValue(bool) override;
virtual bool GetValue() const override;
virtual void SetLabel(const wxBitmap *bitmap);
virtual void SetLabel( const wxString & WXUNUSED(name) ) override {}
wxDECLARE_DYNAMIC_CLASS(wxBitmapCheckBox);
};
#endif
// _WX_CHECKBOX_H_

View File

@@ -0,0 +1,92 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/checklst.h
// Purpose: wxCheckListBox class - a listbox with checkable items
// Note: this is an optional class.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_CHECKLST_H_
#define _WX_MAC_CHECKLST_H_
class WXDLLIMPEXP_CORE wxCheckListBox : public wxCheckListBoxBase
{
public:
// ctors
wxCheckListBox() { Init(); }
wxCheckListBox(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int nStrings = 0,
const wxString *choices = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr))
{
Init();
Create(parent, id, pos, size, nStrings, choices, style, validator, name);
}
wxCheckListBox(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr))
{
Init();
Create(parent, id, pos, size, choices, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int nStrings = 0,
const wxString *choices = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr));
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr));
// items may be checked
bool IsChecked(unsigned int uiIndex) const override;
void Check(unsigned int uiIndex, bool bCheck = true) override;
// data callbacks
virtual void GetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value ) override;
virtual void SetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value ) override;
protected:
// override all methods which add/delete items to update m_checks array as
// well
virtual void OnItemInserted(unsigned int pos) override;
virtual void DoDeleteOneItem(unsigned int n) override;
virtual void DoClear() override;
// the array containing the checked status of the items
wxArrayInt m_checks;
wxListWidgetColumn* m_checkColumn ;
void Init();
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxCheckListBox);
};
#endif // _WX_MAC_CHECKLST_H_

View File

@@ -0,0 +1,81 @@
/*
* Name: wx/osx/chkconf.h
* Purpose: Mac-specific config settings checks
* Author: Vadim Zeitlin
* Modified by:
* Created: 2005-04-05 (extracted from wx/chkconf.h)
* Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwidgets.org>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_OSX_CHKCONF_H_
#define _WX_OSX_CHKCONF_H_
/*
* check graphics context option, must be on for every os x platform
* we only use core graphics now on all builds, try to catch attempts
* to configure the build otherwise and give error messages
*/
#if wxUSE_GUI && (!wxUSE_GRAPHICS_CONTEXT || \
( defined( wxMAC_USE_CORE_GRAPHICS ) && !wxMAC_USE_CORE_GRAPHICS ))
# error "OS X builds use CoreGraphics in this wx version, you cannot turn back to QuickDraw completely"
#endif
/*
* using mixins of cocoa functionality
*/
#ifdef __WXOSX_COCOA__
#define wxOSX_USE_COCOA 1
#else
#define wxOSX_USE_COCOA 0
#endif
#ifdef __WXOSX_CARBON__
#define wxOSX_USE_CARBON 1
#else
#define wxOSX_USE_CARBON 0
#endif
#ifdef __WXOSX_IPHONE__
#define wxOSX_USE_IPHONE 1
#else
#define wxOSX_USE_IPHONE 0
#endif
/*
* platform check
*/
#ifndef __LP64__
#if wxOSX_USE_COCOA
#error "wxOSX/Cocoa requires building in 64 bits"
#endif
#endif
/*
* combination flags
*/
#if wxOSX_USE_COCOA || wxOSX_USE_CARBON
#define wxOSX_USE_COCOA_OR_CARBON 1
#else
#define wxOSX_USE_COCOA_OR_CARBON 0
#endif
#if wxOSX_USE_COCOA || wxOSX_USE_IPHONE
#define wxOSX_USE_COCOA_OR_IPHONE 1
#else
#define wxOSX_USE_COCOA_OR_IPHONE 0
#endif
#if wxOSX_USE_IPHONE
#include "wx/osx/iphone/chkconf.h"
#elif wxOSX_USE_COCOA
#include "wx/osx/cocoa/chkconf.h"
#endif
#endif /* _WX_OSX_CHKCONF_H_ */

View File

@@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/choice.h
// Purpose: wxChoice class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICE_H_
#define _WX_CHOICE_H_
#include "wx/control.h"
#include "wx/dynarray.h"
#include "wx/arrstr.h"
WX_DEFINE_ARRAY( char * , wxChoiceDataArray ) ;
// Choice item
class WXDLLIMPEXP_CORE wxChoice: public wxChoiceBase
{
wxDECLARE_DYNAMIC_CLASS(wxChoice);
public:
wxChoice()
: m_strings(), m_datas()
{}
virtual ~wxChoice() ;
wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxChoiceNameStr))
{
Create(parent, id, pos, size, n, choices, style, validator, name);
}
wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxChoiceNameStr))
{
Create(parent, id, pos, size, choices, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxChoiceNameStr));
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxChoiceNameStr));
virtual unsigned int GetCount() const override;
virtual int GetSelection() const override;
virtual void SetSelection(int n) override;
virtual int FindString(const wxString& s, bool bCase = false) const override;
virtual wxString GetString(unsigned int n) const override;
virtual void SetString(unsigned int pos, const wxString& s) override;
// osx specific event handling common for all osx-ports
virtual bool OSXHandleClicked(double timestampsec) override;
protected:
virtual void DoDeleteOneItem(unsigned int n) override;
virtual void DoClear() override;
virtual wxSize DoGetBestSize() const override;
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type) override;
virtual void DoSetItemClientData(unsigned int n, void* clientData) override;
virtual void* DoGetItemClientData(unsigned int n) const override;
wxArrayString m_strings;
wxChoiceDataArray m_datas ;
private:
// This should be called when the number of items in the control changes.
void DoAfterItemCountChange();
};
#endif
// _WX_CHOICE_H_

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/clipbrd.h
// Purpose: Clipboard functionality.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLIPBRD_H_
#define _WX_CLIPBRD_H_
#if wxUSE_CLIPBOARD
#include "wx/osx/core/cfref.h"
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClipboard : public wxClipboardBase
{
public:
wxClipboard();
virtual ~wxClipboard();
// open the clipboard before SetData() and GetData()
virtual bool Open() override;
// close the clipboard after SetData() and GetData()
virtual void Close() override;
// query whether the clipboard is opened
virtual bool IsOpened() const override;
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data ) override;
// add to the clipboard data.
virtual bool AddData( wxDataObject *data ) override;
// ask if data in correct format is available
virtual bool IsSupported( const wxDataFormat& format ) override;
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data ) override;
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear() override;
// flushes the clipboard: this means that the data which is currently on
// clipboard will stay available even after the application exits (possibly
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush() override;
private:
wxDataObject *m_data;
bool m_open;
wxCFRef<PasteboardRef> m_pasteboard;
wxDECLARE_DYNAMIC_CLASS(wxClipboard);
};
#endif // wxUSE_CLIPBOARD
#endif // _WX_CLIPBRD_H_

View File

@@ -0,0 +1,56 @@
/*
* Name: wx/osx/cocoa/chkconf.h
* Purpose: Compiler-specific configuration checking
* Author: Stefan Csomor
* Modified by:
* Created: 2008-07-30
* Copyright: (c) Stefan Csomor
* Licence: wxWindows licence
*/
#ifndef _WX_OSX_COCOA_CHKCONF_H_
#define _WX_OSX_COCOA_CHKCONF_H_
/*
* native (1) or emulated (0) toolbar
*/
#ifndef wxOSX_USE_NATIVE_TOOLBAR
#define wxOSX_USE_NATIVE_TOOLBAR 1
#endif
/*
* leave is isFlipped and don't override
*/
#ifndef wxOSX_USE_NATIVE_FLIPPED
#define wxOSX_USE_NATIVE_FLIPPED 1
#endif
/*
* Audio System
*/
#define wxOSX_USE_QUICKTIME 0
#define wxOSX_USE_AUDIOTOOLBOX 1
/*
Use the more efficient FSEvents API instead of kqueue
events for file system watcher since that version introduced a flag that
allows watching files as well as sub directories.
*/
#define wxHAVE_FSEVENTS_FILE_NOTIFICATIONS 1
/*
* turn off old style icon format if not asked for
*/
#ifndef wxOSX_USE_ICONREF
#define wxOSX_USE_ICONREF 0
#endif
/*
* turning off capabilities that don't work under cocoa yet
*/
#endif
/* _WX_MAC_CHKCONF_H_ */

View File

@@ -0,0 +1,564 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/dataview.h
// Purpose: wxDataViewCtrl native implementation header for carbon
// Author:
// Copyright: (c) 2009
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAVIEWCTRL_COCOOA_H_
#define _WX_DATAVIEWCTRL_COCOOA_H_
#include "wx/defs.h"
#import <Cocoa/Cocoa.h>
#include "wx/osx/core/dataview.h"
#include "wx/osx/private.h"
// Forward declaration
class wxCocoaDataViewControl;
/*
Dramatis personae:
[vertical arrows indicate inheritance, horizontal -- aggregation]
wxWindow ---> wxWidgetCocoaImpl wxDataViewWidgetImpl NSOutlineView
| \ / |
| \ / |
| \ / |
v \/ \/ v
wxDataViewCtrl -------> wxCocoaDataViewControl <-------> wxCocoaOutlineView
The right most classes are Objective-C only and can't be used from (pure)
C++ code.
*/
// ============================================================================
// wxPointerObject: simply stores a pointer, without taking its ownership
// ============================================================================
// Two pointer objects are equal if the containing pointers are equal. This
// means also that the hash value of a pointer object depends only on the
// stored pointer.
@interface wxPointerObject : NSObject
{
void* pointer;
}
-(id) initWithPointer:(void*)initPointer;
-(void*) pointer;
-(void) setPointer:(void*)newPointer;
@end
// ============================================================================
// wxSortDescriptorObject: helper class to use native sorting facilities
// ============================================================================
@interface wxSortDescriptorObject : NSSortDescriptor<NSCopying>
{
wxDataViewColumn* columnPtr; // pointer to the sorting column
wxDataViewModel* modelPtr; // pointer to model
}
-(id)
initWithModelPtr:(wxDataViewModel*)initModelPtr
sortingColumnPtr:(wxDataViewColumn*)initColumnPtr
ascending:(BOOL)sortAscending;
-(wxDataViewColumn*) columnPtr;
-(wxDataViewModel*) modelPtr;
-(void) setColumnPtr:(wxDataViewColumn*)newColumnPtr;
-(void) setModelPtr:(wxDataViewModel*)newModelPtr;
@end
// ============================================================================
// wxDataViewColumnNativeData: extra data for wxDataViewColumn
// ============================================================================
class wxDataViewColumnNativeData
{
public:
wxDataViewColumnNativeData() : m_NativeColumnPtr(nullptr)
{
}
wxDataViewColumnNativeData(NSTableColumn* initNativeColumnPtr)
: m_NativeColumnPtr(initNativeColumnPtr)
{
}
NSTableColumn* GetNativeColumnPtr() const
{
return m_NativeColumnPtr;
}
void SetNativeColumnPtr(NSTableColumn* newNativeColumnPtr)
{
m_NativeColumnPtr = newNativeColumnPtr;
}
private:
// not owned by us
NSTableColumn* m_NativeColumnPtr;
};
// ============================================================================
// wxDataViewRendererNativeData: extra data for wxDataViewRenderer
// ============================================================================
class wxDataViewRendererNativeData
{
public:
wxDataViewRendererNativeData()
: m_Object(nullptr), m_ColumnCell(nullptr), m_ItemCell(nullptr)
{
Init();
}
wxDataViewRendererNativeData(NSCell* initColumnCell)
: m_Object(nullptr), m_ColumnCell([initColumnCell retain]), m_ItemCell(nullptr)
{
Init();
}
wxDataViewRendererNativeData(NSCell* initColumnCell, id initObject)
: m_Object([initObject retain]), m_ColumnCell([initColumnCell retain]), m_ItemCell(nullptr)
{
Init();
}
~wxDataViewRendererNativeData()
{
[m_ColumnCell release];
[m_Object release];
[m_origFont release];
[m_origTextColour release];
[m_origBackgroundColour release];
}
NSCell* GetColumnCell() const { return m_ColumnCell; }
NSTableColumn* GetColumnPtr() const { return m_TableColumnPtr; }
id GetItem() const { return m_Item; }
NSCell* GetItemCell() const { return m_ItemCell; }
id GetObject() const { return m_Object; }
void SetColumnCell(NSCell* newCell)
{
[newCell retain];
[m_ColumnCell release];
m_ColumnCell = newCell;
}
void SetColumnPtr(NSTableColumn* newColumnPtr)
{
m_TableColumnPtr = newColumnPtr;
}
void SetItem(id newItem)
{
m_Item = newItem;
}
void SetItemCell(NSCell* newCell)
{
m_ItemCell = newCell;
}
void SetObject(id newObject)
{
[newObject retain];
[m_Object release];
m_Object = newObject;
}
// The original cell font and text colour stored here are null by default
// and are only initialized to the values retrieved from the cell when we
// change them from wxCocoaOutlineView:willDisplayCell:forTableColumn:item:
// which calls our SaveOriginalXXX() methods before changing the cell
// attributes.
//
// This allows us to avoid doing anything for the columns without any
// attributes but still be able to restore the correct attributes for the
// ones that do.
NSFont *GetOriginalFont() const { return m_origFont; }
NSColor *GetOriginalTextColour() const { return m_origTextColour; }
NSColor *GetOriginalBackgroundColour() const { return m_origBackgroundColour; }
void SaveOriginalFont(NSFont *font)
{
m_origFont = [font retain];
}
void SaveOriginalTextColour(NSColor *textColour)
{
m_origTextColour = [textColour retain];
}
void SaveOriginalBackgroundColour(NSColor *backgroundColour)
{
m_origBackgroundColour = [backgroundColour retain];
}
// The ellipsization mode which we need to set for each cell being rendered.
void SetEllipsizeMode(wxEllipsizeMode mode) { m_ellipsizeMode = mode; }
wxEllipsizeMode GetEllipsizeMode() const { return m_ellipsizeMode; }
// Set the line break mode for the given cell using our m_ellipsizeMode
void ApplyLineBreakMode(NSCell *cell);
// Does the rendered use a font that the control can't override?
void SetHasCustomFont(bool has) { m_hasCustomFont = has; }
bool HasCustomFont() const { return m_hasCustomFont; }
private:
// common part of all ctors
void Init();
id m_Item; // item NOT owned by renderer
// object that can be used by renderer for storing special data (owned by
// renderer)
id m_Object;
NSCell* m_ColumnCell; // column's cell is owned by renderer
NSCell* m_ItemCell; // item's cell is NOT owned by renderer
NSTableColumn* m_TableColumnPtr; // column NOT owned by renderer
// we own those if they're non-null
NSFont *m_origFont;
NSColor *m_origTextColour;
NSColor *m_origBackgroundColour;
wxEllipsizeMode m_ellipsizeMode;
bool m_hasCustomFont;
};
// ============================================================================
// wxCocoaOutlineDataSource
// ============================================================================
// This class implements the data source delegate for the outline view.
// As only an informal protocol exists this class inherits from NSObject only.
//
// As mentioned in the documentation for NSOutlineView the native control does
// not own any data. Therefore, it has to be done by the data source.
// Unfortunately, wxWidget's data source is a C++ data source but
// NSOutlineDataSource requires objects as data. Therefore, the data (or better
// the native item objects) have to be stored additionally in the native data
// source.
// NSOutlineView requires quick access to the item objects and quick linear
// access to an item's children. This requires normally a hash type of storage
// for the item object itself and an array structure for each item's children.
// This means that basically two times the whole structure of wxWidget's model
// class has to be stored.
// This implementation is using a compromise: all items that are in use by the
// control are stored in a set (from there they can be easily retrieved) and
// owned by the set. Furthermore, children of the last parent are stored
// in a linear list.
//
@interface wxCocoaOutlineDataSource : NSObject <NSOutlineViewDataSource>
{
// descriptors specifying the sorting (currently the array only holds one
// object only)
NSArray* sortDescriptors;
NSMutableArray* children; // buffered children
NSMutableSet* items; // stores all items that are in use by the control
wxCocoaDataViewControl* implementation;
wxDataViewModel* model;
// parent of the buffered children; the object is owned
wxPointerObject* currentParentItem;
}
// methods of informal protocol:
-(BOOL)
outlineView:(NSOutlineView*)outlineView
acceptDrop:(id<NSDraggingInfo>)info
item:(id)item
childIndex:(NSInteger)index;
-(id)
outlineView:(NSOutlineView*)outlineView
child:(NSInteger)index
ofItem:(id)item;
-(id)
outlineView:(NSOutlineView*)outlineView
objectValueForTableColumn:(NSTableColumn*)tableColumn
byItem:(id)item;
-(BOOL)
outlineView:(NSOutlineView*)outlineView
isItemExpandable:(id)item;
-(NSInteger)
outlineView:(NSOutlineView*)outlineView
numberOfChildrenOfItem:(id)item;
-(NSDragOperation)
outlineView:(NSOutlineView*)outlineView
validateDrop:(id<NSDraggingInfo>)info
proposedItem:(id)item
proposedChildIndex:(NSInteger)index;
-(BOOL)
outlineView:(NSOutlineView*)outlineView
writeItems:(NSArray*)items
toPasteboard:(NSPasteboard*)pasteboard;
// buffer for items handling
-(void) addToBuffer:(wxPointerObject*)item;
-(void) clearBuffer;
// returns the item in the buffer that has got the same pointer as "item",
// if such an item does not exist nil is returned
-(wxPointerObject*) getDataViewItemFromBuffer:(const wxDataViewItem&)item;
-(wxPointerObject*) getItemFromBuffer:(wxPointerObject*)item;
-(BOOL) isInBuffer:(wxPointerObject*)item;
-(void) removeFromBuffer:(wxPointerObject*)item;
// buffered children handling
-(void) clearChildren;
-(wxPointerObject*) getChild:(NSUInteger)index;
-(NSUInteger) getChildCount;
// buffer handling
-(void) clearBuffers;
// sorting
-(NSArray*) sortDescriptors;
-(void) setSortDescriptors:(NSArray*)newSortDescriptors;
// access to wxWidgets variables
-(wxPointerObject*) currentParentItem;
-(wxCocoaDataViewControl*) implementation;
-(wxDataViewModel*) model;
-(void) setCurrentParentItem:(wxPointerObject*)newCurrentParentItem;
-(void) setImplementation:(wxCocoaDataViewControl*)newImplementation;
-(void) setModel:(wxDataViewModel*)newModel;
// other methods
-(void)
bufferItem:(wxPointerObject*)parentItem
withChildren:(wxDataViewItemArray*)dataViewChildrenPtr;
@end
// ============================================================================
// wxCustomCell: used for custom renderers
// ============================================================================
@interface wxCustomCell : NSTextFieldCell
{
}
-(NSSize) cellSize;
@end
// ============================================================================
// wxImageCell: used for bitmap renderer
// ============================================================================
@interface wxImageCell : NSImageCell
{
}
-(NSSize) cellSize;
@end
// ============================================================================
// NSTextFieldCell customized to allow vertical alignment
// ============================================================================
@interface wxTextFieldCell : NSTextFieldCell
{
@private
int alignment_;
BOOL adjustRect_;
}
-(void) setWXAlignment:(int)alignment;
@end
// ============================================================================
// wxImageTextCell
// ============================================================================
//
// As the native cocoa environment does not have a cell displaying an icon/
// image and text at the same time, it has to be implemented by the user.
// This implementation follows the implementation of Chuck Pisula in Apple's
// DragNDropOutline sample application.
// Although in wxDataViewCtrl icons are used on OSX icons do not exist for
// display. Therefore, the cell is also called wxImageTextCell.
// Instead of displaying images of any size (which is possible) this cell uses
// a fixed size for displaying the image. Larger images are scaled to fit
// into their reserved space. Smaller or not existing images use the fixed
// reserved size and are scaled if necessary.
//
@interface wxImageTextCell : wxTextFieldCell
{
@private
CGFloat xImageShift; // shift for the image in x-direction from border
CGFloat spaceImageText; // space between image and text
NSImage* image; // the image itself
NSSize imageSize; // largest size of the image; default size is (16, 16)
// the text alignment is used to align the whole cell (image and text)
NSTextAlignment cellAlignment;
}
-(NSTextAlignment) alignment;
-(void) setAlignment:(NSTextAlignment)newAlignment;
-(NSImage*) image;
-(void) setImage:(NSImage*)newImage;
-(NSSize) imageSize;
-(void) setImageSize:(NSSize) newImageSize;
-(NSSize) cellSize;
@end
// ============================================================================
// wxCocoaOutlineView
// ============================================================================
@interface wxCocoaOutlineView : NSOutlineView <NSOutlineViewDelegate>
{
@private
// column and row of the cell being edited or -1 if none
int currentlyEditedColumn,
currentlyEditedRow;
wxCocoaDataViewControl* implementation;
}
-(wxCocoaDataViewControl*) implementation;
-(void) setImplementation:(wxCocoaDataViewControl*) newImplementation;
@end
// ============================================================================
// wxCocoaDataViewControl
// ============================================================================
// This is the internal interface class between wxDataViewCtrl (wxWidget) and
// the native source view (Mac OS X cocoa).
class wxCocoaDataViewControl : public wxWidgetCocoaImpl,
public wxDataViewWidgetImpl
{
public:
// constructors / destructor
wxCocoaDataViewControl(wxWindow* peer,
const wxPoint& pos,
const wxSize& size,
long style);
virtual ~wxCocoaDataViewControl();
wxDataViewCtrl* GetDataViewCtrl() const
{
return static_cast<wxDataViewCtrl*>(GetWXPeer());
}
// column related methods (inherited from wxDataViewWidgetImpl)
virtual bool ClearColumns() override;
virtual bool DeleteColumn(wxDataViewColumn* columnPtr) override;
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr) override;
virtual wxDataViewColumn* GetColumn(unsigned int pos) const override;
virtual int GetColumnPosition(wxDataViewColumn const* columnPtr) const override;
virtual bool InsertColumn(unsigned int pos, wxDataViewColumn* columnPtr) override;
virtual void FitColumnWidthToContent(unsigned int pos) override;
// item related methods (inherited from wxDataViewWidgetImpl)
virtual bool Add(const wxDataViewItem& parent, const wxDataViewItem& item) override;
virtual bool Add(const wxDataViewItem& parent,
const wxDataViewItemArray& items) override;
virtual void Collapse(const wxDataViewItem& item) override;
virtual void EnsureVisible(const wxDataViewItem& item,
wxDataViewColumn const* columnPtr) override;
virtual unsigned int GetCount() const override;
virtual int GetCountPerPage() const override;
virtual wxRect GetRectangle(const wxDataViewItem& item,
wxDataViewColumn const* columnPtr) override;
virtual wxDataViewItem GetTopItem() const override;
virtual bool IsExpanded(const wxDataViewItem& item) const override;
virtual bool Reload() override;
virtual bool Remove(const wxDataViewItem& parent) override;
virtual bool Update(const wxDataViewColumn* columnPtr) override;
virtual bool Update(const wxDataViewItem& parent,
const wxDataViewItem& item) override;
virtual bool Update(const wxDataViewItem& parent,
const wxDataViewItemArray& items) override;
// model related methods
virtual bool AssociateModel(wxDataViewModel* model) override;
//
// selection related methods (inherited from wxDataViewWidgetImpl)
//
virtual wxDataViewItem GetCurrentItem() const override;
virtual void SetCurrentItem(const wxDataViewItem& item) override;
virtual wxDataViewColumn *GetCurrentColumn() const override;
virtual int GetSelectedItemsCount() const override;
virtual int GetSelections(wxDataViewItemArray& sel) const override;
virtual bool IsSelected(const wxDataViewItem& item) const override;
virtual void Select(const wxDataViewItem& item) override;
virtual void Select(const wxDataViewItemArray& items) override;
virtual void SelectAll() override;
virtual void Unselect(const wxDataViewItem& item) override;
virtual void UnselectAll() override;
//
// sorting related methods
//
virtual wxDataViewColumn* GetSortingColumn () const override;
virtual void Resort() override;
//
// other methods (inherited from wxDataViewWidgetImpl)
//
virtual void DoSetIndent(int indent) override;
virtual void DoExpand(const wxDataViewItem& item, bool expandChildren) override;
virtual void HitTest(const wxPoint& point,
wxDataViewItem& item,
wxDataViewColumn*& columnPtr) const override;
virtual void SetRowHeight(int height) override;
virtual void SetRowHeight(const wxDataViewItem& item, unsigned int height) override;
virtual void OnSize() override;
virtual void StartEditor( const wxDataViewItem & item, unsigned int column ) override;
// Cocoa-specific helpers
id GetItemAtRow(int row) const;
virtual void SetFont(const wxFont& font) override;
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd) override;
virtual bool doCommandBySelector(void* sel, WXWidget slf, void* _cmd) override;
private:
void InitOutlineView(long style);
int GetDefaultRowHeight() const;
wxCocoaOutlineDataSource* m_DataSource;
wxCocoaOutlineView* m_OutlineView;
// Width of expander in pixels, computed on demand.
int m_expanderWidth;
};
#endif // _WX_DATAVIEWCTRL_COCOOA_H_

View File

@@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/evtloop.h
// Purpose: declaration of wxGUIEventLoop for wxOSX/Cocoa
// Author: Vadim Zeitlin
// Created: 2008-12-28
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_COCOA_EVTLOOP_H_
#define _WX_OSX_COCOA_EVTLOOP_H_
class WXDLLIMPEXP_BASE wxGUIEventLoop : public wxCFEventLoop
{
public:
wxGUIEventLoop();
~wxGUIEventLoop();
void BeginModalSession( wxWindow* modalWindow );
void EndModalSession();
virtual void WakeUp() override;
void OSXUseLowLevelWakeup(bool useIt)
{ m_osxLowLevelWakeUp = useIt ; }
protected:
virtual int DoDispatchTimeout(unsigned long timeout) override;
virtual void OSXDoRun() override;
virtual void OSXDoStop() override;
virtual CFRunLoopRef CFGetCurrentRunLoop() const override;
void* m_modalSession;
wxWindow* m_modalWindow;
WXWindow m_dummyWindow;
int m_modalNestedLevel;
bool m_osxLowLevelWakeUp;
};
#endif // _WX_OSX_COCOA_EVTLOOP_H_

View File

@@ -0,0 +1,602 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/private.h
// Purpose: Private declarations: as this header is only included by
// wxWidgets itself, it may contain identifiers which don't start
// with "wx".
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_COCOA_H_
#define _WX_PRIVATE_COCOA_H_
#include <ApplicationServices/ApplicationServices.h>
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
#include <vector>
//
// shared between Cocoa and Carbon
//
#include "wx/bmpbndl.h"
// bring in theming types without pulling in the headers
#if wxUSE_GUI
typedef SInt16 ThemeBrush;
CGColorRef WXDLLIMPEXP_CORE wxMacCreateCGColorFromHITheme( ThemeBrush brush ) ;
OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
CGContextRef inContext,
const CGRect * inBounds,
CGImageRef inImage) ;
void WXDLLIMPEXP_CORE wxOSXDrawNSImage(
CGContextRef inContext,
const CGRect * inBounds,
WX_NSImage inImage,
wxCompositionMode composition) ;
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetSystemImage(const wxString& name);
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0, bool isTemplate = false);
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref );
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCFURL( CFURLRef urlref );
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetIconForType(OSType type );
void WXDLLIMPEXP_CORE wxOSXSetImageSize(WX_NSImage image, CGFloat width, CGFloat height);
wxBitmapBundle WXDLLIMPEXP_CORE wxOSXCreateSystemBitmapBundle(const wxString& id, const wxString &client, const wxSize& size);
WXWindow WXDLLIMPEXP_CORE wxOSXGetMainWindow();
WXWindow WXDLLIMPEXP_CORE wxOSXGetKeyWindow();
WXImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromNSCursor(const WXHCURSOR cursor);
class WXDLLIMPEXP_FWD_CORE wxDialog;
class WXDLLIMPEXP_FWD_CORE wxWidgetCocoaImpl;
// a class which disables sending wx keydown events useful when adding text programmatically, for wx-internal use only
class wxWidgetCocoaNativeKeyDownSuspender
{
public:
// stops sending keydown events for text inserted into this widget
explicit wxWidgetCocoaNativeKeyDownSuspender(wxWidgetCocoaImpl *target);
// resumes sending keydown events
~wxWidgetCocoaNativeKeyDownSuspender();
private:
wxWidgetCocoaImpl *m_target;
NSEvent* m_nsevent;
bool m_wxsent;
wxDECLARE_NO_COPY_CLASS(wxWidgetCocoaNativeKeyDownSuspender);
};
class WXDLLIMPEXP_CORE wxWidgetCocoaImpl : public wxWidgetImpl
{
public :
wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, int flags = 0 ) ;
wxWidgetCocoaImpl() ;
~wxWidgetCocoaImpl();
void Init();
virtual bool IsVisible() const override;
virtual void SetVisibility(bool) override;
// we provide a static function which can be reused from
// wxNonOwnedWindowCocoaImpl too
static bool ShowViewOrWindowWithEffect(wxWindow *win,
bool show,
wxShowEffect effect,
unsigned timeout);
virtual bool ShowWithEffect(bool show,
wxShowEffect effect,
unsigned timeout) override;
virtual void Raise() override;
virtual void Lower() override;
virtual void ScrollRect( const wxRect *rect, int dx, int dy ) override;
virtual WXWidget GetWXWidget() const override { return m_osxView; }
virtual void SetBackgroundColour(const wxColour&) override;
virtual bool SetBackgroundStyle(wxBackgroundStyle style) override;
virtual void SetForegroundColour(const wxColour& col) override;
virtual void GetContentArea( int &left, int &top, int &width, int &height ) const override;
virtual void Move(int x, int y, int width, int height) override;
virtual void GetPosition( int &x, int &y ) const override;
virtual void GetSize( int &width, int &height ) const override;
virtual void SetControlSize( wxWindowVariant variant ) override;
virtual void GetLayoutInset(int &left , int &top , int &right, int &bottom) const override;
virtual void SetNeedsDisplay( const wxRect* where = nullptr ) override;
virtual bool GetNeedsDisplay() const override;
virtual void EnableFocusRing(bool enabled) override;
virtual void SetDrawingEnabled(bool enabled) override;
virtual bool CanFocus() const override;
// return true if successful
virtual bool SetFocus() override;
virtual bool HasFocus() const override;
void RemoveFromParent() override;
void Embed( wxWidgetImpl *parent ) override;
void SetDefaultButton( bool isDefault ) override;
void PerformClick() override;
virtual void SetLabel(const wxString& title) override;
void SetCursor( const wxCursor & cursor ) override;
void CaptureMouse() override;
void ReleaseMouse() override;
#if wxUSE_DRAG_AND_DROP
void SetDropTarget(wxDropTarget* target) override;
#endif
wxInt32 GetValue() const override;
void SetValue( wxInt32 v ) override;
wxBitmap GetBitmap() const override;
void SetBitmap( const wxBitmapBundle& bitmap ) override;
void SetBitmapPosition( wxDirection dir ) override;
void SetupTabs( const wxNotebook &notebook ) override;
void GetBestRect( wxRect *r ) const override;
bool IsEnabled() const override;
void Enable( bool enable ) override;
bool ButtonClickDidStateChange() override { return true; }
void SetMinimum( wxInt32 v ) override;
void SetMaximum( wxInt32 v ) override;
void SetIncrement(int value) override;
wxInt32 GetMinimum() const override;
wxInt32 GetMaximum() const override;
int GetIncrement() const override;
void PulseGauge() override;
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) override;
void SetFont(const wxFont & font) override;
void SetToolTip( wxToolTip* tooltip ) override;
void InstallEventHandler( WXWidget control = nullptr ) override;
bool EnableTouchEvents(int eventsMask) override;
virtual bool ShouldHandleKeyNavigation(const wxKeyEvent &event) const;
bool DoHandleKeyNavigation(const wxKeyEvent &event);
virtual bool DoHandleMouseEvent(NSEvent *event);
virtual bool DoHandleKeyEvent(NSEvent *event);
virtual bool DoHandleCharEvent(NSEvent *event, NSString *text);
virtual void DoNotifyFocusSet();
virtual void DoNotifyFocusLost();
virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
virtual void SetupKeyEvent(wxKeyEvent &wxevent, NSEvent * nsEvent, NSString* charString = nullptr);
using MouseEvents = std::vector<wxMouseEvent>;
virtual MouseEvents TranslateMouseEvent(NSEvent * nsEvent);
void SetupCoordinates(wxCoord &x, wxCoord &y, NSEvent *nsEvent);
virtual bool SetupCursor(NSEvent* event);
virtual void PanGestureEvent(NSPanGestureRecognizer *panGestureRecognizer);
virtual void ZoomGestureEvent(NSMagnificationGestureRecognizer *magnificationGestureRecognizer);
virtual void RotateGestureEvent(NSRotationGestureRecognizer *rotationGestureRecognizer);
virtual void LongPressEvent(NSPressGestureRecognizer *pressGestureRecognizer);
virtual void TouchesBegan(NSEvent *event);
virtual void TouchesMoved(NSEvent *event);
virtual void TouchesEnded(NSEvent *event);
virtual void TouchesCancel(NSEvent *event);
#if !wxOSX_USE_NATIVE_FLIPPED
void SetFlipped(bool flipped);
virtual bool IsFlipped() const { return m_isFlipped; }
#endif
virtual double GetContentScaleFactor() const override;
// cocoa thunk connected calls
#if wxUSE_DRAG_AND_DROP
virtual unsigned int draggingEntered(void* sender, WXWidget slf, void* _cmd);
virtual void draggingExited(void* sender, WXWidget slf, void* _cmd);
virtual unsigned int draggingUpdated(void* sender, WXWidget slf, void* _cmd);
virtual bool performDragOperation(void* sender, WXWidget slf, void* _cmd);
#endif
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
virtual void cursorUpdate(WX_NSEvent event, WXWidget slf, void* _cmd);
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
// Returns true if the event was processed by a user-defined event handler.
virtual bool doCommandBySelector(void* sel, WXWidget slf, void* _cmd);
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
#if !wxOSX_USE_NATIVE_FLIPPED
virtual bool isFlipped(WXWidget slf, void* _cmd);
#endif
virtual void drawRect(void* rect, WXWidget slf, void* _cmd);
virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
virtual void controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
// for wxTextCtrl-derived classes, put here since they don't all derive
// from the same pimpl class.
virtual void controlTextDidChange();
virtual void AdjustClippingView(wxScrollBar* horizontal, wxScrollBar* vertical) override;
virtual void UseClippingView() override;
virtual WXWidget GetContainer() const override { return m_osxClipView ? m_osxClipView : m_osxView; }
virtual void ApplyScrollViewBorderType() override;
protected:
WXWidget m_osxView;
WXWidget m_osxClipView;
// begins processing of native key down event, storing the native event for later wx event generation
void BeginNativeKeyDownEvent( NSEvent* event );
// done with the current native key down event
void EndNativeKeyDownEvent();
// allow executing text changes without triggering key down events
// is currently processing a native key down event
bool IsInNativeKeyDown() const;
// the native key event
NSEvent* GetLastNativeKeyDownEvent();
// did send the wx event for the current native key down event
void SetKeyDownSent();
// was the wx event for the current native key down event sent
bool WasKeyDownSent() const;
// Return the view to apply the font/colour to.
NSView* GetViewWithText() const;
NSEvent* m_lastKeyDownEvent;
bool m_lastKeyDownWXSent;
#if !wxOSX_USE_NATIVE_FLIPPED
bool m_isFlipped;
#endif
// if it the control has an editor, that editor will already send some
// events, don't resend them
bool m_hasEditor;
friend class wxWidgetCocoaNativeKeyDownSuspender;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl);
};
DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
{
public :
wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) ;
wxNonOwnedWindowCocoaImpl();
virtual ~wxNonOwnedWindowCocoaImpl();
virtual void WillBeDestroyed() override;
void Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) override;
void Create( wxWindow* parent, WXWindow nativeWindow );
WXWindow GetWXWindow() const override;
void Raise() override;
void Lower() override;
bool Show(bool show) override;
virtual bool ShowWithEffect(bool show,
wxShowEffect effect,
unsigned timeout) override;
void Update() override;
bool SetTransparent(wxByte alpha) override;
bool SetBackgroundColour(const wxColour& col ) override;
void SetExtraStyle( long exStyle ) override;
void SetWindowStyleFlag( long style ) override;
bool SetBackgroundStyle(wxBackgroundStyle style) override;
bool CanSetTransparent() override;
void MoveWindow(int x, int y, int width, int height) override;
void GetPosition( int &x, int &y ) const override;
void GetSize( int &width, int &height ) const override;
void GetContentArea( int &left, int &top, int &width, int &height ) const override;
bool SetShape(const wxRegion& region) override;
virtual void SetTitle( const wxString& title ) override;
virtual wxContentProtection GetContentProtection() const override;
virtual bool SetContentProtection(wxContentProtection contentProtection) override;
virtual bool EnableCloseButton(bool enable) override;
virtual bool EnableMaximizeButton(bool enable) override;
virtual bool EnableMinimizeButton(bool enable) override;
virtual bool IsMaximized() const override;
virtual bool IsIconized() const override;
virtual void Iconize( bool iconize ) override;
virtual void Maximize(bool maximize) override;
virtual bool IsFullScreen() const override;
bool EnableFullScreenView(bool enable, long style) override;
virtual bool ShowFullScreen(bool show, long style) override;
virtual void ShowWithoutActivating() override;
virtual void RequestUserAttention(int flags) override;
virtual void ScreenToWindow( int *x, int *y ) override;
virtual void WindowToScreen( int *x, int *y ) override;
virtual bool IsActive() override;
virtual void SetModified(bool modified) override;
virtual bool IsModified() const override;
virtual void SetRepresentedFilename(const wxString& filename) override;
virtual void SetBottomBorderThickness(int thickness) override;
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
CGWindowLevel GetWindowLevel() const override { return m_macWindowLevel; }
void RestoreWindowLevel() override;
bool m_macIgnoreNextFullscreenChange = false;
long m_macFullscreenStyle = wxFULLSCREEN_ALL;
static WX_NSResponder GetNextFirstResponder() ;
static WX_NSResponder GetFormerFirstResponder() ;
protected :
CGWindowLevel m_macWindowLevel;
WXWindow m_macWindow;
void * m_macFullScreenData ;
private:
void SetUpForModalParent();
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl);
};
DECLARE_WXCOCOA_OBJC_CLASS( wxNSButton );
class wxButtonCocoaImpl : public wxWidgetCocoaImpl, public wxButtonImpl
{
public:
wxButtonCocoaImpl(wxWindowMac *wxpeer, wxNSButton *v);
virtual void SetBitmap(const wxBitmapBundle& bitmap) override;
#if wxUSE_MARKUP
virtual void SetLabelMarkup(const wxString& markup) override;
#endif // wxUSE_MARKUP
void SetPressedBitmap( const wxBitmapBundle& bitmap ) override;
void SetAcceleratorFromLabel(const wxString& label);
NSButton *GetNSButton() const;
};
#ifdef __OBJC__
typedef NSRect WXRect;
typedef void (*wxOSX_TextEventHandlerPtr)(NSView* self, SEL _cmd, NSString *event);
typedef void (*wxOSX_EventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
typedef BOOL (*wxOSX_PerformKeyEventHandlerPtr)(NSView* self, SEL _cmd, NSEvent *event);
typedef void (*wxOSX_DoCommandBySelectorPtr)(NSView* self, SEL _cmd, SEL _sel);
typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
typedef void (*wxOSX_DoCommandBySelectorPtr)(NSView* self, SEL _cmd, SEL _sel);
typedef NSDragOperation (*wxOSX_DraggingEnteredOrUpdatedHandlerPtr)(NSView *self, SEL _cmd, void *sender);
typedef void (*wxOSX_DraggingExitedHandlerPtr)(NSView *self, SEL _cmd, void *sender);
typedef BOOL (*wxOSX_PerformDragOperationHandlerPtr)(NSView *self, SEL _cmd, void *sender);
WXDLLIMPEXP_CORE NSScreen* wxOSXGetMenuScreen();
WXDLLIMPEXP_CORE NSRect wxToNSRect( NSView* parent, const wxRect& r );
WXDLLIMPEXP_CORE wxRect wxFromNSRect( NSView* parent, const NSRect& rect );
WXDLLIMPEXP_CORE NSPoint wxToNSPoint( NSView* parent, const wxPoint& p );
WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p );
WXDLLIMPEXP_CORE NSPoint wxToNSPointF(NSView* parent, const wxPoint2DDouble& p);
WXDLLIMPEXP_CORE wxPoint2DDouble wxFromNSPointF(NSView* parent, const NSPoint& p);
NSRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
bool adjustForOrigin = true );
WXDLLIMPEXP_CORE NSView* wxOSXGetViewFromResponder( NSResponder* responder );
// used for many wxControls
@interface wxNSButton : NSButton
{
NSTrackingRectTag rectTag;
}
@end
@interface wxNSBox : NSBox
{
}
@end
@interface wxNSTextFieldEditor : NSTextView
{
NSEvent* lastKeyDownEvent;
NSTextField* textField;
}
- (void) setTextField:(NSTextField*) field;
@end
@interface wxNSTextField : NSTextField <NSTextFieldDelegate>
{
}
// Note that the name WXFieldEditor is special and is checked by
// windowWillReturnFieldEditor: in wxNonOwnedWindowController
// implementation, see there.
@property (retain) wxNSTextFieldEditor* WXFieldEditor;
@end
@interface wxNSSecureTextField : NSSecureTextField <NSTextFieldDelegate>
{
}
@end
@interface wxNSTextView : NSTextView <NSTextViewDelegate>
{
}
- (void)textDidChange:(NSNotification *)aNotification;
- (void)changeColor:(id)sender;
@property (retain) NSUndoManager* undoManager;
@end
@interface wxNSSearchField : NSSearchField
{
BOOL m_withinTextDidChange;
}
@property (retain) wxNSTextFieldEditor* WXFieldEditor;
@end
@interface wxNSComboBox : NSComboBox
{
}
@property (retain) wxNSTextFieldEditor* WXFieldEditor;
@end
@interface wxNSMenu : NSMenu
{
wxMenuImpl* impl;
}
- (void) setImplementation:(wxMenuImpl*) item;
- (wxMenuImpl*) implementation;
@end
@interface wxNSMenuItem : NSMenuItem
{
wxMenuItemImpl* impl;
}
- (void) setImplementation:(wxMenuItemImpl*) item;
- (wxMenuItemImpl*) implementation;
- (void)clickedAction:(id)sender;
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
@end
// this enum declares which methods should not be overridden in the native view classes
enum wxOSXSkipOverrides {
wxOSXSKIP_NONE = 0x0,
wxOSXSKIP_DRAW = 0x1,
wxOSXSKIP_DND = 0x2
};
void WXDLLIMPEXP_CORE wxOSXCocoaClassAddWXMethods(Class c, wxOSXSkipOverrides skipFlags = wxOSXSKIP_NONE);
/*
We need this for ShowModal, as the sheet just disables the parent window and
returns control to the app, whereas we don't want to return from ShowModal
until the sheet has been dismissed.
*/
@interface ModalDialogDelegate : NSObject
{
BOOL sheetFinished;
int resultCode;
wxDialog* impl;
}
- (void)setImplementation: (wxDialog *)dialog;
- (BOOL)finished;
- (int)code;
- (void)waitForSheetToFinish;
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
@end
WXEXPORT
@interface wxNSAppController : NSObject <NSApplicationDelegate>
{
}
@end
#endif // __OBJC__
// NSCursor
WX_NSCursor wxMacCocoaCreateStockCursor( int cursor_type );
WX_NSCursor wxMacCocoaCreateCursorFromCGImage( CGImageRef cgImageRef, float hotSpotX, float hotSpotY );
void wxMacCocoaSetCursor( WX_NSCursor cursor );
void wxMacCocoaHideCursor();
void wxMacCocoaShowCursor();
wxPoint wxMacCocoaGetCursorHotSpot( WX_NSCursor cursor );
typedef struct tagClassicCursor
{
wxUint16 bits[16];
wxUint16 mask[16];
wxInt16 hotspot[2];
}ClassicCursor;
const short kwxCursorBullseye = 0;
const short kwxCursorBlank = 1;
const short kwxCursorPencil = 2;
const short kwxCursorMagnifier = 3;
const short kwxCursorNoEntry = 4;
const short kwxCursorPaintBrush = 5;
const short kwxCursorPointRight = 6;
const short kwxCursorPointLeft = 7;
const short kwxCursorQuestionArrow = 8;
const short kwxCursorRightArrow = 9;
const short kwxCursorSizeNS = 10;
const short kwxCursorSize = 11;
const short kwxCursorSizeNESW = 12;
const short kwxCursorSizeNWSE = 13;
const short kwxCursorRoller = 14;
const short kwxCursorWatch = 15;
const short kwxCursorLast = kwxCursorWatch;
// exposing our fallback cursor map
extern ClassicCursor gMacCursors[];
extern NSLayoutManager* gNSLayoutManager;
// helper class for setting the current appearance to the
// effective appearance and restore when exiting scope
class WXDLLIMPEXP_CORE wxOSXEffectiveAppearanceSetter
{
public:
wxOSXEffectiveAppearanceSetter();
~wxOSXEffectiveAppearanceSetter();
private:
void * formerAppearance;
};
#endif // wxUSE_GUI
#endif
// _WX_PRIVATE_COCOA_H_

View File

@@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/private/date.h
// Purpose: NSDate-related helpers
// Author: Vadim Zeitlin
// Created: 2011-12-19
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_COCOA_PRIVATE_DATE_H_
#define _WX_OSX_COCOA_PRIVATE_DATE_H_
#include "wx/datetime.h"
namespace wxOSXImpl
{
// Functions to convert between NSDate and wxDateTime.
// Returns an NSDate corresponding to the given wxDateTime which can be invalid
// (in which case nil is returned).
inline NSDate* NSDateFromWX(const wxDateTime& dt)
{
if ( !dt.IsValid() )
return nil;
// Get the internal representation as a double used by NSDate.
double ticks = dt.GetValue().ToDouble();
// wxDateTime uses milliseconds while NSDate uses (fractional) seconds.
return [NSDate dateWithTimeIntervalSince1970:ticks/1000.];
}
// Returns wxDateTime corresponding to the given NSDate (which may be nil).
inline wxDateTime NSDateToWX(const NSDate* d)
{
if ( !d )
return wxDefaultDateTime;
// Reverse everything done above.
wxLongLong ll;
ll.Assign([d timeIntervalSince1970]*1000);
wxDateTime dt(ll);
return dt;
}
} // namespace wxOSXImpl
#endif // _WX_OSX_COCOA_PRIVATE_DATE_H_

View File

@@ -0,0 +1,181 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/private/markuptoattr.h
// Purpose: Class to convert markup to Cocoa attributed strings.
// Author: Vadim Zeitlin
// Created: 2011-02-22
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_COCOA_PRIVATE_MARKUPTOATTR_H_
#define _WX_OSX_COCOA_PRIVATE_MARKUPTOATTR_H_
#include "wx/private/markupparserattr.h"
// ----------------------------------------------------------------------------
// wxMarkupToAttrString: create NSAttributedString from markup.
// ----------------------------------------------------------------------------
class wxMarkupToAttrStringBase : public wxMarkupParserAttrOutput
{
protected:
// We don't care about the original colours because we never use them but
// we do need the correct initial font as we apply modifiers (e.g. create a
// font larger than it) to it and so it must be valid.
wxMarkupToAttrStringBase(const wxFont& font)
: wxMarkupParserAttrOutput(font, wxColour(), wxColour()),
m_attrString(nullptr)
{}
void Parse(const wxFont& font, const wxString& markup)
{
const wxCFStringRef label(PrepareText(wxMarkupParser::Strip(markup)));
m_attrString = [[NSMutableAttributedString alloc]
initWithString: label.AsNSString()];
m_pos = 0;
[m_attrString beginEditing];
// First thing we do is change the default string font: as mentioned in
// Apple documentation, attributed strings use "Helvetica 12" font by
// default which is different from the system "Lucida Grande" font. So
// we need to explicitly change the font for the entire string.
ApplyFont(font, NSMakeRange(0, [m_attrString length]));
// Now translate the markup tags to corresponding attributes.
wxMarkupParser parser(*this);
parser.Parse(markup);
[m_attrString endEditing];
}
~wxMarkupToAttrStringBase()
{
if ( m_attrString )
[m_attrString release];
}
void ApplyFont(const wxFont& font, const NSRange& range)
{
[m_attrString addAttribute:NSFontAttributeName
value:font.OSXGetNSFont()
range:range];
if ( font.GetStrikethrough() )
{
[m_attrString addAttribute:NSStrikethroughStyleAttributeName
value:@(NSUnderlineStyleSingle)
range:range];
}
if ( font.GetUnderlined() )
{
[m_attrString addAttribute:NSUnderlineStyleAttributeName
value:@(NSUnderlineStyleSingle)
range:range];
}
}
// prepare text chunk for display, e.g. strip mnemonics from it
virtual wxString PrepareText(const wxString& text) = 0;
public:
// Accessor for the users of this class.
//
// We keep ownership of the returned string.
NSMutableAttributedString *GetNSAttributedString() const
{
return m_attrString;
}
// Implement base class pure virtual methods to process markup tags.
virtual void OnText(const wxString& text) override
{
m_pos += PrepareText(text).length();
}
virtual void OnAttrStart(const Attr& WXUNUSED(attr)) override
{
// Just remember the starting position of the range, we can't really
// set the attribute until we find the end of it.
m_rangeStarts.push(m_pos);
}
virtual void OnAttrEnd(const Attr& attr) override
{
unsigned start = m_rangeStarts.top();
m_rangeStarts.pop();
const NSRange range = NSMakeRange(start, m_pos - start);
ApplyFont(attr.font, range);
if ( attr.foreground.IsOk() )
{
[m_attrString addAttribute:NSForegroundColorAttributeName
value:attr.foreground.OSXGetNSColor()
range:range];
}
if ( attr.background.IsOk() )
{
[m_attrString addAttribute:NSBackgroundColorAttributeName
value:attr.background.OSXGetNSColor()
range:range];
}
}
private:
// The attributed string we're building.
NSMutableAttributedString *m_attrString;
// The current position in the output string.
unsigned m_pos;
// The positions of starting ranges.
wxStack<unsigned> m_rangeStarts;
};
// for use with labels with mnemonics
class wxMarkupToAttrString : public wxMarkupToAttrStringBase
{
public:
wxMarkupToAttrString(const wxFont& font, const wxString& markup)
: wxMarkupToAttrStringBase(font)
{
Parse(font, markup);
}
protected:
virtual wxString PrepareText(const wxString& text) override
{
return wxControl::RemoveMnemonics(text);
}
wxDECLARE_NO_COPY_CLASS(wxMarkupToAttrString);
};
// for raw markup with no mnemonics
class wxItemMarkupToAttrString : public wxMarkupToAttrStringBase
{
public:
wxItemMarkupToAttrString(const wxFont& font, const wxString& markup)
: wxMarkupToAttrStringBase(font)
{
Parse(font, markup);
}
protected:
virtual wxString PrepareText(const wxString& text) override
{
return text;
}
wxDECLARE_NO_COPY_CLASS(wxItemMarkupToAttrString);
};
#endif // _WX_OSX_COCOA_PRIVATE_MARKUPTOATTR_H_

View File

@@ -0,0 +1,212 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cocoa/private/textimpl.h
// Purpose: textcontrol implementation classes that have to be exposed
// Author: Stefan Csomor
// Created: 03/02/99
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#include "wx/combobox.h"
#include "wx/osx/private.h"
@class wxTextEntryFormatter;
class wxNSTextBase : public wxWidgetCocoaImpl, public wxTextWidgetImpl
{
public :
wxNSTextBase( wxTextCtrl *text, WXWidget w )
: wxWidgetCocoaImpl(text, w),
wxTextWidgetImpl(text)
{
}
wxNSTextBase( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w )
: wxWidgetCocoaImpl(wxPeer, w),
wxTextWidgetImpl(entry)
{
}
virtual ~wxNSTextBase() = default;
virtual bool ShouldHandleKeyNavigation(const wxKeyEvent &event) const override;
virtual void SetInitialLabel(const wxString& WXUNUSED(title)) override
{
// Don't do anything here, text controls don't have any label and
// setting it would overwrite the string value set when creating it.
}
};
// implementation exposed, so that search control can pull it
class wxNSTextFieldControl : public wxNSTextBase
{
public :
// wxNSTextFieldControl must always be associated with a wxTextEntry. If
// it's associated with a wxTextCtrl then we can get the associated entry
// from it but otherwise the second ctor should be used to explicitly pass
// us the entry.
wxNSTextFieldControl( wxTextCtrl *text, WXWidget w );
wxNSTextFieldControl( wxWindow *wxPeer, wxTextEntry *entry, WXWidget w );
virtual ~wxNSTextFieldControl();
virtual bool CanClipMaxLength() const override { return true; }
virtual void SetMaxLength(unsigned long len) override;
virtual bool CanForceUpper() override { return true; }
virtual void ForceUpper() override;
virtual wxTextSearchResult SearchText(const wxTextSearch& WXUNUSED(search)) const override
{
wxFAIL_MSG("SearchText() should only be used with multiline controls.");
return wxTextSearchResult{};
}
virtual wxString GetStringValue() const override ;
virtual void SetStringValue( const wxString &str) override ;
virtual wxString GetRTFValue() const override
{
wxFAIL_MSG("GetRTFValue() should only be used with multiline controls.");
return wxEmptyString;
}
virtual void SetRTFValue(const wxString& WXUNUSED(str)) override
{
wxFAIL_MSG("SetRTFValue() should only be used with multiline controls.");
}
virtual void Copy() override ;
virtual void Cut() override ;
virtual void Paste() override ;
virtual bool CanPaste() const override ;
virtual void SetEditable(bool editable) override ;
virtual long GetLastPosition() const override;
virtual void GetSelection( long* from, long* to) const override ;
virtual void SetSelection( long from , long to ) override;
virtual bool PositionToXY(long pos, long *x, long *y) const override;
virtual long XYToPosition(long x, long y) const override;
virtual void ShowPosition(long pos) override;
virtual void WriteText(const wxString& str) override ;
virtual bool HasOwnContextMenu() const override { return true; }
virtual bool SetHint(const wxString& hint) override;
virtual void SetJustification() override;
virtual void controlAction(WXWidget slf, void* _cmd, void *sender) override;
virtual bool becomeFirstResponder(WXWidget slf, void *_cmd) override;
virtual bool resignFirstResponder(WXWidget slf, void *_cmd) override;
virtual void EnableNewLineReplacement(bool enable) override;
virtual bool GetNewLineReplacement() override;
virtual void SetInternalSelection( long from , long to );
virtual void UpdateInternalSelectionFromEditor( wxNSTextFieldEditor* editor);
virtual wxSize GetBestSize() const override;
protected :
NSTextField* m_textField;
long m_selStart;
long m_selEnd;
private:
// Common part of both ctors.
void Init(WXWidget w);
// Get our formatter, creating it if necessary.
wxTextEntryFormatter* GetFormatter();
};
class wxNSTextViewControl : public wxNSTextBase
{
public:
wxNSTextViewControl( wxTextCtrl *wxPeer, WXWidget w, long style );
virtual ~wxNSTextViewControl();
virtual void insertText(NSString* text, WXWidget slf, void *_cmd) override;
virtual wxTextSearchResult SearchText(const wxTextSearch &search) const override;
virtual wxString GetStringValue() const override ;
virtual void SetStringValue( const wxString &str) override ;
virtual wxString GetRTFValue() const override;
virtual void SetRTFValue(const wxString& str) override;
virtual void Copy() override ;
virtual void Cut() override ;
virtual void Paste() override ;
virtual bool CanPaste() const override ;
virtual void SetEditable(bool editable) override ;
virtual long GetLastPosition() const override;
virtual void GetSelection( long* from, long* to) const override ;
virtual void SetSelection( long from , long to ) override;
virtual bool PositionToXY(long pos, long *x, long *y) const override;
virtual long XYToPosition(long x, long y) const override;
virtual void ShowPosition(long pos) override;
virtual void WriteText(const wxString& str) override ;
virtual void SetFont(const wxFont & font) override;
virtual bool GetStyle(long position, wxTextAttr& style) override;
virtual void SetStyle(long start, long end, const wxTextAttr& style) override;
virtual bool CanFocus() const override;
virtual bool HasOwnContextMenu() const override { return true; }
#if wxUSE_SPELLCHECK
virtual void CheckSpelling(const wxTextProofOptions& options) override;
virtual wxTextProofOptions GetCheckingOptions() const override;
#endif // wxUSE_SPELLCHECK
virtual void EnableAutomaticQuoteSubstitution(bool enable) override;
virtual void EnableAutomaticDashSubstitution(bool enable) override;
virtual void EnableNewLineReplacement(bool enable) override;
virtual bool GetNewLineReplacement() override;
virtual wxSize GetBestSize() const override;
virtual void SetJustification() override;
virtual void controlTextDidChange() override;
virtual bool CanUndo() const override;
virtual void Undo() override;
virtual bool CanRedo() const override;
virtual void Redo() override;
virtual void EmptyUndoBuffer() override;
protected:
void DoUpdateTextStyle();
NSScrollView* m_scrollView;
NSTextView* m_textView;
bool m_useCharWrapping;
NSUndoManager* m_undoManager;
};
class wxNSComboBoxControl : public wxNSTextFieldControl, public wxComboWidgetImpl
{
public :
wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w );
virtual ~wxNSComboBoxControl();
virtual int GetSelectedItem() const override;
virtual void SetSelectedItem(int item) override;
virtual int GetNumberOfItems() const override;
virtual void InsertItem(int pos, const wxString& item) override;
virtual void RemoveItem(int pos) override;
virtual void Clear() override;
virtual wxString GetStringAtIndex(int pos) const override;
virtual int FindString(const wxString& text) const override;
virtual void Popup() override;
virtual void Dismiss() override;
virtual void SetEditable(bool editable) override;
virtual void mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) override;
private:
NSComboBox* m_comboBox;
};
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/colordlg.h
// Purpose: wxColourDialog class. Use generic version if no
// platform-specific implementation.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLORDLG_H_
#define _WX_COLORDLG_H_
#include "wx/dialog.h"
/*
* Platform-specific colour dialog implementation
*/
class WXDLLIMPEXP_CORE wxColourDialog: public wxDialog
{
wxDECLARE_DYNAMIC_CLASS(wxColourDialog);
public:
wxColourDialog();
wxColourDialog(wxWindow *parent, const wxColourData *data = nullptr);
bool Create(wxWindow *parent, const wxColourData *data = nullptr);
int ShowModal() override;
wxColourData& GetColourData() { return m_colourData; }
protected:
wxColourData m_colourData;
wxWindow* m_dialogParent;
};
#endif
// _WX_COLORDLG_H_

View File

@@ -0,0 +1 @@
#include "wx/osx/core/colour.h"

View File

@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/combobox.h
// Purpose: wxComboBox class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOBOX_H_
#define _WX_COMBOBOX_H_
#include "wx/containr.h"
#include "wx/choice.h"
#include "wx/textctrl.h"
WX_DEFINE_ARRAY( char * , wxComboBoxDataArray ) ;
// forward declaration of private implementation classes
class wxComboBoxText;
class wxComboBoxChoice;
class wxComboWidgetImpl;
// Combobox item
class WXDLLIMPEXP_CORE wxComboBox :
public wxWindowWithItems<
wxControl,
wxComboBoxBase>
{
wxDECLARE_DYNAMIC_CLASS(wxComboBox);
public:
virtual ~wxComboBox();
// callback functions
virtual void DelegateTextChanged( const wxString& value );
virtual void DelegateChoice( const wxString& value );
wxComboBox() = default;
wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr))
{
Create(parent, id, value, pos, size, n, choices, style, validator, name);
}
wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr))
{
Create(parent, id, value, pos, size, choices, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr));
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxComboBoxNameStr));
virtual int GetSelection() const override;
virtual void GetSelection(long *from, long *to) const override;
virtual void SetSelection(int n) override;
virtual void SetSelection(long from, long to) override;
virtual int FindString(const wxString& s, bool bCase = false) const override;
virtual wxString GetString(unsigned int n) const override;
virtual wxString GetStringSelection() const override;
virtual void SetString(unsigned int n, const wxString& s) override;
virtual unsigned int GetCount() const override;
virtual void SetValue(const wxString& value) override;
// these methods are provided by wxTextEntry for the native impl.
#if wxOSX_USE_COCOA
virtual void Popup() override;
virtual void Dismiss() override;
#endif // wxOSX_USE_COCOA
virtual const wxTextEntry* WXGetTextEntry() const override { return this; }
// osx specific event handling common for all osx-ports
virtual bool OSXHandleClicked(double timestampsec) override;
#if wxOSX_USE_COCOA
wxComboWidgetImpl* GetComboPeer() const;
#endif
protected:
// List functions
virtual void DoDeleteOneItem(unsigned int n) override;
virtual void DoClear() override;
// wxTextEntry functions
virtual wxWindow *GetEditableWindow() override { return this; }
// override the base class virtuals involved in geometry calculations
virtual wxSize DoGetBestSize() const override;
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type) override;
virtual void DoSetItemClientData(unsigned int n, void* clientData) override;
virtual void * DoGetItemClientData(unsigned int n) const override;
virtual void EnableTextChangedEvents(bool enable) override;
// callbacks
void OnChar(wxKeyEvent& event); // Process 'enter' if required
void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts
// the subcontrols
wxComboBoxText* m_text;
wxComboBoxChoice* m_choice;
wxComboBoxDataArray m_datas;
private:
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_COMBOBOX_H_

View File

@@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/config_xcode.h
// Purpose: configurations for xcode builds
// Author: Stefan Csomor
// Created: 29.04.04
// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// from config.log confdefs
#define HAVE_SSIZE_T 1
#define STDC_HEADERS 1
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif
#define wxUSE_UNIX 1
#define __UNIX__ 1
#define __BSD__ 1
#define __DARWIN__ 1
#define wx_USE_NANOX 0
#define HAVE_VA_COPY 1
#if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 2 )
#define HAVE_GCC_ATOMIC_BUILTINS 1
#endif
#define HAVE_VISIBILITY 1
#define wxHAVE_PTHREAD_CLEANUP 1
#define WX_TIMEZONE timezone
#define WX_SOCKLEN_T socklen_t
#define SOCKOPTLEN_T socklen_t
#define WX_STATFS_T struct statfs
#define WX_GMTOFF_IN_TM 1
#define HAVE_PW_GECOS 1
#define HAVE_DLOPEN 1
#define HAVE_CXA_DEMANGLE 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_FSYNC 1
#define HAVE_SCHED_YIELD 1
#define HAVE_PTHREAD_MUTEXATTR_T 1
#define HAVE_PTHREAD_MUTEXATTR_SETTYPE_DECL 1
#define HAVE_PTHREAD_CANCEL 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
#define HAVE_SNPRINTF 1
#define HAVE_UNIX98_PRINTF 1
#define HAVE_STATFS 1
#define HAVE_STATFS_DECL 1
#define HAVE_STRNLEN 1
#define HAVE_STRPTIME 1
#define HAVE_STRPTIME_DECL 1
#define HAVE_THREAD_PRIORITY_FUNCTIONS 1
#define HAVE_VSNPRINTF 1
#define HAVE_VSSCANF 1
#define HAVE_USLEEP 1
#define HAVE_WCSCASECMP 1
#define HAVE_WCSDUP 1
#define HAVE_WCSLEN 1
#define HAVE_WCSNCASECMP 1
#define HAVE_WCSNLEN 1
#define SIZEOF_WCHAR_T 4
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#ifdef __LP64__
#define SIZEOF_VOID_P 8
#define SIZEOF_LONG 8
#define SIZEOF_SIZE_T 8
#else
#define SIZEOF_VOID_P 4
#define SIZEOF_LONG 4
#define SIZEOF_SIZE_T 4
#endif
#define SIZEOF_LONG_LONG 8
#define wxSIZE_T_IS_ULONG 1
#define wxWCHAR_T_IS_REAL_TYPE 1
#define HAVE_FCNTL 1
#define HAVE_GETHOSTBYNAME 1
#define HAVE_GETSERVBYNAME 1
#define HAVE_GMTIME_R 1
#define HAVE_INET_ADDR 1
#define HAVE_INET_ATON 1
#define HAVE_LOCALTIME_R 1
#define HAVE_MKSTEMP 1
#define HAVE_SETENV 1
/* #define HAVE_PUTENV 1 */
#define HAVE_STRTOK_R 1
#define HAVE_UNAME 1
#define HAVE_USLEEP 1
#define HAVE_X11_XKBLIB_H 1
#define HAVE_SCHED_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WCHAR_H 1
/* better to use the built-in CF conversions, also avoid iconv versioning problems */
/* #undef HAVE_ICONV */
#define ICONV_CONST
#define HAVE_LANGINFO_H 1
#define HAVE_WCSRTOMBS 1
#define HAVE_FPUTWS 1
#define HAVE_WPRINTF 1
#define HAVE_VSWPRINTF 1
#define HAVE_VSWSCANF 1
#define HAVE_FSEEKO 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_FDOPEN 1
#define HAVE_SYSCONF 1
#define HAVE_GETPWUID_R 1
#define HAVE_GETGRGID_R 1
#define HAVE_LOCALE_T 1
#define HAVE_XLOCALE_H 1
#define wxHAS_KQUEUE 1
// for jpeg
#define HAVE_STDLIB_H 1
// OBSOLETE ?
#define HAVE_COS 1
#define HAVE_FLOOR 1
#define HAVE_INTTYPES_H 1
#define HAVE_MEMORY_H 1
#define HAVE_REGCOMP 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_X11_XLIB_H 1
#define SOCKLEN_T socklen_t
#define _FILE_OFFSET_BITS 64

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/control.h
// Purpose: wxControl class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTROL_H_
#define _WX_CONTROL_H_
WXDLLIMPEXP_DATA_CORE(extern const char) wxControlNameStr[];
// General item class
class WXDLLIMPEXP_CORE wxControl : public wxControlBase
{
wxDECLARE_ABSTRACT_CLASS(wxControl);
public:
wxControl();
wxControl(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxControlNameStr))
{
Create(parent, winid, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxControlNameStr));
// Simulates an event
virtual void Command(wxCommandEvent& event) override { ProcessCommand(event); }
// implementation from now on
// --------------------------
// Calls the callback and appropriate event handlers
bool ProcessCommand(wxCommandEvent& event);
void OnKeyDown( wxKeyEvent &event ) ;
};
#endif
// _WX_CONTROL_H_

View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfarrayref.h
// Purpose: wxCFArrayRef class
// Author: Stefan Csomor
// Created: 2018/07/27
// Copyright: (c) 2018 Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*! @header wx/osx/core/cfarrayref.h
@abstract wxCFArrayRef class
*/
#ifndef _WX_OSX_COREFOUNDATION_CFARRAYREF_H__
#define _WX_OSX_COREFOUNDATION_CFARRAYREF_H__
#include "wx/osx/core/cfref.h"
#include "wx/osx/core/cftype.h"
#include <CoreFoundation/CFArray.h>
template <typename T, typename E>
class wxCFArrayRefCommon : public wxCFRef<T>
{
public:
typedef wxCFRef<T> super_type;
typedef size_t size_type;
wxCFArrayRefCommon(T r)
: super_type(r)
{
}
wxCFArrayRefCommon(const wxCFArrayRefCommon& otherRef)
: super_type(otherRef)
{
}
size_type size() const
{
return (size_type)CFArrayGetCount(this->m_ptr);
}
bool empty() const
{
return size() == 0;
}
wxCFRef<E> at(size_type idx)
{
wxASSERT(idx < size());
return wxCFRefFromGet((E)CFArrayGetValueAtIndex(this->m_ptr, idx));
}
operator WX_NSArray() { return (WX_NSArray) this->get(); }
wxCFRef<E> operator[](size_type idx) { return at(idx); }
wxCFRef<E> front() { return at(0); }
wxCFRef<E> back() { return at(size() - 1); }
};
template <typename E>
class wxCFArrayRef : public wxCFArrayRefCommon<CFArrayRef, E>
{
public:
wxCFArrayRef(CFArrayRef r)
: wxCFArrayRefCommon<CFArrayRef, E>(r)
{
}
wxCFArrayRef(const wxCFArrayRef& otherRef)
: wxCFArrayRefCommon<CFArrayRef, E>(otherRef)
{
}
};
template <typename E>
class wxCFMutableArrayRef : public wxCFArrayRefCommon<CFMutableArrayRef, E>
{
public:
wxCFMutableArrayRef()
: wxCFArrayRefCommon<CFMutableArrayRef, E>(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks))
{
}
wxCFMutableArrayRef(CFMutableArrayRef r)
: wxCFArrayRefCommon<CFMutableArrayRef, E>(r)
{
}
wxCFMutableArrayRef(const wxCFMutableArrayRef& otherRef)
: wxCFArrayRefCommon<CFMutableArrayRef, E>(otherRef)
{
}
void push_back(E v)
{
CFArrayAppendValue(this->m_ptr, v);
}
void clear()
{
CFArrayRemoveAllValues(this->m_ptr);
}
};
#endif //ifndef _WX_OSX_COREFOUNDATION_CFARRAYREF_H__

View File

@@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfdataref.h
// Purpose: wxCFDataRef class
// Author: Stefan Csomor
// Created: 2007/05/10
// Copyright: (c) 2007 Stefan Csomor
// Licence: wxWindows licence
// Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBinaryData/index.html
/////////////////////////////////////////////////////////////////////////////
/*! @header wx/osx/core/cfdataref.h
@abstract wxCFDataRef template class
*/
#ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__
#define _WX_MAC_COREFOUNDATION_CFDATAREF_H__
#include "wx/osx/core/cfref.h"
#include <CoreFoundation/CFData.h>
/*! @class wxCFDataRef
@discussion Properly retains/releases reference to CoreFoundation data objects
*/
class wxCFDataRef : public wxCFRef< CFDataRef >
{
public:
/*! @method wxCFDataRef
@abstract Creates a null data ref
*/
wxCFDataRef() = default;
typedef wxCFRef<CFDataRef> super_type;
/*! @method wxCFDataRef
@abstract Assumes ownership of r and creates a reference to it.
@param r The data reference to assume ownership of. May be null.
@discussion Like shared_ptr, it is assumed that the caller has a strong reference to r and intends
to transfer ownership of that reference to this ref holder. If the object comes from
a Create or Copy method then this is the correct behaviour. If the object comes from
a Get method then you must CFRetain it yourself before passing it to this constructor.
A handy way to do this is to use the non-member wxCFRefFromGet factory function.
This method is templated and takes an otherType *p. This prevents implicit conversion
using an operator refType() in a different ref-holding class type.
*/
explicit wxCFDataRef(CFDataRef r)
: super_type(r)
{}
/*! @method wxCFDataRef
@abstract Copies a ref holder of the same type
@param otherRef The other ref holder to copy.
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
the object will be explicitly retained by this new ref.
*/
wxCFDataRef(const wxCFDataRef& otherRef)
: super_type( otherRef )
{}
/*! @method wxCFDataRef
@abstract Copies raw data into a data ref
@param data The raw data.
@param length The data length.
*/
wxCFDataRef(const UInt8* data, CFIndex length)
: super_type(CFDataCreate(kCFAllocatorDefault, data, length))
{
}
/*! @method GetLength
@abstract returns the length in bytes of the data stored
*/
CFIndex GetLength() const
{
if ( m_ptr )
return CFDataGetLength( *this );
else
return 0;
}
/*! @method GetBytes
@abstract Copies the data into an external buffer
@param range The desired range.
@param buffer The target buffer.
*/
void GetBytes( CFRange range, UInt8 *buffer ) const
{
if ( m_ptr )
CFDataGetBytes(m_ptr, range, buffer);
}
};
#endif //ifndef _WX_MAC_COREFOUNDATION_CFDATAREF_H__

View File

@@ -0,0 +1,144 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfdictionaryref.h
// Purpose: wxCFDictionaryRef class
// Author: Stefan Csomor
// Created: 2018/07/27
// Copyright: (c) 2018 Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*! @header wx/osx/core/cfdictionaryref.h
@abstract wxCFDictionaryRef class
*/
#ifndef _WX_OSX_COREFOUNDATION_CFDICTIONARYREF_H__
#define _WX_OSX_COREFOUNDATION_CFDICTIONARYREF_H__
#include "wx/osx/core/cfref.h"
#include "wx/osx/core/cfstring.h"
#include "wx/osx/core/cftype.h"
#include <CoreFoundation/CFDictionary.h>
/*! @class wxCFDictionaryRef
@discussion Properly retains/releases reference to CoreFoundation data objects
*/
template <typename T>
class wxCFDictionaryRefCommon : public wxCFRef<T>
{
public:
typedef wxCFRef<T> super_type;
explicit wxCFDictionaryRefCommon()
: super_type()
{
}
/*! @method wxCFDictionaryRef
@abstract Assumes ownership of r and creates a reference to it.
@param r The dictionary reference to assume ownership of. May be null.
@discussion Like shared_ptr, it is assumed that the caller has a strong reference to r and intends
to transfer ownership of that reference to this ref holder. If the object comes from
a Create or Copy method then this is the correct behaviour. If the object comes from
a Get method then you must CFRetain it yourself before passing it to this constructor.
A handy way to do this is to use the non-member wxCFRefFromGet factory function.
This method is templated and takes an otherType *p. This prevents implicit conversion
using an operator refType() in a different ref-holding class type.
*/
explicit wxCFDictionaryRefCommon(T r)
: super_type(r)
{
}
/*! @method wxCFDictionaryRef
@abstract Copies a ref holder of the same type
@param otherRef The other ref holder to copy.
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
the object will be explicitly retained by this new ref.
*/
wxCFDictionaryRefCommon(const wxCFDictionaryRefCommon&) = default;
/*! @method operator=
@abstract Assigns the other ref's pointer to us when the otherRef is the same type.
@param otherRef The other ref holder to copy.
@discussion The incoming pointer is retained, the original pointer is released, and this object
is made to point to the new pointer.
*/
wxCFDictionaryRefCommon& operator=(const wxCFDictionaryRefCommon&) = default;
wxCFTypeRef GetValue(const void* key)
{
CFTypeRef val = CFDictionaryGetValue(this->m_ptr, key);
if (val)
::CFRetain(val);
return val;
}
};
class wxCFMutableDictionaryRef;
class wxCFDictionaryRef : public wxCFDictionaryRefCommon<CFDictionaryRef>
{
public:
wxCFDictionaryRef()
{
}
wxCFDictionaryRef(CFDictionaryRef r)
: wxCFDictionaryRefCommon(r)
{
}
wxCFDictionaryRef& operator=(const wxCFMutableDictionaryRef& other);
CFDictionaryRef CreateCopy() const
{
return CFDictionaryCreateCopy(kCFAllocatorDefault, this->m_ptr);
}
CFMutableDictionaryRef CreateMutableCopy() const
{
return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, this->m_ptr);
}
};
class wxCFMutableDictionaryRef : public wxCFDictionaryRefCommon<CFMutableDictionaryRef>
{
public:
wxCFMutableDictionaryRef()
: wxCFDictionaryRefCommon(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks))
{
}
wxCFMutableDictionaryRef(CFMutableDictionaryRef r)
: wxCFDictionaryRefCommon(r)
{
}
void SetValue(const void* key, const void* data)
{
CFDictionarySetValue(this->m_ptr, key, data);
}
void SetValue(const void* key, CGFloat v)
{
SetValue(key, wxCFNumberRef(v));
}
CFMutableDictionaryRef CreateCopy() const
{
return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, this->m_ptr);
}
friend class wxCFDictionaryRef;
};
inline wxCFDictionaryRef& wxCFDictionaryRef::operator=(const wxCFMutableDictionaryRef& otherRef)
{
wxCFRetain(otherRef.m_ptr);
wxCFRelease(m_ptr);
m_ptr = (CFDictionaryRef)otherRef.m_ptr;
return *this;
}
#endif //ifndef _WX_OSX_COREFOUNDATION_CFDICTIONARYREF_H__

View File

@@ -0,0 +1,445 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfref.h
// Purpose: wxCFRef template class
// Author: David Elliott <dfe@cox.net>
// Modified by: Stefan Csomor
// Created: 2007/05/10
// Copyright: (c) 2007 David Elliott <dfe@cox.net>, Stefan Csomor
// Licence: wxWindows licence
// Notes: See http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/index.html
/////////////////////////////////////////////////////////////////////////////
/*! @header wx/osx/core/cfref.h
@abstract wxCFRef template class
@discussion FIXME: Convert doc tags to something less buggy with C++
*/
#ifndef _WX_MAC_COREFOUNDATION_CFREF_H__
#define _WX_MAC_COREFOUNDATION_CFREF_H__
// Include Availability for __AVAILABILITY_INTERNAL_DEPRECATED
#include <Availability.h>
#if __has_feature(objc_arc)
#define WX_OSX_BRIDGE_RETAINED __bridge_retained
#define WX_OSX_BRIDGE __bridge
#else
#define WX_OSX_BRIDGE_RETAINED
#define WX_OSX_BRIDGE
#endif
// #include <CoreFoundation/CFBase.h>
/* Don't include CFBase.h such that this header can be included from public
* headers with minimal namespace pollution.
* Note that Darwin CF uses extern for CF_EXPORT. If we need this on Win32
* or non-Darwin Mac OS we'll need to define the appropriate __declspec.
*/
typedef const void *CFTypeRef;
extern "C" {
extern /* CF_EXPORT */
CFTypeRef CFRetain(CFTypeRef cf);
extern /* CF_EXPORT */
void CFRelease(CFTypeRef cf);
extern /* CF_EXPORT */
CFTypeRef CFAutorelease(CFTypeRef cf);
} // extern "C"
/*! @function wxCFRelease
@abstract A CFRelease variant that checks for nullptr before releasing.
@discussion The parameter is template not for type safety but to ensure the argument
is a raw pointer and not a ref holder of any type.
*/
template <class Type>
inline void wxCFRelease(Type *r)
{
if ( r != nullptr )
::CFRelease((CFTypeRef)r);
}
/*! @function wxCFAutorelease
@abstract A CFAutorelease variant that checks for nullptr before releasing.
@discussion The parameter is template not for type safety but to ensure the argument
is a raw pointer and not a ref holder of any type.
*/
template <class Type>
inline Type* wxCFAutorelease(Type *r)
{
if ( r != nullptr )
r = const_cast<Type*>(static_cast<const Type*>(::CFAutorelease(static_cast<CFTypeRef>(r))));
return r;
}
/*! @function wxCFRetain
@abstract A typesafe CFRetain variant that checks for nullptr.
*/
template <class Type>
inline Type* wxCFRetain(Type *r)
{
// NOTE(DE): Setting r to the result of CFRetain improves efficiency on both x86 and PPC
// Casting r to CFTypeRef ensures we are calling the real C version defined in CFBase.h
// and not any possibly templated/overloaded CFRetain.
if ( r != nullptr )
r = const_cast<Type*>(static_cast<const Type*>(::CFRetain(static_cast<CFTypeRef>(r))));
return r;
}
template <class refType>
class wxCFRef;
/*! @class wxCFWeakRef
@templatefield refType The CF reference type (e.g. CFStringRef, CFRunLoopRef, etc.)
It should already be a pointer. This is different from
shared_ptr where the template parameter is the pointee type.
@discussion Wraps a raw pointer without any retain or release.
Provides a way to get what amounts to a raw pointer from a wxCFRef without
using a raw pointer. Unlike a raw pointer, constructing a wxCFRef from this
class will cause it to be retained because it is assumed that a wxCFWeakRef
does not own its pointer.
*/
template <class refType>
class wxCFWeakRef
{
template <class refTypeA, class otherRefType>
friend wxCFWeakRef<refTypeA> static_cfref_cast(const wxCFRef<otherRefType> &otherRef);
public:
/*! @method wxCFWeakRef
@abstract Creates a null reference
*/
wxCFWeakRef()
: m_ptr(nullptr)
{}
// Default copy constructor is fine.
// Default destructor is fine but we'll set the pointer to nullptr to avoid bugs
~wxCFWeakRef()
{ m_ptr = nullptr; }
// Do not implement a raw-pointer constructor.
/*! @method wxCFWeakRef
@abstract Copies another ref holder where its type can be converted to ours
@templatefield otherRefType Any type held by another wxCFWeakRef.
@param otherRef The other weak ref holder to copy.
@discussion This is merely a copy or implicit cast.
*/
template <class otherRefType>
wxCFWeakRef(const wxCFWeakRef<otherRefType>& otherRef)
: m_ptr(otherRef.get()) // Implicit conversion from otherRefType to refType should occur
{}
/*! @method wxCFWeakRef
@abstract Copies a strong ref holder where its type can be converted to ours
@templatefield otherRefType Any type held by a wxCFRef.
@param otherRef The strong ref holder to copy.
@discussion This ref is merely a pointer copy, the strong ref still holds the pointer.
*/
template <class otherRefType>
wxCFWeakRef(const wxCFRef<otherRefType>& otherRef)
: m_ptr(otherRef.get()) // Implicit conversion from otherRefType to refType should occur
{}
/*! @method get
@abstract Explicit conversion to the underlying pointer type
@discussion Allows the caller to explicitly get the underlying pointer.
*/
refType get() const
{ return m_ptr; }
/*! @method operator refType
@abstract Implicit conversion to the underlying pointer type
@discussion Allows the ref to be used in CF function calls.
*/
operator refType() const
{ return m_ptr; }
protected:
/*! @method wxCFWeakRef
@abstract Constructs a weak reference to the raw pointer
@templatefield otherType Any type.
@param p The raw pointer to assume ownership of. May be null.
@discussion This method is private so that the friend static_cfref_cast can use it
*/
template <class otherType>
explicit wxCFWeakRef(otherType *p)
: m_ptr(p) // Implicit conversion from otherType* to refType should occur.
{}
/*! @var m_ptr The raw pointer.
*/
refType m_ptr;
};
/*! @class wxCFRef
@templatefield refType The CF reference type (e.g. CFStringRef, CFRunLoopRef, etc.)
It should already be a pointer. This is different from
shared_ptr where the template parameter is the pointee type.
@discussion Properly retains/releases reference to CoreFoundation objects
*/
template <class refType>
class wxCFRef
{
public:
/*! @method wxCFRef
@abstract Creates a null reference
*/
wxCFRef()
: m_ptr(nullptr)
{}
/*! @method wxCFRef
@abstract Assumes ownership of p and creates a reference to it.
@param p The raw core foundation reference to assume ownership of. May be null.
@discussion Like shared_ptr, it is assumed that the caller has a strong reference to p and intends
to transfer ownership of that reference to this ref holder. If the object comes from
a Create or Copy method then this is the correct behaviour. If the object comes from
a Get method then you must CFRetain it yourself before passing it to this constructor.
A handy way to do this is to use the non-member wxCFRefFromGet factory function.
*/
wxCFRef(refType p) : m_ptr(p)
{
}
/*! @method wxCFRef
@abstract Assumes ownership of p and creates a reference to it.
@templatefield otherType Any type.
@param p The raw pointer to assume ownership of. May be null.
@discussion Like shared_ptr, it is assumed that the caller has a strong reference to p and intends
to transfer ownership of that reference to this ref holder. If the object comes from
a Create or Copy method then this is the correct behaviour. If the object comes from
a Get method then you must CFRetain it yourself before passing it to this constructor.
A handy way to do this is to use the non-member wxCFRefFromGet factory function.
This method is templated and takes an otherType *p. This prevents implicit conversion
using an operator refType() in a different ref-holding class type.
*/
template <class otherType>
explicit wxCFRef(otherType *p)
: m_ptr(p) // Implicit conversion from otherType* to refType should occur.
{}
/*! @method wxCFRef
@abstract Copies a ref holder of the same type
@param otherRef The other ref holder to copy.
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
the object will be explicitly retained by this new ref.
*/
wxCFRef(const wxCFRef& otherRef)
: m_ptr(wxCFRetain(otherRef.m_ptr))
{}
/*! @method wxCFRef
@abstract Copies a ref holder where its type can be converted to ours
@templatefield otherRefType Any type held by another wxCFRef.
@param otherRef The other ref holder to copy.
@discussion Ownership will be shared by the original ref and the newly created ref. That is,
the object will be explicitly retained by this new ref.
*/
template <class otherRefType>
wxCFRef(const wxCFRef<otherRefType>& otherRef)
: m_ptr(wxCFRetain(otherRef.get())) // Implicit conversion from otherRefType to refType should occur
{}
/*! @method wxCFRef
@abstract Copies a weak ref holder where its type can be converted to ours
@templatefield otherRefType Any type held by a wxCFWeakRef.
@param otherRef The weak ref holder to copy.
@discussion Ownership will be taken by this newly created ref. That is,
the object will be explicitly retained by this new ref.
Ownership is most likely shared with some other ref as well.
*/
template <class otherRefType>
wxCFRef(const wxCFWeakRef<otherRefType>& otherRef)
: m_ptr(wxCFRetain(otherRef.get())) // Implicit conversion from otherRefType to refType should occur
{}
/*! @method ~wxCFRef
@abstract Releases (potentially shared) ownership of the ref.
@discussion A ref holder instance is always assumed to have ownership so ownership is always
released (CFRelease called) upon destruction.
*/
~wxCFRef()
{ reset(); }
/*! @method operator=
@abstract Assigns the other ref's pointer to us when the otherRef is the same type.
@param otherRef The other ref holder to copy.
@discussion The incoming pointer is retained, the original pointer is released, and this object
is made to point to the new pointer.
*/
wxCFRef& operator=(const wxCFRef& otherRef)
{
if (this != &otherRef)
{
wxCFRetain(otherRef.m_ptr);
wxCFRelease(m_ptr);
m_ptr = otherRef.m_ptr;
}
return *this;
}
/*! @method operator=
@abstract Assigns the other ref's pointer to us when the other ref can be converted to our type.
@templatefield otherRefType Any type held by another wxCFRef
@param otherRef The other ref holder to copy.
@discussion The incoming pointer is retained, the original pointer is released, and this object
is made to point to the new pointer.
*/
template <class otherRefType>
wxCFRef& operator=(const wxCFRef<otherRefType>& otherRef)
{
wxCFRetain(otherRef.get());
wxCFRelease(m_ptr);
m_ptr = otherRef.get(); // Implicit conversion from otherRefType to refType should occur
return *this;
}
/*! @method get
@abstract Explicit conversion to the underlying pointer type
@discussion Allows the caller to explicitly get the underlying pointer.
*/
refType get() const
{ return m_ptr; }
/*! @method operator refType
@abstract Implicit conversion to the underlying pointer type
@discussion Allows the ref to be used in CF function calls.
*/
operator refType() const
{ return m_ptr; }
#if 0
< // HeaderDoc is retarded and thinks the GT from operator-> is part of a template param.
// So give it that < outside of a comment to fake it out. (if 0 is not a comment to HeaderDoc)
#endif
/*! @method operator-&gt;
@abstract Implicit conversion to the underlying pointer type
@discussion This is nearly useless for CF types which are nearly always opaque
*/
refType operator-> () const
{ return m_ptr; }
/*! @method reset
@abstract Nullifies the reference
@discussion Releases ownership (calls CFRelease) before nullifying the pointer.
*/
void reset()
{
wxCFRelease(m_ptr);
m_ptr = nullptr;
}
/*! @method reset
@abstract Sets this to a new reference
@templatefield otherType Any type.
@param p The raw pointer to assume ownership of
@discussion The existing reference is released (like destruction). It is assumed that the caller
has a strong reference to the new p and intends to transfer ownership of that reference
to this ref holder. Take care to call CFRetain if you received the object from a Get method.
This method is templated and takes an otherType *p. This prevents implicit conversion
using an operator refType() in a different ref-holding class type.
*/
template <class otherType>
void reset(otherType* p)
{
wxCFRelease(m_ptr);
m_ptr = p; // Automatic conversion should occur
}
// Release the pointer, i.e. give up its ownership.
refType release()
{
refType p = m_ptr;
m_ptr = nullptr;
return p;
}
// Autorelease the pointer, i.e. during the next cleanup it will be released
refType autorelease()
{
refType p = m_ptr;
m_ptr = nullptr;
return wxCFAutorelease(p);
}
protected:
/*! @var m_ptr The raw pointer.
*/
refType m_ptr;
};
/*! @function wxCFRefFromGet
@abstract Factory function to create wxCFRef from a raw pointer obtained from a Get-rule function
@param p The pointer to retain and create a wxCFRef from. May be null.
@discussion Unlike the wxCFRef raw pointer constructor, this function explicitly retains its
argument. This can be used for functions such as CFDictionaryGetValue() or
CFAttributedStringGetString() which return a temporary reference (Get-rule functions).
FIXME: Anybody got a better name?
*/
template <typename Type>
inline wxCFRef<Type*> wxCFRefFromGet(Type *p)
{
return wxCFRef<Type*>(wxCFRetain(p));
}
/*! @function static_cfref_cast
@abstract Works like static_cast but with a wxCFRef as the argument.
@param refType Template parameter. The destination raw pointer type
@param otherRef Normal parameter. The source wxCFRef<> object.
@discussion This is intended to be a clever way to make static_cast work while allowing
the return value to be converted to either a strong ref or a raw pointer
while ensuring that the retain count is updated appropriately.
This is modeled after shared_ptr's static_pointer_cast. Just as wxCFRef is
parameterized on a pointer to an opaque type so is this class. Note that
this differs from shared_ptr which is parameterized on the pointee type.
FIXME: Anybody got a better name?
*/
template <class refType, class otherRefType>
inline wxCFWeakRef<refType> static_cfref_cast(const wxCFRef<otherRefType> &otherRef);
template <class refType, class otherRefType>
inline wxCFWeakRef<refType> static_cfref_cast(const wxCFRef<otherRefType> &otherRef)
{
return wxCFWeakRef<refType>(static_cast<refType>(otherRef.get()));
}
/*! @function CFRelease
@abstract Overloads CFRelease so that the user is warned of bad behaviour.
@discussion It is rarely appropriate to retain or release a wxCFRef. If one absolutely
must do it he can explicitly get() the raw pointer
Normally, this function is unimplemented resulting in a linker error if used.
*/
template <class T>
inline void CFRelease(const wxCFRef<T*> & cfref) __AVAILABILITY_INTERNAL_DEPRECATED;
/*! @function CFRetain
@abstract Overloads CFRetain so that the user is warned of bad behaviour.
@discussion It is rarely appropriate to retain or release a wxCFRef. If one absolutely
must do it he can explicitly get() the raw pointer
Normally, this function is unimplemented resulting in a linker error if used.
*/
template <class T>
inline void CFRetain(const wxCFRef<T*>& cfref) __AVAILABILITY_INTERNAL_DEPRECATED;
// Change the 0 to a 1 if you want the functions to work (no link errors)
// Neither function will cause retain/release side-effects if implemented.
#if 0
template <class T>
void CFRelease(const wxCFRef<T*> & cfref)
{
CFRelease(cfref.get());
}
template <class T>
void CFRetain(const wxCFRef<T*> & cfref)
{
CFRetain(cfref.get());
}
#endif
#endif //ndef _WX_MAC_COREFOUNDATION_CFREF_H__

View File

@@ -0,0 +1,97 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cfstring.h
// Purpose: wxCFStringRef and other string functions
// Author: Stefan Csomor
// Created: 2004-10-29 (from code in wx/mac/carbon/private.h)
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
// Usage: Darwin (base library)
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_CFSTRINGHOLDER_H__
#define __WX_CFSTRINGHOLDER_H__
#include "wx/dlimpexp.h"
#include "wx/fontenc.h"
#include "wx/osx/core/cfref.h"
#ifdef WORDS_BIGENDIAN
#define kCFStringEncodingUTF32Native kCFStringEncodingUTF32BE
#else
#define kCFStringEncodingUTF32Native kCFStringEncodingUTF32LE
#endif
class WXDLLIMPEXP_FWD_BASE wxString;
WXDLLIMPEXP_BASE wxString wxMacConvertNewlines13To10(const wxString& data);
WXDLLIMPEXP_BASE wxString wxMacConvertNewlines10To13(const wxString& data);
WXDLLIMPEXP_BASE wxUint32 wxMacGetSystemEncFromFontEnc(wxFontEncoding encoding) ;
WXDLLIMPEXP_BASE wxFontEncoding wxMacGetFontEncFromSystemEnc(wxUint32 encoding) ;
WXDLLIMPEXP_BASE void wxMacWakeUp() ;
class WXDLLIMPEXP_BASE wxCFStringRef : public wxCFRef< CFStringRef >
{
public:
wxCFStringRef()
{
}
wxCFStringRef(const wxString &str);
#ifdef __OBJC__
wxCFStringRef(WX_NSString ref)
: wxCFRef< CFStringRef >((WX_OSX_BRIDGE_RETAINED CFStringRef) ref)
{
}
#endif
wxCFStringRef(CFStringRef ref)
: wxCFRef< CFStringRef >(ref)
{
}
wxCFStringRef(const wxCFStringRef& otherRef )
: wxCFRef< CFStringRef >(otherRef)
{
}
~wxCFStringRef()
{
}
wxString AsString() const;
static wxString AsString( CFStringRef ref ) ;
static wxString AsStringWithNormalizationFormC( CFStringRef ref ) ;
static wxString AsString( WX_NSString ref ) ;
static wxString AsStringWithNormalizationFormC( WX_NSString ref ) ;
#ifdef __OBJC__
WX_NSString AsNSString() const { return (WX_OSX_BRIDGE WX_NSString)(CFStringRef) *this; }
#endif
private:
} ;
/*! @function wxCFStringRefFromGet
@abstract Factory function to create wxCFStringRefRef from a CFStringRef obtained from a Get-rule function
@param p The CFStringRef to retain and create a wxCFStringRefRef from. May be null.
@discussion Unlike the wxCFStringRef raw pointer constructor, this function explicitly retains its
argument. This can be used for functions ) which return a temporary reference (Get-rule functions).
*/
inline wxCFStringRef wxCFStringRefFromGet(CFStringRef p)
{
return wxCFStringRef(wxCFRetain(p));
}
/*! @function wxCFStringRefFromGet
@abstract Factory function to create wxCFStringRefRef from a NSString* obtained from a Get-rule function
@param p The NSString pointer to retain and create a wxCFStringRefRef from. May be null.
@discussion Unlike the wxCFStringRef raw pointer constructor, this function explicitly retains its
argument. This can be used for functions ) which return a temporary reference (Get-rule functions).
*/
inline wxCFStringRef wxCFStringRefFromGet(NSString *p)
{
return wxCFStringRefFromGet((WX_OSX_BRIDGE CFStringRef)p);
}
#endif //__WXCFSTRINGHOLDER_H__

View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/cftype.h
// Purpose: wxCFDictionaryRef class
// Author: Stefan Csomor
// Created: 2018/07/27
// Copyright: (c) 2018 Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*! @header wx/osx/core/cftype.h
@abstract wxCFTypeRef class and derived classes
*/
#ifndef _WX_OSX_COREFOUNDATION_CFTYPEREF_H__
#define _WX_OSX_COREFOUNDATION_CFTYPEREF_H__
#include "wx/osx/core/cfref.h"
#include "wx/osx/core/cfstring.h"
#ifndef WX_PRECOMP
#include "wx/string.h"
#endif
class wxCFTypeRef : public wxCFRef<CFTypeRef>
{
public:
typedef wxCFRef<CFTypeRef> super_type;
wxCFTypeRef(CFTypeRef d)
: super_type(d)
{
}
template <typename V>
bool GetValue(V* ptr) const;
template <typename V>
bool GetValue(V* ptr, V defaultValue) const
{
bool hasKey = GetValue(ptr);
if (!hasKey)
*ptr = defaultValue;
return hasKey;
}
template <typename V>
bool GetValue(V& ref) const
{
return GetValue(&ref);
}
template <typename V>
bool GetValue(V& ref, V defaultValue) const
{
bool hasKey = GetValue(ref);
if (!hasKey)
ref = defaultValue;
return hasKey;
}
// spezialization through overload
bool GetValue(CGFloat* ptr) const
{
if (m_ptr)
CFNumberGetValue((CFNumberRef)m_ptr, kCFNumberCGFloatType, ptr);
return m_ptr;
}
bool GetValue(int32_t* ptr) const
{
if (m_ptr)
CFNumberGetValue((CFNumberRef)m_ptr, kCFNumberSInt32Type, ptr);
return m_ptr;
}
bool GetValue(uint32_t* ptr) const
{
if (m_ptr)
CFNumberGetValue((CFNumberRef)m_ptr, kCFNumberSInt32Type, ptr);
return m_ptr;
}
bool GetValue(int64_t* ptr) const
{
if (m_ptr)
CFNumberGetValue((CFNumberRef)m_ptr, kCFNumberSInt64Type, ptr);
return m_ptr;
}
bool GetValue(uint64_t* ptr) const
{
if (m_ptr)
CFNumberGetValue((CFNumberRef)m_ptr, kCFNumberSInt64Type, ptr);
return m_ptr;
}
bool GetValue(wxString* s) const
{
if (m_ptr)
*s = wxCFStringRef::AsString((CFStringRef)m_ptr);
return m_ptr;
}
};
class wxCFNumberRef : public wxCFTypeRef
{
public:
wxCFNumberRef(CGFloat v)
: wxCFTypeRef(CFNumberCreate(nullptr, kCFNumberCGFloatType, &v))
{
}
wxCFNumberRef(int v)
: wxCFTypeRef(CFNumberCreate(nullptr, kCFNumberIntType, &v))
{
}
};
#endif //ifndef _WX_OSX_COREFOUNDATION_CFTYPEREF_H__

View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/colour.h
// Purpose: wxColour class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOUR_H_
#define _WX_COLOUR_H_
#include "wx/object.h"
#include "wx/string.h"
#include "wx/osx/core/cfref.h"
struct RGBColor;
// Colour
class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour: public wxColourBase
{
public:
// constructors
// ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// default copy ctor and dtor are ok
// accessors
virtual ChannelType Red() const override;
virtual ChannelType Green() const override;
virtual ChannelType Blue() const override;
virtual ChannelType Alpha() const override;
virtual bool IsSolid() const override;
// comparison
bool operator == (const wxColour& colour) const;
bool operator != (const wxColour& colour) const { return !(*this == colour); }
// CoreGraphics CGColor
// --------------------
// This ctor does take ownership of the color.
wxColour( CGColorRef col );
// don't take ownership of the returned value
CGColorRef GetCGColor() const;
// do take ownership of the returned value
CGColorRef CreateCGColor() const { return wxCFRetain(GetCGColor()); }
#if wxOSX_USE_COCOA_OR_CARBON
// Quickdraw RGBColor
// ------------------
wxColour(const RGBColor& col);
void GetRGBColor( RGBColor *col ) const;
#endif
#if wxOSX_USE_COCOA
// NSColor Cocoa
// -------------
// This ctor does not take ownership of the color.
explicit wxColour(WX_NSColor color);
WX_NSColor OSXGetNSColor() const;
WX_NSImage OSXGetNSPatternImage() const;
#endif
protected :
virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) override;
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
wxDECLARE_DYNAMIC_CLASS(wxColour);
};
class wxColourRefData : public wxGDIRefData
{
public:
wxColourRefData() = default;
virtual ~wxColourRefData() = default;
virtual double Red() const = 0;
virtual double Green() const = 0;
virtual double Blue() const = 0;
virtual double Alpha() const = 0;
virtual bool IsSolid() const
{ return true; }
virtual CGColorRef GetCGColor() const = 0;
wxNODISCARD virtual wxColourRefData* Clone() const = 0;
#if wxOSX_USE_COCOA
virtual WX_NSColor GetNSColor() const;
virtual WX_NSImage GetNSPatternImage() const;
#endif
};
#endif
// _WX_COLOUR_H_

View File

@@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/dataview.h
// Purpose: wxDataViewCtrl native implementation header for OSX
// Author:
// Copyright: (c) 2009
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAVIEWCTRL_CORE_H_
#define _WX_DATAVIEWCTRL_CORE_H_
#include "wx/dataview.h"
typedef wxWidgetImpl wxWidgetImplType;
// ---------------------------------------------------------
// Helper functions for dataview implementation on OSX
// ---------------------------------------------------------
wxWidgetImplType* CreateDataView(wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID id,
wxPoint const& pos, wxSize const& size,
long style, long extraStyle);
wxString ConcatenateDataViewItemValues(wxDataViewCtrl const* dataViewCtrlPtr, wxDataViewItem const& dataViewItem); // concatenates all data of the visible columns of the passed control
// and item TAB separated into a string and returns it
// ---------------------------------------------------------
// wxDataViewWidgetImpl
// Common interface of the native dataview implementation
// for the carbon and cocoa environment.
// ATTENTION
// All methods assume that the passed column pointers are
// valid (unless a null pointer is explicitly allowed
// to be passed)!
// ATTENTION
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewWidgetImpl
{
public:
//
// constructors / destructor
//
virtual ~wxDataViewWidgetImpl()
{
}
//
// column related methods
//
virtual bool ClearColumns() = 0; // deletes all columns in the native control
virtual bool DeleteColumn (wxDataViewColumn* columnPtr) = 0; // deletes the column in the native control
virtual void DoSetExpanderColumn(wxDataViewColumn const* columnPtr) = 0; // sets the disclosure column in the native control
virtual wxDataViewColumn* GetColumn (unsigned int pos) const = 0; // returns the column belonging to 'pos' in the native control
virtual int GetColumnPosition (wxDataViewColumn const* columnPtr) const = 0; // returns the position of the passed column in the native control
virtual bool InsertColumn (unsigned int pos, wxDataViewColumn* columnPtr) = 0; // inserts a column at pos in the native control;
// the method can assume that the column's owner is already set
virtual void FitColumnWidthToContent(unsigned int pos) = 0; // resizes column to fit its content
//
// item related methods
//
virtual bool Add (wxDataViewItem const& parent, wxDataViewItem const& item) = 0; // adds an item to the native control
virtual bool Add (wxDataViewItem const& parent, wxDataViewItemArray const& items) = 0; // adds items to the native control
virtual void Collapse (wxDataViewItem const& item) = 0; // collapses the passed item in the native control
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) = 0; // ensures that the passed item's value in the passed column is visible (column pointer can be null)
virtual unsigned int GetCount() const = 0; // returns the number of items in the native control
virtual int GetCountPerPage() const = 0; // get number of items that fit into a single page
virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr) = 0; // returns the rectangle that is used by the passed item and column in the native control
virtual wxDataViewItem GetTopItem() const = 0; // get top-most visible item
virtual bool IsExpanded (wxDataViewItem const& item) const = 0; // checks if the passed item is expanded in the native control
virtual bool Reload() = 0; // clears the native control and reloads all data
virtual bool Remove (wxDataViewItem const& parent) = 0; // removes one or more items under the given parent from the native control
virtual bool Update (wxDataViewColumn const* columnPtr) = 0; // updates the items in the passed column of the native control
virtual bool Update (wxDataViewItem const& parent, wxDataViewItem const& item) = 0; // updates the passed item in the native control
virtual bool Update (wxDataViewItem const& parent, wxDataViewItemArray const& items) = 0; // updates the passed items in the native control
//
// model related methods
//
virtual bool AssociateModel(wxDataViewModel* model) = 0; // informs the native control that a model is present
//
// selection related methods
//
virtual wxDataViewItem GetCurrentItem() const = 0;
virtual void SetCurrentItem(const wxDataViewItem& item) = 0;
virtual wxDataViewColumn *GetCurrentColumn() const = 0;
virtual int GetSelectedItemsCount() const = 0;
virtual int GetSelections(wxDataViewItemArray& sel) const = 0; // returns all selected items in the native control
virtual bool IsSelected (wxDataViewItem const& item) const = 0; // checks if the passed item is selected in the native control
virtual void Select (wxDataViewItem const& item) = 0; // selects the passed item in the native control
virtual void Select (wxDataViewItemArray const& items) = 0; // selects the passed items in the native control
virtual void SelectAll() = 0; // selects all items in the native control
virtual void Unselect (wxDataViewItem const& item) = 0; // unselects the passed item in the native control
virtual void UnselectAll() = 0; // unselects all items in the native control
//
// sorting related methods
//
virtual wxDataViewColumn* GetSortingColumn() const = 0; // returns the column that is primarily responsible for sorting in the native control
virtual void Resort() = 0; // asks the native control to start a resorting process
//
// other methods
//
virtual void DoSetIndent (int indent) = 0; // sets the indentation in the native control
virtual void DoExpand (wxDataViewItem const& item, bool expandChildren) = 0; // expands the passed item in the native control
virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const = 0; // return the item and column pointer that contains with the passed point
virtual void SetRowHeight(int height) = 0; // sets the height of all rows
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height) = 0; // sets the height of the row containing the passed item in the native control
virtual void OnSize() = 0; // updates the layout of the native control after a size event
virtual void StartEditor( const wxDataViewItem & item, unsigned int column ) = 0; // starts editing the passed in item and column
};
#endif // _WX_DATAVIEWCTRL_CORE_H_

View File

@@ -0,0 +1,116 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/evtloop.h
// Purpose: CoreFoundation-based event loop
// Author: Vadim Zeitlin
// Created: 2006-01-12
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_CORE_EVTLOOP_H_
#define _WX_OSX_CORE_EVTLOOP_H_
DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoop )
DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopObserver )
class WXDLLIMPEXP_FWD_BASE wxCFEventLoopPauseIdleEvents;
class WXDLLIMPEXP_BASE wxCFEventLoop : public wxEventLoopBase
{
friend class wxCFEventLoopPauseIdleEvents;
public:
wxCFEventLoop();
virtual ~wxCFEventLoop();
// return true if any events are available
virtual bool Pending() const override;
// dispatch a single event, return false if we should exit from the loop
virtual bool Dispatch() override;
// same as Dispatch() but doesn't wait for longer than the specified (in
// ms) timeout, return true if an event was processed, false if we should
// exit the loop or -1 if timeout expired
virtual int DispatchTimeout(unsigned long timeout) override;
// implement this to wake up the loop: usually done by posting a dummy event
// to it (can be called from non main thread)
virtual void WakeUp() override;
bool ShouldProcessIdleEvents() const { return m_processIdleEvents ; }
#if wxUSE_UIACTIONSIMULATOR
// notifies Yield and Dispatch to wait for at least one event before
// returning, this is necessary, because the synthesized events need to be
// converted by the OS before being available on the native event queue
void SetShouldWaitForEvent(bool should) { m_shouldWaitForEvent = should; }
#endif
protected:
// enters a loop calling OnNextIteration(), Pending() and Dispatch() and
// terminating when Exit() is called
virtual int DoRun() override;
// actually stops the currently running loop
virtual void DoStop(int rc) override;
// may be overridden to perform some action at the start of each new event
// loop iteration
virtual void OnNextIteration() {}
virtual void DoYieldFor(long eventsToProcess) override;
void CommonModeObserverCallBack(CFRunLoopObserverRef observer, int activity);
void DefaultModeObserverCallBack(CFRunLoopObserverRef observer, int activity);
// set to false to avoid idling at unexpected moments - eg when having native message boxes
void SetProcessIdleEvents(bool process) { m_processIdleEvents = process; }
static void OSXCommonModeObserverCallBack(CFRunLoopObserverRef observer, int activity, void *info);
static void OSXDefaultModeObserverCallBack(CFRunLoopObserverRef observer, int activity, void *info);
// get the currently executing CFRunLoop
virtual CFRunLoopRef CFGetCurrentRunLoop() const;
virtual int DoDispatchTimeout(unsigned long timeout);
virtual void OSXDoRun();
virtual void OSXDoStop();
// the loop exit code
int m_exitcode;
// cfrunloop
CFRunLoopRef m_runLoop;
// common modes runloop observer
CFRunLoopObserverRef m_commonModeRunLoopObserver;
// default mode runloop observer
CFRunLoopObserverRef m_defaultModeRunLoopObserver;
// set to false to avoid idling at unexpected moments - eg when having native message boxes
bool m_processIdleEvents;
#if wxUSE_UIACTIONSIMULATOR
bool m_shouldWaitForEvent;
#endif
private:
// process all already pending events and dispatch a new one (blocking
// until it appears in the event queue if necessary)
//
// returns the return value of DoDispatchTimeout()
int DoProcessEvents();
wxDECLARE_NO_COPY_CLASS(wxCFEventLoop);
};
class WXDLLIMPEXP_BASE wxCFEventLoopPauseIdleEvents : public wxObject
{
public:
wxCFEventLoopPauseIdleEvents();
virtual ~wxCFEventLoopPauseIdleEvents();
private:
bool m_formerState;
};
#endif // _WX_OSX_EVTLOOP_H_

View File

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/hid.h
// Purpose: DARWIN HID layer for WX
// Author: Ryan Norton
// Created: 11/11/2003
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ===========================================================================
// declarations
// ===========================================================================
// ---------------------------------------------------------------------------
// headers
// ---------------------------------------------------------------------------
#ifndef _WX_MACCARBONHID_H_
#define _WX_MACCARBONHID_H_
#include "wx/defs.h"
#include "wx/string.h"
//Mac OSX only
#ifdef __DARWIN__
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
//Darn apple - doesn't properly wrap their headers in extern "C"!
//http://www.macosx.com/forums/archive/index.php/t-68069.html
extern "C" {
#include <mach/mach_port.h>
}
#include <mach/mach.h> //this actually includes mach_port.h (see above)
// ===========================================================================
// definitions
// ===========================================================================
// ---------------------------------------------------------------------------
// wxHIDDevice
//
// A wrapper around OS X HID Manager procedures.
// The tutorial "Working With HID Class Device Interfaces" Is
// Quite good, as is the sample program associated with it
// (Depite the author's protests!).
// ---------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxHIDDevice
{
public:
wxHIDDevice() : m_ppDevice(nullptr), m_ppQueue(nullptr), m_pCookies(nullptr) {}
bool Create (int nClass = -1, int nType = -1, int nDev = 1);
static size_t GetCount(int nClass = -1, int nType = -1);
void AddCookie(CFTypeRef Data, int i);
void AddCookieInQueue(CFTypeRef Data, int i);
void InitCookies(size_t dwSize, bool bQueue = false);
//Must be implemented by derived classes
//builds the cookie array -
//first call InitCookies to initialize the cookie
//array, then AddCookie to add a cookie at a certain point in an array
virtual void BuildCookies(CFArrayRef Array) = 0;
//checks to see whether the cookie at nIndex is active (element value != 0)
bool IsActive(int nIndex);
//checks to see whether an element in the internal cookie array
//exists
bool HasElement(int nIndex);
//closes the device and cleans the queue and cookies
virtual ~wxHIDDevice();
protected:
IOHIDDeviceInterface** m_ppDevice; //this, essentially
IOHIDQueueInterface** m_ppQueue; //queue (if we want one)
IOHIDElementCookie* m_pCookies; //cookies
wxString m_szProductName; //product name
int m_nProductId; //product id
int m_nManufacturerId; //manufacturer id
mach_port_t m_pPort; //mach port to use
};
// ---------------------------------------------------------------------------
// wxHIDKeyboard
//
// Semi-simple implementation that opens a connection to the first
// keyboard of the machine. Used in wxGetKeyState.
// ---------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxHIDKeyboard : public wxHIDDevice
{
public:
static int GetCount();
bool Create(int nDev = 1);
void AddCookie(CFTypeRef Data, int i);
virtual void BuildCookies(CFArrayRef Array) override;
void DoBuildCookies(CFArrayRef Array);
};
#endif //__DARWIN__
#endif
// _WX_MACCARBONHID_H_

View File

@@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/joystick.h
// Purpose: wxJoystick class
// Author: Ryan Norton
// Created: 2/13/2005
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_JOYSTICK_H_
#define _WX_JOYSTICK_H_
#include "wx/event.h"
class WXDLLIMPEXP_FWD_CORE wxJoystickThread;
class WXDLLIMPEXP_ADV wxJoystick: public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wxJoystick);
public:
wxJoystick(int joystick = wxJOYSTICK1);
virtual ~wxJoystick();
// Attributes
////////////////////////////////////////////////////////////////////////////
wxPoint GetPosition() const;
int GetPosition(unsigned axis) const;
bool GetButtonState(unsigned button) const;
int GetZPosition() const;
int GetButtonState() const;
int GetPOVPosition() const;
int GetPOVCTSPosition() const;
int GetRudderPosition() const;
int GetUPosition() const;
int GetVPosition() const;
int GetMovementThreshold() const;
void SetMovementThreshold(int threshold) ;
// Capabilities
////////////////////////////////////////////////////////////////////////////
bool IsOk() const; // Checks that the joystick is functioning
static int GetNumberJoysticks() ;
int GetManufacturerId() const ;
int GetProductId() const ;
wxString GetProductName() const ;
int GetXMin() const;
int GetYMin() const;
int GetZMin() const;
int GetXMax() const;
int GetYMax() const;
int GetZMax() const;
int GetNumberButtons() const;
int GetNumberAxes() const;
int GetMaxButtons() const;
int GetMaxAxes() const;
int GetPollingMin() const;
int GetPollingMax() const;
int GetRudderMin() const;
int GetRudderMax() const;
int GetUMin() const;
int GetUMax() const;
int GetVMin() const;
int GetVMax() const;
bool HasRudder() const;
bool HasZ() const;
bool HasU() const;
bool HasV() const;
bool HasPOV() const;
bool HasPOV4Dir() const;
bool HasPOVCTS() const;
// Operations
////////////////////////////////////////////////////////////////////////////
// pollingFreq = 0 means that movement events are sent when above the threshold.
// If pollingFreq > 0, events are received every this many milliseconds.
bool SetCapture(wxWindow* win, int pollingFreq = 0);
bool ReleaseCapture();
protected:
int m_joystick;
wxJoystickThread* m_thread;
class wxHIDJoystick* m_hid;
};
#endif
// _WX_JOYSTICK_H_

View File

@@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/mimetype.h
// Purpose: Mac implementation for wx mime-related classes
// Author: Neil Perkins
// Created: 2010-05-15
// Copyright: (C) 2010 Neil Perkins
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _MIMETYPE_IMPL_H
#define _MIMETYPE_IMPL_H
#include "wx/defs.h"
#if wxUSE_MIMETYPE
#include "wx/mimetype.h"
#include "wx/iconloc.h"
#include <unordered_map>
// This class implements mime type functionality for Mac OS X using UTIs and Launch Services
// Currently only the GetFileTypeFromXXXX public functions have been implemented
class WXDLLIMPEXP_BASE wxMimeTypesManagerImpl
{
public:
wxMimeTypesManagerImpl();
virtual ~wxMimeTypesManagerImpl();
// These functions are not needed on Mac OS X and have no-op implementations
void Initialize(int mailcapStyles = wxMAILCAP_STANDARD, const wxString& extraDir = wxEmptyString);
void ClearData();
// Functions to look up types by ext, mime or UTI
wxFileType *GetFileTypeFromExtension(const wxString& ext);
wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
wxFileType *GetFileTypeFromUti(const wxString& uti);
// These functions are only stubs on Mac OS X
size_t EnumAllFileTypes(wxArrayString& mimetypes);
wxFileType *Associate(const wxFileTypeInfo& ftInfo);
bool Unassociate(wxFileType *ft);
private:
// The work of querying the OS for type data is done in these two functions
void LoadTypeDataForUti(const wxString& uti);
void LoadDisplayDataForUti(const wxString& uti);
// These functions are pass-throughs from wxFileTypeImpl
bool GetExtensions(const wxString& uti, wxArrayString& extensions);
bool GetMimeType(const wxString& uti, wxString *mimeType);
bool GetMimeTypes(const wxString& uti, wxArrayString& mimeTypes);
bool GetIcon(const wxString& uti, wxIconLocation *iconLoc);
bool GetDescription(const wxString& uti, wxString *desc);
bool GetApplication(const wxString& uti, wxString *command);
// Structure to represent file types
typedef struct FileTypeData
{
wxArrayString extensions;
wxArrayString mimeTypes;
wxIconLocation iconLoc;
wxString application;
wxString description;
}
FileTypeInfo;
// Data store
std::unordered_map<wxString, wxString> m_extMap,
m_mimeMap;
std::unordered_map<wxString, FileTypeData> m_utiMap;
friend class wxFileTypeImpl;
};
// This class provides the interface between wxFileType and wxMimeTypesManagerImple for Mac OS X
// Currently only extension, mimetype, description and icon information is available
// All other methods have no-op implementation
class WXDLLIMPEXP_BASE wxFileTypeImpl
{
public:
wxFileTypeImpl();
virtual ~wxFileTypeImpl();
bool GetExtensions(wxArrayString& extensions) const ;
bool GetMimeType(wxString *mimeType) const ;
bool GetMimeTypes(wxArrayString& mimeTypes) const ;
bool GetIcon(wxIconLocation *iconLoc) const ;
bool GetDescription(wxString *desc) const ;
bool GetOpenCommand(wxString *openCmd, const wxFileType::MessageParameters& params) const;
// These functions are only stubs on Mac OS X
bool GetPrintCommand(wxString *printCmd, const wxFileType::MessageParameters& params) const;
size_t GetAllCommands(wxArrayString *verbs, wxArrayString *commands, const wxFileType::MessageParameters& params) const;
bool SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt = TRUE);
bool SetDefaultIcon(const wxString& strIcon = wxEmptyString, int index = 0);
bool Unassociate(wxFileType *ft);
wxString
GetExpandedCommand(const wxString& verb,
const wxFileType::MessageParameters& params) const;
private:
// All that is needed to query type info - UTI and pointer to the manager
wxString m_uti;
wxMimeTypesManagerImpl* m_manager;
friend class wxMimeTypesManagerImpl;
};
#endif // wxUSE_MIMETYPE
#endif //_MIMETYPE_IMPL_H

View File

@@ -0,0 +1,23 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/objcid.h
// Purpose: Define wxObjCID working in both C++ and Objective-C.
// Author: Vadim Zeitlin
// Created: 2012-05-20
// Copyright: (c) 2012 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_CORE_OBJCID_H_
#define _WX_OSX_CORE_OBJCID_H_
// ----------------------------------------------------------------------------
// wxObjCID: Equivalent of Objective-C "id" that works in C++ code.
// ----------------------------------------------------------------------------
#ifdef __OBJC__
#define wxObjCID id
#else
typedef struct objc_object* wxObjCID;
#endif
#endif // _WX_OSX_CORE_OBJCID_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/private/datetime.h
// Purpose:
// Author: Vadim Zeitlin
// Created: 2011-12-19
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_CORE_PRIVATE_DATETIMECTRL_H_
#define _WX_OSX_CORE_PRIVATE_DATETIMECTRL_H_
#if wxUSE_DATEPICKCTRL
#include "wx/osx/private.h"
#include "wx/datetime.h"
enum wxDateTimeWidgetKind
{
wxDateTimeWidget_YearMonthDay,
wxDateTimeWidget_HourMinuteSecond
};
// ----------------------------------------------------------------------------
// wxDateTimeWidgetImpl: peer class for wxDateTimePickerCtrl.
// ----------------------------------------------------------------------------
class wxDateTimeWidgetImpl
#if wxOSX_USE_COCOA
: public wxWidgetCocoaImpl
#else
#error "Unsupported platform"
#endif
{
public:
static wxDateTimeWidgetImpl*
CreateDateTimePicker(wxDateTimePickerCtrl* wxpeer,
const wxDateTime& dt,
const wxPoint& pos,
const wxSize& size,
long style,
wxDateTimeWidgetKind kind);
virtual void SetDateTime(const wxDateTime& dt) = 0;
virtual wxDateTime GetDateTime() const = 0;
virtual void SetDateRange(const wxDateTime& dt1, const wxDateTime& dt2) = 0;
virtual bool GetDateRange(wxDateTime* dt1, wxDateTime* dt2) = 0;
virtual ~wxDateTimeWidgetImpl() = default;
protected:
#if wxOSX_USE_COCOA
wxDateTimeWidgetImpl(wxDateTimePickerCtrl* wxpeer, WXWidget view)
: wxWidgetCocoaImpl(wxpeer, view)
{
}
#endif
};
#endif // wxUSE_DATEPICKCTRL
#endif // _WX_OSX_CORE_PRIVATE_DATETIMECTRL_H_

View File

@@ -0,0 +1,373 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/private/strconv_cf.h
// Purpose: Unicode conversion classes
// Author: David Elliott, Ryan Norton
// Created: 2007-07-06
// Copyright: (c) 2004 Ryan Norton
// (c) 2007 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/strconv.h"
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFStringEncodingExt.h>
#include "wx/fontmap.h"
// ============================================================================
// CoreFoundation conversion classes
// ============================================================================
inline CFStringEncoding wxCFStringEncFromFontEnc(wxFontEncoding encoding)
{
CFStringEncoding enc = kCFStringEncodingInvalidId ;
switch (encoding)
{
case wxFONTENCODING_DEFAULT :
enc = CFStringGetSystemEncoding();
break ;
case wxFONTENCODING_ISO8859_1 :
enc = kCFStringEncodingISOLatin1 ;
break ;
case wxFONTENCODING_ISO8859_2 :
enc = kCFStringEncodingISOLatin2;
break ;
case wxFONTENCODING_ISO8859_3 :
enc = kCFStringEncodingISOLatin3 ;
break ;
case wxFONTENCODING_ISO8859_4 :
enc = kCFStringEncodingISOLatin4;
break ;
case wxFONTENCODING_ISO8859_5 :
enc = kCFStringEncodingISOLatinCyrillic;
break ;
case wxFONTENCODING_ISO8859_6 :
enc = kCFStringEncodingISOLatinArabic;
break ;
case wxFONTENCODING_ISO8859_7 :
enc = kCFStringEncodingISOLatinGreek;
break ;
case wxFONTENCODING_ISO8859_8 :
enc = kCFStringEncodingISOLatinHebrew;
break ;
case wxFONTENCODING_ISO8859_9 :
enc = kCFStringEncodingISOLatin5;
break ;
case wxFONTENCODING_ISO8859_10 :
enc = kCFStringEncodingISOLatin6;
break ;
case wxFONTENCODING_ISO8859_11 :
enc = kCFStringEncodingISOLatinThai;
break ;
case wxFONTENCODING_ISO8859_13 :
enc = kCFStringEncodingISOLatin7;
break ;
case wxFONTENCODING_ISO8859_14 :
enc = kCFStringEncodingISOLatin8;
break ;
case wxFONTENCODING_ISO8859_15 :
enc = kCFStringEncodingISOLatin9;
break ;
case wxFONTENCODING_KOI8 :
enc = kCFStringEncodingKOI8_R;
break ;
case wxFONTENCODING_ALTERNATIVE : // MS-DOS CP866
enc = kCFStringEncodingDOSRussian;
break ;
// case wxFONTENCODING_BULGARIAN :
// enc = ;
// break ;
case wxFONTENCODING_CP437 :
enc = kCFStringEncodingDOSLatinUS ;
break ;
case wxFONTENCODING_CP850 :
enc = kCFStringEncodingDOSLatin1;
break ;
case wxFONTENCODING_CP852 :
enc = kCFStringEncodingDOSLatin2;
break ;
case wxFONTENCODING_CP855 :
enc = kCFStringEncodingDOSCyrillic;
break ;
case wxFONTENCODING_CP866 :
enc = kCFStringEncodingDOSRussian ;
break ;
case wxFONTENCODING_CP874 :
enc = kCFStringEncodingDOSThai;
break ;
case wxFONTENCODING_CP932 :
enc = kCFStringEncodingDOSJapanese;
break ;
case wxFONTENCODING_CP936 :
enc = kCFStringEncodingDOSChineseSimplif ;
break ;
case wxFONTENCODING_CP949 :
enc = kCFStringEncodingDOSKorean;
break ;
case wxFONTENCODING_CP950 :
enc = kCFStringEncodingDOSChineseTrad;
break ;
case wxFONTENCODING_CP1250 :
enc = kCFStringEncodingWindowsLatin2;
break ;
case wxFONTENCODING_CP1251 :
enc = kCFStringEncodingWindowsCyrillic ;
break ;
case wxFONTENCODING_CP1252 :
enc = kCFStringEncodingWindowsLatin1 ;
break ;
case wxFONTENCODING_CP1253 :
enc = kCFStringEncodingWindowsGreek;
break ;
case wxFONTENCODING_CP1254 :
enc = kCFStringEncodingWindowsLatin5;
break ;
case wxFONTENCODING_CP1255 :
enc = kCFStringEncodingWindowsHebrew ;
break ;
case wxFONTENCODING_CP1256 :
enc = kCFStringEncodingWindowsArabic ;
break ;
case wxFONTENCODING_CP1257 :
enc = kCFStringEncodingWindowsBalticRim;
break ;
// This only really encodes to UTF7 (if that) evidently
// case wxFONTENCODING_UTF7 :
// enc = kCFStringEncodingNonLossyASCII ;
// break ;
case wxFONTENCODING_UTF8 :
enc = kCFStringEncodingUTF8 ;
break ;
case wxFONTENCODING_EUC_JP :
enc = kCFStringEncodingEUC_JP;
break ;
/* Don't support conversion to/from UTF16 as wxWidgets can do this better.
* In particular, ToWChar would fail miserably using strlen on an input UTF16.
case wxFONTENCODING_UTF16 :
enc = kCFStringEncodingUnicode ;
break ;
*/
case wxFONTENCODING_MACROMAN :
enc = kCFStringEncodingMacRoman ;
break ;
case wxFONTENCODING_MACJAPANESE :
enc = kCFStringEncodingMacJapanese ;
break ;
case wxFONTENCODING_MACCHINESETRAD :
enc = kCFStringEncodingMacChineseTrad ;
break ;
case wxFONTENCODING_MACKOREAN :
enc = kCFStringEncodingMacKorean ;
break ;
case wxFONTENCODING_MACARABIC :
enc = kCFStringEncodingMacArabic ;
break ;
case wxFONTENCODING_MACHEBREW :
enc = kCFStringEncodingMacHebrew ;
break ;
case wxFONTENCODING_MACGREEK :
enc = kCFStringEncodingMacGreek ;
break ;
case wxFONTENCODING_MACCYRILLIC :
enc = kCFStringEncodingMacCyrillic ;
break ;
case wxFONTENCODING_MACDEVANAGARI :
enc = kCFStringEncodingMacDevanagari ;
break ;
case wxFONTENCODING_MACGURMUKHI :
enc = kCFStringEncodingMacGurmukhi ;
break ;
case wxFONTENCODING_MACGUJARATI :
enc = kCFStringEncodingMacGujarati ;
break ;
case wxFONTENCODING_MACORIYA :
enc = kCFStringEncodingMacOriya ;
break ;
case wxFONTENCODING_MACBENGALI :
enc = kCFStringEncodingMacBengali ;
break ;
case wxFONTENCODING_MACTAMIL :
enc = kCFStringEncodingMacTamil ;
break ;
case wxFONTENCODING_MACTELUGU :
enc = kCFStringEncodingMacTelugu ;
break ;
case wxFONTENCODING_MACKANNADA :
enc = kCFStringEncodingMacKannada ;
break ;
case wxFONTENCODING_MACMALAJALAM :
enc = kCFStringEncodingMacMalayalam ;
break ;
case wxFONTENCODING_MACSINHALESE :
enc = kCFStringEncodingMacSinhalese ;
break ;
case wxFONTENCODING_MACBURMESE :
enc = kCFStringEncodingMacBurmese ;
break ;
case wxFONTENCODING_MACKHMER :
enc = kCFStringEncodingMacKhmer ;
break ;
case wxFONTENCODING_MACTHAI :
enc = kCFStringEncodingMacThai ;
break ;
case wxFONTENCODING_MACLAOTIAN :
enc = kCFStringEncodingMacLaotian ;
break ;
case wxFONTENCODING_MACGEORGIAN :
enc = kCFStringEncodingMacGeorgian ;
break ;
case wxFONTENCODING_MACARMENIAN :
enc = kCFStringEncodingMacArmenian ;
break ;
case wxFONTENCODING_MACCHINESESIMP :
enc = kCFStringEncodingMacChineseSimp ;
break ;
case wxFONTENCODING_MACTIBETAN :
enc = kCFStringEncodingMacTibetan ;
break ;
case wxFONTENCODING_MACMONGOLIAN :
enc = kCFStringEncodingMacMongolian ;
break ;
case wxFONTENCODING_MACETHIOPIC :
enc = kCFStringEncodingMacEthiopic ;
break ;
case wxFONTENCODING_MACCENTRALEUR :
enc = kCFStringEncodingMacCentralEurRoman ;
break ;
case wxFONTENCODING_MACVIATNAMESE :
enc = kCFStringEncodingMacVietnamese ;
break ;
case wxFONTENCODING_MACARABICEXT :
enc = kCFStringEncodingMacExtArabic ;
break ;
case wxFONTENCODING_MACSYMBOL :
enc = kCFStringEncodingMacSymbol ;
break ;
case wxFONTENCODING_MACDINGBATS :
enc = kCFStringEncodingMacDingbats ;
break ;
case wxFONTENCODING_MACTURKISH :
enc = kCFStringEncodingMacTurkish ;
break ;
case wxFONTENCODING_MACCROATIAN :
enc = kCFStringEncodingMacCroatian ;
break ;
case wxFONTENCODING_MACICELANDIC :
enc = kCFStringEncodingMacIcelandic ;
break ;
case wxFONTENCODING_MACROMANIAN :
enc = kCFStringEncodingMacRomanian ;
break ;
case wxFONTENCODING_MACCELTIC :
enc = kCFStringEncodingMacCeltic ;
break ;
case wxFONTENCODING_MACGAELIC :
enc = kCFStringEncodingMacGaelic ;
break ;
/* CFString is known to support this back to the original CarbonLib */
/* http://developer.apple.com/samplecode/CarbonMDEF/listing2.html */
case wxFONTENCODING_MACKEYBOARD :
/* We don't wish to pollute the namespace too much, even though we're a private header. */
/* The constant is well-defined as 41 and is not expected to change. */
enc = 41 /*kTextEncodingMacKeyboardGlyphs*/ ;
break ;
default :
// because gcc is picky
break ;
}
return enc ;
}
class wxMBConv_cf : public wxMBConv
{
public:
enum NormalizationForm
{
None = 0x00,
FromWChar_D = 0x01,
ToWChar_C = 0x02
};
wxMBConv_cf()
{
Init(CFStringGetSystemEncoding(), ToWChar_C) ;
}
wxMBConv_cf(const wxMBConv_cf& conv) : wxMBConv()
{
m_encoding = conv.m_encoding;
m_normalization = conv.m_normalization;
}
#if wxUSE_FONTMAP
wxMBConv_cf(const char* name, NormalizationForm normalization = ToWChar_C)
{
Init( wxCFStringEncFromFontEnc(wxFontMapperBase::Get()->CharsetToEncoding(name, false) ) , normalization) ;
}
#endif
wxMBConv_cf(wxFontEncoding encoding, NormalizationForm normalization = ToWChar_C )
{
Init( wxCFStringEncFromFontEnc(encoding) , normalization);
}
virtual ~wxMBConv_cf()
{
}
void Init( CFStringEncoding encoding, NormalizationForm normalization )
{
m_encoding = encoding ;
m_normalization = normalization;
}
virtual size_t ToWChar(wchar_t * dst, size_t dstSize, const char * src, size_t srcSize = wxNO_LEN) const override;
virtual size_t FromWChar(char *dst, size_t dstSize, const wchar_t *src, size_t srcSize = wxNO_LEN) const override;
wxNODISCARD virtual wxMBConv *Clone() const override { return new wxMBConv_cf(*this); }
bool IsOk() const
{
return m_encoding != kCFStringEncodingInvalidId &&
CFStringIsEncodingAvailable(m_encoding);
}
private:
NormalizationForm m_normalization ;
CFStringEncoding m_encoding ;
};
// This "decomposing" converter is used as wxConvFileName in wxOSX.
class wxMBConvD_cf : public wxMBConv_cf
{
public:
wxMBConvD_cf(wxFontEncoding encoding) : wxMBConv_cf(encoding, (NormalizationForm) (ToWChar_C | FromWChar_D) )
{
}
};
// corresponding class for holding UniChars (native unicode characters)
class WXDLLIMPEXP_BASE wxMacUniCharBuffer
{
public :
wxMacUniCharBuffer( const wxString &str ) ;
~wxMacUniCharBuffer() ;
UniCharPtr GetBuffer() ;
UniCharCount GetChars() ;
private :
UniCharPtr m_ubuf ;
UniCharCount m_chars ;
};

View File

@@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/private/timer.h
// Purpose: wxTimer class based on core foundation
// Author: Stefan Csomor
// Created: 2008-07-16
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_CORE_PRIVATE_TIMER_H_
#define _WX_OSX_CORE_PRIVATE_TIMER_H_
#include "wx/private/timer.h"
struct wxOSXTimerInfo;
class WXDLLIMPEXP_CORE wxOSXTimerImpl : public wxTimerImpl
{
public:
wxOSXTimerImpl(wxTimer *timer);
virtual ~wxOSXTimerImpl();
virtual bool Start(int milliseconds = -1, bool one_shot = false) override;
virtual void Stop() override;
virtual bool IsRunning() const override;
private:
wxOSXTimerInfo *m_info;
};
#endif // _WX_OSX_CORE_PRIVATE_TIMER_H_

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/core/stdpaths.h
// Purpose: wxStandardPaths for Cocoa
// Author: Tobias Taschner
// Created: 2015-09-09
// Copyright: (c) 2015 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_STDPATHS_H_
#define _WX_COCOA_STDPATHS_H_
// ----------------------------------------------------------------------------
// wxStandardPaths
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxStandardPaths : public wxStandardPathsBase
{
public:
// implement base class pure virtuals
virtual wxString GetExecutablePath() const override;
virtual wxString GetConfigDir() const override;
virtual wxString GetUserConfigDir() const override;
virtual wxString GetDataDir() const override;
virtual wxString GetLocalDataDir() const override;
virtual wxString GetUserDataDir() const override;
virtual wxString GetPluginsDir() const override;
virtual wxString GetSharedLibrariesDir() const override;
virtual wxString GetResourcesDir() const override;
virtual wxString
GetLocalizedResourcesDir(const wxString& lang,
ResourceCat category = ResourceCat_None) const override;
virtual wxString GetUserDir(Dir userDir) const override;
virtual wxString MakeConfigFileName(const wxString& basename,
ConfigFileConv conv = ConfigFileConv_Ext
) const override;
protected:
// Ctor is protected, use wxStandardPaths::Get() instead of instantiating
// objects of this class directly.
wxStandardPaths() = default;
};
#endif // _WX_COCOA_STDPATHS_H_

View File

@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/cursor.h
// Purpose: wxCursor class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CURSOR_H_
#define _WX_CURSOR_H_
#include "wx/bitmap.h"
// Cursor
class WXDLLIMPEXP_CORE wxCursor : public wxCursorBase
{
public:
wxCursor();
wxCursor(const wxBitmap& bitmap, const wxPoint& hotSpot)
: wxCursor(bitmap, hotSpot.x, hotSpot.y) { }
wxCursor(const wxBitmap& bitmap, int hotSpotX = 0, int hotSpotY = 0);
#if wxUSE_IMAGE
wxCursor(const wxImage & image) ;
wxCursor(const char* const* xpmData);
#endif // wxUSE_IMAGE
wxCursor(const wxString& name, wxBitmapType type, const wxPoint& hotSpot)
: wxCursor(name, type, hotSpot.x, hotSpot.y) { }
wxCursor(const wxString& name,
wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor id) { InitFromStock(id); }
void MacInstall() const ;
void SetHCURSOR(WXHCURSOR cursor);
WXHCURSOR GetHCURSOR() const;
virtual wxPoint GetHotSpot() const override;
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
void InitFromStock(wxStockCursor);
void InitFromBitmap(const wxBitmap& bitmap, int hotSpotX, int hotSpotY);
#if wxUSE_IMAGE
void InitFromImage(const wxImage & image) ;
#endif // wxUSE_IMAGE
wxDECLARE_DYNAMIC_CLASS(wxCursor);
};
#endif // _WX_CURSOR_H_

View File

@@ -0,0 +1,78 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dataform.h
// Purpose: declaration of the wxDataFormat class
// Author: Stefan Csomor (lifted from dnd.h)
// Created: 10/21/99
// Copyright: (c) 1999 Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_DATAFORM_H
#define _WX_MAC_DATAFORM_H
#include "wx/osx/core/cfstring.h"
class WXDLLIMPEXP_CORE wxDataFormat
{
public:
typedef CFStringRef NativeFormat;
wxDataFormat();
wxDataFormat(wxDataFormatId vType);
wxDataFormat(const wxDataFormat& rFormat);
wxDataFormat(const wxString& rId);
wxDataFormat(const wxChar* pId);
wxDataFormat(NativeFormat vFormat);
~wxDataFormat();
wxDataFormat& operator=(NativeFormat vFormat)
{ SetId(vFormat); return *this; }
// comparison (must have both versions)
bool operator==(const wxDataFormat& format) const ;
bool operator!=(const wxDataFormat& format) const
{ return ! ( *this == format ); }
bool operator==(wxDataFormatId format) const
{ return m_type == (wxDataFormatId)format; }
bool operator!=(wxDataFormatId format) const
{ return m_type != (wxDataFormatId)format; }
wxDataFormat& operator=(const wxDataFormat& format);
// explicit and implicit conversions to NativeFormat which is one of
// standard data types (implicit conversion is useful for preserving the
// compatibility with old code)
NativeFormat GetFormatId() const { return m_format; }
operator NativeFormat() const { return m_format; }
void SetId(NativeFormat format);
// string ids are used for custom types - this SetId() must be used for
// application-specific formats
wxString GetId() const;
void SetId(const wxString& pId);
// implementation
wxDataFormatId GetType() const { return m_type; }
void SetType( wxDataFormatId type );
static NativeFormat GetFormatForType(wxDataFormatId type);
// returns true if the format is one of those defined in wxDataFormatId
bool IsStandard() const { return m_type > 0 && m_type < wxDF_PRIVATE; }
// adds all the native formats for this format when calling a GetData
void AddSupportedTypesForGetting(CFMutableArrayRef types) const;
// adds all the native formats for this format when calling a SetData
void AddSupportedTypesForSetting(CFMutableArrayRef types) const;
private:
void DoAddSupportedTypes(CFMutableArrayRef types, bool forSetting) const;
void ClearNativeFormat();
wxDataFormatId m_type;
wxString m_id;
wxCFStringRef m_format;
};
#endif // _WX_MAC_DATAFORM_H

View File

@@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dataobj.h
// Purpose: declaration of the wxDataObject
// Author: Stefan Csomor (adapted from Robert Roebling's gtk port)
// Created: 10/21/99
// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_DATAOBJ_H_
#define _WX_MAC_DATAOBJ_H_
class WXDLLIMPEXP_CORE wxOSXDataSink;
class WXDLLIMPEXP_CORE wxOSXDataSource;
class WXDLLIMPEXP_CORE wxDataObject : public wxDataObjectBase
{
public:
wxDataObject();
virtual ~wxDataObject() = default;
virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const;
void WriteToSink(wxOSXDataSink *sink) const;
bool ReadFromSource(wxOSXDataSource *source);
bool ReadFromSource(wxDataObject *source);
bool CanReadFromSource(wxOSXDataSource *source) const;
bool CanReadFromSource(wxDataObject *source) const;
wxDataFormat GetSupportedFormatInSource(wxOSXDataSource *source) const;
wxDataFormat GetSupportedFormatInSource(wxDataObject *source) const;
#if wxOSX_USE_COCOA
// adds all the native formats (in descending order of preference) this data object supports
virtual void AddSupportedTypes( CFMutableArrayRef cfarray, Direction dir ) const;
#endif
};
#endif // _WX_MAC_DATAOBJ_H_

View File

@@ -0,0 +1,91 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dataobj2.h
// Purpose: declaration of standard wxDataObjectSimple-derived classes
// Author: David Webster (adapted from Robert Roebling's gtk port
// Created: 10/21/99
// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_DATAOBJ2_H_
#define _WX_MAC_DATAOBJ2_H_
// ----------------------------------------------------------------------------
// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapDataObject : public wxBitmapDataObjectBase
{
public:
// ctors
wxBitmapDataObject();
wxBitmapDataObject(const wxBitmap& bitmap);
// destr
virtual ~wxBitmapDataObject();
// override base class virtual to update PNG data too
virtual void SetBitmap(const wxBitmap& bitmap) override;
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const override;
virtual bool GetDataHere(void *buf) const override;
virtual bool SetData(size_t len, const void *buf) override;
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const override
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const override
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) override
{
return SetData(len, buf);
}
protected :
void Init() ;
void Clear() ;
CFDataRef m_pictData ;
};
// ----------------------------------------------------------------------------
// wxFileDataObject is a specialization of wxDataObject for file names
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileDataObject : public wxFileDataObjectBase
{
public:
// implement base class pure virtuals
// ----------------------------------
void AddFile( const wxString &filename );
virtual size_t GetDataSize() const override;
virtual bool GetDataHere(void *buf) const override;
virtual bool SetData(size_t len, const void *buf) override;
// Must provide overloads to avoid hiding them (and warnings about it)
virtual size_t GetDataSize(const wxDataFormat&) const override
{
return GetDataSize();
}
virtual bool GetDataHere(const wxDataFormat&, void *buf) const override
{
return GetDataHere(buf);
}
virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) override
{
return SetData(len, buf);
}
protected:
// translates the filenames stored into a utf8 encoded char stream
void GetFileNames(wxCharBuffer &buf) const ;
};
#endif // _WX_MAC_DATAOBJ2_H_

View File

@@ -0,0 +1,325 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dataview.h
// Purpose: wxDataViewCtrl native implementation header for OSX
// Author:
// Copyright: (c) 2009
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATAVIEWCTRL_OSX_H_
#define _WX_DATAVIEWCTRL_OSX_H_
#ifdef __WXMAC_CLASSIC__
# error "Native wxDataViewCtrl for classic environment not defined. Please use generic control."
#endif
// --------------------------------------------------------
// Class declarations to mask native types
// --------------------------------------------------------
class wxDataViewColumnNativeData; // class storing environment dependent data for the native implementation
class wxDataViewWidgetImpl; // class used as a common interface for carbon and cocoa implementation
// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
{
public:
// constructors / destructor
wxDataViewColumn(const wxString& title,
wxDataViewRenderer* renderer,
unsigned int model_column,
int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE);
wxDataViewColumn(const wxBitmapBundle& bitmap,
wxDataViewRenderer* renderer,
unsigned int model_column,
int width = wxDVC_DEFAULT_WIDTH,
wxAlignment align = wxALIGN_CENTER,
int flags = wxDATAVIEW_COL_RESIZABLE);
virtual ~wxDataViewColumn();
// implement wxHeaderColumnBase pure virtual methods
virtual wxAlignment GetAlignment() const override { return m_alignment; }
virtual int GetFlags() const override { return m_flags; }
virtual int GetMaxWidth() const { return m_maxWidth; }
virtual int GetMinWidth() const override { return m_minWidth; }
virtual wxString GetTitle() const override { return m_title; }
virtual int GetWidth() const override;
virtual bool IsSortOrderAscending() const override { return m_ascending; }
virtual bool IsSortKey() const override;
virtual bool IsHidden() const override;
virtual void SetAlignment (wxAlignment align) override;
virtual void SetBitmap (wxBitmapBundle const& bitmap) override;
virtual void SetFlags (int flags) override { m_flags = flags; /*SetIndividualFlags(flags); */ }
virtual void SetHidden (bool hidden) override;
virtual void SetMaxWidth (int maxWidth);
virtual void SetMinWidth (int minWidth) override;
virtual void SetReorderable(bool reorderable) override;
virtual void SetResizeable (bool resizable) override;
virtual void UnsetAsSortKey() override;
virtual void SetSortable (bool sortable) override;
virtual void SetSortOrder (bool ascending) override;
virtual void SetTitle (wxString const& title) override;
virtual void SetWidth (int width) override;
// implementation only
wxDataViewColumnNativeData* GetNativeData() const
{
return m_NativeDataPtr;
}
void SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr); // class takes ownership of pointer
int GetWidthVariable() const
{
return m_width;
}
void SetWidthVariable(int NewWidth)
{
m_width = NewWidth;
}
void SetSortOrderVariable(bool NewOrder)
{
m_ascending = NewOrder;
}
private:
// common part of all ctors
void InitCommon(int width, wxAlignment align, int flags)
{
m_ascending = true;
m_flags = flags & ~wxDATAVIEW_COL_HIDDEN; // TODO
m_maxWidth = 30000;
m_minWidth = 0;
m_alignment = align;
SetWidth(width);
}
bool m_ascending; // sorting order
int m_flags; // flags for the column
int m_maxWidth; // maximum width for the column
int m_minWidth; // minimum width for the column
int m_width; // column width
wxAlignment m_alignment; // column header alignment
wxDataViewColumnNativeData* m_NativeDataPtr; // storing environment dependent data for the native implementation
wxString m_title; // column title
};
//
// type definitions related to wxDataViewColumn
//
WX_DEFINE_ARRAY(wxDataViewColumn*,wxDataViewColumnPtrArrayType);
// ---------------------------------------------------------
// wxDataViewCtrl
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase
{
public:
// Constructors / destructor:
wxDataViewCtrl()
{
Init();
}
wxDataViewCtrl(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxDataViewCtrlNameStr) )
{
Init();
Create(parent, winid, pos, size, style, validator, name);
}
~wxDataViewCtrl();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxDataViewCtrlNameStr));
virtual wxWindow* GetMainWindow() // not used for the native implementation
{
return this;
}
// inherited methods from wxDataViewCtrlBase:
virtual bool AssociateModel(wxDataViewModel* model) override;
virtual bool AppendColumn (wxDataViewColumn* columnPtr) override;
virtual bool ClearColumns () override;
virtual bool DeleteColumn (wxDataViewColumn* columnPtr) override;
virtual wxDataViewColumn* GetColumn (unsigned int pos) const override;
virtual unsigned int GetColumnCount () const override;
virtual int GetColumnPosition(const wxDataViewColumn* columnPtr) const override;
virtual wxDataViewColumn* GetSortingColumn () const override;
virtual bool InsertColumn (unsigned int pos, wxDataViewColumn *col) override;
virtual bool PrependColumn (wxDataViewColumn* columnPtr) override;
virtual void Collapse( const wxDataViewItem& item) override;
virtual void EnsureVisible(const wxDataViewItem& item, const wxDataViewColumn* columnPtr=nullptr) override;
virtual bool IsExpanded(const wxDataViewItem & item) const override;
virtual unsigned int GetCount() const;
virtual int GetCountPerPage() const override;
virtual wxRect GetItemRect(const wxDataViewItem& item,
const wxDataViewColumn* columnPtr = nullptr) const override;
virtual int GetSelectedItemsCount() const override;
virtual int GetSelections(wxDataViewItemArray& sel) const override;
virtual wxDataViewItem GetTopItem() const override;
virtual void HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const override;
virtual bool SetRowHeight(int rowHeight) override;
virtual bool IsSelected(const wxDataViewItem& item) const override;
virtual void SelectAll() override;
virtual void Select(const wxDataViewItem& item) override;
virtual void SetSelections(const wxDataViewItemArray& sel) override;
virtual void Unselect(const wxDataViewItem& item) override;
virtual void UnselectAll() override;
//
// implementation
//
// returns a pointer to the native implementation
wxDataViewWidgetImpl* GetDataViewPeer() const;
// adds all children of the passed parent to the control; if 'parentItem' is invalid the root(s) is/are added:
void AddChildren(wxDataViewItem const& parentItem);
// finishes editing of custom items; if no custom item is currently edited the method does nothing
void FinishCustomItemEditing();
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) override;
#if wxUSE_DRAG_AND_DROP
virtual bool DoEnableDropTarget( const wxVector<wxDataFormat>& formats ) override;
#endif // wxUSE_DRAG_AND_DROP
// returns the n-th pointer to a column;
// this method is different from GetColumn(unsigned int pos) because here 'n' is not a position in the control but the n-th
// position in the internal list/array of column pointers
wxDataViewColumn* GetColumnPtr(size_t n) const
{
return m_ColumnPtrs[n];
}
// returns the current being rendered item of the customized renderer (this item is only valid during editing)
wxDataViewItem const& GetCustomRendererItem() const
{
return m_CustomRendererItem;
}
// returns a pointer to a customized renderer (this pointer is only valid during editing)
wxDataViewCustomRenderer* GetCustomRendererPtr() const
{
return m_CustomRendererPtr;
}
// checks if a single item or all items are being deleted
bool IsDeleting() const;
bool IsClearing() const;
// with CG, we need to get the context from an kEventControlDraw event
// unfortunately, the DataBrowser callbacks don't provide the context
// and we need it, so we need to set/remove it before and after draw
// events so we can access it in the callbacks.
void MacSetDrawingContext(void* context)
{
m_cgContext = context;
}
void* MacGetDrawingContext() const
{
return m_cgContext;
}
// sets the currently being edited item of the custom renderer
void SetCustomRendererItem(wxDataViewItem const& NewItem)
{
m_CustomRendererItem = NewItem;
}
// sets the custom renderer
void SetCustomRendererPtr(wxDataViewCustomRenderer* NewCustomRendererPtr)
{
m_CustomRendererPtr = NewCustomRendererPtr;
}
void AdjustAutosizedColumns() const;
virtual wxDataViewColumn *GetCurrentColumn() const override;
virtual wxVisualAttributes GetDefaultAttributes() const override
{
return GetClassDefaultAttributes(GetWindowVariant());
}
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
protected:
// inherited methods from wxDataViewCtrlBase
virtual void DoSetExpanderColumn() override;
virtual void DoSetIndent() override;
virtual void DoExpand(const wxDataViewItem& item, bool expandChildren) override;
virtual wxSize DoGetBestSize() const override;
// event handling
void OnSize(wxSizeEvent &event);
virtual void DoThaw() override;
private:
// initializing of local variables:
void Init();
virtual wxDataViewItem DoGetCurrentItem() const override;
virtual void DoSetCurrentItem(const wxDataViewItem& item) override;
void OnContextMenu(wxContextMenuEvent& event);
//
// variables
//
// If non-null, describes the item(s) being deleted. This is necessary to
// allow avoiding referencing already deleted items from the native
// callbacks/delegates.
struct wxOSXDVCDeleting* m_Deleting;
// This class can set (and reset) m_Deleting.
friend class wxOSXDVCScopedDeleter;
void* m_cgContext; // pointer to core graphics context
wxDataViewCustomRenderer* m_CustomRendererPtr; // pointer to a valid custom renderer while editing; this class does NOT own the pointer
wxDataViewItem m_CustomRendererItem; // currently edited item by the customrenderer; it is invalid while not editing a custom item
wxDataViewColumnPtrArrayType m_ColumnPtrs; // all column pointers are stored in an array
class wxOSXDataViewModelNotifier* m_ModelNotifier; // stores the model notifier for the control (does not own the notifier)
// wxWidget internal stuff:
wxDECLARE_DYNAMIC_CLASS(wxDataViewCtrl);
wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_DATAVIEWCTRL_OSX_H_

View File

@@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/datectrl.h
// Purpose: Declaration of wxOSX-specific wxDatePickerCtrl class.
// Author: Vadim Zeitlin
// Created: 2011-12-18
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_DATECTRL_H_
#define _WX_OSX_DATECTRL_H_
// ----------------------------------------------------------------------------
// wxDatePickerCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDatePickerCtrl : public wxDatePickerCtrlBase
{
public:
// Constructors.
wxDatePickerCtrl() = default;
wxDatePickerCtrl(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr)
{
Create(parent, id, dt, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxDateTime& dt = wxDefaultDateTime,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDP_DEFAULT | wxDP_SHOWCENTURY,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxDatePickerCtrlNameStr);
// Implement the base class pure virtuals.
virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2) override;
virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const override;
virtual void OSXGenerateEvent(const wxDateTime& dt) override;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl);
};
#endif // _WX_OSX_DATECTRL_H_

View File

@@ -0,0 +1,33 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/datetimectrl.h
// Purpose: Declaration of wxOSX-specific wxDateTimePickerCtrl class.
// Author: Vadim Zeitlin
// Created: 2011-12-18
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_DATETIMECTRL_H_
#define _WX_OSX_DATETIMECTRL_H_
class wxDateTimeWidgetImpl;
// ----------------------------------------------------------------------------
// wxDateTimePickerCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDateTimePickerCtrl : public wxDateTimePickerCtrlBase
{
public:
// Implement the base class pure virtuals.
virtual void SetValue(const wxDateTime& dt) override;
virtual wxDateTime GetValue() const override;
// Implementation only.
virtual void OSXGenerateEvent(const wxDateTime& dt) = 0;
protected:
wxDateTimeWidgetImpl* GetDateTimePeer() const;
};
#endif // _WX_OSX_DATETIMECTRL_H_

View File

@@ -0,0 +1,13 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dc.h
// Purpose: wxDC class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DC_H_
#define _WX_DC_H_
#endif // _WX_DC_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dcclient.h
// Purpose: wxClientDC, wxPaintDC and wxWindowDC classes
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCCLIENT_H_
#define _WX_DCCLIENT_H_
#include "wx/dc.h"
#include "wx/dcgraph.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxPaintDC;
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_CORE wxWindowDCImpl: public wxGCDCImpl
{
public:
wxWindowDCImpl( wxDC *owner );
wxWindowDCImpl( wxDC *owner, wxWindow *window );
virtual ~wxWindowDCImpl();
virtual void DoGetSize( int *width, int *height ) const override;
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const override;
virtual void DestroyClippingRegion() override;
protected:
#if WXWIN_COMPATIBILITY_3_2
wxDEPRECATED_MSG("Don't use OSXGetOrigin()")
virtual wxPoint OSXGetOrigin() const override;
#endif // WXWIN_COMPATIBILITY_3_2
bool m_release;
int m_width;
int m_height;
wxPoint m_origin;
wxDECLARE_CLASS(wxWindowDCImpl);
wxDECLARE_NO_COPY_CLASS(wxWindowDCImpl);
};
class WXDLLIMPEXP_CORE wxClientDCImpl: public wxWindowDCImpl
{
public:
wxClientDCImpl( wxDC *owner );
wxClientDCImpl( wxDC *owner, wxWindow *window );
virtual ~wxClientDCImpl();
static bool
CanBeUsedForDrawing(const wxWindow* WXUNUSED(window)) { return false; }
private:
wxDECLARE_CLASS(wxClientDCImpl);
wxDECLARE_NO_COPY_CLASS(wxClientDCImpl);
};
class WXDLLIMPEXP_CORE wxPaintDCImpl: public wxWindowDCImpl
{
public:
wxPaintDCImpl( wxDC *owner );
wxPaintDCImpl( wxDC *owner, wxWindow *win );
virtual ~wxPaintDCImpl();
protected:
wxDECLARE_CLASS(wxPaintDCImpl);
wxDECLARE_NO_COPY_CLASS(wxPaintDCImpl);
};
#endif
// _WX_DCCLIENT_H_

View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dcmemory.h
// Purpose: wxMemoryDC class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMEMORY_H_
#define _WX_DCMEMORY_H_
#include "wx/osx/dcclient.h"
class WXDLLIMPEXP_CORE wxMemoryDCImpl: public wxPaintDCImpl
{
public:
wxMemoryDCImpl( wxMemoryDC *owner );
wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap );
wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc );
virtual ~wxMemoryDCImpl();
virtual void DoGetSize( int *width, int *height ) const override;
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const override
{ return subrect == nullptr ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); }
virtual void DoSelect(const wxBitmap& bitmap) override;
virtual const wxBitmap& GetSelectedBitmap() const override
{ return m_selected; }
virtual wxBitmap& GetSelectedBitmap() override
{ return m_selected; }
private:
void Init();
wxBitmap m_selected;
wxDECLARE_CLASS(wxMemoryDCImpl);
wxDECLARE_NO_COPY_CLASS(wxMemoryDCImpl);
};
#endif
// _WX_DCMEMORY_H_

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dcprint.h
// Purpose: wxPrinterDC class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCPRINT_H_
#define _WX_DCPRINT_H_
#include "wx/dc.h"
#include "wx/dcgraph.h"
#include "wx/cmndata.h"
class wxNativePrinterDC ;
class WXDLLIMPEXP_CORE wxPrinterDCImpl: public wxGCDCImpl
{
public:
#if wxUSE_PRINTING_ARCHITECTURE
wxPrinterDCImpl( wxPrinterDC *owner, const wxPrintData& printdata );
virtual ~wxPrinterDCImpl();
virtual bool StartDoc( const wxString& WXUNUSED(message) ) override;
virtual void EndDoc() override;
virtual void StartPage() override;
virtual void EndPage() override;
wxRect GetPaperRect() const override;
wxPrintData& GetPrintData() { return m_printData; }
virtual wxSize GetPPI() const override;
protected:
virtual void DoGetSize( int *width, int *height ) const override;
wxPrintData m_printData ;
wxNativePrinterDC* m_nativePrinterDC ;
private:
wxDECLARE_CLASS(wxPrinterDC);
#endif // wxUSE_PRINTING_ARCHITECTURE
};
#endif
// _WX_DCPRINT_H_

View File

@@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dcscreen.h
// Purpose: wxScreenDC class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCSCREEN_H_
#define _WX_DCSCREEN_H_
#include "wx/dcclient.h"
#include "wx/osx/dcclient.h"
class WXDLLIMPEXP_CORE wxScreenDCImpl: public wxWindowDCImpl
{
public:
wxScreenDCImpl( wxDC *owner );
virtual ~wxScreenDCImpl();
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const override;
private:
wxDECLARE_CLASS(wxScreenDCImpl);
wxDECLARE_NO_COPY_CLASS(wxScreenDCImpl);
};
#endif
// _WX_DCSCREEN_H_

View File

@@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dialog.h
// Purpose: wxDialog class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DIALOG_H_
#define _WX_DIALOG_H_
#include "wx/panel.h"
class WXDLLIMPEXP_FWD_CORE wxMacToolTip ;
class WXDLLIMPEXP_FWD_CORE wxModalEventLoop ;
// Dialog boxes
class WXDLLIMPEXP_CORE wxDialog : public wxDialogBase
{
wxDECLARE_DYNAMIC_CLASS(wxDialog);
public:
wxDialog() { Init(); }
// Constructor with no modal flag - the new convention.
wxDialog(wxWindow *parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxASCII_STR(wxDialogNameStr))
{
Init();
Create(parent, id, title, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxASCII_STR(wxDialogNameStr));
virtual ~wxDialog();
// virtual bool Destroy();
virtual bool Show(bool show = true) override;
// return true if we're showing the dialog modally
virtual bool IsModal() const override;
// show the dialog modally and return the value passed to EndModal()
virtual int ShowModal() override;
virtual void ShowWindowModal() override;
// may be called to terminate the dialog with the given return code
virtual void EndModal(int retCode) override;
static bool OSXHasModalDialogsOpen();
void OSXBeginModalDialog();
void OSXEndModalDialog();
#if wxOSX_USE_COCOA
bool OSXGetWorksWhenModal();
void OSXSetWorksWhenModal(bool worksWhenModal);
#endif
// implementation
// --------------
wxDialogModality GetModality() const override;
#if wxOSX_USE_COCOA
virtual void ModalFinishedCallback(void* WXUNUSED(panel), int WXUNUSED(returnCode)) {}
#endif
protected:
// show window modal dialog
void DoShowWindowModal();
// end window modal dialog.
void EndWindowModal();
// mac also takes command-period as cancel
virtual bool IsEscapeKey(const wxKeyEvent& event) override;
wxDialogModality m_modality;
wxModalEventLoop* m_eventLoop;
private:
void Init();
static wxVector<wxDialog*> s_modalStack;
#if wxOSX_USE_COCOA
static wxVector<bool> s_modalWorksStack;
#endif
};
#endif
// _WX_DIALOG_H_

View File

@@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dirdlg.h
// Purpose: wxDirDialog class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DIRDLG_H_
#define _WX_DIRDLG_H_
#if wxOSX_USE_COCOA
DECLARE_WXCOCOA_OBJC_CLASS(NSOpenPanel);
#endif
class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase
{
public:
wxDirDialog() { Init(); }
wxDirDialog(wxWindow *parent,
const wxString& message = wxASCII_STR(wxDirSelectorPromptStr),
const wxString& defaultPath = wxT(""),
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxASCII_STR(wxDirDialogNameStr))
{
Init();
Create(parent,message,defaultPath,style,pos,size,name);
}
void Create(wxWindow *parent,
const wxString& message = wxASCII_STR(wxDirSelectorPromptStr),
const wxString& defaultPath = wxT(""),
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxASCII_STR(wxDirDialogNameStr));
#if wxOSX_USE_COCOA
~wxDirDialog();
#endif
virtual int ShowModal() override;
// MacOS 10.11 has removed the titlebar from the dialog, so this is provided
// only for compatibility with older versions
virtual void SetTitle(const wxString& title) override;
#if wxOSX_USE_COCOA
virtual void ShowWindowModal() override;
virtual void ModalFinishedCallback(void* panel, int returnCode) override;
#endif
private:
#if wxOSX_USE_COCOA
// Create and initialize NSOpenPanel that we use in both ShowModal() and
// ShowWindowModal().
WX_NSOpenPanel OSXCreatePanel() const;
#endif
// Common part of all ctors.
void Init();
wxString m_title;
wxDECLARE_DYNAMIC_CLASS(wxDirDialog);
};
#endif // _WX_DIRDLG_H_

View File

@@ -0,0 +1,111 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dnd.h
// Purpose: Declaration of the wxDropTarget, wxDropSource class etc.
// Author: Stefan Csomor
// Copyright: (c) 1998 Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DND_H_
#define _WX_DND_H_
#if wxUSE_DRAG_AND_DROP
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/string.h"
#include "wx/string.h"
#include "wx/dataobj.h"
#include "wx/cursor.h"
//-------------------------------------------------------------------------
// classes
//-------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxDropTarget;
class WXDLLIMPEXP_FWD_CORE wxTextDropTarget;
class WXDLLIMPEXP_FWD_CORE wxFileDropTarget;
class WXDLLIMPEXP_FWD_CORE wxDropSource;
class WXDLLIMPEXP_FWD_CORE wxOSXDataSource;
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// this macro may be used instead for wxDropSource ctor arguments: it will use
// the icon 'name' from an XPM file under GTK, but will expand to something
// else under MSW. If you don't use it, you will have to use #ifdef in the
// application code.
#define wxDROP_ICON(X) wxCursor(X##_xpm)
//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDropTarget: public wxDropTargetBase
{
public:
wxDropTarget(wxDataObject *dataObject = nullptr );
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def) override;
virtual bool OnDrop(wxCoord x, wxCoord y) override;
virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def) override;
virtual bool GetData() override;
// NOTE: This is needed by the generic wxDataViewCtrl, not sure how to implement.
virtual wxDataFormat GetMatchingPair();
bool CurrentDragHasSupportedFormat() ;
void SetCurrentDragSource( wxOSXDataSource* dragpasteboard ) { m_currentDragPasteboard = dragpasteboard ; }
protected :
wxOSXDataSource* m_currentDragPasteboard ;
};
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
{
public:
// ctors: if you use default ctor you must call SetData() later!
//
// NB: the "wxWindow *win" parameter is unused and is here only for wxGTK
// compatibility, as well as both icon parameters
wxDropSource( wxWindow *win = nullptr,
const wxCursorBundle& cursorCopy = {},
const wxCursorBundle& cursorMove = {},
const wxCursorBundle& cursorStop = {});
/* constructor for setting one data object */
wxDropSource( wxDataObject& data,
wxWindow *win,
const wxCursorBundle& cursorCopy = {},
const wxCursorBundle& cursorMove = {},
const wxCursorBundle& cursorStop = {});
virtual ~wxDropSource();
// do it (call this in response to a mouse button press, for example)
// params: if bAllowMove is false, data can be only copied
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly) override;
wxWindow* GetWindow() { return m_window ; }
void SetCurrentDragPasteboard( void* dragpasteboard ) { m_currentDragPasteboard = dragpasteboard ; }
bool MacInstallDefaultCursor(wxDragResult effect) ;
static wxDropSource* GetCurrentDropSource();
protected :
wxWindow *m_window;
void* m_currentDragPasteboard ;
};
#endif // wxUSE_DRAG_AND_DROP
#endif
//_WX_DND_H_

View File

@@ -0,0 +1,115 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dvrenderer.h
// Purpose: wxDataViewRenderer for OS X wxDataViewCtrl implementations
// Author: Vadim Zeitlin
// Created: 2009-11-07 (extracted from wx/osx/dataview.h)
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_DVRENDERER_H_
#define _WX_OSX_DVRENDERER_H_
class wxDataViewRendererNativeData;
// ----------------------------------------------------------------------------
// wxDataViewRenderer
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
{
public:
// constructors / destructor
// -------------------------
wxDataViewRenderer(const wxString& varianttype,
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
virtual ~wxDataViewRenderer();
// inherited methods from wxDataViewRendererBase
// ---------------------------------------------
virtual int GetAlignment() const override
{
return m_alignment;
}
virtual wxDataViewCellMode GetMode() const override
{
return m_mode;
}
virtual bool GetValue(wxVariant& value) const override
{
value = m_value;
return true;
}
// NB: in Carbon this is always identical to the header alignment
virtual void SetAlignment(int align) override;
virtual void SetMode(wxDataViewCellMode mode) override;
virtual bool SetValue(const wxVariant& newValue) override
{
m_value = newValue;
return true;
}
virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) override;
virtual wxEllipsizeMode GetEllipsizeMode() const override;
// implementation
// --------------
const wxVariant& GetValue() const
{
return m_value;
}
wxDataViewRendererNativeData* GetNativeData() const
{
return m_NativeDataPtr;
}
// a call to the native data browser function to render the data;
// returns true if the data value could be rendered, false otherwise
virtual bool MacRender() = 0;
void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr);
void OSXUpdateAlignment();
#if wxOSX_USE_COCOA
// called when a value was edited by user
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col);
protected:
virtual void SetAttr(const wxDataViewItemAttr& attr) override;
virtual void SetEnabled(bool enabled) override;
#else
protected:
void SetAttr(const wxDataViewItemAttr& WXUNUSED(attr)) override { };
void SetEnabled(bool WXUNUSED(enabled)) override { };
#endif
virtual bool IsHighlighted() const override;
private:
// contains the alignment flags
int m_alignment;
// storing the mode that determines how the cell is going to be shown
wxDataViewCellMode m_mode;
// data used by implementation of the native renderer
wxDataViewRendererNativeData* m_NativeDataPtr;
// value that is going to be rendered
wxVariant m_value;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer);
};
#endif // _WX_OSX_DVRENDERER_H_

View File

@@ -0,0 +1,300 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/dvrenderers.h
// Purpose: All OS X wxDataViewCtrl renderer classes
// Author: Vadim Zeitlin
// Created: 2009-11-07 (extracted from wx/osx/dataview.h)
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_DVRENDERERS_H_
#define _WX_OSX_DVRENDERERS_H_
// ---------------------------------------------------------
// wxDataViewCustomRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewCustomRenderer : public wxDataViewCustomRendererBase
{
public:
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewCustomRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
virtual ~wxDataViewCustomRenderer();
// implementation only
// -------------------
virtual bool MacRender() override;
virtual wxDC* GetDC() override; // creates a device context and keeps it
void SetDC(wxDC* newDCPtr); // this method takes ownership of the pointer
private:
wxControl* m_editorCtrlPtr; // pointer to an in-place editor control
wxDC* m_DCPtr;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer);
};
// ---------------------------------------------------------------------------
// This is a Mac-specific class that should be used as the base class for the
// renderers that should be disabled when they're inert, to prevent the user
// from editing them.
// ---------------------------------------------------------------------------
class wxOSXDataViewDisabledInertRenderer : public wxDataViewRenderer
{
protected:
wxOSXDataViewDisabledInertRenderer(const wxString& varianttype,
wxDataViewCellMode mode,
int alignment)
: wxDataViewRenderer(varianttype, mode, alignment)
{
}
virtual void SetEnabled(bool enabled) override
{
wxDataViewRenderer::SetEnabled(enabled &&
GetMode() != wxDATAVIEW_CELL_INERT);
}
};
// ---------------------------------------------------------
// wxDataViewTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("string"); }
wxDataViewTextRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
#if wxUSE_MARKUP && wxOSX_USE_COCOA
void EnableMarkup(bool enable = true);
#endif // wxUSE_MARKUP && Cocoa
virtual bool MacRender() override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
#if wxUSE_MARKUP && wxOSX_USE_COCOA
// True if we should interpret markup in our text.
bool m_useMarkup;
#endif // wxUSE_MARKUP && Cocoa
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer);
};
// ---------------------------------------------------------
// wxDataViewBitmapRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("wxBitmapBundle"); }
wxDataViewBitmapRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
virtual
bool IsCompatibleVariantType(const wxString& variantType) const override;
virtual bool MacRender() override;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer);
};
// -------------------------------------
// wxDataViewChoiceRenderer
// -------------------------------------
class WXDLLIMPEXP_ADV wxDataViewChoiceRenderer
: public wxOSXDataViewDisabledInertRenderer
{
public:
wxDataViewChoiceRenderer(const wxArrayString& choices,
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
int alignment = wxDVR_DEFAULT_ALIGNMENT );
virtual bool MacRender() override;
wxString GetChoice(size_t index) const { return m_choices[index]; }
const wxArrayString& GetChoices() const { return m_choices; }
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
wxArrayString m_choices;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewChoiceRenderer);
};
// ----------------------------------------------------------------------------
// wxDataViewChoiceByIndexRenderer
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewChoiceByIndexRenderer: public wxDataViewChoiceRenderer
{
public:
wxDataViewChoiceByIndexRenderer(const wxArrayString& choices,
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
int alignment = wxDVR_DEFAULT_ALIGNMENT);
virtual bool SetValue(const wxVariant& value) override;
virtual bool GetValue(wxVariant& value) const override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
};
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("wxDataViewIconText"); }
wxDataViewIconTextRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
virtual bool MacRender() override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer);
};
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataViewCheckIconTextRenderer
: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("wxDataViewCheckIconText"); }
explicit wxDataViewCheckIconTextRenderer
(
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
int align = wxDVR_DEFAULT_ALIGNMENT
);
// This renderer can always display the 3rd ("indeterminate") checkbox
// state if the model contains cells with wxCHK_UNDETERMINED value, but it
// doesn't allow the user to set it by default. Call this method to allow
// this to happen.
void Allow3rdStateForUser(bool allow = true);
virtual bool MacRender() override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
bool m_allow3rdStateForUser;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCheckIconTextRenderer);
};
// ---------------------------------------------------------
// wxDataViewToggleRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewToggleRenderer
: public wxOSXDataViewDisabledInertRenderer
{
public:
static wxString GetDefaultType() { return wxS("bool"); }
wxDataViewToggleRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
void ShowAsRadio();
virtual bool MacRender() override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
void DoInitButtonCell(int buttonType);
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer);
};
// ---------------------------------------------------------
// wxDataViewProgressRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("long"); }
wxDataViewProgressRenderer(const wxString& label = wxEmptyString,
const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
int align = wxDVR_DEFAULT_ALIGNMENT);
virtual bool MacRender() override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer);
};
// ---------------------------------------------------------
// wxDataViewDateRenderer
// ---------------------------------------------------------
class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
{
public:
static wxString GetDefaultType() { return wxS("datetime"); }
wxDataViewDateRenderer(const wxString& varianttype = GetDefaultType(),
wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
int align = wxDVR_DEFAULT_ALIGNMENT);
virtual bool MacRender() override;
virtual void OSXOnCellChanged(NSObject *value,
const wxDataViewItem& item,
unsigned col) override;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer);
};
#endif // _WX_OSX_DVRENDERERS_H_

View File

@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/evtloop.h
// Purpose: simply forwards to wx/osx/carbon/evtloop.h or
// wx/osx/cocoa/evtloop.h for consistency with the other Mac
// headers
// Author: Vadim Zeitlin
// Created: 2006-01-12
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_EVTLOOP_H_
#define _WX_OSX_EVTLOOP_H_
#include "wx/osx/cocoa/evtloop.h"
class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
{
public:
wxModalEventLoop(wxWindow *modalWindow);
wxModalEventLoop(WXWindow modalNativeWindow);
#ifdef __WXOSX_COCOA__
// skip wxGUIEventLoop to avoid missing Enter/Exit notifications
virtual int Run() override { return wxCFEventLoop::Run(); }
#endif
protected:
virtual void OSXDoRun() override;
virtual void OSXDoStop() override;
// (in case) the modal window for this event loop
wxNonOwnedWindow* m_modalWindow;
WXWindow m_modalNativeWindow;
};
#endif // _WX_OSX_EVTLOOP_H_

View File

@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/evtloopsrc.h
// Purpose: wxCFEventLoopSource class
// Author: Vadim Zeitlin
// Created: 2009-10-21
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_EVTLOOPSRC_H_
#define _WX_OSX_EVTLOOPSRC_H_
typedef struct __CFSocket* CFSocketRef;
// ----------------------------------------------------------------------------
// wxCFEventLoopSource: CoreFoundation-based wxEventLoopSource for OS X
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxCFEventLoopSource : public wxEventLoopSource
{
public:
// Create a new source in uninitialized state, call InitSocketRef() later
// to associate it with the socket it is going to use.
wxCFEventLoopSource(wxEventLoopSourceHandler *handler, int flags)
: wxEventLoopSource(handler, flags)
{
m_cfSocket = nullptr;
}
// Finish initialization of the event loop source by providing the
// associated socket. This object takes ownership of it and will release it.
void InitSourceSocket(CFSocketRef cfSocket);
// Destructor deletes the associated socket.
virtual ~wxCFEventLoopSource();
private:
CFSocketRef m_cfSocket;
wxDECLARE_NO_COPY_CLASS(wxCFEventLoopSource);
};
#endif // _WX_OSX_EVTLOOPSRC_H_

View File

@@ -0,0 +1,105 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/filedlg.h
// Purpose: wxFileDialog class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDLG_H_
#define _WX_FILEDLG_H_
class WXDLLIMPEXP_FWD_CORE wxChoice;
//-------------------------------------------------------------------------
// wxFileDialog
//-------------------------------------------------------------------------
// set this system option to 1 in order to always show the filetypes popup in
// file open dialogs if possible
#define wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES wxT("osx.openfiledialog.always-show-types")
class WXDLLIMPEXP_CORE wxFileDialog: public wxFileDialogBase
{
wxDECLARE_DYNAMIC_CLASS(wxFileDialog);
protected:
wxArrayString m_fileNames;
wxArrayString m_paths;
public:
wxFileDialog() { Init(); }
wxFileDialog(wxWindow *parent,
const wxString& message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = wxFD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxASCII_STR(wxFileDialogNameStr))
{
Init();
Create(parent,message,defaultDir,defaultFile,wildCard,style,pos,sz,name);
}
void Create(wxWindow *parent,
const wxString& message = wxASCII_STR(wxFileSelectorPromptStr),
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxASCII_STR(wxFileSelectorDefaultWildcardStr),
long style = wxFD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxASCII_STR(wxFileDialogNameStr));
#if wxOSX_USE_COCOA
~wxFileDialog();
#endif
virtual void GetPaths(wxArrayString& paths) const override { paths = m_paths; }
virtual void GetFilenames(wxArrayString& files) const override { files = m_fileNames ; }
virtual int ShowModal() override;
#if wxOSX_USE_COCOA
virtual void ShowWindowModal() override;
virtual void ModalFinishedCallback(void* panel, int resultCode) override;
#endif
virtual bool SupportsExtraControl() const override;
// implementation only
protected:
// not supported for file dialog, RR
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
int WXUNUSED(width), int WXUNUSED(height),
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) override {}
void SetupExtraControls(WXWindow nativeWindow);
#if wxOSX_USE_COCOA
virtual wxWindow* CreateFilterPanel(wxWindow *extracontrol);
void DoOnFilterSelected(int index);
virtual void OnFilterSelected(wxCommandEvent &event);
int GetMatchingFilterExtension(const wxString& filename);
wxArrayString m_filterExtensions;
wxArrayString m_filterNames;
wxChoice* m_filterChoice;
wxWindow* m_filterPanel;
bool m_useFileTypeFilter;
int m_firstFileTypeFilter;
wxArrayString m_currentExtensions;
WX_NSObject m_delegate;
#endif
private:
// Common part of all ctors.
void Init();
};
#endif // _WX_FILEDLG_H_

View File

@@ -0,0 +1,156 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/font.h
// Purpose: wxFont class
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONT_H_
#define _WX_FONT_H_
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
// font styles
enum wxOSXSystemFont
{
wxOSX_SYSTEM_FONT_NONE = 0,
wxOSX_SYSTEM_FONT_NORMAL,
wxOSX_SYSTEM_FONT_BOLD,
wxOSX_SYSTEM_FONT_SMALL,
wxOSX_SYSTEM_FONT_SMALL_BOLD,
wxOSX_SYSTEM_FONT_MINI,
wxOSX_SYSTEM_FONT_MINI_BOLD,
wxOSX_SYSTEM_FONT_LABELS,
wxOSX_SYSTEM_FONT_VIEWS,
wxOSX_SYSTEM_FONT_FIXED
};
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
{
public:
// ctors and such
wxFont() = default;
wxFont(const wxFontInfo& info);
wxFont( wxOSXSystemFont systemFont );
wxFont(CTFontRef font);
#if wxOSX_USE_COCOA
wxFont(WX_NSFont nsfont);
#endif
wxFont(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(const wxSize& pixelSize,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Create(10, family, style, weight, underlined, face, encoding);
SetPixelSize(pixelSize);
}
bool Create(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
wxFont(const wxNativeFontInfo& info)
{
(void)Create(info);
}
wxFont(const wxString& fontDesc);
bool Create(const wxNativeFontInfo& info);
// implement base class pure virtuals
virtual double GetFractionalPointSize() const override;
virtual wxSize GetPixelSize() const override;
virtual wxFontStyle GetStyle() const override;
virtual int GetNumericWeight() const override;
virtual bool GetUnderlined() const override;
virtual bool GetStrikethrough() const override;
virtual wxString GetFaceName() const override;
virtual wxFontEncoding GetEncoding() const override;
virtual const wxNativeFontInfo *GetNativeFontInfo() const override;
virtual bool IsFixedWidth() const override;
virtual void SetFractionalPointSize(double pointSize) override;
virtual void SetFamily(wxFontFamily family) override;
virtual void SetStyle(wxFontStyle style) override;
virtual void SetNumericWeight(int weight) override;
virtual bool SetFaceName(const wxString& faceName) override;
virtual void SetUnderlined(bool underlined) override;
virtual void SetStrikethrough(bool strikethrough) override;
virtual void SetEncoding(wxFontEncoding encoding) override;
wxDECLARE_COMMON_FONT_METHODS();
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
wxFont(int size,
int family,
int style,
int weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
// implementation only from now on
// -------------------------------
virtual bool RealizeResource();
// Mac-specific, risks to change, don't use in portable code
#if wxOSX_USE_COCOA_OR_CARBON
CGFontRef OSXGetCGFont() const;
#endif
CTFontRef OSXGetCTFont() const;
CFDictionaryRef OSXGetCTFontAttributes() const;
#if wxOSX_USE_COCOA
WX_NSFont OSXGetNSFont() const;
#endif
#if wxOSX_USE_IPHONE
WX_UIFont OSXGetUIFont() const;
#endif
protected:
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info) override;
virtual wxFontFamily DoGetFamily() const override;
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
wxDECLARE_DYNAMIC_CLASS(wxFont);
};
#endif // _WX_FONT_H_

View File

@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/fontdlg.h
// Purpose: wxFontDialog class using fonts window services (10.2+).
// Author: Ryan Norton
// Created: 2004-09-25
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONTDLG_H_
#define _WX_FONTDLG_H_
#include "wx/dialog.h"
class WXDLLIMPEXP_CORE wxFontDialog : public wxFontDialogBase
{
public:
wxFontDialog() : wxFontDialogBase() { /* must be Create()d later */ }
wxFontDialog(wxWindow *parent)
: wxFontDialogBase(parent) { Create(parent); }
wxFontDialog(wxWindow *parent, const wxFontData& data)
: wxFontDialogBase(parent, data) { Create(parent, data); }
virtual ~wxFontDialog();
int ShowModal() override;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFontDialog);
};
extern "C" int RunMixedFontDialog(wxFontDialog* dialog) ;
#endif
// _WX_FONTDLG_H_

View File

@@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/frame.h
// Purpose: wxFrame class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FRAME_H_
#define _WX_FRAME_H_
#include "wx/toolbar.h"
#include "wx/accel.h"
#include "wx/icon.h"
class WXDLLIMPEXP_FWD_CORE wxMacToolTip ;
class WXDLLIMPEXP_CORE wxFrame: public wxFrameBase
{
public:
// construction
wxFrame() = default;
wxFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
Create(parent, id, title, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr));
// implementation only from now on
// -------------------------------
// get the origin of the client area (which may be different from (0, 0)
// if the frame has a toolbar) in client coordinates
virtual wxPoint GetClientAreaOrigin() const override;
// override some more virtuals
virtual bool Show(bool show = true) override;
virtual bool Enable(bool enable = true) override;
// event handlers
void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Toolbar
#if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar(long style = -1,
wxWindowID id = -1,
const wxString& name = wxASCII_STR(wxToolBarNameStr)) override;
virtual void SetToolBar(wxToolBar *toolbar) override;
#endif // wxUSE_TOOLBAR
// Status bar
#if wxUSE_STATUSBAR
virtual wxStatusBar* OnCreateStatusBar(int number = 1,
long style = wxSTB_DEFAULT_STYLE,
wxWindowID id = 0,
const wxString& name = wxASCII_STR(wxStatusLineNameStr)) override;
virtual void SetStatusBar(wxStatusBar *statbar) override;
#endif // wxUSE_STATUSBAR
void PositionBars();
// internal response to size events
virtual void MacOnInternalSize() override { PositionBars(); }
protected:
#if wxUSE_TOOLBAR
virtual void PositionToolBar() override;
#endif
#if wxUSE_STATUSBAR
virtual void PositionStatusBar() override;
#endif
// override base class virtuals
virtual void DoGetClientSize(int *width, int *height) const override;
virtual void DoSetClientSize(int width, int height) override;
#if wxUSE_MENUBAR
virtual void DetachMenuBar() override;
virtual void AttachMenuBar(wxMenuBar *menubar) override;
#endif
virtual bool MacIsChildOfClientArea( const wxWindow* child ) const override;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxFrame);
};
#endif
// _WX_FRAME_H_

View File

@@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/fswatcher_fsevents.h
// Purpose: File System watcher that uses the FSEvents API
// of OS X to efficiently watch trees
// Author: Roberto Perpuly
// Created: 2015-04-24
// Copyright: (c) 2015 Roberto Perpuly <robertop2004@gmail.com>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FSWATCHER_FSEVENTS_H_
#define _WX_FSWATCHER_FSEVENTS_H_
#include "wx/defs.h"
#if wxUSE_FSWATCHER
#include "wx/unix/fswatcher_kqueue.h"
/*
The FSEvents watcher uses the newer FSEvents service
that is available in OS X, the service allows for
efficient watching of entire directory hierarchies.
Note that adding a single file watch (or directory
watch) still use kqueue events.
We take care to only use this on OS X >= 10.7, as that
version introduced the ability to get file-level notifications.
See the following docs that outline the FSEvents API
https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html
https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/index.html
*/
class WXDLLIMPEXP_BASE wxFsEventsFileSystemWatcher :
public wxKqueueFileSystemWatcher
{
public:
wxFsEventsFileSystemWatcher();
wxFsEventsFileSystemWatcher(const wxFileName& path,
int events = wxFSW_EVENT_ALL);
~wxFsEventsFileSystemWatcher();
// reimplement adding a tree so that it does not use
// kqueue at all
bool AddTree(const wxFileName& path, int events = wxFSW_EVENT_ALL,
const wxString& filespec = wxEmptyString) override;
// reimplement removing a tree so that we
// cleanup the opened fs streams
bool RemoveTree(const wxFileName& path) override;
// reimplement remove all so that we cleanup
// watches from kqeueue and from FSEvents
bool RemoveAll() override;
// post a file change event to the owner
void PostChange(const wxFileName& oldFileName,
const wxFileName& newFileName, int event);
// post a warning event to the owner
void PostWarning(wxFSWWarningType warning, const wxString& msg);
// post an error event to the owner
void PostError(const wxString& msg);
// reimplement count to include the FS stream watches
int GetWatchedPathsCount() const;
// reimplement to include paths from FS stream watches
int GetWatchedPaths(wxArrayString* paths) const;
private:
// use the pImpl idiom to eliminate this header's dependency
// on CoreServices.h (and ultimately AssertMacros.h)
struct PrivateData;
PrivateData *m_pImpl;
};
#endif /* wxUSE_FSWATCHER */
#endif /* _WX_FSWATCHER_FSEVENTS_H_ */

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/gauge.h
// Purpose: wxGauge class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GAUGE_H_
#define _WX_GAUGE_H_
#include "wx/control.h"
// Group box
class WXDLLIMPEXP_CORE wxGauge: public wxGaugeBase
{
public:
wxGauge() = default;
wxGauge(wxWindow *parent, wxWindowID id,
int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxGaugeNameStr))
{
Create(parent, id, range, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxGaugeNameStr));
// set gauge range/value
virtual void SetRange(int range) override;
virtual void SetValue(int pos) override;
virtual int GetValue() const override;
void Pulse() override;
protected:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGauge);
};
#endif
// _WX_GAUGE_H_

View File

@@ -0,0 +1,136 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/glcanvas.h
// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GLCANVAS_H_
#define _WX_GLCANVAS_H_
#ifdef __WXOSX_IPHONE__
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#define wxUSE_OPENGL_EMULATION 1
#else
#ifndef GL_SILENCE_DEPRECATION
#define GL_SILENCE_DEPRECATION
#endif
#include <OpenGL/gl.h>
#endif
#include "wx/vector.h"
// low level calls
WXDLLIMPEXP_GL WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext );
WXDLLIMPEXP_GL void WXGLDestroyContext( WXGLContext context );
WXDLLIMPEXP_GL WXGLContext WXGLGetCurrentContext();
WXDLLIMPEXP_GL bool WXGLSetCurrentContext(WXGLContext context);
WXDLLIMPEXP_GL WXGLPixelFormat WXGLChoosePixelFormat(const int *GLAttrs = nullptr,
int n1 = 0,
const int *ctxAttrs = nullptr,
int n2 = 0);
WXDLLIMPEXP_GL void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat );
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
{
public:
wxGLContext(wxGLCanvas *win,
const wxGLContext *other = nullptr,
const wxGLContextAttrs *ctxAttrs = nullptr);
virtual ~wxGLContext();
virtual bool SetCurrent(const wxGLCanvas& win) const override;
// Mac-specific
WXGLContext GetWXGLContext() const { return m_glContext; }
private:
WXGLContext m_glContext;
wxDECLARE_NO_COPY_CLASS(wxGLContext);
};
class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
{
public:
wxGLCanvas() = default;
wxGLCanvas(wxWindow *parent,
const wxGLAttributes& dispAttrs,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette);
wxGLCanvas(wxWindow *parent,
wxWindowID id = wxID_ANY,
const int *attribList = nullptr,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette);
bool Create(wxWindow *parent,
const wxGLAttributes& dispAttrs,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette);
bool Create(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const int *attribList = nullptr,
const wxPalette& palette = wxNullPalette);
virtual ~wxGLCanvas();
// implement wxGLCanvasBase methods
virtual bool SwapBuffers() override;
// Mac-specific functions
// ----------------------
// return true if multisample extension is supported
static bool IsAGLMultiSampleAvailable();
// return the pixel format used by this window
WXGLPixelFormat GetWXGLPixelFormat() const { return m_glFormat; }
// Return the copy of attributes passed at ctor
wxGLAttributes& GetGLDispAttrs() { return m_GLAttrs; }
// update the view port of the current context to match this window
void SetViewport();
// implementation-only from now on
protected:
bool DoCreate(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name);
WXGLPixelFormat m_glFormat = nullptr;
wxGLAttributes m_GLAttrs;
wxDECLARE_CLASS(wxGLCanvas);
};
#endif // _WX_GLCANVAS_H_

View File

@@ -0,0 +1,399 @@
/*
* Name: wx/osx/iphone/chkconf.h
* Purpose: Compiler-specific configuration checking
* Author: Stefan Csomor
* Modified by:
* Created: 2008-07-30
* Copyright: (c) Stefan Csomor
* Licence: wxWindows licence
*/
#ifndef _WX_OSX_IPHONE_CHKCONF_H_
#define _WX_OSX_IPHONE_CHKCONF_H_
/*
* text rendering system
*/
/* we have different options and we turn on all that make sense
* under a certain platform
*/
#define wxHAS_OPENGL_ES
#define wxOSX_USE_QUICKTIME 0
#define wxOSX_USE_AUDIOTOOLBOX 1
/*
* turning off capabilities that don't work under iphone yet
*/
#if wxUSE_MIMETYPE
#undef wxUSE_MIMETYPE
#define wxUSE_MIMETYPE 0
#endif
#if wxUSE_MDI
#undef wxUSE_MDI
#define wxUSE_MDI 0
#endif
#if wxUSE_MDI_ARCHITECTURE
#undef wxUSE_MDI_ARCHITECTURE
#define wxUSE_MDI_ARCHITECTURE 0
#endif
#if wxUSE_DRAG_AND_DROP
#undef wxUSE_DRAG_AND_DROP
#define wxUSE_DRAG_AND_DROP 0
#endif
#if wxUSE_TASKBARICON
#undef wxUSE_TASKBARICON
#define wxUSE_TASKBARICON 0
#endif
#if wxUSE_TOOLTIPS
#undef wxUSE_TOOLTIPS
#define wxUSE_TOOLTIPS 0
#endif
#if wxUSE_DATAVIEWCTRL
#undef wxUSE_DATAVIEWCTRL
#define wxUSE_DATAVIEWCTRL 0
#endif
#if wxUSE_TREELISTCTRL
#undef wxUSE_TREELISTCTRL
#define wxUSE_TREELISTCTRL 0
#endif
#if wxUSE_DRAG_AND_DROP
#undef wxUSE_DRAG_AND_DROP
#define wxUSE_DRAG_AND_DROP 0
#endif
#if wxUSE_TASKBARICON
#undef wxUSE_TASKBARICON
#define wxUSE_TASKBARICON 0
#endif
#define wxUSE_BUTTON 1
#if wxUSE_CARET
#undef wxUSE_CARET
#define wxUSE_CARET 0
#endif
#if wxUSE_CHOICE
#undef wxUSE_CHOICE
#define wxUSE_CHOICE 0
#endif
#if wxUSE_COMBOBOX
#undef wxUSE_COMBOBOX
#define wxUSE_COMBOBOX 0
#endif
#ifndef __WXUNIVERSAL__
#undef wxUSE_SCROLLBAR
#define wxUSE_SCROLLBAR 0
#endif
#undef wxUSE_STATUSBAR
#undef wxUSE_NATIVE_STATUSBAR
#undef wxUSE_ABOUTDLG
#undef wxUSE_STATLINE
#undef wxUSE_COLLPANE
#undef wxUSE_STATBMP
#undef wxUSE_STATBOX
#undef wxUSE_RADIOBTN
#undef wxUSE_RADIOBOX
#undef wxUSE_TOGGLEBTN
#define wxUSE_STATUSBAR 0
#define wxUSE_NATIVE_STATUSBAR 0
#define wxUSE_ABOUTDLG 0
#define wxUSE_STATLINE 0
#define wxUSE_COLLPANE 0
#define wxUSE_STATBMP 0
#define wxUSE_STATBOX 0
#define wxUSE_RADIOBTN 0
#define wxUSE_RADIOBOX 0
#define wxUSE_TOGGLEBTN 0
#undef wxUSE_HTML
#define wxUSE_HTML 0
#undef wxUSE_RICHTEXT
#define wxUSE_RICHTEXT 0
#undef wxUSE_ACTIVITYINDICATOR
#undef wxUSE_ADDREMOVECTRL
#undef wxUSE_ANIMATIONCTRL
#undef wxUSE_CALENDARCTRL
#undef wxUSE_COMBOCTRL
#undef wxUSE_ODCOMBOBOX
#undef wxUSE_BITMAPCOMBOBOX
#undef wxUSE_BMPBUTTON
#undef wxUSE_CHECKLISTBOX
#undef wxUSE_GRID
#undef wxUSE_LISTBOX
#undef wxUSE_LISTCTRL
#undef wxUSE_NOTEBOOK
#undef wxUSE_SPINBTN
#undef wxUSE_SPINCTRL
#undef wxUSE_TREECTRL
#undef wxUSE_DATEPICKCTRL
#undef wxUSE_DATAVIEWCTRL
#undef wxUSE_EDITABLELISTBOX
#undef wxUSE_FILEPICKERCTRL
#undef wxUSE_DIRPICKERCTRL
#undef wxUSE_FILECTRL
#undef wxUSE_COLOURPICKERCTRL
#undef wxUSE_FONTPICKERCTRL
#undef wxUSE_DEBUGREPORT
#undef wxUSE_HYPERLINKCTRL
#undef wxUSE_STC
#undef wxUSE_AUI
#undef wxUSE_BUSYINFO
#undef wxUSE_SEARCHCTRL
#define wxUSE_ACTIVITYINDICATOR 0
#define wxUSE_ADDREMOVECTRL 0
#define wxUSE_ANIMATIONCTRL 0
#define wxUSE_CALENDARCTRL 0
#define wxUSE_COMBOCTRL 0
#define wxUSE_ODCOMBOBOX 0
#define wxUSE_BITMAPCOMBOBOX 0
#define wxUSE_BMPBUTTON 0
#define wxUSE_CHECKLISTBOX 0
#define wxUSE_GRID 0
#define wxUSE_LISTBOX 0
#define wxUSE_LISTCTRL 0
#define wxUSE_NOTEBOOK 0
#define wxUSE_SPINBTN 0
#define wxUSE_SPINCTRL 0
#define wxUSE_TREECTRL 0
#define wxUSE_DATEPICKCTRL 0
#define wxUSE_DATAVIEWCTRL 0
#define wxUSE_EDITABLELISTBOX 0
#define wxUSE_FILEPICKERCTRL 0
#define wxUSE_DIRPICKERCTRL 0
#define wxUSE_FILECTRL 0
#define wxUSE_COLOURPICKERCTRL 0
#define wxUSE_FONTPICKERCTRL 0
#define wxUSE_DEBUGREPORT 0
#define wxUSE_HYPERLINKCTRL 0
#define wxUSE_STC 0
#define wxUSE_AUI 0
#define wxUSE_BUSYINFO 0
#define wxUSE_SEARCHCTRL 0
#undef wxUSE_LOGWINDOW
#undef wxUSE_LOG_DIALOG
#undef wxUSE_LISTBOOK
#undef wxUSE_CHOICEBOOK
#undef wxUSE_TREEBOOK
#undef wxUSE_TOOLBOOK
#undef wxUSE_CHOICEDLG
#undef wxUSE_HELP
#undef wxUSE_PROGRESSDLG
#undef wxUSE_FONTDLG
#undef wxUSE_FILEDLG
#undef wxUSE_CHOICEDLG
#undef wxUSE_NUMBERDLG
#undef wxUSE_TEXTDLG
#undef wxUSE_DIRDLG
#undef wxUSE_STARTUP_TIPS
#undef wxUSE_WIZARDDLG
#undef wxUSE_TOOLBAR_NATIVE
#undef wxUSE_FINDREPLDLG
#undef wxUSE_TASKBARICON
#undef wxUSE_REARRANGECTRL
#undef wxUSE_NATIVE_DATAVIEWCTRL
#define wxUSE_LOGWINDOW 0
#define wxUSE_LOG_DIALOG 0
#define wxUSE_LISTBOOK 0
#define wxUSE_CHOICEBOOK 0
#define wxUSE_TREEBOOK 0
#define wxUSE_TOOLBOOK 0
#define wxUSE_CHOICEDLG 0
#define wxUSE_HELP 0
#define wxUSE_PROGRESSDLG 0
#define wxUSE_FONTDLG 0
#define wxUSE_FILEDLG 0
#define wxUSE_CHOICEDLG 0
#define wxUSE_NUMBERDLG 0
#define wxUSE_TEXTDLG 0
#define wxUSE_DIRDLG 0
#define wxUSE_STARTUP_TIPS 0
#define wxUSE_WIZARDDLG 0
#define wxUSE_TOOLBAR_NATIVE 0
#define wxUSE_FINDREPLDLG 0
#define wxUSE_TASKBARICON 0
#define wxUSE_REARRANGECTRL 0
#define wxUSE_NATIVE_DATAVIEWCTRL 0
#if wxUSE_WXHTML_HELP
#undef wxUSE_WXHTML_HELP
#define wxUSE_WXHTML_HELP 0
#endif
#if wxUSE_DOC_VIEW_ARCHITECTURE
#undef wxUSE_DOC_VIEW_ARCHITECTURE
#define wxUSE_DOC_VIEW_ARCHITECTURE 0
#endif
#if wxUSE_PRINTING_ARCHITECTURE
#undef wxUSE_PRINTING_ARCHITECTURE
#define wxUSE_PRINTING_ARCHITECTURE 0
#endif
#if wxUSE_MENUS
#undef wxUSE_MENUS
// we are basing our implementatino on UIMenuElement
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
#define wxUSE_MENUS 1
#else
#define wxUSE_MENUS 0
#endif
#endif
#if wxUSE_MENUBAR
#undef wxUSE_MENUBAR
#define wxUSE_MENUBAR 0
#endif
/*
#if wxUSE_POPUPWIN
#undef wxUSE_POPUPWIN
#define wxUSE_POPUPWIN 0
#endif
#if wxUSE_COMBOBOX
#undef wxUSE_COMBOBOX
#define wxUSE_COMBOBOX 0
#endif
#if wxUSE_CALENDARCTRL
#undef wxUSE_CALENDARCTRL
#define wxUSE_CALENDARCTRL 0
#endif
*/
#if wxUSE_CLIPBOARD
#undef wxUSE_CLIPBOARD
#define wxUSE_CLIPBOARD 0
#endif // wxUSE_CLIPBOARD
/*
#if wxUSE_GLCANVAS
#undef wxUSE_GLCANVAS
#define wxUSE_GLCANVAS 0
#endif // wxUSE_GLCANVAS
*/
#if wxUSE_COLOURDLG
#undef wxUSE_COLOURDLG
#define wxUSE_COLOURDLG 0
#endif // wxUSE_COLOURDLG
// iphone has a toolbar that is a regular UIView
#ifdef wxOSX_USE_NATIVE_TOOLBAR
#if wxOSX_USE_NATIVE_TOOLBAR
#undef wxOSX_USE_NATIVE_TOOLBAR
#define wxOSX_USE_NATIVE_TOOLBAR 0
#endif
#else
#define wxOSX_USE_NATIVE_TOOLBAR 0
#endif
#if wxUSE_RIBBON
#undef wxUSE_RIBBON
#define wxUSE_RIBBON 0
#endif
#if wxUSE_INFOBAR
#undef wxUSE_INFOBAR
#define wxUSE_INFOBAR 0
#endif
#if wxUSE_FILE_HISTORY
#undef wxUSE_FILE_HISTORY
#define wxUSE_FILE_HISTORY 0
#endif
#if wxUSE_NOTIFICATION_MESSAGE
#undef wxUSE_NOTIFICATION_MESSAGE
#define wxUSE_NOTIFICATION_MESSAGE 0
#endif
#undef wxUSE_PREFERENCES_EDITOR
#define wxUSE_PREFERENCES_EDITOR 0
#if wxUSE_PROPGRID
#undef wxUSE_PROPGRID
#define wxUSE_PROPGRID 0
#endif
#if wxUSE_WEBKIT
#undef wxUSE_WEBKIT
#define wxUSE_WEBKIT 0
#endif
#if wxUSE_DATAOBJ
#undef wxUSE_DATAOBJ
#define wxUSE_DATAOBJ 0
#endif
#if wxUSE_UIACTIONSIMULATOR
#undef wxUSE_UIACTIONSIMULATOR
#define wxUSE_UIACTIONSIMULATOR 0
#endif
#if wxUSE_RICHMSGDLG
#undef wxUSE_RICHMSGDLG
#define wxUSE_RICHMSGDLG 0
#endif
#if wxUSE_RICHTEXT
#undef wxUSE_RICHTEXT
#define wxUSE_RICHTEXT 0
#endif
#if wxUSE_TIMEPICKCTRL
#undef wxUSE_TIMEPICKCTRL
#define wxUSE_TIMEPICKCTRL 0
#endif
#if wxUSE_RICHTOOLTIP
#undef wxUSE_RICHTOOLTIP
#define wxUSE_RICHTOOLTIP 0
#endif
#if wxUSE_WEBVIEW
#undef wxUSE_WEBVIEW
#define wxUSE_WEBVIEW 0
#endif
#if wxUSE_SECRETSTORE
#undef wxUSE_SECRETSTORE
#define wxUSE_SECRETSTORE 0
#endif
// IconRef datatype does not exist on iOS
#undef wxOSX_USE_ICONREF
#define wxOSX_USE_ICONREF 0
#endif
/* _WX_OSX_IPHONE_CHKCONF_H_ */

View File

@@ -0,0 +1,242 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/iphone/private.h
// Purpose: Private declarations: as this header is only included by
// wxWidgets itself, it may contain identifiers which don't start
// with "wx".
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_IPHONE_H_
#define _WX_PRIVATE_IPHONE_H_
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#include <CoreText/CTFont.h>
#include <CoreText/CTStringAttributes.h>
#include <CoreText/CTLine.h>
#if wxUSE_GUI
#include "wx/bmpbndl.h"
typedef CGRect WXRect;
OSStatus WXDLLIMPEXP_CORE wxMacDrawCGImage(
CGContextRef inContext,
const CGRect * inBounds,
CGImageRef inImage) ;
WX_UIImage WXDLLIMPEXP_CORE wxOSXGetUIImageFromCGImage( CGImageRef image );
wxBitmapBundle WXDLLIMPEXP_CORE wxOSXCreateSystemBitmapBundle(const wxString& id, const wxString &client, const wxSize& size);
class WXDLLIMPEXP_CORE wxWidgetIPhoneImpl : public wxWidgetImpl
{
public :
wxWidgetIPhoneImpl( wxWindowMac* peer , WXWidget w, int flags = 0 ) ;
wxWidgetIPhoneImpl() ;
~wxWidgetIPhoneImpl();
void Init();
virtual bool IsVisible() const ;
virtual void SetVisibility( bool visible );
virtual void Raise();
virtual void Lower();
virtual void ScrollRect( const wxRect *rect, int dx, int dy );
virtual WXWidget GetWXWidget() const { return m_osxView; }
virtual void SetBackgroundColour( const wxColour& col ) ;
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
virtual void SetForegroundColour( const wxColour& col ) ;
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
virtual void Move(int x, int y, int width, int height);
virtual void GetPosition( int &x, int &y ) const;
virtual void GetSize( int &width, int &height ) const;
virtual void SetControlSize( wxWindowVariant variant );
virtual double GetContentScaleFactor() const ;
virtual void SetNeedsDisplay( const wxRect* where = nullptr );
virtual bool GetNeedsDisplay() const;
virtual bool CanFocus() const;
// return true if successful
virtual bool SetFocus();
virtual bool HasFocus() const;
void RemoveFromParent();
void Embed( wxWidgetImpl *parent );
void SetDefaultButton( bool isDefault );
void PerformClick();
virtual void SetLabel(const wxString& title);
void SetCursor( const wxCursor & cursor );
void CaptureMouse();
void ReleaseMouse();
wxInt32 GetValue() const;
void SetValue( wxInt32 v );
virtual wxBitmap GetBitmap() const;
virtual void SetBitmap( const wxBitmapBundle& bitmap );
virtual void SetBitmapPosition( wxDirection dir );
void SetupTabs( const wxNotebook &notebook );
void GetBestRect( wxRect *r ) const;
bool IsEnabled() const;
void Enable( bool enable );
bool ButtonClickDidStateChange() { return true ;}
void SetMinimum( wxInt32 v );
void SetMaximum( wxInt32 v );
void SetIncrement(int WXUNUSED(value)) { }
wxInt32 GetMinimum() const;
wxInt32 GetMaximum() const;
int GetIncrement() const { return 1; }
void PulseGauge();
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
void SetFont(const wxFont & font);
void InstallEventHandler( WXWidget control = nullptr );
bool EnableTouchEvents(int WXUNUSED(eventsMask)) { return false; }
virtual void DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow);
// thunk connected calls
virtual void drawRect(CGRect* rect, WXWidget slf, void* _cmd);
virtual void touchEvent(WX_NSSet touches, WX_UIEvent event, WXWidget slf, void* _cmd);
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);
// action
virtual void controlAction(void* sender, wxUint32 controlEvent, WX_UIEvent rawEvent);
virtual void controlTextDidChange();
protected:
WXWidget m_osxView;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetIPhoneImpl);
};
class wxNonOwnedWindowIPhoneImpl : public wxNonOwnedWindowImpl
{
public :
wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonownedwnd) ;
wxNonOwnedWindowIPhoneImpl();
virtual ~wxNonOwnedWindowIPhoneImpl();
virtual void WillBeDestroyed() override;
void Create(wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name ) override;
void Create( wxWindow* parent, WXWindow nativeWindow );
WXWindow GetWXWindow() const override;
void Raise() override;
void Lower() override;
bool Show(bool show) override;
bool ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout) override;
void Update() override;
bool SetTransparent(wxByte alpha) override;
bool SetBackgroundColour(const wxColour& col ) override;
void SetExtraStyle( long exStyle ) override;
bool SetBackgroundStyle(wxBackgroundStyle style) override;
bool CanSetTransparent() override;
void MoveWindow(int x, int y, int width, int height) override;
void GetPosition( int &x, int &y ) const override;
void GetSize( int &width, int &height ) const override;
void GetContentArea( int &left , int &top , int &width , int &height ) const override;
bool SetShape(const wxRegion& region) override;
virtual void SetTitle( const wxString& title ) override;
// Title bar buttons don't exist in iOS.
virtual bool EnableCloseButton(bool WXUNUSED(enable)) override { return false; }
virtual bool EnableMaximizeButton(bool WXUNUSED(enable)) override { return false; }
virtual bool EnableMinimizeButton(bool WXUNUSED(enable)) override { return false; }
virtual bool IsMaximized() const override;
virtual bool IsIconized() const override;
virtual void Iconize( bool iconize ) override;
virtual void Maximize(bool maximize) override;
virtual bool IsFullScreen() const override;
virtual bool EnableFullScreenView(bool enable, long style) override;
virtual bool ShowFullScreen(bool show, long style) override;
virtual wxContentProtection GetContentProtection() const override
{ return wxCONTENT_PROTECTION_NONE; }
virtual bool SetContentProtection(wxContentProtection WXUNUSED(contentProtection)) override
{ return false; }
virtual void RequestUserAttention(int flags) override;
virtual void ScreenToWindow( int *x, int *y ) override;
virtual void WindowToScreen( int *x, int *y ) override;
// FIXME: Does iPhone have a concept of inactive windows?
virtual bool IsActive() override { return true; }
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
virtual bool InitialShowEventSent() { return m_initialShowSent; }
protected :
WX_UIWindow m_macWindow;
void * m_macFullScreenData ;
bool m_initialShowSent;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowIPhoneImpl);
};
#ifdef __OBJC__
WXDLLIMPEXP_CORE CGRect wxToNSRect( UIView* parent, const wxRect& r );
WXDLLIMPEXP_CORE wxRect wxFromNSRect( UIView* parent, const CGRect& rect );
WXDLLIMPEXP_CORE CGPoint wxToNSPoint( UIView* parent, const wxPoint& p );
WXDLLIMPEXP_CORE wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p );
WXDLLIMPEXP_CORE CGPoint wxToNSPointF(UIView* parent, const wxPoint2DDouble& p);
WXDLLIMPEXP_CORE wxPoint2DDouble wxFromNSPointF(UIView* parent, const CGPoint& p);
CGRect WXDLLIMPEXP_CORE wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size ,
bool adjustForOrigin = true );
@interface wxUIButton : UIButton
{
}
@end
@interface wxUIView : UIView
{
}
@end // wxUIView
void WXDLLIMPEXP_CORE wxOSXIPhoneClassAddWXMethods(Class c);
#endif
#endif // wxUSE_GUI
#endif
// _WX_PRIVATE_IPHONE_H_

View File

@@ -0,0 +1,113 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/iphone/private/textimpl.h
// Purpose: textcontrol implementation classes that have to be exposed
// Author: Stefan Csomor
// Created: 03/02/99
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
#include "wx/combobox.h"
#include "wx/osx/private.h"
// implementation exposed, so that search control can pull it
class wxUITextFieldControl : public wxWidgetIPhoneImpl, public wxTextWidgetImpl
{
public :
wxUITextFieldControl( wxTextCtrl *wxPeer, UITextField* w );
virtual ~wxUITextFieldControl();
virtual wxTextSearchResult SearchText(const wxTextSearch &search) const;
virtual wxString GetStringValue() const ;
virtual void SetStringValue( const wxString &str) ;
virtual wxString GetRTFValue() const;
virtual void SetRTFValue(const wxString& WXUNUSED(str));
virtual void Copy() ;
virtual void Cut() ;
virtual void Paste() ;
virtual bool CanPaste() const ;
virtual void SetEditable(bool editable) ;
virtual void GetSelection( long* from, long* to) const ;
virtual void SetSelection( long from , long to );
virtual void WriteText(const wxString& str) ;
virtual bool HasOwnContextMenu() const { return true; }
virtual wxSize GetBestSize() const;
virtual bool SetHint(const wxString& hint);
virtual void controlAction(WXWidget slf, void* _cmd, void *sender);
protected :
UITextField* m_textField;
NSObject<UITextFieldDelegate>* m_delegate;
long m_selStart;
long m_selEnd;
};
class wxUITextViewControl : public wxWidgetIPhoneImpl, public wxTextWidgetImpl
{
public:
wxUITextViewControl( wxTextCtrl *wxPeer, UITextView* w );
virtual ~wxUITextViewControl();
virtual wxTextSearchResult SearchText(const wxTextSearch &search) const;
virtual wxString GetStringValue() const ;
virtual void SetStringValue( const wxString &str) ;
virtual wxString GetRTFValue() const;
virtual void SetRTFValue(const wxString& WXUNUSED(str));
virtual void Copy() ;
virtual void Cut() ;
virtual void Paste() ;
virtual bool CanPaste() const ;
virtual void SetEditable(bool editable) ;
virtual void GetSelection( long* from, long* to) const ;
virtual void SetSelection( long from , long to );
virtual void WriteText(const wxString& str) ;
virtual void SetFont(const wxFont & font);
virtual bool GetStyle(long position, wxTextAttr& style);
virtual void SetStyle(long start, long end, const wxTextAttr& style);
virtual bool CanFocus() const;
virtual bool HasOwnContextMenu() const { return true; }
virtual wxSize GetBestSize() const;
protected:
NSObject<UITextViewDelegate>* m_delegate;
UITextView* m_textView;
};
#if 0
class wxNSComboBoxControl : public wxUITextFieldControl, public wxComboWidgetImpl
{
public :
wxNSComboBoxControl( wxWindow *wxPeer, WXWidget w );
virtual ~wxNSComboBoxControl();
virtual int GetSelectedItem() const;
virtual void SetSelectedItem(int item);
virtual int GetNumberOfItems() const;
virtual void InsertItem(int pos, const wxString& item);
virtual void RemoveItem(int pos);
virtual void Clear();
virtual wxString GetStringAtIndex(int pos) const;
virtual int FindString(const wxString& text) const;
private:
NSComboBox* m_comboBox;
};
#endif
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/joystick.h
// Purpose: wxJoystick class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_JOYSTICK_H_
#define _WX_JOYSTICK_H_
#include "wx/event.h"
class WXDLLIMPEXP_ADV wxJoystick: public wxObject
{
wxDECLARE_DYNAMIC_CLASS(wxJoystick);
public:
/*
* Public interface
*/
wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; }
// Attributes
////////////////////////////////////////////////////////////////////////////
wxPoint GetPosition() const;
int GetPosition(unsigned axis) const;
bool GetButtonState(unsigned button) const;
int GetZPosition() const;
int GetButtonState() const;
int GetPOVPosition() const;
int GetPOVCTSPosition() const;
int GetRudderPosition() const;
int GetUPosition() const;
int GetVPosition() const;
int GetMovementThreshold() const;
void SetMovementThreshold(int threshold) ;
// Capabilities
////////////////////////////////////////////////////////////////////////////
bool IsOk() const; // Checks that the joystick is functioning
static int GetNumberJoysticks() ;
int GetManufacturerId() const ;
int GetProductId() const ;
wxString GetProductName() const ;
int GetXMin() const;
int GetYMin() const;
int GetZMin() const;
int GetXMax() const;
int GetYMax() const;
int GetZMax() const;
int GetNumberButtons() const;
int GetNumberAxes() const;
int GetMaxButtons() const;
int GetMaxAxes() const;
int GetPollingMin() const;
int GetPollingMax() const;
int GetRudderMin() const;
int GetRudderMax() const;
int GetUMin() const;
int GetUMax() const;
int GetVMin() const;
int GetVMax() const;
bool HasRudder() const;
bool HasZ() const;
bool HasU() const;
bool HasV() const;
bool HasPOV() const;
bool HasPOV4Dir() const;
bool HasPOVCTS() const;
// Operations
////////////////////////////////////////////////////////////////////////////
// pollingFreq = 0 means that movement events are sent when above the threshold.
// If pollingFreq > 0, events are received every this many milliseconds.
bool SetCapture(wxWindow* win, int pollingFreq = 0);
bool ReleaseCapture();
protected:
int m_joystick;
};
#endif
// _WX_JOYSTICK_H_

View File

@@ -0,0 +1,179 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/listbox.h
// Purpose: wxListBox class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTBOX_H_
#define _WX_LISTBOX_H_
// ----------------------------------------------------------------------------
// simple types
// ----------------------------------------------------------------------------
#include "wx/dynarray.h"
#include "wx/arrstr.h"
// forward decl for GetSelections()
class wxArrayInt;
// forward decl for wxListWidgetImpl implementation type.
class wxListWidgetImpl;
// List box item
WX_DEFINE_ARRAY( char* , wxListDataArray );
// ----------------------------------------------------------------------------
// List box control
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxListWidgetColumn;
class WXDLLIMPEXP_FWD_CORE wxListWidgetCellValue;
class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase
{
public:
// ctors and such
wxListBox();
wxListBox(
wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr))
{
Create(parent, winid, pos, size, n, choices, style, validator, name);
}
wxListBox(
wxWindow *parent,
wxWindowID winid,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr))
{
Create(parent, winid, pos, size, choices, style, validator, name);
}
bool Create(
wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0,
const wxString choices[] = nullptr,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr));
bool Create(
wxWindow *parent,
wxWindowID winid,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxASCII_STR(wxListBoxNameStr));
virtual ~wxListBox();
// implement base class pure virtuals
virtual unsigned int GetCount() const override;
virtual wxString GetString(unsigned int n) const override;
virtual void SetString(unsigned int n, const wxString& s) override;
virtual int FindString(const wxString& s, bool bCase = false) const override;
// data callbacks
virtual void GetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value );
virtual void SetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value );
virtual bool IsSelected(int n) const override;
virtual int GetSelection() const override;
virtual int GetSelections(wxArrayInt& aSelections) const override;
virtual void EnsureVisible(int n) override;
virtual int GetTopItem() const override;
virtual int GetCountPerPage() const override;
virtual wxVisualAttributes GetDefaultAttributes() const override
{
return GetClassDefaultAttributes(GetWindowVariant());
}
// wxCheckListBox support
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
wxListWidgetImpl* GetListPeer() const;
virtual void HandleLineEvent( unsigned int n, bool doubleClick );
// This is called by wxNSTableView
void MacHandleSelectionChange(int row);
protected:
// callback for derived classes which may have to insert additional data
// at a certain line - which cannot be predetermined for sorted list data
virtual void OnItemInserted(unsigned int pos);
virtual void DoClear() override;
virtual void DoDeleteOneItem(unsigned int n) override;
// from wxItemContainer
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type) override;
virtual void DoSetItemClientData(unsigned int n, void* clientData) override;
virtual void* DoGetItemClientData(unsigned int n) const override;
// from wxListBoxBase
virtual void DoSetSelection(int n, bool select) override;
virtual void DoSetFirstItem(int n) override;
virtual int DoListHitTest(const wxPoint& point) const override;
// free memory (common part of Clear() and dtor)
// prevent collision with some BSD definitions of macro Free()
void FreeData();
virtual wxSize DoGetBestSize() const override;
bool m_blockEvents;
wxListWidgetColumn* m_textColumn;
// data storage (copied from univ)
// the array containing all items (it is sorted if the listbox has
// wxLB_SORT style)
union
{
wxArrayString *unsorted;
wxSortedArrayString *sorted;
} m_strings;
// and this one the client data (either void or wxClientData)
wxArrayPtrVoid m_itemsClientData;
private:
// Mostly the same as DoSetSelection() but doesn't call EnsureVisible().
void DoSetSelectionWithoutEnsureVisible(int n, bool select);
wxDECLARE_DYNAMIC_CLASS(wxListBox);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_LISTBOX_H_

View File

@@ -0,0 +1,153 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/mdi.h
// Purpose: MDI (Multiple Document Interface) classes.
// Author: Stefan Csomor
// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// (c) 2008 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_CARBON_MDI_H_
#define _WX_OSX_CARBON_MDI_H_
class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase
{
public:
wxMDIParentFrame() { Init(); }
wxMDIParentFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
Init();
Create(parent, id, title, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxASCII_STR(wxFrameNameStr));
virtual ~wxMDIParentFrame();
// implement/override base class [pure] virtuals
// ---------------------------------------------
static bool IsTDI() { return false; }
virtual void AddChild(wxWindowBase *child) override;
virtual void RemoveChild(wxWindowBase *child) override;
virtual void ActivateNext() override { /* TODO */ }
virtual void ActivatePrevious() override { /* TODO */ }
virtual bool Show(bool show = true) override;
// Mac-specific implementation from now on
// ---------------------------------------
// Mac OS activate event
virtual void MacActivate(long timestamp, bool activating) override;
// wxWidgets activate event
void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void SetMenuBar(wxMenuBar *menu_bar) override;
// Get rect to be used to center top-level children
virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h) override;
protected:
// common part of all ctors
void Init();
// returns true if this frame has some contents and so should be visible,
// false if it's used solely as container for its children
bool ShouldBeVisible() const;
wxMenu *m_windowMenu;
// true if MDI Frame is intercepting commands, not child
bool m_parentFrameActive;
// true if the frame should be shown but is not because it is empty and
// useless otherwise than a container for its children
bool m_shouldBeShown;
private:
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS(wxMDIParentFrame);
};
class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase
{
public:
wxMDIChildFrame() { Init(); }
wxMDIChildFrame(wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
Init() ;
Create(parent, id, title, pos, size, style, name);
}
bool Create(wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxASCII_STR(wxFrameNameStr));
virtual ~wxMDIChildFrame();
// un-override the base class override
virtual bool IsTopLevel() const override { return true; }
// implement MDI operations
virtual void Activate() override;
// Mac OS activate event
virtual void MacActivate(long timestamp, bool activating) override;
protected:
// common part of all ctors
void Init();
wxDECLARE_DYNAMIC_CLASS(wxMDIChildFrame);
};
class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
{
public:
wxMDIClientWindow() = default;
virtual ~wxMDIClientWindow();
virtual bool CreateClient(wxMDIParentFrame *parent,
long style = wxVSCROLL | wxHSCROLL) override;
protected:
virtual void DoGetClientSize(int *width, int *height) const override;
wxDECLARE_DYNAMIC_CLASS(wxMDIClientWindow);
};
#endif // _WX_OSX_CARBON_MDI_H_

View File

@@ -0,0 +1,200 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/menu.h
// Purpose: wxMenu, wxMenuBar classes
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MENU_H_
#define _WX_MENU_H_
class WXDLLIMPEXP_FWD_CORE wxFrame;
#include "wx/arrstr.h"
class wxMenuRadioItemsData;
// ----------------------------------------------------------------------------
// Menu
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxMenuImpl ;
class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase
{
public:
// ctors & dtor
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style) { Init(); }
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
virtual ~wxMenu();
virtual void SetTitle(const wxString& title) override;
virtual void SetInvokingWindow(wxWindow* win) override;
bool ProcessCommand(wxCommandEvent& event);
// get the menu handle
WXHMENU GetHMenu() const ;
// implementation only from now on
// -------------------------------
bool HandleCommandUpdateStatus( wxMenuItem* menuItem );
bool HandleCommandProcess( wxMenuItem* menuItem );
void HandleMenuItemHighlighted( wxMenuItem* menuItem );
void HandleMenuOpened();
void HandleMenuClosed();
wxMenuImpl* GetPeer() { return m_peer; }
// make sure we can veto
void SetAllowRearrange( bool allow );
bool AllowRearrange() const { return m_allowRearrange; }
// if a menu is used purely for internal implementation reasons (eg wxChoice)
// we don't want native menu events being triggered
void SetNoEventsMode( bool noEvents );
bool GetNoEventsMode() const { return m_noEventsMode; }
// Returns the start and end position of the radio group to which the item
// at given position belongs. Return false if there is no radio group
// containing this position.
bool OSXGetRadioGroupRange(int pos, int *start, int *end) const;
#if wxUSE_MENUBAR
virtual void Attach(wxMenuBarBase *menubar) override;
#endif
void SetupBitmaps();
protected:
// hide special menu items like exit, preferences etc
// that are expected in the app menu
void DoRearrange() ;
virtual wxMenuItem* DoAppend(wxMenuItem *item) override;
virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item) override;
virtual wxMenuItem* DoRemove(wxMenuItem *item) override;
private:
// common part of all ctors
void Init();
// common part of Do{Append,Insert}(): behaves as Append if pos == -1
bool DoInsertOrAppend(wxMenuItem *item, size_t pos = (size_t)-1);
// Common part of HandleMenu{Opened,Closed}().
void DoHandleMenuOpenedOrClosed(wxEventType evtType);
// if TRUE, insert a break before appending the next item
bool m_doBreak;
// in this menu rearranging of menu items (esp hiding) is allowed
bool m_allowRearrange;
// don't trigger native events
bool m_noEventsMode;
wxMenuRadioItemsData* m_radioData;
wxMenuImpl* m_peer;
wxDECLARE_DYNAMIC_CLASS(wxMenu);
};
#if wxUSE_MENUBAR
// the iphone only has popup-menus
// ----------------------------------------------------------------------------
// Menu Bar (a la Windows)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
{
public:
// ctors & dtor
// default constructor
wxMenuBar();
// unused under MSW
wxMenuBar(long style);
// menubar takes ownership of the menus arrays but copies the titles
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
virtual ~wxMenuBar();
// menubar construction
virtual bool Append( wxMenu *menu, const wxString &title ) override;
virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title) override;
virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title) override;
virtual wxMenu *Remove(size_t pos) override;
virtual void EnableTop( size_t pos, bool flag ) override;
virtual bool IsEnabledTop(size_t pos) const override;
virtual void SetMenuLabel( size_t pos, const wxString& label ) override;
virtual wxString GetMenuLabel( size_t pos ) const override;
virtual bool Enable( bool enable = true ) override;
// for virtual function hiding
virtual void Enable( int itemid, bool enable )
{
wxMenuBarBase::Enable( itemid, enable );
}
// implementation from now on
// returns TRUE if we're attached to a frame
bool IsAttached() const { return m_menuBarFrame != nullptr; }
// get the frame we live in
wxFrame *GetFrame() const { return m_menuBarFrame; }
// if the menubar is modified, the display is not updated automatically,
// call this function to update it (m_menuBarFrame should be non-null)
void Refresh(bool eraseBackground = true, const wxRect *rect = nullptr) override;
wxMenu *OSXGetAppleMenu() const { return m_appleMenu; }
static void SetAutoWindowMenu( bool enable ) { s_macAutoWindowMenu = enable ; }
static bool GetAutoWindowMenu() { return s_macAutoWindowMenu ; }
void MacUninstallMenuBar() ;
void MacInstallMenuBar() ;
static wxMenuBar* MacGetInstalledMenuBar() { return s_macInstalledMenuBar ; }
static void MacSetCommonMenuBar(wxMenuBar* menubar) { s_macCommonMenuBar=menubar; }
static wxMenuBar* MacGetCommonMenuBar() { return s_macCommonMenuBar; }
virtual void Attach(wxFrame *frame) override;
void SetupBitmaps();
static WXHMENU MacGetWindowMenuHMenu() { return s_macWindowMenuHandle ; }
virtual void DoGetPosition(int *x, int *y) const override;
virtual void DoGetSize(int *width, int *height) const override;
virtual void DoGetClientSize(int *width, int *height) const override;
protected:
// common part of all ctors
void Init();
static bool s_macAutoWindowMenu ;
static WXHMENU s_macWindowMenuHandle ;
private:
static wxMenuBar* s_macInstalledMenuBar ;
static wxMenuBar* s_macCommonMenuBar ;
wxMenu* m_rootMenu;
wxMenu* m_appleMenu;
wxDECLARE_DYNAMIC_CLASS(wxMenuBar);
};
#endif
#endif // _WX_MENU_H_

View File

@@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/menuitem.h
// Purpose: wxMenuItem class
// Author: Vadim Zeitlin
// Created: 11.11.97
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _MENUITEM_H
#define _MENUITEM_H
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#include "wx/vector.h"
// ----------------------------------------------------------------------------
// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxMenuItemImpl ;
class WXDLLIMPEXP_CORE wxMenuItem: public wxMenuItemBase
{
public:
// ctor & dtor
wxMenuItem(wxMenu *parentMenu = nullptr,
int id = wxID_SEPARATOR,
const wxString& name = wxEmptyString,
const wxString& help = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL,
wxMenu *subMenu = nullptr);
virtual ~wxMenuItem();
// override base class virtuals
virtual void SetItemLabel(const wxString& strName) override;
virtual void Enable(bool bDoEnable = true) override;
virtual void Check(bool bDoCheck = true) override;
#if wxUSE_ACCEL
virtual void AddExtraAccel(const wxAcceleratorEntry& accel) override;
virtual void ClearExtraAccels() override;
void RemoveHiddenItems();
#endif // wxUSE_ACCEL
// Implementation only from now on.
// update the os specific representation
void UpdateItemBitmap() ;
void UpdateItemText() ;
void UpdateItemStatus() ;
wxMenuItemImpl* GetPeer() { return m_peer; }
private:
void UncheckRadio() ;
wxMenuItemImpl* m_peer;
#if wxUSE_ACCEL
wxVector<wxMenuItem*> m_hiddenMenuItems;
#endif // wxUSE_ACCEL
wxDECLARE_DYNAMIC_CLASS(wxMenuItem);
};
#endif //_MENUITEM_H

View File

@@ -0,0 +1,169 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/metafile.h
// Purpose: wxMetaFile, wxMetaFileDC classes.
// This probably should be restricted to Windows platforms,
// but if there is an equivalent on your platform, great.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_METAFIILE_H_
#define _WX_METAFIILE_H_
#include "wx/dc.h"
#include "wx/gdiobj.h"
#if wxUSE_DATAOBJ
#include "wx/dataobj.h"
#endif
#include "wx/osx/dcclient.h"
/*
* Metafile and metafile device context classes
*
*/
#define wxMetaFile wxMetafile
#define wxMetaFileDC wxMetafileDC
class WXDLLIMPEXP_FWD_CORE wxMetafile;
class wxMetafileRefData ;
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
class WXDLLIMPEXP_CORE wxMetafile : public wxGDIObject
{
public:
wxMetafile(const wxString& file = wxEmptyString);
virtual ~wxMetafile();
// After this is called, the metafile cannot be used for anything
// since it is now owned by the clipboard.
virtual bool SetClipboard(int width = 0, int height = 0);
virtual bool Play(wxDC *dc);
wxSize GetSize() const;
int GetWidth() const { return GetSize().x; }
int GetHeight() const { return GetSize().y; }
// Implementation
WXHMETAFILE GetHMETAFILE() const ;
void SetHMETAFILE(WXHMETAFILE mf) ;
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
wxDECLARE_DYNAMIC_CLASS(wxMetafile);
};
class WXDLLIMPEXP_CORE wxMetafileDCImpl: public wxGCDCImpl
{
public:
wxMetafileDCImpl( wxDC *owner,
const wxString& filename,
int width, int height,
const wxString& description );
virtual ~wxMetafileDCImpl();
// Should be called at end of drawing
virtual wxMetafile *Close();
// Implementation
wxMetafile *GetMetaFile() const { return m_metaFile; }
void SetMetaFile(wxMetafile *mf) { m_metaFile = mf; }
protected:
virtual void DoGetSize(int *width, int *height) const override;
wxMetafile* m_metaFile;
private:
wxDECLARE_CLASS(wxMetafileDCImpl);
wxDECLARE_NO_COPY_CLASS(wxMetafileDCImpl);
};
class WXDLLIMPEXP_CORE wxMetafileDC: public wxDC
{
public:
// the ctor parameters specify the filename (empty for memory metafiles),
// the metafile picture size and the optional description/comment
wxMetafileDC( const wxString& filename = wxEmptyString,
int width = 0, int height = 0,
const wxString& description = wxEmptyString ) :
wxDC( new wxMetafileDCImpl( this, filename, width, height, description) )
{ }
wxMetafile *GetMetafile() const
{ return ((wxMetafileDCImpl*)m_pimpl)->GetMetaFile(); }
wxMetafile *Close()
{ return ((wxMetafileDCImpl*)m_pimpl)->Close(); }
private:
wxDECLARE_CLASS(wxMetafileDC);
wxDECLARE_NO_COPY_CLASS(wxMetafileDC);
};
/*
* Pass filename of existing non-placeable metafile, and bounding box.
* Adds a placeable metafile header, sets the mapping mode to anisotropic,
* and sets the window origin and extent to mimic the wxMM_TEXT mapping mode.
*
*/
// No origin or extent
#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0f);
// Optional origin and extent
bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0f, bool useOriginAndExtent = true);
// ----------------------------------------------------------------------------
// wxMetafileDataObject is a specialization of wxDataObject for metafile data
// ----------------------------------------------------------------------------
#if wxUSE_DATAOBJ
class WXDLLIMPEXP_CORE wxMetafileDataObject : public wxDataObjectSimple
{
public:
// ctors
wxMetafileDataObject()
: wxDataObjectSimple(wxDF_METAFILE) { }
wxMetafileDataObject(const wxMetafile& metafile)
: wxDataObjectSimple(wxDF_METAFILE), m_metafile(metafile) { }
// virtual functions which you may override if you want to provide data on
// demand only - otherwise, the trivial default versions will be used
virtual void SetMetafile(const wxMetafile& metafile)
{ m_metafile = metafile; }
virtual wxMetafile GetMetafile() const
{ return m_metafile; }
// implement base class pure virtuals
virtual size_t GetDataSize() const override;
virtual bool GetDataHere(void *buf) const override;
virtual bool SetData(size_t len, const void *buf) override;
virtual size_t GetDataSize(const wxDataFormat& WXUNUSED(format)) const override
{ return GetDataSize(); }
virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
void *buf) const override
{ return GetDataHere(buf); }
virtual bool SetData(const wxDataFormat& WXUNUSED(format),
size_t len, const void *buf) override
{ return SetData(len, buf); }
protected:
wxMetafile m_metafile;
};
#endif
#endif
// _WX_METAFIILE_H_

View File

@@ -0,0 +1 @@
#include "wx/osx/core/mimetype.h"

View File

@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/minifram.h
// Purpose: wxMiniFrame class. A small frame for e.g. floating toolbars.
// If there is no equivalent on your platform, just make it a
// normal frame.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MINIFRAM_H_
#define _WX_MINIFRAM_H_
#include "wx/frame.h"
class WXDLLIMPEXP_CORE wxMiniFrame: public wxFrame {
wxDECLARE_DYNAMIC_CLASS(wxMiniFrame);
public:
wxMiniFrame() = default;
wxMiniFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION,
const wxString& name = wxASCII_STR(wxFrameNameStr))
{
// Use wxFrame constructor in absence of more specific code.
Create(parent, id, title, pos, size, style | wxFRAME_TOOL_WINDOW | wxFRAME_FLOAT_ON_PARENT , name);
}
virtual ~wxMiniFrame() = default;
protected:
};
#endif
// _WX_MINIFRAM_H_

View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/msgdlg.h
// Purpose: wxMessageDialog class. Use generic version if no
// platform-specific implementation.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
class WXDLLIMPEXP_CORE wxMessageDialog : public wxMessageDialogBase
{
public:
wxMessageDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxASCII_STR(wxMessageBoxCaptionStr),
long style = wxOK|wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
virtual int ShowModal() override;
#if wxOSX_USE_COCOA
virtual void ShowWindowModal() override;
virtual void ModalFinishedCallback(void* panel, int resultCode) override;
#endif
protected:
// not supported for message dialog
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
int WXUNUSED(width), int WXUNUSED(height),
int WXUNUSED(sizeFlags) = wxSIZE_AUTO) override {}
#if wxOSX_USE_COCOA
void* ConstructNSAlert();
#endif
int m_buttonId[4];
int m_buttonCount;
wxDECLARE_DYNAMIC_CLASS(wxMessageDialog);
};
#endif // _WX_MSGBOXDLG_H_

View File

@@ -0,0 +1,165 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/nonownedwnd.h
// Purpose: declares wxNonOwnedWindow class
// Author: Stefan Csomor
// Created: 2008-03-24
// Copyright: (c) 2008 Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_NONOWNEDWND_H_
#define _WX_MAC_NONOWNEDWND_H_
#include "wx/window.h"
#include "wx/graphics.h"
#if wxUSE_SYSTEM_OPTIONS
#define wxMAC_WINDOW_PLAIN_TRANSITION wxT("mac.window-plain-transition")
#endif
//-----------------------------------------------------------------------------
// wxNonOwnedWindow
//-----------------------------------------------------------------------------
// This class represents "non-owned" window. A window is owned by another
// window if it has a parent and is positioned within the parent. For example,
// wxFrame is non-owned, because even though it can have a parent, it's
// location is independent of it. This class is for internal use only, it's
// the base class for wxTopLevelWindow and wxPopupWindow.
class wxNonOwnedWindowImpl;
class WXDLLIMPEXP_CORE wxNonOwnedWindow : public wxNonOwnedWindowBase
{
public:
// constructors and such
wxNonOwnedWindow() { Init(); }
wxNonOwnedWindow(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr))
{
Init();
(void)Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxPanelNameStr));
bool Create(wxWindow *parent, WXWindow nativeWindow);
virtual ~wxNonOwnedWindow();
virtual void SubclassWin(WXWindow nativeWindow);
virtual void UnsubclassWin();
virtual wxPoint GetClientAreaOrigin() const override;
// implement base class pure virtuals
virtual bool SetTransparent(wxByte alpha) override;
virtual bool CanSetTransparent() override;
virtual bool SetBackgroundStyle(wxBackgroundStyle style) override;
virtual void Update() override;
WXWindow GetWXWindow() const ;
static wxNonOwnedWindow* GetFromWXWindow( WXWindow win );
// implementation from now on
// --------------------------
// These accessors are Mac-specific and don't exist in other ports.
const wxRegion& GetShape() const { return m_shape; }
#if wxUSE_GRAPHICS_CONTEXT
const wxGraphicsPath& GetShapePath() { return m_shapePath; }
#endif // wxUSE_GRAPHICS_CONTEXT
// activation hooks only necessary for MDI Implementation
static void MacDelayedDeactivation(long timestamp);
virtual void MacActivate( long timestamp , bool inIsActivating ) ;
virtual void SetWindowStyleFlag(long flags) override;
virtual void Raise() override;
virtual void Lower() override;
virtual bool Show( bool show = true ) override;
virtual void SetExtraStyle(long exStyle) override;
virtual bool SetBackgroundColour( const wxColour &colour ) override;
wxNonOwnedWindowImpl* GetNonOwnedPeer() const { return m_nowpeer; }
#if wxOSX_USE_COCOA_OR_IPHONE
// override the base class method to return an NSWindow instead of NSView
virtual void *OSXGetViewOrWindow() const override;
#endif // Cocoa
// osx specific event handling common for all osx-ports
virtual void HandleActivated( double timestampsec, bool didActivate );
virtual void HandleResized( double timestampsec );
virtual void HandleMoved( double timestampsec );
virtual void HandleResizing( double timestampsec, wxRect* rect );
void OSXHandleMiniaturize(double WXUNUSED(timestampsec), bool miniaturized);
void OSXSetIgnoreResizing(bool value) { m_ignoreResizing = value; }
void WindowWasPainted();
virtual bool Destroy() override;
protected:
// common part of all ctors
void Init();
virtual void DoGetPosition( int *x, int *y ) const override;
virtual void DoGetSize( int *width, int *height ) const override;
virtual void DoMoveWindow(int x, int y, int width, int height) override;
virtual void DoGetClientSize(int *width, int *height) const override;
virtual bool OSXShowWithEffect(bool show,
wxShowEffect effect,
unsigned timeout) override;
virtual bool DoClearShape() override;
virtual bool DoSetRegionShape(const wxRegion& region) override;
#if wxUSE_GRAPHICS_CONTEXT
virtual bool DoSetPathShape(const wxGraphicsPath& path) override;
#endif // wxUSE_GRAPHICS_CONTEXT
virtual void WillBeDestroyed();
wxNonOwnedWindowImpl* m_nowpeer ;
// wxWindowMac* m_macFocus ;
static wxNonOwnedWindow *s_macDeactivateWindow;
private :
static clock_t s_lastFlush;
wxRegion m_shape;
#if wxUSE_GRAPHICS_CONTEXT
wxGraphicsPath m_shapePath;
#endif // wxUSE_GRAPHICS_CONTEXT
bool m_ignoreResizing;
};
// list of all frames and modeless dialogs
extern WXDLLIMPEXP_DATA_CORE(wxWindowList) wxModelessWindows;
#endif // _WX_MAC_NONOWNEDWND_H_

View File

@@ -0,0 +1,158 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/notebook.h
// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
// Author: Stefan Csomor
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_
#define _WX_NOTEBOOK_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/event.h"
#include <vector>
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
// fwd declarations
class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxWindow;
// ----------------------------------------------------------------------------
// wxNotebook
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxNotebook : public wxNotebookBase
{
public:
// ctors
// -----
// default for dynamic class
wxNotebook() = default;
// the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxNotebookNameStr))
{ Create( parent, id, pos, size, style, name ); }
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxASCII_STR(wxNotebookNameStr));
// dtor
virtual ~wxNotebook();
// accessors
// ---------
// set the currently selected page, return the index of the previously
// selected one (or wxNOT_FOUND on error)
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
int SetSelection(size_t nPage) override { return DoSetSelection(nPage, SetSelection_SendEvent); }
// changes selected page without sending events
int ChangeSelection(size_t nPage) override { return DoSetSelection(nPage); }
// set/get the title of a page
bool SetPageText(size_t nPage, const wxString& strText) override;
wxString GetPageText(size_t nPage) const override;
// sets/returns item's image index in the current image list
int GetPageImage(size_t nPage) const override;
bool SetPageImage(size_t nPage, int nImage) override;
// control the appearance of the notebook pages
// set the size (the same for all pages)
virtual void SetPageSize(const wxSize& size) override;
// set the padding between tabs (in pixels)
virtual void SetPadding(const wxSize& padding) override;
// sets the size of the tabs (assumes all tabs are the same size)
virtual void SetTabSize(const wxSize& sz) override;
// hit test
virtual int HitTest(const wxPoint& pt, long *flags = nullptr) const override;
// calculate size for wxNotebookSizer
wxSize CalcSizeFromPage(const wxSize& sizePage) const override;
wxRect GetPageRect() const override;
// operations
// ----------
// remove all pages
bool DeleteAllPages() override;
// the same as AddPage(), but adds it at the specified position
bool InsertPage(size_t nPage,
wxNotebookPage *pPage,
const wxString& strText,
bool bSelect = false,
int imageId = NO_IMAGE) override;
// callbacks
// ---------
void OnSize(wxSizeEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnNavigationKey(wxNavigationKeyEvent& event);
// implementation
// --------------
#if wxUSE_CONSTRAINTS
virtual void SetConstraintSizes(bool recurse = true) override;
virtual bool DoPhase(int nPhase) override;
#endif
// base class virtuals
// -------------------
virtual void Command(wxCommandEvent& event) override;
// osx specific event handling common for all osx-ports
virtual bool OSXHandleClicked( double timestampsec ) override;
protected:
virtual wxNotebookPage *DoRemovePage(size_t page) override;
// common part of all ctors
void Init();
// helper functions
void ChangePage(int nOldSel, int nSel); // change pages
void MacSetupTabs();
int DoSetSelection(size_t nPage, int flags = 0) override;
private:
// this vector is synchronized with m_pages in the base class
struct PageData
{
PageData(const wxString& text_, int image_)
: text{text_}, image{image_}
{
}
PageData(const PageData&) = default;
PageData& operator=(const PageData&) = default;
PageData(PageData&&) = default;
PageData& operator=(PageData&&) = default;
wxString text;
int image = wxNOT_FOUND;
};
std::vector<PageData> m_pagesData;
wxDECLARE_DYNAMIC_CLASS(wxNotebook);
wxDECLARE_EVENT_TABLE();
};
#endif // _WX_NOTEBOOK_H_

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/palette.h
// Purpose: wxPalette class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PALETTE_H_
#define _WX_PALETTE_H_
#include "wx/gdiobj.h"
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLIMPEXP_CORE wxPalette : public wxPaletteBase
{
public:
wxPalette();
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const;
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual int GetColoursCount() const override;
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
wxDECLARE_DYNAMIC_CLASS(wxPalette);
};
#endif // _WX_PALETTE_H_

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/pen.h
// Purpose: wxPen class
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PEN_H_
#define _WX_PEN_H_
#include "wx/gdiobj.h"
#include "wx/colour.h"
#include "wx/bitmap.h"
// Pen
class WXDLLIMPEXP_CORE wxPen : public wxPenBase
{
public:
wxPen();
wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
wxPen(const wxBitmap& stipple, int width);
wxPen(const wxPenInfo& info);
bool operator==(const wxPen& pen) const;
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
// Override in order to recreate the pen
void SetColour(const wxColour& col) override;
void SetColour(unsigned char r, unsigned char g, unsigned char b) override;
void SetWidth(int width) override;
void SetStyle(wxPenStyle style) override;
void SetStipple(const wxBitmap& stipple) override;
void SetDashes(int nb_dashes, const wxDash *dash) override;
void SetJoin(wxPenJoin join) override;
void SetCap(wxPenCap cap) override;
wxColour GetColour() const override;
int GetWidth() const override;
wxPenStyle GetStyle() const override;
wxPenJoin GetJoin() const override;
wxPenCap GetCap() const override;
int GetDashes(wxDash **ptr) const override;
int GetDashCount() const;
wxBitmap *GetStipple() const override;
wxDEPRECATED_MSG("use wxPENSTYLE_XXX constants")
wxPen(const wxColour& col, int width, int style);
wxDEPRECATED_MSG("use wxPENSTYLE_XXX constants")
void SetStyle(int style) { SetStyle((wxPenStyle)style); }
// Implementation
// Useful helper: create the brush resource
bool RealizeResource();
protected:
virtual wxGDIRefData *CreateGDIRefData() const override;
wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override;
private:
void Unshare();
wxDECLARE_DYNAMIC_CLASS(wxPen);
};
#endif
// _WX_PEN_H_

View File

@@ -0,0 +1,34 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/popupwin.h
// Purpose: wxPopupWindow class for wxMac
// Author: Stefan Csomor
// Created:
// Copyright: (c) 2006 Stefan Csomor
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MAC_POPUPWIN_H_
#define _WX_MAC_POPUPWIN_H_
// ----------------------------------------------------------------------------
// wxPopupWindow
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPopupWindow : public wxPopupWindowBase
{
public:
wxPopupWindow() = default;
~wxPopupWindow();
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
{ (void)Create(parent, flags); }
bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
virtual bool Show(bool show = true) override;
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow);
};
#endif // _WX_MAC_POPUPWIN_H_

View File

@@ -0,0 +1,110 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/printdlg.h
// Purpose: wxPrintDialog, wxPageSetupDialog classes.
// Use generic, PostScript version if no
// platform-specific implementation.
// Author: Stefan Csomor
// Created: 1998-01-01
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRINTDLG_H_
#define _WX_PRINTDLG_H_
#include "wx/dialog.h"
#include "wx/cmndata.h"
#include "wx/printdlg.h"
#include "wx/prntbase.h"
/*
* wxMacPrintDialog
* The Mac dialog for printing
*/
class WXDLLIMPEXP_FWD_CORE wxDC;
class WXDLLIMPEXP_CORE wxMacPrintDialog: public wxPrintDialogBase
{
public:
wxMacPrintDialog();
wxMacPrintDialog(wxWindow *parent, wxPrintDialogData* data = nullptr);
wxMacPrintDialog(wxWindow *parent, wxPrintData* data );
virtual ~wxMacPrintDialog();
bool Create(wxWindow *parent, wxPrintDialogData* data = nullptr);
virtual int ShowModal() override;
virtual wxPrintDialogData& GetPrintDialogData() override { return m_printDialogData; }
virtual wxPrintData& GetPrintData() override { return m_printDialogData.GetPrintData(); }
virtual wxDC *GetPrintDC() override;
private:
wxPrintDialogData m_printDialogData;
wxDC* m_printerDC;
bool m_destroyDC;
wxWindow* m_dialogParent;
private:
wxDECLARE_DYNAMIC_CLASS(wxPrintDialog);
};
/*
* wxMacPageSetupDialog
* The Mac page setup dialog
*/
class WXDLLIMPEXP_CORE wxMacPageSetupDialog: public wxPageSetupDialogBase
{
public:
wxMacPageSetupDialog(wxWindow *parent, wxPageSetupDialogData *data = nullptr);
virtual ~wxMacPageSetupDialog();
virtual wxPageSetupDialogData& GetPageSetupDialogData() override;
bool Create(wxWindow *parent, wxPageSetupDialogData *data = nullptr);
virtual int ShowModal() override;
private:
wxPageSetupDialogData m_pageSetupData;
wxWindow* m_dialogParent;
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxMacPageSetupDialog);
};
class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
/*
* wxMacPageMarginsDialog
* A Mac dialog for setting the page margins separately from page setup since
* (native) wxMacPageSetupDialog doesn't let you set margins.
*/
class WXDLLIMPEXP_CORE wxMacPageMarginsDialog : public wxDialog
{
public:
wxMacPageMarginsDialog(wxFrame* parent, wxPageSetupDialogData* data);
bool TransferToWindow();
bool TransferDataFromWindow() override;
virtual wxPageSetupDialogData& GetPageSetupDialogData() { return *m_pageSetupDialogData; }
private:
wxPageSetupDialogData* m_pageSetupDialogData;
wxPoint m_MinMarginTopLeft;
wxPoint m_MinMarginBottomRight;
wxTextCtrl *m_LeftMargin;
wxTextCtrl *m_TopMargin;
wxTextCtrl *m_RightMargin;
wxTextCtrl *m_BottomMargin;
void GetMinMargins();
bool CheckValue(wxTextCtrl* textCtrl, int *value, int minValue, const wxString& name);
private:
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxMacPageMarginsDialog);
};
#endif // _WX_PRINTDLG_H_

View File

@@ -0,0 +1,58 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/printmac.h
// Purpose: wxWindowsPrinter, wxWindowsPrintPreview classes
// Author: Julian Smart
// Created: 01/02/97
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRINTWIN_H_
#define _WX_PRINTWIN_H_
#include "wx/prntbase.h"
/*
* Represents the printer: manages printing a wxPrintout object
*/
class WXDLLIMPEXP_CORE wxMacPrinter: public wxPrinterBase
{
wxDECLARE_DYNAMIC_CLASS(wxMacPrinter);
public:
wxMacPrinter(wxPrintDialogData *data = nullptr);
virtual ~wxMacPrinter();
virtual bool Print(wxWindow *parent,
wxPrintout *printout,
bool prompt = true) override;
virtual wxDC* PrintDialog(wxWindow *parent) override;
virtual bool Setup(wxWindow *parent) override;
};
/*
* wxPrintPreview
* Programmer creates an object of this class to preview a wxPrintout.
*/
class WXDLLIMPEXP_CORE wxMacPrintPreview: public wxPrintPreviewBase
{
wxDECLARE_CLASS(wxMacPrintPreview);
public:
wxMacPrintPreview(wxPrintout *printout,
wxPrintout *printoutForPrinting = nullptr,
wxPrintDialogData *data = nullptr);
wxMacPrintPreview(wxPrintout *printout,
wxPrintout *printoutForPrinting,
wxPrintData *data);
virtual ~wxMacPrintPreview();
virtual bool Print(bool interactive) override;
virtual void DetermineScaling() override;
};
#endif
// _WX_PRINTWIN_H_

View File

@@ -0,0 +1,14 @@
#ifndef _WX_PRIVATE_OSX_H_
#define _WX_PRIVATE_OSX_H_
#include "wx/osx/core/private.h"
#if wxOSX_USE_IPHONE
#include "wx/osx/iphone/private.h"
#elif wxOSX_USE_COCOA
#include "wx/osx/cocoa/private.h"
#elif wxUSE_GUI
#error "Must include wx/defs.h first"
#endif
#endif

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_

Some files were not shown because too many files have changed in this diff Show More