1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/toplevel.h
3 // Purpose: wxTopLevelWindowCocoa is the Cocoa implementation of wxTLW
4 // Author: David Elliott
8 // Copyright: (c) 2002 David Elliott
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_TOPLEVEL_H__
13 #define __WX_COCOA_TOPLEVEL_H__
15 #include "wx/hashmap.h"
16 #include "wx/cocoa/NSWindow.h"
18 class WXDLLIMPEXP_FWD_CORE wxMenuBar
;
20 // ========================================================================
21 // wxTopLevelWindowCocoa
22 // ========================================================================
23 class WXDLLEXPORT wxTopLevelWindowCocoa
: public wxTopLevelWindowBase
, protected wxCocoaNSWindow
25 DECLARE_EVENT_TABLE();
26 DECLARE_NO_COPY_CLASS(wxTopLevelWindowCocoa
);
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 inline wxTopLevelWindowCocoa()
32 : wxCocoaNSWindow(this)
35 inline wxTopLevelWindowCocoa(wxWindow
*parent
,
37 const wxString
& title
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
40 long style
= wxDEFAULT_FRAME_STYLE
,
41 const wxString
& name
= wxFrameNameStr
)
42 : wxCocoaNSWindow(this)
45 Create(parent
, winid
, title
, pos
, size
, style
, name
);
48 bool Create(wxWindow
*parent
,
50 const wxString
& title
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
53 long style
= wxDEFAULT_FRAME_STYLE
,
54 const wxString
& name
= wxFrameNameStr
);
56 virtual ~wxTopLevelWindowCocoa();
59 // common part of all ctors
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
66 inline WX_NSWindow
GetNSWindow() { return m_cocoaNSWindow
; }
67 virtual void CocoaDelegate_windowWillClose(void);
68 virtual bool CocoaDelegate_windowShouldClose(void);
69 virtual void CocoaDelegate_windowDidBecomeKey(void);
70 virtual void CocoaDelegate_windowDidResignKey(void);
71 virtual void CocoaDelegate_windowDidBecomeMain(void);
72 virtual void CocoaDelegate_windowDidResignMain(void);
73 virtual void CocoaDelegate_wxMenuItemAction(WX_NSMenuItem sender
);
74 virtual bool CocoaDelegate_validateMenuItem(WX_NSMenuItem sender
);
75 virtual wxMenuBar
* GetAppMenuBar(wxCocoaNSWindow
*win
);
76 static void DeactivatePendingWindow();
78 void SetNSWindow(WX_NSWindow cocoaNSWindow
);
79 WX_NSWindow m_cocoaNSWindow
;
80 static wxCocoaNSWindowHash sm_cocoaHash
;
81 virtual void CocoaReplaceView(WX_NSView oldView
, WX_NSView newView
);
82 static unsigned int NSWindowStyleForWxStyle(long style
);
83 static NSRect
MakeInitialNSWindowContentRect(const wxPoint
& pos
, const wxSize
& size
, unsigned int cocoaStyleMask
);
85 static wxTopLevelWindowCocoa
*sm_cocoaDeactivateWindow
;
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
90 virtual bool Destroy();
92 virtual void Maximize(bool maximize
= true);
93 virtual bool IsMaximized() const;
94 virtual void Iconize(bool iconize
= true);
95 virtual bool IsIconized() const;
96 virtual void Restore();
97 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
98 virtual bool IsFullScreen() const;
100 virtual bool Show( bool show
= true );
101 virtual bool Close( bool force
= false );
102 virtual void OnCloseWindow(wxCloseEvent
& event
);
103 virtual void CocoaSetWxWindowSize(int width
, int height
);
104 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
105 virtual void DoGetSize(int *width
, int *height
) const;
106 virtual void DoGetPosition(int *x
, int *y
) const;
107 virtual void SetTitle( const wxString
& title
);
108 virtual wxString
GetTitle() const;
110 // Default button (item)
111 wxWindow
*SetDefaultItem(wxWindow
*win
);
113 // Things I may/may not do
114 // virtual void SetIcons(const wxIconBundle& icons);
115 // virtual void Clear() ;
116 // virtual void Raise();
117 // virtual void Lower();
119 // is the frame currently iconized?
121 // has the frame been closed
123 // should the frame be maximized when it will be shown? set by Maximize()
124 // when it is called while the frame is hidden
125 bool m_maximizeOnShow
;
128 // list of all frames and modeless dialogs
129 extern WXDLLEXPORT_DATA(wxWindowList
) wxModelessWindows
;
131 #endif // __WX_COCOA_TOPLEVEL_H__