Import r67258 of the wxWidgets trunk, which I expect will before

long become wxWidgets 2.9.2, which in turn is expected to be the
last 2.9 release before the 3.0 stable release.

Since the full wxWidgets distribution is rather large, I have
imported only the parts that we use, on a subdirectory basis:

art
include/wx/*.*
include/wx/aui
include/wx/cocoa
include/wx/generic
include/wx/gtk
include/wx/meta
include/wx/msw
include/wx/osx
include/wx/persist
include/wx/private
include/wx/protocol
include/wx/unix
src/aui
src/common
src/generic
src/gtk
src/msw
src/osx
src/unix


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7380 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2011-03-20 18:05:19 +00:00
parent 205637ccc3
commit d14efe561b
1945 changed files with 694474 additions and 0 deletions

View File

@ -0,0 +1,68 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSApplication.h
// Purpose: wxNSApplicationDelegate definition
// Author: David Elliott
// Modified by:
// Created: 2004/01/26
// RCS-ID: $Id: NSApplication.h 46227 2007-05-27 04:52:04Z DE $
// Copyright: (c) 2003,2004 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_NSAPPLICATION_H__
#define _WX_COCOA_NSAPPLICATION_H__
#include "wx/cocoa/objc/objc_uniquifying.h"
// ========================================================================
// wxNSApplicationDelegate
// ========================================================================
/*!
@class wxNSApplicationDelegate
@discussion Implements an NSApplication delegate which can respond to messages sent by Cocoa to change Cocoa's behavior.
wxCocoa will set a singleton instance of this class as the NSApplication delegate upon startup unless wxWidgets is running
in a "plugin" manner in which case it would not be appropriate to do this.
Although Cocoa will send notifications to the delegate it is also possible to register a different object to listen for
them. Because we want to support the plugin case, we use a separate notification observer object when we can.
*/
@interface wxNSApplicationDelegate : NSObject
{
}
// Delegate methods
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication;
@end // interface wxNSApplicationDelegate : NSObject
WX_DECLARE_GET_OBJC_CLASS(wxNSApplicationDelegate,NSObject)
// ========================================================================
// wxNSApplicationObserver
// ========================================================================
/*!
@class wxNSApplicationObserver
@discussion Observes most notifications sent by the NSApplication singleton.
wxCocoa will create a singleton instance of this class upon startup and register it with the default notification center to
listen for several events sent by the NSApplication singleton.
Because there can be any number of notification observers, this method allows wxCocoa to function properly even when it is
running as a plugin of some other (most likely not wxWidgets) application.
*/
@interface wxNSApplicationObserver : NSObject
{
}
// Methods defined as (but not used here) as NSApplication delegate methods.
- (void)applicationWillBecomeActive:(NSNotification *)notification;
- (void)applicationDidBecomeActive:(NSNotification *)notification;
- (void)applicationWillResignActive:(NSNotification *)notification;
- (void)applicationDidResignActive:(NSNotification *)notification;
- (void)applicationWillUpdate:(NSNotification *)notification;
// Other notifications
- (void)controlTintChanged:(NSNotification *)notification;
@end // interface wxNSApplicationObserver : NSObject
WX_DECLARE_GET_OBJC_CLASS(wxNSApplicationObserver,NSObject)
#endif //ndef _WX_COCOA_NSAPPLICATION_H__

View File

@ -0,0 +1,26 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSBox.h
// Purpose: wxCocoaNSBox class
// Author: David Elliott
// Modified by:
// Created: 2003/03/19
// RCS-ID: $Id: NSBox.h 58022 2009-01-11 12:00:51Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSBOX_H__
#define __WX_COCOA_NSBOX_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSBox);
class wxCocoaNSBox
{
WX_DECLARE_OBJC_INTERFACE(NSBox)
protected:
// virtual void Cocoa_didChangeText(void) = 0;
};
#endif // _WX_COCOA_NSBOX_H_

View File

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSButton.h
// Purpose: wxCocoaNSButton class
// Author: David Elliott
// Modified by:
// Created: 2002/12/09
// RCS-ID: $Id: NSButton.h 38031 2006-03-12 15:10:23Z VZ $
// Copyright: (c) 2002-2004 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_NSBUTTON_H__
#define _WX_COCOA_NSBUTTON_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
#include "wx/cocoa/ObjcRef.h"
WX_DECLARE_OBJC_HASHMAP(NSButton);
class wxCocoaNSButton
{
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSButton);
public:
void AssociateNSButton(WX_NSButton cocoaNSButton);
void DisassociateNSButton(WX_NSButton cocoaNSButton)
{
if(cocoaNSButton)
sm_cocoaHash.erase(cocoaNSButton);
}
virtual void Cocoa_wxNSButtonAction(void) = 0;
virtual ~wxCocoaNSButton() { }
protected:
static const wxObjcAutoRefFromAlloc<struct objc_object*> sm_cocoaTarget;
};
#endif // _WX_COCOA_NSBUTTON_H__

View File

@ -0,0 +1,32 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSControl.h
// Purpose: wxCocoaNSControl class
// Author: David Elliott
// Modified by:
// Created: 2003/02/15
// RCS-ID: $Id: NSControl.h 58022 2009-01-11 12:00:51Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSCONTROL_H__
#define __WX_COCOA_NSCONTROL_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSControl);
class wxCocoaNSControl
{
WX_DECLARE_OBJC_INTERFACE(NSControl)
public:
virtual void CocoaTarget_action() {}
// virtual void Cocoa_didChangeText(void) = 0;
virtual ~wxCocoaNSControl() { }
protected:
static struct objc_object *sm_cocoaTarget;
};
#endif // _WX_COCOA_NSCONTROL_H_

View File

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSMenu.h
// Purpose: wxCocoaNSMenu class
// Author: David Elliott
// Modified by:
// Created: 2002/12/09
// RCS-ID: $Id: NSMenu.h 49523 2007-10-29 16:18:59Z DE $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSMENU_H__
#define __WX_COCOA_NSMENU_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSMenu);
// ========================================================================
// wxCocoaNSMenu
// ========================================================================
class wxCocoaNSMenu
{
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSMenu)
public:
void AssociateNSMenu(WX_NSMenu cocoaNSMenu, unsigned int flags = 0);
void DisassociateNSMenu(WX_NSMenu cocoaNSMenu);
enum
{ OBSERVE_DidAddItem = 0x01
, OBSERVE_DidChangeItem = 0x02
, OBSERVE_DidRemoveItem = 0x04
, OBSERVE_DidSendAction = 0x08
, OBSERVE_WillSendAction = 0x10
};
virtual void Cocoa_dealloc() {}
virtual void CocoaNotification_menuDidAddItem(WX_NSNotification WXUNUSED(notification)) {}
virtual void CocoaNotification_menuDidChangeItem(WX_NSNotification WXUNUSED(notification)) {}
virtual void CocoaNotification_menuDidRemoveItem(WX_NSNotification WXUNUSED(notification)) {}
virtual void CocoaNotification_menuDidSendAction(WX_NSNotification WXUNUSED(notification)) {}
virtual void CocoaNotification_menuWillSendAction(WX_NSNotification WXUNUSED(notification)) {}
virtual ~wxCocoaNSMenu() { }
protected:
static struct objc_object *sm_cocoaObserver;
};
#endif // _WX_COCOA_NSMENU_H_

View File

@ -0,0 +1,25 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSPanel.h
// Purpose: wxCocoaNSPanel class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: NSPanel.h 42046 2006-10-16 09:30:01Z ABX $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSPANEL_H__
#define __WX_COCOA_NSPANEL_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSPanel);
class wxCocoaNSPanel
{
WX_DECLARE_OBJC_INTERFACE(NSPanel)
};
#endif // _WX_COCOA_NSPANEL_H_

View File

@ -0,0 +1,41 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSScroller.h
// Purpose: wxCocoaNSScroller class
// Author: David Elliott
// Modified by:
// Created: 2004/04/27
// RCS-ID: $Id: NSScroller.h 38031 2006-03-12 15:10:23Z VZ $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_NSSCROLLER_H__
#define _WX_COCOA_NSSCROLLER_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
#include "wx/cocoa/ObjcRef.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSScroller);
WX_DECLARE_OBJC_HASHMAP(NSScroller);
class wxCocoaNSScroller
{
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSScroller);
public:
void AssociateNSScroller(WX_NSScroller cocoaNSScroller);
void DisassociateNSScroller(WX_NSScroller cocoaNSScroller)
{
if(cocoaNSScroller)
sm_cocoaHash.erase(cocoaNSScroller);
}
virtual void Cocoa_wxNSScrollerAction(void) = 0;
virtual ~wxCocoaNSScroller() { }
protected:
static const wxObjcAutoRefFromAlloc<struct objc_object*> sm_cocoaTarget;
};
#endif // _WX_COCOA_NSSCROLLER_H__

View File

@ -0,0 +1,47 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSSlider.h
// Purpose: wxCocoaNSSlider class
// Author: Mark Oxenham
// Modified by: David Elliott
// Created: 2007/08/10
// RCS-ID: $Id: NSSlider.h 64940 2010-07-13 13:29:13Z VZ $
// Copyright: (c) 2007 Software 2000 Ltd. All rights reserved.
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WXNSSLIDER_H_
#define _WXNSSLIDER_H_
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
#include "wx/cocoa/ObjcRef.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSSlider);
WX_DECLARE_OBJC_HASHMAP(NSSlider);
// For when we're not in Objective-C mode:
typedef struct objc_selector *SEL;
class wxCocoaNSSliderLastSelectorChanger;
class wxCocoaNSSlider
{
friend class wxCocoaNSSliderLastSelectorChanger;
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSSlider);
public:
void AssociateNSSlider(WX_NSSlider cocoaNSSlider);
void DisassociateNSSlider(WX_NSSlider cocoaNSSlider);
virtual void CocoaNotification_startTracking(WX_NSNotification notification) = 0;
virtual void CocoaNotification_continueTracking(WX_NSNotification notification) = 0;
virtual void CocoaNotification_stopTracking(WX_NSNotification notification) = 0;
static SEL GetLastResponderSelector()
{ return sm_lastResponderSelector; }
protected:
virtual ~wxCocoaNSSlider() { }
static SEL sm_lastResponderSelector;
};
#endif

View File

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSTabView.h
// Purpose: wxCocoaNSTabView class
// Author: David Elliott
// Modified by:
// Created: 2004/04/08
// RCS-ID: $Id: NSTabView.h 38031 2006-03-12 15:10:23Z VZ $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_NSTABVIEW_H__
#define _WX_COCOA_NSTABVIEW_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
#include "wx/cocoa/ObjcRef.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSTabView);
DECLARE_WXCOCOA_OBJC_CLASS(NSTabViewItem);
WX_DECLARE_OBJC_HASHMAP(NSTabView);
class wxCocoaNSTabView
{
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSTabView)
public:
void AssociateNSTabView(WX_NSTabView cocoaNSTabView);
void DisassociateNSTabView(WX_NSTabView ocoaNSTabView);
virtual void CocoaDelegate_tabView_didSelectTabViewItem(WX_NSTabViewItem tabviewItem) = 0;
virtual bool CocoaDelegate_tabView_shouldSelectTabViewItem(WX_NSTabViewItem tabviewItem) = 0;
virtual ~wxCocoaNSTabView() { }
protected:
static wxObjcAutoRefFromAlloc<struct objc_object*> sm_cocoaDelegate;
};
#endif // _WX_COCOA_NSTABVIEW_H__

View File

