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 WXDLLEXPORT 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() { Init(); }
33 inline wxTopLevelWindowCocoa(wxWindow
*parent
,
35 const wxString
& title
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
,
38 long style
= wxDEFAULT_FRAME_STYLE
,
39 const wxString
& name
= wxFrameNameStr
)
42 Create(parent
, winid
, title
, pos
, size
, style
, name
);
45 bool Create(wxWindow
*parent
,
47 const wxString
& title
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
50 long style
= wxDEFAULT_FRAME_STYLE
,
51 const wxString
& name
= wxFrameNameStr
);
53 virtual ~wxTopLevelWindowCocoa();
56 // common part of all ctors
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
63 inline WX_NSWindow
GetNSWindow() { return m_cocoaNSWindow
; }
64 virtual void CocoaDelegate_windowWillClose(void);
65 virtual bool CocoaDelegate_windowShouldClose(void);
66 virtual void CocoaDelegate_windowDidBecomeKey(void);
67 virtual void CocoaDelegate_windowDidResignKey(void);
68 virtual void CocoaDelegate_windowDidBecomeMain(void);
69 virtual void CocoaDelegate_windowDidResignMain(void);
70 virtual void CocoaDelegate_wxMenuItemAction(struct objc_object
*sender
);
71 virtual bool CocoaDelegate_validateMenuItem(struct objc_object
*sender
);
72 virtual wxMenuBar
* GetAppMenuBar(wxCocoaNSWindow
*win
);
73 static void DeactivatePendingWindow();
75 void SetNSWindow(WX_NSWindow cocoaNSWindow
);
76 WX_NSWindow m_cocoaNSWindow
;
77 static wxCocoaNSWindowHash sm_cocoaHash
;
78 virtual void CocoaReplaceView(WX_NSView oldView
, WX_NSView newView
);
79 static unsigned int NSWindowStyleForWxStyle(long style
);
81 static wxTopLevelWindowCocoa
*sm_cocoaDeactivateWindow
;
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
86 virtual bool Destroy();
88 virtual void Maximize(bool maximize
= true);
89 virtual bool IsMaximized() const;
90 virtual void Iconize(bool iconize
= true);
91 virtual bool IsIconized() const;
92 virtual void Restore();
93 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
94 virtual bool IsFullScreen() const;
96 virtual bool Show( bool show
= true );
97 virtual bool Close( bool force
= false );
98 virtual void OnCloseWindow(wxCloseEvent
& event
);
99 virtual void CocoaSetWxWindowSize(int width
, int height
);
100 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
101 virtual void DoGetSize(int *width
, int *height
) const;
102 virtual void DoGetPosition(int *x
, int *y
) const;
105 // Things I may/may not do
106 // virtual void SetIcon(const wxIcon& icon);
107 // virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); }
108 // virtual void Clear() ;
109 // virtual void Raise();
110 // virtual void Lower();
111 // virtual void SetTitle( const wxString& title);
113 // is the frame currently iconized?
115 // has the frame been closed
117 // should the frame be maximized when it will be shown? set by Maximize()
118 // when it is called while the frame is hidden
119 bool m_maximizeOnShow
;
122 // list of all frames and modeless dialogs
123 extern WXDLLEXPORT_DATA(wxWindowList
) wxModelessWindows
;
125 #endif // __WX_COCOA_TOPLEVEL_H__