Mercurial > projects > dwt-linux
comparison dwt/custom/CTabFolder.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | d0081b1505da |
children | ce446666f5a2 |
comparison
equal
deleted
inserted
replaced
237:98b80b00af79 | 238:380bad9f6852 |
---|---|
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 | 14 |
15 import tango.util.log.Trace; | |
15 | 16 |
16 import dwt.DWT; | 17 import dwt.DWT; |
17 import dwt.DWTException; | 18 import dwt.DWTException; |
18 import dwt.accessibility.ACC; | 19 import dwt.accessibility.ACC; |
19 import dwt.accessibility.Accessible; | 20 import dwt.accessibility.Accessible; |
409 * but a texture. To show the correct default background, we must allow | 410 * but a texture. To show the correct default background, we must allow |
410 * the operating system to draw it and therefore, we can not use the | 411 * the operating system to draw it and therefore, we can not use the |
411 * NO_BACKGROUND style. The NO_BACKGROUND style is not required on platforms | 412 * NO_BACKGROUND style. The NO_BACKGROUND style is not required on platforms |
412 * that use double buffering which is true in both of these cases. | 413 * that use double buffering which is true in both of these cases. |
413 */ | 414 */ |
414 char[] platform = DWT.getPlatform(); | 415 String platform = DWT.getPlatform(); |
415 if ("carbon"==platform || "gtk"==platform) return style; //$NON-NLS-1$ //$NON-NLS-2$ | 416 if ("carbon"==platform || "gtk"==platform) return style; //$NON-NLS-1$ //$NON-NLS-2$ |
416 | 417 |
417 //TEMPORARY CODE | 418 //TEMPORARY CODE |
418 /* | 419 /* |
419 * In Right To Left orientation on Windows, all GC calls that use a brush are drawing | 420 * In Right To Left orientation on Windows, all GC calls that use a brush are drawing |
881 while (showCount < priority.length && items[priority[showCount]].showing) { | 882 while (showCount < priority.length && items[priority[showCount]].showing) { |
882 showCount++; | 883 showCount++; |
883 } | 884 } |
884 count = items.length - showCount; | 885 count = items.length - showCount; |
885 } | 886 } |
886 char[] chevronString = count > 99 ? "99+" : to!(char[])(count); //$NON-NLS-1$ | 887 String chevronString = count > 99 ? "99+" : to!(String)(count); //$NON-NLS-1$ |
887 switch (chevronImageState) { | 888 switch (chevronImageState) { |
888 case NORMAL: { | 889 case NORMAL: { |
889 Color chevronBorder = single ? getSelectionForeground() : getForeground(); | 890 Color chevronBorder = single ? getSelectionForeground() : getForeground(); |
890 gc.setForeground(chevronBorder); | 891 gc.setForeground(chevronBorder); |
891 gc.setFont(f); | 892 gc.setFont(f); |
1298 /* | 1299 /* |
1299 * Return the lowercase of the first non-'&' character following | 1300 * Return the lowercase of the first non-'&' character following |
1300 * an '&' character in the given string. If there are no '&' | 1301 * an '&' character in the given string. If there are no '&' |
1301 * characters in the given string, return '\0'. | 1302 * characters in the given string, return '\0'. |
1302 */ | 1303 */ |
1303 dchar _findMnemonic (char[] string) { | 1304 dchar _findMnemonic (String string) { |
1304 if (string is null) return '\0'; | 1305 if (string is null) return '\0'; |
1305 int index = 0; | 1306 int index = 0; |
1306 int length_ = string.length; | 1307 int length_ = string.length; |
1307 do { | 1308 do { |
1308 while (index < length_ && string[index] !is '&') index++; | 1309 while (index < length_ && string[index] !is '&') index++; |
1310 if (string[index] !is '&') return CharacterFirstToLower(string[index..$]); | 1311 if (string[index] !is '&') return CharacterFirstToLower(string[index..$]); |
1311 index++; | 1312 index++; |
1312 } while (index < length_); | 1313 } while (index < length_); |
1313 return '\0'; | 1314 return '\0'; |
1314 } | 1315 } |
1315 char[] stripMnemonic (char[] string) { | 1316 String stripMnemonic (String string) { |
1316 int index = 0; | 1317 int index = 0; |
1317 int length_ = string.length; | 1318 int length_ = string.length; |
1318 do { | 1319 do { |
1319 while ((index < length_) && (string[index] !is '&')) index++; | 1320 while ((index < length_) && (string[index] !is '&')) index++; |
1320 if (++index >= length_) return string; | 1321 if (++index >= length_) return string; |
1640 if (items[i] is item) return i; | 1641 if (items[i] is item) return i; |
1641 } | 1642 } |
1642 return -1; | 1643 return -1; |
1643 } | 1644 } |
1644 void initAccessible() { | 1645 void initAccessible() { |
1645 final Accessible accessible = getAccessible(); | 1646 Accessible accessible = getAccessible(); |
1646 accessible.addAccessibleListener(new class() AccessibleAdapter { | 1647 accessible.addAccessibleListener(new class() AccessibleAdapter { |
1647 public void getName(AccessibleEvent e) { | 1648 public void getName(AccessibleEvent e) { |
1648 char[] name = null; | 1649 String name = null; |
1649 int childID = e.childID; | 1650 int childID = e.childID; |
1650 if (childID >= 0 && childID < items.length) { | 1651 if (childID >= 0 && childID < items.length) { |
1651 name = stripMnemonic(items[childID].getText()); | 1652 name = stripMnemonic(items[childID].getText()); |
1652 } else if (childID is items.length + CHEVRON_CHILD_ID) { | 1653 } else if (childID is items.length + CHEVRON_CHILD_ID) { |
1653 name = DWT.getMessage("SWT_ShowList"); //$NON-NLS-1$ | 1654 name = DWT.getMessage("SWT_ShowList"); //$NON-NLS-1$ |
1658 } | 1659 } |
1659 e.result = name; | 1660 e.result = name; |
1660 } | 1661 } |
1661 | 1662 |
1662 public void getHelp(AccessibleEvent e) { | 1663 public void getHelp(AccessibleEvent e) { |
1663 char[] help = null; | 1664 String help = null; |
1664 int childID = e.childID; | 1665 int childID = e.childID; |
1665 if (childID is ACC.CHILDID_SELF) { | 1666 if (childID is ACC.CHILDID_SELF) { |
1666 help = getToolTipText(); | 1667 help = getToolTipText(); |
1667 } else if (childID >= 0 && childID < items.length) { | 1668 } else if (childID >= 0 && childID < items.length) { |
1668 help = items[childID].getToolTipText(); | 1669 help = items[childID].getToolTipText(); |
1669 } | 1670 } |
1670 e.result = help; | 1671 e.result = help; |
1671 } | 1672 } |
1672 | 1673 |
1673 public void getKeyboardShortcut(AccessibleEvent e) { | 1674 public void getKeyboardShortcut(AccessibleEvent e) { |
1674 char[] shortcut = null; | 1675 String shortcut = null; |
1675 int childID = e.childID; | 1676 int childID = e.childID; |
1676 if (childID >= 0 && childID < items.length) { | 1677 if (childID >= 0 && childID < items.length) { |
1677 char[] text = items[childID].getText(); | 1678 String text = items[childID].getText(); |
1678 if (text !is null) { | 1679 if (text !is null) { |
1679 dchar mnemonic = _findMnemonic(text); | 1680 dchar mnemonic = _findMnemonic(text); |
1680 if (mnemonic !is '\0') { | 1681 if (mnemonic !is '\0') { |
1681 shortcut = "Alt+"~tango.text.convert.Utf.toString([mnemonic]); //$NON-NLS-1$ | 1682 shortcut = "Alt+"~tango.text.convert.Utf.toString([mnemonic]); //$NON-NLS-1$ |
1682 } | 1683 } |
1740 public void getChildCount(AccessibleControlEvent e) { | 1741 public void getChildCount(AccessibleControlEvent e) { |
1741 e.detail = items.length + EXTRA_CHILD_ID_COUNT; | 1742 e.detail = items.length + EXTRA_CHILD_ID_COUNT; |
1742 } | 1743 } |
1743 | 1744 |
1744 public void getDefaultAction(AccessibleControlEvent e) { | 1745 public void getDefaultAction(AccessibleControlEvent e) { |
1745 char[] action = null; | 1746 String action = null; |
1746 int childID = e.childID; | 1747 int childID = e.childID; |
1747 if (childID >= 0 && childID < items.length) { | 1748 if (childID >= 0 && childID < items.length) { |
1748 action = DWT.getMessage ("SWT_Switch"); //$NON-NLS-1$ | 1749 action = DWT.getMessage ("SWT_Switch"); //$NON-NLS-1$ |
1749 } | 1750 } |
1750 if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT) { | 1751 if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT) { |
1816 } | 1817 } |
1817 e.children = children; | 1818 e.children = children; |
1818 } | 1819 } |
1819 }); | 1820 }); |
1820 | 1821 |
1821 addListener(DWT.Selection, new class(accessible) Listener { | 1822 addListener(DWT.Selection, getInst(accessible) ); |
1822 Accessible acc; | 1823 addListener(DWT.FocusIn, new class(accessible) Listener { |
1823 this( Accessible acc ){ this.acc = acc; } | 1824 Accessible acc2; |
1825 this( Accessible acc2 ){ this.acc2 = acc2; } | |
1824 public void handleEvent(Event event) { | 1826 public void handleEvent(Event event) { |
1825 if (isFocusControl()) { | 1827 if (this.outer.selectedIndex is -1) { |
1828 acc2.setFocus(ACC.CHILDID_SELF); | |
1829 } else { | |
1830 acc2.setFocus(this.outer.selectedIndex); | |
1831 } | |
1832 } | |
1833 }); | |
1834 } | |
1835 Listener getInst(Accessible accessible ){ | |
1836 return new class/+accessible+/ Listener { | |
1837 //Accessible acc; | |
1838 //this( Accessible acc ){ this.acc = acc; } | |
1839 public void handleEvent(Event event) { | |
1840 Trace.formatln( "{} {}", __FILE__, __LINE__ ); | |
1841 Trace.formatln( "{} {} {}", __FILE__, __LINE__, cast(void*)this ); | |
1842 Trace.formatln( "{} {} {}", __FILE__, __LINE__, cast(void*)this.outer ); | |
1843 //auto p = &this.outer.isFocusControl; | |
1844 //Trace.formatln( "{} {} {}", __FILE__, __LINE__, cast(void*)p.ptr ); | |
1845 //Trace.formatln( "{} {} {}", __FILE__, __LINE__, cast(void*)p.funcptr ); | |
1846 test(); | |
1847 Trace.formatln( "{} {}", __FILE__, __LINE__ ); | |
1848 // if (this.outer.isFocusControl()) { | |
1849 // Trace.formatln( "{} {}", __FILE__, __LINE__ ); | |
1826 if (selectedIndex is -1) { | 1850 if (selectedIndex is -1) { |
1827 acc.setFocus(ACC.CHILDID_SELF); | 1851 // Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1828 } else { | 1852 // acc.setFocus(ACC.CHILDID_SELF); |
1829 acc.setFocus(selectedIndex); | 1853 // Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1830 } | 1854 // } else { |
1831 } | 1855 // Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1832 } | 1856 // // acc.setFocus(this.outer.selectedIndex); |
1833 }); | 1857 // Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1834 | 1858 // } |
1835 addListener(DWT.FocusIn, new class(accessible) Listener { | 1859 Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1836 Accessible acc; | 1860 } |
1837 this( Accessible acc ){ this.acc = acc; } | 1861 Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1838 public void handleEvent(Event event) { | 1862 |
1839 if (selectedIndex is -1) { | 1863 } |
1840 acc.setFocus(ACC.CHILDID_SELF); | 1864 }; |
1841 } else { | 1865 } |
1842 acc.setFocus(selectedIndex); | 1866 void test(){ |
1843 } | 1867 Trace.formatln( "{} {}", __FILE__, __LINE__ ); |
1844 } | |
1845 }); | |
1846 } | 1868 } |
1847 void onKeyDown (Event event) { | 1869 void onKeyDown (Event event) { |
1848 switch (event.keyCode) { | 1870 switch (event.keyCode) { |
1849 case DWT.ARROW_LEFT: | 1871 case DWT.ARROW_LEFT: |
1850 case DWT.ARROW_RIGHT: | 1872 case DWT.ARROW_RIGHT: |
3870 MenuItem[] items = showMenu.getItems(); | 3892 MenuItem[] items = showMenu.getItems(); |
3871 for (int i = 0; i < items.length; i++) { | 3893 for (int i = 0; i < items.length; i++) { |
3872 items[i].dispose(); | 3894 items[i].dispose(); |
3873 } | 3895 } |
3874 } | 3896 } |
3875 static const char[] id = "CTabFolder_showList_Index"; //$NON-NLS-1$ | 3897 static const String id = "CTabFolder_showList_Index"; //$NON-NLS-1$ |
3876 for (int i = 0; i < items.length; i++) { | 3898 for (int i = 0; i < items.length; i++) { |
3877 CTabItem tab = items[i]; | 3899 CTabItem tab = items[i]; |
3878 if (tab.showing) continue; | 3900 if (tab.showing) continue; |
3879 MenuItem item = new MenuItem(showMenu, DWT.NONE); | 3901 MenuItem item = new MenuItem(showMenu, DWT.NONE); |
3880 item.setText(tab.getText()); | 3902 item.setText(tab.getText()); |
3914 showItem(getSelection()); | 3936 showItem(getSelection()); |
3915 } | 3937 } |
3916 } | 3938 } |
3917 | 3939 |
3918 void _setToolTipText (int x, int y) { | 3940 void _setToolTipText (int x, int y) { |
3919 char[] oldTip = getToolTipText(); | 3941 String oldTip = getToolTipText(); |
3920 char[] newTip = _getToolTip(x, y); | 3942 String newTip = _getToolTip(x, y); |
3921 if (newTip is null || newTip!=oldTip) { | 3943 if (newTip is null || newTip!=oldTip) { |
3922 setToolTipText(newTip); | 3944 setToolTipText(newTip); |
3923 } | 3945 } |
3924 } | 3946 } |
3925 | 3947 |
4047 20+d, 12+d, 21+d, 12+d, 22+d, 12+d ]; | 4069 20+d, 12+d, 21+d, 12+d, 22+d, 12+d ]; |
4048 } | 4070 } |
4049 notifyListeners(DWT.Resize, new Event()); | 4071 notifyListeners(DWT.Resize, new Event()); |
4050 return true; | 4072 return true; |
4051 } | 4073 } |
4052 char[] _getToolTip(int x, int y) { | 4074 String _getToolTip(int x, int y) { |
4053 if (showMin && minRect.contains(x, y)) return minimized ? DWT.getMessage("SWT_Restore") : DWT.getMessage("SWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$ | 4075 if (showMin && minRect.contains(x, y)) return minimized ? DWT.getMessage("SWT_Restore") : DWT.getMessage("SWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$ |
4054 if (showMax && maxRect.contains(x, y)) return maximized ? DWT.getMessage("SWT_Restore") : DWT.getMessage("SWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$ | 4076 if (showMax && maxRect.contains(x, y)) return maximized ? DWT.getMessage("SWT_Restore") : DWT.getMessage("SWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$ |
4055 if (showChevron && chevronRect.contains(x, y)) return DWT.getMessage("SWT_ShowList"); //$NON-NLS-1$ | 4077 if (showChevron && chevronRect.contains(x, y)) return DWT.getMessage("SWT_ShowList"); //$NON-NLS-1$ |
4056 CTabItem item = getItem(new Point (x, y)); | 4078 CTabItem item = getItem(new Point (x, y)); |
4057 if (item is null) return null; | 4079 if (item is null) return null; |