]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/window.h
setter fix
[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
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
d139c3a8
DE
17#ifdef __OBJC__
18 #import <Foundation/NSGeometry.h>
19#endif //def __OBJC__
20
a82b8141 21class wxWindowCocoaHider;
816c52cf 22class wxWindowCocoaScroller;
a82b8141 23
fb896a32
DE
24// ========================================================================
25// wxWindowCocoa
26// ========================================================================
27class WXDLLEXPORT wxWindowCocoa: public wxWindowBase, protected wxCocoaNSView
28{
29 DECLARE_DYNAMIC_CLASS(wxWindowCocoa)
30 DECLARE_NO_COPY_CLASS(wxWindowCocoa)
31 DECLARE_EVENT_TABLE()
b9505233 32 friend wxWindow *wxWindowBase::GetCapture();
816c52cf 33 friend class wxWindowCocoaScroller;
fb896a32
DE
34// ------------------------------------------------------------------------
35// initialization
36// ------------------------------------------------------------------------
37public:
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);
56protected:
57 void Init();
58// ------------------------------------------------------------------------
59// Cocoa specifics
60// ------------------------------------------------------------------------
61public:
a82b8141 62 // Returns the content NSView (where children are added, drawing performed)
fb896a32 63 inline WX_NSView GetNSView() { return m_cocoaNSView; }
a82b8141
DE
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;
fb896a32
DE
68 void CocoaAddChild(wxWindowCocoa *child);
69 void CocoaRemoveFromParent(void);
fb896a32 70protected:
adb4816c
DE
71 // enable==false: disables the control
72 // enable==true: enables the control IF it should be enabled
73 bool EnableSelfAndChildren(bool enable);
74 // actually enable/disable the cocoa control, overridden by subclasses
75 virtual void CocoaSetEnabled(bool enable) { }
76 // Reflects the state for THIS window (ignoring disables by parents)
77 bool m_shouldBeEnabled;
78
816c52cf 79 void CocoaCreateNSScrollView();
69dbb709 80 void InitMouseEvent(wxMouseEvent &event, WX_NSEvent cocoaEvent);
8ea5271e
DE
81 virtual void Cocoa_FrameChanged(void);
82 virtual bool Cocoa_drawRect(const NSRect &rect);
69dbb709
DE
83 virtual bool Cocoa_mouseDown(WX_NSEvent theEvent);
84 virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent);
85 virtual bool Cocoa_mouseUp(WX_NSEvent theEvent);
86 virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent);
87 virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent);
88 virtual bool Cocoa_mouseExited(WX_NSEvent theEvent);
89 virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent);
90 virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent);
91 virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent);
92 virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent);
93 virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent);
94 virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent);
fb896a32
DE
95 void SetNSView(WX_NSView cocoaNSView);
96 WX_NSView m_cocoaNSView;
a82b8141 97 wxWindowCocoaHider *m_cocoaHider;
816c52cf 98 wxWindowCocoaScroller *m_cocoaScroller;
55c5be5e 99 bool m_isInPaint;
b9505233 100 static wxWindow *sm_capturedWindow;
a82b8141 101 virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
d139c3a8
DE
102 void SetInitialFrameRect(const wxPoint& pos, const wxSize& size);
103#ifdef __OBJC__
104 inline NSRect MakeDefaultNSRect(const wxSize& size)
105 {
106 // NOTE: position is 10,10 to make it "obvious" that it's out of place
107 return NSMakeRect(10.0,10.0,WidthDefault(size.x),HeightDefault(size.y));
108 }
109#endif //def __OBJC__
fb896a32
DE
110// ------------------------------------------------------------------------
111// Implementation
112// ------------------------------------------------------------------------
113public:
114 /* Pure Virtuals */
115 // Raise the window to the top of the Z order
116 virtual void Raise();
117 // Lower the window to the bottom of the Z order
118 virtual void Lower();
119 // Set the focus to this window
120 virtual void SetFocus();
121 // Warp the pointer the given position
122 virtual void WarpPointer(int x_pos, int y_pos) ;
123 // Send the window a refresh event
124 virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
fb896a32
DE
125 // Set/get the window's font
126 virtual bool SetFont(const wxFont& f);
127// inline virtual wxFont& GetFont() const;
128 // Get character size
129 virtual int GetCharHeight() const;
130 virtual int GetCharWidth() const;
131 virtual void GetTextExtent(const wxString& string, int *x, int *y,
132 int *descent = NULL,
133 int *externalLeading = NULL,
134 const wxFont *theFont = NULL) const;
135 // Scroll stuff
136 virtual void SetScrollbar(int orient, int pos, int thumbVisible,
137 int range, bool refresh = TRUE);
138 virtual void SetScrollPos(int orient, int pos, bool refresh = TRUE);
139 virtual int GetScrollPos(int orient) const;
140 virtual int GetScrollThumb(int orient) const;
141 virtual int GetScrollRange(int orient) const;
142 virtual void ScrollWindow(int dx, int dy, const wxRect *rect = NULL);
816c52cf 143 virtual void DoSetVirtualSize(int x, int y);
fb896a32
DE
144 // Get the private handle (platform-dependent)
145 virtual WXWidget GetHandle() const;
146 // Convert client to screen coordinates
147 virtual void DoClientToScreen(int *x, int *y) const;
148 // Convert screen to client coordinates
149 virtual void DoScreenToClient(int *x, int *y) const;
150 // Capture/release mouse
151 virtual void DoCaptureMouse();
152 virtual void DoReleaseMouse();
153 // Get window position, relative to parent (or screen if no parent)
154 virtual void DoGetPosition(int *x, int *y) const;
155 // Get overall window size
156 virtual void DoGetSize(int *width, int *height) const;
157 // Get/set client (application-useable) size
158 virtual void DoGetClientSize(int *width, int *height) const;
159 virtual void DoSetClientSize(int width, int size);
e08efb8d
DE
160 // Set the size of the wxWindow (the contentView of an NSWindow)
161 // wxTopLevelWindow will override this and set the NSWindow size
162 // such that the contentView will be this size
163 virtual void CocoaSetWxWindowSize(int width, int height);
fb896a32
DE
164 // Set overall size and position
165 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
166 virtual void DoMoveWindow(int x, int y, int width, int height);
167 // Popup a menu
168 virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
169
170 /* Other implementation */
171
172 // NOTE: typically Close() is not virtual, but we want this for Cocoa
173 virtual bool Close( bool force = false );
174 virtual bool Show( bool show = true );
adb4816c 175 virtual bool Enable( bool enable = true );
fb896a32
DE
176};
177
178#endif // __WX_COCOA_WINDOW_H__