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:
David Elliott
2003-03-21 19:51:47 +00:00
parent 43225e09fe
commit fb896a322a
40 changed files with 4164 additions and 0 deletions

View 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_

View 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
View 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_

View 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
View 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_

View 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
View 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
View 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
View 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__

View 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__

View 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__

View 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__

View 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
View 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
View 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_

View 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
View 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_

View 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_

View 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
View 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
View 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
View 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__