Mercurial > projects > dstep
comparison dstep/appkit/NSColorPanel.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSColorPanel; | |
8 | |
9 import dstep.appkit.NSApplication; | |
10 import dstep.appkit.NSColor; | |
11 import dstep.appkit.NSColorList; | |
12 import dstep.appkit.NSEvent; | |
13 import dstep.appkit.NSPanel; | |
14 import dstep.appkit.NSView; | |
15 import dstep.applicationservices.coregraphics.CGBase; | |
16 import dstep.foundation.NSArray; | |
17 import dstep.foundation.NSObjCRuntime; | |
18 import dstep.foundation.NSString; | |
19 import dstep.objc.bridge.Bridge; | |
20 import dstep.objc.objc; | |
21 | |
22 import bindings = dstep.appkit.NSColorPanel_bindings; | |
23 | |
24 alias NSInteger NSColorPanelMode; | |
25 | |
26 private | |
27 { | |
28 NSString NSColorPanelColorDidChangeNotification_; | |
29 } | |
30 | |
31 NSString NSColorPanelColorDidChangeNotification () | |
32 { | |
33 if (NSColorPanelColorDidChangeNotification_) | |
34 return NSColorPanelColorDidChangeNotification_; | |
35 | |
36 return NSColorPanelColorDidChangeNotification_ = new NSString(bindings.NSColorPanelColorDidChangeNotification); | |
37 } | |
38 | |
39 enum | |
40 { | |
41 NSNoModeColorPanel = -1, | |
42 NSGrayModeColorPanel = 0, | |
43 NSRGBModeColorPanel = 1, | |
44 NSCMYKModeColorPanel = 2, | |
45 NSHSBModeColorPanel = 3, | |
46 NSCustomPaletteModeColorPanel = 4, | |
47 NSColorListModeColorPanel = 5, | |
48 NSWheelModeColorPanel = 6, | |
49 NSCrayonModeColorPanel = 7 | |
50 } | |
51 | |
52 enum | |
53 { | |
54 NSColorPanelGrayModeMask = 0x00000001, | |
55 NSColorPanelRGBModeMask = 0x00000002, | |
56 NSColorPanelCMYKModeMask = 0x00000004, | |
57 NSColorPanelHSBModeMask = 0x00000008, | |
58 NSColorPanelCustomPaletteModeMask = 0x00000010, | |
59 NSColorPanelColorListModeMask = 0x00000020, | |
60 NSColorPanelWheelModeMask = 0x00000040, | |
61 NSColorPanelCrayonModeMask = 0x00000080, | |
62 NSColorPanelAllModesMask = 0x0000ffff | |
63 } | |
64 | |
65 class NSColorPanel : NSPanel | |
66 { | |
67 mixin (ObjcWrap); | |
68 | |
69 static NSColorPanel sharedColorPanel () | |
70 { | |
71 return invokeObjcSelfClass!(NSColorPanel, "sharedColorPanel"); | |
72 } | |
73 | |
74 static bool sharedColorPanelExists () | |
75 { | |
76 return invokeObjcSelfClass!(bool, "sharedColorPanelExists"); | |
77 } | |
78 | |
79 static bool dragColor (NSColor color, NSEvent theEvent, NSView sourceView) | |
80 { | |
81 return invokeObjcSelfClass!(bool, "dragColor:withEvent:fromView:", NSColor, NSEvent, NSView)(color, theEvent, sourceView); | |
82 } | |
83 | |
84 static void setPickerMask (NSUInteger mask) | |
85 { | |
86 return invokeObjcSelfClass!(void, "setPickerMask:", NSUInteger)(mask); | |
87 } | |
88 | |
89 static void setPickerMode (int mode) | |
90 { | |
91 return invokeObjcSelfClass!(void, "setPickerMode:", int)(mode); | |
92 } | |
93 | |
94 void setAccessoryView (NSView aView) | |
95 { | |
96 return invokeObjcSelf!(void, "setAccessoryView:", NSView)(aView); | |
97 } | |
98 | |
99 NSView accessoryView () | |
100 { | |
101 return invokeObjcSelf!(NSView, "accessoryView"); | |
102 } | |
103 | |
104 void setContinuous (bool flag) | |
105 { | |
106 return invokeObjcSelf!(void, "setContinuous:", bool)(flag); | |
107 } | |
108 | |
109 bool isContinuous () | |
110 { | |
111 return invokeObjcSelf!(bool, "isContinuous"); | |
112 } | |
113 | |
114 void setShowsAlpha (bool flag) | |
115 { | |
116 return invokeObjcSelf!(void, "setShowsAlpha:", bool)(flag); | |
117 } | |
118 | |
119 bool showsAlpha () | |
120 { | |
121 return invokeObjcSelf!(bool, "showsAlpha"); | |
122 } | |
123 | |
124 void setMode (int mode) | |
125 { | |
126 return invokeObjcSelf!(void, "setMode:", int)(mode); | |
127 } | |
128 | |
129 int mode () | |
130 { | |
131 return invokeObjcSelf!(int, "mode"); | |
132 } | |
133 | |
134 void setColor (NSColor color) | |
135 { | |
136 return invokeObjcSelf!(void, "setColor:", NSColor)(color); | |
137 } | |
138 | |
139 NSColor color () | |
140 { | |
141 return invokeObjcSelf!(NSColor, "color"); | |
142 } | |
143 | |
144 CGFloat alpha () | |
145 { | |
146 return invokeObjcSelf!(CGFloat, "alpha"); | |
147 } | |
148 | |
149 void setAction (SEL aSelector) | |
150 { | |
151 return invokeObjcSelf!(void, "setAction:", SEL)(aSelector); | |
152 } | |
153 | |
154 void setTarget (Object anObject) | |
155 { | |
156 return invokeObjcSelf!(void, "setTarget:", Object)(anObject); | |
157 } | |
158 | |
159 void attachColorList (NSColorList colorList) | |
160 { | |
161 return invokeObjcSelf!(void, "attachColorList:", NSColorList)(colorList); | |
162 } | |
163 | |
164 void detachColorList (NSColorList colorList) | |
165 { | |
166 return invokeObjcSelf!(void, "detachColorList:", NSColorList)(colorList); | |
167 } | |
168 } | |
169 | |
170 const TNSColorPanelResponderMethod = ` | |
171 | |
172 void changeColor (Object sender) | |
173 { | |
174 return invokeObjcSelf!(void, "changeColor:", Object)(sender); | |
175 } | |
176 | |
177 //mixin ObjcBindMethod!(changeColor, "changeColor:"); | |
178 | |
179 `; | |
180 | |
181 const TNSColorPanel = ` | |
182 | |
183 void orderFrontColorPanel (Object sender) | |
184 { | |
185 return invokeObjcSelf!(void, "orderFrontColorPanel:", Object)(sender); | |
186 } | |
187 | |
188 //mixin ObjcBindMethod!(orderFrontColorPanel, "orderFrontColorPanel:"); | |
189 | |
190 `; | |
191 |