Mercurial > projects > dwt-samples
view dwtsnippets/text/Snippet258.d @ 11:b61e7baf0574
Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
author | Jesse Phillips <Jesse.K.Phillips+D@gmail.com> |
---|---|
date | Thu, 14 Feb 2008 13:04:14 -0800 |
parents | |
children | 47a66440dddd |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * D port: * Jesse Phillips <Jesse.K.Phillips+D> gmail.com *******************************************************************************/ module dwtsnippets.text.Snippet258; /* * Create a search text control * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ * * @since 3.3 */ import dwt.DWT; import dwt.graphics.Image; import dwt.widgets.Display; import dwt.widgets.Shell; import dwt.widgets.Text; import dwt.widgets.ToolBar; import dwt.widgets.ToolItem; import dwt.layout.GridLayout; import dwt.layout.GridData; import dwt.events.SelectionAdapter; import dwt.events.SelectionEvent; import tango.io.Stdout; void main() { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(2, false)); final Text text = new Text(shell, DWT.SEARCH | DWT.CANCEL); Image image = null; if ((text.getStyle() & DWT.CANCEL) == 0) { image = new Image (display, "../images/cancel.gif"); ToolBar toolBar = new ToolBar (shell, DWT.FLAT); ToolItem item = new ToolItem (toolBar, DWT.PUSH); item.setImage (image); item.addSelectionListener(new class SelectionAdapter { public void widgetSelected(SelectionEvent e) { text.setText(""); Stdout("Search cancelled").newline; } }); } text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); text.setText("Search text"); text.addSelectionListener(new class SelectionAdapter { public void widgetDefaultSelected(SelectionEvent e) { if (e.detail == DWT.CANCEL) { Stdout("Search cancelled").newline; } else { Stdout("Searching for: ")(text.getText())("...").newline; } } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (image != null) image.dispose(); display.dispose(); }