Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/CLabel.d @ 51:c01d033c633a
[swt lin]
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 19:58:06 +0100 |
parents | 7a2dd761a8b2 |
children | 536e43f63c81 |
comparison
equal
deleted
inserted
replaced
50:d5075f5226e5 | 51:c01d033c633a |
---|---|
221 int index = 0; | 221 int index = 0; |
222 int length = string.length; | 222 int length = string.length; |
223 do { | 223 do { |
224 while (index < length && string[index] !is '&') index++; | 224 while (index < length && string[index] !is '&') index++; |
225 if (++index >= length) return '\0'; | 225 if (++index >= length) return '\0'; |
226 if (string[index] !is '&') { | 226 if (string[index] !is '&') return Character.toLowerCase (string.dcharAt (index)); |
227 dchar[1] tmp; uint ate; | |
228 dchar[] tmp2 = tango.text.convert.Utf.toString32( string[index .. Math.min( index + 4, string.length ) ], tmp, &ate ); | |
229 assert( tmp2.length == 1 ); | |
230 return tango.text.Unicode.toLower( tmp2 )[0]; | |
231 } | |
232 index++; | 227 index++; |
233 } while (index < length); | 228 } while (index < length); |
234 return '\0'; | 229 return '\0'; |
235 } | 230 } |
236 /** | 231 /** |
315 public void getKeyboardShortcut(AccessibleEvent e) { | 310 public void getKeyboardShortcut(AccessibleEvent e) { |
316 dchar mnemonic = _findMnemonic(this.outer.text); | 311 dchar mnemonic = _findMnemonic(this.outer.text); |
317 if (mnemonic !is '\0') { | 312 if (mnemonic !is '\0') { |
318 dchar[1] d; | 313 dchar[1] d; |
319 d[0] = mnemonic; | 314 d[0] = mnemonic; |
320 e.result = "Alt+" ~ tango.text.convert.Utf.toString(d); //$NON-NLS-1$ | 315 e.result = Format("Alt+{}", d); //$NON-NLS-1$ |
321 } | 316 } |
322 } | 317 } |
323 }); | 318 }); |
324 | 319 |
325 accessible.addAccessibleControlListener(new class() AccessibleControlAdapter { | 320 accessible.addAccessibleControlListener(new class() AccessibleControlAdapter { |
357 appToolTipText = null; | 352 appToolTipText = null; |
358 } | 353 } |
359 void onMnemonic(TraverseEvent event) { | 354 void onMnemonic(TraverseEvent event) { |
360 dchar mnemonic = _findMnemonic(text); | 355 dchar mnemonic = _findMnemonic(text); |
361 if (mnemonic is '\0') return; | 356 if (mnemonic is '\0') return; |
362 dchar[1] d; uint ate; | 357 if (Character.toLowerCase(event.character) !is mnemonic) return; |
363 auto r = tango.text.convert.Utf.toString32( [event.character][], d, &ate ); | |
364 if (tango.text.Unicode.toLower(r)[0] !is mnemonic) return; | |
365 Composite control = this.getParent(); | 358 Composite control = this.getParent(); |
366 while (control !is null) { | 359 while (control !is null) { |
367 Control [] children = control.getChildren(); | 360 Control [] children = control.getChildren(); |
368 int index = 0; | 361 int index = 0; |
369 while (index < children.length) { | 362 while (index < children.length) { |
806 if (mid <= 0) return t; | 799 if (mid <= 0) return t; |
807 TextLayout layout = new TextLayout (getDisplay()); | 800 TextLayout layout = new TextLayout (getDisplay()); |
808 layout.setText(t); | 801 layout.setText(t); |
809 mid = validateOffset(layout, mid); | 802 mid = validateOffset(layout, mid); |
810 while (min < mid && mid < max) { | 803 while (min < mid && mid < max) { |
811 String s1 = t[0 .. mid].dup; | 804 String s1 = t.substring(0, mid); |
812 String s2 = t.substring(validateOffset(layout, l-mid), l); | 805 String s2 = t.substring(validateOffset(layout, l-mid), l); |
813 int l1 = gc.textExtent(s1, DRAW_FLAGS).x; | 806 int l1 = gc.textExtent(s1, DRAW_FLAGS).x; |
814 int l2 = gc.textExtent(s2, DRAW_FLAGS).x; | 807 int l2 = gc.textExtent(s2, DRAW_FLAGS).x; |
815 if (l1+w+l2 > width) { | 808 if (l1+w+l2 > width) { |
816 max = mid; | 809 max = mid; |
833 } | 826 } |
834 private String[] splitString(String text) { | 827 private String[] splitString(String text) { |
835 String[] lines = new String[1]; | 828 String[] lines = new String[1]; |
836 int start = 0, pos; | 829 int start = 0, pos; |
837 do { | 830 do { |
838 pos = tango.text.Util.locate( text, '\n', start); | 831 pos = text.indexOf( '\n', start); |
839 if (pos is text.length ) { | 832 if (pos is -1 ) { |
840 lines[lines.length - 1] = text[start .. $ ]; | 833 lines[lines.length - 1] = text[start .. $ ]; |
841 } else { | 834 } else { |
842 bool crlf = (pos > 0) && (text[ pos - 1 ] is '\r'); | 835 bool crlf = (pos > 0) && (text[ pos - 1 ] is '\r'); |
843 lines[lines.length - 1] = text[ start .. pos - (crlf ? 1 : 0)]; | 836 lines[lines.length - 1] = text[ start .. pos - (crlf ? 1 : 0)]; |
844 start = pos + 1; | 837 start = pos + 1; |