comparison dstep/appkit/NSColorList.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.NSColorList;
8
9 import dstep.appkit.AppKitDefines;
10 import dstep.foundation.NSArray;
11 import dstep.appkit.NSColor;
12 import dstep.corefoundation.CFDictionary;
13 import dstep.foundation.NSArray;
14 import dstep.foundation.NSBundle;
15 import dstep.foundation.NSCoder;
16 import dstep.foundation.NSObjCRuntime;
17 import dstep.foundation.NSObject;
18 import dstep.foundation.NSString;
19 import dstep.objc.bridge.Bridge;
20 import dstep.objc.objc;
21
22 import bindings = dstep.appkit.NSColorList_bindings;
23
24 private
25 {
26 NSString NSColorListDidChangeNotification_;
27 }
28
29 NSString NSColorListDidChangeNotification ()
30 {
31 if (NSColorListDidChangeNotification_)
32 return NSColorListDidChangeNotification_;
33
34 return NSColorListDidChangeNotification_ = new NSString(bindings.NSColorListDidChangeNotification);
35 }
36
37 class NSColorList : NSObject, INSCoding
38 {
39 mixin (ObjcWrap);
40
41 this (NSCoder aDecoder)
42 {
43 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject);
44 }
45
46 void encodeWithCoder (NSCoder aCoder)
47 {
48 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
49 }
50
51 typeof(this) initWithCoder (NSCoder aDecoder)
52 {
53 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder);
54 }
55
56 static NSArray availableColorLists ()
57 {
58 return invokeObjcSelfClass!(NSArray, "availableColorLists");
59 }
60
61 static NSColorList colorListNamed (NSString name)
62 {
63 return invokeObjcSelfClass!(NSColorList, "colorListNamed:", NSString)(name);
64 }
65
66 NSColorList initWithName (NSString name)
67 {
68 id result = invokeObjcSelf!(id, "initWithName:", NSString)(name);
69 return result is this.objcObject ? this : (result !is null ? new NSColorList(result) : null);
70 }
71
72 this (NSString name)
73 {
74 super(NSColorList.alloc.initWithName(name).objcObject);
75 }
76
77 NSColorList initWithName (NSString name, NSString path)
78 {
79 id result = invokeObjcSelf!(id, "initWithName:fromFile:", NSString, NSString)(name, path);
80 return result is this.objcObject ? this : (result !is null ? new NSColorList(result) : null);
81 }
82
83 this (NSString name, NSString path)
84 {
85 super(NSColorList.alloc.initWithName(name, path).objcObject);
86 }
87
88 NSString name ()
89 {
90 return invokeObjcSelf!(NSString, "name");
91 }
92
93 void setColor (NSColor color, NSString key)
94 {
95 return invokeObjcSelf!(void, "setColor:forKey:", NSColor, NSString)(color, key);
96 }
97
98 void insertColor (NSColor color, NSString key, NSUInteger loc)
99 {
100 return invokeObjcSelf!(void, "insertColor:key:atIndex:", NSColor, NSString, NSUInteger)(color, key, loc);
101 }
102
103 void removeColorWithKey (NSString key)
104 {
105 return invokeObjcSelf!(void, "removeColorWithKey:", NSString)(key);
106 }
107
108 NSColor colorWithKey (NSString key)
109 {
110 return invokeObjcSelf!(NSColor, "colorWithKey:", NSString)(key);
111 }
112
113 NSArray allKeys ()
114 {
115 return invokeObjcSelf!(NSArray, "allKeys");
116 }
117
118 bool isEditable ()
119 {
120 return invokeObjcSelf!(bool, "isEditable");
121 }
122
123 bool writeToFile (NSString path)
124 {
125 return invokeObjcSelf!(bool, "writeToFile:", NSString)(path);
126 }
127
128 void removeFile ()
129 {
130 return invokeObjcSelf!(void, "removeFile");
131 }
132
133 }
134