1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/window.h
3 // Purpose: wxWindowCocoa
4 // Author: David Elliott
8 // Copyright: (c) 2002 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_WINDOW_H__
13 #define __WX_COCOA_WINDOW_H__
15 #include "wx/cocoa/NSView.h"
17 // ========================================================================
19 // ========================================================================
20 class WXDLLEXPORT wxWindowCocoa
: public wxWindowBase
, protected wxCocoaNSView
22 DECLARE_DYNAMIC_CLASS(wxWindowCocoa
)
23 DECLARE_NO_COPY_CLASS(wxWindowCocoa
)
25 // ------------------------------------------------------------------------
27 // ------------------------------------------------------------------------
29 wxWindowCocoa() { Init(); }
30 inline wxWindowCocoa(wxWindow
*parent
, wxWindowID winid
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
34 const wxString
& name
= wxPanelNameStr
)
37 Create(parent
, winid
, pos
, size
, style
, name
);
40 virtual ~wxWindowCocoa();
42 bool Create(wxWindow
*parent
, wxWindowID winid
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxString
& name
= wxPanelNameStr
);
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
53 inline WX_NSView
GetNSView() { return m_cocoaNSView
; }
54 void CocoaAddChild(wxWindowCocoa
*child
);
55 void CocoaRemoveFromParent(void);
57 virtual void Cocoa_FrameChanged(void);
58 virtual bool Cocoa_drawRect(const NSRect
&rect
);
59 void SetNSView(WX_NSView cocoaNSView
);
60 WX_NSView m_cocoaNSView
;
61 WX_NSView m_dummyNSView
;
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 // Raise the window to the top of the Z order
69 // Lower the window to the bottom of the Z order
71 // Set the focus to this window
72 virtual void SetFocus();
73 // Warp the pointer the given position
74 virtual void WarpPointer(int x_pos
, int y_pos
) ;
75 // Send the window a refresh event
76 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
79 // Set/get the window's font
80 virtual bool SetFont(const wxFont
& f
);
81 // inline virtual wxFont& GetFont() const;
83 virtual int GetCharHeight() const;
84 virtual int GetCharWidth() const;
85 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
87 int *externalLeading
= NULL
,
88 const wxFont
*theFont
= NULL
) const;
90 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
91 int range
, bool refresh
= TRUE
);
92 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
93 virtual int GetScrollPos(int orient
) const;
94 virtual int GetScrollThumb(int orient
) const;
95 virtual int GetScrollRange(int orient
) const;
96 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
97 // Get the private handle (platform-dependent)
98 virtual WXWidget
GetHandle() const;
99 // Convert client to screen coordinates
100 virtual void DoClientToScreen(int *x
, int *y
) const;
101 // Convert screen to client coordinates
102 virtual void DoScreenToClient(int *x
, int *y
) const;
103 // Capture/release mouse
104 virtual void DoCaptureMouse();
105 virtual void DoReleaseMouse();
106 // Get window position, relative to parent (or screen if no parent)
107 virtual void DoGetPosition(int *x
, int *y
) const;
108 // Get overall window size
109 virtual void DoGetSize(int *width
, int *height
) const;
110 // Get/set client (application-useable) size
111 virtual void DoGetClientSize(int *width
, int *height
) const;
112 virtual void DoSetClientSize(int width
, int size
);
113 // Set overall size and position
114 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
115 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
117 virtual bool DoPopupMenu(wxMenu
*menu
, int x
, int y
);
119 /* Other implementation */
121 // NOTE: typically Close() is not virtual, but we want this for Cocoa
122 virtual bool Close( bool force
= false );
123 virtual bool Show( bool show
= true );
126 #endif // __WX_COCOA_WINDOW_H__