comparison dwt/custom/CTabFolder.d @ 315:349b8c12e243

Sync dwt/custom with dwt-linux
author Frank Benoit <benoit@tionex.de>
date Tue, 07 Oct 2008 16:18:26 +0200
parents fd9c62a2998e
children
comparison
equal deleted inserted replaced
314:0e2b4fed7a0f 315:349b8c12e243
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language: 10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwt.custom.CTabFolder; 13 module dwt.custom.CTabFolder;
14
15 14
16 import dwt.DWT; 15 import dwt.DWT;
17 import dwt.DWTException; 16 import dwt.DWTException;
18 import dwt.accessibility.ACC; 17 import dwt.accessibility.ACC;
19 import dwt.accessibility.Accessible; 18 import dwt.accessibility.Accessible;
540 addListener(DWT.DefaultSelection, typedListener); 539 addListener(DWT.DefaultSelection, typedListener);
541 } 540 }
542 void antialias (int[] shape, RGB lineRGB, RGB innerRGB, RGB outerRGB, GC gc){ 541 void antialias (int[] shape, RGB lineRGB, RGB innerRGB, RGB outerRGB, GC gc){
543 // Don't perform anti-aliasing on Mac and WPF because the platform 542 // Don't perform anti-aliasing on Mac and WPF because the platform
544 // already does it. The simple style also does not require anti-aliasing. 543 // already does it. The simple style also does not require anti-aliasing.
545 if (simple || "carbon"==DWT.getPlatform() || "wpf"==DWT.getPlatform()) return; //$NON-NLS-1$ 544 if (simple || "carbon".equals(DWT.getPlatform()) || "wpf".equals(DWT.getPlatform())) return; //$NON-NLS-1$
546 // Don't perform anti-aliasing on low resolution displays 545 // Don't perform anti-aliasing on low resolution displays
547 if (getDisplay().getDepth() < 15) return; 546 if (getDisplay().getDepth() < 15) return;
548 if (outerRGB !is null) { 547 if (outerRGB !is null) {
549 int index = 0; 548 int index = 0;
550 bool left = true; 549 bool left = true;
553 for (int i = 0; i < shape.length/2; i++) { 552 for (int i = 0; i < shape.length/2; i++) {
554 if (left && (index + 3 < shape.length)) { 553 if (left && (index + 3 < shape.length)) {
555 left = onBottom ? oldY <= shape[index+3] : oldY >= shape[index+3]; 554 left = onBottom ? oldY <= shape[index+3] : oldY >= shape[index+3];
556 oldY = shape[index+1]; 555 oldY = shape[index+1];
557 } 556 }
558 outer[index] = shape[index++] + (left ? -1 : +1); 557 outer[index] = shape[index] + (left ? -1 : +1);
559 outer[index] = shape[index++]; 558 index++;
559 outer[index] = shape[index];
560 index++;
560 } 561 }
561 RGB from = lineRGB; 562 RGB from = lineRGB;
562 RGB to = outerRGB; 563 RGB to = outerRGB;
563 int red = from.red + 2*(to.red - from.red)/3; 564 int red = from.red + 2*(to.red - from.red)/3;
564 int green = from.green + 2*(to.green - from.green)/3; 565 int green = from.green + 2*(to.green - from.green)/3;
576 for (int i = 0; i < shape.length/2; i++) { 577 for (int i = 0; i < shape.length/2; i++) {
577 if (left && (index + 3 < shape.length)) { 578 if (left && (index + 3 < shape.length)) {
578 left = onBottom ? oldY <= shape[index+3] : oldY >= shape[index+3]; 579 left = onBottom ? oldY <= shape[index+3] : oldY >= shape[index+3];
579 oldY = shape[index+1]; 580 oldY = shape[index+1];
580 } 581 }
581 inner[index] = shape[index++] + (left ? +1 : -1); 582 inner[index] = shape[index] + (left ? +1 : -1);
582 inner[index] = shape[index++]; 583 index++;
584 inner[index] = shape[index];
585 index++;
583 } 586 }
584 RGB from = lineRGB; 587 RGB from = lineRGB;
585 RGB to = innerRGB; 588 RGB to = innerRGB;
586 int red = from.red + 2*(to.red - from.red)/3; 589 int red = from.red + 2*(to.red - from.red)/3;
587 int green = from.green + 2*(to.green - from.green)/3; 590 int green = from.green + 2*(to.green - from.green)/3;
1305 int index = 0; 1308 int index = 0;
1306 int length_ = string.length; 1309 int length_ = string.length;
1307 do { 1310 do {
1308 while (index < length_ && string[index] !is '&') index++; 1311 while (index < length_ && string[index] !is '&') index++;
1309 if (++index >= length_) return '\0'; 1312 if (++index >= length_) return '\0';
1310 if (string[index] !is '&') return CharacterToLower(firstCodePoint( string[index..$])); 1313 if (string[index] !is '&') return CharacterFirstToLower(string[index..$]);
1311 index++; 1314 index++;
1312 } while (index < length_); 1315 } while (index < length_);
1313 return '\0'; 1316 return '\0';
1314 } 1317 }
1315 String stripMnemonic (String string) { 1318 String stripMnemonic (String string) {
1317 int length_ = string.length; 1320 int length_ = string.length;
1318 do { 1321 do {
1319 while ((index < length_) && (string[index] !is '&')) index++; 1322 while ((index < length_) && (string[index] !is '&')) index++;
1320 if (++index >= length_) return string; 1323 if (++index >= length_) return string;
1321 if (string[index] !is '&') { 1324 if (string[index] !is '&') {
1322 return string[0 .. index-1] ~ string[index .. length_]; 1325 return string.substring(0, index-1) ~ string.substring(index, length_);
1323 } 1326 }
1324 index++; 1327 index++;
1325 } while (index < length_); 1328 } while (index < length_);
1326 return string; 1329 return string;
1327 } 1330 }
1642 if (items[i] is item) return i; 1645 if (items[i] is item) return i;
1643 } 1646 }
1644 return -1; 1647 return -1;
1645 } 1648 }
1646 void initAccessible() { 1649 void initAccessible() {
1647 final Accessible accessible = getAccessible(); 1650 Accessible accessible = getAccessible();
1648 accessible.addAccessibleListener(new class() AccessibleAdapter { 1651 accessible.addAccessibleListener(new class() AccessibleAdapter {
1649 public void getName(AccessibleEvent e) { 1652 public void getName(AccessibleEvent e) {
1650 String name = null; 1653 String name = null;
1651 int childID = e.childID; 1654 int childID = e.childID;
1652 if (childID >= 0 && childID < items.length) { 1655 if (childID >= 0 && childID < items.length) {
1826 } 1829 }
1827 }); 1830 });
1828 1831
1829 addListener(DWT.Selection, new class(accessible) Listener { 1832 addListener(DWT.Selection, new class(accessible) Listener {
1830 Accessible acc; 1833 Accessible acc;
1831 this( Accessible acc ){ this.acc = acc; } 1834 this( Accessible a ){
1835 this.acc = a;
1836 }
1832 public void handleEvent(Event event) { 1837 public void handleEvent(Event event) {
1833 if (isFocusControl()) { 1838 if (isFocusControl()) {
1834 if (selectedIndex is -1) { 1839 if (selectedIndex is -1) {
1835 acc.setFocus(ACC.CHILDID_SELF); 1840 acc.setFocus(ACC.CHILDID_SELF);
1836 } else { 1841 } else {
1840 } 1845 }
1841 }); 1846 });
1842 1847
1843 addListener(DWT.FocusIn, new class(accessible) Listener { 1848 addListener(DWT.FocusIn, new class(accessible) Listener {
1844 Accessible acc; 1849 Accessible acc;
1845 this( Accessible acc ){ this.acc = acc; } 1850 this( Accessible a ){ this.acc = a; }
1846 public void handleEvent(Event event) { 1851 public void handleEvent(Event event) {
1847 if (selectedIndex is -1) { 1852 if (selectedIndex is -1) {
1848 acc.setFocus(ACC.CHILDID_SELF); 1853 acc.setFocus(ACC.CHILDID_SELF);
1849 } else { 1854 } else {
1850 acc.setFocus(selectedIndex); 1855 acc.setFocus(selectedIndex);
1851 } 1856 }
1852 } 1857 }
1853 }); 1858 });
1854 } 1859 }
1860
1855 void onKeyDown (Event event) { 1861 void onKeyDown (Event event) {
1856 switch (event.keyCode) { 1862 switch (event.keyCode) {
1857 case DWT.ARROW_LEFT: 1863 case DWT.ARROW_LEFT:
1858 case DWT.ARROW_RIGHT: 1864 case DWT.ARROW_RIGHT:
1859 int count = items.length; 1865 int count = items.length;