diff dwt/custom/CLabel.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 a5afe31f5cdd
children 36f5cb12e1a2
line wrap: on
line diff
--- a/dwt/custom/CLabel.d	Sat Apr 26 10:01:48 2008 +0200
+++ b/dwt/custom/CLabel.d	Mon May 05 00:12:38 2008 +0200
@@ -74,13 +74,13 @@
     /** Left and right margins */
     private static const int INDENT = 3;
     /** a string inserted in the middle of text that has been shortened */
-    private static const char[] ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
+    private static const String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
     /** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/
     private int align_ = DWT.LEFT;
     private int hIndent = INDENT;
     private int vIndent = INDENT;
     /** the current text */
-    private char[] text;
+    private String text;
     /** the current icon */
     private Image image;
     // The tooltip is used for two purposes - the application can set
@@ -88,7 +88,7 @@
     // the text has been truncated due to the label being too short.
     // The appToolTip stores the tooltip set by the application.  Control.tooltiptext
     // contains whatever tooltip is currently being displayed.
-    private char[] appToolTipText;
+    private String appToolTipText;
 
     private Image backgroundImage;
     private Color[] gradientColors;
@@ -209,7 +209,7 @@
  * an '&' character in the given string. If there are no '&'
  * characters in the given string, return '\0'.
  */
-dchar _findMnemonic (char[] string) {
+dchar _findMnemonic (String string) {
     if (string is null) return '\0';
     int index = 0;
     int length = string.length;
@@ -248,7 +248,7 @@
 /**
  * Compute the minimum size.
  */
-private Point getTotalSize(Image image, char[] text) {
+private Point getTotalSize(Image image, String text) {
     Point size = new Point(0, 0);
 
     if (image !is null) {
@@ -286,11 +286,11 @@
  *
  * @return the text of the label or null
  */
-public char[] getText() {
+public String getText() {
     //checkWidget();
     return text;
 }
-public override char[] getToolTipText () {
+public override String getToolTipText () {
     checkWidget();
     return appToolTipText;
 }
@@ -379,7 +379,7 @@
     if (rect.width is 0 || rect.height is 0) return;
 
     bool shortenText_ = false;
-    char[] t = text;
+    String t = text;
     Image img = image;
     int availableWidth = Math.max(0, rect.width - 2*hIndent);
     Point extent = getTotalSize(img, t);
@@ -392,7 +392,7 @@
     }
 
     GC gc = event.gc;
-    char[][] lines = text is null ? null : splitString(text);
+    String[] lines = text is null ? null : splitString(text);
 
     // shorten the text
     if (shortenText_) {
@@ -765,7 +765,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public void setText(char[] text) {
+public void setText(String text) {
     checkWidget();
     if (text is null) text = ""; //$NON-NLS-1$
     if ( text !=/*eq*/ this.text) {
@@ -773,7 +773,7 @@
         redraw();
     }
 }
-public override void setToolTipText (char[] string) {
+public override void setToolTipText (String string) {
     super.setToolTipText (string);
     appToolTipText = super.getToolTipText();
 }
@@ -788,7 +788,7 @@
  * @param width the width to shorten the text to, in pixels
  * @return the shortened text
  */
-protected char[] shortenText(GC gc, char[] t, int width) {
+protected String shortenText(GC gc, String t, int width) {
     if (t is null) return null;
     int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x;
     if (width<=w) return t;
@@ -798,8 +798,8 @@
     int mid = (max+min)/2 - 1;
     if (mid <= 0) return t;
     while (min < mid && mid < max) {
-        char[] s1 = t[0 .. mid].dup;
-        char[] s2 = t[l-mid .. l].dup;
+        String s1 = t[0 .. mid].dup;
+        String s2 = t[l-mid .. l].dup;
         int l1 = gc.textExtent(s1, DRAW_FLAGS).x;
         int l2 = gc.textExtent(s2, DRAW_FLAGS).x;
         if (l1+w+l2 > width) {
@@ -816,8 +816,8 @@
     return t[ 0 .. mid ] ~ ELLIPSIS ~ t[ l-mid .. l ];
 }
 
-private char[][] splitString(char[] text) {
-    char[][] lines = new char[][1];
+private String[] splitString(String text) {
+    String[] lines = new String[1];
     int start = 0, pos;
     do {
         pos = tango.text.Util.locate( text, '\n', start);
@@ -827,7 +827,7 @@
             bool crlf = (pos > 0) && (text[ pos - 1 ] is '\r');
             lines[lines.length - 1] = text[ start .. pos - (crlf ? 1 : 0)];
             start = pos + 1;
-            char[][] newLines = new char[][lines.length+1];
+            String[] newLines = new String[lines.length+1];
             System.arraycopy(lines, 0, newLines, 0, lines.length);
             lines = newLines;
         }