1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/toplevel.h
3 // Purpose: wxTopLevelWindowCocoa is the Cocoa implementation of wxTLW
4 // Author: David Elliott
7 // Copyright: (c) 2002 David Elliott
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef __WX_COCOA_TOPLEVEL_H__
12 #define __WX_COCOA_TOPLEVEL_H__
14 #include "wx/hashmap.h"
15 #include "wx/cocoa/NSWindow.h"
17 class WXDLLIMPEXP_FWD_CORE wxMenuBar
;
19 // ========================================================================
20 // wxTopLevelWindowCocoa
21 // ========================================================================
22 class WXDLLIMPEXP_CORE wxTopLevelWindowCocoa
: public wxTopLevelWindowBase
, protected wxCocoaNSWindow
24 DECLARE_EVENT_TABLE();
25 DECLARE_NO_COPY_CLASS(wxTopLevelWindowCocoa
);
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 inline wxTopLevelWindowCocoa()
31 : wxCocoaNSWindow(this)
34 inline wxTopLevelWindowCocoa(wxWindow
*parent
,
36 const wxString
& title
,
37 const wxPoint
& pos
= wxDefaultPosition
,
38 const wxSize
& size
= wxDefaultSize
,
39 long style
= wxDEFAULT_FRAME_STYLE
,
40 const wxString
& name
= wxFrameNameStr
)
41 : wxCocoaNSWindow(this)
44 Create(parent
, winid
, title
, pos
, size
, style
, name
);
47 bool Create(wxWindow
*parent
,
49 const wxString
& title
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
52 long style
= wxDEFAULT_FRAME_STYLE
,
53 const wxString
& name
= wxFrameNameStr
);
55 virtual ~wxTopLevelWindowCocoa();
58 // common part of all ctors
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
65 inline WX_NSWindow
GetNSWindow() { return m_cocoaNSWindow
; }
66 virtual void CocoaDelegate_windowWillClose(void);
67 virtual bool CocoaDelegate_windowShouldClose(void);
68 virtual void CocoaDelegate_windowDidBecomeKey(void);
69 virtual void CocoaDelegate_windowDidResignKey(void);
70 virtual void CocoaDelegate_windowDidBecomeMain(void);
71 virtual void CocoaDelegate_windowDidResignMain(void);
72 virtual void CocoaDelegate_wxMenuItemAction(WX_NSMenuItem sender
);
73 virtual bool CocoaDelegate_validateMenuItem(WX_NSMenuItem sender
);
74 virtual wxMenuBar
* GetAppMenuBar(wxCocoaNSWindow
*win
);
75 static void DeactivatePendingWindow();
77 void SetNSWindow(WX_NSWindow cocoaNSWindow
);
78 WX_NSWindow m_cocoaNSWindow
;
79 static wxCocoaNSWindowHash sm_cocoaHash
;
80 virtual void CocoaReplaceView(WX_NSView oldView
, WX_NSView newView
);
81 static unsigned int NSWindowStyleForWxStyle(long style
);
82 static NSRect
MakeInitialNSWindowContentRect(const wxPoint
& pos
, const wxSize
& size
, unsigned int cocoaStyleMask
);
84 static wxTopLevelWindowCocoa
*sm_cocoaDeactivateWindow
;
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
89 virtual bool Destroy();
91 virtual void Maximize(bool maximize
= true);
92 virtual bool IsMaximized() const;
93 virtual void Iconize(bool iconize
= true);
94 virtual bool IsIconized() const;
95 virtual void Restore();
96 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
97 virtual bool IsFullScreen() const;
99 virtual bool Show( bool show
= true );
100 virtual bool Close( bool force
= false );
101 virtual void OnCloseWindow(wxCloseEvent
& event
);
102 virtual void CocoaSetWxWindowSize(int width
, int height
);
103 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
104 virtual void DoGetSize(int *width
, int *height
) const;
105 virtual void DoGetPosition(int *x
, int *y
) const;
106 virtual void SetTitle( const wxString
& title
);
107 virtual wxString
GetTitle() const;
109 // Default button (item)
110 wxWindow
*SetDefaultItem(wxWindow
*win
);
112 // Things I may/may not do
113 // virtual void SetIcons(const wxIconBundle& icons);
114 // virtual void Clear() ;
115 // virtual void Raise();
116 // virtual void Lower();
118 // is the frame currently iconized?
120 // has the frame been closed
122 // should the frame be maximized when it will be shown? set by Maximize()
123 // when it is called while the frame is hidden
124 bool m_maximizeOnShow
;
127 // list of all frames and modeless dialogs
128 extern WXDLLIMPEXP_DATA_CORE(wxWindowList
) wxModelessWindows
;
130 #endif // __WX_COCOA_TOPLEVEL_H__