1 /*******************************************************************************
2  * Copyright (c) 2000, 2020 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *    IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.internal.cocoa;
15 
16 public class NSView extends NSResponder {
17 
NSView()18 public NSView() {
19 	super();
20 }
21 
NSView(long id)22 public NSView(long id) {
23 	super(id);
24 }
25 
NSView(id id)26 public NSView(id id) {
27 	super(id);
28 }
29 
acceptsFirstMouse(NSEvent theEvent)30 public boolean acceptsFirstMouse(NSEvent theEvent) {
31 	return OS.objc_msgSend_bool(this.id, OS.sel_acceptsFirstMouse_, theEvent != null ? theEvent.id : 0);
32 }
33 
addSubview(NSView aView)34 public void addSubview(NSView aView) {
35 	OS.objc_msgSend(this.id, OS.sel_addSubview_, aView != null ? aView.id : 0);
36 }
37 
addSubview(NSView aView, long place, NSView otherView)38 public void addSubview(NSView aView, long place, NSView otherView) {
39 	OS.objc_msgSend(this.id, OS.sel_addSubview_positioned_relativeTo_, aView != null ? aView.id : 0, place, otherView != null ? otherView.id : 0);
40 }
41 
addToolTipRect(NSRect aRect, id anObject, long data)42 public long addToolTipRect(NSRect aRect, id anObject, long data) {
43 	return OS.objc_msgSend(this.id, OS.sel_addToolTipRect_owner_userData_, aRect, anObject != null ? anObject.id : 0, data);
44 }
45 
beginDocument()46 public void beginDocument() {
47 	OS.objc_msgSend(this.id, OS.sel_beginDocument);
48 }
49 
beginPageInRect(NSRect aRect, NSPoint location)50 public void beginPageInRect(NSRect aRect, NSPoint location) {
51 	OS.objc_msgSend(this.id, OS.sel_beginPageInRect_atPlacement_, aRect, location);
52 }
53 
bitmapImageRepForCachingDisplayInRect(NSRect rect)54 public NSBitmapImageRep bitmapImageRepForCachingDisplayInRect(NSRect rect) {
55 	long result = OS.objc_msgSend(this.id, OS.sel_bitmapImageRepForCachingDisplayInRect_, rect);
56 	return result != 0 ? new NSBitmapImageRep(result) : null;
57 }
58 
bounds()59 public NSRect bounds() {
60 	NSRect result = new NSRect();
61 	OS.objc_msgSend_stret(result, this.id, OS.sel_bounds);
62 	return result;
63 }
64 
cacheDisplayInRect(NSRect rect, NSBitmapImageRep bitmapImageRep)65 public void cacheDisplayInRect(NSRect rect, NSBitmapImageRep bitmapImageRep) {
66 	OS.objc_msgSend(this.id, OS.sel_cacheDisplayInRect_toBitmapImageRep_, rect, bitmapImageRep != null ? bitmapImageRep.id : 0);
67 }
68 
canBecomeKeyView()69 public boolean canBecomeKeyView() {
70 	return OS.objc_msgSend_bool(this.id, OS.sel_canBecomeKeyView);
71 }
72 
convertPoint_fromView_(NSPoint aPoint, NSView aView)73 public NSPoint convertPoint_fromView_(NSPoint aPoint, NSView aView) {
74 	NSPoint result = new NSPoint();
75 	OS.objc_msgSend_stret(result, this.id, OS.sel_convertPoint_fromView_, aPoint, aView != null ? aView.id : 0);
76 	return result;
77 }
78 
convertPoint_toView_(NSPoint aPoint, NSView aView)79 public NSPoint convertPoint_toView_(NSPoint aPoint, NSView aView) {
80 	NSPoint result = new NSPoint();
81 	OS.objc_msgSend_stret(result, this.id, OS.sel_convertPoint_toView_, aPoint, aView != null ? aView.id : 0);
82 	return result;
83 }
84 
convertRect_fromView_(NSRect aRect, NSView aView)85 public NSRect convertRect_fromView_(NSRect aRect, NSView aView) {
86 	NSRect result = new NSRect();
87 	OS.objc_msgSend_stret(result, this.id, OS.sel_convertRect_fromView_, aRect, aView != null ? aView.id : 0);
88 	return result;
89 }
90 
convertRect_toView_(NSRect aRect, NSView aView)91 public NSRect convertRect_toView_(NSRect aRect, NSView aView) {
92 	NSRect result = new NSRect();
93 	OS.objc_msgSend_stret(result, this.id, OS.sel_convertRect_toView_, aRect, aView != null ? aView.id : 0);
94 	return result;
95 }
96 
discardCursorRects()97 public void discardCursorRects() {
98 	OS.objc_msgSend(this.id, OS.sel_discardCursorRects);
99 }
100 
display()101 public void display() {
102 	OS.objc_msgSend(this.id, OS.sel_display);
103 }
104 
displayIfNeeded()105 public void displayIfNeeded() {
106 	OS.objc_msgSend(this.id, OS.sel_displayIfNeeded);
107 }
108 
displayRectIgnoringOpacity(NSRect aRect, NSGraphicsContext context)109 public void displayRectIgnoringOpacity(NSRect aRect, NSGraphicsContext context) {
110 	OS.objc_msgSend(this.id, OS.sel_displayRectIgnoringOpacity_inContext_, aRect, context != null ? context.id : 0);
111 }
112 
dragImage(NSImage anImage, NSPoint viewLocation, NSSize initialOffset, NSEvent event, NSPasteboard pboard, id sourceObj, boolean slideFlag)113 public void dragImage(NSImage anImage, NSPoint viewLocation, NSSize initialOffset, NSEvent event, NSPasteboard pboard, id sourceObj, boolean slideFlag) {
114 	OS.objc_msgSend(this.id, OS.sel_dragImage_at_offset_event_pasteboard_source_slideBack_, anImage != null ? anImage.id : 0, viewLocation, initialOffset, event != null ? event.id : 0, pboard != null ? pboard.id : 0, sourceObj != null ? sourceObj.id : 0, slideFlag);
115 }
116 
drawRect(NSRect dirtyRect)117 public void drawRect(NSRect dirtyRect) {
118 	OS.objc_msgSend(this.id, OS.sel_drawRect_, dirtyRect);
119 }
120 
endDocument()121 public void endDocument() {
122 	OS.objc_msgSend(this.id, OS.sel_endDocument);
123 }
124 
endPage()125 public void endPage() {
126 	OS.objc_msgSend(this.id, OS.sel_endPage);
127 }
128 
frame()129 public NSRect frame() {
130 	NSRect result = new NSRect();
131 	OS.objc_msgSend_stret(result, this.id, OS.sel_frame);
132 	return result;
133 }
134 
hitTest(NSPoint aPoint)135 public NSView hitTest(NSPoint aPoint) {
136 	long result = OS.objc_msgSend(this.id, OS.sel_hitTest_, aPoint);
137 	return result == this.id ? this : (result != 0 ? new NSView(result) : null);
138 }
139 
initWithFrame(NSRect frameRect)140 public NSView initWithFrame(NSRect frameRect) {
141 	long result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_, frameRect);
142 	return result == this.id ? this : (result != 0 ? new NSView(result) : null);
143 }
144 
isDescendantOf(NSView aView)145 public boolean isDescendantOf(NSView aView) {
146 	return OS.objc_msgSend_bool(this.id, OS.sel_isDescendantOf_, aView != null ? aView.id : 0);
147 }
148 
isFlipped()149 public boolean isFlipped() {
150 	return OS.objc_msgSend_bool(this.id, OS.sel_isFlipped);
151 }
152 
isHidden()153 public boolean isHidden() {
154 	return OS.objc_msgSend_bool(this.id, OS.sel_isHidden);
155 }
156 
isHiddenOrHasHiddenAncestor()157 public boolean isHiddenOrHasHiddenAncestor() {
158 	return OS.objc_msgSend_bool(this.id, OS.sel_isHiddenOrHasHiddenAncestor);
159 }
160 
isOpaque()161 public boolean isOpaque() {
162 	return OS.objc_msgSend_bool(this.id, OS.sel_isOpaque);
163 }
164 
lockFocus()165 public void lockFocus() {
166 	OS.objc_msgSend(this.id, OS.sel_lockFocus);
167 }
168 
lockFocusIfCanDraw()169 public boolean lockFocusIfCanDraw() {
170 	return OS.objc_msgSend_bool(this.id, OS.sel_lockFocusIfCanDraw);
171 }
172 
menuForEvent(NSEvent event)173 public NSMenu menuForEvent(NSEvent event) {
174 	long result = OS.objc_msgSend(this.id, OS.sel_menuForEvent_, event != null ? event.id : 0);
175 	return result != 0 ? new NSMenu(result) : null;
176 }
177 
mouse(NSPoint aPoint, NSRect aRect)178 public boolean mouse(NSPoint aPoint, NSRect aRect) {
179 	return OS.objc_msgSend_bool(this.id, OS.sel_mouse_inRect_, aPoint, aRect);
180 }
181 
mouseDownCanMoveWindow()182 public boolean mouseDownCanMoveWindow() {
183 	return OS.objc_msgSend_bool(this.id, OS.sel_mouseDownCanMoveWindow);
184 }
185 
needsPanelToBecomeKey()186 public boolean needsPanelToBecomeKey() {
187 	return OS.objc_msgSend_bool(this.id, OS.sel_needsPanelToBecomeKey);
188 }
189 
registerForDraggedTypes(NSArray newTypes)190 public void registerForDraggedTypes(NSArray newTypes) {
191 	OS.objc_msgSend(this.id, OS.sel_registerForDraggedTypes_, newTypes != null ? newTypes.id : 0);
192 }
193 
removeFromSuperview()194 public void removeFromSuperview() {
195 	OS.objc_msgSend(this.id, OS.sel_removeFromSuperview);
196 }
197 
removeToolTip(long tag)198 public void removeToolTip(long tag) {
199 	OS.objc_msgSend(this.id, OS.sel_removeToolTip_, tag);
200 }
201 
removeTrackingArea(NSTrackingArea trackingArea)202 public void removeTrackingArea(NSTrackingArea trackingArea) {
203 	OS.objc_msgSend(this.id, OS.sel_removeTrackingArea_, trackingArea != null ? trackingArea.id : 0);
204 }
205 
resetCursorRects()206 public void resetCursorRects() {
207 	OS.objc_msgSend(this.id, OS.sel_resetCursorRects);
208 }
209 
scrollClipView(NSClipView aClipView, NSPoint aPoint)210 public void scrollClipView(NSClipView aClipView, NSPoint aPoint) {
211 	OS.objc_msgSend(this.id, OS.sel_scrollClipView_toPoint_, aClipView != null ? aClipView.id : 0, aPoint);
212 }
213 
scrollPoint(NSPoint aPoint)214 public void scrollPoint(NSPoint aPoint) {
215 	OS.objc_msgSend(this.id, OS.sel_scrollPoint_, aPoint);
216 }
217 
scrollRect(NSRect aRect, NSSize delta)218 public void scrollRect(NSRect aRect, NSSize delta) {
219 	OS.objc_msgSend(this.id, OS.sel_scrollRect_by_, aRect, delta);
220 }
221 
setAcceptsTouchEvents(boolean acceptsTouchEvents)222 public void setAcceptsTouchEvents(boolean acceptsTouchEvents) {
223 	OS.objc_msgSend(this.id, OS.sel_setAcceptsTouchEvents_, acceptsTouchEvents);
224 }
225 
setAutoresizesSubviews(boolean autoresizesSubviews)226 public void setAutoresizesSubviews(boolean autoresizesSubviews) {
227 	OS.objc_msgSend(this.id, OS.sel_setAutoresizesSubviews_, autoresizesSubviews);
228 }
229 
setAutoresizingMask(long autoresizingMask)230 public void setAutoresizingMask(long autoresizingMask) {
231 	OS.objc_msgSend(this.id, OS.sel_setAutoresizingMask_, autoresizingMask);
232 }
233 
setBoundsRotation(double boundsRotation)234 public void setBoundsRotation(double boundsRotation) {
235 	OS.objc_msgSend(this.id, OS.sel_setBoundsRotation_, boundsRotation);
236 }
237 
setBoundsSize(NSSize newSize)238 public void setBoundsSize(NSSize newSize) {
239 	OS.objc_msgSend(this.id, OS.sel_setBoundsSize_, newSize);
240 }
241 
setFocusRingType(long focusRingType)242 public void setFocusRingType(long focusRingType) {
243 	OS.objc_msgSend(this.id, OS.sel_setFocusRingType_, focusRingType);
244 }
245 
setFrame(NSRect frame)246 public void setFrame(NSRect frame) {
247 	OS.objc_msgSend(this.id, OS.sel_setFrame_, frame);
248 }
249 
setFrameOrigin(NSPoint newOrigin)250 public void setFrameOrigin(NSPoint newOrigin) {
251 	OS.objc_msgSend(this.id, OS.sel_setFrameOrigin_, newOrigin);
252 }
253 
setFrameSize(NSSize newSize)254 public void setFrameSize(NSSize newSize) {
255 	OS.objc_msgSend(this.id, OS.sel_setFrameSize_, newSize);
256 }
257 
setHidden(boolean hidden)258 public void setHidden(boolean hidden) {
259 	OS.objc_msgSend(this.id, OS.sel_setHidden_, hidden);
260 }
261 
setNeedsDisplay(boolean needsDisplay)262 public void setNeedsDisplay(boolean needsDisplay) {
263 	OS.objc_msgSend(this.id, OS.sel_setNeedsDisplay_, needsDisplay);
264 }
265 
setNeedsDisplayInRect(NSRect invalidRect)266 public void setNeedsDisplayInRect(NSRect invalidRect) {
267 	OS.objc_msgSend(this.id, OS.sel_setNeedsDisplayInRect_, invalidRect);
268 }
269 
setToolTip(NSString toolTip)270 public void setToolTip(NSString toolTip) {
271 	OS.objc_msgSend(this.id, OS.sel_setToolTip_, toolTip != null ? toolTip.id : 0);
272 }
273 
setWantsRestingTouches(boolean wantsRestingTouches)274 public void setWantsRestingTouches(boolean wantsRestingTouches) {
275 	OS.objc_msgSend(this.id, OS.sel_setWantsRestingTouches_, wantsRestingTouches);
276 }
277 
shouldDelayWindowOrderingForEvent(NSEvent theEvent)278 public boolean shouldDelayWindowOrderingForEvent(NSEvent theEvent) {
279 	return OS.objc_msgSend_bool(this.id, OS.sel_shouldDelayWindowOrderingForEvent_, theEvent != null ? theEvent.id : 0);
280 }
281 
subviews()282 public NSArray subviews() {
283 	long result = OS.objc_msgSend(this.id, OS.sel_subviews);
284 	return result != 0 ? new NSArray(result) : null;
285 }
286 
superview()287 public NSView superview() {
288 	long result = OS.objc_msgSend(this.id, OS.sel_superview);
289 	return result == this.id ? this : (result != 0 ? new NSView(result) : null);
290 }
291 
trackingAreas()292 public NSArray trackingAreas() {
293 	long result = OS.objc_msgSend(this.id, OS.sel_trackingAreas);
294 	return result != 0 ? new NSArray(result) : null;
295 }
296 
unlockFocus()297 public void unlockFocus() {
298 	OS.objc_msgSend(this.id, OS.sel_unlockFocus);
299 }
300 
unregisterDraggedTypes()301 public void unregisterDraggedTypes() {
302 	OS.objc_msgSend(this.id, OS.sel_unregisterDraggedTypes);
303 }
304 
updateTrackingAreas()305 public void updateTrackingAreas() {
306 	OS.objc_msgSend(this.id, OS.sel_updateTrackingAreas);
307 }
308 
viewDidMoveToWindow()309 public void viewDidMoveToWindow() {
310 	OS.objc_msgSend(this.id, OS.sel_viewDidMoveToWindow);
311 }
312 
viewWillMoveToWindow(NSWindow newWindow)313 public void viewWillMoveToWindow(NSWindow newWindow) {
314 	OS.objc_msgSend(this.id, OS.sel_viewWillMoveToWindow_, newWindow != null ? newWindow.id : 0);
315 }
316 
visibleRect()317 public NSRect visibleRect() {
318 	NSRect result = new NSRect();
319 	OS.objc_msgSend_stret(result, this.id, OS.sel_visibleRect);
320 	return result;
321 }
322 
window()323 public NSWindow window() {
324 	long result = OS.objc_msgSend(this.id, OS.sel_window);
325 	return result != 0 ? new NSWindow(result) : null;
326 }
327 
328 }
329