Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/DateTime.d @ 120:536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
===D2===
* added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements
used these templates to work with strict type storage rules of dmd-2.053
* com.ibm.icu now also compilable with D2, but not tested yet
* small fixes
Snippet288 - shared data is in TLS
===Phobos===
* fixed critical bugs in Phobos implemention
completely incorrect segfault prone fromStringz (Linux's port ruthless killer)
terrible, incorrect StringBuffer realization (StyledText killer)
* fixed small bugs as well
Snippet72 - misprint in the snippet
* implemented missed functionality for Phobos
ByteArrayOutputStream implemented (image loading available)
formatting correctly works for all DWT's cases
As a result, folowing snippets now works with Phobos (Snippet### - what is fixed):
Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting
Snippet48, 282 - crash on image loading
Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText
Snippet244 - hang-up
===Tango===
* few changes for the latest Tango trunc-r5661
* few small performance improvments
===General===
* implMissing-s for only one version changed to implMissingInTango/InPhobos
* incorrect calls to Format in toString-s fixed
* fixed loading \uXXXX characters in ResourceBundle
* added good UTF-8 support for StyledText, TextLayout (Win32) and friends
UTF functions revised and tested. It is now in java.nonstandard.*Utf modules
StyledText and TextLayout (Win32) modules revised for UTF-8 support
* removed small diferences in most identical files in *.swt.* folders
*.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32
now 179 of 576 (~31%) files in *.swt.* folders are fully identical
* Win32: snippets now have right subsystem, pretty icons and native system style controls
* small fixes in snippets
Snippet44 - it's not Snippet44
Snippet212 - functions work with different images and offsets arrays
Win32: Snippet282 - crash on close if the button has an image
Snippet293 - setGrayed is commented
and others
Win32: As a result, folowing snippets now works
Snippet68 - color doesn't change
Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above)
Snippet193 - no tabel headers
author | Denis Shelomovskij <verylonglogin.reg@gmail.com> |
---|---|
date | Sat, 09 Jul 2011 15:50:20 +0300 |
parents | c01d033c633a |
children |
comparison
equal
deleted
inserted
replaced
119:d00e8db0a568 | 120:536e43f63c81 |
---|---|
42 static import tango.time.WallClock; | 42 static import tango.time.WallClock; |
43 static import tango.time.chrono.Gregorian; | 43 static import tango.time.chrono.Gregorian; |
44 static import tango.time.chrono.Calendar; | 44 static import tango.time.chrono.Calendar; |
45 } else { // Phobos | 45 } else { // Phobos |
46 import std.conv; | 46 import std.conv; |
47 static import std.datetime; | |
47 } | 48 } |
48 | 49 |
49 | 50 |
50 private class Calendar{ | 51 private class Calendar{ |
51 enum { | 52 enum { |
95 auto greg = tango.time.chrono.Gregorian.Gregorian.generic; | 96 auto greg = tango.time.chrono.Gregorian.Gregorian.generic; |
96 this.dayofmonth = greg.getDayOfMonth( time ); | 97 this.dayofmonth = greg.getDayOfMonth( time ); |
97 this.month = greg.getMonth( time ); | 98 this.month = greg.getMonth( time ); |
98 this.year = greg.getYear( time ); | 99 this.year = greg.getYear( time ); |
99 } else { // Phobos | 100 } else { // Phobos |
100 implMissing( __FILE__, __LINE__ ); | 101 auto time = std.datetime.Clock.currTime(); |
102 this.second = time.second; | |
103 this.minute = time.minute; | |
104 this.hour = time.hour; | |
105 this.dayofmonth = time.day; | |
106 this.month = time.month; | |
107 this.year = time.year; | |
101 } | 108 } |
102 } | 109 } |
103 int getActualMaximum(int field){ | 110 int getActualMaximum(int field){ |
104 switch( field ){ | 111 switch( field ){ |
105 case YEAR: | 112 case YEAR: |
297 } | 304 } |
298 | 305 |
299 | 306 |
300 private class DateFormatSymbols { | 307 private class DateFormatSymbols { |
301 private const String[] ampm = [ "AM"[], "PM" ]; | 308 private const String[] ampm = [ "AM"[], "PM" ]; |
302 String[] getAmPmStrings(){ | 309 TryConst!(String[]) getAmPmStrings(){ |
303 return ampm; | 310 return ampm; |
304 } | 311 } |
305 } | 312 } |
306 | 313 |
307 | 314 |
563 } | 570 } |
564 } | 571 } |
565 | 572 |
566 String formattedStringValue(int fieldName, int value, bool adjust) { | 573 String formattedStringValue(int fieldName, int value, bool adjust) { |
567 if (fieldName is Calendar.AM_PM) { | 574 if (fieldName is Calendar.AM_PM) { |
568 String[] ampm = formatSymbols.getAmPmStrings(); | 575 return formatSymbols.getAmPmStrings()[value]; |
569 return ampm[value]; | |
570 } | 576 } |
571 if (adjust) { | 577 if (adjust) { |
572 if (fieldName is Calendar.HOUR && value is 0) { | 578 if (fieldName is Calendar.HOUR && value is 0) { |
573 return to!(String)(12); | 579 return to!(String)(12); |
574 } | 580 } |
596 return -1; | 602 return -1; |
597 } | 603 } |
598 | 604 |
599 String getFormattedString(int style) { | 605 String getFormattedString(int style) { |
600 if ((style & SWT.TIME) !is 0) { | 606 if ((style & SWT.TIME) !is 0) { |
601 String[] ampm = formatSymbols.getAmPmStrings(); | 607 auto ampm = formatSymbols.getAmPmStrings(); |
602 int h = calendar.get(Calendar.HOUR); if (h is 0) h = 12; | 608 int h = calendar.get(Calendar.HOUR); if (h is 0) h = 12; |
603 int m = calendar.get(Calendar.MINUTE); | 609 int m = calendar.get(Calendar.MINUTE); |
604 int s = calendar.get(Calendar.SECOND); | 610 int s = calendar.get(Calendar.SECOND); |
605 int a = calendar.get(Calendar.AM_PM); | 611 int a = calendar.get(Calendar.AM_PM); |
606 if ((style & SWT.SHORT) !is 0) return "" ~ (h < 10 ? " " : "") ~ to!(String)(h) ~ ":" ~ (m < 10 ? "0" : "") ~ to!(String)(m) ~ " " ~ ampm[a]; | 612 if ((style & SWT.SHORT) !is 0) return "" ~ (h < 10 ? " " : "") ~ to!(String)(h) ~ ":" ~ (m < 10 ? "0" : "") ~ to!(String)(m) ~ " " ~ ampm[a]; |
909 int start = fieldIndices[currentField].x; | 915 int start = fieldIndices[currentField].x; |
910 int end = fieldIndices[currentField].y; | 916 int end = fieldIndices[currentField].y; |
911 int length_ = end - start; | 917 int length_ = end - start; |
912 String newText = event.text; | 918 String newText = event.text; |
913 if (fieldName is Calendar.AM_PM) { | 919 if (fieldName is Calendar.AM_PM) { |
914 String[] ampm = formatSymbols.getAmPmStrings(); | 920 auto ampm = formatSymbols.getAmPmStrings(); |
915 if (newText.equalsIgnoreCase(ampm[Calendar.AM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.AM])) { | 921 if (newText.equalsIgnoreCase(ampm[Calendar.AM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.AM])) { |
916 setTextField(fieldName, Calendar.AM, true, false); | 922 setTextField(fieldName, Calendar.AM, true, false); |
917 } else if (newText.equalsIgnoreCase(ampm[Calendar.PM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.PM])) { | 923 } else if (newText.equalsIgnoreCase(ampm[Calendar.PM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.PM])) { |
918 setTextField(fieldName, Calendar.PM, true, false); | 924 setTextField(fieldName, Calendar.PM, true, false); |
919 } | 925 } |