comparison dwt/internal/cocoa/NSColorPanel.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSColorPanel; 14 module dwt.internal.cocoa.NSColorPanel;
15 15
16 import dwt.internal.cocoa.CGFloat; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.id; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSColor; 18 import dwt.internal.cocoa.NSColor;
19 import dwt.internal.cocoa.NSColorList;
20 import dwt.internal.cocoa.NSEvent;
21 import dwt.internal.cocoa.NSInteger;
22 import dwt.internal.cocoa.NSPanel; 19 import dwt.internal.cocoa.NSPanel;
23 import dwt.internal.cocoa.NSView;
24 import dwt.internal.cocoa.OS; 20 import dwt.internal.cocoa.OS;
25 import objc = dwt.internal.objc.runtime; 21 import objc = dwt.internal.objc.runtime;
26 22
27 alias NSInteger NSColorPanelMode; 23 public class NSColorPanel : NSPanel {
28 24
29 public class NSColorPanel : NSPanel 25 public this() {
30 { 26 super();
27 }
31 28
32 public this () 29 public this(objc.id id) {
33 { 30 super(id);
34 super(); 31 }
35 }
36 32
37 public this (objc.id id) 33 public this(cocoa.id id) {
38 { 34 super(id);
39 super(id); 35 }
40 }
41 36
42 public NSView accessoryView () 37 public NSColor color() {
43 { 38 objc.id result = OS.objc_msgSend(this.id, OS.sel_color);
44 objc.id result = OS.objc_msgSend(this.id_, OS.sel_accessoryView); 39 return result !is null ? new NSColor(result) : null;
45 return result !is null ? new NSView(result) : null; 40 }
46 }
47 41
48 public CGFloat alpha () 42 public void setColor(NSColor color) {
49 { 43 OS.objc_msgSend(this.id, OS.sel_setColor_, color !is null ? color.id : null);
50 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_alpha); 44 }
51 }
52 45
53 public void attachColorList (NSColorList colorList) 46 public static NSColorPanel sharedColorPanel() {
54 { 47 objc.id result = OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanel);
55 OS.objc_msgSend(this.id_, OS.sel_attachColorList_1, colorList !is null ? colorList.id_ : null); 48 return result !is null ? new NSColorPanel(result) : null;
56 } 49 }
57
58 public NSColor color ()
59 {
60 objc.id result = OS.objc_msgSend(this.id_, OS.sel_color);
61 return result !is null ? new NSColor(result) : null;
62 }
63
64 public void detachColorList (NSColorList colorList)
65 {
66 OS.objc_msgSend(this.id_, OS.sel_detachColorList_1, colorList !is null ? colorList.id_ : null);
67 }
68
69 public static bool dragColor (NSColor color, NSEvent theEvent, NSView sourceView)
70 {
71 return OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_dragColor_1withEvent_1fromView_1, color !is null ? color.id_ : null,
72 theEvent !is null ? theEvent.id_ : null, sourceView !is null ? sourceView.id_ : null) !is null;
73 }
74
75 public bool isContinuous ()
76 {
77 return OS.objc_msgSend(this.id_, OS.sel_isContinuous) !is null;
78 }
79
80 public objc.id mode ()
81 {
82 return OS.objc_msgSend(this.id_, OS.sel_mode);
83 }
84
85 public void setAccessoryView (NSView aView)
86 {
87 OS.objc_msgSend(this.id_, OS.sel_setAccessoryView_1, aView !is null ? aView.id_ : null);
88 }
89
90 public void setAction (objc.SEL aSelector)
91 {
92 OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector);
93 }
94
95 public void setColor (NSColor color)
96 {
97 OS.objc_msgSend(this.id_, OS.sel_setColor_1, color !is null ? color.id_ : null);
98 }
99
100 public void setContinuous (bool flag)
101 {
102 OS.objc_msgSend(this.id_, OS.sel_setContinuous_1, flag);
103 }
104
105 public void setMode (objc.id mode)
106 {
107 OS.objc_msgSend(this.id_, OS.sel_setMode_1, mode);
108 }
109
110 public static void setPickerMask (NSUInteger mask)
111 {
112 OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_setPickerMask_1, mask);
113 }
114
115 public static void setPickerMode (NSColorPanelMode mode)
116 {
117 OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_setPickerMode_1, mode);
118 }
119
120 public void setShowsAlpha (bool flag)
121 {
122 OS.objc_msgSend(this.id_, OS.sel_setShowsAlpha_1, flag);
123 }
124
125 public void setTarget (id anObject)
126 {
127 OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null);
128 }
129
130 public static NSColorPanel sharedColorPanel ()
131 {
132 objc.id result = OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanel);
133 return result !is null ? new NSColorPanel(result) : null;
134 }
135
136 public static bool sharedColorPanelExists ()
137 {
138 return OS.objc_msgSend(OS.class_NSColorPanel, OS.sel_sharedColorPanelExists) !is null;
139 }
140
141 public bool showsAlpha ()
142 {
143 return OS.objc_msgSend(this.id_, OS.sel_showsAlpha) !is null;
144 }
145 50
146 } 51 }