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 void InitMouseEvent(wxMouseEvent
&event
, WX_NSEvent cocoaEvent
);
58 virtual void Cocoa_FrameChanged(void);
59 virtual bool Cocoa_drawRect(const NSRect
&rect
);
60 virtual bool Cocoa_mouseDown(WX_NSEvent theEvent
);
61 virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent
);
62 virtual bool Cocoa_mouseUp(WX_NSEvent theEvent
);
63 virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent
);
64 virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent
);
65 virtual bool Cocoa_mouseExited(WX_NSEvent theEvent
);
66 virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent
);
67 virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent
);
68 virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent
);
69 virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent
);
70 virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent
);
71 virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent
);
72 void SetNSView(WX_NSView cocoaNSView
);
73 WX_NSView m_cocoaNSView
;
74 WX_NSView m_dummyNSView
;
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 // Raise the window to the top of the Z order
82 // Lower the window to the bottom of the Z order
84 // Set the focus to this window
85 virtual void SetFocus();
86 // Warp the pointer the given position
87 virtual void WarpPointer(int x_pos
, int y_pos
) ;
88 // Send the window a refresh event
89 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
92 // Set/get the window's font
93 virtual bool SetFont(const wxFont
& f
);
94 // inline virtual wxFont& GetFont() const;
96 virtual int GetCharHeight() const;
97 virtual int GetCharWidth() const;
98 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
100 int *externalLeading
= NULL
,
101 const wxFont
*theFont
= NULL
) const;
103 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
104 int range
, bool refresh
= TRUE
);
105 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
106 virtual int GetScrollPos(int orient
) const;
107 virtual int GetScrollThumb(int orient
) const;
108 virtual int GetScrollRange(int orient
) const;
109 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
110 // Get the private handle (platform-dependent)
111 virtual WXWidget
GetHandle() const;
112 // Convert client to screen coordinates
113 virtual void DoClientToScreen(int *x
, int *y
) const;
114 // Convert screen to client coordinates
115 virtual void DoScreenToClient(int *x
, int *y
) const;
116 // Capture/release mouse
117 virtual void DoCaptureMouse();
118 virtual void DoReleaseMouse();
119 // Get window position, relative to parent (or screen if no parent)
120 virtual void DoGetPosition(int *x
, int *y
) const;
121 // Get overall window size
122 virtual void DoGetSize(int *width
, int *height
) const;
123 // Get/set client (application-useable) size
124 virtual void DoGetClientSize(int *width
, int *height
) const;
125 virtual void DoSetClientSize(int width
, int size
);
126 // Set overall size and position
127 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
128 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
130 virtual bool DoPopupMenu(wxMenu
*menu
, int x
, int y
);
132 /* Other implementation */
134 // NOTE: typically Close() is not virtual, but we want this for Cocoa
135 virtual bool Close( bool force
= false );
136 virtual bool Show( bool show
= true );
139 #endif // __WX_COCOA_WINDOW_H__