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 friend wxWindow
*wxWindowBase::GetCapture();
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 wxWindowCocoa() { Init(); }
31 inline wxWindowCocoa(wxWindow
*parent
, wxWindowID winid
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
35 const wxString
& name
= wxPanelNameStr
)
38 Create(parent
, winid
, pos
, size
, style
, name
);
41 virtual ~wxWindowCocoa();
43 bool Create(wxWindow
*parent
, wxWindowID winid
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
47 const wxString
& name
= wxPanelNameStr
);
50 // ------------------------------------------------------------------------
52 // ------------------------------------------------------------------------
54 inline WX_NSView
GetNSView() { return m_cocoaNSView
; }
55 void CocoaAddChild(wxWindowCocoa
*child
);
56 void CocoaRemoveFromParent(void);
58 void InitMouseEvent(wxMouseEvent
&event
, WX_NSEvent cocoaEvent
);
59 virtual void Cocoa_FrameChanged(void);
60 virtual bool Cocoa_drawRect(const NSRect
&rect
);
61 virtual bool Cocoa_mouseDown(WX_NSEvent theEvent
);
62 virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent
);
63 virtual bool Cocoa_mouseUp(WX_NSEvent theEvent
);
64 virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent
);
65 virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent
);
66 virtual bool Cocoa_mouseExited(WX_NSEvent theEvent
);
67 virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent
);
68 virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent
);
69 virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent
);
70 virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent
);
71 virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent
);
72 virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent
);
73 void SetNSView(WX_NSView cocoaNSView
);
74 WX_NSView m_cocoaNSView
;
75 WX_NSView m_dummyNSView
;
77 static wxWindow
*sm_capturedWindow
;
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
83 // Raise the window to the top of the Z order
85 // Lower the window to the bottom of the Z order
87 // Set the focus to this window
88 virtual void SetFocus();
89 // Warp the pointer the given position
90 virtual void WarpPointer(int x_pos
, int y_pos
) ;
91 // Send the window a refresh event
92 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
95 // Set/get the window's font
96 virtual bool SetFont(const wxFont
& f
);
97 // inline virtual wxFont& GetFont() const;
99 virtual int GetCharHeight() const;
100 virtual int GetCharWidth() const;
101 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
103 int *externalLeading
= NULL
,
104 const wxFont
*theFont
= NULL
) const;
106 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
107 int range
, bool refresh
= TRUE
);
108 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
109 virtual int GetScrollPos(int orient
) const;
110 virtual int GetScrollThumb(int orient
) const;
111 virtual int GetScrollRange(int orient
) const;
112 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
113 // Get the private handle (platform-dependent)
114 virtual WXWidget
GetHandle() const;
115 // Convert client to screen coordinates
116 virtual void DoClientToScreen(int *x
, int *y
) const;
117 // Convert screen to client coordinates
118 virtual void DoScreenToClient(int *x
, int *y
) const;
119 // Capture/release mouse
120 virtual void DoCaptureMouse();
121 virtual void DoReleaseMouse();
122 // Get window position, relative to parent (or screen if no parent)
123 virtual void DoGetPosition(int *x
, int *y
) const;
124 // Get overall window size
125 virtual void DoGetSize(int *width
, int *height
) const;
126 // Get/set client (application-useable) size
127 virtual void DoGetClientSize(int *width
, int *height
) const;
128 virtual void DoSetClientSize(int width
, int size
);
129 // Set overall size and position
130 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
131 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
133 virtual bool DoPopupMenu(wxMenu
*menu
, int x
, int y
);
135 /* Other implementation */
137 // NOTE: typically Close() is not virtual, but we want this for Cocoa
138 virtual bool Close( bool force
= false );
139 virtual bool Show( bool show
= true );
142 #endif // __WX_COCOA_WINDOW_H__