Changeset 145:d4b244e1e1ae
- Timestamp:
- 01/22/08 19:59:19
(7 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
CustomControlExample? compiles
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r143 |
r145 |
|
| 100 | 100 | buildflags+=-g -gc |
|---|
| 101 | 101 | buildflags+=-Jdwtexamples/controlexample |
|---|
| | 102 | buildflags+=-version=CONTROL_EXAMPLE_MAIN |
|---|
| 102 | 103 | |
|---|
| | 104 | [dwtexamples/controlexample/CustomControlExample.d] |
|---|
| | 105 | buildflags+=-L-lgtk-x11-2.0 |
|---|
| | 106 | buildflags+=-L-lgdk-x11-2.0 |
|---|
| | 107 | buildflags+=-L-latk-1.0 |
|---|
| | 108 | buildflags+=-L-lgdk_pixbuf-2.0 |
|---|
| | 109 | buildflags+=-L-lgthread-2.0 |
|---|
| | 110 | buildflags+=-L-lm |
|---|
| | 111 | buildflags+=-L-lpangocairo-1.0 |
|---|
| | 112 | buildflags+=-L-lfontconfig |
|---|
| | 113 | buildflags+=-L-lXtst |
|---|
| | 114 | buildflags+=-L-lXext |
|---|
| | 115 | buildflags+=-L-lXrender |
|---|
| | 116 | buildflags+=-L-lXinerama |
|---|
| | 117 | buildflags+=-L-lXi |
|---|
| | 118 | buildflags+=-L-lXrandr |
|---|
| | 119 | buildflags+=-L-lXcursor |
|---|
| | 120 | buildflags+=-L-lXcomposite |
|---|
| | 121 | buildflags+=-L-lXdamage |
|---|
| | 122 | buildflags+=-L-lX11 |
|---|
| | 123 | buildflags+=-L-lXfixes |
|---|
| | 124 | buildflags+=-L-lpango-1.0 |
|---|
| | 125 | buildflags+=-L-lgobject-2.0 |
|---|
| | 126 | buildflags+=-L-lgmodule-2.0 |
|---|
| | 127 | buildflags+=-L-ldl |
|---|
| | 128 | buildflags+=-L-lglib-2.0 |
|---|
| | 129 | buildflags+=-L-lcairo |
|---|
| | 130 | buildflags+=-g -gc |
|---|
| | 131 | buildflags+=-Jdwtexamples/controlexample |
|---|
| | 132 | buildflags+=-version=CUSTOM_CONTROL_EXAMPLE_MAIN |
|---|
| r144 |
r145 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 35 | 35 | Button flatButton, readOnlyButton; |
|---|
| 36 | 36 | |
|---|
| 37 | | static char[] [] ListData = {ControlExample.getResourceString("ListData1_0"), |
|---|
| 38 | | ControlExample.getResourceString("ListData1_1"), |
|---|
| 39 | | ControlExample.getResourceString("ListData1_2"), |
|---|
| 40 | | ControlExample.getResourceString("ListData1_3"), |
|---|
| 41 | | ControlExample.getResourceString("ListData1_4"), |
|---|
| 42 | | ControlExample.getResourceString("ListData1_5"), |
|---|
| 43 | | ControlExample.getResourceString("ListData1_6"), |
|---|
| 44 | | ControlExample.getResourceString("ListData1_7"), |
|---|
| 45 | | ControlExample.getResourceString("ListData1_8")}; |
|---|
| | 37 | static char[] [] ListData; |
|---|
| 46 | 38 | |
|---|
| 47 | 39 | /** |
|---|
| … | … | |
| 50 | 42 | this(ControlExample instance) { |
|---|
| 51 | 43 | super(instance); |
|---|
| | 44 | if( ListData is null ){ |
|---|
| | 45 | ListData = [ |
|---|
| | 46 | ControlExample.getResourceString("ListData1_0"), |
|---|
| | 47 | ControlExample.getResourceString("ListData1_1"), |
|---|
| | 48 | ControlExample.getResourceString("ListData1_2"), |
|---|
| | 49 | ControlExample.getResourceString("ListData1_3"), |
|---|
| | 50 | ControlExample.getResourceString("ListData1_4"), |
|---|
| | 51 | ControlExample.getResourceString("ListData1_5"), |
|---|
| | 52 | ControlExample.getResourceString("ListData1_6"), |
|---|
| | 53 | ControlExample.getResourceString("ListData1_7"), |
|---|
| | 54 | ControlExample.getResourceString("ListData1_8")]; |
|---|
| | 55 | } |
|---|
| 52 | 56 | } |
|---|
| 53 | 57 | |
|---|
| r144 |
r145 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 23 | 23 | import dwt.widgets.Widget; |
|---|
| 24 | 24 | |
|---|
| | 25 | |
|---|
| | 26 | import dwtexamples.controlexample.AlignableTab; |
|---|
| | 27 | import dwtexamples.controlexample.ControlExample; |
|---|
| | 28 | |
|---|
| | 29 | import tango.text.convert.Format; |
|---|
| | 30 | |
|---|
| 25 | 31 | class CLabelTab : AlignableTab { |
|---|
| 26 | 32 | /* Example widgets and groups that contain them */ |
|---|
| … | … | |
| 34 | 40 | * Creates the Tab within a given instance of ControlExample. |
|---|
| 35 | 41 | */ |
|---|
| 36 | | CLabelTab(ControlExample instance) { |
|---|
| | 42 | this(ControlExample instance) { |
|---|
| 37 | 43 | super(instance); |
|---|
| 38 | 44 | } |
|---|
| … | … | |
| 74 | 80 | label2.setImage (instance.images[ControlExample.ciTarget]); |
|---|
| 75 | 81 | label3 = new CLabel (textLabelGroup, style); |
|---|
| 76 | | label3.setText(ControlExample.getResourceString("Example_string") + "\n" + ControlExample.getResourceString("One_Two_Three")); |
|---|
| | 82 | label3.setText(Format( "{}\n{}", ControlExample.getResourceString("Example_string"), ControlExample.getResourceString("One_Two_Three"))); |
|---|
| 77 | 83 | } |
|---|
| 78 | 84 | |
|---|
| … | … | |
| 96 | 102 | */ |
|---|
| 97 | 103 | Widget [] getExampleWidgets () { |
|---|
| 98 | | return new Widget [] {label1, label2, label3}; |
|---|
| | 104 | return [ cast(Widget) label1, label2, label3]; |
|---|
| 99 | 105 | } |
|---|
| 100 | 106 | |
|---|
| … | … | |
| 103 | 109 | * that can be used to set/get values in the example control(s). |
|---|
| 104 | 110 | */ |
|---|
| 105 | | String[] getMethodNames() { |
|---|
| 106 | | return new String[] {"Text", "ToolTipText"}; |
|---|
| | 111 | char[][] getMethodNames() { |
|---|
| | 112 | return ["Text", "ToolTipText"]; |
|---|
| 107 | 113 | } |
|---|
| 108 | 114 | |
|---|
| … | … | |
| 110 | 116 | * Gets the text for the tab folder item. |
|---|
| 111 | 117 | */ |
|---|
| 112 | | String getTabText () { |
|---|
| | 118 | char[] getTabText () { |
|---|
| 113 | 119 | return "CLabel"; |
|---|
| 114 | 120 | } |
|---|
| r144 |
r145 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 40 | 40 | import dwt.widgets.Widget; |
|---|
| 41 | 41 | |
|---|
| | 42 | import dwtexamples.controlexample.Tab; |
|---|
| | 43 | import dwtexamples.controlexample.ControlExample; |
|---|
| | 44 | |
|---|
| | 45 | import tango.text.convert.Format; |
|---|
| | 46 | |
|---|
| 42 | 47 | class CTabFolderTab : Tab { |
|---|
| 43 | 48 | int lastSelectedTab = 0; |
|---|
| … | … | |
| 50 | 55 | Button topButton, bottomButton, flatButton, closeButton; |
|---|
| 51 | 56 | |
|---|
| 52 | | static String [] CTabItems1 = {ControlExample.getResourceString("CTabItem1_0"), |
|---|
| 53 | | ControlExample.getResourceString("CTabItem1_1"), |
|---|
| 54 | | ControlExample.getResourceString("CTabItem1_2")}; |
|---|
| | 57 | static char[] [] CTabItems1; |
|---|
| 55 | 58 | |
|---|
| 56 | 59 | /* Controls and resources added to the "Fonts" group */ |
|---|
| 57 | | static final int SELECTION_FOREGROUND_COLOR = 3; |
|---|
| 58 | | static final int SELECTION_BACKGROUND_COLOR = 4; |
|---|
| 59 | | static final int ITEM_FONT = 5; |
|---|
| | 60 | static const int SELECTION_FOREGROUND_COLOR = 3; |
|---|
| | 61 | static const int SELECTION_BACKGROUND_COLOR = 4; |
|---|
| | 62 | static const int ITEM_FONT = 5; |
|---|
| 60 | 63 | Color selectionForegroundColor, selectionBackgroundColor; |
|---|
| 61 | 64 | Font itemFont; |
|---|
| … | … | |
| 69 | 72 | this(ControlExample instance) { |
|---|
| 70 | 73 | super(instance); |
|---|
| | 74 | if( CTabItems1 is null ){ |
|---|
| | 75 | CTabItems1 = [ |
|---|
| | 76 | ControlExample.getResourceString("CTabItem1_0"), |
|---|
| | 77 | ControlExample.getResourceString("CTabItem1_1"), |
|---|
| | 78 | ControlExample.getResourceString("CTabItem1_2")]; |
|---|
| | 79 | } |
|---|
| 71 | 80 | } |
|---|
| 72 | 81 | |
|---|
| … | … | |
| 84 | 93 | item.setText(ControlExample.getResourceString ("Item_Font")); |
|---|
| 85 | 94 | |
|---|
| 86 | | shell.addDisposeListener(new DisposeListener() { |
|---|
| | 95 | shell.addDisposeListener(new class() DisposeListener { |
|---|
| 87 | 96 | public void widgetDisposed(DisposeEvent event) { |
|---|
| 88 | 97 | if (selectionBackgroundColor !is null) selectionBackgroundColor.dispose(); |
|---|
| … | … | |
| 150 | 159 | simpleTabButton.setText (ControlExample.getResourceString("Set_Simple_Tabs")); |
|---|
| 151 | 160 | simpleTabButton.setSelection(true); |
|---|
| 152 | | simpleTabButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 161 | simpleTabButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 153 | 162 | public void widgetSelected (SelectionEvent event) { |
|---|
| 154 | 163 | setSimpleTabs(); |
|---|
| … | … | |
| 159 | 168 | singleTabButton.setText (ControlExample.getResourceString("Set_Single_Tabs")); |
|---|
| 160 | 169 | singleTabButton.setSelection(false); |
|---|
| 161 | | singleTabButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 170 | singleTabButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 162 | 171 | public void widgetSelected (SelectionEvent event) { |
|---|
| 163 | 172 | setSingleTabs(); |
|---|
| … | … | |
| 168 | 177 | showMinButton.setText (ControlExample.getResourceString("Set_Min_Visible")); |
|---|
| 169 | 178 | showMinButton.setSelection(false); |
|---|
| 170 | | showMinButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 179 | showMinButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 171 | 180 | public void widgetSelected (SelectionEvent event) { |
|---|
| 172 | 181 | setMinimizeVisible(); |
|---|
| … | … | |
| 177 | 186 | showMaxButton.setText (ControlExample.getResourceString("Set_Max_Visible")); |
|---|
| 178 | 187 | showMaxButton.setSelection(false); |
|---|
| 179 | | showMaxButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 188 | showMaxButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 180 | 189 | public void widgetSelected (SelectionEvent event) { |
|---|
| 181 | 190 | setMaximizeVisible(); |
|---|
| … | … | |
| 185 | 194 | imageButton = new Button (otherGroup, DWT.CHECK); |
|---|
| 186 | 195 | imageButton.setText (ControlExample.getResourceString("Set_Image")); |
|---|
| 187 | | imageButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 196 | imageButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 188 | 197 | public void widgetSelected (SelectionEvent event) { |
|---|
| 189 | 198 | setImages(); |
|---|
| … | … | |
| 194 | 203 | unselectedImageButton.setText (ControlExample.getResourceString("Set_Unselected_Image_Visible")); |
|---|
| 195 | 204 | unselectedImageButton.setSelection(true); |
|---|
| 196 | | unselectedImageButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 205 | unselectedImageButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 197 | 206 | public void widgetSelected (SelectionEvent event) { |
|---|
| 198 | 207 | setUnselectedImageVisible(); |
|---|
| … | … | |
| 202 | 211 | unselectedCloseButton.setText (ControlExample.getResourceString("Set_Unselected_Close_Visible")); |
|---|
| 203 | 212 | unselectedCloseButton.setSelection(true); |
|---|
| 204 | | unselectedCloseButton.addSelectionListener (new SelectionAdapter () { |
|---|
| | 213 | unselectedCloseButton.addSelectionListener (new class() SelectionAdapter { |
|---|
| 205 | 214 | public void widgetSelected (SelectionEvent event) { |
|---|
| 206 | 215 | setUnselectedCloseVisible(); |
|---|
| … | … | |
| 241 | 250 | item.setText(CTabItems1[i]); |
|---|
| 242 | 251 | Text text = new Text(tabFolder1, DWT.READ_ONLY); |
|---|
| 243 | | text.setText(ControlExample.getResourceString("CTabItem_content") + ": " + i); |
|---|
| | 252 | text.setText(Format( "{}: {}", ControlExample.getResourceString("CTabItem_content"), i)); |
|---|
| 244 | 253 | item.setControl(text); |
|---|
| 245 | 254 | } |
|---|
| 246 | | tabFolder1.addListener(DWT.Selection, new Listener() { |
|---|
| | 255 | tabFolder1.addListener(DWT.Selection, new class() Listener { |
|---|
| 247 | 256 | public void handleEvent(Event event) { |
|---|
| 248 | 257 | lastSelectedTab = tabFolder1.getSelectionIndex(); |
|---|
| … | … | |
| 277 | 286 | * @return an array containing custom event names |
|---|
| 278 | 287 | */ |
|---|
| 279 | | String [] getCustomEventNames () { |
|---|
| 280 | | return new String [] {"CTabFolderEvent"}; |
|---|
| | 288 | char[] [] getCustomEventNames () { |
|---|
| | 289 | return ["CTabFolderEvent"]; |
|---|
| 281 | 290 | } |
|---|
| 282 | 291 | |
|---|
| … | … | |
| 294 | 303 | */ |
|---|
| 295 | 304 | Widget [] getExampleWidgets () { |
|---|
| 296 | | return new Widget [] {tabFolder1}; |
|---|
| | 305 | return [ cast(Widget) tabFolder1]; |
|---|
| 297 | 306 | } |
|---|
| 298 | 307 | |
|---|
| … | … | |
| 300 | 309 | * Gets the text for the tab folder item. |
|---|
| 301 | 310 | */ |
|---|
| 302 | | String getTabText () { |
|---|
| | 311 | char[] getTabText () { |
|---|
| 303 | 312 | return "CTabFolder"; |
|---|
| 304 | 313 | } |
|---|
| … | … | |
| 307 | 316 | * Hooks the custom listener specified by eventName. |
|---|
| 308 | 317 | */ |
|---|
| 309 | | void hookCustomListener (final String eventName) { |
|---|
| | 318 | void hookCustomListener (char[] eventName) { |
|---|
| 310 | 319 | if (eventName is "CTabFolderEvent") { |
|---|
| 311 | | tabFolder1.addCTabFolder2Listener (new CTabFolder2Adapter () { |
|---|
| | 320 | tabFolder1.addCTabFolder2Listener (new class(eventName) CTabFolder2Adapter { |
|---|
| | 321 | char[] name; |
|---|
| | 322 | this( char[] name ){ this.name = name; } |
|---|
| 312 | 323 | public void close (CTabFolderEvent event) { |
|---|
| 313 | | log (eventName, event); |
|---|
| | 324 | log (name, event); |
|---|
| 314 | 325 | } |
|---|
| 315 | 326 | }); |
|---|
| r144 |
r145 |
|
| 12 | 12 | *******************************************************************************/ |
|---|
| 13 | 13 | module dwtexamples.controlexample.ControlExample; |
|---|
| 14 | | |
|---|
| 15 | | pragma( msg, "The ControlExample: still work left" ); |
|---|
| 16 | | pragma( msg, "todo: search for //PORTING_LEFT" ); |
|---|
| 17 | | pragma( msg, "todo: Implement Get/Set API reflection" ); |
|---|
| 18 | | pragma( msg, "todo: DateTimeTab not implemented" ); |
|---|
| 19 | | pragma( msg, "todo: ExpandBarTab looks strange" ); |
|---|
| 20 | | pragma( msg, "todo: ProgressBarTab crash on vertical" ); |
|---|
| 21 | | pragma( msg, "todo: SliderTab horizontal arrow buttons are too high" ); |
|---|
| 22 | | pragma( msg, "please report problems" ); |
|---|
| 23 | 14 | |
|---|
| 24 | 15 | import dwt.DWT; |
|---|
| … | … | |
| 81 | 72 | } |
|---|
| 82 | 73 | |
|---|
| 83 | | void main(){ |
|---|
| 84 | | ControlExample.main( null ); |
|---|
| | 74 | version( CONTROL_EXAMPLE_MAIN ){ |
|---|
| | 75 | void main(){ |
|---|
| | 76 | Stdout.formatln( "The ControlExample: still work left" ); |
|---|
| | 77 | Stdout.formatln( "todo: search for //PORTING_LEFT" ); |
|---|
| | 78 | Stdout.formatln( "todo: Implement Get/Set API reflection" ); |
|---|
| | 79 | Stdout.formatln( "todo: DateTimeTab not implemented" ); |
|---|
| | 80 | Stdout.formatln( "todo: ExpandBarTab looks strange" ); |
|---|
| | 81 | Stdout.formatln( "todo: ProgressBarTab crash on vertical" ); |
|---|
| | 82 | Stdout.formatln( "todo: SliderTab horizontal arrow buttons are too high" ); |
|---|
| | 83 | Stdout.formatln( "please report problems" ); |
|---|
| | 84 | ControlExample.main( null ); |
|---|
| | 85 | } |
|---|
| 85 | 86 | } |
|---|
| 86 | 87 | |
|---|
| r144 |
r145 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 19 | 19 | import dwt.widgets.Shell; |
|---|
| 20 | 20 | |
|---|
| | 21 | import dwtexamples.controlexample.ControlExample; |
|---|
| | 22 | import dwtexamples.controlexample.CComboTab; |
|---|
| | 23 | import dwtexamples.controlexample.CLabelTab; |
|---|
| | 24 | import dwtexamples.controlexample.CTabFolderTab; |
|---|
| | 25 | import dwtexamples.controlexample.SashFormTab; |
|---|
| | 26 | import dwtexamples.controlexample.StyledTextTab; |
|---|
| | 27 | |
|---|
| | 28 | import dwtexamples.controlexample.Tab; |
|---|
| | 29 | import tango.io.Stdout; |
|---|
| | 30 | |
|---|
| | 31 | version( CUSTOM_CONTROL_EXAMPLE_MAIN ){ |
|---|
| | 32 | void main(){ |
|---|
| | 33 | Stdout.formatln( "The CustomControlExample: still work left" ); |
|---|
| | 34 | Stdout.formatln( "please report problems" ); |
|---|
| | 35 | CustomControlExample.main( null ); |
|---|
| | 36 | } |
|---|
| | 37 | } |
|---|
| 21 | 38 | |
|---|
| 22 | 39 | public class CustomControlExample : ControlExample { |
|---|
| … | … | |
| 36 | 53 | */ |
|---|
| 37 | 54 | Tab[] createTabs() { |
|---|
| 38 | | return new Tab [] { |
|---|
| | 55 | return [ cast(Tab) |
|---|
| 39 | 56 | new CComboTab (this), |
|---|
| 40 | 57 | new CLabelTab (this), |
|---|
| 41 | 58 | new CTabFolderTab (this), |
|---|
| 42 | 59 | new SashFormTab (this), |
|---|
| 43 | | new StyledTextTab (this), |
|---|
| 44 | | }; |
|---|
| | 60 | new StyledTextTab (this) |
|---|
| | 61 | ]; |
|---|
| 45 | 62 | } |
|---|
| 46 | 63 | |
|---|
| … | … | |
| 48 | 65 | * Invokes as a standalone program. |
|---|
| 49 | 66 | */ |
|---|
| 50 | | public static void main(String[] args) { |
|---|
| | 67 | public static void main(char[][] args) { |
|---|
| | 68 | Stdout.formatln( "{}", __LINE__ ); |
|---|
| 51 | 69 | Display display = new Display(); |
|---|
| | 70 | Stdout.formatln( "{}", __LINE__ ); |
|---|
| 52 | 71 | Shell shell = new Shell(display); |
|---|
| | 72 | Stdout.formatln( "{}", __LINE__ ); |
|---|
| 53 | 73 | shell.setLayout(new FillLayout()); |
|---|
| | 74 | Stdout.formatln( "{}", __LINE__ ); |
|---|
| 54 | 75 | CustomControlExample instance = new CustomControlExample(shell); |
|---|
| | 76 | Stdout.formatln( "{}", __LINE__ ); |
|---|
| 55 | 77 | shell.setText(getResourceString("custom.window.title")); |
|---|
| 56 | 78 | setShellSize(instance, shell); |
|---|
| r144 |
r145 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 25 | 25 | import dwt.widgets.Widget; |
|---|
| 26 | 26 | |
|---|
| | 27 | import dwtexamples.controlexample.Tab; |
|---|
| | 28 | import dwtexamples.controlexample.ControlExample; |
|---|
| | 29 | |
|---|
| | 30 | |
|---|
| 27 | 31 | class SashFormTab : Tab { |
|---|
| 28 | 32 | /* Example widgets and groups that contain them */ |
|---|
| … | … | |
| 35 | 39 | Button horizontalButton, verticalButton, smoothButton; |
|---|
| 36 | 40 | |
|---|
| 37 | | static String [] ListData0 = {ControlExample.getResourceString("ListData0_0"), //$NON-NLS-1$ |
|---|
| 38 | | ControlExample.getResourceString("ListData0_1"), //$NON-NLS-1$ |
|---|
| 39 | | ControlExample.getResourceString("ListData0_2"), //$NON-NLS-1$ |
|---|
| 40 | | ControlExample.getResourceString("ListData0_3"), //$NON-NLS-1$ |
|---|
| 41 | | ControlExample.getResourceString("ListData0_4"), //$NON-NLS-1$ |
|---|
| 42 | | ControlExample.getResourceString("ListData0_5"), //$NON-NLS-1$ |
|---|
| 43 | | ControlExample.getResourceString("ListData0_6"), //$NON-NLS-1$ |
|---|
| 44 | | ControlExample.getResourceString("ListData0_7")}; //$NON-NLS-1$ |
|---|
| 45 | | |
|---|
| 46 | | static String [] ListData1 = {ControlExample.getResourceString("ListData1_0"), //$NON-NLS-1$ |
|---|
| 47 | | ControlExample.getResourceString("ListData1_1"), //$NON-NLS-1$ |
|---|
| 48 | | ControlExample.getResourceString("ListData1_2"), //$NON-NLS-1$ |
|---|
| 49 | | ControlExample.getResourceString("ListData1_3"), //$NON-NLS-1$ |
|---|
| 50 | | ControlExample.getResourceString("ListData1_4"), //$NON-NLS-1$ |
|---|
| 51 | | ControlExample.getResourceString("ListData1_5"), //$NON-NLS-1$ |
|---|
| 52 | | ControlExample.getResourceString("ListData1_6"), //$NON-NLS-1$ |
|---|
| 53 | | ControlExample.getResourceString("ListData1_7")}; //$NON-NLS-1$ |
|---|
| | 41 | static char[] [] ListData0; |
|---|
| | 42 | static char[] [] ListData1; |
|---|
| 54 | 43 | |
|---|
| 55 | 44 | |
|---|
| … | … | |
| 59 | 48 | this(ControlExample instance) { |
|---|
| 60 | 49 | super(instance); |
|---|
| | 50 | if( ListData0 is null ){ |
|---|
| | 51 | ListData0 = [ |
|---|
| | 52 | ControlExample.getResourceString("ListData0_0"), //$NON-NLS-1$ |
|---|
| | 53 | ControlExample.getResourceString("ListData0_1"), //$NON-NLS-1$ |
|---|
| | 54 | ControlExample.getResourceString("ListData0_2"), //$NON-NLS-1$ |
|---|
| | 55 | ControlExample.getResourceString("ListData0_3"), //$NON-NLS-1$ |
|---|
| | 56 | ControlExample.getResourceString("ListData0_4"), //$NON-NLS-1$ |
|---|
| | 57 | ControlExample.getResourceString("ListData0_5"), //$NON-NLS-1$ |
|---|
| | 58 | ControlExample.getResourceString("ListData0_6"), //$NON-NLS-1$ |
|---|
| | 59 | ControlExample.getResourceString("ListData0_7")]; //$NON-NLS-1$ |
|---|
| | 60 | |
|---|
| | 61 | } |
|---|
| | 62 | if( ListData1 is null ){ |
|---|
| | 63 | ListData1 = [ |
|---|
| | 64 | ControlExample.getResourceString("ListData1_0"), //$NON-NLS-1$ |
|---|
| | 65 | ControlExample.getResourceString("ListData1_1"), //$NON-NLS-1$ |
|---|
| | 66 | ControlExample.getResourceString("ListData1_2"), //$NON-NLS-1$ |
|---|
| | 67 | ControlExample.getResourceString("ListData1_3"), //$NON-NLS-1$ |
|---|
| | 68 | ControlExample.getResourceString("ListData1_4"), //$NON-NLS-1$ |
|---|
| | 69 | ControlExample.getResourceString("ListData1_5"), //$NON-NLS-1$ |
|---|
| | 70 | ControlExample.getResourceString("ListData1_6"), //$NON-NLS-1$ |
|---|
| | 71 | ControlExample.getResourceString("ListData1_7")]; //$NON-NLS-1$ |
|---|
| | 72 | } |
|---|
| 61 | 73 | } |
|---|
| 62 | 74 | void createExampleGroup () { |
|---|
| … | … | |
| 85 | 97 | text = new Text (form, DWT.MULTI | DWT.BORDER); |
|---|
| 86 | 98 | text.setText (ControlExample.getResourceString("Multi_line")); //$NON-NLS-1$ |
|---|
| 87 | | form.setWeights(new int[] {1, 1, 1}); |
|---|
| | 99 | form.setWeights([1, 1, 1]); |
|---|
| 88 | 100 | } |
|---|
| 89 | 101 | /** |
|---|
| … | … | |
| 109 | 121 | */ |
|---|
| 110 | 122 | Widget [] getExampleWidgets () { |
|---|
| 111 | | return new Widget [] {form}; |
|---|
| | 123 | return [ cast(Widget) form]; |
|---|
| 112 | 124 | } |
|---|
| 113 | 125 | |
|---|
| … | … | |
| 115 | 127 | * Gets the text for the tab folder item. |
|---|
| 116 | 128 | */ |
|---|
| 117 | | String getTabText () { |
|---|
| | 129 | char[] getTabText () { |
|---|
| 118 | 130 | return "SashForm"; //$NON-NLS-1$ |
|---|
| 119 | 131 | } |
|---|
| r144 |
r145 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 14 | 14 | |
|---|
| 15 | 15 | |
|---|
| 16 | | import java.io.IOException; |
|---|
| 17 | | import java.io.InputStream; |
|---|
| | 16 | import dwt.dwthelper.ByteArrayInputStream; |
|---|
| 18 | 17 | |
|---|
| 19 | 18 | |
|---|
| … | … | |
| 42 | 41 | import dwt.widgets.Widget; |
|---|
| 43 | 42 | |
|---|
| | 43 | import dwtexamples.controlexample.ScrollableTab; |
|---|
| | 44 | import dwtexamples.controlexample.ControlExample; |
|---|
| | 45 | import tango.core.Exception; |
|---|
| | 46 | import tango.io.Stdout; |
|---|
| | 47 | |
|---|
| 44 | 48 | class StyledTextTab : ScrollableTab { |
|---|
| 45 | 49 | /* Example widgets and groups that contain them */ |
|---|
| … | … | |
| 55 | 59 | |
|---|
| 56 | 60 | /* Variables for saving state. */ |
|---|
| 57 | | String text; |
|---|
| | 61 | char[] text; |
|---|
| 58 | 62 | StyleRange[] styleRanges; |
|---|
| 59 | 63 | |
|---|
| … | … | |
| 68 | 72 | * Creates a bitmap image. |
|---|
| 69 | 73 | */ |
|---|
| 70 | | Image createBitmapImage (Display display, String name) { |
|---|
| 71 | | InputStream sourceStream = ControlExample.class.getResourceAsStream (name + ".bmp"); |
|---|
| 72 | | InputStream maskStream = ControlExample.class.getResourceAsStream (name + "_mask.bmp"); |
|---|
| | 74 | Image createBitmapImage (Display display, void[] sourceData, void[] maskData ) { |
|---|
| | 75 | InputStream sourceStream = new ByteArrayInputStream ( cast(byte[])sourceData ); |
|---|
| | 76 | InputStream maskStream = new ByteArrayInputStream ( cast(byte[])maskData ); |
|---|
| 73 | 77 | ImageData source = new ImageData (sourceStream); |
|---|
| 74 | 78 | ImageData mask = new ImageData (maskStream); |
|---|
| … | … | |
| 78 | 82 | maskStream.close (); |
|---|
| 79 | 83 | } catch (IOException e) { |
|---|
| 80 | | e.printStackTrace (); |
|---|
| | 84 | Stderr.formatln( "Stacktrace: {}", e ); |
|---|
| 81 | 85 | } |
|---|
| 82 | 86 | return result; |
|---|
| … | … | |
| 165 | 169 | |
|---|
| 166 | 170 | /* Get images */ |
|---|
| 167 | | boldImage = createBitmapImage (display, "bold"); |
|---|
| 168 | | italicImage = createBitmapImage (display, "italic"); |
|---|
| 169 | | redImage = createBitmapImage (display, "red"); |
|---|
| 170 | | yellowImage = createBitmapImage (display, "yellow"); |
|---|
| 171 | | underlineImage = createBitmapImage (display, "underline"); |
|---|
| 172 | | strikeoutImage = createBitmapImage (display, "strikeout"); |
|---|
| | 171 | boldImage = createBitmapImage (display, import("bold.bmp"), import("bold_mask.bmp")); |
|---|
| | 172 | italicImage = createBitmapImage (display, import("italic.bmp"), import("italic_mask.bmp")); |
|---|
| | 173 | redImage = createBitmapImage (display, import("red.bmp"), import("red_mask.bmp")); |
|---|
| | 174 | yellowImage = createBitmapImage (display, import("yellow.bmp"), import("yellow_mask.bmp")); |
|---|
| | 175 | underlineImage = createBitmapImage (display, import("underline.bmp"), import("underline_mask.bmp")); |
|---|
| | 176 | strikeoutImage = createBitmapImage (display, import("strikeout.bmp"), import("strikeout_mask.bmp")); |
|---|
| 173 | 177 | |
|---|
| 174 | 178 | /* Create controls to modify the StyledText */ |
|---|
| … | … | |
| 206 | 210 | yellowButton = new Button (styledTextStyleGroup, DWT.PUSH); |
|---|
| 207 | 211 | yellowButton.setImage (yellowImage); |
|---|
| 208 | | SelectionListener styleListener = new SelectionAdapter () { |
|---|
| | 212 | SelectionListener styleListener = new class() SelectionAdapter { |
|---|
| 209 | 213 | public void widgetSelected (SelectionEvent e) { |
|---|
| 210 | 214 | Point sel = styledText.getSelectionRange(); |
|---|
| … | … | |
| 214 | 218 | StyleRange range = styledText.getStyleRangeAtOffset(i); |
|---|
| 215 | 219 | if (range !is null) { |
|---|
| 216 | | style = (StyleRange)range.clone(); |
|---|
| | 220 | style = cast(StyleRange)range.clone(); |
|---|
| 217 | 221 | style.start = i; |
|---|
| 218 | 222 | style.length = 1; |
|---|
| … | … | |
| 234 | 238 | } |
|---|
| 235 | 239 | }; |
|---|
| 236 | | SelectionListener colorListener = new SelectionAdapter () { |
|---|
| | 240 | SelectionListener colorListener = new class() SelectionAdapter { |
|---|
| 237 | 241 | public void widgetSelected (SelectionEvent e) { |
|---|
| 238 | 242 | Point sel = styledText.getSelectionRange(); |
|---|
| … | … | |
| 248 | 252 | StyleRange range = styledText.getStyleRangeAtOffset(i); |
|---|
| 249 | 253 | if (range !is null) { |
|---|
| 250 | | style = (StyleRange)range.clone(); |
|---|
| | 254 | style = cast(StyleRange)range.clone(); |
|---|
| 251 | 255 | style.start = i; |
|---|
| 252 | 256 | style.length = 1; |
|---|
| … | … | |
| 267 | 271 | redButton.addSelectionListener(colorListener); |
|---|
| 268 | 272 | yellowButton.addSelectionListener(colorListener); |
|---|
| 269 | | yellowButton.addDisposeListener(new DisposeListener () { |
|---|
| | 273 | yellowButton.addDisposeListener(new class() DisposeListener { |
|---|
| 270 | 274 | public void widgetDisposed (DisposeEvent e) { |
|---|
| 271 | 275 | boldImage.dispose(); |
|---|
| … | … | |
| 294 | 298 | * recalculate the preferred size correctly. |
|---|
| 295 | 299 | */ |
|---|
| 296 | | tabFolderPage.addControlListener(new ControlAdapter() { |
|---|
| | 300 | tabFolderPage.addControlListener(new class() ControlAdapter { |
|---|
| 297 | 301 | public void controlResized(ControlEvent e) { |
|---|
| 298 | 302 | setExampleWidgetSize (); |
|---|
| … | … | |
| 319 | 323 | */ |
|---|
| 320 | 324 | Widget [] getExampleWidgets () { |
|---|
| 321 | | return new Widget [] {styledText}; |
|---|
| | 325 | return [ cast(Widget) styledText]; |
|---|
| 322 | 326 | } |
|---|
| 323 | 327 | |
|---|
| … | … | |
| 326 | 330 | * that can be used to set/get values in the example control(s). |
|---|
| 327 | 331 | */ |
|---|
| 328 | | String[] getMethodNames() { |
|---|
| 329 | | return new String[] {"CaretOffset", "DoubleClickEnabled", "Editable", "HorizontalIndex", "HorizontalPixel", "Orientation", "Selection", "Tabs", "Text", "TextLimit", "ToolTipText", "TopIndex", "TopPixel", "WordWrap"}; |
|---|
| | 332 | char[][] getMethodNames() { |
|---|
| | 333 | return ["CaretOffset", "DoubleClickEnabled", "Editable", "HorizontalIndex", "HorizontalPixel", "Orientation", "Selection", "Tabs", "Text", "TextLimit", "ToolTipText", "TopIndex", "TopPixel", "WordWrap"]; |
|---|
| 330 | 334 | } |
|---|
| 331 | 335 | |
|---|
| … | … | |
| 334 | 338 | * Gets the text for the tab folder item. |
|---|
| 335 | 339 | */ |
|---|
| 336 | | String getTabText () { |
|---|
| | 340 | char[] getTabText () { |
|---|
| 337 | 341 | return "StyledText"; |
|---|
| 338 | 342 | } |
|---|