Show
Ignore:
Timestamp:
05/04/08 18:42:55 (4 years ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

reverted char[] to String

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/widgets/DateTime.d

    r203 r238  
    279279 
    280280private class DateFormatSymbols { 
    281     private const char[][] ampm = [ "AM"[], "PM" ]; 
    282     char[][] getAmPmStrings(){ 
     281    private const String[] ampm = [ "AM"[], "PM" ]; 
     282    String[] getAmPmStrings(){ 
    283283        return ampm; 
    284284    } 
     
    382382    Button down, up; 
    383383    Text text; 
    384     char[] format; 
     384    String format; 
    385385    Point[] fieldIndices; 
    386386    int[] fieldNames; 
    387387    int fieldCount, currentField = 0, characterCount = 0; 
    388388    bool ignoreVerify = false; 
    389     static const char[] DEFAULT_SHORT_DATE_FORMAT = "MM/YYYY"; 
    390     static const char[] DEFAULT_MEDIUM_DATE_FORMAT = "MM/DD/YYYY"; 
    391     static const char[] DEFAULT_LONG_DATE_FORMAT = "MM/DD/YYYY"; 
    392     static const char[] DEFAULT_SHORT_TIME_FORMAT = "HH:MM AM"; 
    393     static const char[] DEFAULT_MEDIUM_TIME_FORMAT = "HH:MM:SS AM"; 
    394     static const char[] DEFAULT_LONG_TIME_FORMAT = "HH:MM:SS AM"; 
     389    static const String DEFAULT_SHORT_DATE_FORMAT = "MM/YYYY"; 
     390    static const String DEFAULT_MEDIUM_DATE_FORMAT = "MM/DD/YYYY"; 
     391    static const String DEFAULT_LONG_DATE_FORMAT = "MM/DD/YYYY"; 
     392    static const String DEFAULT_SHORT_TIME_FORMAT = "HH:MM AM"; 
     393    static const String DEFAULT_MEDIUM_TIME_FORMAT = "HH:MM:SS AM"; 
     394    static const String DEFAULT_LONG_TIME_FORMAT = "HH:MM:SS AM"; 
    395395 
    396396 
     
    592592        int start = fieldIndices[currentField].x; 
    593593        int end = fieldIndices[currentField].y; 
    594         char[] value = text.getText(start, end - 1); 
     594        String value = text.getText(start, end - 1); 
    595595        int s = value.lastIndexOf(' '); 
    596596        if (s !is -1) value = value.substring(s + 1); 
     
    600600} 
    601601 
    602 char[] formattedStringValue(int fieldName, int value, bool adjust) { 
     602String formattedStringValue(int fieldName, int value, bool adjust) { 
    603603    if (fieldName is Calendar.AM_PM) { 
    604         char[][] ampm = formatSymbols.getAmPmStrings(); 
     604        String[] ampm = formatSymbols.getAmPmStrings(); 
    605605        return ampm[value]; 
    606606    } 
    607607    if (adjust) { 
    608608        if (fieldName is Calendar.HOUR && value is 0) { 
    609             return to!(char[])(12); 
     609            return to!(String)(12); 
    610610        } 
    611611        if (fieldName is Calendar.MONTH) { 
    612             return to!(char[])(value + 1); 
    613         } 
    614     } 
    615     return to!(char[])(value); 
    616 } 
    617  
    618 char[] getComputeSizeString(int style) { 
     612            return to!(String)(value + 1); 
     613        } 
     614    } 
     615    return to!(String)(value); 
     616} 
     617 
     618String getComputeSizeString(int style) { 
    619619    if ((style & DWT.DATE) !is 0) { 
    620620        return (style & DWT.SHORT) !is 0 ? DEFAULT_SHORT_DATE_FORMAT : (style & DWT.LONG) !is 0 ? DEFAULT_LONG_DATE_FORMAT : DEFAULT_MEDIUM_DATE_FORMAT; 
     
    633633} 
    634634 
    635 char[] getFormattedString(int style) { 
     635String getFormattedString(int style) { 
    636636    if ((style & DWT.TIME) !is 0) { 
    637         char[][] ampm = formatSymbols.getAmPmStrings(); 
     637        String[] ampm = formatSymbols.getAmPmStrings(); 
    638638        int h = calendar.get(Calendar.HOUR); if (h is 0) h = 12; 
    639639        int m = calendar.get(Calendar.MINUTE); 
    640640        int s = calendar.get(Calendar.SECOND); 
    641641        int a = calendar.get(Calendar.AM_PM); 
    642         if ((style & DWT.SHORT) !is 0) return "" ~ (h < 10 ? " " : "") ~ to!(char[])(h) ~ ":" ~ (m < 10 ? " " : "") ~ to!(char[])(m) ~ " " ~ ampm[a]; 
    643         return "" ~ (h < 10 ? " " : "") ~ to!(char[])(h) ~ ":" ~ (m < 10 ? " " : "") ~ to!(char[])(m) ~ ":" ~ (s < 10 ? " " : "") ~ to!(char[])(s) ~ " " ~ ampm[a]; 
     642        if ((style & DWT.SHORT) !is 0) return "" ~ (h < 10 ? " " : "") ~ to!(String)(h) ~ ":" ~ (m < 10 ? " " : "") ~ to!(String)(m) ~ " " ~ ampm[a]; 
     643        return "" ~ (h < 10 ? " " : "") ~ to!(String)(h) ~ ":" ~ (m < 10 ? " " : "") ~ to!(String)(m) ~ ":" ~ (s < 10 ? " " : "") ~ to!(String)(s) ~ " " ~ ampm[a]; 
    644644    } 
    645645    /* DWT.DATE */ 
     
    647647    int m = calendar.get(Calendar.MONTH) + 1; 
    648648    int d = calendar.get(Calendar.DAY_OF_MONTH); 
    649     if ((style & DWT.SHORT) !is 0) return "" ~ (m < 10 ? " " : "") ~ to!(char[])(m) ~ "/" ~ to!(char[])(y); 
    650     return "" ~ (m < 10 ? " " : "") ~ to!(char[])(m) ~ "/" ~ (d < 10 ? " " : "") ~ to!(char[])(d) ~ "/" ~ to!(char[])(y); 
     649    if ((style & DWT.SHORT) !is 0) return "" ~ (m < 10 ? " " : "") ~ to!(String)(m) ~ "/" ~ to!(String)(y); 
     650    return "" ~ (m < 10 ? " " : "") ~ to!(String)(m) ~ "/" ~ (d < 10 ? " " : "") ~ to!(String)(d) ~ "/" ~ to!(String)(y); 
    651651} 
    652652 
     
    931931    int end = fieldIndices[currentField].y; 
    932932    int length_ = end - start; 
    933     char[] newText = event.text; 
     933    String newText = event.text; 
    934934    if (fieldName is Calendar.AM_PM) { 
    935         char[][] ampm = formatSymbols.getAmPmStrings(); 
     935        String[] ampm = formatSymbols.getAmPmStrings(); 
    936936        if (newText.equalsIgnoreCase(ampm[Calendar.AM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.AM])) { 
    937937            setTextField(fieldName, Calendar.AM, true, false); 
     
    947947            return; 
    948948        } 
    949         char[] value = text.getText(start, end - 1); 
     949        String value = text.getText(start, end - 1); 
    950950        int s = value.lastIndexOf(' '); 
    951951        if (s !is -1) value = value.substring(s + 1); 
     
    10261026        public void run() { 
    10271027            if (!text.isDisposed()) { 
    1028                 char[] value = text.getText(start, end - 1); 
     1028                String value = text.getText(start, end - 1); 
    10291029                int s = value.lastIndexOf(' '); 
    10301030                if (s is -1 ) s = start; 
     
    10711071} 
    10721072 
    1073 /*public*/ void setFormat(char[] string) { 
     1073/*public*/ void setFormat(String string) { 
    10741074    checkWidget(); 
    10751075    // TODO: this needs to be locale sensitive 
     
    11341134    int end = fieldIndices[currentField].y; 
    11351135    text.setSelection(start, end); 
    1136     char[] newValue = formattedStringValue(fieldName, value, adjust); 
     1136    String newValue = formattedStringValue(fieldName, value, adjust); 
    11371137    TangoText buffer = new TangoText(newValue); 
    11381138    /* Convert leading 0's into spaces. */ 
     
    12971297} 
    12981298 
    1299 int unformattedIntValue(int fieldName, char[] newText, bool adjust, int max) { 
     1299int unformattedIntValue(int fieldName, String newText, bool adjust, int max) { 
    13001300    int newValue; 
    13011301    try { 
     
    13161316public void updateControl() { 
    13171317    if (text !is null) { 
    1318         char[] string = getFormattedString(style); 
     1318        String string = getFormattedString(style); 
    13191319        ignoreVerify = true; 
    13201320        text.setText(string);