1 /*******************************************************************************
2  * Copyright (c) 2000, 2019 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 NSImage extends NSObject {
17 
NSImage()18 public NSImage() {
19 	super();
20 }
21 
NSImage(long id)22 public NSImage(long id) {
23 	super(id);
24 }
25 
NSImage(id id)26 public NSImage(id id) {
27 	super(id);
28 }
29 
TIFFRepresentation()30 public NSData TIFFRepresentation() {
31 	long result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentation);
32 	return result != 0 ? new NSData(result) : null;
33 }
34 
addRepresentation(NSImageRep imageRep)35 public void addRepresentation(NSImageRep imageRep) {
36 	OS.objc_msgSend(this.id, OS.sel_addRepresentation_, imageRep != null ? imageRep.id : 0);
37 }
38 
bestRepresentationForDevice(NSDictionary deviceDescription)39 public NSImageRep bestRepresentationForDevice(NSDictionary deviceDescription) {
40 	long result = OS.objc_msgSend(this.id, OS.sel_bestRepresentationForDevice_, deviceDescription != null ? deviceDescription.id : 0);
41 	return result != 0 ? new NSImageRep(result) : null;
42 }
43 
drawInRect(NSRect rect, NSRect fromRect, long op, double delta)44 public void drawInRect(NSRect rect, NSRect fromRect, long op, double delta) {
45 	OS.objc_msgSend(this.id, OS.sel_drawInRect_fromRect_operation_fraction_, rect, fromRect, op, delta);
46 }
47 
imageNamed(NSString name)48 public static NSImage imageNamed(NSString name) {
49 	long result = OS.objc_msgSend(OS.class_NSImage, OS.sel_imageNamed_, name != null ? name.id : 0);
50 	return result != 0 ? new NSImage(result) : null;
51 }
52 
initByReferencingFile(NSString fileName)53 public NSImage initByReferencingFile(NSString fileName) {
54 	long result = OS.objc_msgSend(this.id, OS.sel_initByReferencingFile_, fileName != null ? fileName.id : 0);
55 	return result == this.id ? this : (result != 0 ? new NSImage(result) : null);
56 }
57 
initWithContentsOfFile(NSString fileName)58 public NSImage initWithContentsOfFile(NSString fileName) {
59 	long result = OS.objc_msgSend(this.id, OS.sel_initWithContentsOfFile_, fileName != null ? fileName.id : 0);
60 	return result == this.id ? this : (result != 0 ? new NSImage(result) : null);
61 }
62 
initWithData(NSData data)63 public NSImage initWithData(NSData data) {
64 	long result = OS.objc_msgSend(this.id, OS.sel_initWithData_, data != null ? data.id : 0);
65 	return result == this.id ? this : (result != 0 ? new NSImage(result) : null);
66 }
67 
initWithIconRef(long iconRef)68 public NSImage initWithIconRef(long iconRef) {
69 	long result = OS.objc_msgSend(this.id, OS.sel_initWithIconRef_, iconRef);
70 	return result == this.id ? this : (result != 0 ? new NSImage(result) : null);
71 }
72 
initWithSize(NSSize aSize)73 public NSImage initWithSize(NSSize aSize) {
74 	long result = OS.objc_msgSend(this.id, OS.sel_initWithSize_, aSize);
75 	return result == this.id ? this : (result != 0 ? new NSImage(result) : null);
76 }
77 
lockFocus()78 public void lockFocus() {
79 	OS.objc_msgSend(this.id, OS.sel_lockFocus);
80 }
81 
removeRepresentation(NSImageRep imageRep)82 public void removeRepresentation(NSImageRep imageRep) {
83 	OS.objc_msgSend(this.id, OS.sel_removeRepresentation_, imageRep != null ? imageRep.id : 0);
84 }
85 
representations()86 public NSArray representations() {
87 	long result = OS.objc_msgSend(this.id, OS.sel_representations);
88 	return result != 0 ? new NSArray(result) : null;
89 }
90 
setCacheMode(long cacheMode)91 public void setCacheMode(long cacheMode) {
92 	OS.objc_msgSend(this.id, OS.sel_setCacheMode_, cacheMode);
93 }
94 
setScalesWhenResized(boolean flag)95 public void setScalesWhenResized(boolean flag) {
96 	OS.objc_msgSend(this.id, OS.sel_setScalesWhenResized_, flag);
97 }
98 
setSize(NSSize size)99 public void setSize(NSSize size) {
100 	OS.objc_msgSend(this.id, OS.sel_setSize_, size);
101 }
102 
size()103 public NSSize size() {
104 	NSSize result = new NSSize();
105 	OS.objc_msgSend_stret(result, this.id, OS.sel_size);
106 	return result;
107 }
108 
unlockFocus()109 public void unlockFocus() {
110 	OS.objc_msgSend(this.id, OS.sel_unlockFocus);
111 }
112 
113 }
114