comparison dwt/widgets/Canvas.d @ 51:e6f04eb518ae

Updated Canvas to 3.514
author Jacob Carlborg <doob@me.com>
date Sun, 07 Dec 2008 21:24:13 +0100
parents cfa563df4fdd
children c74ba20de292
comparison
equal deleted inserted replaced
50:30adfb32d4be 51:e6f04eb518ae
30 import dwt.internal.cocoa.NSRect; 30 import dwt.internal.cocoa.NSRect;
31 import dwt.internal.cocoa.NSSize; 31 import dwt.internal.cocoa.NSSize;
32 import dwt.internal.cocoa.OS; 32 import dwt.internal.cocoa.OS;
33 33
34 import dwt.dwthelper.utils; 34 import dwt.dwthelper.utils;
35 import dwt.internal.cocoa.NSImage; 35 import dwt.internal.objc.cocoa.Cocoa;
36 import dwt.widgets.Caret; 36 import dwt.widgets.Caret;
37 import dwt.widgets.Composite; 37 import dwt.widgets.Composite;
38 import dwt.widgets.Control; 38 import dwt.widgets.Control;
39 import dwt.widgets.IME; 39 import dwt.widgets.IME;
40 40
66 66
67 this () { 67 this () {
68 /* Do nothing */ 68 /* Do nothing */
69 } 69 }
70 70
71 int /*long*/ attributedSubstringFromRange (int /*long*/ id, int /*long*/ sel, int /*long*/ range) { 71 objc.id attributedSubstringFromRange (objc.id id, objc.SEL sel, objc.id range) {
72 if (ime !is null) return ime.attributedSubstringFromRange (id, sel, range); 72 if (ime !is null) return ime.attributedSubstringFromRange (id, sel, range);
73 return super.attributedSubstringFromRange(id, sel, range); 73 return super.attributedSubstringFromRange(id, sel, range);
74 } 74 }
75 75
76 bool becomeFirstResponder (int /*long*/ id, int /*long*/ sel) { 76 bool becomeFirstResponder (objc.id id, objc.SEL sel) {
77 if (caret !is null) caret.setFocus (); 77 if (caret !is null) caret.setFocus ();
78 return super.becomeFirstResponder(id, sel); 78 return super.becomeFirstResponder(id, sel);
79 } 79 }
80 80
81 bool resignFirstResponder (int /*long*/ id, int /*long*/ sel) { 81 bool resignFirstResponder (objc.id id, objc.SEL sel) {
82 if (caret !is null) caret.killFocus (); 82 if (caret !is null) caret.killFocus ();
83 return super.resignFirstResponder(id, sel); 83 return super.resignFirstResponder(id, sel);
84 } 84 }
85 85
86 86
113 */ 113 */
114 public this (Composite parent, int style) { 114 public this (Composite parent, int style) {
115 super (parent, style); 115 super (parent, style);
116 } 116 }
117 117
118 int /*long*/ characterIndexForPoint (int /*long*/ id, int /*long*/ sel, int /*long*/ point) { 118 NSInteger characterIndexForPoint (objc.id id, objc.SEL sel, objc.id point) {
119 if (ime !is null) return ime.characterIndexForPoint (id, sel, point); 119 if (ime !is null) return ime.characterIndexForPoint (id, sel, point);
120 return super.characterIndexForPoint (id, sel, point); 120 return super.characterIndexForPoint (id, sel, point);
121 } 121 }
122 122
123 /** 123 /**
156 } else { 156 } else {
157 gc.fillRectangle (x, y, width, height); 157 gc.fillRectangle (x, y, width, height);
158 } 158 }
159 } 159 }
160 160
161 void drawWidget (objc.id id_, NSRect rect) { 161 void drawWidget (objc.id id, NSRect rect) {
162 super.drawWidget (id, rect); 162 super.drawWidget (id, rect);
163 if (caret is null) return; 163 if (caret is null) return;
164 if (caret.isShowing) { 164 if (caret.isShowing) {
165 NSGraphicsContext context = NSGraphicsContext.currentContext(); 165 NSGraphicsContext context = NSGraphicsContext.currentContext();
166 166
171 fromRect.width = size.width; 171 fromRect.width = size.width;
172 fromRect.height = size.height; 172 fromRect.height = size.height;
173 NSPoint point = NSPoint(); 173 NSPoint point = NSPoint();
174 point.x = caret.x; 174 point.x = caret.x;
175 point.y = caret.y; 175 point.y = caret.y;
176 image.handle.drawAtPoint(point, rect, NSCompositeXOR, 1); 176 image.handle.drawAtPoint(point, rect, OS.NSCompositeXOR, 1);
177 } else { 177 } else {
178 context.saveGraphicsState(); 178 context.saveGraphicsState();
179 context.setCompositingOperation(NSCompositeXOR); 179 context.setCompositingOperation(OS.NSCompositeXOR);
180 NSRect drawRect = NSRect(); 180 NSRect drawRect = NSRect();
181 drawRect.x = caret.x; 181 drawRect.x = caret.x;
182 drawRect.y = caret.y; 182 drawRect.y = caret.y;
183 drawRect.width = caret.width !is 0 ? caret.width : Caret.DEFAULT_WIDTH; 183 drawRect.width = caret.width !is 0 ? caret.width : Caret.DEFAULT_WIDTH;
184 drawRect.height = caret.height; 184 drawRect.height = caret.height;
189 context.restoreGraphicsState(); 189 context.restoreGraphicsState();
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 NSRect firstRectForCharacterRange (int /*long*/ id, int /*long*/ sel, int /*long*/ range) { 194 NSRect firstRectForCharacterRange (objc.id id, objc.SEL sel, objc.id range) {
195 if (ime !is null) return ime.firstRectForCharacterRange (id, sel, range); 195 if (ime !is null) return ime.firstRectForCharacterRange (id, sel, range);
196 return super.firstRectForCharacterRange (id, sel, range); 196 return super.firstRectForCharacterRange (id, sel, range);
197 } 197 }
198 198
199 /** 199 /**
234 public IME getIME () { 234 public IME getIME () {
235 checkWidget(); 235 checkWidget();
236 return ime; 236 return ime;
237 } 237 }
238 238
239 bool hasMarkedText (int /*long*/ id, int /*long*/ sel) { 239 bool hasMarkedText (objc.id id, objc.SEL sel) {
240 if (ime !is null) return ime.hasMarkedText (id, sel); 240 if (ime !is null) return ime.hasMarkedText (id, sel);
241 return super.hasMarkedText (id, sel); 241 return super.hasMarkedText (id, sel);
242 } 242 }
243 243
244 bool insertText (int /*long*/ id, int /*long*/ sel, int /*long*/ string) { 244 bool insertText (objc.id id, objc.SEL sel, objc.id string) {
245 if (ime !is null) { 245 if (ime !is null) {
246 if (!ime.insertText (id, sel, string)) return false; 246 if (!ime.insertText (id, sel, string)) return false;
247 } 247 }
248 return super.insertText (id, sel, string); 248 return super.insertText (id, sel, string);
249 } 249 }
250 250
251 NSRange markedRange (int /*long*/ id, int /*long*/ sel) { 251 NSRange markedRange (objc.id id, objc.SEL sel) {
252 if (ime !is null) return ime.markedRange (id, sel); 252 if (ime !is null) return ime.markedRange (id, sel);
253 return super.markedRange (id, sel); 253 return super.markedRange (id, sel);
254 } 254 }
255 255
256 //void redrawWidget (int control, bool children) { 256 //void redrawWidget (int control, bool children) {
344 } 344 }
345 } 345 }
346 if (isFocus) caret.setFocus (); 346 if (isFocus) caret.setFocus ();
347 } 347 }
348 348
349 NSRange selectedRange (int /*long*/ id, int /*long*/ sel) { 349 NSRange selectedRange (objc.id id, objc.SEL sel) {
350 if (ime !is null) return ime.selectedRange (id, sel); 350 if (ime !is null) return ime.selectedRange (id, sel);
351 return super.selectedRange (id, sel); 351 return super.selectedRange (id, sel);
352 } 352 }
353 353
354 bool sendKeyEvent (NSEvent nsEvent, int type) { 354 bool sendKeyEvent (NSEvent nsEvent, int type) {
415 checkWidget (); 415 checkWidget ();
416 if (ime !is null && ime.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT); 416 if (ime !is null && ime.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
417 this.ime = ime; 417 this.ime = ime;
418 } 418 }
419 419
420 bool setMarkedText_selectedRange (int /*long*/ id, int /*long*/ sel, int /*long*/ string, int /*long*/ range) { 420 bool setMarkedText_selectedRange (objc.id id, objc.SEL sel, objc.id string, objc.id range) {
421 if (ime !is null) { 421 if (ime !is null) {
422 if (!ime.setMarkedText_selectedRange (id, sel, string, range)) return false; 422 if (!ime.setMarkedText_selectedRange (id, sel, string, range)) return false;
423 } 423 }
424 return super.setMarkedText_selectedRange (id, sel, string, range); 424 return super.setMarkedText_selectedRange (id, sel, string, range);
425 } 425 }
426 426
427 int /*long*/ validAttributesForMarkedText (int /*long*/ id, int /*long*/ sel) { 427 objc.id validAttributesForMarkedText (objc.id id, objc.SEL sel) {
428 if (ime !is null) return ime.validAttributesForMarkedText (id, sel); 428 if (ime !is null) return ime.validAttributesForMarkedText (id, sel);
429 return super.validAttributesForMarkedText(id, sel); 429 return super.validAttributesForMarkedText(id, sel);
430 } 430 }
431 431
432 } 432 }