Mercurial > projects > dwt-mac
comparison dwt/widgets/IME.d @ 51:e6f04eb518ae
Updated Canvas to 3.514
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 07 Dec 2008 21:24:13 +0100 |
parents | d8635bb48c7c |
children | 6309d49b16b7 |
comparison
equal
deleted
inserted
replaced
50:30adfb32d4be | 51:e6f04eb518ae |
---|---|
31 import dwt.internal.cocoa.NSString; | 31 import dwt.internal.cocoa.NSString; |
32 import dwt.internal.cocoa.NSView; | 32 import dwt.internal.cocoa.NSView; |
33 import dwt.internal.cocoa.OS; | 33 import dwt.internal.cocoa.OS; |
34 | 34 |
35 import dwt.dwthelper.utils; | 35 import dwt.dwthelper.utils; |
36 import dwt.internal.objc.cocoa.Cocoa; | |
36 import dwt.widgets.Canvas; | 37 import dwt.widgets.Canvas; |
37 import dwt.widgets.Widget; | 38 import dwt.widgets.Widget; |
38 | 39 |
39 /** | 40 /** |
40 * Instances of this class represent input method editors. | 41 * Instances of this class represent input method editors. |
104 super (parent, style); | 105 super (parent, style); |
105 this.parent = parent; | 106 this.parent = parent; |
106 createWidget (); | 107 createWidget (); |
107 } | 108 } |
108 | 109 |
109 int /*long*/ attributedSubstringFromRange (int /*long*/ id, int /*long*/ sel, int /*long*/ rangePtr) { | 110 objc.id attributedSubstringFromRange (objc.id id, objc.SEL sel, objc.id rangePtr) { |
110 Event event = new Event (); | 111 Event event = new Event (); |
111 event.detail = DWT.COMPOSITION_SELECTION; | 112 event.detail = DWT.COMPOSITION_SELECTION; |
112 sendEvent (DWT.ImeComposition, event); | 113 sendEvent (DWT.ImeComposition, event); |
113 NSRange range = new NSRange (); | 114 NSRange range = new NSRange (); |
114 OS.memmove (range, rangePtr, NSRange.sizeof); | 115 OS.memmove (range, rangePtr, NSRange.sizeof); |
118 NSString str = NSString.stringWith (event.text.substring(start - event.start, end - event.start)); | 119 NSString str = NSString.stringWith (event.text.substring(start - event.start, end - event.start)); |
119 NSAttributedString attriStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString(str, null); | 120 NSAttributedString attriStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString(str, null); |
120 attriStr.autorelease (); | 121 attriStr.autorelease (); |
121 return attriStr.id; | 122 return attriStr.id; |
122 } | 123 } |
123 return 0; | 124 return null; |
124 } | 125 } |
125 | 126 |
126 int /*long*/ characterIndexForPoint (int /*long*/ id, int /*long*/ sel, int /*long*/ point) { | 127 NSInteger characterIndexForPoint (objc.id id, objc.SEL sel, objc.id point) { |
127 if (!isInlineEnabled ()) return OS.NSNotFound; | 128 if (!isInlineEnabled ()) return OS.NSNotFound; |
128 NSPoint pt = new NSPoint (); | 129 NSPoint pt = new NSPoint (); |
129 OS.memmove (pt, point, NSPoint.sizeof); | 130 OS.memmove (pt, point, NSPoint.sizeof); |
130 NSView view = parent.view; | 131 NSView view = parent.view; |
131 pt = view.window ().convertScreenToBase (pt); | 132 pt = view.window ().convertScreenToBase (pt); |
145 if (parent.getIME () is null) { | 146 if (parent.getIME () is null) { |
146 parent.setIME (this); | 147 parent.setIME (this); |
147 } | 148 } |
148 } | 149 } |
149 | 150 |
150 NSRect firstRectForCharacterRange(int /*long*/ id, int /*long*/ sel, int /*long*/ range) { | 151 NSRect firstRectForCharacterRange(objc.id id, objc.SEL sel, objc.id range) { |
151 NSRect rect = new NSRect (); | 152 NSRect rect = new NSRect (); |
152 Caret caret = parent.caret; | 153 Caret caret = parent.caret; |
153 if (caret !is null) { | 154 if (caret !is null) { |
154 NSView view = parent.view; | 155 NSView view = parent.view; |
155 NSPoint pt = new NSPoint (); | 156 NSPoint pt = new NSPoint (); |
350 */ | 351 */ |
351 public bool getWideCaret() { | 352 public bool getWideCaret() { |
352 return false; | 353 return false; |
353 } | 354 } |
354 | 355 |
355 bool hasMarkedText (int /*long*/ id, int /*long*/ sel) { | 356 bool hasMarkedText (objc.id id, objc.SEL sel) { |
356 return text.length () !is 0; | 357 return text.length () !is 0; |
357 } | 358 } |
358 | 359 |
359 bool insertText (int /*long*/ id, int /*long*/ sel, int /*long*/ string) { | 360 bool insertText (objc.id id, objc.SEL sel, objc.id string) { |
360 if (startOffset is -1) return true; | 361 if (startOffset is -1) return true; |
361 NSString str = new NSString (string); | 362 NSString str = new NSString (string); |
362 if (str.isKindOfClass (OS.objc_getClass ("NSAttributedString"))) { | 363 if (str.isKindOfClass (OS.objc_getClass ("NSAttributedString"))) { |
363 str = new NSAttributedString (string).string (); | 364 str = (new NSAttributedString (string)).string (); |
364 } | 365 } |
365 int length = (int)/*64*/str.length (); | 366 NSUInteger length = str.length (); |
366 int end = startOffset + text.length (); | 367 NSUInteger end = startOffset + text.length (); |
367 ranges = null; | 368 ranges = null; |
368 styles = null; | 369 styles = null; |
369 caretOffset = commitCount = length; | 370 caretOffset = commitCount = length; |
370 Event event = new Event (); | 371 Event event = new Event (); |
371 event.detail = DWT.COMPOSITION_CHANGED; | 372 event.detail = DWT.COMPOSITION_CHANGED; |
381 | 382 |
382 bool isInlineEnabled () { | 383 bool isInlineEnabled () { |
383 return hooks (DWT.ImeComposition); | 384 return hooks (DWT.ImeComposition); |
384 } | 385 } |
385 | 386 |
386 NSRange markedRange (int /*long*/ id, int /*long*/ sel) { | 387 NSRange markedRange (objc.id id, objc.SEL sel) { |
387 if (startOffset is -1) { | 388 if (startOffset is -1) { |
388 Event event = new Event (); | 389 Event event = new Event (); |
389 event.detail = DWT.COMPOSITION_SELECTION; | 390 event.detail = DWT.COMPOSITION_SELECTION; |
390 sendEvent (DWT.ImeComposition, event); | 391 sendEvent (DWT.ImeComposition, event); |
391 startOffset = event.start; | 392 startOffset = event.start; |
407 text = null; | 408 text = null; |
408 styles = null; | 409 styles = null; |
409 ranges = null; | 410 ranges = null; |
410 } | 411 } |
411 | 412 |
412 NSRange selectedRange (int /*long*/ id, int /*long*/ sel) { | 413 NSRange selectedRange (objc.id id, objc.SEL sel) { |
413 Event event = new Event (); | 414 Event event = new Event (); |
414 event.detail = DWT.COMPOSITION_SELECTION; | 415 event.detail = DWT.COMPOSITION_SELECTION; |
415 sendEvent (DWT.ImeComposition, event); | 416 sendEvent (DWT.ImeComposition, event); |
416 NSRange range = new NSRange (); | 417 NSRange range = new NSRange (); |
417 range.location = event.start; | 418 range.location = event.start; |
441 if (startOffset !is -1) { | 442 if (startOffset !is -1) { |
442 startOffset = offset; | 443 startOffset = offset; |
443 } | 444 } |
444 } | 445 } |
445 | 446 |
446 bool setMarkedText_selectedRange (int /*long*/ id, int /*long*/ sel, int /*long*/ string, int /*long*/ selRange) { | 447 bool setMarkedText_selectedRange (objc.id id, objc.SEL sel, objc.id string, objc.id selRange) { |
447 if (!isInlineEnabled ()) return true; | 448 if (!isInlineEnabled ()) return true; |
448 ranges = null; | 449 ranges = null; |
449 styles = null; | 450 styles = null; |
450 caretOffset = commitCount = 0; | 451 caretOffset = commitCount = 0; |
451 int end = startOffset + text.length (); | 452 int end = startOffset + text.length (); |
500 event.text = text = str.getString(); | 501 event.text = text = str.getString(); |
501 sendEvent (DWT.ImeComposition, event); | 502 sendEvent (DWT.ImeComposition, event); |
502 return true; | 503 return true; |
503 } | 504 } |
504 | 505 |
505 int /*long*/ validAttributesForMarkedText (int /*long*/ id, int /*long*/ sel) { | 506 objc.id validAttributesForMarkedText (objc.id id, objc.SEL sel) { |
506 NSMutableArray attribs = NSMutableArray.arrayWithCapacity (6); | 507 NSMutableArray attribs = NSMutableArray.arrayWithCapacity (6); |
507 attribs.addObject (new NSString (OS.NSForegroundColorAttributeName ())); | 508 attribs.addObject (new NSString (OS.NSForegroundColorAttributeName_ )); |
508 attribs.addObject (new NSString (OS.NSBackgroundColorAttributeName ())); | 509 attribs.addObject (new NSString (OS.NSBackgroundColorAttributeName_ )); |
509 attribs.addObject (new NSString (OS.NSUnderlineStyleAttributeName ())); | 510 attribs.addObject (new NSString (OS.NSUnderlineStyleAttributeName_ )); |
510 attribs.addObject (new NSString (OS.NSUnderlineColorAttributeName ())); | 511 attribs.addObject (new NSString (OS.NSUnderlineColorAttributeName_ )); |
511 attribs.addObject (new NSString (OS.NSStrikethroughStyleAttributeName ())); | 512 attribs.addObject (new NSString (OS.NSStrikethroughStyleAttributeName_ )); |
512 attribs.addObject (new NSString (OS.NSStrikethroughColorAttributeName ())); | 513 attribs.addObject (new NSString (OS.NSStrikethroughColorAttributeName_ )); |
513 return attribs.id; | 514 return attribs.id; |
514 } | 515 } |
515 | 516 |
516 } | 517 } |