Added original works and stubs to CVS repository
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
34
include/wx/cocoa/NSButton.h
Normal file
34
include/wx/cocoa/NSButton.h
Normal file
@@ -0,0 +1,34 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/NSButton.h
|
||||
// Purpose: wxCocoaNSButton class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/09
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_NSBUTTON_H__
|
||||
#define __WX_COCOA_NSBUTTON_H__
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
WX_DECLARE_OBJC_HASHMAP(NSButton);
|
||||
|
||||
class wxCocoaNSButton
|
||||
{
|
||||
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSButton);
|
||||
public:
|
||||
void AssociateNSButton(WX_NSButton cocoaNSButton);
|
||||
inline void DisassociateNSButton(WX_NSButton cocoaNSButton)
|
||||
{
|
||||
sm_cocoaHash.erase(cocoaNSButton);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void Cocoa_wxNSButtonAction(void) = 0;
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_NSBUTTON_H_
|
26
include/wx/cocoa/NSControl.h
Normal file
26
include/wx/cocoa/NSControl.h
Normal file
@@ -0,0 +1,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/NSControl.h
|
||||
// Purpose: wxCocoaNSControl class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_NSCONTROL_H__
|
||||
#define __WX_COCOA_NSCONTROL_H__
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
WX_DECLARE_OBJC_HASHMAP(NSControl);
|
||||
class wxCocoaNSControl
|
||||
{
|
||||
WX_DECLARE_OBJC_INTERFACE(NSControl)
|
||||
protected:
|
||||
// virtual void Cocoa_didChangeText(void) = 0;
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_NSCONTROL_H_
|
50
include/wx/cocoa/NSMenu.h
Normal file
50
include/wx/cocoa/NSMenu.h
Normal file
@@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/NSMenu.h
|
||||
// Purpose: wxCocoaNSMenu class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/09
|
||||
// RCS-ID: $Id:
|
||||
// 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/ObjcPose.h"
|
||||
|
||||
WX_DECLARE_OBJC_HASHMAP(NSMenu);
|
||||
|
||||
// ========================================================================
|
||||
// wxCocoaNSMenu
|
||||
// ========================================================================
|
||||
|
||||
class wxCocoaNSMenu
|
||||
{
|
||||
WX_DECLARE_OBJC_INTERFACE(NSMenu)
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
inline wxCocoaNSMenu()
|
||||
{
|
||||
m_cocoaNSMenu = NULL;
|
||||
}
|
||||
~wxCocoaNSMenu();
|
||||
// ------------------------------------------------------------------------
|
||||
// Cocoa specifics
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
bool CocoaCreate(const wxString &title);
|
||||
inline WX_NSMenu GetNSMenu() { return m_cocoaNSMenu; }
|
||||
protected:
|
||||
WX_NSMenu m_cocoaNSMenu;
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_NSMENU_H_
|
26
include/wx/cocoa/NSTextField.h
Normal file
26
include/wx/cocoa/NSTextField.h
Normal file
@@ -0,0 +1,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/NSTextField.h
|
||||
// Purpose: wxCocoaNSTextField class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/09
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_NSTEXTFIELD_H__
|
||||
#define __WX_COCOA_NSTEXTFIELD_H__
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
WX_DECLARE_OBJC_HASHMAP(NSTextField);
|
||||
class wxCocoaNSTextField
|
||||
{
|
||||
WX_DECLARE_OBJC_INTERFACE(NSTextField)
|
||||
protected:
|
||||
virtual void Cocoa_didChangeText(void) = 0;
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_NSTEXTFIELD_H_
|
32
include/wx/cocoa/NSView.h
Normal file
32
include/wx/cocoa/NSView.h
Normal file
@@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/NSView.h
|
||||
// Purpose: wxCocoaNSView class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_NSVIEW_H__
|
||||
#define __WX_COCOA_NSVIEW_H__
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
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 void *sm_cocoaObserver;
|
||||
public:
|
||||
virtual void Cocoa_FrameChanged(void) = 0;
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_NSVIEW_H_
|
35
include/wx/cocoa/NSWindow.h
Normal file
35
include/wx/cocoa/NSWindow.h
Normal file
@@ -0,0 +1,35 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/NSWindow.h
|
||||
// Purpose: wxCocoaNSWindow class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_NSWINDOW_H__
|
||||
#define __WX_COCOA_NSWINDOW_H__
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
WX_DECLARE_OBJC_HASHMAP(NSWindow);
|
||||
|
||||
class wxCocoaNSWindow
|
||||
{
|
||||
/* NSWindow is a rather special case and requires some extra attention */
|
||||
WX_DECLARE_OBJC_INTERFACE_HASHMAP(NSWindow)
|
||||
public:
|
||||
void AssociateNSWindow(WX_NSWindow cocoaNSWindow);
|
||||
inline void DisassociateNSWindow(WX_NSWindow cocoaNSWindow)
|
||||
{
|
||||
sm_cocoaHash.erase(cocoaNSWindow);
|
||||
}
|
||||
virtual void Cocoa_close(void) = 0;
|
||||
virtual bool Cocoa_windowShouldClose(void) = 0;
|
||||
virtual void Cocoa_wxMenuItemAction(wxMenuItem& item) = 0;
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_NSWINDOW_H_
|
123
include/wx/cocoa/ObjcPose.h
Normal file
123
include/wx/cocoa/ObjcPose.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/ObjcPose.h
|
||||
// Purpose: Macros for initializing poseAs, among other things
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/03
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott <dfe@cox.net>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_PRIVATE_POSER_H__
|
||||
#define __WX_COCOA_PRIVATE_POSER_H__
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
Objective-C Poser class initialization
|
||||
-------------------------------------------------------------------------*/
|
||||
#ifdef __OBJC__
|
||||
#import <objc/objc-class.h>
|
||||
|
||||
class wxPoseAsInitializer
|
||||
{
|
||||
public:
|
||||
wxPoseAsInitializer(Class poser)
|
||||
: m_poser(poser)
|
||||
, m_next(sm_first)
|
||||
{
|
||||
sm_first = this;
|
||||
}
|
||||
~wxPoseAsInitializer()
|
||||
{
|
||||
class_poseAs(m_poser,m_poser->super_class);
|
||||
sm_first = m_next;
|
||||
}
|
||||
static void InitializePosers()
|
||||
{
|
||||
while(sm_first)
|
||||
{
|
||||
delete sm_first;
|
||||
}
|
||||
};
|
||||
protected:
|
||||
Class m_poser;
|
||||
wxPoseAsInitializer *m_next;
|
||||
static wxPoseAsInitializer *sm_first;
|
||||
};
|
||||
|
||||
class wxDummyForPoseAsInitializer
|
||||
{
|
||||
public:
|
||||
wxDummyForPoseAsInitializer(void*) {}
|
||||
};
|
||||
|
||||
#define WX_IMPLEMENT_POSER(poser) \
|
||||
wxDummyForPoseAsInitializer wxDummyPoseAsInitializerFor##poser(new wxPoseAsInitializer([poser class]))
|
||||
|
||||
#endif // __OBJC__
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
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) \
|
||||
{ \
|
||||
sm_cocoaHash.insert(wxCocoa##ObjcClass##Hash::value_type(cocoaObjcClass,this)); \
|
||||
} \
|
||||
inline void Disassociate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
|
||||
{ \
|
||||
sm_cocoaHash.erase(cocoaObjcClass); \
|
||||
}
|
||||
|
||||
#define WX_IMPLEMENT_OBJC_INTERFACE(ObjcClass) \
|
||||
WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(ObjcClass)
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
Stuff to be used by the wxWindows 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) \
|
||||
{ \
|
||||
if(m_cocoa##ObjcRoot) \
|
||||
Disassociate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
|
||||
Set##ObjcBase(cocoaObjcClass); \
|
||||
if(m_cocoa##ObjcRoot) \
|
||||
Associate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
|
||||
}
|
||||
|
||||
#endif // __WX_COCOA_PRIVATE_POSER_H__
|
||||
|
73
include/wx/cocoa/app.h
Normal file
73
include/wx/cocoa/app.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/app.h
|
||||
// Purpose: wxApp class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/11/27
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_COCOA_APP_H_
|
||||
#define _WX_COCOA_APP_H_
|
||||
|
||||
// entrypoint
|
||||
int WXDLLEXPORT wxEntry( int argc, char *argv[] );
|
||||
|
||||
// Represents the application. Derive OnInit and declare
|
||||
// a new App object to start application
|
||||
class WXDLLEXPORT wxApp: public wxAppBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxApp)
|
||||
DECLARE_EVENT_TABLE()
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
wxApp();
|
||||
virtual ~wxApp() {}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Cocoa specifics
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
inline WX_NSApplication GetNSApplication() { return m_cocoaApp; }
|
||||
void CocoaInstallRequestedIdleHandler() { if(m_isIdle) CocoaInstallIdleHandler(); }
|
||||
inline void CocoaRequestIdle() { m_isIdle = true; }
|
||||
protected:
|
||||
WX_NSApplication m_cocoaApp;
|
||||
void CocoaInstallIdleHandler();
|
||||
bool m_isIdle;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
// Implement wxAppBase pure virtuals
|
||||
virtual int MainLoop();
|
||||
virtual void ExitMainLoop();
|
||||
virtual bool Initialized();
|
||||
virtual bool Pending();
|
||||
virtual void Dispatch();
|
||||
virtual bool Yield(bool onlyIfNeeded = FALSE);
|
||||
virtual bool ProcessIdle();
|
||||
|
||||
/* Idle Processing */
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
// Send idle event to all top-level windows.
|
||||
// Returns TRUE if more idle time is requested.
|
||||
bool SendIdleEvents();
|
||||
// Send idle event to window and all subwindows
|
||||
// Returns TRUE if more idle time is requested.
|
||||
bool SendIdleEvents(wxWindowCocoa* win);
|
||||
|
||||
static bool Initialize();
|
||||
static void CleanUp();
|
||||
|
||||
virtual bool OnInit();
|
||||
virtual bool OnInitGui();
|
||||
void DeletePendingObjects();
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_APP_H_
|
59
include/wx/cocoa/button.h
Normal file
59
include/wx/cocoa/button.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/button.h
|
||||
// Purpose: wxButton class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/29
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_BUTTON_H__
|
||||
#define __WX_COCOA_BUTTON_H__
|
||||
|
||||
#include "wx/cocoa/NSButton.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxButton
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT 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,
|
||||
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,
|
||||
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:
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_BUTTON_H__
|
63
include/wx/cocoa/checklst.h
Normal file
63
include/wx/cocoa/checklst.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/checklst.h
|
||||
// Purpose: wxCheckListBox class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_CHECKLST_H__
|
||||
#define __WX_COCOA_CHECKLST_H__
|
||||
|
||||
//#include "wx/cocoa/NSTableView.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxCheckListBox
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT 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);
|
||||
}
|
||||
|
||||
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);
|
||||
virtual ~wxCheckListBox();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Cocoa callbacks
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
// check list box specific methods
|
||||
virtual bool IsChecked(size_t item) const;
|
||||
virtual void Check(size_t item, bool check = TRUE);
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_CHECKLST_H__
|
93
include/wx/cocoa/control.h
Normal file
93
include/wx/cocoa/control.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/control.h
|
||||
// Purpose: wxControl class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_CONTROL_H__
|
||||
#define __WX_COCOA_CONTROL_H__
|
||||
|
||||
#include "wx/cocoa/NSControl.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxControl
|
||||
// ========================================================================
|
||||
|
||||
class WXDLLEXPORT 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);
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
|
||||
wxColour* GetButtonColour() const { return NULL; }
|
||||
|
||||
inline virtual void SetLabelFont(const wxFont& font);
|
||||
inline virtual void SetButtonFont(const wxFont& font);
|
||||
inline wxFont& GetLabelFont() const;
|
||||
inline wxFont& GetButtonFont() const;
|
||||
|
||||
// Adds callback
|
||||
inline void Callback(const wxFunction function);
|
||||
|
||||
wxFunction GetCallback() { return m_callback; }
|
||||
|
||||
protected:
|
||||
wxFunction m_callback; // Callback associated with the window
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
inline void wxControl::Callback(const wxFunction f) { m_callback = f; };
|
||||
inline wxFont& wxControl::GetLabelFont() const { return GetFont(); }
|
||||
inline wxFont& wxControl::GetButtonFont() const { return GetFont(); }
|
||||
inline void wxControl::SetLabelFont(const wxFont& font) { SetFont(font); }
|
||||
inline void wxControl::SetButtonFont(const wxFont& font) { SetFont(font); }
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
#endif // __WX_COCOA_CONTROL_H__
|
28
include/wx/cocoa/dcmemory.h
Normal file
28
include/wx/cocoa/dcmemory.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/dcmemory.h
|
||||
// Purpose: wxMemoryDC class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_DCMEMORY_H__
|
||||
#define __WX_COCOA_DCMEMORY_H__
|
||||
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
class WXDLLEXPORT wxMemoryDC: public wxDC
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
|
||||
public:
|
||||
wxMemoryDC(void);
|
||||
wxMemoryDC( wxDC *dc ); // Create compatible DC
|
||||
~wxMemoryDC(void);
|
||||
virtual void SelectObject(const wxBitmap& bitmap);
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_DCMEMORY_H__
|
26
include/wx/cocoa/dcscreen.h
Normal file
26
include/wx/cocoa/dcscreen.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/dcscreen.h
|
||||
// Purpose: wxScreenDC class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_DCSCREEN_H__
|
||||
#define __WX_COCOA_DCSCREEN_H__
|
||||
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
class WXDLLEXPORT wxScreenDC: public wxDC
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxScreenDC)
|
||||
public:
|
||||
wxScreenDC(void);
|
||||
wxScreenDC( wxDC *dc ); // Create compatible DC
|
||||
~wxScreenDC(void);
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_DCSCREEN_H__
|
104
include/wx/cocoa/dialog.h
Normal file
104
include/wx/cocoa/dialog.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/dialog.h
|
||||
// Purpose: wxDialog class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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"
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
|
||||
|
||||
// ========================================================================
|
||||
// wxDialog
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT wxDialog : public wxDialogBase, protected wxCocoaNSPanel
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDialog)
|
||||
DECLARE_EVENT_TABLE()
|
||||
WX_DECLARE_COCOA_OWNER(NSPanel,NSWindow,NSWindow)
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
wxDialog() { Init(); }
|
||||
|
||||
// Constructor with a modal flag, but no window id - the old convention
|
||||
wxDialog(wxWindow *parent,
|
||||
const wxString& title, bool modal,
|
||||
int x = -1, int y= -1, int width = 500, int height = 500,
|
||||
long style = wxDEFAULT_DIALOG_STYLE,
|
||||
const wxString& name = wxDialogNameStr)
|
||||
{
|
||||
Init();
|
||||
long modalStyle = modal ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
|
||||
Create(parent, -1, title, wxPoint(x, y), wxSize(width, height),
|
||||
style | modalStyle, name);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
~wxDialog();
|
||||
protected:
|
||||
void Init();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Cocoa specifics
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
virtual void Cocoa_close(void);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
bool Show(bool show);
|
||||
|
||||
void SetModal(bool flag);
|
||||
virtual bool IsModal() const;
|
||||
|
||||
// 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);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Event handlers
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
// Standard buttons
|
||||
void OnOK(wxCommandEvent& event);
|
||||
void OnApply(wxCommandEvent& event);
|
||||
void OnCancel(wxCommandEvent& event);
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_DIALOG_H_
|
73
include/wx/cocoa/frame.h
Normal file
73
include/wx/cocoa/frame.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/frame.h
|
||||
// Purpose: wxFrame class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_COCOA_FRAME_H_
|
||||
#define _WX_COCOA_FRAME_H_
|
||||
|
||||
class WXDLLEXPORT wxMenuBar;
|
||||
class WXDLLEXPORT wxMenuItem;
|
||||
|
||||
class WXDLLEXPORT 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
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
virtual void Cocoa_wxMenuItemAction(wxMenuItem& item);
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
void AttachMenuBar(wxMenuBar *mbar);
|
||||
void DetachMenuBar();
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// override some more virtuals
|
||||
virtual bool Show( bool show = true );
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
#endif // _WX_COCOA_FRAME_H_
|
88
include/wx/cocoa/listbox.h
Normal file
88
include/wx/cocoa/listbox.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/listbox.h
|
||||
// Purpose: wxListBox class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_LISTBOX_H__
|
||||
#define __WX_COCOA_LISTBOX_H__
|
||||
|
||||
//#include "wx/cocoa/NSTableView.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxListBox
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT wxListBox: public wxListBoxBase //, protected wxCocoaNSTableView
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxListBox)
|
||||
DECLARE_EVENT_TABLE()
|
||||
WX_DECLARE_COCOA_OWNER(NSTableView,NSControl,NSView)
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
wxListBox() { }
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
virtual ~wxListBox();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Cocoa callbacks
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
// pure virtuals from wxListBoxBase
|
||||
virtual bool IsSelected(int n) const;
|
||||
virtual void SetSelection(int n, bool select = TRUE);
|
||||
virtual int GetSelections(wxArrayInt& aSelections) const;
|
||||
protected:
|
||||
virtual void DoInsertItems(const wxArrayString& items, int pos);
|
||||
virtual void DoSetItems(const wxArrayString& items, void **clientData);
|
||||
virtual void DoSetFirstItem(int n);
|
||||
|
||||
// pure virtuals from wxItemContainer
|
||||
public:
|
||||
// deleting items
|
||||
virtual void Clear();
|
||||
virtual void Delete(int n);
|
||||
// accessing strings
|
||||
virtual int GetCount() const;
|
||||
virtual wxString GetString(int n) const;
|
||||
virtual void SetString(int n, const wxString& s);
|
||||
virtual int FindString(const wxString& s) const;
|
||||
// selection
|
||||
virtual void Select(int n);
|
||||
virtual int GetSelection() const;
|
||||
protected:
|
||||
virtual int DoAppend(const wxString& item);
|
||||
virtual void DoSetItemClientData(int n, void* clientData);
|
||||
virtual void* DoGetItemClientData(int n) const;
|
||||
virtual void DoSetItemClientObject(int n, wxClientData* clientData);
|
||||
virtual wxClientData* DoGetItemClientObject(int n) const;
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_LISTBOX_H__
|
161
include/wx/cocoa/menu.h
Normal file
161
include/wx/cocoa/menu.h
Normal file
@@ -0,0 +1,161 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/menu.h
|
||||
// Purpose: wxMenu and wxMenuBar classes
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/09
|
||||
// RCS-ID: $Id:
|
||||
// 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 WXDLLEXPORT wxMenu : public wxMenuBase, public wxCocoaNSMenu
|
||||
{
|
||||
public:
|
||||
// ctors and dtor
|
||||
wxMenu(const wxString& title, long style = 0)
|
||||
: wxMenuBase(title, style) { Create(title,style); }
|
||||
bool Create(const wxString& title, long style = 0);
|
||||
|
||||
wxMenu(long style = 0) : wxMenuBase(style) { Create(wxEmptyString, style); }
|
||||
|
||||
virtual ~wxMenu();
|
||||
|
||||
protected:
|
||||
// implement base class virtuals
|
||||
virtual bool DoAppend(wxMenuItem *item);
|
||||
virtual bool 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 WXDLLEXPORT wxMenuBar : public wxMenuBarBase, public wxCocoaNSMenu
|
||||
{
|
||||
public:
|
||||
// ctors and dtor
|
||||
wxMenuBar(long style = 0) { Create(style); }
|
||||
bool Create(long style = 0);
|
||||
virtual ~wxMenuBar();
|
||||
|
||||
wxMenuItemList m_items; // the list of menu items
|
||||
|
||||
// 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 SetLabelTop(size_t pos, const wxString& label);
|
||||
virtual wxString GetLabelTop(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_
|
94
include/wx/cocoa/menuitem.h
Normal file
94
include/wx/cocoa/menuitem.h
Normal file
@@ -0,0 +1,94 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/menuitem.h
|
||||
// Purpose: wxMenuItem class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/13
|
||||
// RCS-ID: $Id:
|
||||
// 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"
|
||||
|
||||
// ========================================================================
|
||||
// wxMenuItem
|
||||
// ========================================================================
|
||||
|
||||
#define wxMenuItemCocoa wxMenuItem
|
||||
class wxMenuItemCocoa;
|
||||
WX_DECLARE_HASH_MAP(WX_NSMenuItem,wxMenuItem*,wxPointerHash,wxPointerEqual,wxMenuItemCocoaHash);
|
||||
|
||||
class WXDLLEXPORT wxMenuItemCocoa : public wxMenuItemBase
|
||||
{
|
||||
public:
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
// ------------------------------------------------------------------------
|
||||
wxMenuItemCocoa(wxMenu *parentMenu = (wxMenu *)NULL,
|
||||
int id = wxID_SEPARATOR,
|
||||
const wxString& name = wxEmptyString,
|
||||
const wxString& help = wxEmptyString,
|
||||
wxItemKind kind = wxITEM_NORMAL,
|
||||
wxMenu *subMenu = (wxMenu *)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;
|
||||
}
|
||||
protected:
|
||||
WX_NSMenuItem m_cocoaNSMenuItem;
|
||||
static wxMenuItemCocoaHash sm_cocoaHash;
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
// override base class virtuals to update the item appearance on screen
|
||||
virtual void SetText(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_
|
||||
|
58
include/wx/cocoa/stattext.h
Normal file
58
include/wx/cocoa/stattext.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/stattext.h
|
||||
// Purpose: wxStaticText class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_STATTEXT_H__
|
||||
#define __WX_COCOA_STATTEXT_H__
|
||||
|
||||
#include "wx/cocoa/NSTextField.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxStaticText
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT 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:
|
||||
void SetLabel(const wxString& label);
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_STATTEXT_H__
|
118
include/wx/cocoa/textctrl.h
Normal file
118
include/wx/cocoa/textctrl.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/textctrl.h
|
||||
// Purpose: wxTextCtrl class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_TEXTCTRL_H__
|
||||
#define __WX_COCOA_TEXTCTRL_H__
|
||||
|
||||
#include "wx/cocoa/NSTextField.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxTextCtrl
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT 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);
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
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 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 long GetLastPosition() const;
|
||||
|
||||
virtual void SetSelection(long from, long to);
|
||||
// virtual void SelectAll();
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_TEXTCTRL_H__
|
111
include/wx/cocoa/toplevel.h
Normal file
111
include/wx/cocoa/toplevel.h
Normal file
@@ -0,0 +1,111 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_TOPLEVEL_H__
|
||||
#define __WX_COCOA_TOPLEVEL_H__
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/cocoa/NSWindow.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxTopLevelWindowCocoa
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT wxTopLevelWindowCocoa : public wxTopLevelWindowBase, protected wxCocoaNSWindow
|
||||
{
|
||||
DECLARE_CLASS(wxTopLevelWindowCocoa);
|
||||
DECLARE_EVENT_TABLE();
|
||||
// ------------------------------------------------------------------------
|
||||
// initialization
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
inline wxTopLevelWindowCocoa() { 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)
|
||||
{
|
||||
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 Cocoa_close(void);
|
||||
virtual bool Cocoa_windowShouldClose(void);
|
||||
virtual void Cocoa_wxMenuItemAction(wxMenuItem& item);
|
||||
protected:
|
||||
void SetNSWindow(WX_NSWindow cocoaNSWindow);
|
||||
WX_NSWindow m_cocoaNSWindow;
|
||||
static wxCocoaNSWindowHash sm_cocoaHash;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Implementation
|
||||
// ------------------------------------------------------------------------
|
||||
public:
|
||||
// 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 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;
|
||||
|
||||
|
||||
// Things I may/may not do
|
||||
// virtual void SetIcon(const wxIcon& icon);
|
||||
// virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); }
|
||||
// virtual void Clear() ;
|
||||
// virtual void Raise();
|
||||
// virtual void Lower();
|
||||
// virtual void SetTitle( const wxString& title);
|
||||
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 WXDLLEXPORT_DATA(wxWindowList) wxModelessWindows;
|
||||
|
||||
#endif // __WX_COCOA_TOPLEVEL_H__
|
125
include/wx/cocoa/window.h
Normal file
125
include/wx/cocoa/window.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/cocoa/window.h
|
||||
// Purpose: wxWindowCocoa
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/26
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __WX_COCOA_WINDOW_H__
|
||||
#define __WX_COCOA_WINDOW_H__
|
||||
|
||||
#include "wx/cocoa/NSView.h"
|
||||
|
||||
// ========================================================================
|
||||
// wxWindowCocoa
|
||||
// ========================================================================
|
||||
class WXDLLEXPORT wxWindowCocoa: public wxWindowBase, protected wxCocoaNSView
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxWindowCocoa)
|
||||
DECLARE_NO_COPY_CLASS(wxWindowCocoa)
|
||||
DECLARE_EVENT_TABLE()
|
||||
// ------------------------------------------------------------------------
|
||||
// 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:
|
||||
inline WX_NSView GetNSView() { return m_cocoaNSView; }
|
||||
void CocoaAddChild(wxWindowCocoa *child);
|
||||
void CocoaRemoveFromParent(void);
|
||||
virtual void Cocoa_FrameChanged(void);
|
||||
protected:
|
||||
void SetNSView(WX_NSView cocoaNSView);
|
||||
WX_NSView m_cocoaNSView;
|
||||
WX_NSView m_dummyNSView;
|
||||
// ------------------------------------------------------------------------
|
||||
// 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) ;
|
||||
// Send the window a refresh event
|
||||
virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
|
||||
// Clear the window
|
||||
virtual void Clear();
|
||||
// Set/get the window's font
|
||||
virtual bool SetFont(const wxFont& f);
|
||||
// inline virtual wxFont& GetFont() const;
|
||||
// Get character size
|
||||
virtual int GetCharHeight() const;
|
||||
virtual int GetCharWidth() const;
|
||||
virtual void GetTextExtent(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);
|
||||
// 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 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 );
|
||||
};
|
||||
|
||||
#endif // __WX_COCOA_WINDOW_H__
|
62
src/cocoa/NSButton.mm
Normal file
62
src/cocoa/NSButton.mm
Normal file
@@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSButton.cpp
|
||||
// Purpose: wxCocoaNSButton
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/01/31
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/log.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cocoa/NSButton.h"
|
||||
#import <AppKit/NSButton.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSButton)
|
||||
|
||||
// ============================================================================
|
||||
// @class wxPoserNSButton
|
||||
// ============================================================================
|
||||
@interface wxPoserNSButton : NSButton
|
||||
{
|
||||
}
|
||||
|
||||
- (void)wxNSButtonAction: (id)sender;
|
||||
@end // wxPoserNSButton
|
||||
|
||||
WX_IMPLEMENT_POSER(wxPoserNSButton);
|
||||
|
||||
@implementation wxPoserNSButton : NSButton
|
||||
- (void)wxNSButtonAction: (id)sender
|
||||
{
|
||||
wxASSERT_MSG(self==sender,"Received wxNSButtonAction from another object");
|
||||
wxCocoaNSButton *button = wxCocoaNSButton::GetFromCocoa(self);
|
||||
wxCHECK_RET(button,"wxNSButtonAction received without associated wx object");
|
||||
button->Cocoa_wxNSButtonAction();
|
||||
}
|
||||
|
||||
@end // implementation wxPoserNSButton
|
||||
|
||||
void wxCocoaNSButton::AssociateNSButton(WX_NSButton cocoaNSButton)
|
||||
{
|
||||
sm_cocoaHash.insert(wxCocoaNSButtonHash::value_type(cocoaNSButton,this));
|
||||
[cocoaNSButton setTarget: cocoaNSButton];
|
||||
[cocoaNSButton setAction: @selector(wxNSButtonAction:)];
|
||||
}
|
||||
|
30
src/cocoa/NSControl.mm
Normal file
30
src/cocoa/NSControl.mm
Normal file
@@ -0,0 +1,30 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSControl.cpp
|
||||
// Purpose: wxCocoaNSControl
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cocoa/NSControl.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
WX_IMPLEMENT_OBJC_INTERFACE(NSControl)
|
||||
|
66
src/cocoa/NSMenu.mm
Normal file
66
src/cocoa/NSMenu.mm
Normal file
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSMenu.mm
|
||||
// Purpose: wxCocoaNSMenu implementation
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/09
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/log.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cocoa/NSMenu.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <AppKit/NSMenu.h>
|
||||
|
||||
#if wxUSE_MENUS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ============================================================================
|
||||
// @class wxPoserNSMenu
|
||||
// ============================================================================
|
||||
@interface wxPoserNSMenu : NSMenu
|
||||
{
|
||||
}
|
||||
|
||||
@end // wxPoserNSMenu
|
||||
|
||||
WX_IMPLEMENT_POSER(wxPoserNSMenu);
|
||||
@implementation wxPoserNSMenu : NSMenu
|
||||
|
||||
@end // wxPoserNSMenu
|
||||
|
||||
// ============================================================================
|
||||
// wxCocoaNSMenu implementation
|
||||
// ============================================================================
|
||||
bool wxCocoaNSMenu::CocoaCreate(const wxString &title)
|
||||
{
|
||||
wxLogDebug("CocoaCreate: "+title);
|
||||
m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: [NSString stringWithCString: title.c_str()]];
|
||||
return true;
|
||||
}
|
||||
|
||||
wxCocoaNSMenu::~wxCocoaNSMenu()
|
||||
{
|
||||
[m_cocoaNSMenu release];
|
||||
}
|
||||
|
||||
#endif // wxUSE_MENUS
|
27
src/cocoa/NSTextField.mm
Normal file
27
src/cocoa/NSTextField.mm
Normal file
@@ -0,0 +1,27 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSTextField.mm
|
||||
// Purpose: wxCocoaNSTextField
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/01/31
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cocoa/NSTextField.h"
|
||||
|
||||
WX_IMPLEMENT_OBJC_INTERFACE(NSTextField)
|
||||
|
86
src/cocoa/NSView.mm
Normal file
86
src/cocoa/NSView.mm
Normal file
@@ -0,0 +1,86 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSView.mm
|
||||
// Purpose: wxCocoaNSView
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/window.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cocoa/NSView.h"
|
||||
|
||||
#import <Appkit/NSView.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSView)
|
||||
|
||||
void wxCocoaNSView::AssociateNSView(WX_NSView cocoaNSView)
|
||||
{
|
||||
sm_cocoaHash.insert(wxCocoaNSViewHash::value_type(cocoaNSView,this));
|
||||
[[NSNotificationCenter defaultCenter] addObserver:(id)sm_cocoaObserver selector:@selector(notificationFrameChanged:) name:@"NSViewFrameDidChangeNotification" object:cocoaNSView];
|
||||
[cocoaNSView setPostsFrameChangedNotifications: YES];
|
||||
}
|
||||
|
||||
void wxCocoaNSView::DisassociateNSView(WX_NSView cocoaNSView)
|
||||
{
|
||||
sm_cocoaHash.erase(cocoaNSView);
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:(id)sm_cocoaObserver name:@"NSViewFrameDidChangeNotification" object:cocoaNSView];
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// @class wxPoserNSView
|
||||
// ============================================================================
|
||||
@interface wxPoserNSView : NSView
|
||||
{
|
||||
}
|
||||
|
||||
@end // wxPoserNSView
|
||||
|
||||
WX_IMPLEMENT_POSER(wxPoserNSView);
|
||||
@implementation wxPoserNSView : NSView
|
||||
|
||||
@end // implementation wxPoserNSView
|
||||
|
||||
@interface wxNSViewNotificationObserver : NSObject
|
||||
{
|
||||
}
|
||||
|
||||
// FIXME: Initializing like this is a really bad idea. If for some reason
|
||||
// we ever require posing as an NSObject we won't be able to since an instance
|
||||
// will have already been created here. Of course, catching messages for
|
||||
// NSObject seems like a LOT of overkill, so I doubt we ever will anyway!
|
||||
void *wxCocoaNSView::sm_cocoaObserver = [[wxNSViewNotificationObserver alloc] init];
|
||||
|
||||
- (void)notificationFrameChanged: (NSNotification *)notification;
|
||||
@end // interface wxNSViewNotificationObserver
|
||||
|
||||
@implementation wxNSViewNotificationObserver : NSObject
|
||||
|
||||
- (void)notificationFrameChanged: (NSNotification *)notification;
|
||||
{
|
||||
wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa([notification object]);
|
||||
wxCHECK_RET(win,"notificationFrameChanged received but no wxWindow exists");
|
||||
win->Cocoa_FrameChanged();
|
||||
}
|
||||
|
||||
@end // implementation wxNSViewNotificationObserver
|
||||
|
91
src/cocoa/NSWindow.mm
Normal file
91
src/cocoa/NSWindow.mm
Normal file
@@ -0,0 +1,91 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/NSWindow.mm
|
||||
// Purpose: wxCocoaNSWindow
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/log.h"
|
||||
#include "wx/menuitem.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/cocoa/NSWindow.h"
|
||||
|
||||
#import <Appkit/NSWindow.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSWindow)
|
||||
|
||||
void wxCocoaNSWindow::AssociateNSWindow(WX_NSWindow cocoaNSWindow)
|
||||
{
|
||||
[cocoaNSWindow setReleasedWhenClosed: NO];
|
||||
sm_cocoaHash.insert(wxCocoaNSWindowHash::value_type(cocoaNSWindow,this));
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// @class wxPoserNSWindow
|
||||
// ============================================================================
|
||||
@interface wxPoserNSWindow : NSWindow
|
||||
{
|
||||
}
|
||||
|
||||
- (void)close;
|
||||
- (BOOL)windowShouldClose: (id)sender;
|
||||
|
||||
- (BOOL)wxMenuItemAction: (id)sender;
|
||||
@end // wxPoserNSwindow
|
||||
|
||||
WX_IMPLEMENT_POSER(wxPoserNSWindow);
|
||||
@implementation wxPoserNSWindow : NSWindow
|
||||
|
||||
- (void)close
|
||||
{
|
||||
wxLogDebug("close");
|
||||
wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
|
||||
if(tlw)
|
||||
tlw->Cocoa_close();
|
||||
[super close];
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose: (id)sender
|
||||
{
|
||||
wxLogDebug("windowShouldClose");
|
||||
wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(sender);
|
||||
if(tlw && !tlw->Cocoa_windowShouldClose())
|
||||
return NO;
|
||||
wxLogDebug("Window will most likely be CLOSED");
|
||||
if([[wxPoserNSWindow superclass] instancesRespondToSelector:@selector(windowShouldClose:)])
|
||||
return [super windowShouldClose: sender];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)wxMenuItemAction: (id)sender
|
||||
{
|
||||
wxLogDebug("wxMenuItemAction");
|
||||
wxMenuItem *item = wxMenuItem::GetFromCocoa(sender);
|
||||
if(!item)
|
||||
return NO;
|
||||
|
||||
wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
|
||||
wxASSERT(tlw);
|
||||
tlw->Cocoa_wxMenuItemAction(*item);
|
||||
return YES;
|
||||
}
|
||||
@end // implementation wxPoserNSWindow
|
||||
|
546
src/cocoa/app.mm
Normal file
546
src/cocoa/app.mm
Normal file
@@ -0,0 +1,546 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/app.mm
|
||||
// Purpose: wxApp
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/11/27
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
# include "wx/resource.h"
|
||||
#endif
|
||||
|
||||
#import <AppKit/NSApplication.h>
|
||||
#import <Foundation/NSRunLoop.h>
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxApp *wxTheApp = NULL;
|
||||
wxPoseAsInitializer *wxPoseAsInitializer::sm_first = NULL;
|
||||
|
||||
@interface wxPoserNSApplication : NSApplication
|
||||
{
|
||||
}
|
||||
|
||||
- (void)doIdle: (id)data;
|
||||
- (void)finishLaunching;
|
||||
- (void)sendEvent: (NSEvent*)anEvent;
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication;
|
||||
@end // wxPoserNSApplication
|
||||
|
||||
@implementation wxPoserNSApplication : NSApplication
|
||||
|
||||
- (void)doIdle: (id)data
|
||||
{
|
||||
wxASSERT(wxTheApp);
|
||||
wxLogDebug("doIdle called");
|
||||
NSRunLoop *rl = [NSRunLoop currentRunLoop];
|
||||
// runMode: beforeDate returns YES if something was done
|
||||
while(wxTheApp->ProcessIdle()) // FIXME: AND NO EVENTS ARE PENDING
|
||||
{
|
||||
wxLogDebug("Looping for idle events");
|
||||
#if 1
|
||||
if( [rl runMode:[rl currentMode] beforeDate:[NSDate distantPast]])
|
||||
{
|
||||
wxLogDebug("Found actual work to do");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
wxLogDebug("Idle processing complete, requesting next idle event");
|
||||
// Add ourself back into the run loop (on next event) if necessary
|
||||
wxTheApp->CocoaRequestIdle();
|
||||
}
|
||||
|
||||
- (void)finishLaunching
|
||||
{
|
||||
wxLogDebug("finishLaunching");
|
||||
bool initsuccess = wxTheApp->OnInit();
|
||||
if(!initsuccess)
|
||||
[super stop: NULL];
|
||||
|
||||
[super finishLaunching];
|
||||
}
|
||||
|
||||
- (void)sendEvent: (NSEvent*)anEvent
|
||||
{
|
||||
wxLogDebug("SendEvent");
|
||||
wxTheApp->CocoaInstallRequestedIdleHandler();
|
||||
[super sendEvent: anEvent];
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
|
||||
{
|
||||
BOOL ret = wxTheApp->GetExitOnFrameDelete();
|
||||
wxLogDebug("applicationShouldTermintaeAfterLastWindowClosed=%d",ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@end // wxPoserNSApplication
|
||||
WX_IMPLEMENT_POSER(wxPoserNSApplication);
|
||||
|
||||
// ============================================================================
|
||||
// functions
|
||||
// ============================================================================
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// wxEntry
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
int WXDLLEXPORT wxEntryStart( int WXUNUSED(argc), char *WXUNUSED(argv)[] )
|
||||
{
|
||||
return wxApp::Initialize();
|
||||
}
|
||||
|
||||
int WXDLLEXPORT wxEntryInitGui()
|
||||
{
|
||||
return wxTheApp->OnInitGui();
|
||||
}
|
||||
|
||||
void WXDLLEXPORT wxEntryCleanup()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
}
|
||||
|
||||
int wxEntry( int argc, char *argv[])
|
||||
{
|
||||
if (!wxEntryStart(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
wxLogDebug("Creating application");
|
||||
// create the application object or ensure that one already exists
|
||||
if (!wxTheApp)
|
||||
{
|
||||
// The app may have declared a global application object, but we recommend
|
||||
// the IMPLEMENT_APP macro is used instead, which sets an initializer
|
||||
// function for delayed, dynamic app object construction.
|
||||
wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
|
||||
wxT("No initializer - use IMPLEMENT_APP macro.") );
|
||||
|
||||
wxTheApp = (wxApp*) (*wxApp::GetInitializerFunction()) ();
|
||||
}
|
||||
|
||||
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
|
||||
|
||||
// Mac OS X passes a process serial number command line argument when
|
||||
// the application is launched from the Finder. This argument must be
|
||||
// removed from the command line arguments before being handled by the
|
||||
// application (otherwise applications would need to handle it)
|
||||
|
||||
if (argc > 1) {
|
||||
char theArg[6] = "";
|
||||
strncpy(theArg, argv[1], 5);
|
||||
|
||||
if (strcmp(theArg, "-psn_") == 0) {
|
||||
// assume the argument is always the only one and remove it
|
||||
--argc;
|
||||
}
|
||||
}
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
wxTheApp->argv = argv;
|
||||
|
||||
wxLogDebug("initializing gui");
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
wxEntryInitGui();
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
int retValue = 0;
|
||||
|
||||
wxLogDebug("Time to run");
|
||||
retValue = wxTheApp->OnRun();
|
||||
|
||||
wxWindow *topWindow = wxTheApp->GetTopWindow();
|
||||
if ( topWindow )
|
||||
{
|
||||
// Forcibly delete the window.
|
||||
if ( topWindow->IsKindOf(CLASSINFO(wxFrame)) ||
|
||||
topWindow->IsKindOf(CLASSINFO(wxDialog)) )
|
||||
{
|
||||
topWindow->Close(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete topWindow;
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
wxTheApp->OnExit();
|
||||
|
||||
wxEntryCleanup();
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// other functions
|
||||
// ----------------------------------------------------------------------------
|
||||
void wxWakeUpIdle()
|
||||
{
|
||||
wxTheApp->CocoaRequestIdle();
|
||||
}
|
||||
|
||||
void wxExit()
|
||||
{
|
||||
wxLogError(_("Fatal error: exiting"));
|
||||
|
||||
wxApp::CleanUp();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxApp implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxApp Static member initialization
|
||||
// ----------------------------------------------------------------------------
|
||||
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
// EVT_END_SESSION(wxApp::OnEndSession)
|
||||
// EVT_QUERY_END_SESSION(wxApp::OnQueryEndSession)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxApp static functions
|
||||
// ----------------------------------------------------------------------------
|
||||
/*static*/ bool wxApp::Initialize()
|
||||
{
|
||||
wxPoseAsInitializer::InitializePosers();
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
#if wxUSE_THREADS
|
||||
wxPendingEventsLocker = new wxCriticalSection;
|
||||
#endif
|
||||
|
||||
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
|
||||
wxTheColourDatabase->Initialize();
|
||||
|
||||
wxInitializeStockLists();
|
||||
wxInitializeStockObjects();
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
wxInitializeResourceSystem();
|
||||
#endif
|
||||
|
||||
wxBitmap::InitStandardHandlers();
|
||||
|
||||
wxModule::RegisterModules();
|
||||
if (!wxModule::InitializeModules()) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*static*/ void wxApp::CleanUp()
|
||||
{
|
||||
wxModule::CleanUpModules();
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
wxCleanUpResourceSystem();
|
||||
#endif
|
||||
|
||||
wxDeleteStockObjects() ;
|
||||
|
||||
// Destroy all GDI lists, etc.
|
||||
wxDeleteStockLists();
|
||||
|
||||
delete wxTheColourDatabase;
|
||||
wxTheColourDatabase = NULL;
|
||||
|
||||
wxBitmap::CleanUpHandlers();
|
||||
|
||||
delete wxPendingEvents;
|
||||
|
||||
#if wxUSE_THREADS
|
||||
delete wxPendingEventsLocker;
|
||||
// If we don't do the following, we get an apparent memory leak.
|
||||
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
|
||||
#endif
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
|
||||
delete wxTheApp;
|
||||
wxTheApp = NULL;
|
||||
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// At this point we want to check if there are any memory
|
||||
// blocks that aren't part of the wxDebugContext itself,
|
||||
// as a special case. Then when dumping we need to ignore
|
||||
// wxDebugContext, too.
|
||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||
{
|
||||
wxLogDebug(wxT("There were memory leaks."));
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
}
|
||||
// wxDebugContext::SetStream(NULL, NULL);
|
||||
#endif
|
||||
|
||||
#if wxUSE_LOG
|
||||
// do it as the very last thing because everything else can log messages
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
#endif // wxUSE_LOG
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxApp creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxApp::wxApp()
|
||||
{
|
||||
m_topWindow = NULL;
|
||||
wxTheApp = this;
|
||||
|
||||
m_isIdle = true;
|
||||
#if WXWIN_COMPATIBILITY_2_2
|
||||
m_wantDebugOutput = TRUE;
|
||||
#endif
|
||||
|
||||
argc = 0;
|
||||
argv = NULL;
|
||||
m_cocoaApp = NULL;
|
||||
}
|
||||
|
||||
void wxApp::CocoaInstallIdleHandler()
|
||||
{
|
||||
wxLogDebug("wxApp::CocoaInstallIdleHandler");
|
||||
m_isIdle = false;
|
||||
// Call doIdle for EVERYTHING dammit
|
||||
// We'd need Foundation/NSConnection.h for this next constant, do we need it?
|
||||
[[ NSRunLoop currentRunLoop ] performSelector:@selector(doIdle:) target:m_cocoaApp argument:NULL order:0 modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, /* NSConnectionReplyRunLoopMode,*/ NSModalPanelRunLoopMode, /**/NSEventTrackingRunLoopMode,/**/ nil] ];
|
||||
}
|
||||
|
||||
bool wxApp::OnInitGui()
|
||||
{
|
||||
if(!wxAppBase::OnInitGui())
|
||||
return FALSE;
|
||||
|
||||
// Create the app using the sharedApplication method
|
||||
m_cocoaApp = [NSApplication sharedApplication];
|
||||
// [ m_cocoaApp setDelegate:m_cocoaApp ];
|
||||
#if 0
|
||||
wxLogDebug("Just for kicks");
|
||||
[ m_cocoaApp performSelector:@selector(doIdle:) withObject:NULL ];
|
||||
wxLogDebug("okay.. done now");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxApp::OnInit()
|
||||
{
|
||||
if(!wxAppBase::OnInit())
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxApp::Initialized()
|
||||
{
|
||||
if (GetTopWindow())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int wxApp::MainLoop()
|
||||
{
|
||||
[m_cocoaApp run];
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns TRUE if more time is needed.
|
||||
bool wxApp::ProcessIdle()
|
||||
{
|
||||
wxIdleEvent event;
|
||||
event.SetEventObject(this);
|
||||
ProcessEvent(event);
|
||||
|
||||
return event.MoreRequested();
|
||||
}
|
||||
|
||||
void wxApp::ExitMainLoop()
|
||||
{
|
||||
wxLogDebug("wxApp::ExitMailLoop m_isIdle=%d, isRunning=%d",(int)m_isIdle,(int)[m_cocoaApp isRunning]);
|
||||
// CocoaInstallRequestedIdleHandler();
|
||||
// if(m_isIdle)
|
||||
// [[ NSRunLoop currentRunLoop ] performSelector:@selector(doIdle:) target:m_cocoaApp argument:NULL order:0 modes:[NSArray arrayWithObjects:NSDefaultRunLoopMode, /* NSConnectionReplyRunLoopMode, NSModalPanelRunLoopMode, NSEventTrackingRunLoopMode,*/ nil] ];
|
||||
// actually.. we WANT the idle event
|
||||
// or not
|
||||
#if 0
|
||||
if(!m_isIdle)
|
||||
[[ NSRunLoop currentRunLoop ] cancelPerformSelector:@selector(doIdle:) target:m_cocoaApp argument:NULL];
|
||||
#endif
|
||||
[m_cocoaApp terminate: m_cocoaApp];
|
||||
}
|
||||
|
||||
// Is a message/event pending?
|
||||
bool wxApp::Pending()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Dispatch a message.
|
||||
void wxApp::Dispatch()
|
||||
{
|
||||
}
|
||||
|
||||
void wxApp::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
wxLogDebug("wxApp::OnIdle");
|
||||
static bool s_inOnIdle = FALSE;
|
||||
|
||||
// Avoid recursion (via ProcessEvent default case)
|
||||
if ( s_inOnIdle )
|
||||
return;
|
||||
s_inOnIdle = TRUE;
|
||||
|
||||
|
||||
DeletePendingObjects();
|
||||
|
||||
// flush the logged messages if any
|
||||
wxLog *pLog = wxLog::GetActiveTarget();
|
||||
if ( pLog != NULL && pLog->HasPendingMessages() )
|
||||
pLog->Flush();
|
||||
|
||||
// Send OnIdle events to all windows
|
||||
bool needMore = SendIdleEvents();
|
||||
|
||||
if (needMore)
|
||||
event.RequestMore(TRUE);
|
||||
|
||||
s_inOnIdle = FALSE;
|
||||
}
|
||||
|
||||
// Send idle event to all top-level windows
|
||||
bool wxApp::SendIdleEvents()
|
||||
{
|
||||
bool needMore = FALSE;
|
||||
wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* win = node->GetData();
|
||||
if (SendIdleEvents(win))
|
||||
needMore = TRUE;
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
return needMore;
|
||||
}
|
||||
|
||||
// Send idle event to window and all subwindows
|
||||
bool wxApp::SendIdleEvents(wxWindow* win)
|
||||
{
|
||||
// wxLogDebug("SendIdleEvents win=%p",win);
|
||||
bool needMore = FALSE;
|
||||
|
||||
wxIdleEvent event;
|
||||
event.SetEventObject(win);
|
||||
win->ProcessEvent(event);
|
||||
|
||||
if (event.MoreRequested())
|
||||
needMore = TRUE;
|
||||
|
||||
wxWindowList::Node* node = win->GetChildren().GetFirst();
|
||||
while (node)
|
||||
{
|
||||
// wxLogDebug("child=%p",node->Data());
|
||||
wxWindow* win = node->GetData();
|
||||
if (SendIdleEvents(win))
|
||||
needMore = TRUE;
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
return needMore;
|
||||
}
|
||||
|
||||
// Yield to other processes
|
||||
|
||||
bool wxApp::Yield(bool onlyIfNeeded)
|
||||
{
|
||||
// MT-FIXME
|
||||
static bool s_inYield = false;
|
||||
|
||||
#if wxUSE_LOG
|
||||
// disable log flushing from here because a call to wxYield() shouldn't
|
||||
// normally result in message boxes popping up &c
|
||||
wxLog::Suspend();
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
if (s_inYield)
|
||||
{
|
||||
if ( !onlyIfNeeded )
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxYield called recursively" ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
s_inYield = true;
|
||||
|
||||
wxLogDebug("WARNING: SUPPOSED to have yielded!");
|
||||
// FIXME: Do something!
|
||||
|
||||
#if wxUSE_LOG
|
||||
// let the logs be flashed again
|
||||
wxLog::Resume();
|
||||
#endif // wxUSE_LOG
|
||||
|
||||
s_inYield = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxApp::DeletePendingObjects()
|
||||
{
|
||||
wxNode *node = wxPendingDelete.GetFirst();
|
||||
while (node)
|
||||
{
|
||||
wxObject *obj = (wxObject *)node->GetData();
|
||||
|
||||
delete obj;
|
||||
|
||||
if (wxPendingDelete.Find(obj))
|
||||
delete node;
|
||||
|
||||
node = wxPendingDelete.GetFirst();
|
||||
}
|
||||
}
|
||||
|
||||
// platform specifics
|
||||
|
66
src/cocoa/button.mm
Normal file
66
src/cocoa/button.mm
Normal file
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/button.mm
|
||||
// Purpose: wxButton
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/30
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#include "wx/button.h"
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#import <AppKit/NSButton.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
BEGIN_EVENT_TABLE(wxButton, wxButtonBase)
|
||||
END_EVENT_TABLE()
|
||||
WX_IMPLEMENT_COCOA_OWNER(wxButton,NSButton,NSControl,NSView)
|
||||
|
||||
bool wxButton::Create(wxWindow *parent, wxWindowID winid,
|
||||
const wxString& label, const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator, const wxString& name)
|
||||
{
|
||||
wxLogDebug("Creating control with id=%d",winid);
|
||||
if(!CreateControl(parent,winid,pos,size,style,validator,name))
|
||||
return false;
|
||||
wxLogDebug("Created control with id=%d",GetId());
|
||||
NSRect cocoaRect = NSMakeRect(10,10,20,20);
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSButton([[NSButton alloc] initWithFrame: cocoaRect]);
|
||||
// NOTE: YES we want to release this (to match the alloc).
|
||||
// DoAddChild(this) will retain us again since addSubView doesn't.
|
||||
[m_cocoaNSView release];
|
||||
|
||||
[GetNSButton() setBezelStyle:NSRoundedBezelStyle];
|
||||
[GetNSButton() setTitle:[NSString stringWithCString: label.c_str()]];
|
||||
[GetNSControl() sizeToFit];
|
||||
|
||||
if(m_parent)
|
||||
m_parent->CocoaAddChild(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxButton::~wxButton()
|
||||
{
|
||||
CocoaRemoveFromParent();
|
||||
SetNSButton(NULL);
|
||||
}
|
||||
|
||||
void wxButton::Cocoa_wxNSButtonAction(void)
|
||||
{
|
||||
wxLogDebug("YAY!");
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
|
||||
InitCommandEvent(event); // event.SetEventObject(this);
|
||||
Command(event);
|
||||
}
|
||||
|
81
src/cocoa/control.mm
Normal file
81
src/cocoa/control.mm
Normal file
@@ -0,0 +1,81 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/control.mm
|
||||
// Purpose: wxControl class
|
||||
// Author: David Elliiott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/defs.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#import <AppKit/NSControl.h>
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
|
||||
BEGIN_EVENT_TABLE(wxControl, wxControlBase)
|
||||
END_EVENT_TABLE()
|
||||
WX_IMPLEMENT_COCOA_OWNER(wxControl,NSControl,NSView,NSView)
|
||||
|
||||
bool wxControl::Create(wxWindow *parent, wxWindowID winid,
|
||||
const wxPoint& pos, const wxSize& size, long style,
|
||||
const wxValidator& validator, const wxString& name)
|
||||
{
|
||||
wxLogDebug("Creating control with id=%d",winid);
|
||||
if(!CreateControl(parent,winid,pos,size,style,validator,name))
|
||||
return false;
|
||||
wxLogDebug("Created control with id=%d",GetId());
|
||||
NSRect cocoaRect = NSMakeRect(10,10,20,20);
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSControl([[NSControl alloc] initWithFrame: cocoaRect]);
|
||||
// NOTE: YES we want to release this (to match the alloc).
|
||||
// DoAddChild(this) will retain us again since addSubView doesn't.
|
||||
[m_cocoaNSView release];
|
||||
|
||||
[GetNSControl() sizeToFit];
|
||||
|
||||
if(m_parent)
|
||||
m_parent->CocoaAddChild(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxControl::~wxControl()
|
||||
{
|
||||
CocoaRemoveFromParent();
|
||||
SetNSControl(NULL);
|
||||
}
|
||||
|
||||
wxSize wxControl::DoGetBestSize() const
|
||||
{
|
||||
wxASSERT(m_cocoaNSView);
|
||||
NSRect storedRect = [m_cocoaNSView frame];
|
||||
[GetNSControl() sizeToFit];
|
||||
NSRect cocoaRect = [m_cocoaNSView frame];
|
||||
wxSize size((int)cocoaRect.size.width+10,(int)cocoaRect.size.height);
|
||||
[m_cocoaNSView setFrame: storedRect];
|
||||
wxLogDebug("wxControl=%p::DoGetBestSize()==(%d,%d)",this,size.x,size.y);
|
||||
return size;
|
||||
}
|
||||
|
||||
bool wxControl::ProcessCommand(wxCommandEvent& event)
|
||||
{
|
||||
#if WXWIN_COMPATIBILITY
|
||||
if ( m_callback )
|
||||
{
|
||||
(void)(*m_callback)(*this, event);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
#endif // WXWIN_COMPATIBILITY
|
||||
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
204
src/cocoa/dialog.mm
Normal file
204
src/cocoa/dialog.mm
Normal file
@@ -0,0 +1,204 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/cocoa/dialog.mm
|
||||
// Purpose: wxDialog class
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#import <AppKit/NSPanel.h>
|
||||
#import <AppKit/NSApplication.h>
|
||||
|
||||
// Lists to keep track of windows, so we can disable/enable them
|
||||
// for modal dialogs
|
||||
static wxWindowList wxModalDialogs;
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
WX_IMPLEMENT_COCOA_OWNER(wxDialog,NSPanel,NSWindow,NSWindow)
|
||||
|
||||
void wxDialog::Init()
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
}
|
||||
|
||||
bool wxDialog::Create(wxWindow *parent, wxWindowID winid,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
|
||||
return false;
|
||||
|
||||
if (parent)
|
||||
parent->AddChild(this);
|
||||
|
||||
NSRect cocoaRect = NSMakeRect(300,300,200,200);
|
||||
|
||||
unsigned int cocoaStyle = 0;
|
||||
cocoaStyle |= NSTitledWindowMask;
|
||||
cocoaStyle |= NSClosableWindowMask;
|
||||
cocoaStyle |= NSMiniaturizableWindowMask;
|
||||
cocoaStyle |= NSResizableWindowMask;
|
||||
|
||||
m_cocoaNSWindow = NULL;
|
||||
SetNSPanel([[NSPanel alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]);
|
||||
// NOTE: SetNSWindow has retained the Cocoa object for this object.
|
||||
// Because we do not release on close, the following release matches the
|
||||
// above alloc and thus the retain count will be 1.
|
||||
[m_cocoaNSWindow release];
|
||||
wxLogDebug("wxDialog m_cocoaNSWindow retainCount=%d",[m_cocoaNSWindow retainCount]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
{
|
||||
wxLogDebug("Destroying");
|
||||
// setReleasedWhenClosed: NO
|
||||
[m_cocoaNSWindow close];
|
||||
SetNSPanel(NULL);
|
||||
}
|
||||
|
||||
void wxDialog::Cocoa_close(void)
|
||||
{
|
||||
m_closed = true;
|
||||
/* Actually, this isn't true anymore */
|
||||
wxLogDebug("Woah: Dialogs are not generally closed");
|
||||
}
|
||||
|
||||
void wxDialog::SetModal(bool flag)
|
||||
{
|
||||
if ( flag )
|
||||
{
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
m_windowStyle |= wxDIALOG_MODAL ;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_windowStyle &= ~wxDIALOG_MODAL ;
|
||||
wxModelessWindows.Append(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool wxDialog::Show(bool show)
|
||||
{
|
||||
if(show)
|
||||
InitDialog();
|
||||
if(IsModal())
|
||||
{
|
||||
if(show)
|
||||
{
|
||||
wxModalDialogs.Append(this);
|
||||
wxLogDebug("runModal");
|
||||
[wxTheApp->GetNSApplication() runModalForWindow:m_cocoaNSWindow];
|
||||
wxLogDebug("runModal END");
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogDebug("abortModal");
|
||||
[wxTheApp->GetNSApplication() abortModal];
|
||||
wxModalDialogs.DeleteObject(this);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Replacement for Show(TRUE) for modal dialogs - returns return code
|
||||
int wxDialog::ShowModal()
|
||||
{
|
||||
if(!IsModal())
|
||||
SetModal(true);
|
||||
Show(true);
|
||||
return GetReturnCode();
|
||||
}
|
||||
|
||||
// EndModal will work for any dialog
|
||||
void wxDialog::EndModal(int retCode)
|
||||
{
|
||||
SetReturnCode(retCode);
|
||||
Show(false);
|
||||
}
|
||||
|
||||
bool wxDialog::IsModal() const
|
||||
{
|
||||
return (GetWindowStyleFlag() & wxDIALOG_MODAL);
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
// We'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close().
|
||||
|
||||
// Note that if a cancel button and handler aren't present in the dialog,
|
||||
// nothing will happen when you close the dialog via the window manager, or
|
||||
// via Close().
|
||||
// We wouldn't want to destroy the dialog by default, since the dialog may have been
|
||||
// created on the stack.
|
||||
// However, this does mean that calling dialog->Close() won't delete the dialog
|
||||
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
|
||||
// sure to destroy the dialog.
|
||||
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
|
||||
// ALWAYS VETO THIS EVENT!!!!
|
||||
event.Veto();
|
||||
|
||||
static wxList closing;
|
||||
|
||||
if ( closing.Member(this) )
|
||||
{
|
||||
wxLogDebug("WARNING: Attempting to recursively call Close for dialog");
|
||||
return;
|
||||
}
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxLogDebug("Sending Cancel Event");
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
|
||||
|
||||
closing.DeleteObject(this);
|
||||
}
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& event)
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
wxLogDebug("Cancelled!");
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
|
85
src/cocoa/frame.mm
Normal file
85
src/cocoa/frame.mm
Normal file
@@ -0,0 +1,85 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/frame.mm
|
||||
// Purpose: wxFrame
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#import <AppKit/NSWindow.h>
|
||||
#import <AppKit/NSApplication.h>
|
||||
|
||||
// wxFrame
|
||||
|
||||
BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
||||
|
||||
void wxFrame::Init()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxFrame::Create(wxWindow *parent,
|
||||
wxWindowID winid,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
bool rt = wxTopLevelWindow::Create(parent,winid,title,pos,size,style,name);
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
wxFrame::~wxFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
|
||||
{
|
||||
Command(item.GetId());
|
||||
}
|
||||
|
||||
void wxFrame::AttachMenuBar(wxMenuBar *mbar)
|
||||
{
|
||||
wxFrameBase::AttachMenuBar(mbar);
|
||||
if(m_frameMenuBar)
|
||||
{
|
||||
wxLogDebug("Attached menu");
|
||||
[m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
|
||||
}
|
||||
}
|
||||
|
||||
void wxFrame::DetachMenuBar()
|
||||
{
|
||||
if(m_frameMenuBar)
|
||||
{
|
||||
[m_cocoaNSWindow setMenu:nil];
|
||||
}
|
||||
wxFrameBase::DetachMenuBar();
|
||||
}
|
||||
|
||||
bool wxFrame::Show(bool show)
|
||||
{
|
||||
bool ret = wxFrameBase::Show(show);
|
||||
if(show && GetMenuBar())
|
||||
[wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxPoint wxFrame::GetClientAreaOrigin() const
|
||||
{
|
||||
return wxPoint(0,0);
|
||||
}
|
||||
|
19
src/cocoa/main.cpp
Normal file
19
src/cocoa/main.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/main.cpp
|
||||
// Purpose: Entry point
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/11/11
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/* DFE: ^^^^^ Was that really necessary :-) */
|
||||
|
||||
#include "wx/app.h"
|
||||
|
||||
WXDLLEXPORT int main(int argc, char* argv[])
|
||||
{
|
||||
return wxEntry(argc, argv);
|
||||
}
|
||||
|
174
src/cocoa/menu.mm
Normal file
174
src/cocoa/menu.mm
Normal file
@@ -0,0 +1,174 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/menu.cpp
|
||||
// Purpose: wxMenu and wxMenuBar implementation
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/09
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/menu.h"
|
||||
#include "wx/log.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <AppKit/NSMenu.h>
|
||||
|
||||
#if wxUSE_MENUS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ============================================================================
|
||||
// wxMenu implementation
|
||||
// ============================================================================
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler)
|
||||
|
||||
bool wxMenu::Create(const wxString& title, long style)
|
||||
{
|
||||
#if 0
|
||||
if(!title)
|
||||
return CocoaCreate("wxMenu");
|
||||
#endif
|
||||
return CocoaCreate(title);
|
||||
}
|
||||
|
||||
wxMenu::~wxMenu()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxMenu::DoAppend(wxMenuItem *item)
|
||||
{
|
||||
if(!wxMenuBase::DoAppend(item))
|
||||
return false;
|
||||
[m_cocoaNSMenu addItem: item->GetNSMenuItem()];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxMenu::DoInsert(unsigned long pos, wxMenuItem *item)
|
||||
{
|
||||
if(!wxMenuBase::DoInsert(pos,item))
|
||||
return false;
|
||||
[m_cocoaNSMenu insertItem:item->GetNSMenuItem() atIndex:pos];
|
||||
return true;
|
||||
}
|
||||
|
||||
wxMenuItem* wxMenu::DoRemove(wxMenuItem *item)
|
||||
{
|
||||
wxMenuItem *retitem = wxMenuBase::DoRemove(item);
|
||||
wxASSERT(retitem->GetNSMenuItem());
|
||||
[m_cocoaNSMenu removeItem:retitem->GetNSMenuItem()];
|
||||
return retitem;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxMenuBar implementation
|
||||
// ============================================================================
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow)
|
||||
|
||||
bool wxMenuBar::Create(long style)
|
||||
{
|
||||
if(!CocoaCreate("wxMenuBar"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
wxMenuBar::~wxMenuBar()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxMenuBar::Append( wxMenu *menu, const wxString &title )
|
||||
{
|
||||
wxLogDebug("append menu=%p, title=%s",menu,title.c_str());
|
||||
if(!wxMenuBarBase::Append(menu,title))
|
||||
return false;
|
||||
wxASSERT(menu);
|
||||
wxASSERT(menu->GetNSMenu());
|
||||
NSString *menuTitle = [[NSString alloc] initWithCString: wxStripMenuCodes(title).c_str()];
|
||||
NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:NULL keyEquivalent:@""];
|
||||
[menu->GetNSMenu() setTitle:menuTitle];
|
||||
[newItem setSubmenu:menu->GetNSMenu()];
|
||||
|
||||
[m_cocoaNSMenu addItem:newItem];
|
||||
|
||||
[menuTitle release];
|
||||
[newItem release];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
||||
{
|
||||
wxLogDebug("insert pos=%lu, menu=%p, title=%s",pos,menu,title.c_str());
|
||||
if(!wxMenuBarBase::Insert(pos,menu,title))
|
||||
return false;
|
||||
wxASSERT(menu);
|
||||
wxASSERT(menu->GetNSMenu());
|
||||
NSString *menuTitle = [[NSString alloc] initWithCString: title.c_str()];
|
||||
NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:NULL keyEquivalent:@""];
|
||||
[menu->GetNSMenu() setTitle:menuTitle];
|
||||
[newItem setSubmenu:menu->GetNSMenu()];
|
||||
|
||||
[m_cocoaNSMenu insertItem:newItem atIndex:pos];
|
||||
|
||||
[menuTitle release];
|
||||
[newItem release];
|
||||
return true;
|
||||
}
|
||||
|
||||
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxMenu *wxMenuBar::Remove(size_t pos)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void wxMenuBar::EnableTop(size_t pos, bool enable)
|
||||
{
|
||||
}
|
||||
|
||||
bool wxMenuBar::IsEnabledTop(size_t pos) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
|
||||
{
|
||||
}
|
||||
|
||||
wxString wxMenuBar::GetLabelTop(size_t pos) const
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
void wxMenuBar::Attach(wxFrame *frame)
|
||||
{
|
||||
}
|
||||
|
||||
void wxMenuBar::Detach()
|
||||
{
|
||||
}
|
||||
|
||||
wxSize wxMenuBar::DoGetBestClientSize() const
|
||||
{
|
||||
return wxDefaultSize;
|
||||
}
|
||||
|
||||
#endif // wxUSE_MENUS
|
141
src/cocoa/menuitem.mm
Normal file
141
src/cocoa/menuitem.mm
Normal file
@@ -0,0 +1,141 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: menuitem.cpp
|
||||
// Purpose: wxMenuItem implementation
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: 2002 David Elliott
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/menu.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/frame.h"
|
||||
#endif
|
||||
|
||||
#include "wx/cocoa/ObjcPose.h"
|
||||
|
||||
#import <AppKit/NSMenuItem.h>
|
||||
#import <AppKit/NSMenu.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#if wxUSE_MENUS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
wxMenuItemCocoaHash wxMenuItemCocoa::sm_cocoaHash;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// functions prototypes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ============================================================================
|
||||
// @class wxPoserNSMenuItem
|
||||
// ============================================================================
|
||||
@interface wxPoserNSMenuItem : NSMenuItem
|
||||
{
|
||||
}
|
||||
|
||||
@end // wxPoserNSMenuItem
|
||||
|
||||
WX_IMPLEMENT_POSER(wxPoserNSMenuItem);
|
||||
@implementation wxPoserNSMenuItem : NSMenuItem
|
||||
|
||||
@end // wxPoseRNSMenuItem
|
||||
|
||||
// ============================================================================
|
||||
// wxMenuItemCocoa implementation
|
||||
// ============================================================================
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMenuItemBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
|
||||
int itemid,
|
||||
const wxString& name,
|
||||
const wxString& help,
|
||||
wxItemKind kind,
|
||||
wxMenu *subMenu)
|
||||
{
|
||||
return new wxMenuItem(parentMenu, itemid, name, help, kind, subMenu);
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
|
||||
{
|
||||
return wxStripMenuCodes(text);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ctor & dtor
|
||||
// ----------------------------------------------------------------------------
|
||||
wxMenuItemCocoa::wxMenuItemCocoa(wxMenu *pParentMenu,
|
||||
int itemid,
|
||||
const wxString& strName,
|
||||
const wxString& strHelp,
|
||||
wxItemKind kind,
|
||||
wxMenu *pSubMenu)
|
||||
: wxMenuItemBase(pParentMenu, itemid, strName, strHelp, kind, pSubMenu)
|
||||
{
|
||||
NSString *menuTitle = [[NSString alloc] initWithCString: wxStripMenuCodes(strName).c_str()];
|
||||
m_cocoaNSMenuItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:@selector(wxMenuItemAction:) keyEquivalent:@""];
|
||||
sm_cocoaHash.insert(wxMenuItemCocoaHash::value_type(m_cocoaNSMenuItem,this));
|
||||
if(pSubMenu)
|
||||
{
|
||||
wxASSERT(pSubMenu->GetNSMenu());
|
||||
[pSubMenu->GetNSMenu() setTitle:menuTitle];
|
||||
[m_cocoaNSMenuItem setSubmenu:pSubMenu->GetNSMenu()];
|
||||
}
|
||||
[menuTitle release];
|
||||
}
|
||||
|
||||
wxMenuItem::~wxMenuItem()
|
||||
{
|
||||
sm_cocoaHash.erase(m_cocoaNSMenuItem);
|
||||
[m_cocoaNSMenuItem release];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// change item state
|
||||
// -----------------
|
||||
|
||||
void wxMenuItem::Enable(bool bDoEnable)
|
||||
{
|
||||
wxMenuItemBase::Enable(bDoEnable);
|
||||
}
|
||||
|
||||
void wxMenuItem::Check(bool bDoCheck)
|
||||
{
|
||||
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
||||
wxMenuItemBase::Check(bDoCheck);
|
||||
}
|
||||
|
||||
void wxMenuItem::SetText(const wxString& label)
|
||||
{
|
||||
wxMenuItemBase::SetText(label);
|
||||
}
|
||||
|
||||
void wxMenuItem::SetCheckable(bool checkable)
|
||||
{
|
||||
wxMenuItemBase::SetCheckable(checkable);
|
||||
}
|
||||
|
||||
#endif // wxUSE_MENUS
|
60
src/cocoa/stattext.mm
Normal file
60
src/cocoa/stattext.mm
Normal file
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/stattext.mm
|
||||
// Purpose: wxStaticText
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/02/15
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/stattext.h"
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <AppKit/NSTextField.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
|
||||
BEGIN_EVENT_TABLE(wxStaticText, wxControl)
|
||||
END_EVENT_TABLE()
|
||||
WX_IMPLEMENT_COCOA_OWNER(wxStaticText,NSTextField,NSControl,NSView)
|
||||
|
||||
bool wxStaticText::Create(wxWindow *parent, wxWindowID winid,
|
||||
const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
|
||||
return false;
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
|
||||
[m_cocoaNSView release];
|
||||
[GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]];
|
||||
// [GetNSTextField() setBordered: NO];
|
||||
[GetNSTextField() setBezeled: NO];
|
||||
[GetNSTextField() setEditable: NO];
|
||||
[GetNSTextField() setDrawsBackground: NO];
|
||||
[GetNSControl() sizeToFit];
|
||||
if(m_parent)
|
||||
m_parent->CocoaAddChild(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
wxStaticText::~wxStaticText()
|
||||
{
|
||||
CocoaRemoveFromParent();
|
||||
SetNSTextField(NULL);
|
||||
}
|
||||
|
||||
void wxStaticText::SetLabel(const wxString& label)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxStaticText::Cocoa_didChangeText(void)
|
||||
{
|
||||
}
|
||||
|
184
src/cocoa/textctrl.mm
Normal file
184
src/cocoa/textctrl.mm
Normal file
@@ -0,0 +1,184 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/textctrl.mm
|
||||
// Purpose: wxTextCtrl
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2003/03/16
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2003 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
#import <AppKit/NSTextField.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
END_EVENT_TABLE()
|
||||
WX_IMPLEMENT_COCOA_OWNER(wxTextCtrl,NSTextField,NSControl,NSView)
|
||||
|
||||
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if(!CreateControl(parent,winid,pos,size,style,validator,name))
|
||||
return false;
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSTextField([[NSTextField alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
|
||||
[m_cocoaNSView release];
|
||||
[GetNSTextField() setStringValue:[NSString stringWithCString:value.c_str()]];
|
||||
[GetNSControl() sizeToFit];
|
||||
if(m_parent)
|
||||
m_parent->CocoaAddChild(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
wxTextCtrl::~wxTextCtrl()
|
||||
{
|
||||
CocoaRemoveFromParent();
|
||||
SetNSTextField(NULL);
|
||||
}
|
||||
|
||||
void wxTextCtrl::Cocoa_didChangeText(void)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::AppendText(wxString const&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetEditable(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::DiscardEdits()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetSelection(long, long)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::ShowPosition(long)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetInsertionPoint(long)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetInsertionPointEnd()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Redo()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Undo()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Clear()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Paste()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Remove(long, long)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::Replace(long, long, wxString const&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetValue(wxString const&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTextCtrl::WriteText(wxString const&)
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTextCtrl::IsEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::IsModified() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetLineText(long) const
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
void wxTextCtrl::GetSelection(long*, long*) const
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTextCtrl::PositionToXY(long, long*, long*) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long wxTextCtrl::XYToPosition(long, long) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxTextCtrl::GetLineLength(long) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
long wxTextCtrl::GetLastPosition() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxTextCtrl::GetNumberOfLines() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
long wxTextCtrl::GetInsertionPoint() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanRedo() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanUndo() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetValue() const
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
241
src/cocoa/toplevel.mm
Normal file
241
src/cocoa/toplevel.mm
Normal file
@@ -0,0 +1,241 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cocoa/toplevel.mm
|
||||
// Purpose: implements wxTopLevelWindow for Cocoa
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/11/27
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/window.h"
|
||||
#include "wx/toplevel.h"
|
||||
#include "wx/menuitem.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/app.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#import <AppKit/NSWindow.h>
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// list of all frames and modeless dialogs
|
||||
wxWindowList wxModelessWindows;
|
||||
|
||||
// ============================================================================
|
||||
// wxTopLevelWindowCocoa implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowCocoa creation
|
||||
// ----------------------------------------------------------------------------
|
||||
IMPLEMENT_CLASS(wxTopLevelWindowCocoa,wxWindowCocoa)
|
||||
BEGIN_EVENT_TABLE(wxTopLevelWindowCocoa,wxTopLevelWindowBase)
|
||||
EVT_CLOSE(wxTopLevelWindowCocoa::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void wxTopLevelWindowCocoa::Init()
|
||||
{
|
||||
m_iconized =
|
||||
m_maximizeOnShow =
|
||||
m_closed = false;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::Create(wxWindow *parent,
|
||||
wxWindowID winid,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
|
||||
return FALSE;
|
||||
|
||||
if ( parent )
|
||||
parent->AddChild(this);
|
||||
|
||||
// TODO: get rect from given position/size
|
||||
NSRect cocoaRect = NSMakeRect(100,100,200,200);
|
||||
|
||||
// TODO: Set flags given wxWindows style
|
||||
unsigned int cocoaStyle = 0;
|
||||
cocoaStyle |= NSTitledWindowMask;
|
||||
cocoaStyle |= NSClosableWindowMask;
|
||||
cocoaStyle |= NSMiniaturizableWindowMask;
|
||||
cocoaStyle |= NSResizableWindowMask;
|
||||
|
||||
m_cocoaNSWindow = NULL;
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSWindow([[NSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]);
|
||||
// NOTE: SetNSWindow has retained the Cocoa object for this object.
|
||||
// Because we do not release on close, the following release matches the
|
||||
// above alloc and thus the retain count will be 1.
|
||||
[m_cocoaNSWindow release];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa()
|
||||
{
|
||||
SetNSWindow(NULL);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowCocoa Cocoa Specifics
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowCocoa::SetNSWindow(WX_NSWindow cocoaNSWindow)
|
||||
{
|
||||
bool need_debug = cocoaNSWindow || m_cocoaNSWindow;
|
||||
if(need_debug) wxLogDebug("wxTopLevelWindowCocoa=%p::SetNSWindow [m_cocoaNSWindow=%p retainCount]=%d",this,m_cocoaNSWindow,[m_cocoaNSWindow retainCount]);
|
||||
if(m_cocoaNSWindow)
|
||||
DisassociateNSWindow(m_cocoaNSWindow);
|
||||
[cocoaNSWindow retain];
|
||||
[m_cocoaNSWindow release];
|
||||
m_cocoaNSWindow = cocoaNSWindow;
|
||||
if(m_cocoaNSWindow)
|
||||
SetNSView([m_cocoaNSWindow contentView]);
|
||||
else
|
||||
SetNSView(NULL);
|
||||
if(m_cocoaNSWindow)
|
||||
AssociateNSWindow(m_cocoaNSWindow);
|
||||
if(need_debug) wxLogDebug("wxTopLevelWindowCocoa=%p::SetNSWindow [cocoaNSWindow=%p retainCount]=%d",this,cocoaNSWindow,[cocoaNSWindow retainCount]);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::Cocoa_wxMenuItemAction(wxMenuItem& item)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::Cocoa_close(void)
|
||||
{
|
||||
m_closed = true;
|
||||
Destroy();
|
||||
/* Be SURE that idle events get ran. If the window was not active when
|
||||
it was closed, then there will be no more events to trigger this and
|
||||
therefore it must be done here */
|
||||
wxTheApp->CocoaInstallRequestedIdleHandler();
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::Cocoa_windowShouldClose()
|
||||
{
|
||||
return wxWindowBase::Close(false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowCocoa maximize/minimize
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTopLevelWindowCocoa::Maximize(bool maximize)
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::IsMaximized() const
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::Iconize(bool iconize)
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::IsIconized() const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::Restore()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::Show(bool show)
|
||||
{
|
||||
if(show)
|
||||
[m_cocoaNSWindow makeKeyAndOrderFront:m_cocoaNSWindow];
|
||||
else
|
||||
[m_cocoaNSWindow orderOut:m_cocoaNSWindow];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::Close(bool force)
|
||||
{
|
||||
if(force)
|
||||
return wxWindowBase::Close(force);
|
||||
// performClose will fake the user clicking the close button which
|
||||
// will invoke windowShouldClose which will call the base class version
|
||||
// of Close() which will NOT Destroy() the window (see below) but
|
||||
// if closing is not stopped, then performClose will go ahead and
|
||||
// close the window which will invoke Cocoa_close() setting m_closed
|
||||
// to true and Destroy()ing the window.
|
||||
[m_cocoaNSWindow performClose:m_cocoaNSWindow];
|
||||
return m_closed;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
// If the event was forced, close the window which will Destroy() it
|
||||
if(!event.CanVeto())
|
||||
[m_cocoaNSWindow close];
|
||||
// if the event was not forced, it's probably because the user clicked
|
||||
// the close button, or Close(false) was called which (see above) is
|
||||
// redirected to performClose and thus Cocoa itself will close the window
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTopLevelWindowCocoa misc
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTopLevelWindowCocoa::ShowFullScreen(bool show, long style)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowCocoa::IsFullScreen() const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
wxLogDebug("wxTopLevelWindow=%p::DoMoveWindow(%d,%d,%d,%d)",this,x,y,width,height);
|
||||
|
||||
NSRect cocoaRect = NSMakeRect(x,y,width,height);
|
||||
[m_cocoaNSWindow setFrame: cocoaRect display:NO];
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::DoGetSize(int *w, int *h) const
|
||||
{
|
||||
NSRect cocoaRect = [m_cocoaNSWindow frame];
|
||||
if(w)
|
||||
*w=(int)cocoaRect.size.width;
|
||||
if(h)
|
||||
*h=(int)cocoaRect.size.height;
|
||||
wxLogDebug("wxTopLevelWindow=%p::DoGetSize = (%d,%d)",this,(int)cocoaRect.size.width,(int)cocoaRect.size.height);
|
||||
}
|
||||
|
||||
void wxTopLevelWindowCocoa::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
NSRect cocoaRect = [m_cocoaNSWindow frame];
|
||||
if(x)
|
||||
*x=(int)cocoaRect.origin.x;
|
||||
if(y)
|
||||
*y=(int)cocoaRect.origin.y;
|
||||
wxLogDebug("wxTopLevelWindow=%p::DoGetPosition = (%d,%d)",this,(int)cocoaRect.origin.x,(int)cocoaRect.origin.y);
|
||||
}
|
||||
|
401
src/cocoa/window.mm
Normal file
401
src/cocoa/window.mm
Normal file
@@ -0,0 +1,401 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/cocoa/window.mm
|
||||
// Purpose: wxWindowCocoa
|
||||
// Author: David Elliott
|
||||
// Modified by:
|
||||
// Created: 2002/12/26
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) 2002 David Elliott
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/window.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#import <Appkit/NSView.h>
|
||||
|
||||
// normally the base classes aren't included, but wxWindow is special
|
||||
#ifdef __WXUNIVERSAL__
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxWindowCocoa, wxWindowBase)
|
||||
#else
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
|
||||
#endif
|
||||
|
||||
BEGIN_EVENT_TABLE(wxWindowCocoa, wxWindowBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Constructor
|
||||
void wxWindowCocoa::Init()
|
||||
{
|
||||
InitBase();
|
||||
|
||||
m_cocoaNSView = NULL;
|
||||
m_dummyNSView = NULL;
|
||||
m_isBeingDeleted = FALSE;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
bool wxWindow::Create(wxWindow *parent, wxWindowID winid,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
|
||||
return false;
|
||||
|
||||
// TODO: create the window
|
||||
NSRect cocoaRect = NSMakeRect(10,10,20,20);
|
||||
m_cocoaNSView = NULL;
|
||||
SetNSView([[NSView alloc] initWithFrame: cocoaRect]);
|
||||
[m_cocoaNSView release];
|
||||
|
||||
if (m_parent)
|
||||
{
|
||||
m_parent->AddChild(this);
|
||||
m_parent->CocoaAddChild(this);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
wxWindow::~wxWindow()
|
||||
{
|
||||
DestroyChildren();
|
||||
|
||||
if(m_parent)
|
||||
m_parent->RemoveChild(this);
|
||||
|
||||
CocoaRemoveFromParent();
|
||||
SetNSView(NULL);
|
||||
}
|
||||
|
||||
void wxWindowCocoa::CocoaAddChild(wxWindowCocoa *child)
|
||||
{
|
||||
[child->m_cocoaNSView retain];
|
||||
// NOTE: addSubView takes ownership of, but does not retain the subview
|
||||
// Upon a removeFromView or closing the super view, the child WILL be
|
||||
// released!!! I think the idea here is that normally you would alloc
|
||||
// the subview and add it to the superview and this way you don't have
|
||||
// to release what you just alloced. Unfortunately, that doesn't
|
||||
// make sense for wxCocoa, so we do this instead.
|
||||
[m_cocoaNSView addSubview: child->m_cocoaNSView];
|
||||
wxASSERT(!child->m_dummyNSView);
|
||||
child->m_isShown = true;
|
||||
}
|
||||
|
||||
void wxWindowCocoa::CocoaRemoveFromParent(void)
|
||||
{
|
||||
wxASSERT(m_cocoaNSView);
|
||||
if(m_dummyNSView)
|
||||
{
|
||||
// balances the alloc
|
||||
[m_dummyNSView removeFromSuperview];
|
||||
// But since we also retained it ourselves
|
||||
[m_dummyNSView release];
|
||||
m_dummyNSView = nil;
|
||||
// m_cocoaNSView has of course already been removed by virtue of
|
||||
// replaceSubview: m_cocoaNSView with: m_dummyNSView
|
||||
}
|
||||
else
|
||||
[m_cocoaNSView removeFromSuperview];
|
||||
}
|
||||
|
||||
void wxWindowCocoa::SetNSView(WX_NSView cocoaNSView)
|
||||
{
|
||||
bool need_debug = cocoaNSView || m_cocoaNSView;
|
||||
if(need_debug) wxLogDebug("wxWindowCocoa=%p::SetNSView [m_cocoaNSView=%p retainCount]=%d",this,m_cocoaNSView,[m_cocoaNSView retainCount]);
|
||||
if(m_cocoaNSView)
|
||||
DisassociateNSView(m_cocoaNSView);
|
||||
[cocoaNSView retain];
|
||||
[m_cocoaNSView release];
|
||||
m_cocoaNSView = cocoaNSView;
|
||||
if(m_cocoaNSView)
|
||||
AssociateNSView(m_cocoaNSView);
|
||||
if(need_debug) wxLogDebug("wxWindowCocoa=%p::SetNSView [cocoaNSView=%p retainCount]=%d",this,cocoaNSView,[cocoaNSView retainCount]);
|
||||
}
|
||||
|
||||
void wxWindowCocoa::Cocoa_FrameChanged(void)
|
||||
{
|
||||
wxLogDebug("Cocoa_FrameChanged");
|
||||
wxSizeEvent event(GetSize(), m_windowId);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
bool wxWindow::Close(bool force)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxWindow::Show(bool show)
|
||||
{
|
||||
// If the window is marked as visible, then it shouldn't have a dummy view
|
||||
// If the window is marked hidden, then it should have a dummy view
|
||||
wxASSERT_MSG( (m_isShown && !m_dummyNSView) || (!m_isShown && m_dummyNSView),"wxWindow: m_isShown does not agree with m_dummyNSView");
|
||||
// Return false if there isn't a window to show or hide
|
||||
if(!m_cocoaNSView)
|
||||
return false;
|
||||
// Return false if the state isn't changing
|
||||
if( show == m_isShown )
|
||||
return false;
|
||||
if(show)
|
||||
{
|
||||
// replaceSubView releases m_dummyNSView, balancing the alloc
|
||||
[m_cocoaNSView retain];
|
||||
[[m_dummyNSView superview] replaceSubview:m_dummyNSView with:m_cocoaNSView];
|
||||
// But since we also retained it ourselves
|
||||
[m_dummyNSView release];
|
||||
m_dummyNSView = nil;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dummyNSView = [[NSView alloc] initWithFrame: [m_cocoaNSView frame]];
|
||||
[m_dummyNSView retain];
|
||||
// NOTE: replaceSubView will cause m_cocaNSView to be released
|
||||
[[m_cocoaNSView superview] replaceSubview:m_cocoaNSView with:m_dummyNSView];
|
||||
// m_coocaNSView is now only retained by us
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindowCocoa::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
wxLogDebug("wxWindow=%p::DoSetSizeWindow(%d,%d,%d,%d,Auto: %s%s)",this,x,y,width,height,(sizeFlags&wxSIZE_AUTO_WIDTH)?"W":".",sizeFlags&wxSIZE_AUTO_HEIGHT?"H":".");
|
||||
int currentX, currentY;
|
||||
int currentW, currentH;
|
||||
DoGetPosition(¤tX, ¤tY);
|
||||
DoGetSize(¤tW, ¤tH);
|
||||
if((x==-1) && !(sizeFlags&wxSIZE_ALLOW_MINUS_ONE))
|
||||
x=currentX;
|
||||
if((y==-1) && !(sizeFlags&wxSIZE_ALLOW_MINUS_ONE))
|
||||
y=currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x,y,sizeFlags);
|
||||
|
||||
wxSize size(-1,-1);
|
||||
|
||||
if((width==-1)&&!(sizeFlags&wxSIZE_ALLOW_MINUS_ONE))
|
||||
{
|
||||
if(sizeFlags&wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
size=DoGetBestSize();
|
||||
width=size.x;
|
||||
}
|
||||
else
|
||||
width=currentW;
|
||||
}
|
||||
if((height==-1)&&!(sizeFlags&wxSIZE_ALLOW_MINUS_ONE))
|
||||
{
|
||||
if(sizeFlags&wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if(size.x==-1)
|
||||
size=DoGetBestSize();
|
||||
height=size.y;
|
||||
}
|
||||
else
|
||||
height=currentH;
|
||||
}
|
||||
DoMoveWindow(x,y,width,height);
|
||||
}
|
||||
|
||||
void wxWindowCocoa::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
wxLogDebug("wxWindow=%p::DoMoveWindow(%d,%d,%d,%d)",this,x,y,width,height);
|
||||
|
||||
NSView *superview = [m_cocoaNSView superview];
|
||||
wxCHECK_RET(superview,"NSView does not have a superview");
|
||||
NSRect parentRect = [superview frame];
|
||||
|
||||
NSRect cocoaRect = NSMakeRect(x,parentRect.size.height-(y+height),width,height);
|
||||
[m_cocoaNSView setFrame: cocoaRect];
|
||||
// Also change the dummy's size
|
||||
if(m_dummyNSView)
|
||||
[m_dummyNSView setFrame: cocoaRect];
|
||||
}
|
||||
|
||||
// Get total size
|
||||
void wxWindow::DoGetSize(int *w, int *h) const
|
||||
{
|
||||
NSRect cocoaRect = [m_cocoaNSView frame];
|
||||
if(w)
|
||||
*w=(int)cocoaRect.size.width;
|
||||
if(h)
|
||||
*h=(int)cocoaRect.size.height;
|
||||
wxLogDebug("wxWindow=%p::DoGetSize = (%d,%d)",this,(int)cocoaRect.size.width,(int)cocoaRect.size.height);
|
||||
}
|
||||
|
||||
void wxWindow::DoGetPosition(int *x, int *y) const
|
||||
{
|
||||
NSView *superview = [m_cocoaNSView superview];
|
||||
wxCHECK_RET(superview,"NSView does not have a superview");
|
||||
NSRect parentRect = [superview frame];
|
||||
|
||||
NSRect cocoaRect = [m_cocoaNSView frame];
|
||||
if(x)
|
||||
*x=(int)cocoaRect.origin.x;
|
||||
if(y)
|
||||
*y=(int)(parentRect.size.height-(cocoaRect.origin.y+cocoaRect.size.height));
|
||||
wxLogDebug("wxWindow=%p::DoGetPosition = (%d,%d)",this,(int)cocoaRect.origin.x,(int)cocoaRect.origin.y);
|
||||
}
|
||||
|
||||
WXWidget wxWindow::GetHandle() const
|
||||
{
|
||||
return m_cocoaNSView;
|
||||
}
|
||||
|
||||
void wxWindow::SetFocus()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxWindow::DoCaptureMouse()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxWindow::DoReleaseMouse()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxWindow::DoScreenToClient(int *x, int *y) const
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxWindow::DoClientToScreen(int *x, int *y) const
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Get size *available for subwindows* i.e. excluding menu bar etc.
|
||||
void wxWindow::DoGetClientSize(int *x, int *y) const
|
||||
{
|
||||
wxLogDebug("DoGetClientSize:");
|
||||
wxWindowCocoa::DoGetSize(x,y);
|
||||
// TODO: Actually account for menubar, borders, etc...
|
||||
}
|
||||
|
||||
void wxWindow::DoSetClientSize(int width, int height)
|
||||
{
|
||||
wxLogDebug("DoSetClientSize=(%d,%d)",width,height);
|
||||
// TODO
|
||||
}
|
||||
|
||||
int wxWindow::GetCharHeight() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxWindow::GetCharWidth() const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
|
||||
int *descent, int *externalLeading, const wxFont *theFont) const
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Coordinates relative to the window
|
||||
void wxWindow::WarpPointer (int x_pos, int y_pos)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
int wxWindow::GetScrollPos(int orient) const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This now returns the whole range, not just the number
|
||||
// of positions that we can scroll.
|
||||
int wxWindow::GetScrollRange(int orient) const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxWindow::GetScrollThumb(int orient) const
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// New function that will replace some of the above.
|
||||
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
|
||||
int range, bool refresh)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Does a physical scroll
|
||||
void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool wxWindow::SetFont(const wxFont& font)
|
||||
{
|
||||
// TODO
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxWindow::Clear()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Raise the window to the top of the Z order
|
||||
void wxWindow::Raise()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Lower the window to the bottom of the Z order
|
||||
void wxWindow::Lower()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get the window with the focus
|
||||
wxWindow *wxWindowBase::FindFocus()
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* static */ wxWindow *wxWindowBase::GetCapture()
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxWindow *wxGetActiveWindow()
|
||||
{
|
||||
// TODO
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user