]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/window.h
ef3dcb47404223bdd4f0f6daa8eccd77fbb488d1
[wxWidgets.git] / include / wx / cocoa / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cocoa/window.h
3 // Purpose: wxWindowCocoa
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2002/12/26
7 // RCS-ID: $Id:
8 // Copyright: (c) 2002 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __WX_COCOA_WINDOW_H__
13 #define __WX_COCOA_WINDOW_H__
14
15 #include "wx/cocoa/NSView.h"
16
17 class wxWindowCocoaHider;
18
19 // ========================================================================
20 // wxWindowCocoa
21 // ========================================================================
22 class WXDLLEXPORT wxWindowCocoa: public wxWindowBase, protected wxCocoaNSView
23 {
24 DECLARE_DYNAMIC_CLASS(wxWindowCocoa)
25 DECLARE_NO_COPY_CLASS(wxWindowCocoa)
26 DECLARE_EVENT_TABLE()
27 friend wxWindow *wxWindowBase::GetCapture();
28 // ------------------------------------------------------------------------
29 // initialization
30 // ------------------------------------------------------------------------
31 public:
32 wxWindowCocoa() { Init(); }
33 inline wxWindowCocoa(wxWindow *parent, wxWindowID winid,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize,
36 long style = 0,
37 const wxString& name = wxPanelNameStr)
38 {
39 Init();
40 Create(parent, winid, pos, size, style, name);
41 }
42
43 virtual ~wxWindowCocoa();
44
45 bool Create(wxWindow *parent, wxWindowID winid,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxString& name = wxPanelNameStr);
50 protected:
51 void Init();
52 // ------------------------------------------------------------------------
53 // Cocoa specifics
54 // ------------------------------------------------------------------------
55 public:
56 // Returns the content NSView (where children are added, drawing performed)
57 inline WX_NSView GetNSView() { return m_cocoaNSView; }
58 // Returns the NSView suitable for use as a subview
59 WX_NSView GetNSViewForSuperview() const;
60 // Returns the NSView that may be hidden/is being hidden
61 WX_NSView GetNSViewForHiding() const;
62 void CocoaAddChild(wxWindowCocoa *child);
63 void CocoaRemoveFromParent(void);
64 protected:
65 void InitMouseEvent(wxMouseEvent &event, WX_NSEvent cocoaEvent);
66 virtual void Cocoa_FrameChanged(void);
67 virtual bool Cocoa_drawRect(const NSRect &rect);
68 virtual bool Cocoa_mouseDown(WX_NSEvent theEvent);
69 virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent);
70 virtual bool Cocoa_mouseUp(WX_NSEvent theEvent);
71 virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent);
72 virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent);
73 virtual bool Cocoa_mouseExited(WX_NSEvent theEvent);
74 virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent);
75 virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent);
76 virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent);
77 virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent);
78 virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent);
79 virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent);
80 void SetNSView(WX_NSView cocoaNSView);
81 WX_NSView m_cocoaNSView;
82 wxWindowCocoaHider *m_cocoaHider;
83 bool m_isInPaint;
84 static wxWindow *sm_capturedWindow;
85 virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
86 // ------------------------------------------------------------------------
87 // Implementation
88 // ------------------------------------------------------------------------
89 public:
90 /* Pure Virtuals */
91 // Raise the window to the top of the Z order
92 virtual void Raise();
93 // Lower the window to the bottom of the Z order
94 virtual void Lower();
95 // Set the focus to this window
96 virtual void SetFocus();
97 // Warp the pointer the given position
98 virtual void WarpPointer(int x_pos, int y_pos) ;
99 // Send the window a refresh event
100 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
101 // Set/get the window's font
102 virtual bool SetFont(const wxFont& f);
103 // inline virtual wxFont& GetFont() const;
104 // Get character size
105 virtual int GetCharHeight() const;
106 virtual int GetCharWidth() const;
107 virtual void GetTextExtent(const wxString& string, int *x, int *y,
108 int *descent = NULL,
109 int *externalLeading = NULL,
110 const wxFont *theFont = NULL) const;
111 // Scroll stuff
112 virtual void SetScrollbar(int orient, int pos, int thumbVisible,
113 int range, bool refresh = TRUE);
114 virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
115 virtual int GetScrollPos(int orient) const;
116 virtual int GetScrollThumb(int orient) const;
117 virtual int GetScrollRange(int orient) const;
118 virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
119 // Get the private handle (platform-dependent)
120 virtual WXWidget GetHandle() const;
121 // Convert client to screen coordinates
122 virtual void DoClientToScreen(int *x, int *y) const;
123 // Convert screen to client coordinates
124 virtual void DoScreenToClient(int *x, int *y) const;
125 // Capture/release mouse
126 virtual void DoCaptureMouse();
127 virtual void DoReleaseMouse();
128 // Get window position, relative to parent (or screen if no parent)
129 virtual void DoGetPosition(int *x, int *y) const;
130 // Get overall window size
131 virtual void DoGetSize(int *width, int *height) const;
132 // Get/set client (application-useable) size
133 virtual void DoGetClientSize(int *width, int *height) const;
134 virtual void DoSetClientSize(int width, int size);
135 // Set overall size and position
136 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
137 virtual void DoMoveWindow(int x, int y, int width, int height);
138 // Popup a menu
139 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
140
141 /* Other implementation */
142
143 // NOTE: typically Close() is not virtual, but we want this for Cocoa
144 virtual bool Close( bool force = false );
145 virtual bool Show( bool show = true );
146 };
147
148 #endif // __WX_COCOA_WINDOW_H__