]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/window.h
remove miniframe stuff from GtkOnSize(), it's handled by wxFrame
[wxWidgets.git] / include / wx / cocoa / window.h
CommitLineData
fb896a32
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/cocoa/window.h
3// Purpose: wxWindowCocoa
4// Author: David Elliott
5// Modified by:
6// Created: 2002/12/26
8d8d3633 7// RCS-ID: $Id$
fb896a32 8// Copyright: (c) 2002 David Elliott
8d8d3633 9// Licence: wxWindows licence
fb896a32
DE
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __WX_COCOA_WINDOW_H__
13#define __WX_COCOA_WINDOW_H__
14
15#include "wx/cocoa/NSView.h"
16
d139c3a8
DE
17#ifdef __OBJC__
18 #import <Foundation/NSGeometry.h>
19#endif //def __OBJC__
20
9d208085
DE
21DECLARE_WXCOCOA_OBJC_CLASS(NSAffineTransform);
22
a82b8141 23class wxWindowCocoaHider;
f298b203 24class wxWindowCocoaScrollView;
a82b8141 25
fb896a32
DE
26// ========================================================================
27// wxWindowCocoa
28// ========================================================================
29class WXDLLEXPORT wxWindowCocoa: public wxWindowBase, protected wxCocoaNSView
30{
31 DECLARE_DYNAMIC_CLASS(wxWindowCocoa)
32 DECLARE_NO_COPY_CLASS(wxWindowCocoa)
33 DECLARE_EVENT_TABLE()
b9505233 34 friend wxWindow *wxWindowBase::GetCapture();
f298b203 35 friend class wxWindowCocoaScrollView;
fb896a32
DE
36// ------------------------------------------------------------------------
37// initialization
38// ------------------------------------------------------------------------
39public:
40 wxWindowCocoa() { Init(); }
41 inline wxWindowCocoa(wxWindow *parent, wxWindowID winid,
42 const wxPoint& pos = wxDefaultPosition,
43 const wxSize& size = wxDefaultSize,
44 long style = 0,
45 const wxString& name = wxPanelNameStr)
46 {
47 Init();
48 Create(parent, winid, pos, size, style, name);
49 }
50
51 virtual ~wxWindowCocoa();
52
53 bool Create(wxWindow *parent, wxWindowID winid,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxString& name = wxPanelNameStr);
58protected:
59 void Init();
60// ------------------------------------------------------------------------
61// Cocoa specifics
62// ------------------------------------------------------------------------
63public:
a82b8141 64 // Returns the content NSView (where children are added, drawing performed)
fb896a32 65 inline WX_NSView GetNSView() { return m_cocoaNSView; }
a82b8141
DE
66 // Returns the NSView suitable for use as a subview
67 WX_NSView GetNSViewForSuperview() const;
68 // Returns the NSView that may be hidden/is being hidden
69 WX_NSView GetNSViewForHiding() const;
514e7b7b
DE
70 // Returns the NSView for non-client drawing
71 virtual WX_NSView GetNonClientNSView() { return GetNSViewForSuperview(); }
72 // Add/remove children
fb896a32
DE
73 void CocoaAddChild(wxWindowCocoa *child);
74 void CocoaRemoveFromParent(void);
9d208085
DE
75#ifdef __OBJC__
76 // Returns an autoreleased NSAffineTransform which can be applied
77 // to a graphics context currently using the view's coordinate system
78 // (such as the one locked when drawRect is called or after a call
79 // to [NSView lockFocus]) such that further drawing is done using
80 // the wxWidgets coordinate system.
81 WX_NSAffineTransform CocoaGetWxToBoundsTransform();
82#endif //def __OBJC__
fb896a32 83protected:
adb4816c
DE
84 // actually enable/disable the cocoa control, overridden by subclasses
85 virtual void CocoaSetEnabled(bool enable) { }
adb4816c 86
816c52cf 87 void CocoaCreateNSScrollView();
69dbb709 88 void InitMouseEvent(wxMouseEvent &event, WX_NSEvent cocoaEvent);
f7e98dee 89 virtual wxWindow* GetWxWindow() const;
8ea5271e
DE
90 virtual void Cocoa_FrameChanged(void);
91 virtual bool Cocoa_drawRect(const NSRect &rect);
69dbb709
DE
92 virtual bool Cocoa_mouseDown(WX_NSEvent theEvent);
93 virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent);
94 virtual bool Cocoa_mouseUp(WX_NSEvent theEvent);
95 virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent);
96 virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent);
97 virtual bool Cocoa_mouseExited(WX_NSEvent theEvent);
98 virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent);
99 virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent);
100 virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent);
101 virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent);
102 virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent);
103 virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent);
5558135c 104 virtual bool Cocoa_resetCursorRects();
fb896a32
DE
105 void SetNSView(WX_NSView cocoaNSView);
106 WX_NSView m_cocoaNSView;
a82b8141 107 wxWindowCocoaHider *m_cocoaHider;
f298b203 108 wxWindowCocoaScrollView *m_wxCocoaScrollView;
55c5be5e 109 bool m_isInPaint;
b9505233 110 static wxWindow *sm_capturedWindow;
a82b8141 111 virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
d139c3a8
DE
112 void SetInitialFrameRect(const wxPoint& pos, const wxSize& size);
113#ifdef __OBJC__
114 inline NSRect MakeDefaultNSRect(const wxSize& size)
115 {
116 // NOTE: position is 10,10 to make it "obvious" that it's out of place
117 return NSMakeRect(10.0,10.0,WidthDefault(size.x),HeightDefault(size.y));
118 }
34c9978d
DE
119 // These functions translate NSPoint or NSRect between the coordinate
120 // system of Cocoa's boudns rect and wx's coordinate system.
121 NSPoint CocoaTransformBoundsToWx(NSPoint pointBounds);
122 NSRect CocoaTransformBoundsToWx(NSRect rectBounds);
123 NSPoint CocoaTransformWxToBounds(NSPoint pointWx);
124 NSRect CocoaTransformWxToBounds(NSRect rectWx);
d139c3a8 125#endif //def __OBJC__
fb896a32
DE
126// ------------------------------------------------------------------------
127// Implementation
128// ------------------------------------------------------------------------
129public:
130 /* Pure Virtuals */
131 // Raise the window to the top of the Z order
132 virtual void Raise();
133 // Lower the window to the bottom of the Z order
134 virtual void Lower();
135 // Set the focus to this window
136 virtual void SetFocus();
137 // Warp the pointer the given position
138 virtual void WarpPointer(int x_pos, int y_pos) ;
139 // Send the window a refresh event
8d8d3633 140 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
fb896a32
DE
141 // Set/get the window's font
142 virtual bool SetFont(const wxFont& f);
143// inline virtual wxFont& GetFont() const;
2a2d7a73
WS
144 virtual void SetLabel(const wxString& label);
145 virtual wxString GetLabel() const;
8d8d3633 146 // label handling
fb896a32
DE
147 // Get character size
148 virtual int GetCharHeight() const;
149 virtual int GetCharWidth() const;
150 virtual void GetTextExtent(const wxString& string, int *x, int *y,
151 int *descent = NULL,
152 int *externalLeading = NULL,
153 const wxFont *theFont = NULL) const;
154 // Scroll stuff
155 virtual void SetScrollbar(int orient, int pos, int thumbVisible,
8d8d3633
WS
156 int range, bool refresh = true);
157 virtual void SetScrollPos(int orient, int pos, bool refresh = true);
fb896a32
DE
158 virtual int GetScrollPos(int orient) const;
159 virtual int GetScrollThumb(int orient) const;
160 virtual int GetScrollRange(int orient) const;
161 virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
816c52cf 162 virtual void DoSetVirtualSize(int x, int y);
fb896a32
DE
163 // Get the private handle (platform-dependent)
164 virtual WXWidget GetHandle() const;
165 // Convert client to screen coordinates
166 virtual void DoClientToScreen(int *x, int *y) const;
167 // Convert screen to client coordinates
168 virtual void DoScreenToClient(int *x, int *y) const;
169 // Capture/release mouse
170 virtual void DoCaptureMouse();
171 virtual void DoReleaseMouse();
172 // Get window position, relative to parent (or screen if no parent)
173 virtual void DoGetPosition(int *x, int *y) const;
174 // Get overall window size
175 virtual void DoGetSize(int *width, int *height) const;
176 // Get/set client (application-useable) size
177 virtual void DoGetClientSize(int *width, int *height) const;
178 virtual void DoSetClientSize(int width, int size);
5558135c
RN
179 // Set this window's tooltip
180 virtual void DoSetToolTip( wxToolTip *tip );
e08efb8d
DE
181 // Set the size of the wxWindow (the contentView of an NSWindow)
182 // wxTopLevelWindow will override this and set the NSWindow size
183 // such that the contentView will be this size
184 virtual void CocoaSetWxWindowSize(int width, int height);
fb896a32
DE
185 // Set overall size and position
186 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
187 virtual void DoMoveWindow(int x, int y, int width, int height);
188 // Popup a menu
189 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
190
191 /* Other implementation */
192
193 // NOTE: typically Close() is not virtual, but we want this for Cocoa
194 virtual bool Close( bool force = false );
195 virtual bool Show( bool show = true );
47a8a4d5 196 virtual void DoEnable( bool enable );
2e992e06
VZ
197
198 virtual bool IsDoubleBuffered() const { return true; }
fb896a32
DE
199};
200
201#endif // __WX_COCOA_WINDOW_H__