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