Changeset 212:ab60f3309436 for dwt/custom/CLabel.d
- Timestamp:
- 05/04/08 18:12:38 (7 months ago)
- Files:
-
- dwt/custom/CLabel.d (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/custom/CLabel.d
r155 r212 75 75 private static const int INDENT = 3; 76 76 /** a string inserted in the middle of text that has been shortened */ 77 private static const char[]ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"77 private static const String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026" 78 78 /** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/ 79 79 private int align_ = DWT.LEFT; … … 81 81 private int vIndent = INDENT; 82 82 /** the current text */ 83 private char[]text;83 private String text; 84 84 /** the current icon */ 85 85 private Image image; … … 89 89 // The appToolTip stores the tooltip set by the application. Control.tooltiptext 90 90 // contains whatever tooltip is currently being displayed. 91 private char[]appToolTipText;91 private String appToolTipText; 92 92 93 93 private Image backgroundImage; … … 210 210 * characters in the given string, return '\0'. 211 211 */ 212 dchar _findMnemonic ( char[]string) {212 dchar _findMnemonic (String string) { 213 213 if (string is null) return '\0'; 214 214 int index = 0; … … 249 249 * Compute the minimum size. 250 250 */ 251 private Point getTotalSize(Image image, char[]text) {251 private Point getTotalSize(Image image, String text) { 252 252 Point size = new Point(0, 0); 253 253 … … 287 287 * @return the text of the label or null 288 288 */ 289 public char[]getText() {289 public String getText() { 290 290 //checkWidget(); 291 291 return text; 292 292 } 293 public override char[]getToolTipText () {293 public override String getToolTipText () { 294 294 checkWidget(); 295 295 return appToolTipText; … … 380 380 381 381 bool shortenText_ = false; 382 char[]t = text;382 String t = text; 383 383 Image img = image; 384 384 int availableWidth = Math.max(0, rect.width - 2*hIndent); … … 393 393 394 394 GC gc = event.gc; 395 char[][] lines = text is null ? null : splitString(text);395 String[] lines = text is null ? null : splitString(text); 396 396 397 397 // shorten the text … … 766 766 * </ul> 767 767 */ 768 public void setText( char[]text) {768 public void setText(String text) { 769 769 checkWidget(); 770 770 if (text is null) text = ""; //$NON-NLS-1$ … … 774 774 } 775 775 } 776 public override void setToolTipText ( char[]string) {776 public override void setToolTipText (String string) { 777 777 super.setToolTipText (string); 778 778 appToolTipText = super.getToolTipText(); … … 789 789 * @return the shortened text 790 790 */ 791 protected char[] shortenText(GC gc, char[]t, int width) {791 protected String shortenText(GC gc, String t, int width) { 792 792 if (t is null) return null; 793 793 int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x; … … 799 799 if (mid <= 0) return t; 800 800 while (min < mid && mid < max) { 801 char[]s1 = t[0 .. mid].dup;802 char[]s2 = t[l-mid .. l].dup;801 String s1 = t[0 .. mid].dup; 802 String s2 = t[l-mid .. l].dup; 803 803 int l1 = gc.textExtent(s1, DRAW_FLAGS).x; 804 804 int l2 = gc.textExtent(s2, DRAW_FLAGS).x; … … 817 817 } 818 818 819 private char[][] splitString(char[]text) {820 char[][] lines = new char[][1];819 private String[] splitString(String text) { 820 String[] lines = new String[1]; 821 821 int start = 0, pos; 822 822 do { … … 828 828 lines[lines.length - 1] = text[ start .. pos - (crlf ? 1 : 0)]; 829 829 start = pos + 1; 830 char[][] newLines = new char[][lines.length+1];830 String[] newLines = new String[lines.length+1]; 831 831 System.arraycopy(lines, 0, newLines, 0, lines.length); 832 832 lines = newLines;