@ -0,0 +1,35 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSTableDataSource.h
// Purpose: wxCocoaNSTableDataSource Objective-C class
// Author: David Elliott
// Modified by:
// Created: 2003/08/05
// RCS-ID: $Id: NSTableDataSource.h 48106 2007-08-15 16:10:19Z DE $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSTABLEDATASOURCE_H__
#define __WX_COCOA_NSTABLEDATASOURCE_H__
#include "wx/cocoa/objc/objc_uniquifying.h"
#import <Foundation/NSObject.h>
// ============================================================================
// @class wxCocoaNSTableDataSource
// ============================================================================
@interface wxCocoaNSTableDataSource : NSObject
{
}
// NSTableDataSource is a loosely defined protocol consisting of the
// following two message implementations
- (int)numberOfRowsInTableView: (NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn: (NSTableColumn *)tableColumn
row: (int)rowIndex;
@end // wxCocoaNSTableDataSource
WX_DECLARE_GET_OBJC_CLASS(wxCocoaNSTableDataSource,NSObject)
#endif // _WX_COCOA_NSTABLEDATASOURCE_H_

View File

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSTableView.h
// Purpose: wxCocoaNSTableView class
// Author: David Elliott
// Modified by:
// Created: 2003/08/05
// RCS-ID: $Id: NSTableView.h 38031 2006-03-12 15:10:23Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSTABLEVIEW_H__
#define __WX_COCOA_NSTABLEVIEW_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSTableView);
class wxCocoaNSTableView
{
WX_DECLARE_OBJC_INTERFACE(NSTableView)
public:
virtual int CocoaDataSource_numberOfRows() = 0;
virtual struct objc_object* CocoaDataSource_objectForTableColumn(
WX_NSTableColumn tableColumn, int rowIndex) = 0;
virtual ~wxCocoaNSTableView() { }
};
#endif // _WX_COCOA_NSTABLEVIEW_H_

View File

@ -0,0 +1,27 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSTextField.h
// Purpose: wxCocoaNSTextField class
// Author: David Elliott
// Modified by:
// Created: 2002/12/09
// RCS-ID: $Id: NSTextField.h 58022 2009-01-11 12:00:51Z FM $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSTEXTFIELD_H__
#define __WX_COCOA_NSTEXTFIELD_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSTextField);
class wxCocoaNSTextField
{
WX_DECLARE_OBJC_INTERFACE(NSTextField)
protected:
virtual void Cocoa_didChangeText(void) = 0;
virtual ~wxCocoaNSTextField() { }
};
#endif // _WX_COCOA_NSTEXTFIELD_H_

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSView.h
// Purpose: wxCocoaNSView class
// Author: David Elliott
// Modified by:
// Created: 2003/02/15
// RCS-ID: $Id: NSView.h 51576 2008-02-06 20:10:07Z DE $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSVIEW_H__
#define __WX_COCOA_NSVIEW_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
struct objc_object;
class wxWindow;
WX_DECLARE_OBJC_HASHMAP(NSView);
class wxCocoaNSView
{
/* NSView is a rather special case and requires some extra attention */
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSView)
public:
void AssociateNSView(WX_NSView cocoaNSView);
void DisassociateNSView(WX_NSView cocoaNSView);
protected:
static struct objc_object *sm_cocoaObserver;
public:
virtual wxWindow* GetWxWindow() const
{ return NULL; }
virtual void Cocoa_FrameChanged(void) = 0;
virtual void Cocoa_synthesizeMouseMoved(void) = 0;
virtual bool Cocoa_acceptsFirstMouse(bool &WXUNUSED(acceptsFirstMouse), WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_drawRect(const NSRect &WXUNUSED(rect))
{ return false; }
virtual bool Cocoa_mouseDown(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_mouseDragged(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_mouseUp(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_mouseMoved(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_mouseEntered(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_mouseExited(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_rightMouseDown(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_rightMouseDragged(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_rightMouseUp(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_otherMouseDown(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_otherMouseDragged(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_otherMouseUp(WX_NSEvent WXUNUSED(theEvent))
{ return false; }
virtual bool Cocoa_resetCursorRects()
{ return false; }
virtual bool Cocoa_viewDidMoveToWindow()
{ return false; }
virtual bool Cocoa_viewWillMoveToWindow(WX_NSWindow WXUNUSED(newWindow))
{ return false; }
virtual ~wxCocoaNSView() { }
};
#endif
// __WX_COCOA_NSVIEW_H__

View File

@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/NSWindow.h
// Purpose: wxCocoaNSWindow class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: NSWindow.h 49523 2007-10-29 16:18:59Z DE $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_NSWINDOW_H__
#define __WX_COCOA_NSWINDOW_H__
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
WX_DECLARE_OBJC_HASHMAP(NSWindow);
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
class WXDLLIMPEXP_FWD_CORE wxTopLevelWindowCocoa;
DECLARE_WXCOCOA_OBJC_CLASS(NSMenuItem);
DECLARE_WXCOCOA_OBJC_CLASS(wxNSWindowDelegate);
class WXDLLIMPEXP_CORE wxCocoaNSWindow
{
/* NSWindow is a rather special case and requires some extra attention */
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSWindow)
public:
void AssociateNSWindow(WX_NSWindow cocoaNSWindow);
void DisassociateNSWindow(WX_NSWindow cocoaNSWindow);
virtual bool Cocoa_canBecomeKeyWindow(bool &WXUNUSED(canBecome))
{ return false; }
virtual bool Cocoa_canBecomeMainWindow(bool &WXUNUSED(canBecome))
{ return false; }
virtual bool CocoaDelegate_windowShouldClose(void) = 0;
virtual void CocoaDelegate_windowWillClose(void) = 0;
virtual void CocoaDelegate_windowDidBecomeKey(void) { }
virtual void CocoaDelegate_windowDidResignKey(void) { }
virtual void CocoaDelegate_windowDidBecomeMain(void) { }
virtual void CocoaDelegate_windowDidResignMain(void) { }
virtual void CocoaDelegate_wxMenuItemAction(WX_NSMenuItem menuItem) = 0;
virtual bool CocoaDelegate_validateMenuItem(WX_NSMenuItem menuItem) = 0;
virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
inline wxTopLevelWindowCocoa* GetWxTopLevelWindowCocoa()
{ return m_wxTopLevelWindowCocoa; }
protected:
wxCocoaNSWindow(wxTopLevelWindowCocoa *tlw = NULL);
virtual ~wxCocoaNSWindow();
WX_wxNSWindowDelegate m_cocoaDelegate;
wxTopLevelWindowCocoa *m_wxTopLevelWindowCocoa;
};
#endif // _WX_COCOA_NSWINDOW_H_

View File

@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/ObjcAssociate.h
// Purpose: Associates an Objective-C class with a C++ class
// Author: David Elliott
// Modified by:
// Created: 2002/12/03
// RCS-ID: $Id: ObjcAssociate.h 42046 2006-10-16 09:30:01Z ABX $
// Copyright: (c) 2002 David Elliott <dfe@cox.net>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_OBJC_ASSOCIATE_H__
#define __WX_COCOA_OBJC_ASSOCIATE_H__
/*-------------------------------------------------------------------------
Basic hashmap stuff, used by everything
-------------------------------------------------------------------------*/
#define WX_DECLARE_OBJC_HASHMAP(ObjcClass) \
class wxCocoa##ObjcClass; \
WX_DECLARE_HASH_MAP(WX_##ObjcClass,wxCocoa##ObjcClass*,wxPointerHash,wxPointerEqual,wxCocoa##ObjcClass##Hash)
#define WX_DECLARE_OBJC_INTERFACE_HASHMAP(ObjcClass) \
public: \
static inline wxCocoa##ObjcClass* GetFromCocoa(WX_##ObjcClass cocoaObjcClass) \
{ \
wxCocoa##ObjcClass##Hash::iterator iter = sm_cocoaHash.find(cocoaObjcClass); \
if(iter!=sm_cocoaHash.end()) \
{ \
return iter->second; \
} \
return NULL; \
} \
protected: \
static wxCocoa##ObjcClass##Hash sm_cocoaHash;
#define WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(ObjcClass) \
wxCocoa##ObjcClass##Hash wxCocoa##ObjcClass::sm_cocoaHash;
/*-------------------------------------------------------------------------
The entire interface, including some boilerplate stuff
-------------------------------------------------------------------------*/
#define WX_DECLARE_OBJC_INTERFACE(ObjcClass) \
WX_DECLARE_OBJC_INTERFACE_HASHMAP(ObjcClass) \
public: \
inline void Associate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
{ \
if(cocoaObjcClass) \
sm_cocoaHash.insert(wxCocoa##ObjcClass##Hash::value_type(cocoaObjcClass,this)); \
} \
inline void Disassociate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
{ \
if(cocoaObjcClass) \
sm_cocoaHash.erase(cocoaObjcClass); \
}
#define WX_IMPLEMENT_OBJC_INTERFACE(ObjcClass) \
WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(ObjcClass)
/*-------------------------------------------------------------------------
Stuff to be used by the wxWidgets class (not the Cocoa interface)
-------------------------------------------------------------------------*/
#define WX_DECLARE_COCOA_OWNER(ObjcClass,ObjcBase,ObjcRoot) \
public: \
inline WX_##ObjcClass Get##ObjcClass() { return (WX_##ObjcClass)m_cocoa##ObjcRoot; } \
inline const WX_##ObjcClass Get##ObjcClass() const { return (WX_##ObjcClass)m_cocoa##ObjcRoot; } \
protected: \
void Set##ObjcClass(WX_##ObjcClass cocoaObjcClass);
#define WX_IMPLEMENT_COCOA_OWNER(wxClass,ObjcClass,ObjcBase,ObjcRoot) \
void wxClass::Set##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
{ \
Disassociate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
Set##ObjcBase(cocoaObjcClass); \
Associate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
}
#endif // __WX_COCOA_OBJC_ASSOCIATE_H__

View File

@ -0,0 +1,236 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/ObjcRef.h
// Purpose: wxObjcAutoRef template class
// Author: David Elliott
// Modified by:
// Created: 2004/03/28
// RCS-ID: $Id: ObjcRef.h 61724 2009-08-21 10:41:26Z VZ $
// Copyright: (c) 2004 David Elliott <dfe@cox.net>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_OBJCREF_H__
#define _WX_COCOA_OBJCREF_H__
// Reuse wxCFRef-related code (e.g. wxCFRetain/wxCFRelease)
#include "wx/osx/core/cfref.h"
// NOTE WELL: We can only know whether or not GC can be used when compiling Objective-C.
// Therefore we cannot implement these functions except when compiling Objective-C.
#ifdef __OBJC__
/*! @function wxGCSafeRetain
@templatefield Type (implicit) An Objective-C class type
@arg r Pointer to Objective-C object. May be null.
@abstract Retains the Objective-C object, even when using Apple's garbage collector
@discussion
When Apple's garbage collector is enabled, the usual [obj retain] and [obj release] messages
are ignored. Instead the collector with help from compiler-generated write-barriers tracks
reachable objects. The write-barriers are generated when setting i-vars of C++ classes but
they are ignored by the garbage collector unless the C++ object is in GC-managed memory.
The simple solution is to use CFRetain on the Objective-C object which has been enhanced in
GC mode to forcibly retain the object. In Retain/Release (RR) mode the CFRetain function has
the same effect as [obj retain]. Note that GC vs. RR is selected at runtime.
Take care that wxGCSafeRetain must be balanced with wxGCSafeRelease and that conversely
wxGCSafeRelease must only be called on objects to balance wxGCSafeRetain. In particular when
receiving an Objective-C object from an alloc or copy method take care that you must retain
it with wxGCSafeRetain and balance the initial alloc with a standard release.
Example:
wxGCSafeRelease(m_obj); // release current object (if any)
NSObject *obj = [[NSObject alloc] init];
m_obj = wxGCSafeRetain(obj);
[obj release];
Alternatively (same effect, perhaps less clear):
wxGCSafeRelease(m_obj); // release current object (if any)
m_obj = wxGCSafeRetain([[NSObject alloc] init]);
[m_obj release]; // balance alloc
Consider the effect on the retain count from each statement (alloc, CFRetain, release)
In RR mode: retainCount = 1, +1, -1
In GC mode: strongRetainCount = 0, +1, -0
This is a template function to ensure it is used on raw pointers and never on pointer-holder
objects via implicit conversion operators.
*/
template <class Type>
inline Type * wxGCSafeRetain(Type *r)
{
#ifdef __OBJC_GC__
return static_cast<Type*>(wxCFRetain(r));
#else
return [r retain];
#endif
}
/*! @function wxGCSafeRelease
@templatefield Type (implicit) An Objective-C class type
@arg r Pointer to Objective-C object. May be null.
@abstract Balances wxGCSafeRetain. Particularly useful with the Apple Garbage Collector.
@discussion
See the wxGCSafeRetain documentation for more details.
Example (from wxGCSafeRetain documentation):
wxGCSafeRelease(m_obj); // release current object (if any)
m_obj = wxGCSafeRetain([[NSObject alloc] init]);
[m_obj release]; // balance alloc
When viewed from the start, m_obj ought to start as nil. However, the second time through
the wxGCSafeRelease call becomes critical as it releases the retain from the first time
through.
In the destructor for this C++ object with the m_obj i-var you ought to do the following:
wxGCSafeRelease(m_obj);
m_obj = nil; // Not strictly needed, but safer.
Under no circumstances should you balance an alloc or copy with a wxGCSafeRelease.
*/
template <class Type>
inline void wxGCSafeRelease(Type *r)
{
#ifdef __OBJC_GC__
wxCFRelease(r);
#else
[r release];
#endif
}
#else
// NOTE: When not compiling Objective-C, declare these functions such that they can be
// used by other inline-implemented methods. Since those methods in turn will not actually
// be used from non-ObjC code the compiler ought not emit them. If it emits an out of
// line copy of those methods then presumably it will have also emitted at least one
// out of line copy of these functions from at least one Objective-C++ translation unit.
// That means the out of line implementation will be available at link time.
template <class Type>
inline Type * wxGCSafeRetain(Type *r);
template <class Type>
inline void wxGCSafeRelease(Type *r);
#endif //def __OBJC__
/*
wxObjcAutoRefFromAlloc: construct a reference to an object that was
[NSObject -alloc]'ed and thus does not need a retain
wxObjcAutoRef: construct a reference to an object that was
either autoreleased or is retained by something else.
*/
struct objc_object;
// We must do any calls to Objective-C from an Objective-C++ source file
class wxObjcAutoRefBase
{
protected:
/*! @function ObjcRetain
@abstract Simply does [p retain].
*/
static struct objc_object* ObjcRetain(struct objc_object*);
/*! @function ObjcRelease
@abstract Simply does [p release].
*/
static void ObjcRelease(struct objc_object*);
};
/*! @class wxObjcAutoRefFromAlloc
@templatefield T The type of _pointer_ (e.g. NSString*, NSRunLoop*)
@abstract Pointer-holder for Objective-C objects
@discussion
When constructing this object from a raw pointer, the pointer is assumed to have
come from an alloc-style method. That is, once you construct this object from
the pointer you must not balance your alloc with a call to release.
This class has been carefully designed to work with both the traditional Retain/Release
and the new Garbage Collected modes. In RR-mode it will prevent the object from being
released by managing the reference count using the retain/release semantics. In GC-mode
it will use a method (currently CFRetain/CFRelease) to ensure the object will never be
finalized until this object is destroyed.
*/
template <class T>
class wxObjcAutoRefFromAlloc: wxObjcAutoRefBase
{
public:
wxObjcAutoRefFromAlloc(T p = 0)
: m_ptr(p)
// NOTE: this is from alloc. Do NOT retain
{
// CFRetain
// GC: Object is strongly retained and prevented from being collected
// non-GC: Simply realizes it's an Objective-C object and calls [p retain]
wxGCSafeRetain(p);
// ObjcRelease (e.g. [p release])
// GC: Objective-C retain/release mean nothing in GC mode
// non-GC: This is a normal release call, balancing the retain
ObjcRelease(static_cast<T>(p));
// The overall result:
// GC: Object is strongly retained
// non-GC: Retain count is the same as it was (retain then release)
}
wxObjcAutoRefFromAlloc(const wxObjcAutoRefFromAlloc& otherRef)
: m_ptr(otherRef.m_ptr)
{ wxGCSafeRetain(m_ptr); }
~wxObjcAutoRefFromAlloc()
{ wxGCSafeRelease(m_ptr); }
wxObjcAutoRefFromAlloc& operator=(const wxObjcAutoRefFromAlloc& otherRef)
{ wxGCSafeRetain(otherRef.m_ptr);
wxGCSafeRelease(m_ptr);
m_ptr = otherRef.m_ptr;
return *this;
}
operator T() const
{ return static_cast<T>(m_ptr); }
T operator->() const
{ return static_cast<T>(m_ptr); }
protected:
/*! @field m_ptr The pointer to the Objective-C object
@discussion
The pointer to the Objective-C object is typed as void* to avoid compiler-generated write
barriers as would be used for implicitly __strong object pointers and to avoid the similar
read barriers as would be used for an explicitly __weak object pointer. The write barriers
are useless unless this object is located in GC-managed heap which is highly unlikely.
Since we guarantee strong reference via CFRetain/CFRelease the write-barriers are not needed
at all, even if this object does happen to be allocated in GC-managed heap.
*/
void *m_ptr;
};
/*!
@class wxObjcAutoRef
@description
A pointer holder that does retain its argument.
NOTE: It is suggest that you instead use wxObjcAutoRefFromAlloc<T> foo([aRawPointer retain])
*/
template <class T>
class wxObjcAutoRef: public wxObjcAutoRefFromAlloc<T>
{
public:
/*! @method wxObjcAutoRef
@description
Uses the underlying wxObjcAutoRefFromAlloc and simply does a typical [p retain] such that
in RR-mode the object is in effectively the same retain-count state as it would have been
coming straight from an alloc method.
*/
wxObjcAutoRef(T p = 0)
: wxObjcAutoRefFromAlloc<T>(p)
{ // NOTE: ObjcRetain is correct because in GC-mode it balances ObjcRelease in our superclass constructor
// In RR mode it does retain and the superclass does retain/release thus resulting in an overall retain.
ObjcRetain(static_cast<T>(wxObjcAutoRefFromAlloc<T>::m_ptr));
}
~wxObjcAutoRef() {}
wxObjcAutoRef(const wxObjcAutoRef& otherRef)
: wxObjcAutoRefFromAlloc<T>(otherRef)
{}
wxObjcAutoRef(const wxObjcAutoRefFromAlloc<T>& otherRef)
: wxObjcAutoRefFromAlloc<T>(otherRef)
{}
wxObjcAutoRef& operator=(const wxObjcAutoRef& otherRef)
{ return wxObjcAutoRefFromAlloc<T>::operator=(otherRef); }
};
#endif //ndef _WX_COCOA_OBJCREF_H__

View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/app.h
// Purpose: wxApp class
// Author: David Elliott
// Modified by:
// Created: 2002/11/27
// RCS-ID: $Id: app.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_APP_H_
#define _WX_COCOA_APP_H_
typedef struct __CFRunLoopObserver * CFRunLoopObserverRef;
typedef const struct __CFString * CFStringRef;
#include "wx/osx/core/cfref.h"
// ========================================================================
// wxApp
// ========================================================================
// Represents the application. Derive OnInit and declare
// a new App object to start application
class WXDLLIMPEXP_CORE wxApp: public wxAppBase
{
DECLARE_DYNAMIC_CLASS(wxApp)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxApp();
virtual ~wxApp();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
inline WX_NSApplication GetNSApplication() { return m_cocoaApp; }
virtual void CocoaDelegate_applicationWillBecomeActive();
virtual void CocoaDelegate_applicationDidBecomeActive();
virtual void CocoaDelegate_applicationWillResignActive();
virtual void CocoaDelegate_applicationDidResignActive();
virtual void CocoaDelegate_applicationWillUpdate();
virtual void CF_ObserveMainRunLoopBeforeWaiting(CFRunLoopObserverRef observer, int activity);
protected:
WX_NSApplication m_cocoaApp;
struct objc_object *m_cocoaAppDelegate;
WX_NSThread m_cocoaMainThread;
wxCFRef<CFRunLoopObserverRef> m_cfRunLoopIdleObserver;
wxCFRef<CFStringRef> m_cfObservedRunLoopMode;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// Implement wxAppBase pure virtuals
virtual void Exit();
virtual void WakeUpIdle();
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
virtual bool CallOnInit();
virtual bool OnInit();
virtual bool OnInitGui();
// Set true _before_ initializing wx to force embedded mode (no app delegate, etc.)
static bool sm_isEmbedded;
};
#endif // _WX_COCOA_APP_H_

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/autorelease.h
// Purpose: Automatic NSAutoreleasePool functionality
// Author: David Elliott
// Modified by:
// Created: 2003/07/11
// RCS-ID: $Id: autorelease.h 61724 2009-08-21 10:41:26Z VZ $
// Copyright: (c) 2003 David Elliott <dfe@cox.net>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_AUTORELEASE_H__
#define __WX_COCOA_AUTORELEASE_H__
#import <Foundation/NSAutoreleasePool.h>
class wxAutoNSAutoreleasePool
{
public:
wxAutoNSAutoreleasePool()
{
m_pool = [[NSAutoreleasePool alloc] init];
}
~wxAutoNSAutoreleasePool()
{
[m_pool release];
}
protected:
NSAutoreleasePool *m_pool;
};
#endif //__WX_COCOA_AUTORELEASE_H__

View File

@ -0,0 +1,164 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/bitmap.h
// Purpose: wxBitmap class
// Author: David Elliott
// Modified by:
// Created: 2003/07/19
// RCS-ID: $Id: bitmap.h 59526 2009-03-14 13:57:51Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_BITMAP_H__
#define __WX_COCOA_BITMAP_H__
#include "wx/palette.h"
// Bitmap
class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxCursor;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxPixelDataBase;
// ========================================================================
// wxMask
// ========================================================================
// A mask is a 1-bit alpha bitmap used for drawing bitmaps transparently.
class WXDLLIMPEXP_CORE wxMask: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxMask)
public:
wxMask();
// 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 bitmap and a palette index indicating
// the transparent area
wxMask(const wxBitmap& bitmap, int paletteIndex);
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask(const wxBitmap& bitmap);
// Copy constructor
wxMask(const wxMask& src);
virtual ~wxMask();
bool Create(const wxBitmap& bitmap, const wxColour& colour);
bool Create(const wxBitmap& bitmap, int paletteIndex);
bool Create(const wxBitmap& bitmap);
// wxCocoa
inline WX_NSBitmapImageRep GetNSBitmapImageRep()
{ return m_cocoaNSBitmapImageRep; }
protected:
WX_NSBitmapImageRep m_cocoaNSBitmapImageRep;
};
// ========================================================================
// wxBitmap
// ========================================================================
class WXDLLIMPEXP_CORE wxBitmap: public wxGDIObject
{
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
// Platform-specific default constructor
wxBitmap();
// 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);
// Construct from Cocoa's NSImage
wxBitmap(NSImage* cocoaNSImage);
// Construct from Cocoa's NSBitmapImageRep
wxBitmap(NSBitmapImageRep* cocoaNSBitmapImageRep);
// Constructor for generalised creation from data
wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth = 1);
// 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)
{ CreateFromImage(image, depth); }
// Convert from wxIcon
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
// destructor
virtual ~wxBitmap();
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// Initialize from wxImage
bool CreateFromImage(const wxImage& image, int depth=-1);
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH)
{ return Create(sz.GetWidth(), sz.GetHeight(), depth); }
bool Create(NSImage* cocoaNSImage);
bool Create(NSBitmapImageRep* cocoaNSBitmapImageRep);
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
// copies the contents and mask of the given (colour) icon to the bitmap
virtual bool CopyFromIcon(const wxIcon& icon);
wxImage ConvertToImage() const;
// get the given part of bitmap
wxBitmap GetSubBitmap( const wxRect& rect ) const;
int GetWidth() const;
int GetHeight() const;
int GetDepth() const;
int GetQuality() const;
void SetWidth(int w);
void SetHeight(int h);
void SetDepth(int d);
void SetQuality(int q);
void SetOk(bool isOk);
// raw bitmap access support functions
void *GetRawData(wxPixelDataBase& data, int bpp);
void UngetRawData(wxPixelDataBase& data);
wxPalette* GetPalette() const;
void SetPalette(const wxPalette& palette);
wxMask *GetMask() const;
void SetMask(wxMask *mask) ;
wxBitmapType GetBitmapType() const;
// wxCocoa
WX_NSBitmapImageRep GetNSBitmapImageRep();
void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
WX_NSImage GetNSImage(bool useMask) const;
static void InitStandardHandlers() { }
static void CleanUpHandlers() { }
protected:
wxGDIRefData *CreateGDIRefData() const;
wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
DECLARE_DYNAMIC_CLASS(wxBitmap)
};
#endif // __WX_COCOA_BITMAP_H__

View File

@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/bmpbuttn.h
// Purpose: wxBitmapButton class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: bmpbuttn.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_BMPBUTTN_H__
#define __WX_COCOA_BMPBUTTN_H__
#include "wx/cocoa/NSButton.h"
// ========================================================================
// wxBitmapButton
// ========================================================================
class WXDLLIMPEXP_CORE wxBitmapButton : public wxBitmapButtonBase
{
DECLARE_DYNAMIC_CLASS(wxBitmapButton)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSButton,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxBitmapButton() { }
wxBitmapButton(wxWindow *parent, wxWindowID winid,
const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr)
{
Create(parent, winid, bitmap, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
virtual ~wxBitmapButton();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxNSButtonAction(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// The wxButton::DoGetBestSize is not correct for bitmap buttons
wxSize DoGetBestSize() const
{ return wxButtonBase::DoGetBestSize(); }
};
#endif // __WX_COCOA_BMPBUTTN_H__

View File

@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/brush.h
// Purpose: wxBrush class
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2003/07/03
// RCS-ID: $Id: brush.h 54273 2008-06-17 17:28:26Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_BRUSH_H__
#define __WX_COCOA_BRUSH_H__
#include "wx/gdicmn.h"
#include "wx/gdiobj.h"
#include "wx/bitmap.h"
class WXDLLIMPEXP_FWD_CORE wxBrush;
// ========================================================================
// wxBrush
// ========================================================================
class WXDLLIMPEXP_CORE wxBrush: public wxBrushBase
{
DECLARE_DYNAMIC_CLASS(wxBrush)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxBrush();
wxBrush(const wxColour& col, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
#if FUTURE_WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_FUTURE( wxBrush(const wxColour& col, int style) );
#endif
wxBrush(const wxBitmap& stipple);
virtual ~wxBrush();
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
virtual void SetColour(const wxColour& col) ;
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
virtual void SetStyle(wxBrushStyle style) ;
virtual void SetStipple(const wxBitmap& stipple) ;
// comparison
bool operator == (const wxBrush& brush) const
{ return m_refData == brush.m_refData; }
bool operator != (const wxBrush& brush) const
{ return m_refData != brush.m_refData; }
// accessors
wxColour GetColour() const;
virtual wxBrushStyle GetStyle() const;
wxBitmap *GetStipple() const;
#if FUTURE_WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_FUTURE( void SetStyle(int style) )
{ SetStyle((wxBrushStyle)style); }
#endif
// wxCocoa
WX_NSColor GetNSColor();
protected:
wxGDIRefData *CreateGDIRefData() const;
wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
};
#endif // __WX_COCOA_BRUSH_H__

View File

@ -0,0 +1,65 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/button.h
// Purpose: wxButton class
// Author: David Elliott
// Modified by:
// Created: 2002/12/29
// RCS-ID: $Id: button.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_BUTTON_H__
#define __WX_COCOA_BUTTON_H__
#include "wx/cocoa/NSButton.h"
// ========================================================================
// wxButton
// ========================================================================
class WXDLLIMPEXP_CORE wxButton : public wxButtonBase, protected wxCocoaNSButton
{
DECLARE_DYNAMIC_CLASS(wxButton)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSButton,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxButton() { }
wxButton(wxWindow *parent, wxWindowID winid,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr)
{
Create(parent, winid, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
virtual ~wxButton();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxNSButtonAction(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
wxString GetLabel() const;
void SetLabel(const wxString& label);
wxSize DoGetBestSize() const;
};
#endif
// __WX_COCOA_BUTTON_H__

View File

@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/checkbox.h
// Purpose: wxCheckBox class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: checkbox.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_CHECKBOX_H__
#define __WX_COCOA_CHECKBOX_H__
#include "wx/cocoa/NSButton.h"
// ========================================================================
// wxCheckBox
// ========================================================================
class WXDLLIMPEXP_CORE wxCheckBox: public wxCheckBoxBase , protected wxCocoaNSButton
{
DECLARE_DYNAMIC_CLASS(wxCheckBox)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSButton,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxCheckBox() { }
wxCheckBox(wxWindow *parent, wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr)
{
Create(parent, winid, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual ~wxCheckBox();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxNSButtonAction(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void SetValue(bool);
virtual bool GetValue() const;
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const;
protected:
virtual void DoSet3StateValue(wxCheckBoxState state);
virtual wxCheckBoxState DoGet3StateValue() const;
};
#endif // __WX_COCOA_CHECKBOX_H__

View File

@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/checklst.h
// Purpose: wxCheckListBox class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: checklst.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_CHECKLST_H__
#define __WX_COCOA_CHECKLST_H__
//#include "wx/cocoa/NSTableView.h"
// ========================================================================
// wxCheckListBox
// ========================================================================
class WXDLLIMPEXP_CORE wxCheckListBox: public wxCheckListBoxBase //, protected wxCocoaNSTableView
{
DECLARE_DYNAMIC_CLASS(wxCheckListBox)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSTableView,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxCheckListBox() { }
wxCheckListBox(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr)
{
Create(parent, winid, pos, size, n, choices, style, validator, name);
}
wxCheckListBox(wxWindow *parent, wxWindowID winid,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = 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[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = 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 = wxListBoxNameStr);
virtual ~wxCheckListBox();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// check list box specific methods
virtual bool IsChecked(unsigned int item) const;
virtual void Check(unsigned int item, bool check = true);
};
#endif // __WX_COCOA_CHECKLST_H__

View File

@ -0,0 +1,22 @@
/*
* Name: wx/cocoa/chkconf.h
* Purpose: wxCocoa-specific config settings checks
* Author: Vadim Zeitlin
* Created: 2008-09-11
* RCS-ID: $Id: chkconf.h 55546 2008-09-11 11:20:33Z VZ $
* Copyright: (c) 2008 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_COCOA_CHKCONF_H_
#define _WX_COCOA_CHKCONF_H_
/*
wxLogDialog doesn't currently work correctly in wxCocoa.
*/
#undef wxUSE_LOG_DIALOG
#define wxUSE_LOG_DIALOG 0
#endif // _WX_COCOA_CHKCONF_H_

View File

@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/choice.h
// Purpose: wxChoice class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: choice.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_CHOICE_H__
#define __WX_COCOA_CHOICE_H__
//#include "wx/cocoa/NSPopUpButton.h"
#include "wx/cocoa/NSMenu.h"
class WXDLLIMPEXP_FWD_BASE wxSortedArrayString;
// ========================================================================
// wxChoice
// ========================================================================
class WXDLLIMPEXP_CORE wxChoice: public wxChoiceBase /*, protected wxCocoaNSPopUpButton */, protected wxCocoaNSMenu
{
DECLARE_DYNAMIC_CLASS(wxChoice)
DECLARE_EVENT_TABLE()
// WX_DECLARE_COCOA_OWNER(NSTableView,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxChoice() { Init(); }
wxChoice(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr)
{
Init();
Create(parent, winid, pos, size, n, choices, style, validator, name);
}
wxChoice(wxWindow *parent, wxWindowID winid,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr)
{
Init();
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[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr);
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 = wxChoiceNameStr);
virtual ~wxChoice();
protected:
void Init();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
void CocoaNotification_menuDidSendAction(WX_NSNotification notification);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void DoClear();
virtual unsigned int GetCount() const;
virtual wxString GetString(unsigned int) const;
virtual void SetString(unsigned int pos, const wxString&);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual int GetSelection() const;
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type);
virtual void DoDeleteOneItem(unsigned int pos);
virtual void DoSetItemClientData(unsigned int, void*);
virtual void* DoGetItemClientData(unsigned int) const;
virtual void SetSelection(int pos);
protected:
wxSortedArrayString *m_sortedStrings;
wxArrayPtrVoid m_itemsClientData;
};
#endif // __WX_COCOA_CHOICE_H__

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/clipbrd.h
// Purpose: wxClipboard
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2003/07/23
// RCS-ID: $Id: clipbrd.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_CLIPBRD_H__
#define __WX_COCOA_CLIPBRD_H__
#include "wx/dataobj.h"
//=========================================================================
// wxClipboard
//=========================================================================
class wxClipboard : public wxClipboardBase
{
DECLARE_DYNAMIC_CLASS(wxClipboard)
public:
wxClipboard();
virtual ~wxClipboard();
// open the clipboard before SetData() and GetData()
virtual bool Open();
// close the clipboard after SetData() and GetData()
virtual void Close();
// query whether the clipboard is opened
virtual bool IsOpened() const;
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data );
// add to the clipboard data.
virtual bool AddData( wxDataObject *data );
// ask if data in correct format is available
virtual bool IsSupported( const wxDataFormat& format );
// fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data );
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
};
#endif //__WX_COCOA_CLIPBRD_H__

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/colour.h
// Purpose: wxColour class
// Author: David Elliott
// Modified by:
// Created: 2003/06/17
// RCS-ID: $Id: colour.h 54125 2008-06-11 19:17:41Z SC $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_COLOUR_H__
#define __WX_COCOA_COLOUR_H__
#include "wx/object.h"
#include "wx/string.h"
// ========================================================================
// wxColour
// ========================================================================
class WXDLLIMPEXP_CORE wxColour : public wxColourBase
{
public:
// constructors
// ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// initialization using existing NSColor
wxColour( WX_NSColor aColor );
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour& operator = ( const wxColour& col );
virtual ~wxColour();
// accessors
virtual bool IsOk() const { return m_cocoaNSColor; }
WX_NSColor GetNSColor() { return m_cocoaNSColor; }
WX_NSColor GetNSColor() const { return m_cocoaNSColor; }
unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; }
unsigned char Blue() const { return m_blue; }
unsigned char Alpha() const { return m_alpha; }
// comparison
bool operator == (const wxColour& colour) const
{
return m_cocoaNSColor == colour.m_cocoaNSColor ||
(m_red == colour.m_red &&
m_green == colour.m_green &&
m_blue == colour.m_blue &&
m_alpha == colour.m_alpha);
}
bool operator != (const wxColour& colour) const
{ return !(*this == colour); }
// Set() functions
void Set( WX_NSColor aColor );
// reroute the inherited ones
void Set(unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha = wxALPHA_OPAQUE)
{ wxColourBase::Set(red, green, blue, alpha); }
bool Set(const wxString &str)
{ return wxColourBase::Set(str); }
void Set(unsigned long colRGB)
{ wxColourBase::Set(colRGB); }
protected:
// puts the object in an invalid, uninitialized state
void Init();
virtual void
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
private:
WX_NSColor m_cocoaNSColor;
unsigned char m_red;
unsigned char m_green;
unsigned char m_blue;
unsigned char m_alpha;
DECLARE_DYNAMIC_CLASS(wxColour)
};
#endif // __WX_COCOA_COLOUR_H__

View File

@ -0,0 +1,158 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/combobox.h
// Purpose: wxComboBox class
// Author: Ryan Norton
// Modified by:
// Created: 2005/02/16
// RCS-ID: $Id: combobox.h 59263 2009-03-02 12:25:01Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_COMBOBOX_H__
#define __WX_COCOA_COMBOBOX_H__
//Begin NSComboBox.h
#include "wx/hashmap.h"
#include "wx/cocoa/ObjcAssociate.h"
#include "wx/textctrl.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSComboBox);
WX_DECLARE_OBJC_HASHMAP(NSComboBox);
class wxCocoaNSComboBox
{
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSComboBox)
public:
void AssociateNSComboBox(WX_NSComboBox cocoaNSComboBox);
void DisassociateNSComboBox(WX_NSComboBox cocoaNSComboBox);
virtual void doWxEvent(int nEvent) = 0;
virtual ~wxCocoaNSComboBox() { }
};
//begin combobox.h
#include "wx/dynarray.h"
// ========================================================================
// wxComboBox
// ========================================================================
class WXDLLIMPEXP_CORE wxComboBox : public wxControl, public wxComboBoxBase, protected wxCocoaNSComboBox, protected wxCocoaNSTextField
{
DECLARE_DYNAMIC_CLASS(wxComboBox)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSComboBox,NSTextField,NSView)
WX_DECLARE_COCOA_OWNER(NSTextField,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxComboBox() { }
wxComboBox(wxWindow *parent, wxWindowID winid,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
{
Create(parent, winid, value, pos, size, n, choices, style, validator, name);
}
wxComboBox(wxWindow *parent, wxWindowID winid,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
{
Create(parent, winid, value, pos, size, choices, style,
validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
virtual ~wxComboBox();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
wxArrayPtrVoid m_Datas;
virtual void doWxEvent(int nEvent);
virtual void Cocoa_didChangeText()
{}
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
void Clear() // HACK
{ wxComboBoxBase::Clear(); }
// wxCombobox methods
virtual void SetSelection(int pos);
// Overlapping methods
virtual wxString GetStringSelection();
// wxItemContainer
virtual void DoClear();
virtual void DoDeleteOneItem(unsigned int n);
virtual unsigned int GetCount() const;
virtual wxString GetString(unsigned int) const;
virtual void SetString(unsigned int pos, const wxString&);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual int GetSelection() const;
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type);
virtual void DoSetItemClientData(unsigned int, void*);
virtual void* DoGetItemClientData(unsigned int) const;
virtual bool IsSorted() const { return HasFlag(wxCB_SORT); }
// ------------------------------------------------------------------------
// wxTextEntryBase virtual implementations:
// ------------------------------------------------------------------------
// FIXME: This needs to be moved to some sort of common code.
virtual void WriteText(const wxString&);
virtual wxString GetValue() const;
virtual void Remove(long, long);
virtual void Cut();
virtual void Copy();
virtual void Paste();
virtual void Undo();
virtual void Redo();
virtual bool CanUndo() const;
virtual bool CanRedo() const;
virtual void SetInsertionPoint(long pos);
virtual long GetInsertionPoint() const;
virtual wxTextPos GetLastPosition() const;
virtual void SetSelection(long from, long to);
virtual void GetSelection(long *from, long *to) const;
virtual bool IsEditable() const;
virtual void SetEditable(bool editable);
private:
// implement wxTextEntry pure virtual method
virtual wxWindow *GetEditableWindow() { return this; }
};
#endif // __WX_COCOA_COMBOBOX_H__

View File

@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/control.h
// Purpose: wxControl class
// Author: David Elliott
// Modified by:
// Created: 2003/02/15
// RCS-ID: $Id: control.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_CONTROL_H__
#define __WX_COCOA_CONTROL_H__
#include "wx/cocoa/NSControl.h"
// ========================================================================
// wxControl
// ========================================================================
class WXDLLIMPEXP_CORE wxControl : public wxControlBase, public wxCocoaNSControl
{
DECLARE_ABSTRACT_CLASS(wxControl)
WX_DECLARE_COCOA_OWNER(NSControl,NSView,NSView)
DECLARE_EVENT_TABLE()
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
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 = 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 = wxControlNameStr);
virtual ~wxControl();
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// implementation from now on
// --------------------------
void OnEraseBackground(wxEraseEvent& event);
virtual void Command(wxCommandEvent& event) { ProcessCommand(event); }
// Calls the callback and appropriate event handlers
bool ProcessCommand(wxCommandEvent& event);
// Enables the control
virtual void CocoaSetEnabled(bool enable);
protected:
virtual wxSize DoGetBestSize() const;
// Provides a common implementation of title setting which strips mnemonics
// and then calls setTitle: with the stripped string. May be implemented
// to call setTitleWithMnemonic: on OpenStep-compatible systems. Only
// intended for use by views or cells which implement at least setTitle:
// and possibly setTitleWithMnemonic: such as NSBox and NSButton or NSCell
// classes, for example as used by wxRadioBox. Not usable with classes like
// NSTextField which expect setStringValue:.
static void CocoaSetLabelForObject(const wxString& labelWithWxMnemonic, struct objc_object *anObject);
};
#endif
// __WX_COCOA_CONTROL_H__

View File

@ -0,0 +1,65 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/cursor.h
// Purpose: wxCursor class
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2002/11/27
// RCS-ID: $Id: cursor.h 58757 2009-02-08 11:45:59Z VZ $
// Copyright: (c) David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_CURSOR_H_
#define _WX_COCOA_CURSOR_H_
#include "wx/bitmap.h"
class WXDLLIMPEXP_CORE wxCursorRefData : public wxGDIRefData
{
public:
wxCursorRefData();
virtual ~wxCursorRefData();
protected:
int m_width, m_height;
WX_NSCursor m_hCursor;
friend class WXDLLIMPEXP_FWD_CORE wxBitmap;
friend class WXDLLIMPEXP_FWD_CORE wxCursor;
wxDECLARE_NO_COPY_CLASS(wxCursorRefData);
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
// Cursor
class WXDLLIMPEXP_CORE wxCursor: public wxBitmap
{
public:
wxCursor();
wxCursor(const wxString& name, wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor id) { InitFromStock(id); }
#if WXWIN_COMPATIBILITY_2_8
wxCursor(int id) { InitFromStock((wxStockCursor)id); }
#endif
virtual ~wxCursor();
// FIXME: operator==() is wrong!
bool operator==(const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
bool operator!=(const wxCursor& cursor) const { return !(*this == cursor); }
WX_NSCursor GetNSCursor() const { return M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0; }
private:
void InitFromStock(wxStockCursor);
DECLARE_DYNAMIC_CLASS(wxCursor)
};
extern WXDLLIMPEXP_CORE void wxSetCursor(const wxCursor& cursor);
#endif
// _WX_COCOA_CURSOR_H_

View File

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dataform.h
// Purpose: declaration of the wxDataFormat class
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2003/07/23
// RCS-ID: $Id: dataform.h 46254 2007-05-30 22:02:19Z VS $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DATAFORM_H__
#define __WX_COCOA_DATAFORM_H__
class wxDataFormat
{
public:
wxDataFormat(unsigned int uFormat = wxDF_INVALID) { m_uFormat = uFormat; }
wxDataFormat(const wxString& zFormat) { SetId(zFormat); }
wxDataFormat& operator=(unsigned int uFormat) { m_uFormat = uFormat; return(*this); }
wxDataFormat& operator=(const wxDataFormat& rFormat) {m_uFormat = rFormat.m_uFormat; return(*this); }
//
// Comparison (must have both versions)
//
bool operator==(wxDataFormatId eFormat) const { return (m_uFormat == (unsigned int)eFormat); }
bool operator!=(wxDataFormatId eFormat) const { return (m_uFormat != (unsigned int)eFormat); }
bool operator==(const wxDataFormat& rFormat) const { return (m_uFormat == rFormat.m_uFormat); }
bool operator!=(const wxDataFormat& rFormat) const { return (m_uFormat != rFormat.m_uFormat); }
operator unsigned int(void) const { return m_uFormat; }
unsigned int GetFormatId(void) const { return (unsigned int)m_uFormat; }
unsigned int GetType(void) const { return (unsigned int)m_uFormat; }
bool IsStandard(void) const;
void SetType(unsigned int uType){ m_uFormat = uType; }
//
// String ids are used for custom types - this SetId() must be used for
// application-specific formats
//
wxString GetId(void) const;
void SetId(const wxString& WXUNUSED(pId)) { /* TODO */ }
private:
unsigned int m_uFormat;
}; // end of CLASS wxDataFormat
#endif // __WX_COCOA_DATAFORM_H__

View File

@ -0,0 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dataobj.h
// Purpose: declaration of the wxDataObject
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2003/07/23
// RCS-ID: $Id: dataobj.h 48095 2007-08-15 13:05:35Z VS $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DATAOBJ_H__
#define __WX_COCOA_DATAOBJ_H__
class WXDLLIMPEXP_CORE wxDataObject : public wxDataObjectBase
{
public:
wxDataObject();
virtual ~wxDataObject();
virtual bool IsSupportedFormat(const wxDataFormat& format,
Direction dir = Get) const;
};
#endif // __WX_COCOA_DATAOBJ_H__

View File

@ -0,0 +1,84 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dataobj2.h
// Purpose: declaration of standard wxDataObjectSimple-derived classes
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2003/07/23
// RCS-ID: $Id: dataobj2.h 58227 2009-01-19 13:55:27Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DATAOBJ2_H__
#define __WX_COCOA_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);
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const { return m_pngSize; }
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf);
protected:
void Init() { m_pngData = NULL; m_pngSize = 0; }
void Clear() { free(m_pngData); }
void ClearAll() { Clear(); Init(); }
size_t m_pngSize;
void *m_pngData;
void DoConvertToPng();
private:
// virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
};
//=========================================================================
// 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;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf);
private:
// virtual function hiding supression
size_t GetDataSize(const wxDataFormat& format) const
{ return(wxDataObjectSimple::GetDataSize(format)); }
bool GetDataHere(const wxDataFormat& format, void* pBuf) const
{ return(wxDataObjectSimple::GetDataHere(format, pBuf)); }
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf)
{ return(wxDataObjectSimple::SetData(format, nLen, pBuf)); }
};
#endif //__WX_COCOA_DATAOBJ2_H__

View File

@ -0,0 +1,175 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dc.h
// Purpose: wxDC
// Author: David Elliott
// Modified by:
// Created: 2003/04/01
// RCS-ID: $Id: dc.h 58757 2009-02-08 11:45:59Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DC_H__
#define __WX_COCOA_DC_H__
DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
#include "wx/dc.h"
class WXDLLIMPEXP_FWD_CORE wxCocoaDCImpl;
WX_DECLARE_LIST(wxCocoaDCImpl, wxCocoaDCStack);
//=========================================================================
// wxDC
//=========================================================================
class WXDLLIMPEXP_CORE wxCocoaDCImpl: public wxDCImpl
{
DECLARE_ABSTRACT_CLASS(wxCocoaDCImpl)
wxDECLARE_NO_COPY_CLASS(wxCocoaDCImpl);
//-------------------------------------------------------------------------
// Initialization
//-------------------------------------------------------------------------
public:
wxCocoaDCImpl(wxDC *owner);
virtual ~wxCocoaDCImpl();
//-------------------------------------------------------------------------
// wxCocoa specifics
//-------------------------------------------------------------------------
public:
static void CocoaInitializeTextSystem();
static void CocoaShutdownTextSystem();
static WX_NSTextStorage sm_cocoaNSTextStorage;
static WX_NSLayoutManager sm_cocoaNSLayoutManager;
static WX_NSTextContainer sm_cocoaNSTextContainer;
// Create a simple Wx to Bounds transform (just flip the coordinate system)
static WX_NSAffineTransform CocoaGetWxToBoundsTransform(bool isFlipped, float height);
protected:
// DC stack
static wxCocoaDCStack sm_cocoaDCStack;
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
bool CocoaUnwindStackAndTakeFocus();
inline bool CocoaTakeFocus()
{
wxCocoaDCStack::compatibility_iterator node = sm_cocoaDCStack.GetFirst();
if(node && (node->GetData() == this))
return true;
return CocoaUnwindStackAndTakeFocus();
}
void CocoaUnwindStackAndLoseFocus();
// DC flipping/transformation
void CocoaApplyTransformations();
void CocoaUnapplyTransformations();
WX_NSAffineTransform m_cocoaWxToBoundsTransform;
// Get bounds rect (for Clear())
// note: we use void * to mean NSRect * so that we can avoid
// putting NSRect in the headers.
virtual bool CocoaGetBounds(void *rectData);
// Blitting
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
//-------------------------------------------------------------------------
// Implementation
//-------------------------------------------------------------------------
public:
// implement base class pure virtuals
// ----------------------------------
virtual void Clear();
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return true; }
virtual void EndDoc(void) {};
virtual void StartPage(void) {};
virtual void EndPage(void) {};
virtual void SetFont(const wxFont& font);
virtual void SetPen(const wxPen& pen);
virtual void SetBrush(const wxBrush& brush);
virtual void SetBackground(const wxBrush& brush);
virtual void SetBackgroundMode(int mode) { m_backgroundMode = mode; }
virtual void SetPalette(const wxPalette& palette);
virtual void DestroyClippingRegion();
virtual wxCoord GetCharHeight() const;
virtual wxCoord GetCharWidth() const;
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
const wxFont *theFont = NULL) const;
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;
virtual int GetDepth() const;
virtual wxSize GetPPI() const;
virtual void SetMapMode(wxMappingMode mode);
virtual void SetUserScale(double x, double y);
virtual void SetLogicalScale(double x, double y);
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
virtual void SetLogicalFunction(wxRasterOperationMode function);
virtual void SetTextForeground(const wxColour& colour) ;
virtual void SetTextBackground(const wxColour& colour) ;
virtual void ComputeScaleAndOrigin();
protected:
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
wxFloodFillStyle style = wxFLOOD_SURFACE);
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
virtual void DoDrawPoint(wxCoord x, wxCoord y);
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea);
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius);
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoCrossHair(wxCoord x, wxCoord y);
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = false);
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
double angle);
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
// this is gnarly - we can't even call this function DoSetClippingRegion()
// because of virtual function hiding
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetSizeMM(int* width, int* height) const;
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset);
virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle = wxODDEVEN_RULE);
};
#endif // __WX_COCOA_DC_H__

View File

@ -0,0 +1,70 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dcclient.h
// Purpose: wxClientDCImpl, wxPaintDCImpl and wxWindowDCImpl classes
// Author: David Elliott
// Modified by:
// Created: 2003/04/01
// RCS-ID: $Id: dcclient.h 50462 2007-12-04 04:22:16Z DE $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DCCLIENT_H__
#define __WX_COCOA_DCCLIENT_H__
#include "wx/cocoa/dc.h"
// DFE: A while ago I stumbled upon the fact that retrieving the parent
// NSView of the content view seems to return the entire window rectangle
// (including decorations). Of course, that is not at all part of the
// Cocoa or OpenStep APIs, but it might be a neat hack.
class WXDLLIMPEXP_CORE wxWindowDCImpl: public wxCocoaDCImpl
{
DECLARE_DYNAMIC_CLASS(wxWindowDCImpl)
public:
wxWindowDCImpl(wxDC *owner);
// Create a DC corresponding to a window
wxWindowDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxWindowDCImpl(void);
protected:
wxWindow *m_window;
WX_NSView m_lockedNSView;
// DC stack
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
bool CocoaLockFocusOnNSView(WX_NSView nsview);
bool CocoaUnlockFocusOnNSView();
virtual bool CocoaGetBounds(void *rectData);
};
class WXDLLIMPEXP_CORE wxClientDCImpl: public wxWindowDCImpl
{
DECLARE_DYNAMIC_CLASS(wxClientDCImpl)
public:
wxClientDCImpl(wxDC *owner);
// Create a DC corresponding to a window
wxClientDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxClientDCImpl(void);
protected:
// DC stack
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
};
class WXDLLIMPEXP_CORE wxPaintDCImpl: public wxWindowDCImpl
{
DECLARE_DYNAMIC_CLASS(wxPaintDCImpl)
public:
wxPaintDCImpl(wxDC *owner);
// Create a DC corresponding to a window
wxPaintDCImpl(wxDC *owner, wxWindow *win);
virtual ~wxPaintDCImpl(void);
protected:
// DC stack
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
};
#endif
// __WX_COCOA_DCCLIENT_H__

View File

@ -0,0 +1,55 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dcmemory.h
// Purpose: wxMemoryDCImpl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: dcmemory.h 57907 2009-01-08 14:21:53Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DCMEMORY_H__
#define __WX_COCOA_DCMEMORY_H__
#include "wx/cocoa/dc.h"
#include "wx/dcmemory.h"
class WXDLLIMPEXP_CORE wxMemoryDCImpl: public wxCocoaDCImpl
{
DECLARE_DYNAMIC_CLASS(wxMemoryDCImpl)
public:
wxMemoryDCImpl(wxMemoryDC *owner)
: wxCocoaDCImpl(owner)
{ Init(); }
wxMemoryDCImpl(wxMemoryDC *owner, wxBitmap& bitmap)
: wxCocoaDCImpl(owner)
{ Init();
owner->SelectObject(bitmap);
}
wxMemoryDCImpl(wxMemoryDC *owner, wxDC *dc ); // Create compatible DC
virtual ~wxMemoryDCImpl(void);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoSelect(const wxBitmap& bitmap);
protected:
wxBitmap m_selectedBitmap;
WX_NSImage m_cocoaNSImage;
// DC stack
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
virtual bool CocoaGetBounds(void *rectData);
// Blitting
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
private:
void Init();
};
#endif
// __WX_COCOA_DCMEMORY_H__

View File

@ -0,0 +1,32 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dcscreen.h
// Purpose: wxScreenDCImpl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: dcscreen.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_DCSCREEN_H__
#define __WX_COCOA_DCSCREEN_H__
#include "wx/dcscreen.h"
#include "wx/cocoa/dc.h"
class WXDLLIMPEXP_CORE wxScreenDCImpl: public wxCocoaDCImpl
{
DECLARE_DYNAMIC_CLASS(wxScreenDCImpl)
public:
wxScreenDCImpl(wxScreenDC *owner);
wxScreenDCImpl(wxScreenDC *owner, wxDC *dc ); // Create compatible DC
virtual ~wxScreenDCImpl(void);
// Compatibility with X's requirements for drawing on top of all windows
static bool StartDrawingOnTop(wxWindow* WXUNUSED(window)) { return true; }
static bool StartDrawingOnTop(wxRect* WXUNUSED(rect) = NULL) { return true; }
static bool EndDrawingOnTop() { return true; }
};
#endif // __WX_COCOA_DCSCREEN_H__

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dialog.h
// Purpose: wxDialog class
// Author: David Elliott
// Modified by:
// Created: 2002/12/15
// RCS-ID: $Id: dialog.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_DIALOG_H_
#define _WX_COCOA_DIALOG_H_
#include "wx/defs.h"
// NOTE: we don't need panel.h, but other things expect it to be included
#include "wx/panel.h"
#include "wx/cocoa/NSPanel.h"
// ========================================================================
// wxDialog
// ========================================================================
class WXDLLIMPEXP_CORE wxDialog : public wxDialogBase, protected wxCocoaNSPanel
{
DECLARE_DYNAMIC_CLASS(wxDialog)
WX_DECLARE_COCOA_OWNER(NSPanel,NSWindow,NSWindow)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxDialog() { Init(); }
#if WXWIN_COMPATIBILITY_2_6
// Constructor with a modal flag, but no window id - the old convention
wxDialog(wxWindow *parent,
const wxString& title, bool WXUNUSED(modal),
int x = wxDefaultCoord, int y= wxDefaultCoord, int width = 500, int height = 500,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr)
{
Init();
Create(parent, wxID_ANY, title, wxPoint(x, y), wxSize(width, height),
style, name);
}
#endif // WXWIN_COMPATIBILITY_2_6
// Constructor with no modal flag - the new convention.
wxDialog(wxWindow *parent, wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr)
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr);
virtual ~wxDialog();
protected:
void Init();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
protected:
virtual void CocoaDelegate_windowWillClose(void);
virtual bool Cocoa_canBecomeMainWindow(bool &canBecome)
{ canBecome = true; return true; }
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual bool Show(bool show = true);
void SetModal(bool flag);
virtual bool IsModal() const { return m_isModal; }
bool m_isModal;
// For now, same as Show(true) but returns return code
virtual int ShowModal();
// may be called to terminate the dialog with the given return code
virtual void EndModal(int retCode);
};
#endif // _WX_COCOA_DIALOG_H_

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/dirdlg.h
// Purpose: wxDirDialog class
// Author: Ryan Norton
// Modified by: Hiroyuki Nakamura(maloninc)
// Created: 2006-01-10
// RCS-ID: $Id: dirdlg.h 61724 2009-08-21 10:41:26Z VZ $
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_DIRDLG_H_
#define _WX_COCOA_DIRDLG_H_
DECLARE_WXCOCOA_OBJC_CLASS(NSSavePanel);
#define wxDirDialog wxCocoaDirDialog
//-------------------------------------------------------------------------
// wxDirDialog
//-------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDirDialog: public wxDirDialogBase
{
DECLARE_DYNAMIC_CLASS(wxDirDialog)
wxDECLARE_NO_COPY_CLASS(wxDirDialog);
public:
wxDirDialog(wxWindow *parent,
const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxT(""),
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxDirDialogNameStr);
virtual ~wxDirDialog();
virtual int ShowModal();
inline WX_NSSavePanel GetNSSavePanel()
{ return (WX_NSSavePanel)m_cocoaNSWindow; }
protected:
wxString m_dir;
wxWindow * m_parent;
wxString m_fileName;
private:
wxArrayString m_fileNames;
};
#endif // _WX_DIRDLG_H_

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/evtloop.h
// Purpose: declaration of wxGUIEventLoop for wxCocoa
// Author: Vadim Zeitlin
// Created: 2008-12-28
// RCS-ID: $Id: evtloop.h 58911 2009-02-15 14:25:08Z FM $
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_EVTLOOP_H_
#define _WX_COCOA_EVTLOOP_H_
// ----------------------------------------------------------------------------
// wxGUIEventLoop for wxCocoa
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxEventLoopBase
{
public:
wxGUIEventLoop() { m_exitcode = 0; }
virtual int Run();
virtual void Exit(int rc = 0);
virtual bool Pending() const;
virtual bool Dispatch();
virtual int DispatchTimeout(unsigned long timeout);
virtual void WakeUp() { }
virtual bool YieldFor(long eventsToProcess);
protected:
int m_exitcode;
wxDECLARE_NO_COPY_CLASS(wxGUIEventLoop);
};
#endif // _WX_COCOA_EVTLOOP_H_

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/filedlg.h
// Purpose: wxFileDialog class
// Author: Ryan Norton
// Modified by:
// Created: 2004-10-02
// RCS-ID: $Id: filedlg.h 61724 2009-08-21 10:41:26Z VZ $
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_FILEDLG_H_
#define _WX_COCOA_FILEDLG_H_
DECLARE_WXCOCOA_OBJC_CLASS(NSSavePanel);
#define wxFileDialog wxCocoaFileDialog
//-------------------------------------------------------------------------
// wxFileDialog
//-------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileDialog: public wxFileDialogBase
{
DECLARE_DYNAMIC_CLASS(wxFileDialog)
wxDECLARE_NO_COPY_CLASS(wxFileDialog);
public:
wxFileDialog(wxWindow *parent,
const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = wxFD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize,
const wxString& name = wxFileDialogNameStr);
virtual ~wxFileDialog();
virtual void SetPath(const wxString& path);
virtual void GetPaths(wxArrayString& paths) const;
virtual void GetFilenames(wxArrayString& files) const;
virtual int ShowModal();
inline WX_NSSavePanel GetNSSavePanel()
{ return (WX_NSSavePanel)m_cocoaNSWindow; }
private:
WX_NSMutableArray m_wildcards;
wxArrayString m_fileNames;
};
#endif // _WX_FILEDLG_H_

View File

@ -0,0 +1,158 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/font.h
// Purpose: wxFont class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: font.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONT_H_
#define _WX_FONT_H_
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
DECLARE_WXCOCOA_OBJC_CLASS(NSFont);
// Internal class that bridges us with code like wxSystemSettings
class wxCocoaFontFactory;
// We have c-tors/methods taking pointers of these
class wxFontRefData;
/*! @discussion
wxCocoa's implementation of wxFont is very incomplete. In particular,
a lot of work needs to be done on wxNativeFontInfo which is currently
using the totally generic implementation.
See the documentation in src/cocoa/font.mm for more implementatoin details.
*/
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
{
friend class wxCocoaFontFactory;
public:
/*! @abstract Default construction of invalid font for 2-step construct then Create process.
*/
wxFont() { }
/*! @abstract Platform-independent construction with individual properties
*/
#if FUTURE_WXWIN_COMPATIBILITY_3_0
wxFont(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
(void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
}
#endif
wxFont(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
(void)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);
}
/*! @abstract Construction with opaque wxNativeFontInfo
*/
wxFont(const wxNativeFontInfo& info)
{
(void)Create(info);
}
/*! @abstract Construction with platform-dependent font descriptor string.
@param fontDesc Usually the result of wxNativeFontInfo::ToUserString()
*/
wxFont(const wxString& fontDesc);
// NOTE: Copy c-tor and assignment from wxObject is fine
bool Create(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
bool Create(const wxNativeFontInfo& info);
virtual ~wxFont();
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual wxFontStyle GetStyle() const;
virtual wxFontWeight GetWeight() const;
virtual bool GetUnderlined() const;
virtual wxString GetFaceName() const;
virtual wxFontEncoding GetEncoding() const;
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
virtual void SetPointSize(int pointSize);
virtual void SetFamily(wxFontFamily family);
virtual void SetStyle(wxFontStyle style);
virtual void SetWeight(wxFontWeight weight);
virtual bool SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);
wxDECLARE_COMMON_FONT_METHODS();
// implementation only from now on
// -------------------------------
/*! @abstract Defined on some ports (not including this one) in wxGDIObject
@discussion
The intention here I suppose is to allow one to create a wxFont without yet
creating the underlying native object. There's no point not to create the
NSFont immediately in wxCocoa so this is useless.
This method came from the stub code copied in the early days of wxCocoa.
FIXME(1): Remove this in trunk. FIXME(2): Is it really a good idea for this to
be part of the public API for wxGDIObject?
*/
virtual bool RealizeResource();
protected:
/*! @abstract Internal constructor with ref data
@discussion
Takes ownership of @a refData. That is, it is assumed that refData has either just been
created using new (which initializes its m_refCount to 1) or if you are sharing a ref that
you have called IncRef on it before passing it to this method.
*/
explicit wxFont(wxFontRefData *refData)
{ Create(refData); }
bool Create(wxFontRefData *refData);
virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
virtual wxFontFamily DoGetFamily() const;
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
#endif
// _WX_FONT_H_

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/frame.h
// Purpose: wxFrame class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: frame.h 60337 2009-04-25 12:59:09Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_FRAME_H_
#define _WX_COCOA_FRAME_H_
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
class WXDLLIMPEXP_FWD_CORE wxStatusBar;
class WXDLLIMPEXP_CORE wxFrame: public wxFrameBase
{
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxFrame() { Init(); }
wxFrame(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
virtual ~wxFrame();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
protected:
void Init();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
// Returns the NSView for non-client drawing
virtual WX_NSView GetNonClientNSView();
// Helper function to position status/tool bars
// Also called by native toolbar to force a size update
void UpdateFrameNSView();
virtual void CocoaDelegate_wxMenuItemAction(WX_NSMenuItem menuItem);
virtual bool CocoaDelegate_validateMenuItem(WX_NSMenuItem menuItem);
protected:
virtual void CocoaSetWxWindowSize(int width, int height);
virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
// frameNSView is used whenever a statusbar/generic toolbar are present
WX_NSView m_frameNSView;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void AttachMenuBar(wxMenuBar *mbar);
virtual void DetachMenuBar();
virtual void SetMenuBar(wxMenuBar *menubar);
// implementation only from now on
// -------------------------------
// override some more virtuals
// 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;
// create the main status bar by calling OnCreateStatusBar()
virtual wxStatusBar* CreateStatusBar(int number = 1,
long style = wxSTB_DEFAULT_STYLE,
wxWindowID winid = 0,
const wxString& name =
wxStatusLineNameStr);
// sets the main status bar
void SetStatusBar(wxStatusBar *statBar);
#if wxUSE_TOOLBAR
// create main toolbar bycalling OnCreateToolBar()
virtual wxToolBar* CreateToolBar(long style = -1,
wxWindowID winid = wxID_ANY,
const wxString& name = wxToolBarNameStr);
// sets the main tool bar
virtual void SetToolBar(wxToolBar *toolbar);
#endif //wxUSE_TOOLBAR
protected:
void PositionStatusBar();
};
#endif // _WX_COCOA_FRAME_H_

View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/gauge.h
// Purpose: wxGauge class
// Author: David Elliott
// Modified by:
// Created: 2003/07/15
// RCS-ID: $Id: gauge.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_GAUGE_H__
#define __WX_COCOA_GAUGE_H__
// #include "wx/cocoa/NSProgressIndicator.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSProgressIndicator);
// ========================================================================
// wxGauge
// ========================================================================
class WXDLLIMPEXP_CORE wxGauge: public wxGaugeBase// , protected wxCocoaNSProgressIndicator
{
DECLARE_DYNAMIC_CLASS(wxGauge)
DECLARE_EVENT_TABLE()
// WX_DECLARE_COCOA_OWNER(NSProgressIndicator,NSView,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxGauge() { }
wxGauge(wxWindow *parent, wxWindowID winid, int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxGaugeNameStr)
{
Create(parent, winid, range, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid, int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxGaugeNameStr);
virtual ~wxGauge();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
public:
inline WX_NSProgressIndicator GetNSProgressIndicator() const { return (WX_NSProgressIndicator)m_cocoaNSView; }
protected:
// NSProgressIndicator cannot be enabled/disabled
virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// Pure Virtuals
virtual int GetValue() const;
virtual void SetValue(int value);
// retrieve/change the range
virtual void SetRange(int maxValue);
int GetRange(void) const;
protected:
virtual wxSize DoGetBestSize() const;
};
#endif
// __WX_COCOA_GAUGE_H__

View File

@ -0,0 +1,98 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/glcanvas.h
// Purpose: wxGLCanvas class
// Author: David Elliott
// Modified by:
// Created: 2004/09/29
// RCS-ID: $Id: glcanvas.h 47254 2007-07-09 10:09:52Z VS $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_GLCANVAS_H__
#define _WX_COCOA_GLCANVAS_H__
#include "wx/window.h"
// #include "wx/cocoa/NSOpenGLView.h"
// Include gl.h from the OpenGL framework
#include <OpenGL/gl.h>
class WXDLLIMPEXP_FWD_GL wxGLCanvas;
DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLContext);
DECLARE_WXCOCOA_OBJC_CLASS(NSOpenGLView);
// ========================================================================
// wxGLContext
// ========================================================================
class WXDLLIMPEXP_GL wxGLContext : public wxGLContextBase
{
public:
wxGLContext(wxGLCanvas *win, const wxGLContext *other = NULL);
virtual ~wxGLContext();
virtual void SetCurrent(const wxGLCanvas& win) const;
WX_NSOpenGLContext GetNSOpenGLContext() const
{ return m_cocoaNSOpenGLContext; }
private:
WX_NSOpenGLContext m_cocoaNSOpenGLContext;
};
// ========================================================================
// wxGLCanvas
// ========================================================================
class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
// , protected wxCocoaNSOpenGLView
{
DECLARE_DYNAMIC_CLASS(wxGLCanvas)
// WX_DECLARE_COCOA_OWNER(NSOpenGLView,NSView,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxGLCanvas(wxWindow *parent,
wxWindowID id = wxID_ANY,
const int *attribList = NULL,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxGLCanvasName,
const wxPalette& palette = wxNullPalette)
{
Create(parent, id, pos, size, style, name, attribList, palette);
}
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 = NULL,
const wxPalette& palette = wxNullPalette);
virtual ~wxGLCanvas();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// NSOpenGLView cannot be enabled/disabled
virtual void CocoaSetEnabled(bool enable) { }
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void SwapBuffers();
NSOpenGLView *GetNSOpenGLView() const
{ return (NSOpenGLView *)m_cocoaNSView; }
};
#endif //ndef _WX_COCOA_GLCANVAS_H__

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/icon.h
// Purpose: wxIcon class
// Author: David Elliott
// Modified by:
// Created: 2003/08/11
// RCS-ID: $Id: icon.h 65887 2010-10-23 21:47:22Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_ICON_H__
#define _WX_COCOA_ICON_H__
#include "wx/gdicmn.h"
#include "wx/gdiobj.h"
// ========================================================================
// wxIcon
// ========================================================================
class WXDLLIMPEXP_CORE wxIcon : public wxGDIObject
{
public:
wxIcon();
wxIcon(const char* const* data) { CreateFromXpm(data); }
wxIcon(const char bits[], int width , int height );
wxIcon(const wxString& name, int flags = wxICON_DEFAULT_TYPE,
int desiredWidth = -1, int desiredHeight = -1);
wxIcon(const wxIconLocation& loc)
{
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
}
virtual ~wxIcon();
bool LoadFile(const wxString& name, wxBitmapType flags = wxICON_DEFAULT_TYPE,
int desiredWidth=-1, int desiredHeight=-1);
bool operator==(const wxIcon& icon) const
{ return m_refData == icon.m_refData; }
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
// create from bitmap (which should have a mask unless it's monochrome):
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
// ctors, assignment operators...), but it's ok to have such function
void CopyFromBitmap(const wxBitmap& bmp);
int GetWidth() const;
int GetHeight() const;
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
WX_NSImage GetNSImage() const;
bool CreateFromXpm(const char* const* bits);
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
private:
DECLARE_DYNAMIC_CLASS(wxIcon)
};
#endif // _WX_COCOA_ICON_H__

View File

@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/listbox.h
// Purpose: wxListBox class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: listbox.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_LISTBOX_H__
#define __WX_COCOA_LISTBOX_H__
#include "wx/cocoa/NSTableView.h"
#include "wx/dynarray.h"
// ========================================================================
// wxListBox
// ========================================================================
class WXDLLIMPEXP_CORE wxListBox: public wxListBoxBase, protected wxCocoaNSTableView
{
DECLARE_DYNAMIC_CLASS(wxListBox)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSTableView,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxListBox() { m_cocoaItems = NULL; m_cocoaDataSource = NULL; }
wxListBox(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = 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 = 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[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = 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 = wxListBoxNameStr);
virtual ~wxListBox();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual int CocoaDataSource_numberOfRows();
virtual struct objc_object* CocoaDataSource_objectForTableColumn(
WX_NSTableColumn tableColumn, int rowIndex);
WX_NSMutableArray m_cocoaItems;
wxArrayPtrVoid m_itemClientData;
struct objc_object *m_cocoaDataSource;
bool m_needsUpdate;
inline bool _WxCocoa_GetNeedsUpdate();
inline void _WxCocoa_SetNeedsUpdate(bool needsUpdate);
virtual void OnInternalIdle();
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual wxSize DoGetBestSize() const;
// pure virtuals from wxListBoxBase
virtual bool IsSelected(int n) const;
virtual int GetSelections(wxArrayInt& aSelections) const;
protected:
virtual void DoSetFirstItem(int n);
virtual void DoSetSelection(int n, bool select);
// pure virtuals from wxItemContainer
public:
// deleting items
virtual void DoClear();
virtual void DoDeleteOneItem(unsigned int n);
// accessing strings
virtual unsigned int GetCount() const;
virtual wxString GetString(unsigned int n) const;
virtual void SetString(unsigned int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
// selection
virtual int GetSelection() const;
protected:
virtual int DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type);
virtual void DoSetItemClientData(unsigned int n, void* clientData);
virtual void* DoGetItemClientData(unsigned int n) const;
};
#endif // __WX_COCOA_LISTBOX_H__

View File

@ -0,0 +1,22 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/log.h
// Purpose: Declare wxCocoa-specific trace masks
// Author: David Elliott
// Modified by:
// Created: 2004/02/07
// RCS-ID: $Id: log.h 27408 2004-05-23 20:53:33Z JS $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_LOG_H__
#define _WX_COCOA_LOG_H__
// General tracing (in lieu of wxLogDebug)
#define wxTRACE_COCOA wxT("COCOA")
// Specific tracing
#define wxTRACE_COCOA_RetainRelease wxT("COCOA_RetainRelease")
#define wxTRACE_COCOA_TopLevelWindow_Size wxT("COCOA_TopLevelWindow_Size")
#define wxTRACE_COCOA_Window_Size wxT("COCOA_Window_Size")
#endif //ndef _WX_COCOA_LOG_H__

View File

@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/mbarman.h
// Purpose: wxMenuBarManager class
// Author: David Elliott
// Modified by:
// Created: 2003/09/04
// RCS-ID: $Id: mbarman.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_MBARMAN_H__
#define __WX_COCOA_MBARMAN_H__
#if wxUSE_MENUS
#include "wx/toplevel.h"
DECLARE_WXCOCOA_OBJC_CLASS(wxMenuBarManagerObserver);
// ========================================================================
// wxMenuBarManager
// ========================================================================
class WXDLLIMPEXP_CORE wxMenuBarManager : public wxObject
{
// ------------------------------------------------------------------------
// initialization/destruction
// ------------------------------------------------------------------------
public:
wxMenuBarManager();
virtual ~wxMenuBarManager();
// ------------------------------------------------------------------------
// Single instance
// ------------------------------------------------------------------------
public:
static wxMenuBarManager *GetInstance() { return sm_mbarmanInstance; }
static void CreateInstance();
static void DestroyInstance();
protected:
static wxMenuBarManager *sm_mbarmanInstance;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
void SetMainMenuBar(wxMenuBar* menubar);
void WindowDidBecomeKey(NSNotification *notification);
#if 0
void WindowDidResignKey(NSNotification *notification);
void WindowDidBecomeMain(NSNotification *notification);
void WindowDidResignMain(NSNotification *notification);
void WindowWillClose(NSNotification *notification);
#endif // 0
void UpdateMenuBar();
protected:
void SetMenuBar(wxMenuBar* menubar);
void InstallMenuBarForWindow(wxCocoaNSWindow *win);
void InstallMainMenu();
WX_NSMenu m_menuApp;
WX_NSMenu m_menuServices;
WX_NSMenu m_menuWindows;
WX_NSMenu m_menuMain;
// Is main menu bar the current one
bool m_mainMenuBarInstalled;
// Main menu (if app provides one)
wxMenuBar *m_mainMenuBar;
wxMenuBarManagerObserver *m_observer;
WX_NSWindow m_currentNSWindow;
};
#endif // wxUSE_MENUS
#endif // _WX_COCOA_MBARMAN_H_

View File

@ -0,0 +1,164 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/mdi.h
// Purpose: wxMDIParentFrame, wxMDIChildFrame, wxMDIClientWindow
// Author: David Elliott
// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
// Created: 2003/09/08
// RCS-ID: $Id: mdi.h 56674 2008-11-04 02:46:19Z VZ $
// Copyright: (c) 2003 David Elliott
// (c) 2008 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_MDI_H__
#define __WX_COCOA_MDI_H__
#include "wx/frame.h"
DECLARE_WXCOCOA_OBJC_CLASS(wxMDIParentFrameObserver);
class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow;
WX_DECLARE_EXPORTED_LIST(wxMDIChildFrame, wxCocoaMDIChildFrameList);
// ========================================================================
// wxMDIParentFrame
// ========================================================================
class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase
{
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxMDIParentFrame() { Init(); }
wxMDIParentFrame(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
virtual ~wxMDIParentFrame();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
protected:
void Init();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
void WindowDidBecomeMain(NSNotification *notification);
protected:
virtual void CocoaDelegate_windowDidBecomeKey(void);
virtual void CocoaDelegate_windowDidResignKey(void);
virtual bool Cocoa_canBecomeMainWindow(bool &canBecome);
virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
void AddMDIChild(wxMDIChildFrame *child);
void RemoveMDIChild(wxMDIChildFrame *child);
wxMDIParentFrameObserver *m_observer;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
void SetActiveChild(wxMDIChildFrame *child);
// implement base class pure virtuals
// ----------------------------------
static bool IsTDI() { return false; }
virtual void ActivateNext() { /* TODO */ }
virtual void ActivatePrevious() { /* TODO */ }
protected:
wxMDIClientWindow *m_clientWindow;
wxMDIChildFrame *m_currentChild;
wxCocoaMDIChildFrameList m_mdiChildren;
};
// ========================================================================
// wxMDIChildFrame
// ========================================================================
class WXDLLIMPEXP_CORE wxMDIChildFrame: public wxFrame
{
friend class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxMDIChildFrame() { Init(); }
wxMDIChildFrame(wxMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
virtual ~wxMDIChildFrame();
bool Create(wxMDIParentFrame *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
protected:
void Init();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
protected:
virtual void CocoaDelegate_windowDidBecomeKey(void);
virtual void CocoaDelegate_windowDidBecomeMain(void);
virtual void CocoaDelegate_windowDidResignKey(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void Activate();
virtual bool Destroy();
protected:
wxMDIParentFrame *m_mdiParent;
};
// ========================================================================
// wxMDIClientWindow
// ========================================================================
class wxMDIClientWindow : public wxMDIClientWindowBase
{
public:
wxMDIClientWindow() { }
virtual bool CreateClient(wxMDIParentFrame *parent,
long style = wxHSCROLL | wxVSCROLL);
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
};
#endif // __WX_COCOA_MDI_H__

View File

@ -0,0 +1,186 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/menu.h
// Purpose: wxMenu and wxMenuBar classes
// Author: David Elliott
// Modified by:
// Created: 2002/12/09
// RCS-ID: $Id: menu.h 58022 2009-01-11 12:00:51Z FM $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_MENU_H__
#define __WX_COCOA_MENU_H__
#include "wx/cocoa/NSMenu.h"
#if wxUSE_ACCEL
#include "wx/accel.h"
#endif // wxUSE_ACCEL
// ========================================================================
// wxMenu
// ========================================================================
class WXDLLIMPEXP_CORE wxMenu : public wxMenuBase, public wxCocoaNSMenu
{
public:
// ctors and dtor
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style)
, m_cocoaDeletes(false)
{ Create(title,style); }
bool Create(const wxString& title, long style = 0);
wxMenu(long style = 0) : wxMenuBase(style) { Create(wxEmptyString, style); }
virtual ~wxMenu();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
inline WX_NSMenu GetNSMenu() { return m_cocoaNSMenu; }
void SetCocoaDeletes(bool cocoaDeletes);
virtual void Cocoa_dealloc();
protected:
WX_NSMenu m_cocoaNSMenu;
bool m_cocoaDeletes;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
protected:
// implement base class virtuals
virtual wxMenuItem* DoAppend(wxMenuItem *item);
virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem* DoRemove(wxMenuItem *item);
#if wxUSE_ACCEL
// add/remove accel for the given menu item
void AddAccelFor(wxMenuItem *item);
void RemoveAccelFor(wxMenuItem *item);
#endif // wxUSE_ACCEL
private:
#if wxUSE_ACCEL
// the accel table for this menu
wxAcceleratorTable m_accelTable;
#endif // wxUSE_ACCEL
DECLARE_DYNAMIC_CLASS(wxMenu)
};
// ========================================================================
// wxMenuBar
// ========================================================================
class WXDLLIMPEXP_CORE wxMenuBar : public wxMenuBarBase
{
public:
// ctors and dtor
wxMenuBar(long style = 0) { Create(style); }
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
bool Create(long style = 0);
virtual ~wxMenuBar();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
inline WX_NSMenu GetNSMenu() { return m_cocoaNSMenu; }
protected:
WX_NSMenu m_cocoaNSMenu;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// implement base class virtuals
virtual bool Append(wxMenu *menu, const wxString &title);
virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
virtual wxMenu *Remove(size_t pos);
virtual void EnableTop(size_t pos, bool enable);
virtual bool IsEnabledTop(size_t pos) const;
virtual void SetMenuLabel(size_t pos, const wxString& label);
virtual wxString GetMenuLabel(size_t pos) const;
virtual void Attach(wxFrame *frame);
virtual void Detach();
// get the next item for the givan accel letter (used by wxFrame), return
// -1 if none
//
// if unique is not NULL, filled with TRUE if there is only one item with
// this accel, FALSE if two or more
int FindNextItemForAccel(int idxStart,
int keycode,
bool *unique = NULL) const;
// called by wxFrame to set focus to or open the given menu
void SelectMenu(size_t pos);
#if wxUSE_ACCEL
// find the item for the given accel and generate an event if found
bool ProcessAccelEvent(const wxKeyEvent& event);
#endif // wxUSE_ACCEL
protected:
// event handlers
void OnLeftDown(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKillFocus(wxFocusEvent& event);
// process the mouse move event, return TRUE if we did, FALSE to continue
// processing as usual
//
// the coordinates are client coordinates of menubar, convert if necessary
bool ProcessMouseEvent(const wxPoint& pt);
// menubar geometry
virtual wxSize DoGetBestClientSize() const;
// has the menubar been created already?
bool IsCreated() const { return m_frameLast != NULL; }
// get the (total) width of the specified menu
wxCoord GetItemWidth(size_t pos) const;
// get the rect of the item
wxRect GetItemRect(size_t pos) const;
// get the menu from the given point or -1 if none
int GetMenuFromPoint(const wxPoint& pos) const;
// refresh the given item
void RefreshItem(size_t pos);
// refresh all items after this one (including it)
void RefreshAllItemsAfter(size_t pos);
// do we show a menu currently?
bool IsShowingMenu() const { return m_menuShown != 0; }
// we don't want to have focus except while selecting from menu
void GiveAwayFocus();
// the current item (only used when menubar has focus)
int m_current;
private:
// the last frame to which we were attached, NULL initially
wxFrame *m_frameLast;
// the currently shown menu or NULL
wxMenu *m_menuShown;
// should be showing the menu? this is subtly different from m_menuShown !=
// NULL as the menu which should be shown may be disabled in which case we
// don't show it - but will do as soon as the focus shifts to another menu
bool m_shouldShowMenu;
DECLARE_DYNAMIC_CLASS(wxMenuBar)
};
#endif // _WX_COCOA_MENU_H_

View File

@ -0,0 +1,100 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/menuitem.h
// Purpose: wxMenuItem class
// Author: David Elliott
// Modified by:
// Created: 2002/12/13
// RCS-ID: $Id: menuitem.h 58227 2009-01-19 13:55:27Z VZ $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_MENUITEM_H_
#define _WX_COCOA_MENUITEM_H_
#include "wx/hashmap.h"
#include "wx/bitmap.h"
#include "wx/cocoa/ObjcRef.h"
// ========================================================================
// wxMenuItem
// ========================================================================
#define wxMenuItemCocoa wxMenuItem
class wxMenuItemCocoa;
WX_DECLARE_HASH_MAP(WX_NSMenuItem,wxMenuItem*,wxPointerHash,wxPointerEqual,wxMenuItemCocoaHash);
class WXDLLIMPEXP_CORE wxMenuItemCocoa : public wxMenuItemBase
{
public:
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
wxMenuItemCocoa(wxMenu *parentMenu = NULL,
int id = wxID_SEPARATOR,
const wxString& name = wxEmptyString,
const wxString& help = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL,
wxMenu *subMenu = NULL);
virtual ~wxMenuItemCocoa();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
inline WX_NSMenuItem GetNSMenuItem() { return m_cocoaNSMenuItem; }
static inline wxMenuItem* GetFromCocoa(WX_NSMenuItem cocoaNSMenuItem)
{
wxMenuItemCocoaHash::iterator iter=sm_cocoaHash.find(cocoaNSMenuItem);
if(iter!=sm_cocoaHash.end())
return iter->second;
return NULL;
}
void CocoaItemSelected();
bool Cocoa_validateMenuItem();
protected:
void CocoaSetKeyEquivalent();
WX_NSMenuItem m_cocoaNSMenuItem;
static wxMenuItemCocoaHash sm_cocoaHash;
static wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaTarget;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// override base class virtuals to update the item appearance on screen
virtual void SetItemLabel(const wxString& text);
virtual void SetCheckable(bool checkable);
virtual void Enable(bool enable = TRUE);
virtual void Check(bool check = TRUE);
// we add some extra functions which are also available under MSW from
// wxOwnerDrawn class - they will be moved to wxMenuItemBase later
// hopefully
void SetBitmaps(const wxBitmap& bmpChecked,
const wxBitmap& bmpUnchecked = wxNullBitmap);
void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
const wxBitmap& GetBitmap(bool checked = TRUE) const
{ return checked ? m_bmpChecked : m_bmpUnchecked; }
protected:
// notify the menu about the change in this item
inline void NotifyMenu();
// set the accel index and string from text
void UpdateAccelInfo();
// the bitmaps (may be invalid, then they're not used)
wxBitmap m_bmpChecked,
m_bmpUnchecked;
// the accel string (i.e. "Ctrl-Q" or "Alt-F1")
wxString m_strAccel;
private:
DECLARE_DYNAMIC_CLASS(wxMenuItem)
};
#endif // _WX_COCOA_MENUITEM_H_

View File

@ -0,0 +1,71 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/msgdlg.h
// Purpose: wxMessageDialog class
// Author: Gareth Simpson
// Created: 2007-10-29
// RCS-ID: $Id: msgdlg.h 67254 2011-03-20 00:14:35Z DS $
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_MSGDLG_H_
#define _WX_COCOA_MSGDLG_H_
#include "wx/msgdlg.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSAlert);
#ifndef wxUSE_COCOA_NATIVE_MSGDLG
// trunk: Always use Cocoa dialog
// 2.8: Only use Cocoa dialog if ABI incompatible features is on
// Build both on both branches (there was no wxCocoaMessageDialog class so it's not an ABI issue)
#if 1/* wxUSE_ABI_INCOMPATIBLE_FEATURES */
#define wxUSE_COCOA_NATIVE_MSGDLG 1
#else
#define wxUSE_COCOA_NATIVE_MSGDLG 0
#endif
#endif
#if wxUSE_COCOA_NATIVE_MSGDLG
#define wxMessageDialog wxCocoaMessageDialog
#else
#include "wx/generic/msgdlgg.h"
#define wxMessageDialog wxGenericMessageDialog
#endif
// ----------------------------------------------------------------------------
// wxCocoaMessageDialog
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCocoaMessageDialog
: public wxMessageDialogWithCustomLabels
{
public:
wxCocoaMessageDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxMessageBoxCaptionStr,
long style = wxOK|wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
virtual int ShowModal();
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 wxMessageDialogWithCustomLabels method to get rid of
// accelerators in the custom label strings
//
// VZ: I have no idea _why_ do we do this but the old version did and
// I didn't want to change the existing behaviour
virtual void DoSetCustomLabel(wxString& var, const ButtonLabel& label);
DECLARE_DYNAMIC_CLASS(wxCocoaMessageDialog)
wxDECLARE_NO_COPY_CLASS(wxCocoaMessageDialog);
};
#endif // _WX_MSGDLG_H_

View File

@ -0,0 +1,105 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/notebook.h
// Purpose: wxNotebook class
// Author: David Elliott
// Modified by:
// Created: 2004/04/08
// RCS-ID: $Id: notebook.h 65930 2010-10-27 16:54:24Z VZ $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_NOTEBOOK_H__
#define _WX_COCOA_NOTEBOOK_H__
#include "wx/cocoa/NSTabView.h"
// ========================================================================
// wxNotebook
// ========================================================================
class WXDLLIMPEXP_CORE wxNotebook: public wxNotebookBase, protected wxCocoaNSTabView
{
DECLARE_DYNAMIC_CLASS(wxNotebook)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSTabView,NSView,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxNotebook() { }
wxNotebook(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxNotebookNameStr)
{
Create(parent, winid, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxNotebookNameStr);
virtual ~wxNotebook();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// Notebooks cannot be enabled/disabled
virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
virtual void CocoaDelegate_tabView_didSelectTabViewItem(WX_NSTabViewItem tabviewItem);
virtual bool CocoaDelegate_tabView_shouldSelectTabViewItem(WX_NSTabViewItem tabviewItem);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// set the currently selected page, return the index of the previously
// selected one (or wxNOT_FOUND on error)
int SetSelection(size_t nPage);
// get the currently selected page
int GetSelection() const;
// changes selected page without sending events
int ChangeSelection(size_t nPage);
// set/get the title of a page
bool SetPageText(size_t nPage, const wxString& strText);
wxString GetPageText(size_t nPage) const;
// sets/returns item's image index in the current image list
int GetPageImage(size_t nPage) const;
bool SetPageImage(size_t nPage, int nImage);
// set the size (the same for all pages)
void SetPageSize(const wxSize& size);
// SetPadding and SetTabSize aren't possible to implement
void SetPadding(const wxSize& padding);
void SetTabSize(const wxSize& sz);
//-----------------------
// adding/removing pages
// remove one page from the notebook, without deleting
virtual wxNotebookPage *DoRemovePage(size_t nPage);
// remove one page from the notebook
bool DeletePage(size_t nPage);
// remove all pages
bool DeleteAllPages();
// adds a new page to the notebook (it will be deleted ny the notebook,
// don't delete it yourself). If bSelect, this page becomes active.
// the same as AddPage(), but adds it at the specified position
bool InsertPage( size_t position,
wxNotebookPage *win,
const wxString& strText,
bool bSelect = false,
int imageId = -1 );
protected:
};
#endif //ndef _WX_COCOA_NOTEBOOK_H__

View File

@ -0,0 +1,31 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSMenu.h
// Purpose: WXNSMenu class
// Author: David Elliott
// Modified by:
// Created: 2007/04/20 (move from NSMenu.mm)
// RCS-ID: $Id: NSMenu.h 48106 2007-08-15 16:10:19Z DE $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_OBJC_NSMENU_H__
#define __WX_COCOA_OBJC_NSMENU_H__
#include "wx/cocoa/objc/objc_uniquifying.h"
#import <AppKit/NSMenu.h>
// ============================================================================
// @class WXNSMenu
// ============================================================================
@interface WXNSMenu : NSMenu
{
}
- (void)dealloc;
@end // WXNSMenu
WX_DECLARE_GET_OBJC_CLASS(WXNSMenu,NSMenu)
#endif //ndef __WX_COCOA_OBJC_NSMENU_H__

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSSlider.h
// Purpose: WXNSSlider class
// Author: David Elliott
// Modified by:
// Created: 2007/08/10 (move from NSSlider.mm)
// RCS-ID: $Id: NSSlider.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) 2007 Software 2000 Ltd.
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_OBJC_NSSLIDER_H__
#define __WX_COCOA_OBJC_NSSLIDER_H__
#include "wx/cocoa/objc/objc_uniquifying.h"
#import <AppKit/NSSlider.h>
// ============================================================================
// @class WXNSSlider
// ============================================================================
@interface WXNSSlider : NSSlider
@end
WX_DECLARE_GET_OBJC_CLASS(WXNSSlider,NSSlider)
// ============================================================================
// @class WXNSSliderCell
// ============================================================================
@interface WXNSSliderCell : NSSliderCell
@end
WX_DECLARE_GET_OBJC_CLASS(WXNSSliderCell,NSSliderCell)
#endif //ndef __WX_COCOA_OBJC_NSSLIDER_H__

View File

@ -0,0 +1,45 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSView.h
// Purpose: WXNSView class
// Author: David Elliott
// Modified by:
// Created: 2007/04/20 (move from NSView.mm)
// RCS-ID: $Id: NSView.h 46229 2007-05-28 04:22:10Z DE $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_OBJC_NSVIEW_H__
#define __WX_COCOA_OBJC_NSVIEW_H__
#include "wx/cocoa/objc/objc_uniquifying.h"
#import <AppKit/NSView.h>
// ============================================================================
// @class WXNSView
// ============================================================================
@interface WXNSView : NSView
{
}
- (void)drawRect: (NSRect)rect;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
- (void)mouseUp:(NSEvent *)theEvent;
- (void)mouseMoved:(NSEvent *)theEvent;
- (void)mouseEntered:(NSEvent *)theEvent;
- (void)mouseExited:(NSEvent *)theEvent;
- (void)rightMouseDown:(NSEvent *)theEvent;
- (void)rightMouseDragged:(NSEvent *)theEvent;
- (void)rightMouseUp:(NSEvent *)theEvent;
- (void)otherMouseDown:(NSEvent *)theEvent;
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
- (void)resetCursorRects;
- (void)viewDidMoveToWindow;
- (void)viewWillMoveToWindow:(NSWindow *)newWindow;
@end // WXNSView
WX_DECLARE_GET_OBJC_CLASS(WXNSView,NSView)
#endif //ndef __WX_COCOA_OBJC_NSVIEW_H__

View File

@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSWindow.h
// Purpose: WXNSWindow class
// Author: David Elliott
// Modified by:
// Created: 2007/04/20 (move from NSWindow.mm)
// RCS-ID: $Id: NSWindow.h 47988 2007-08-09 18:15:50Z DE $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#import <AppKit/NSWindow.h>
#import <AppKit/NSPanel.h>
#include "wx/cocoa/objc/objc_uniquifying.h"
// ============================================================================
// @class WXNSWindow
// ============================================================================
@interface WXNSWindow : NSWindow
{
}
- (BOOL)canBecomeKeyWindow;
- (BOOL)canBecomeMainWindow;
@end // WXNSWindow
WX_DECLARE_GET_OBJC_CLASS(WXNSWindow,NSWindow)
// ============================================================================
// @class WXNSPanel
// ============================================================================
@interface WXNSPanel : NSPanel
{
}
- (BOOL)canBecomeKeyWindow;
- (BOOL)canBecomeMainWindow;
@end // WXNSPanel
WX_DECLARE_GET_OBJC_CLASS(WXNSPanel,NSPanel)

View File

@ -0,0 +1,365 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/objc_uniquifying.h
// Purpose: Allows wxWidgets code to get a direct pointer to a compiled
// Objective-C class and provides a method to fix up the
// name to include a unique identifier (currently the address
// of the objc_class structure).
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2007/05/15
// RCS-ID: $Id: objc_uniquifying.h 51891 2008-02-18 20:36:16Z DE $
// Copyright: (c) 2007 Software 2000 Ltd.
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_OBJC_CLASS_H__
#define __WX_COCOA_OBJC_CLASS_H__
/* A note about this header:
Nothing in here is guaranteed to exist in future versions of wxCocoa. There
are other ways of adding Objective-C classes at runtime and a future wxCocoa
might use these instead of this ugly hack. You may use this header file in
your own wxCocoa code if you need your own Objective-C classes to be
unqiuified.
You cannot turn this on for 64-bit mode. It will not compile due to opaque
Objective-C data structures and it is not needed because it is a workaround
for a bug that does not exist in the 64-bit runtime.
You should not use this when wxCocoa is built as a dynamic library. This has
only been tested for the case when wxCocoa is built as a static library and
statically linked to user code to form a loadable bundle (e.g. a Cocoa plugin).
It forces each plugin (when multiple wxCocoa-using plugins are used) to use
its own internal Objective-C classes which is desirable when wxCocoa is
statically linked to the rest of the code.
Do not use uniquifying on your principal class. That one should be named
differently for different bundles.
*/
#if wxUSE_OBJC_UNIQUIFYING
// objc_getClass and stuff
#include <objc/objc-runtime.h>
////////////// Objective-C uniquifying implementation //////////////
template <typename ObjcType>
class wxObjcClassInitializer;
template <typename ObjcType>
class UniquifiedName;
template <typename ObjcType>
class wxObjcCompilerInformation
{
friend class wxObjcClassInitializer<ObjcType>;
friend class UniquifiedName<ObjcType>;
private:
// GetCompiledClass must be partially specialized for an ObjcType
// If you're not using it, implement an inline returning NULL
inline static struct objc_class * GetCompiledClass();
// sm_theClassName must be partially specialized for each type
static const char sm_theClassName[];
// GetSuperclass must be specialized. Typically one of two ways:
// 1. objc_getClass("SomeRealClassName")
// 2. wxGetObjcClass_SomeWxClassName();
inline static struct objc_class *GetSuperclass();
};
template <typename ObjcType>
struct UniquifiedName
{
// We're going for OriginalClassName@ClassStructureAddress
// Therefore our size is the sizeof the original class name constant string (which includes the terminating NULL)
// plus the sizeof a pointer to struct objc_class times two (two hex digits for each byte) plus 3 for "@0x"
typedef char Type[sizeof(wxObjcCompilerInformation<ObjcType>::sm_theClassName) + (sizeof(struct objc_class*)<<1) + 3];
static void Init(Type m_theString, const objc_class *aClass)
{
snprintf(const_cast<char*>(m_theString), sizeof(Type), "%s@%p", wxObjcCompilerInformation<ObjcType>::sm_theClassName, aClass);
}
};
/*! @function HidePointerFromGC
@abstract Returns an l-value whose location the compiler cannot know.
@discussion
The compiler-generated Objective-C class structures are located in the static data area.
They are by design Objective-C objects in their own right which makes the compiler issue
write barriers as if they were located in the GC-managed heap as most Objective-C objects.
By accepting and returning a reference to any pointer type we can set any i-var of an
Objective-C object that is a pointer to another Objective-C object without the compiler
generating an objc_assign_ivar write barrier. It will instad generate an
objc_assign_strongCast write barrier which is the appropriate write-barrier when assigning
pointers to Objective-C objects located in unknown memory.
For instance:
Class *someClass = ...;
HidePointerFromGC(someClass->isa) = ...;
*/
template <typename ObjcType>
inline ObjcType * & HidePointerFromGC(ObjcType * &p) __attribute__((always_inline));
template <typename ObjcType>
inline ObjcType * & HidePointerFromGC(ObjcType * &p)
{
return p;
}
template <typename ObjcType>
class wxObjcClassInitializer
{
public:
static struct objc_class* Get()
{
static wxObjcClassInitializer<ObjcType> s_theInstance;
s_theInstance.noop(); // Make the compiler think we need this instance
return wxObjcCompilerInformation<ObjcType>::GetCompiledClass();
}
private:
void noop()
{}
// This "constructor" operates solely on static data
// It exists so that we can take advantage of a function-static
// "instance" of this class to do the static data initialization.
wxObjcClassInitializer()
{
// Objective-C class initialization occurs before C++ static initialization because the
// libobjc.dylib gets notified directly by dyld on Tiger.
// Therefore, even though we change the name, the class is still registered with the
// original name. We unfortunately can't change that.
// The first time the class is loaded, Objective-C will already have fixed up the super_class
// and isa->isa and isa->super_class variables so much of this won't do anything. But
// the next time the class is loaded, Objective-C will ignore it and thus we need to
// initialize the data structures appropriately.
// Ideally we'd have some sort of lock here, but we depend on the fact that we get called
// just before the first time someone wants to send a class message so it should be
// reasonably safe to do this without any locks.
struct objc_class &theClassData = *wxObjcCompilerInformation<ObjcType>::GetCompiledClass();
// Initialize the uniquified class name
UniquifiedName<ObjcType>::Init(sm_theUniquifiedClassName, &theClassData);
//////// Class Initialization ////////
// Use objc_getClass to fix up the superclass pointer
theClassData.super_class = wxObjcCompilerInformation<ObjcType>::GetSuperclass();
// Fix up the compiler generated class struct to use the new name
theClassData.name = sm_theUniquifiedClassName;
//////// Meta-Class Initialization ////////
// theClassData.isa is the metaclass pointer
// Globals on Darwin use PC-relative access (slow) so it's quicker to use theClassData.isa
// In any object hierarchy a metaclass's metaclass is always the root class's metaclass
// Therefore, our superclass's metaclass's metaclass should already be the root class's metaclass
HidePointerFromGC(theClassData.isa->isa) = theClassData.super_class->isa->isa;
// A metaclass's superclass is always the superclass's metaclass.
HidePointerFromGC(theClassData.isa->super_class) = theClassData.super_class->isa;
// Fix up the compiler generated metaclass struct to use the new name
theClassData.isa->name = sm_theUniquifiedClassName;
// We need to set the initialized flag because after we change the name, Objective-C can't
// look us up by name because we're only registered with the original name.
theClassData.isa->info |= CLS_INITIALIZED;
}
wxObjcClassInitializer(const wxObjcClassInitializer&); // NO COPY
wxObjcClassInitializer& operator =(const wxObjcClassInitializer&); // NO ASSIGN
static typename UniquifiedName<ObjcType>::Type sm_theUniquifiedClassName;
};
template<typename ObjcType>
typename UniquifiedName<ObjcType>::Type wxObjcClassInitializer<ObjcType>::sm_theUniquifiedClassName;
// WX_DECLARE_GET_OBJC_CLASS
// Declares a function to get a direct pointer to an objective-C class.
// The class is guaranteed to be usable.
// When wxCocoa is built into a Mach-O bundle this function allows the wxCocoa
// code to get a reference to the Objective-C class structure located in the
// same bundle. This allows a static wxCocoa library to be built into
// two different Mach-O bundles without having one bundle's Objective-C
// classes trample on the other's.
// Right now we toss the ObjcSuperClass parameter, but we might use it later.
#define WX_DECLARE_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass) \
struct objc_class* wx_GetObjcClass_ ## ObjcClass();
// WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass)
// Provides an architecture-dependent way to get the direct pointer to the
// objc_class structure in the __OBJC segment.
// This takes advantage of the fact that the Objective-C compiler uses guessable
// local assembler labels for the class structures.
// Those class structures are only available on the Objective-C file containing the
// @implementation block.
#if 1
// Generic implementation - Tested on i386 and PPC. Should work in all cases.
// This is a hack that depends on GCC asm symbol names.
// The static variable winds up being initialized with a direct reference to the appropriate
// L_OBJC_CLASS and no global symbol reference is generated because nothing uses the global symbol
// except for the static initializer which does it directly.
// The generated assembler for s_objc_class_ptr is basically like this:
// _s_objc_class_ptr_ObjcClass:
// .long L_OBJC_CLASS_ObjcClass
// Once that static symbol is defined, the function implementation is easy for GCC to generate.
// Do note that return &s_objc_class_data_ObjcClass won't work. The code is wrong in the case.
#define WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \
extern "C" objc_class s_objc_class_data_ ## ObjcClass asm("L_OBJC_CLASS_" #ObjcClass); \
static objc_class * s_objc_class_ptr_ ## ObjcClass = &s_objc_class_data_ ## ObjcClass; \
template<> \
inline objc_class * wxObjcCompilerInformation<ObjcClass>::GetCompiledClass() \
{ \
return s_objc_class_ptr_## ObjcClass; \
}
#elif defined(__i386__)
// Not used because the generic implementation seems to work fine.
// But this is here since it was written beforehand and it also works.
// This is based on the code GCC generates for accessing file-static data on i386.
// The i386 PC-relative addressing happens in this manner
// 1. The program counter is placed into ecx using the code that GCC should have
// already generated.
// 2. A label is placed directly after the call to get the program counter.
// 3. The Load Effective Address instruction is used to add the offset of the
// local assembler label we're interested in minus the local assembler label
// from step 2 to the program counter register in ecx and place the result
// into the result register (typically eax if not inlined).
#define WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \
template<> \
inline objc_class * wxObjcCompilerInformation<ObjcClass>::GetCompiledClass() \
{ \
register struct objc_class *retval; \
asm \
( "call ___i686.get_pc_thunk.cx\n" \
"\"LPC_FOR_GET_CLASS_" #ObjcClass "\":\n\t" \
"leal L_OBJC_CLASS_" #ObjcClass "-\"LPC_FOR_GET_CLASS_" #ObjcClass "\"(%%ecx), %0" \
: "=r"(retval) \
: \
: "ecx" \
); \
return retval; \
}
#elif defined(__ppc__)
// Not used because the generic implementation seems to work fine.
// But this is here since it was written beforehand and it also works.
// This is based on the code GCC generates for accessing file-static data on PPC.
// The PowerPC PC-relative addressing happens in this manner
// 1. The link register is saved (mflr) to a temporary (we re-use the output register for this)
// 2. An unconditional branch instruction (bcl) "branches" to the following address (labeled)
// 3. The link register (filled in by bcl) is saved to r10 (a temporary)
// 4. The previous link register is restored (mtlr) (from the output register we were using as a temporary)
// 5. The address of the LPC label as executed is added to the high 16 bits of the offset between that label and the static data we want
// and stored in a temporary register (r2)
// 6. That temporary register plus the low 16 bits of the offset are stored into the result register.
#define WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \
template<> \
inline objc_class * wxObjcCompilerInformation<ObjcClass>::GetCompiledClass() \
{ \
register struct objc_class *retval; \
asm \
( "mflr %0" \
"\n\tbcl 20, 31, \"LPC_FOR_GET_CLASS_" #ObjcClass "\"" \
"\n\"LPC_FOR_GET_CLASS_" #ObjcClass "\":" \
"\n\tmflr r10" \
"\n\tmtlr %0" \
"\n\taddis r2,r10,ha16(L_OBJC_CLASS_" #ObjcClass "-\"LPC_FOR_GET_CLASS_" #ObjcClass "\")" \
"\n\tla %0,lo16(L_OBJC_CLASS_" #ObjcClass "-\"LPC_FOR_GET_CLASS_" #ObjcClass "\")(r2)" \
: "=r" (retval) \
: \
: "r10","r2" \
); \
return retval; \
}
// TODO: __x86_64__, __ppc64__
#else // Can't wrie inline asm to bust into __OBJC segment
// This won't be used since the generic implementation takes precedence.
#warning "Don't know how to implement wxObjcCompilerInformation<ObjcClass>::GetCompiledClass on this platform"
#endif // platforms
// The WX_IMPLEMENT_OBJC_GET_SUPERCLASS macro implements the template specialization
// to get the superclass. This only works if it's a real superclass. If you are
// deriving from a class that's already being uniquified then you'd need to
// implement the specialization to call the appropriate get method instead.
#define WX_IMPLEMENT_OBJC_GET_SUPERCLASS(ObjcClass,ObjcSuperClass) \
template <> \
inline objc_class* wxObjcCompilerInformation<ObjcClass>::GetSuperclass() \
{ \
return objc_getClass(#ObjcSuperClass); \
}
// The WX_IMPLEMENT_OBJC_GET_UNIQUIFIED_SUPERCLASS macro implements the template
// specialization to get the superclass when the superclass is another uniquified
// Objective-C class.
#define WX_IMPLEMENT_OBJC_GET_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) \
template <> \
inline objc_class* wxObjcCompilerInformation<ObjcClass>::GetSuperclass() \
{ \
return wx_GetObjcClass_ ## ObjcSuperClass(); \
}
// The WX_IMPLEMENT_OBJC_CLASS_NAME macro implements the template specialization
// of the sm_theClassName constant. As soon as this specialization is in place
// sizeof(sm_theClassName) will return the number of bytes at compile time.
#define WX_IMPLEMENT_OBJC_CLASS_NAME(ObjcClass) \
template <> \
const char wxObjcCompilerInformation<ObjcClass>::sm_theClassName[] = #ObjcClass;
// The WX_IMPLEMENT_OBJC_GET_OBJC_CLASS macro is the final one that actually provides
// the wx_GetObjcClass_XXX function that will be called in lieu of asking the Objective-C
// runtime for the class. All the others are really machinery to make this happen.
#define WX_IMPLEMENT_OBJC_GET_OBJC_CLASS(ObjcClass) \
objc_class* wx_GetObjcClass_ ## ObjcClass() \
{ \
return wxObjcClassInitializer<ObjcClass>::Get(); \
}
// The WX_IMPLEMENT_GET_OBJC_CLASS macro combines all of these together
// for the case when the superclass is a non-uniquified class.
#define WX_IMPLEMENT_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass) \
WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \
WX_IMPLEMENT_OBJC_GET_SUPERCLASS(ObjcClass,ObjcSuperClass) \
WX_IMPLEMENT_OBJC_CLASS_NAME(ObjcClass) \
WX_IMPLEMENT_OBJC_GET_OBJC_CLASS(ObjcClass)
// The WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS macro combines all
// of these together for the case when the superclass is another uniquified class.
#define WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) \
WX_IMPLEMENT_OBJC_GET_COMPILED_CLASS(ObjcClass) \
WX_IMPLEMENT_OBJC_GET_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass) \
WX_IMPLEMENT_OBJC_CLASS_NAME(ObjcClass) \
WX_IMPLEMENT_OBJC_GET_OBJC_CLASS(ObjcClass)
// The WX_GET_OBJC_CLASS macro is intended to wrap the class name when the class
// is used as a message receiver (e.g. for calling class methods). When
// class name uniquifying is used, this calls the global function implemented
// in the Objective-C file containing the class @implementation.
#define WX_GET_OBJC_CLASS(ObjcClass) wx_GetObjcClass_ ## ObjcClass()
#else // wxUSE_OBJC_UNIQUIFYING
// Define WX_DECLARE_GET_OBJC_CLASS as nothing
#define WX_DECLARE_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass)
// Define WX_IMPLEMENT_GET_OBJC_CLASS as nothing
#define WX_IMPLEMENT_GET_OBJC_CLASS(ObjcClass,ObjcSuperClass)
// Define WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS as nothing
#define WX_IMPLEMENT_GET_OBJC_CLASS_WITH_UNIQUIFIED_SUPERCLASS(ObjcClass,ObjcSuperClass)
// Define WX_GET_OBJC_CLASS macro to output the class name and let the compiler do the normal thing
// The WX_GET_OBJC_CLASS macro is intended to wrap the class name when the class
// is used as a message receiver (e.g. for calling class methods). When
// class name uniquifying is not used, this is simply defined to be the class
// name which will allow the compiler to do the normal thing.
#define WX_GET_OBJC_CLASS(ObjcClass) ObjcClass
#endif // wxUSE_OBJC_UNIQUIFYING
#endif //ndef __WX_COCOA_OBJC_CLASS_H__

View File

@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/pen.h
// Purpose: wxPen class
// Author: David Elliott
// Modified by:
// Created: 2003/08/02 (stubs from 22.03.2003)
// RCS-ID: $Id: pen.h 54273 2008-06-17 17:28:26Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_PEN_H__
#define __WX_COCOA_PEN_H__
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
class WXDLLIMPEXP_FWD_CORE wxColour;
class WXDLLIMPEXP_FWD_CORE wxBitmap;
// ========================================================================
// wxPen
// ========================================================================
class WXDLLIMPEXP_CORE wxPen: public wxGDIObject
{
public:
wxPen();
wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
#if FUTURE_WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_FUTURE( wxPen(const wxColour& col, int width, int style) );
#endif
wxPen(const wxBitmap& stipple, int width);
virtual ~wxPen();
// FIXME: operator==() is wrong
bool operator==(const wxPen& pen) const { return m_refData == pen.m_refData; }
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
void SetColour(const wxColour& col) ;
void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
void SetWidth(int width);
void SetStyle(wxPenStyle style);
void SetStipple(const wxBitmap& stipple);
void SetDashes(int nb_dashes, const wxDash *dash);
void SetJoin(wxPenJoin join);
void SetCap(wxPenCap cap);
wxColour GetColour() const;
int GetWidth() const;
wxPenStyle GetStyle() const;
wxPenJoin GetJoin() const;
wxPenCap GetCap() const;
int GetDashes(wxDash **ptr) const;
wxBitmap *GetStipple() const;
#if FUTURE_WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_FUTURE( void SetStyle(int style) )
{ SetStyle((wxPenStyle)style); }
#endif
// Cocoa-specific
WX_NSColor GetNSColor();
int GetCocoaLineDash(const CGFloat **pattern);
protected:
wxGDIRefData *CreateGDIRefData() const;
wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
DECLARE_DYNAMIC_CLASS(wxPen)
};
#endif // __WX_COCOA_PEN_H__

View File

@ -0,0 +1,28 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/private/fontfactory.h
// Purpose: wxFontFactory class
// Author: David Elliott
// Modified by:
// Created: 2007-10-13
// RCS-ID: $Id: fontfactory.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: 2007 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_FONTFACTORY_H_
#define _WX_COCOA_FONTFACTORY_H_
/*! @discussion
This class exists so that wxFont need not know about wxSettings
The implementation, however, is in the font.mm file because the
implementation needs to have knowledge of wxFontRefData.
*/
class wxCocoaFontFactory
{
public:
/*! @abstract Create an instance with the specified NSFont and underline flag.
*/
static wxFont InstanceForNSFont(WX_NSFont cocoaFont, bool underlined = false);
};
#endif //_WX_COCOA_FONTFACTORY_H_

View File

@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/private/scrollview.h
// Purpose: wxWindowCocoaScrollView
// Author: David Elliott
// Modified by:
// Created: 2008/02/14
// RCS-ID: $Id: scrollview.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) 2003- David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_SCROLLVIEW_H__
#define _WX_COCOA_SCROLLVIEW_H__
@class NSScroller;
// ========================================================================
// wxWindowCocoaScrollView
// ========================================================================
class wxWindowCocoaScrollView: protected wxCocoaNSView
{
wxDECLARE_NO_COPY_CLASS(wxWindowCocoaScrollView);
public:
wxWindowCocoaScrollView(wxWindow *owner);
virtual ~wxWindowCocoaScrollView();
inline WX_NSScrollView GetNSScrollView() { return m_cocoaNSScrollView; }
void ClientSizeToSize(int &width, int &height);
void DoGetClientSize(int *x, int *y) const;
void Encapsulate();
void Unencapsulate();
// wxWindow calls this to do the work. Note that we don't have the refresh parameter
// because wxWindow handles that itself.
void SetScrollbar(int orientation, int position, int thumbSize, int range);
int GetScrollPos(wxOrientation orient);
void SetScrollPos(wxOrientation orient, int position);
int GetScrollRange(wxOrientation orient);
int GetScrollThumb(wxOrientation orient);
void ScrollWindow(int dx, int dy, const wxRect*);
void UpdateSizes();
void _wx_doScroller(NSScroller *sender);
protected:
wxWindowCocoa *m_owner;
WX_NSScrollView m_cocoaNSScrollView;
virtual void Cocoa_FrameChanged(void);
virtual void Cocoa_synthesizeMouseMoved(void) {}
/*!
Flag as to whether we're scrolling for a native view or a custom
wxWindow. This controls the scrolling behavior. When providing
scrolling for a native view we don't catch scroller action messages
and thus don't send scroll events and we don't actually scroll the
window when the application calls ScrollWindow.
When providing scrolling for a custom wxWindow, we make the NSScroller
send their action messages to us which we in turn package as wx window
scrolling events. At this point, the window will not physically be
scrolled. The application will most likely handle the event by calling
ScrollWindow which will do the real scrolling. On the other hand,
the application may instead not call ScrollWindow until some threshold
is reached. This causes the window to only scroll in steps which is
what, for instance, wxScrolledWindow does.
*/
bool m_isNativeView;
/*!
The range as the application code wishes to see it. That is, the
range from the last SetScrollbar call for the appropriate dimension.
The horizontal dimension is the first [0] element and the vertical
dimension the second [1] element.
In wxMSW, a SCROLLINFO with nMin=0 and nMax=range-1 is used which
gives exactly range possible positions so long as nPage (which is
the thumb size) is less than or equal to 1.
*/
int m_scrollRange[2];
/*!
The thumb size is intended to reflect the size of the visible portion
of the scrolled document. As the document size increases, the thumb
visible thumb size decreases. As document size decreases, the visible
thumb size increases. However, the thumb size on wx is defined in
terms of scroll units (which are effectively defined by the scroll
range) and so increasing the number of scroll units to reflect increased
document size will have the effect of decreasing the visible thumb
size even though the number doesn't change.
It's also important to note that subtracting the thumb size from the
full range gives you the real range that can be used. Microsoft
defines nPos (the current scrolling position) to be within the range
from nMin to nMax - max(nPage - 1, 0). We know that wxMSW code always
sets nMin = 0 and nMax = range -1. So let's algebraically reduce the
definition of the maximum allowed position:
Begin:
= nMax - max(nPage - 1, 0)
Substitute (range - 1) for nMax and thumbSize for nPage:
= range - 1 - max(thumbSize - 1, 0)
Add one inside the max conditional and subtract one outside of it:
= range - 1 - (max(thumbSize - 1 + 1, 1) - 1)
Reduce some constants:
= range - 1 - (max(thumbSize, 1) - 1)
Distribute the negative across the parenthesis:
= range - 1 - max(thumbSize, 1) + 1
Reduce the constants:
= range - max(thumbSize, 1)
Also keep in mind that thumbSize may never be greater than range but
can be equal to it. Thus for the smallest possible thumbSize there
are exactly range possible scroll positions (numbered from 0 to
range - 1) and for the largest possible thumbSize there is exactly
one possible scroll position (numbered 0).
*/
int m_scrollThumb[2];
/*!
The origin of the virtual coordinate space expressed in terms of client
coordinates. Starts at (0,0) and each call to ScrollWindow accumulates
into it. Thus if the user scrolls the window right (thus causing the
contents to move left with respect to the client origin, the
application code (typically wxScrolledWindow) will be called with
dx of -something, for example -20. This is added to m_virtualOrigin
and thus m_virtualOrigin will be (-20,0) in this example.
*/
wxPoint m_virtualOrigin;
private:
wxWindowCocoaScrollView();
};
#endif //ndef _WX_COCOA_SCROLLVIEW_H__

View File

@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/private/timer.h
// Purpose: Cocoa wxTimer class
// Author: Ryan Norton
// Id: $Id: timer.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_PRIVATE_TIMER_H_
#define _WX_COCOA_PRIVATE_TIMER_H_
#include "wx/private/timer.h"
#include "wx/cocoa/ObjcRef.h"
//-----------------------------------------------------------------------------
// wxTimer
//-----------------------------------------------------------------------------
DECLARE_WXCOCOA_OBJC_CLASS(NSTimer);
class WXDLLIMPEXP_CORE wxCocoaTimerImpl : public wxTimerImpl
{
public:
wxCocoaTimerImpl(wxTimer* timer) : wxTimerImpl(timer) { Init(); }
virtual ~wxCocoaTimerImpl();
virtual bool Start(int millisecs = -1, bool oneShot = false);
virtual void Stop();
virtual bool IsRunning() const;
WX_NSTimer GetNSTimer() { return m_cocoaNSTimer; }
protected:
void Init();
private:
WX_NSTimer m_cocoaNSTimer;
};
#endif // _WX_COCOA_PRIVATE_TIMER_H_

View File

@ -0,0 +1,138 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/radiobox.h
// Purpose: wxRadioBox class
// Author: David Elliott
// Modified by:
// Created: 2003/03/18
// RCS-ID: $Id: radiobox.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_RADIOBOX_H__
#define __WX_COCOA_RADIOBOX_H__
// #include "wx/cocoa/NSButton.h"
DECLARE_WXCOCOA_OBJC_CLASS(NSMatrix);
// ========================================================================
// wxRadioBox
// ========================================================================
class WXDLLIMPEXP_CORE wxRadioBox: public wxControl, public wxRadioBoxBase// , protected wxCocoaNSButton
{
DECLARE_DYNAMIC_CLASS(wxRadioBox)
DECLARE_EVENT_TABLE()
// NOTE: We explicitly skip NSControl because our primary cocoa view is
// the NSBox but we want to receive action messages from the NSMatrix.
WX_DECLARE_COCOA_OWNER(NSBox,NSView,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxRadioBox() { }
wxRadioBox(wxWindow *parent, wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 0,
long style = 0, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
{
Create(parent, winid, title, pos, size, n, choices, majorDim, style, validator, name);
}
wxRadioBox(wxWindow *parent, wxWindowID winid,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
int majorDim = 0,
long style = 0, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
{
Create(parent, winid, title, pos, size, choices, majorDim, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 0,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
int majorDim = 0,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
virtual ~wxRadioBox();
// Enabling
virtual bool Enable(unsigned int n, bool enable = true);
virtual bool IsItemEnabled(unsigned int WXUNUSED(n)) const
{
/* TODO */
return true;
}
// Showing
virtual bool Show(unsigned int n, bool show = true);
virtual bool IsItemShown(unsigned int WXUNUSED(n)) const
{
/* TODO */
return true;
}
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// Radio boxes cannot be enabled/disabled
virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
virtual void CocoaTarget_action(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// Pure virtuals
// selection
virtual void SetSelection(int n);
virtual int GetSelection() const;
// string access
virtual unsigned int GetCount() const;
virtual wxString GetString(unsigned int n) const;
virtual void SetString(unsigned int n, const wxString& label);
// change the individual radio button state
protected:
// We don't want the typical wxCocoaNSBox behavior because our real
// implementation is by using an NSMatrix as the NSBox's contentView.
WX_NSMatrix GetNSMatrix() const;
void AssociateNSBox(WX_NSBox theBox);
void DisassociateNSBox(WX_NSBox theBox);
virtual wxSize DoGetBestSize() const;
int GetRowForIndex(int n) const
{
if(m_windowStyle & wxRA_SPECIFY_COLS)
return n / GetMajorDim();
else
return n % GetMajorDim();
}
int GetColumnForIndex(int n) const
{
if(m_windowStyle & wxRA_SPECIFY_COLS)
return n % GetMajorDim();
else
return n / GetMajorDim();
}
};
#endif // __WX_COCOA_RADIOBOX_H__

View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/radiobut.h
// Purpose: wxRadioButton class
// Author: David Elliott
// Modified by:
// Created: 2003/03/18
// RCS-ID: $Id: radiobut.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_RADIOBUT_H__
#define __WX_COCOA_RADIOBUT_H__
#include "wx/cocoa/NSButton.h"
class WXDLLIMPEXP_FWD_CORE wxRadioButton;
WX_DECLARE_EXPORTED_LIST(wxRadioButton, wxRadioButtonList);
// ========================================================================
// wxRadioButton
// ========================================================================
class WXDLLIMPEXP_CORE wxRadioButton: public wxControl, protected wxCocoaNSButton
{
DECLARE_DYNAMIC_CLASS(wxRadioButton)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSButton,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxRadioButton() { m_radioMaster = NULL; }
wxRadioButton(wxWindow *parent, wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr)
{
Create(parent, winid, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr);
virtual ~wxRadioButton();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxNSButtonAction(void);
private:
void Cocoa_DeselectOtherButtonsInTheGroup(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void SetValue(bool);
virtual bool GetValue() const;
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const;
protected:
wxRadioButtonList m_radioSlaves;
wxRadioButton *m_radioMaster;
};
#endif // __WX_COCOA_RADIOBUT_H__

View File

@ -0,0 +1,76 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/region.h
// Purpose: wxRegion class
// Author: David Elliott
// Modified by:
// Created: 2004/04/12
// RCS-ID: $Id: region.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_REGION_H__
#define _WX_COCOA_REGION_H__
#include "wx/generic/region.h"
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
class WXDLLIMPEXP_CORE wxRegion : public wxRegionGeneric
{
public:
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
: wxRegionGeneric(x,y,w,h)
{}
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
: wxRegionGeneric(topLeft, bottomRight)
{}
wxRegion(const wxRect& rect)
: wxRegionGeneric(rect)
{}
wxRegion() {}
wxRegion(const wxBitmap& bmp)
: wxRegionGeneric()
{ Union(bmp); }
wxRegion(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0)
: wxRegionGeneric()
{ Union(bmp, transColour, tolerance); }
virtual ~wxRegion() {}
wxRegion(const wxRegion& r)
: wxRegionGeneric(r)
{}
wxRegion& operator= (const wxRegion& r)
{ return *(wxRegion*)&(this->wxRegionGeneric::operator=(r)); }
// Cocoa-specific creation
wxRegion(const NSRect& rect);
wxRegion(const NSRect *rects, int count);
private:
DECLARE_DYNAMIC_CLASS(wxRegion);
};
class WXDLLIMPEXP_CORE wxRegionIterator : public wxRegionIteratorGeneric
{
// DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
public:
wxRegionIterator() {}
wxRegionIterator(const wxRegion& region)
: wxRegionIteratorGeneric(region)
{}
wxRegionIterator(const wxRegionIterator& iterator)
: wxRegionIteratorGeneric(iterator)
{}
virtual ~wxRegionIterator() {}
wxRegionIterator& operator=(const wxRegionIterator& iter)
{ return *(wxRegionIterator*)&(this->wxRegionIteratorGeneric::operator=(iter)); }
};
#endif
//ndef _WX_COCOA_REGION_H__

View File

@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/scrolbar.h
// Purpose: wxScrollBar class
// Author: David Elliott
// Modified by:
// Created: 2004/04/25
// RCS-ID: $Id: scrolbar.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_SCROLBAR_H__
#define _WX_COCOA_SCROLBAR_H__
#include "wx/cocoa/NSScroller.h"
// ========================================================================
// wxScrollBar
// ========================================================================
class WXDLLIMPEXP_CORE wxScrollBar: public wxScrollBarBase, protected wxCocoaNSScroller
{
DECLARE_DYNAMIC_CLASS(wxScrollBar)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSScroller,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxScrollBar() { }
wxScrollBar(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSB_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxScrollBarNameStr)
{
Create(parent, winid, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSB_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxScrollBarNameStr);
virtual ~wxScrollBar();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxNSScrollerAction(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// accessors
virtual int GetThumbPosition() const;
virtual int GetThumbSize() const { return m_thumbSize; }
virtual int GetPageSize() const { return m_pageSize; }
virtual int GetRange() const { return m_range; }
// operations
virtual void SetThumbPosition(int viewStart);
virtual void SetScrollbar(int position, int thumbSize,
int range, int pageSize,
bool refresh = TRUE);
protected:
int m_range;
int m_thumbSize;
int m_pageSize;
};
#endif
// _WX_COCOA_SCROLBAR_H__

View File

@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/slider.h
// Purpose: wxSlider class
// Author: David Elliott
// Mark Oxenham
// Modified by:
// Created: 2003/06/19
// RCS-ID: $Id: slider.h 66844 2011-02-05 16:36:30Z VZ $
// Copyright: (c) 2003 David Elliott
// (c) 2007 Software 2000 Ltd.
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_SLIDER_H__
#define __WX_COCOA_SLIDER_H__
#include "wx/cocoa/NSSlider.h"
// ========================================================================
// wxSlider
// ========================================================================
class WXDLLIMPEXP_CORE wxSlider: public wxSliderBase, protected wxCocoaNSSlider
{
DECLARE_DYNAMIC_CLASS(wxSlider)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSSlider,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxSlider() { }
wxSlider(wxWindow *parent, wxWindowID winid,
int value, int minValue, int maxValue,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSL_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxSliderNameStr)
{
Create(parent, winid, value, minValue, maxValue,
pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
int value, int minValue, int maxValue,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSL_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxSliderNameStr);
virtual ~wxSlider();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// Override this so we can use wxCocoaNSControl's target
void AssociateNSSlider(WX_NSSlider theSlider);
// Helper method to do the real work
virtual void ProcessEventType(wxEventType commandType);
// from wxCocoaNSControl:
virtual void CocoaTarget_action();
// from wxCocoaNSSlider:
virtual void CocoaNotification_startTracking(WX_NSNotification notification);
virtual void CocoaNotification_continueTracking(WX_NSNotification notification);
virtual void CocoaNotification_stopTracking(WX_NSNotification notification);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// Pure Virtuals
virtual int GetValue() const;
virtual void SetValue(int value);
// retrieve/change the range
virtual void SetRange(int minValue, int maxValue);
virtual int GetMin() const;
virtual int GetMax() const;
// the line/page size is the increment by which the slider moves when
// cursor arrow key/page up or down are pressed (clicking the mouse is like
// pressing PageUp/Down) and are by default set to 1 and 1/10 of the range
virtual void SetLineSize(int lineSize);
virtual void SetPageSize(int pageSize);
virtual int GetLineSize() const;
virtual int GetPageSize() const;
// these methods get/set the length of the slider pointer in pixels
virtual void SetThumbLength(int lenPixels);
virtual int GetThumbLength() const;
// copied from (wxSliderCocoa.h)
virtual int GetTickFreq() const;
virtual void ClearTicks() { SetTickFreq(0); }
virtual void SetTickPos(int pos);
protected:
// Platform-specific implementation of SetTickFreq
virtual void DoSetTickFreq(int freq);
};
#endif
// __WX_COCOA_SLIDER_H__

View File

@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/sound.h
// Purpose: wxSound class (loads and plays short Windows .wav files).
// Optional on non-Windows platforms.
// Authors: David Elliott, Ryan Norton
// Modified by:
// Created: 2004-10-02
// RCS-ID: $Id: sound.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) 2004 David Elliott, Ryan Norton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_SOUND_H_
#define _WX_COCOA_SOUND_H_
#include "wx/object.h"
#include "wx/cocoa/ObjcRef.h"
class WXDLLIMPEXP_ADV wxSound : public wxSoundBase
{
public:
wxSound()
: m_cocoaNSSound(NULL)
{}
wxSound(const wxString& fileName, bool isResource = false)
: m_cocoaNSSound(NULL)
{ Create(fileName, isResource); }
wxSound(int size, const wxByte* data)
: m_cocoaNSSound(NULL)
{ LoadWAV(data,size,true); }
wxSound(const wxSound& sound); // why not?
virtual ~wxSound();
public:
bool Create(const wxString& fileName, bool isResource = false);
bool IsOk() const
{ return m_cocoaNSSound; }
static void Stop();
static bool IsPlaying();
void SetNSSound(WX_NSSound cocoaNSSound);
inline WX_NSSound GetNSSound()
{ return m_cocoaNSSound; }
protected:
bool DoPlay(unsigned flags) const;
bool LoadWAV(const wxUint8 *data, size_t length, bool copyData);
private:
WX_NSSound m_cocoaNSSound;
static const wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaDelegate;
};
#endif //ndef _WX_COCOA_SOUND_H_

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/spinbutt.h
// Purpose: wxSpinButton class
// Author: David Elliott
// Modified by:
// Created: 2003/07/14
// RCS-ID: $Id: spinbutt.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_SPINBUTT_H__
#define __WX_COCOA_SPINBUTT_H__
// #include "wx/cocoa/NSStepper.h"
// ========================================================================
// wxSpinButton
// ========================================================================
class WXDLLIMPEXP_CORE wxSpinButton: public wxSpinButtonBase// , protected wxCocoaNSStepper
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
DECLARE_EVENT_TABLE()
// WX_DECLARE_COCOA_OWNER(NSStepper,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxSpinButton() { }
wxSpinButton(wxWindow *parent, wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
const wxString& name = wxSPIN_BUTTON_NAME)
{
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 = wxSP_HORIZONTAL,
const wxString& name = wxSPIN_BUTTON_NAME);
virtual ~wxSpinButton();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
virtual void CocoaTarget_action();
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// Pure Virtuals
virtual int GetValue() const;
virtual void SetValue(int value);
// retrieve/change the range
virtual void SetRange(int minValue, int maxValue);
};
#endif
// __WX_COCOA_SPINBUTT_H__

View File

@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/statbmp.h
// Purpose: wxStaticBitmap class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: statbmp.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_STATBMP_H__
#define __WX_COCOA_STATBMP_H__
DECLARE_WXCOCOA_OBJC_CLASS(NSImageView);
// ========================================================================
// wxStaticBitmap
// ========================================================================
class WXDLLIMPEXP_CORE wxStaticBitmap : public wxStaticBitmapBase //, protected wxCocoaNSxxx
{
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
DECLARE_EVENT_TABLE()
// WX_DECLARE_COCOA_OWNER(NSxxx,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxStaticBitmap() {}
wxStaticBitmap(wxWindow *parent, wxWindowID winid,
const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxStaticBitmapNameStr)
{
Create(parent, winid, bitmap, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxStaticBitmapNameStr);
virtual ~wxStaticBitmap();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
WX_NSImageView GetNSImageView() { return (WX_NSImageView)m_cocoaNSView; }
wxBitmap m_bitmap;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
virtual void SetIcon(const wxIcon& icon);
virtual void SetBitmap(const wxBitmap& bitmap);
virtual wxBitmap GetBitmap() const;
};
#endif // __WX_COCOA_STATBMP_H__

View File

@ -0,0 +1,61 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/statbox.h
// Purpose: wxStaticBox class
// Author: David Elliott
// Modified by:
// Created: 2003/03/18
// RCS-ID: $Id: statbox.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_STATBOX_H__
#define __WX_COCOA_STATBOX_H__
#include "wx/cocoa/NSBox.h"
// ========================================================================
// wxStaticBox
// ========================================================================
class WXDLLIMPEXP_CORE wxStaticBox: public wxStaticBoxBase, protected wxCocoaNSBox
{
DECLARE_DYNAMIC_CLASS(wxStaticBox)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSBox,NSView,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxStaticBox() { }
wxStaticBox(wxWindow *parent, wxWindowID winid, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxStaticBoxNameStr)
{
Create(parent, winid, title, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID winid, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxStaticBoxNameStr);
virtual ~wxStaticBox();
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const;
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// Static boxes cannot be enabled/disabled
virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void GetBordersForSizer(int *borderTop, int *borderOther) const;
protected:
};
#endif // __WX_COCOA_STATBOX_H__

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/statline.h
// Purpose: wxStaticLine class
// Author: David Elliott
// Modified by:
// Created: 2003/03/18
// RCS-ID: $Id: statline.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_STATLINE_H__
#define __WX_COCOA_STATLINE_H__
// #include "wx/cocoa/NSButton.h"
// ========================================================================
// wxStaticLine
// ========================================================================
class WXDLLIMPEXP_CORE wxStaticLine: public wxStaticLineBase// , protected wxCocoaNSButton
{
DECLARE_DYNAMIC_CLASS(wxStaticLine)
DECLARE_EVENT_TABLE()
// WX_DECLARE_COCOA_OWNER(NSButton,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxStaticLine() { }
wxStaticLine(wxWindow *parent, wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxStaticLineNameStr)
{
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 = wxStaticLineNameStr);
virtual ~wxStaticLine();
// ------------------------------------------------------------------------
// Cocoa callbacks
// ------------------------------------------------------------------------
protected:
// Static lines cannot be enabled/disabled
virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
};
#endif // __WX_COCOA_STATLINE_H__

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/stattext.h
// Purpose: wxStaticText class
// Author: David Elliott
// Modified by:
// Created: 2003/02/15
// RCS-ID: $Id: stattext.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_STATTEXT_H__
#define __WX_COCOA_STATTEXT_H__
#include "wx/cocoa/NSTextField.h"
// ========================================================================
// wxStaticText
// ========================================================================
class WXDLLIMPEXP_CORE wxStaticText : public wxStaticTextBase, protected wxCocoaNSTextField
{
DECLARE_DYNAMIC_CLASS(wxStaticText)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSTextField,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxStaticText() {}
wxStaticText(wxWindow *parent, wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxStaticTextNameStr)
{
Create(parent, winid, label, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxStaticTextNameStr);
virtual ~wxStaticText();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_didChangeText(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const;
};
#endif // __WX_COCOA_STATTEXT_H__

View File

@ -0,0 +1,53 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/string.h
// Purpose: String conversion methods
// Author: David Elliott
// Modified by:
// Created: 2003/04/13
// RCS-ID: $Id: string.h 54721 2008-07-19 19:59:59Z VZ $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_STRING_H__
#define __WX_COCOA_STRING_H__
#import <Foundation/NSString.h>
#include "wx/string.h"
// FIXME: In unicode mode we are doing the conversion twice. wxString
// converts to UTF-8 and NSString converts from UTF-8.
// One possible optimization is to convert to the wxString internal
// representation which is an unsigned short (unichar) but unfortunately
// there is little documentation on which encoding it uses by default.
// Return an autoreleased NSString
inline NSString* wxNSStringWithWxString(const wxString &wxstring)
{
#if wxUSE_UNICODE
return [NSString stringWithUTF8String: wxstring.utf8_str()];
#else
return [NSString stringWithCString: wxstring.c_str() length:wxstring.Len()];
#endif // wxUSE_UNICODE
}
// Intialize an NSString which has already been allocated
inline NSString* wxInitNSStringWithWxString(NSString *nsstring, const wxString &wxstring)
{
#if wxUSE_UNICODE
return [nsstring initWithUTF8String: wxstring.utf8_str()];
#else
return [nsstring initWithCString: wxstring.c_str() length:wxstring.Len()];
#endif // wxUSE_UNICODE
}
inline wxString wxStringWithNSString(NSString *nsstring)
{
#if wxUSE_UNICODE
return wxString::FromUTF8Unchecked([nsstring UTF8String]);
#else
return wxString([nsstring lossyCString]);
#endif // wxUSE_UNICODE
}
#endif // __WX_COCOA_STRING_H__

View File

@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////
// File: wx/cocoa/taskbar.h
// Purpose: Defines wxTaskBarIcon class
// Author: David Elliott
// Modified by:
// Created: 2004/01/24
// RCS-ID: $Id: taskbar.h 50646 2007-12-12 01:35:53Z VZ $
// Copyright: (c) 2004 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_TASKBAR_H__
#define _WX_COCOA_TASKBAR_H__
#include "wx/icon.h"
class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxMenu;
class wxTaskBarIconCocoaImpl;
class WXDLLIMPEXP_ADV wxTaskBarIcon : public wxTaskBarIconBase
{
friend class wxTaskBarIconCocoaImpl;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxTaskBarIcon)
public:
//type of taskbar item to create (currently only DOCK is implemented)
enum wxTaskBarIconType
{ DOCK
, CUSTOM_STATUSITEM
// , STATUSITEM // TODO: Implement using NSStatusItem w/o custom NSView
// , MENUEXTRA // Menu extras require undocumented hacks
, DEFAULT_TYPE = CUSTOM_STATUSITEM
};
// Only one wxTaskBarIcon can be of the Dock type so by default
// create NSStatusItem for maximum source compatibility.
wxTaskBarIcon(wxTaskBarIconType iconType = DEFAULT_TYPE);
virtual ~wxTaskBarIcon();
bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString);
bool RemoveIcon();
bool PopupMenu(wxMenu *menu); //, int x, int y);
protected:
wxTaskBarIconCocoaImpl *m_impl;
};
#endif // _WX_COCOA_TASKBAR_H__

View File

@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/textctrl.h
// Purpose: wxTextCtrl class
// Author: David Elliott
// Modified by:
// Created: 2003/03/16
// RCS-ID: $Id: textctrl.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_TEXTCTRL_H__
#define __WX_COCOA_TEXTCTRL_H__
#include "wx/cocoa/NSTextField.h"
// ========================================================================
// wxTextCtrl
// ========================================================================
class WXDLLIMPEXP_CORE wxTextCtrl : public wxTextCtrlBase, protected wxCocoaNSTextField
{
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
DECLARE_EVENT_TABLE()
WX_DECLARE_COCOA_OWNER(NSTextField,NSControl,NSView)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxTextCtrl() {}
wxTextCtrl(wxWindow *parent, wxWindowID winid,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr)
{
Create(parent, winid, value, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID winid,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr);
virtual ~wxTextCtrl();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
protected:
virtual void Cocoa_didChangeText(void);
virtual void CocoaTarget_action(void);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual wxString GetValue() const;
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
virtual int GetNumberOfLines() const;
virtual bool IsModified() const;
virtual bool IsEditable() const;
// If the return values from and to are the same, there is no selection.
virtual void GetSelection(long* from, long* to) const;
// operations
// ----------
// editing
virtual void Clear();
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
// clears the dirty flag
virtual void MarkDirty();
virtual void DiscardEdits();
// writing text inserts it at the current position, appending always
// inserts it at the end
virtual void WriteText(const wxString& text);
virtual void AppendText(const wxString& text);
// translate between the position (which is just an index in the text ctrl
// considering all its contents as a single strings) and (x, y) coordinates
// which represent column and line.
virtual long XYToPosition(long x, long y) const;
virtual bool PositionToXY(long pos, long *x, long *y) const;
virtual void ShowPosition(long pos);
// Clipboard operations
virtual void Copy();
virtual void Cut();
virtual void Paste();
// Undo/redo
virtual void Undo();
virtual void Redo();
virtual bool CanUndo() const;
virtual bool CanRedo() const;
// Insertion point
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const;
virtual wxTextPos GetLastPosition() const;
virtual void SetSelection(long from, long to);
// virtual void SelectAll();
virtual void SetEditable(bool editable);
protected:
virtual wxSize DoGetBestSize() const;
virtual void DoSetValue(const wxString& value, int flags = 0);
};
#endif // __WX_COCOA_TEXTCTRL_H__

View File

@ -0,0 +1,121 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/toolbar.h
// Purpose: wxToolBar
// Author: David Elliott
// Modified by:
// Created: 2003/08/17
// RCS-ID: $Id: toolbar.h 48095 2007-08-15 13:05:35Z VS $
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_TOOLBAR_H__
#define __WX_COCOA_TOOLBAR_H__
#if wxUSE_TOOLBAR
// ========================================================================
// wxToolBar
// ========================================================================
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#endif
class wxToolBarTool;
class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase
{
DECLARE_DYNAMIC_CLASS(wxToolBar)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxToolBar() { Init(); }
wxToolBar( wxWindow *parent,
wxWindowID toolid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr )
{
Init();
Create(parent, toolid, pos, size, style, name);
}
bool Create( wxWindow *parent,
wxWindowID toolid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr );
virtual ~wxToolBar();
protected:
// common part of all ctors
void Init();
// ------------------------------------------------------------------------
// Cocoa
// ------------------------------------------------------------------------
protected:
virtual bool Cocoa_acceptsFirstMouse(bool &acceptsFirstMouse, WX_NSEvent theEvent);
virtual bool Cocoa_drawRect(const NSRect &rect);
virtual bool Cocoa_mouseDown(WX_NSEvent theEvent);
virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent);
wxToolBarTool *CocoaFindToolForPosition(const NSPoint& pos) const;
void CocoaToolClickEnded();
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// override base class virtuals
virtual void SetMargins(int x, int y);
virtual void SetToolSeparation(int separation);
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
virtual void SetToolShortHelp(int toolid, const wxString& helpString);
virtual void SetWindowStyleFlag( long style );
// implementation from now on
// --------------------------
void OnInternalIdle();
virtual bool Realize();
virtual wxSize DoGetBestSize() const;
void SetOwningFrame(wxFrame *owningFrame)
{ m_owningFrame = owningFrame; }
protected:
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int toolid,
const wxString& label,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
wxItemKind kind,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control,
const wxString& label);
wxSize m_bestSize;
wxFrame *m_owningFrame;
wxToolBarTool *m_mouseDownTool;
};
#endif // wxUSE_TOOLBAR
#endif // __WX_COCOA_TOOLBAR_H__

View File

@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/tooltip.h
// Purpose: wxToolTip class - tooltip control
// Author: Ryan Norton
// Modified by:
// Created: 31.01.99
// RCS-ID: $Id: tooltip.h 67254 2011-03-20 00:14:35Z DS $
// Copyright: (c) Ryan Norton
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COCOA_TOOLTIP_H_
#define _WX_COCOA_TOOLTIP_H_
#include "wx/object.h"
class wxWindow;
class wxToolTip : public wxObject
{
public:
// ctor & dtor
wxToolTip(const wxString &tip);
virtual ~wxToolTip();
// accessors
// tip text
void SetTip(const wxString& tip);
const wxString& GetTip() const;
// the window we're associated with
wxWindow *GetWindow() const;
// controlling tooltip behaviour: globally change tooltip parameters
// enable or disable the tooltips globally
static void Enable(bool flag);
// set the delay after which the tooltip appears
static void SetDelay(long milliseconds);
// set the delay after which the tooltip disappears or how long the tooltip remains visible
static void SetAutoPop(long milliseconds);
// set the delay between subsequent tooltips to appear
static void SetReshow(long milliseconds);
private:
void SetWindow(wxWindow* window);
friend class wxWindow;
wxString m_text; // tooltip text
wxWindow *m_window; // window we're associated with
DECLARE_ABSTRACT_CLASS(wxToolTip)
};
#endif // _WX_COCOA_TOOLTIP_H_

View File

@ -0,0 +1,131 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/toplevel.h
// Purpose: wxTopLevelWindowCocoa is the Cocoa implementation of wxTLW
// Author: David Elliott
// Modified by:
// Created: 2002/12/08
// RCS-ID: $Id: toplevel.h 52834 2008-03-26 15:06:00Z FM $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_TOPLEVEL_H__
#define __WX_COCOA_TOPLEVEL_H__
#include "wx/hashmap.h"
#include "wx/cocoa/NSWindow.h"
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
// ========================================================================
// wxTopLevelWindowCocoa
// ========================================================================
class WXDLLIMPEXP_CORE wxTopLevelWindowCocoa : public wxTopLevelWindowBase, protected wxCocoaNSWindow
{
DECLARE_EVENT_TABLE();
DECLARE_NO_COPY_CLASS(wxTopLevelWindowCocoa);
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
inline wxTopLevelWindowCocoa()
: wxCocoaNSWindow(this)
{ Init(); }
inline wxTopLevelWindowCocoa(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
: wxCocoaNSWindow(this)
{
Init();
Create(parent, winid, title, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID winid,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
virtual ~wxTopLevelWindowCocoa();
protected:
// common part of all ctors
void Init();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
inline WX_NSWindow GetNSWindow() { return m_cocoaNSWindow; }
virtual void CocoaDelegate_windowWillClose(void);
virtual bool CocoaDelegate_windowShouldClose(void);
virtual void CocoaDelegate_windowDidBecomeKey(void);
virtual void CocoaDelegate_windowDidResignKey(void);
virtual void CocoaDelegate_windowDidBecomeMain(void);
virtual void CocoaDelegate_windowDidResignMain(void);
virtual void CocoaDelegate_wxMenuItemAction(WX_NSMenuItem sender);
virtual bool CocoaDelegate_validateMenuItem(WX_NSMenuItem sender);
virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
static void DeactivatePendingWindow();
protected:
void SetNSWindow(WX_NSWindow cocoaNSWindow);
WX_NSWindow m_cocoaNSWindow;
static wxCocoaNSWindowHash sm_cocoaHash;
virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
static unsigned int NSWindowStyleForWxStyle(long style);
static NSRect MakeInitialNSWindowContentRect(const wxPoint& pos, const wxSize& size, unsigned int cocoaStyleMask);
static wxTopLevelWindowCocoa *sm_cocoaDeactivateWindow;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
virtual bool Destroy();
// Pure virtuals
virtual void Maximize(bool maximize = true);
virtual bool IsMaximized() const;
virtual void Iconize(bool iconize = true);
virtual bool IsIconized() const;
virtual void Restore();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const;
// other
virtual bool Show( bool show = true );
virtual bool Close( bool force = false );
virtual void OnCloseWindow(wxCloseEvent& event);
virtual void CocoaSetWxWindowSize(int width, int height);
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetPosition(int *x, int *y) const;
virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
// Default button (item)
wxWindow *SetDefaultItem(wxWindow *win);
// Things I may/may not do
// virtual void SetIcons(const wxIconBundle& icons);
// virtual void Clear() ;
// virtual void Raise();
// virtual void Lower();
protected:
// is the frame currently iconized?
bool m_iconized;
// has the frame been closed
bool m_closed;
// should the frame be maximized when it will be shown? set by Maximize()
// when it is called while the frame is hidden
bool m_maximizeOnShow;
};
// list of all frames and modeless dialogs
extern WXDLLIMPEXP_DATA_CORE(wxWindowList) wxModelessWindows;
#endif // __WX_COCOA_TOPLEVEL_H__

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/trackingrectmanager.h
// Purpose: wxCocoaTrackingRectManager
// Notes: Source in window.mm
// Author: David Elliott <dfe@cox.net>
// Modified by:
// Created: 2007/05/02
// RCS-ID: $Id: trackingrectmanager.h 58757 2009-02-08 11:45:59Z VZ $
// Copyright: (c) 2007 Software 2000 Ltd.
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_TRACKINGRECTMANAGER_H__
#define __WX_COCOA_TRACKINGRECTMANAGER_H__
#include <CoreFoundation/CFRunLoop.h>
#define wxTRACE_COCOA_TrackingRect wxT("COCOA_TrackingRect")
class wxCocoaTrackingRectManager
{
wxDECLARE_NO_COPY_CLASS(wxCocoaTrackingRectManager);
public:
wxCocoaTrackingRectManager(wxWindow *window);
void ClearTrackingRect();
void BuildTrackingRect();
void RebuildTrackingRectIfNeeded();
void RebuildTrackingRect();
bool IsOwnerOfEvent(NSEvent *anEvent);
~wxCocoaTrackingRectManager();
void BeginSynthesizingEvents();
void StopSynthesizingEvents();
protected:
wxWindow *m_window;
bool m_isTrackingRectActive;
NSInteger m_trackingRectTag;
NSRect m_trackingRectInWindowCoordinates;
private:
wxCocoaTrackingRectManager();
};
#endif // ndef __WX_COCOA_TRACKINGRECTMANAGER_H__

View File

@ -0,0 +1,227 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/window.h
// Purpose: wxWindowCocoa
// Author: David Elliott
// Modified by:
// Created: 2002/12/26
// RCS-ID: $Id: window.h 60984 2009-06-10 16:41:41Z VZ $
// Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_WINDOW_H__
#define __WX_COCOA_WINDOW_H__
#include "wx/cocoa/NSView.h"
#ifdef __OBJC__
#import <Foundation/NSGeometry.h>
#endif //def __OBJC__
// We can only import Foundation/NSGeometry.h from Objective-C code but it's
// nice to be able to use NSPoint and NSRect in the declarations of helper
// methods so we must define them as opaque structs identically to the way
// they are defined by the real header.
// NOTE: We specifically use these regardless of C++ or Objective-C++ mode so
// the compiler will complain if we got the definitions wrong. In regular
// C++ mode there is no way to know if we got the definitons right so
// we depend on at least one Objective-C++ file including this header.
#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
typedef struct CGPoint NSPoint;
typedef struct CGRect NSRect;
#else
typedef struct _NSPoint NSPoint;
typedef struct _NSRect NSRect;
#endif
DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
class wxWindowCocoaHider;
class wxWindowCocoaScrollView;
class wxCocoaTrackingRectManager;
// ========================================================================
// wxWindowCocoa
// ========================================================================
class WXDLLIMPEXP_CORE wxWindowCocoa: public wxWindowBase, protected wxCocoaNSView
{
DECLARE_DYNAMIC_CLASS(wxWindowCocoa)
wxDECLARE_NO_COPY_CLASS(wxWindowCocoa);
DECLARE_EVENT_TABLE()
friend wxWindow *wxWindowBase::GetCapture();
friend class wxWindowCocoaScrollView;
friend class wxCocoaTrackingRectManager;
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
public:
wxWindowCocoa() { Init(); }
inline wxWindowCocoa(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr)
{
Init();
Create(parent, winid, pos, size, style, name);
}
virtual ~wxWindowCocoa();
bool Create(wxWindow *parent, wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
protected:
void Init();
// ------------------------------------------------------------------------
// Cocoa specifics
// ------------------------------------------------------------------------
public:
// Returns the content NSView (where children are added, drawing performed)
inline WX_NSView GetNSView() { return m_cocoaNSView; }
// Returns the NSView suitable for use as a subview
WX_NSView GetNSViewForSuperview() const;
// Returns the NSView that may be hidden/is being hidden
WX_NSView GetNSViewForHiding() const;
// Returns the NSView for non-client drawing
virtual WX_NSView GetNonClientNSView() { return GetNSViewForSuperview(); }
// Add/remove children
void CocoaAddChild(wxWindowCocoa *child);
void CocoaRemoveFromParent(void);
#ifdef __OBJC__
// Returns an autoreleased NSAffineTransform which can be applied
// to a graphics context currently using the view's coordinate system
// (such as the one locked when drawRect is called or after a call
// to [NSView lockFocus]) such that further drawing is done using
// the wxWidgets coordinate system.
WX_NSAffineTransform CocoaGetWxToBoundsTransform();
#endif //def __OBJC__
protected:
// actually enable/disable the cocoa control, overridden by subclasses
virtual void CocoaSetEnabled(bool WXUNUSED(enable)) { }
void CocoaCreateNSScrollView();
void InitMouseEvent(wxMouseEvent &event, WX_NSEvent cocoaEvent);
virtual wxWindow* GetWxWindow() const;
virtual void Cocoa_FrameChanged(void);
virtual void Cocoa_synthesizeMouseMoved(void);
virtual bool Cocoa_drawRect(const NSRect &rect);
virtual bool Cocoa_mouseDown(WX_NSEvent theEvent);
virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent);
virtual bool Cocoa_mouseUp(WX_NSEvent theEvent);
virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent);
virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent);
virtual bool Cocoa_mouseExited(WX_NSEvent theEvent);
virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent);
virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent);
virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent);
virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent);
virtual bool Cocoa_resetCursorRects();
virtual bool Cocoa_viewDidMoveToWindow();
virtual bool Cocoa_viewWillMoveToWindow(WX_NSWindow newWindow);
void SetNSView(WX_NSView cocoaNSView);
WX_NSView m_cocoaNSView;
wxWindowCocoaHider *m_cocoaHider;
wxWindowCocoaScrollView *m_wxCocoaScrollView;
bool m_isInPaint;
wxCocoaTrackingRectManager *m_visibleTrackingRectManager;
static wxWindow *sm_capturedWindow;
virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
void SetInitialFrameRect(const wxPoint& pos, const wxSize& size);
#ifdef __OBJC__
inline NSRect MakeDefaultNSRect(const wxSize& size)
{
// NOTE: position is 10,10 to make it "obvious" that it's out of place
return NSMakeRect(10.0,10.0,WidthDefault(size.x),HeightDefault(size.y));
}
// These functions translate NSPoint or NSRect between the coordinate
// system of Cocoa's boudns rect and wx's coordinate system.
NSPoint CocoaTransformBoundsToWx(NSPoint pointBounds);
NSRect CocoaTransformBoundsToWx(NSRect rectBounds);
NSPoint CocoaTransformWxToBounds(NSPoint pointWx);
NSRect CocoaTransformWxToBounds(NSRect rectWx);
#endif //def __OBJC__
static wxPoint OriginInWxDisplayCoordinatesForRectInCocoaScreenCoordinates(NSRect windowFrame);
static NSPoint OriginInCocoaScreenCoordinatesForRectInWxDisplayCoordinates(wxCoord x, wxCoord y, wxCoord width, wxCoord height, bool keepOriginVisible);
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
/* Pure Virtuals */
// Raise the window to the top of the Z order
virtual void Raise();
// Lower the window to the bottom of the Z order
virtual void Lower();
// Set the focus to this window
virtual void SetFocus();
// Warp the pointer the given position
virtual void WarpPointer(int x_pos, int y_pos) ;
// Change the window's cursor
virtual bool SetCursor( const wxCursor &cursor );
// Send the window a refresh event
virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
// Set/get the window's font
virtual bool SetFont(const wxFont& f);
// inline virtual wxFont& GetFont() const;
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const;
// label handling
// Get character size
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void DoGetTextExtent(const wxString& string, int *x, int *y,
int *descent = NULL,
int *externalLeading = NULL,
const wxFont *theFont = NULL) const;
// Scroll stuff
virtual void SetScrollbar(int orient, int pos, int thumbVisible,
int range, bool refresh = true);
virtual void SetScrollPos(int orient, int pos, bool refresh = true);
virtual int GetScrollPos(int orient) const;
virtual int GetScrollThumb(int orient) const;
virtual int GetScrollRange(int orient) const;
virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
virtual void DoSetVirtualSize(int x, int y);
// Get the private handle (platform-dependent)
virtual WXWidget GetHandle() const;
// Convert client to screen coordinates
virtual void DoClientToScreen(int *x, int *y) const;
// Convert screen to client coordinates
virtual void DoScreenToClient(int *x, int *y) const;
// Capture/release mouse
virtual void DoCaptureMouse();
virtual void DoReleaseMouse();
// Get window position, relative to parent (or screen if no parent)
virtual void DoGetPosition(int *x, int *y) const;
// Get overall window size
virtual void DoGetSize(int *width, int *height) const;
// Get/set client (application-useable) size
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetClientSize(int width, int size);
// Set this window's tooltip
virtual void DoSetToolTip( wxToolTip *tip );
// Set the size of the wxWindow (the contentView of an NSWindow)
// wxTopLevelWindow will override this and set the NSWindow size
// such that the contentView will be this size
virtual void CocoaSetWxWindowSize(int width, int height);
// Set overall size and position
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void DoMoveWindow(int x, int y, int width, int height);
// Popup a menu
virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
/* Other implementation */
// NOTE: typically Close() is not virtual, but we want this for Cocoa
virtual bool Close( bool force = false );
virtual bool Show( bool show = true );
virtual void DoEnable( bool enable );
virtual bool IsDoubleBuffered() const { return true; }
};
#endif // __WX_COCOA_WINDOW_H__