]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/window.h
wxTheApp can't be assigned to any longer
[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 // ========================================================================
18 // wxWindowCocoa
19 // ========================================================================
20 class WXDLLEXPORT wxWindowCocoa: public wxWindowBase, protected wxCocoaNSView
21 {
22 DECLARE_DYNAMIC_CLASS(wxWindowCocoa)
23 DECLARE_NO_COPY_CLASS(wxWindowCocoa)
24 DECLARE_EVENT_TABLE()
25 friend wxWindow *wxWindowBase::GetCapture();
26 // ------------------------------------------------------------------------
27 // initialization
28 // ------------------------------------------------------------------------
29 public:
30 wxWindowCocoa() { Init(); }
31 inline wxWindowCocoa(wxWindow *parent, wxWindowID winid,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 long style = 0,
35 const wxString& name = wxPanelNameStr)
36 {
37 Init();
38 Create(parent, winid, pos, size, style, name);
39 }
40
41 virtual ~wxWindowCocoa();
42
43 bool Create(wxWindow *parent, wxWindowID winid,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0,
47 const wxString& name = wxPanelNameStr);
48 protected:
49 void Init();
50 // ------------------------------------------------------------------------
51 // Cocoa specifics
52 // ------------------------------------------------------------------------
53 public:
54 inline WX_NSView GetNSView() { return m_cocoaNSView; }
55 void CocoaAddChild(wxWindowCocoa *child);
56 void CocoaRemoveFromParent(void);
57 protected:
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;
76 bool m_isInPaint;
77 static wxWindow *sm_capturedWindow;
78 // ------------------------------------------------------------------------
79 // Implementation
80 // ------------------------------------------------------------------------
81 public:
82 /* Pure Virtuals */
83 // Raise the window to the top of the Z order
84 virtual void Raise();
85 // Lower the window to the bottom of the Z order
86 virtual void Lower();
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);
93 // Clear the window
94 virtual void Clear();
95 // Set/get the window's font
96 virtual bool SetFont(const wxFont& f);
97 // inline virtual wxFont& GetFont() const;
98 // Get character size
99 virtual int GetCharHeight() const;
100 virtual int GetCharWidth() const;
101 virtual void GetTextExtent(const wxString& string, int *x, int *y,
102 int *descent = NULL,
103 int *externalLeading = NULL,
104 const wxFont *theFont = NULL) const;
105 // Scroll stuff
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);
132 // Popup a menu
133 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
134
135 /* Other implementation */
136
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 );
140 };
141
142 #endif // __WX_COCOA_WINDOW_H__