]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/window.h
makefiles update with OSX fixes
[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 // Clear the window
102 virtual void Clear();
103 // Set/get the window's font
104 virtual bool SetFont(const wxFont& f);
105 // inline virtual wxFont& GetFont() const;
106 // Get character size
107 virtual int GetCharHeight() const;
108 virtual int GetCharWidth() const;
109 virtual void GetTextExtent(const wxString& string, int *x, int *y,
110 int *descent = NULL,
111 int *externalLeading = NULL,
112 const wxFont *theFont = NULL) const;
113 // Scroll stuff
114 virtual void SetScrollbar(int orient, int pos, int thumbVisible,
115 int range, bool refresh = TRUE);
116 virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
117 virtual int GetScrollPos(int orient) const;
118 virtual int GetScrollThumb(int orient) const;
119 virtual int GetScrollRange(int orient) const;
120 virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
121 // Get the private handle (platform-dependent)
122 virtual WXWidget GetHandle() const;
123 // Convert client to screen coordinates
124 virtual void DoClientToScreen(int *x, int *y) const;
125 // Convert screen to client coordinates
126 virtual void DoScreenToClient(int *x, int *y) const;
127 // Capture/release mouse
128 virtual void DoCaptureMouse();
129 virtual void DoReleaseMouse();
130 // Get window position, relative to parent (or screen if no parent)
131 virtual void DoGetPosition(int *x, int *y) const;
132 // Get overall window size
133 virtual void DoGetSize(int *width, int *height) const;
134 // Get/set client (application-useable) size
135 virtual void DoGetClientSize(int *width, int *height) const;
136 virtual void DoSetClientSize(int width, int size);
137 // Set overall size and position
138 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
139 virtual void DoMoveWindow(int x, int y, int width, int height);
140 // Popup a menu
141 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
142
143 /* Other implementation */
144
145 // NOTE: typically Close() is not virtual, but we want this for Cocoa
146 virtual bool Close( bool force = false );
147 virtual bool Show( bool show = true );
148 };
149
150 #endif // __WX_COCOA_WINDOW_H__