Mercurial > projects > dwt-win
comparison dwt/custom/CCombo.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 3afcd4ddcf90 |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
194 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 194 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
195 * </ul> | 195 * </ul> |
196 * | 196 * |
197 * @see #add(String,int) | 197 * @see #add(String,int) |
198 */ | 198 */ |
199 public void add (char[] string) { | 199 public void add (String string) { |
200 checkWidget(); | 200 checkWidget(); |
201 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 201 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
202 list.add (string); | 202 list.add (string); |
203 } | 203 } |
204 /** | 204 /** |
222 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 222 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
223 * </ul> | 223 * </ul> |
224 * | 224 * |
225 * @see #add(String) | 225 * @see #add(String) |
226 */ | 226 */ |
227 public void add (char[] string, int index) { | 227 public void add (String string, int index) { |
228 checkWidget(); | 228 checkWidget(); |
229 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 229 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
230 list.add (string, index); | 230 list.add (string, index); |
231 } | 231 } |
232 /** | 232 /** |
374 } | 374 } |
375 | 375 |
376 public override Point computeSize (int wHint, int hHint, bool changed) { | 376 public override Point computeSize (int wHint, int hHint, bool changed) { |
377 checkWidget (); | 377 checkWidget (); |
378 int width = 0, height = 0; | 378 int width = 0, height = 0; |
379 char[][] items = list.getItems (); | 379 String[] items = list.getItems (); |
380 GC gc = new GC (text); | 380 GC gc = new GC (text); |
381 int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ | 381 int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$ |
382 int textWidth = gc.stringExtent (text.getText ()).x; | 382 int textWidth = gc.stringExtent (text.getText ()).x; |
383 for (int i = 0; i < items.length; i++) { | 383 for (int i = 0; i < items.length; i++) { |
384 textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); | 384 textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth); |
410 */ | 410 */ |
411 public void copy () { | 411 public void copy () { |
412 checkWidget (); | 412 checkWidget (); |
413 text.copy (); | 413 text.copy (); |
414 } | 414 } |
415 void createPopup(char[][] items, int selectionIndex) { | 415 void createPopup(String[] items, int selectionIndex) { |
416 // create shell and list | 416 // create shell and list |
417 popup = new Shell (getShell (), DWT.NO_TRIM | DWT.ON_TOP); | 417 popup = new Shell (getShell (), DWT.NO_TRIM | DWT.ON_TOP); |
418 int style = getStyle (); | 418 int style = getStyle (); |
419 int listStyle = DWT.SINGLE | DWT.V_SCROLL; | 419 int listStyle = DWT.SINGLE | DWT.V_SCROLL; |
420 if ((style & DWT.FLAT) !is 0) listStyle |= DWT.FLAT; | 420 if ((style & DWT.FLAT) !is 0) listStyle |= DWT.FLAT; |
494 } | 494 } |
495 return; | 495 return; |
496 } | 496 } |
497 | 497 |
498 if (getShell() !is popup.getParent ()) { | 498 if (getShell() !is popup.getParent ()) { |
499 char[][] items = list.getItems (); | 499 String[] items = list.getItems (); |
500 int selectionIndex = list.getSelectionIndex (); | 500 int selectionIndex = list.getSelectionIndex (); |
501 list.removeListener (DWT.Dispose, listener); | 501 list.removeListener (DWT.Dispose, listener); |
502 popup.dispose(); | 502 popup.dispose(); |
503 popup = null; | 503 popup = null; |
504 list = null; | 504 list = null; |
532 /* | 532 /* |
533 * Return the lowercase of the first non-'&' character following | 533 * Return the lowercase of the first non-'&' character following |
534 * an '&' character in the given string. If there are no '&' | 534 * an '&' character in the given string. If there are no '&' |
535 * characters in the given string, return '\0'. | 535 * characters in the given string, return '\0'. |
536 */ | 536 */ |
537 dchar _findMnemonic (char[] string) { | 537 dchar _findMnemonic (String string) { |
538 if (string is null) return '\0'; | 538 if (string is null) return '\0'; |
539 int index = 0; | 539 int index = 0; |
540 int length = string.length; | 540 int length = string.length; |
541 do { | 541 do { |
542 while (index < length && string[index] !is '&') index++; | 542 while (index < length && string[index] !is '&') index++; |
600 * @exception DWTException <ul> | 600 * @exception DWTException <ul> |
601 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 601 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
602 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 602 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
603 * </ul> | 603 * </ul> |
604 */ | 604 */ |
605 public char[] getItem (int index) { | 605 public String getItem (int index) { |
606 checkWidget(); | 606 checkWidget(); |
607 return list.getItem (index); | 607 return list.getItem (index); |
608 } | 608 } |
609 /** | 609 /** |
610 * Returns the number of items contained in the receiver's list. | 610 * Returns the number of items contained in the receiver's list. |
649 * @exception DWTException <ul> | 649 * @exception DWTException <ul> |
650 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 650 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
651 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 651 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
652 * </ul> | 652 * </ul> |
653 */ | 653 */ |
654 public char[] [] getItems () { | 654 public String [] getItems () { |
655 checkWidget (); | 655 checkWidget (); |
656 return list.getItems (); | 656 return list.getItems (); |
657 } | 657 } |
658 public override Menu getMenu() { | 658 public override Menu getMenu() { |
659 return text.getMenu(); | 659 return text.getMenu(); |
706 * @exception DWTException <ul> | 706 * @exception DWTException <ul> |
707 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 707 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
708 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 708 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
709 * </ul> | 709 * </ul> |
710 */ | 710 */ |
711 public char[] getText () { | 711 public String getText () { |
712 checkWidget (); | 712 checkWidget (); |
713 return text.getText (); | 713 return text.getText (); |
714 } | 714 } |
715 /** | 715 /** |
716 * Returns the height of the receivers's text field. | 716 * Returns the height of the receivers's text field. |
808 * @exception DWTException <ul> | 808 * @exception DWTException <ul> |
809 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 809 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
810 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 810 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
811 * </ul> | 811 * </ul> |
812 */ | 812 */ |
813 public int indexOf (char[] string) { | 813 public int indexOf (String string) { |
814 checkWidget (); | 814 checkWidget (); |
815 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 815 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
816 return list.indexOf (string); | 816 return list.indexOf (string); |
817 } | 817 } |
818 /** | 818 /** |
832 * @exception DWTException <ul> | 832 * @exception DWTException <ul> |
833 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 833 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
834 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 834 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
835 * </ul> | 835 * </ul> |
836 */ | 836 */ |
837 public int indexOf (char[] string, int start) { | 837 public int indexOf (String string, int start) { |
838 checkWidget (); | 838 checkWidget (); |
839 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 839 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
840 return list.indexOf (string, start); | 840 return list.indexOf (string, start); |
841 } | 841 } |
842 | 842 |
843 void initAccessible() { | 843 void initAccessible() { |
844 AccessibleAdapter accessibleAdapter = new class() AccessibleAdapter { | 844 AccessibleAdapter accessibleAdapter = new class() AccessibleAdapter { |
845 public void getName (AccessibleEvent e) { | 845 public void getName (AccessibleEvent e) { |
846 char[] name = null; | 846 String name = null; |
847 Label label = getAssociatedLabel (); | 847 Label label = getAssociatedLabel (); |
848 if (label !is null) { | 848 if (label !is null) { |
849 name = stripMnemonic (label.getText()); | 849 name = stripMnemonic (label.getText()); |
850 } | 850 } |
851 e.result = name; | 851 e.result = name; |
852 } | 852 } |
853 public void getKeyboardShortcut(AccessibleEvent e) { | 853 public void getKeyboardShortcut(AccessibleEvent e) { |
854 char[] shortcut = null; | 854 String shortcut = null; |
855 Label label = getAssociatedLabel (); | 855 Label label = getAssociatedLabel (); |
856 if (label !is null) { | 856 if (label !is null) { |
857 char[] text = label.getText (); | 857 String text = label.getText (); |
858 if (text !is null) { | 858 if (text !is null) { |
859 dchar mnemonic = _findMnemonic (text); | 859 dchar mnemonic = _findMnemonic (text); |
860 if (mnemonic !is '\0') { | 860 if (mnemonic !is '\0') { |
861 shortcut = tango.text.convert.Format.Format( "Alt+{}", mnemonic ); //$NON-NLS-1$ | 861 shortcut = tango.text.convert.Format.Format( "Alt+{}", mnemonic ); //$NON-NLS-1$ |
862 } | 862 } |
962 } | 962 } |
963 void listEvent (Event event) { | 963 void listEvent (Event event) { |
964 switch (event.type) { | 964 switch (event.type) { |
965 case DWT.Dispose: | 965 case DWT.Dispose: |
966 if (getShell () !is popup.getParent ()) { | 966 if (getShell () !is popup.getParent ()) { |
967 char[][] items = list.getItems (); | 967 String[] items = list.getItems (); |
968 int selectionIndex = list.getSelectionIndex (); | 968 int selectionIndex = list.getSelectionIndex (); |
969 popup = null; | 969 popup = null; |
970 list = null; | 970 list = null; |
971 createPopup (items, selectionIndex); | 971 createPopup (items, selectionIndex); |
972 } | 972 } |
1168 * @exception DWTException <ul> | 1168 * @exception DWTException <ul> |
1169 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1169 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1170 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1170 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1171 * </ul> | 1171 * </ul> |
1172 */ | 1172 */ |
1173 public void remove (char[] string) { | 1173 public void remove (String string) { |
1174 checkWidget(); | 1174 checkWidget(); |
1175 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 1175 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
1176 list.remove (string); | 1176 list.remove (string); |
1177 } | 1177 } |
1178 /** | 1178 /** |
1350 * @exception DWTException <ul> | 1350 * @exception DWTException <ul> |
1351 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1351 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1352 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1352 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1353 * </ul> | 1353 * </ul> |
1354 */ | 1354 */ |
1355 public void setItem (int index, char[] string) { | 1355 public void setItem (int index, String string) { |
1356 checkWidget(); | 1356 checkWidget(); |
1357 list.setItem (index, string); | 1357 list.setItem (index, string); |
1358 } | 1358 } |
1359 /** | 1359 /** |
1360 * Sets the receiver's list to be the given array of items. | 1360 * Sets the receiver's list to be the given array of items. |
1368 * @exception DWTException <ul> | 1368 * @exception DWTException <ul> |
1369 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1369 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1370 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1370 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1371 * </ul> | 1371 * </ul> |
1372 */ | 1372 */ |
1373 public void setItems (char[] [] items) { | 1373 public void setItems (String [] items) { |
1374 checkWidget (); | 1374 checkWidget (); |
1375 list.setItems (items); | 1375 list.setItems (items); |
1376 if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$ | 1376 if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$ |
1377 } | 1377 } |
1378 /** | 1378 /** |
1438 * @exception DWTException <ul> | 1438 * @exception DWTException <ul> |
1439 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1439 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1440 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1440 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1441 * </ul> | 1441 * </ul> |
1442 */ | 1442 */ |
1443 public void setText (char[] string) { | 1443 public void setText (String string) { |
1444 checkWidget(); | 1444 checkWidget(); |
1445 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 1445 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
1446 int index = list.indexOf (string); | 1446 int index = list.indexOf (string); |
1447 if (index is -1) { | 1447 if (index is -1) { |
1448 list.deselectAll (); | 1448 list.deselectAll (); |
1471 public void setTextLimit (int limit) { | 1471 public void setTextLimit (int limit) { |
1472 checkWidget(); | 1472 checkWidget(); |
1473 text.setTextLimit (limit); | 1473 text.setTextLimit (limit); |
1474 } | 1474 } |
1475 | 1475 |
1476 public override void setToolTipText (char[] string) { | 1476 public override void setToolTipText (String string) { |
1477 checkWidget(); | 1477 checkWidget(); |
1478 super.setToolTipText(string); | 1478 super.setToolTipText(string); |
1479 arrow.setToolTipText (string); | 1479 arrow.setToolTipText (string); |
1480 text.setToolTipText (string); | 1480 text.setToolTipText (string); |
1481 } | 1481 } |
1505 public void setVisibleItemCount (int count) { | 1505 public void setVisibleItemCount (int count) { |
1506 checkWidget (); | 1506 checkWidget (); |
1507 if (count < 0) return; | 1507 if (count < 0) return; |
1508 visibleItemCount = count; | 1508 visibleItemCount = count; |
1509 } | 1509 } |
1510 char[] stripMnemonic (char[] string) { | 1510 String stripMnemonic (String string) { |
1511 int index = 0; | 1511 int index = 0; |
1512 int length_ = string.length; | 1512 int length_ = string.length; |
1513 do { | 1513 do { |
1514 while ((index < length_) && (string[index] !is '&')) index++; | 1514 while ((index < length_) && (string[index] !is '&')) index++; |
1515 if (++index >= length_) return string; | 1515 if (++index >= length_) return string; |