Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-This board game is a variant of Reversi and Tic Tac Toe. Each one of the two players sets a pawn on an empty cell of the board.
-
Pawns
-
-
Player 1
-
Player 2
-
Wall. Cannot be reversed.
-
-
-Different themes are supported. Theme is configured through a Cascading Style Sheet (CSS) that determines how the HTML content is rendered by the SWT Browser widget.
-
-The game ends when all cells are filled. The winner is the one with most pawns of their colour.
-
-
Java and HTML integrated through the SWT Browser widget
-
-Rendering is based on HTML and CSS techniques. Computer moves are programmed in regular
-Java code in the Eclipse plug-in. The SWT Browser widget is used for rendering and reacting
-to user input.
-
-
Implementation
-
-The board is a table filled with hyperlinks. Cascading Style Sheets
-provide various themes and control the table aesthetic appearance.
- The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws
-the board game from HTML generated in memory.
- Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener.
-e.g the player clicks on a cell that may generate a hyperlink with a URL similar to
-http://www.org.eclipse.swt.examples.browser.demos/xx1yy2. That hyperlink identifies
-the position of the cell selected by the player (column 1, row 2). The move is completed by generating
-new HTML content and invoking Browser.setText to update the board game.
-
-This board game is a variant of Reversi and Tic Tac Toe. Each one of the two players sets a pawn on an empty cell of the board.
-
Pawns
-
-
Player 1
-
Player 2
-
Wall. Cannot be reversed.
-
-
-Different themes are supported. Theme is configured through a Cascading Style Sheet (CSS) that determines how the HTML content is rendered by the SWT Browser widget.
-
-The game ends when all cells are filled. The winner is the one with most pawns of their colour.
-
-
Java and HTML integrated through the SWT Browser widget
-
-Rendering is based on HTML and CSS techniques. Computer moves are programmed in regular
-Java code in the Eclipse plug-in. The SWT Browser widget is used for rendering and reacting
-to user input.
-
-
Implementation
-
-The board is a table filled with hyperlinks. Cascading Style Sheets
-provide various themes and control the table aesthetic appearance.
- The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws
-the board game from HTML generated in memory.
- Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener.
-e.g the player clicks on a cell that may generate a hyperlink with a URL similar to
-http://www.org.eclipse.swt.examples.browser.demos/xx1yy2. That hyperlink identifies
-the position of the cell selected by the player (column 1, row 2). The move is completed by generating
-new HTML content and invoking Browser.setText to update the board game.
-
-This board game is a variant of Reversi and Tic Tac Toe. Each one of the two players sets a pawn on an empty cell of the board.
-
Pawns
-
-
Player 1
-
Player 2
-
Wall. Cannot be reversed.
-
-
-Different themes are supported. Theme is configured through a Cascading Style Sheet (CSS) that determines how the HTML content is rendered by the SWT Browser widget.
-
-The game ends when all cells are filled. The winner is the one with most pawns of their colour.
-
-
Java and HTML integrated through the SWT Browser widget
-
-Rendering is based on HTML and CSS techniques. Computer moves are programmed in regular
-Java code in the Eclipse plug-in. The SWT Browser widget is used for rendering and reacting
-to user input.
-
-
Implementation
-
-The board is a table filled with hyperlinks. Cascading Style Sheets
-provide various themes and control the table aesthetic appearance.
- The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws
-the board game from HTML generated in memory.
- Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener.
-e.g the player clicks on a cell that may generate a hyperlink with a URL similar to
-http://www.org.eclipse.swt.examples.browser.demos/xx1yy2. That hyperlink identifies
-the position of the cell selected by the player (column 1, row 2). The move is completed by generating
-new HTML content and invoking Browser.setText to update the board game.
-
-This board game is a variant of Reversi and Tic Tac Toe. Each one of the two players sets a pawn on an empty cell of the board.
-
Pawns
-
-
Player 1
-
Player 2
-
Wall. Cannot be reversed.
-
-
-Different themes are supported. Theme is configured through a Cascading Style Sheet (CSS) that determines how the HTML content is rendered by the SWT Browser widget.
-
-The game ends when all cells are filled. The winner is the one with most pawns of their colour.
-
-
Java and HTML integrated through the SWT Browser widget
-
-Rendering is based on HTML and CSS techniques. Computer moves are programmed in regular
-Java code in the Eclipse plug-in. The SWT Browser widget is used for rendering and reacting
-to user input.
-
-
Implementation
-
-The board is a table filled with hyperlinks. Cascading Style Sheets
-provide various themes and control the table aesthetic appearance.
- The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws
-the board game from HTML generated in memory.
- Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener.
-e.g the player clicks on a cell that may generate a hyperlink with a URL similar to
-http://www.org.eclipse.swt.examples.browser.demos/xx1yy2. That hyperlink identifies
-the position of the cell selected by the player (column 1, row 2). The move is completed by generating
-new HTML content and invoking Browser.setText to update the board game.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.browser.demos/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.browser.demos/doc-html/hglegal.htm
deleted file mode 100644
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.browser.demos/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.browser.demos/doc-html/ngibmcpy.gif
deleted file mode 100644
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.browser.demos/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.browser.demos/doc-html/swt_browser_ex.html b/examples/org.eclipse.swt.examples.browser.demos/doc-html/swt_browser_ex.html
deleted file mode 100644
index 6eb33018d7..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/doc-html/swt_browser_ex.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- SWT - Controls Overview
-
-
-
-
SWT example - Browser Demos
-
-
-The Browser Demos demonstrate various features of the SWT Browser widget.
-
The Pawns Game is a board game that can be played against the computer
-or against another player. Rendering is based on HTML and CSS techniques. The
-board is a table filled with hyperlinks. Cascading Style Sheets
-provide various themes and control the table aesthetic appearance.
-The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws
-the board game from HTML generated in memory.
-Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener.
-e.g the player clicks on a cell that may generate an hyperlink with a URL similar to
-http://www.org.eclipse.swt.examples.browser.demos/xx1yy2. That hyperlink identifies
-the position of the cell selected by the player. The move is completed by generating
-new HTML content and invoking Browser.setText to update the board game.
-
-The "Main" class is org.eclipse.swt.examples.browser.demos.BrowserDemoView.
-
-
-This example can also be run using the Example Launcher.
-Select the Browser Demo item from the Workbench Views category and click Run.
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.browser.demos/icons/pawn.gif b/examples/org.eclipse.swt.examples.browser.demos/icons/pawn.gif
deleted file mode 100644
index c811f8ba71..0000000000
Binary files a/examples/org.eclipse.swt.examples.browser.demos/icons/pawn.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.browser.demos/plugin.properties b/examples/org.eclipse.swt.examples.browser.demos/plugin.properties
deleted file mode 100644
index 99a8ef4787..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/plugin.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTBrowserDemos.name = SWT Browser Demos Plugin
-category.SWTExamples.name = SWT Examples
-view.BrowserDemos.name = Browser Demo
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.BrowserDemos.name = Browser Demo
-launchitem.BrowserDemos.description = \
- The example illustrates how to use the SWT Browser widget for HTML rendering.\n\n\
- The Pawns Game is a board game that can be played against the computer or against another player.\n\n\
- Rendering is based on HTML and CSS techniques. The board is a table filled with hyperlinks. Cascading Style Sheets \
- provide various themes and control the table aesthetic appearance. \n\
- The API org.eclipse.swt.browser.Browser.setText(java.lang.String) draws the board game from HTML generated in memory.\n\
- Player moves are captured by implementing the interface org.eclipse.swt.browser.LocationListener. e.g the player clicks \
- on a cell that defines an hyperlink with a URL http://www.org.eclipse.swt.examples.browser.demos/xx1yy2.\
- That hyperlink identifies the position of the cell selected by the player. The move is completed by generating \
- new HTML content and invoking Browser.setText to update the board game.
diff --git a/examples/org.eclipse.swt.examples.browser.demos/plugin.xml b/examples/org.eclipse.swt.examples.browser.demos/plugin.xml
deleted file mode 100644
index 371ee25a6e..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/plugin.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/BrowserDemoPlugin.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/BrowserDemoPlugin.java
deleted file mode 100644
index 753991767a..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/BrowserDemoPlugin.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browser.demos;
-
-import org.eclipse.ui.plugin.*;
-import org.osgi.framework.BundleContext;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-
-public class BrowserDemoPlugin extends AbstractUIPlugin {
-
- public static BrowserDemoPlugin plugin;
- ResourceBundle resourceBundle;
- public static String PLUGIN_PATH = null;
-
- public BrowserDemoPlugin() {
- super();
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.swt.examples.browser.demos.BrowserDemoPluginResources");
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- PLUGIN_PATH = Platform.resolve(plugin.getBundle().getEntry(".")).toString();
- }
-
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- }
-
- public static BrowserDemoPlugin getDefault() {
- return plugin;
- }
-
- public static String getResourceString(String key) {
- ResourceBundle bundle = BrowserDemoPlugin.getDefault().getResourceBundle();
- try {
- return (bundle != null) ? bundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/Pawns.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/Pawns.java
deleted file mode 100644
index a2240878b6..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/Pawns.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browser.demos;
-
-public class Pawns {
-
- /* Current board representation in compacted form */
- byte[] game = new byte[64];
- /* Best move */
- int bestIndex = -1;
- /* Related best score */
- int bestScore = Integer.MIN_VALUE;
- /* Estimated strategic value of each cell based on proximity to walls */
- static int[] gameWallWeight = new int[64];
- Thread thread = null;
- boolean threadStop = false;
-
- final static byte EMPTY = 0;
- final static byte WHITE = 1;
- final static byte BLACK = 2;
- final static byte WALL = 3;
-
-public Pawns() {
-}
-
-/* Provide the current game and ignitiate the search of the best move for the given type
- * Must return immediately as it will be called from the UI thread.
- * The UI thread will fetch the best move any time thereafter.
- */
-public void playRequest(byte[][] game, int type) {
- threadStop = true;
- synchronized (this) {
- bestIndex = -1;
- bestScore = Integer.MIN_VALUE;
- convert(game, this.game);
- initPawnBorders(this.game, gameWallWeight);
- /* Quickly compute a legal move */
- for (int i = 0; i < this.game.length; i++) {
- if (this.game[i] == EMPTY) {
- bestIndex = i;
- break;
- }
- }
- new Thread() {
- public void run() {
- synchronized(Pawns.this) {
- threadStop = false;
- int[] result = new int[2];
- /* if long time, must check for threadStop and exit early */
- evalBest(Pawns.this.game, BLACK, 2, result);
- bestIndex = result[0];
- bestScore = result[1];
- }
- }
- }.start();
- }
-}
-
-/* Fetch best move in natural coordinates for the board previously given in
- * the call to playRequest.
- */
-public void getBestMove(int[] point) {
- convert(bestIndex, point);
- threadStop = true;
-}
-
-/* Given an expanded representation of the board, format internal compact mode */
-static void convert(byte[][] board, byte[] g) {
- for (int i = 0; i < board.length; i++) System.arraycopy(board[i], 0, g, i * 8, 8);
-}
-/* Update given compact model based on player move in natural coordinates */
-static void set(byte[] g, int x, int y, byte type) {
- g[x*8+y] = type;
-}
-/* Given an index in compact representation, return natural coordinates */
-static void convert(int index, /*out [0] x [1] y */int[] point) {
- point[0] = index / 8;
- point[1] = index % 8;
-}
-/* Given an index into the compact model and the neighbour code,
- * return the index of the corresponding neighbour index.
- * Returns -1 if there is no neighbour.
- *
- * Neighbour code for the index X
- * 0 1 2
- * 3 X 4
- * 5 6 7
- */
-static int getNeighbourIndex(byte[] g, int index, int neighbour) {
- if (index < 0 || index >= g.length) return -1;
- int result = -1;
- switch (neighbour) {
- case 0: result = index < 8 || index % 8 == 0 ? -1 : index - 9; break;
- case 1: result = index < 8 ? -1 : index - 8; break;
- case 2: result = index < 8 || index % 8 == 7 ? -1 : index - 7; break;
- case 3: result = index % 8 == 0 ? -1 : index - 1; break;
- case 4: result = index % 8 == 7 ? -1 : index + 1; break;
- case 5: result = index % 8 == 0 || index >= 56 ? -1 : index + 7; break;
- case 6: result = index >= 56 ? -1 : index + 8; break;
- case 7: result = index % 8 == 7 || index >= 56 ? -1 : index + 9; break;
- }
- return result;
-}
-/* Make the player type play at index on given compact board
- * Compute all pawns that must be reversed.
- */
-static void play(byte[] g, int index, byte type) {
- byte opponentType = type == WHITE ? BLACK : WHITE;
- for (int neighbour = 0; neighbour <= 7; neighbour++) {
- int nIndex = getNeighbourIndex(g, index, neighbour);
- int[] reversiIndeces = new int[6];
- int nReversi = 0;
- while (nIndex != -1 && nReversi < 6 && g[nIndex] == opponentType) {
- reversiIndeces[nReversi] = nIndex;
- nReversi++;
- nIndex = getNeighbourIndex(g, nIndex, neighbour);
- }
- if (nReversi > 0 && nIndex != -1 && g[nIndex] == type) {
- for (int i = 0; i < nReversi; i++) g[reversiIndeces[i]] = type;
- }
- }
- g[index] = type;
-}
-/* Evaluate the given compact model based on pawns distribution
- * High means white has advantage. Below zero means black has advantage.
- */
-static int eval(byte[] g) {
- int cntWhite = 0, cntBlack = 0, cntEmpty = 0;
- int cntWhiteWallAdvantage = 0, cntBlackWallAdvantage = 0;
- for (int i = 0; i < 64; i++) {
- if (g[i] == WHITE) {
- cntWhite++;
- cntWhiteWallAdvantage += gameWallWeight[i];
- }
- else if (g[i] == BLACK) {
- cntBlack++;
- cntBlackWallAdvantage += gameWallWeight[i];
- }
- else if (g[i] == EMPTY) cntEmpty++;
- }
- if (cntEmpty == 0) {
- if (cntWhite > cntBlack) return Integer.MAX_VALUE; /* White wins */
- if (cntWhite < cntBlack) return Integer.MIN_VALUE; /* Black wins */
- return 0; /* Stalemate */
- }
- return cntWhite + cntWhiteWallAdvantage - cntBlack - cntBlackWallAdvantage;
-}
-
-/* Recognize pawns protected by walls or borders
- * TBD - note this should be called only once for each cell and stored
- * in a separate byte[] gWallGain
- * */
-static void initPawnBorders(byte[] g, int[] gameWallWeight) {
- /* A pawn has 8 neighbours on 4 axes.
- * Strategic pawns have one side of each axis protected by a wall and the other
- * side not closed by a wall.
- * A pawn cannot be reversed when each of its 4 axes are protected by a wall on
- * one side. Pawns that have more than 4 walls are less interesting since they
- * are not open enough to the board.
- *
- * Nbr walls, nbr axis covered, estimated value
- * 0 n/a 0
- * 1 1 2
- * 2 1 1
- * 2 2 6
- * 3 2 4
- * 4 2 2
- * 3 3 9
- * 4 3 8
- * 4 4 16
- * 5 4 14
- * 6 4 9
- * 7 4 6
- * 8 4 0
- */
- int[] nTypes = new int[8];
- for (int i = 0; i < 64; i++) {
- int nWalls = 0;
- int nAxis = 0;
- for (int n = 0; n < 8; n++) {
- int nIndex = getNeighbourIndex(g, i, n);
- nTypes[n] = nIndex != -1 ? g[nIndex] : WALL;
- if (nTypes[n] == WALL) nWalls++;
- }
- int score = nWalls;
- if (nWalls > 0) {
- if (nTypes[0] == WALL || nTypes[7] == WALL) nAxis++;
- if (nTypes[1] == WALL || nTypes[6] == WALL) nAxis++;
- if (nTypes[2] == WALL || nTypes[5] == WALL) nAxis++;
- if (nTypes[4] == WALL || nTypes[3] == WALL) nAxis++;
- switch (nAxis) {
- case 4: switch (nWalls) { case 4: score = 16; break; case 5: score = 14; break; case 6: score = 9; case 7: score = 6; break; case 8: score = 0; break;}; break;
- case 3: switch (nWalls) { case 3: score = 9; break; case 4: score = 8;}; break;
- case 2: switch (nWalls) { case 2: score = 6; break; case 3: score = 4; break; case 4: score = 2; }; break;
- case 1: switch (nWalls) { case 1: score = 2; break; case 2: score = 1; break;}; break;
- };
- }
- gameWallWeight[i] = score;
- }
-}
-
-/* Evaluate the best move for player type for the given board, doing a depth 1 search */
-static void evalBest(byte[] g, byte type, int depth, /* out [0] best move, [1] minimax */int[] result) {
- byte[] tmp = new byte[64];
- byte opponentType = type == WHITE ? BLACK : WHITE;
- result[0] = -1; result[1] = Integer.MIN_VALUE;
- for (int i = 0; i < 64; i++) {
- if (g[i] == EMPTY) {
- System.arraycopy(g, 0, tmp, 0, 64);
- play(tmp, i, type);
- int score = eval(tmp);
- if (depth > 1) {
- int[] tmpResult = new int[2];
- evalBest(tmp, opponentType, depth - 1, tmpResult);
- score = tmpResult[1];
- }
- if ((type == WHITE && score > result[1]) || (type == BLACK && score < result[1]) || result[0] == -1) {
- result[0] = i;
- result[1] = score;
- }
- }
- }
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/BrowserDemoView.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/BrowserDemoView.java
deleted file mode 100644
index aa4d8079d0..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/BrowserDemoView.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browser.demos.views;
-
-import org.eclipse.ui.part.*;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.action.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.browser.*;
-
-public class BrowserDemoView extends ViewPart {
- Action pawnAction;
- Action editAction;
- Composite parent;
-
- public BrowserDemoView() {
- }
- public void createPartControl(Composite parent) {
- this.parent = parent;
- parent.setLayout(new FillLayout());
- try {
- Browser browser = new Browser(parent, SWT.NONE);
- browser.dispose();
- } catch (SWTError e) {
- Text text = new Text(parent, SWT.MULTI | SWT.READ_ONLY);
- text.setText("Browser widget cannot be instantiated. The exact error is:\r\n"+e);
- parent.layout(true);
- return;
- }
- TabFolder folder = new TabFolder(parent, SWT.NONE);
- TabItem item = new TabItem(folder, SWT.NONE);
- PawnTab pawnTab = new PawnTab(item);
-
- item = new TabItem(folder, SWT.NONE);
- EditorTab editorTab = new EditorTab(item);
- }
-
- private void showMessage(String message) {
- MessageDialog.openInformation(
- parent.getShell(),
- "Browser Demo",
- message);
- }
- public void setFocus() {
- }
-
-
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/EditorTab.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/EditorTab.java
deleted file mode 100644
index e17d1c37ae..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/EditorTab.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browser.demos.views;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.graphics.*;
-
-public class EditorTab {
- Browser browser;
- Text htmlText, scriptText;
- Button htmlButton, scriptButton;
- static String html =
- "\r\n"+
- " \r\n"+
- "
HTML Document
\r\n"+
- "
Set HTML content
\r\n"+
- " \r\n"+
- "
Enter html data into the 'setText' pane
\r\n"+
- "
Click on 'setText' to set the new content
\r\n"+
- " \r\n"+
- "
Query or modify HTML document
\r\n"+
- " \r\n"+
- "
Enter javascript commands into the 'execute' pane
\r\n"+
- "
Click on 'execute' to run the javascript in the current document
\r\n"+
- " \r\n"+
- " \r\n"+
- "";
-
- static String script =
- "var node = document.createElement('P');\r\n"+
- "var text = document.createTextNode('Content inserted!');\r\n"+
- "node.appendChild(text);\r\n"+
- "document.getElementById('myid').appendChild(node);\r\n\r\n"+
- "document.bgColor = 'yellow';";
-
- public EditorTab(TabItem item) {
- final Composite parent = new Composite(item.getParent(), SWT.NONE);
- item.setText("Editor");
- item.setControl(parent);
-
- try {
- browser = new Browser(parent, SWT.NONE);
- } catch (SWTError e) {
- e.printStackTrace();
- return;
- }
- final Sash sash = new Sash(parent, SWT.VERTICAL);
- Composite panel = new Composite(parent, SWT.NONE);
- final FormLayout form = new FormLayout();
- parent.setLayout(form);
-
- FormData data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(sash, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- browser.setLayoutData(data);
-
- final FormData sashData = new FormData();
- sashData.left = new FormAttachment(50, 0);
- sashData.top = new FormAttachment(0, 0);
- sashData.bottom = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
- sash.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- Rectangle rect = sash.getBounds();
- Rectangle parentRect = sash.getParent().getClientArea();
- int right = parentRect.width - rect.width - 20;
- e.x = Math.max(Math.min(e.x, right), 20);
- if (e.x != rect.x) {
- sashData.left = new FormAttachment(0, e.x);
- parent.layout();
- }
- }
- });
- data = new FormData();
- data.left = new FormAttachment(sash, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- panel.setLayoutData(data);
-
- /* Initialize Panel */
- panel.setLayout(new FillLayout(SWT.VERTICAL));
- Group htmlGroup = new Group(panel, SWT.NONE);
- htmlGroup.setText("setText");
- htmlText = new Text(htmlGroup, SWT.MULTI);
- htmlButton = new Button(htmlGroup, SWT.PUSH);
- htmlButton.setText("setText");
- GridLayout gridLayout = new GridLayout();
- htmlGroup.setLayout(gridLayout);
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- htmlText.setLayoutData(gridData);
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.END;
- htmlButton.setLayoutData(gridData);
- htmlGroup.layout();
-
- Group scriptGroup = new Group(panel, SWT.NONE);
- scriptGroup.setText("execute");
- scriptText = new Text(scriptGroup, SWT.MULTI);
- scriptButton = new Button(scriptGroup, SWT.PUSH);
- scriptButton.setText("execute");
- gridLayout = new GridLayout();
- scriptGroup.setLayout(gridLayout);
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- scriptText.setLayoutData(gridData);
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.END;
- scriptButton.setLayoutData(gridData);
- scriptGroup.layout();
-
- browser.setText(html);
- htmlText.setText(html);
- scriptText.setText(script);
- parent.layout();
-
- Listener listener = new Listener() {
- public void handleEvent(Event e) {
- Widget w = e.widget;
- if (w == htmlButton) browser.setText(htmlText.getText());
- if (w == scriptButton) browser.execute(scriptText.getText());
- }
- };
-
- htmlButton.addListener(SWT.Selection, listener);
- scriptButton.addListener(SWT.Selection, listener);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
deleted file mode 100644
index c11a5408d7..0000000000
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browser.demos.views;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.examples.browser.demos.BrowserDemoPlugin;
-import org.eclipse.swt.examples.browser.demos.Pawns;
-
-public class PawnTab {
-
- Action pawnAction;
- Action editAction;
-
- Browser browser = null;
- ReversiListener reversiListener;
-
- final static int TYPE_WELCOME = 1;
- final static int TYPE_START = 2;
- final static int TYPE_BOARD = 3;
- final static int TYPE_BOARD_OVER = 4;
-
- final static String URL = "http://www.org.eclipse.swt.examples.browser.demos.pawns/";
- static String PLUGIN_PATH = BrowserDemoPlugin.PLUGIN_PATH;
- static String CSS_FOLDER = "css2";
- static String URL_CSS = PLUGIN_PATH+CSS_FOLDER+"/style.css";
- static String URL_WELCOME =PLUGIN_PATH+CSS_FOLDER+"/welcome.html";
-
- final static String ACTION_START_2_PLAYERS = "actionstart2players";
- final static String ACTION_START_1_PLAYER = "actionstart1player";
- final static String ACTION_WHITE = "actionwhite";
- final static String ACTION_BLACK = "actionblack";
- final static String ACTION_THEME = "actiontheme";
-
- static byte[][] game = null;
- static boolean isWhite = true;
- static int cntWhite = 0, cntBlack = 0;
- static boolean computer = false;
- static int cx, cy;
- final static byte EMPTY = 0;
- final static byte WHITE = 1;
- final static byte BLACK = 2;
- final static byte WALL = 3;
-
- static Pawns ttr = null;
- static int[] move = new int[2];
- static Menu menu = null;
-
- public PawnTab(TabItem item) {
- try {
- browser = new Browser(item.getParent(), SWT.NONE);
- } catch (SWTError e) {
- e.printStackTrace();
- return;
- }
- item.setText("Pawns");
- item.setControl(browser);
-
- menu = new Menu(browser.getShell(), SWT.POP_UP);
- MenuItem item2 = new MenuItem(menu, SWT.PUSH);
- item2.setText("End Game");
- item2.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- game = null;
- isWhite = true;
- cntWhite = 0; cntBlack = 0;
- ttr = null;
- browser.setUrl(URL_WELCOME);
- }
- });
- browser.setMenu(menu);
-
- reversiListener = new ReversiListener();
- browser.addLocationListener(reversiListener);
- browser.setUrl(URL_WELCOME);
- }
-
- static String getHtml(int type) {
- String html = null;
- switch (type) {
- case TYPE_BOARD:
- case TYPE_BOARD_OVER: {
- html = "
";
- html += empty; break;
- }
- case WHITE: html += white; break;
- case BLACK: html += black; break;
- case WALL: html += wall; break;
- }
- }
- html +="
";
- }
- html += "
";
- html += "
"+cntWhite+"
";
- html += "
"+cntBlack+"
";
- html += "";
- break;
- }
- }
- return html;
- }
-
- public class ReversiListener implements LocationListener {
- public void changed(LocationEvent e) {
- }
- public void changing(LocationEvent e) {
- try {
- final Browser browser = (Browser)e.widget;
- if (e.location.indexOf(ACTION_START_1_PLAYER) != -1 || e.location.indexOf(ACTION_START_2_PLAYERS) != -1) {
- computer = e.location.indexOf(ACTION_START_1_PLAYER) != -1;
- game = new byte[8][8];
- if (computer) ttr = new Pawns();
- for (int i = 0; i < 5; i++) game[(int)(Math.random()*game.length)][(int)(Math.random()*game[0].length)] = WALL;
- e.display.asyncExec(new Runnable() {
- public void run() {
- browser.setText(getHtml(TYPE_BOARD));
- }});
- e.doit = false;
- return;
- }
- if (e.location.indexOf(ACTION_THEME) != -1) {
- int index = e.location.indexOf(ACTION_THEME) + ACTION_THEME.length() + 1;
- CSS_FOLDER = e.location.substring(index, index + 4);
- URL_CSS = PLUGIN_PATH+CSS_FOLDER+"/style.css";
- URL_WELCOME = PLUGIN_PATH+CSS_FOLDER+"/welcome.html";
- e.display.asyncExec(new Runnable() {
- public void run() {
- browser.setUrl(URL_WELCOME);
- }});
- e.doit = false;
- return;
- }
- byte player = EMPTY;
- if (e.location.indexOf(ACTION_WHITE) != -1) player = WHITE;
- else if (e.location.indexOf(ACTION_BLACK) != -1) player = BLACK;
- if (player != EMPTY) {
- int index = e.location.indexOf("xx") + 2;
- int x = Integer.parseInt(e.location.substring(index, index + 1));
- index = e.location.indexOf("yy") + 2;
- int y = Integer.parseInt(e.location.substring(index, index + 1));
- boolean hasMore = add(x, y, player);
- isWhite = player != WHITE;
- browser.setText(getHtml(hasMore ? TYPE_BOARD : TYPE_BOARD_OVER));
- if (computer && hasMore && !isWhite) play(e.display, browser, 5000);
- e.doit = false;
- }
- }catch (Exception e1 ) {
- e1.printStackTrace();
- }
- }
- }
-
- public static boolean add(int x, int y, byte color) {
- game[x][y] = color;
- int cnt = Math.min(x, y), n = 0;
- int other_color = color == WHITE ? BLACK : WHITE;
- for (int d = 1; d <= cnt; d++) {
- if (game[x-d][y-d] == other_color) n++;
- else if (game[x-d][y-d] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x-d][y-d] = color; break; }
- }
- cnt = Math.min(game.length - 1 - x, game[0].length - 1 - y); n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x+d][y+d] == other_color) n++;
- else if (game[x+d][y+d] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x+d][y+d] = color; break; }
- }
- cnt = Math.min(game.length - 1 - x, y); n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x+d][y-d] == other_color) n++;
- else if (game[x+d][y-d] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x+d][y-d] = color; break; }
- }
- cnt = Math.min(x, game[0].length - 1 - y); n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x-d][y+d] == other_color) n++;
- else if (game[x-d][y+d] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x-d][y+d] = color; break; }
- }
- cnt = y; n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x][y-d] == other_color) n++;
- else if (game[x][y-d] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x][y-d] = color; break; }
- }
- cnt = game[0].length - 1 - y; n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x][y+d] == other_color) n++;
- else if (game[x][y+d] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x][y+d] = color; break; }
- }
- cnt = x; n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x-d][y] == other_color) n++;
- else if (game[x-d][y] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x-d][y] = color; break; }
- }
- cnt = game.length - 1 - x; n = 0;
- for (int d = 1; d <= cnt; d++) {
- if (game[x+d][y] == other_color) n++;
- else if (game[x+d][y] != color) break;
- else { if (n > 0) for (d = 1; d <= n; d++) game[x+d][y] = color; break; }
- }
-
- boolean hasMore = false;
- cntWhite = 0; cntBlack = 0;
- for (int i = 0; i < game.length; i++)
- for (int j = 0; j < game[0].length; j++) {
- switch (game[i][j]) {
- case EMPTY: hasMore = true; break;
- case WHITE: cntWhite++; break;
- case BLACK: cntBlack++; break;
- }
- }
- return hasMore;
- }
-
- public static void play(final Display display, final Browser browser, int delay) {
- ttr.playRequest(game, BLACK);
- display.timerExec(3000, new Runnable() {
- public void run() {
- ttr.getBestMove(move);
- boolean hasMore = add(move[0], move[1], BLACK);
- isWhite = true;
- browser.setText(getHtml(hasMore ? TYPE_BOARD : TYPE_BOARD_OVER));
- }
- });
- }
-
- public static void main(String[] args) {
- }
-}
diff --git a/examples/org.eclipse.swt.examples.browser/.classpath b/examples/org.eclipse.swt.examples.browser/.classpath
deleted file mode 100644
index 7b14e15a15..0000000000
--- a/examples/org.eclipse.swt.examples.browser/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.browser/.cvsignore b/examples/org.eclipse.swt.examples.browser/.cvsignore
deleted file mode 100644
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.examples.browser/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.browser/.project b/examples/org.eclipse.swt.examples.browser/.project
deleted file mode 100644
index 6fd5ee59c9..0000000000
--- a/examples/org.eclipse.swt.examples.browser/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- org.eclipse.swt.examples.browser
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/examples/org.eclipse.swt.examples.browser/about.html b/examples/org.eclipse.swt.examples.browser/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.examples.browser/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.browser/build.properties b/examples/org.eclipse.swt.examples.browser/build.properties
deleted file mode 100644
index 818e48379c..0000000000
--- a/examples/org.eclipse.swt.examples.browser/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = doc-html/,\
- icons/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.browserexample.jar = src/
diff --git a/examples/org.eclipse.swt.examples.browser/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.browser/doc-html/hglegal.htm
deleted file mode 100644
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.browser/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.browser/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.browser/doc-html/ngibmcpy.gif
deleted file mode 100644
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.browser/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.browser/doc-html/swt_browser_ex.html b/examples/org.eclipse.swt.examples.browser/doc-html/swt_browser_ex.html
deleted file mode 100644
index af4189e3e6..0000000000
--- a/examples/org.eclipse.swt.examples.browser/doc-html/swt_browser_ex.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- SWT - Controls Overview
-
-
-
-
SWT example - Browser
-
-
-The Browser Example is a simple demonstration of the SWT Browser widget.
-It consists of a composite containing a Browser widget to render HTML and some
-additional widgets to implement actions commonly found on browsers (toolbar
-with back, forward, refresh and stop buttons, status bar etc.).
-
-The "Main" class is org.eclipse.swt.examples.browserexample.BrowserExample.
-
-
-This example can also be run using the Example Launcher.
-Select the Browser item from the Workbench Views category and click Run.
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.browser/icons/browser_example.gif b/examples/org.eclipse.swt.examples.browser/icons/browser_example.gif
deleted file mode 100644
index 895e22110d..0000000000
Binary files a/examples/org.eclipse.swt.examples.browser/icons/browser_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.browser/plugin.properties b/examples/org.eclipse.swt.examples.browser/plugin.properties
deleted file mode 100644
index 032ebc018d..0000000000
--- a/examples/org.eclipse.swt.examples.browser/plugin.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTBrowserExample.name = SWT Browser Example Plugin
-category.SWTExamples.name = SWT Examples
-view.BrowserExample.name = Web Browser
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.BrowserExample.name = Web Browser
-launchitem.BrowserExample.description = \
- This example demonstrates how to integrate a Web Browser with the SWT Browser widget.\n\n\
- It consists of a composite containing a Browser widget to render HTML. \
- Additional widgets allow the user to perform typical browser actions (for example, navigate to a particular URL, go back, forward, refresh and stop).
-
diff --git a/examples/org.eclipse.swt.examples.browser/plugin.xml b/examples/org.eclipse.swt.examples.browser/plugin.xml
deleted file mode 100644
index ed246e65ca..0000000000
--- a/examples/org.eclipse.swt.examples.browser/plugin.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.browser/src/import.properties b/examples/org.eclipse.swt.examples.browser/src/import.properties
deleted file mode 100644
index 58344f0d3e..0000000000
--- a/examples/org.eclipse.swt.examples.browser/src/import.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Persist project settings for later import
-natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature
-builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder
-var.ECLIPSE_PLUGINS = <>
diff --git a/examples/org.eclipse.swt.examples.browser/src/org/eclipse/swt/examples/browserexample/BrowserPlugin.java b/examples/org.eclipse.swt.examples.browser/src/org/eclipse/swt/examples/browserexample/BrowserPlugin.java
deleted file mode 100644
index cb61fa3454..0000000000
--- a/examples/org.eclipse.swt.examples.browser/src/org/eclipse/swt/examples/browserexample/BrowserPlugin.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browserexample;
-
-
-import org.eclipse.ui.plugin.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class BrowserPlugin extends AbstractUIPlugin {
- /**
- * The constructor.
- */
- public BrowserPlugin() {
- super();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.browser/src/org/eclipse/swt/examples/browserexample/BrowserView.java b/examples/org.eclipse.swt.examples.browser/src/org/eclipse/swt/examples/browserexample/BrowserView.java
deleted file mode 100644
index e7d2670bbd..0000000000
--- a/examples/org.eclipse.swt.examples.browser/src/org/eclipse/swt/examples/browserexample/BrowserView.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.browserexample;
-
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.part.*;
-
-/**
- * BrowserView is a simple demonstration
- * of the SWT Browser widget. It consists of a workbench
- * view and tab folder where each tab in the folder allows the
- * user to interact with a control.
- *
- * @see ViewPart
- */
-public class BrowserView extends ViewPart {
- BrowserExample instance = null;
-
- /**
- * Create the example
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite frame) {
- instance = new BrowserExample(frame, true);
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- instance.focus();
- }
-
- /**
- * Called when the View is to be disposed
- */
- public void dispose() {
- instance.dispose();
- instance = null;
- super.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.controls/.classpath b/examples/org.eclipse.swt.examples.controls/.classpath
deleted file mode 100755
index 065ac06e19..0000000000
--- a/examples/org.eclipse.swt.examples.controls/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.controls/.cvsignore b/examples/org.eclipse.swt.examples.controls/.cvsignore
deleted file mode 100755
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.examples.controls/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.controls/.project b/examples/org.eclipse.swt.examples.controls/.project
deleted file mode 100644
index f8c68eb6b4..0000000000
--- a/examples/org.eclipse.swt.examples.controls/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.eclipse.swt.examples.controls
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/examples/org.eclipse.swt.examples.controls/about.html b/examples/org.eclipse.swt.examples.controls/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.examples.controls/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.controls/build.properties b/examples/org.eclipse.swt.examples.controls/build.properties
deleted file mode 100755
index ca7f7ae865..0000000000
--- a/examples/org.eclipse.swt.examples.controls/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = doc-html/,\
- icons/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.controls.jar = src/
diff --git a/examples/org.eclipse.swt.examples.controls/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.controls/doc-html/hglegal.htm
deleted file mode 100755
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.controls/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.controls/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.controls/doc-html/ngibmcpy.gif
deleted file mode 100755
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.controls/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.controls/doc-html/swt_controls_ex.html b/examples/org.eclipse.swt.examples.controls/doc-html/swt_controls_ex.html
deleted file mode 100755
index 288fe2b184..0000000000
--- a/examples/org.eclipse.swt.examples.controls/doc-html/swt_controls_ex.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- SWT - Controls Overview
-
-
-
-
SWT example - Controls
-
-
-The Controls Example is a simple demonstration of common SWT controls.
-It consists of a tab folder where each tab in the folder allows the user
-to interact with a different control.
-The user can change styles and settings and view how this affects each control.
-
-The Custom Controls example is a simple demonstration of emulated SWT controls.
-It consists of a tab folder where each tab in the folder allows the user
-to interact with a different emulated control.
-The user can change styles and settings and view how this affects each control.
-
-The "Main" class is org.eclipse.swt.examples.controlexample.CustomControlExample.
-
-
-This example can also be run using the Example Launcher.
-Select the Custom Controls item from the Workbench Views category and click Run.
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.controls/icons/controls_example.gif b/examples/org.eclipse.swt.examples.controls/icons/controls_example.gif
deleted file mode 100755
index cbdee97066..0000000000
Binary files a/examples/org.eclipse.swt.examples.controls/icons/controls_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.controls/plugin.properties b/examples/org.eclipse.swt.examples.controls/plugin.properties
deleted file mode 100755
index ee2fea23ad..0000000000
--- a/examples/org.eclipse.swt.examples.controls/plugin.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTControlsExample.name = SWT Controls Example Plugin
-category.SWTExamples.name = SWT Examples
-view.ControlsExample.name = SWT Controls
-view.CustomControlsExample.name = SWT Custom Controls
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.ControlsExample.name = Controls
-launchitem.ControlsExample.description = \
- This example is a simple demonstration of native SWT controls.\n\n\
- It consists of a tab folder where each tab allows the user \
- to interact with a different SWT control. \
- The user can change styles and settings and view how this affects the control.
-
-launchitem.CustomControlsExample.name = Custom Controls
-launchitem.CustomControlsExample.description = \
- This example is a simple demonstration of custom SWT controls.\n\n\
- It consists of a tab folder where each tab allows the user \
- to interact with a different SWT custom control. \
- The user can change styles and settings and view how this affects the control.
diff --git a/examples/org.eclipse.swt.examples.controls/plugin.xml b/examples/org.eclipse.swt.examples.controls/plugin.xml
deleted file mode 100755
index ab660f00e4..0000000000
--- a/examples/org.eclipse.swt.examples.controls/plugin.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.controls/src/import.properties b/examples/org.eclipse.swt.examples.controls/src/import.properties
deleted file mode 100644
index 58344f0d3e..0000000000
--- a/examples/org.eclipse.swt.examples.controls/src/import.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Persist project settings for later import
-natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature
-builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder
-var.ECLIPSE_PLUGINS = <>
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ControlPlugin.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ControlPlugin.java
deleted file mode 100755
index d0a2a3a583..0000000000
--- a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ControlPlugin.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.controls;
-
-
-import org.eclipse.ui.plugin.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class ControlPlugin extends AbstractUIPlugin {
- /**
- * The constructor.
- */
- public ControlPlugin() {
- super();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ControlView.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ControlView.java
deleted file mode 100755
index 502464174f..0000000000
--- a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/ControlView.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.controls;
-
-
-import org.eclipse.swt.examples.controlexample.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.part.*;
-
-/**
- * Controls is a simple demonstration
- * of the native controls defined by SWT. It consists of a workbench
- * view and tab folder where each tab in the folder allows the
- * user to interact with a control.
- *
- * @see ViewPart
- */
-public class ControlView extends ViewPart {
- ControlExample instance = null;
-
- /**
- * Create the example
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite frame) {
- instance = new ControlExample(frame);
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- instance.setFocus();
- }
-
- /**
- * Called when the View is to be disposed
- */
- public void dispose() {
- instance.dispose();
- instance = null;
- super.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/CustomControlView.java b/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/CustomControlView.java
deleted file mode 100644
index ec66fd4686..0000000000
--- a/examples/org.eclipse.swt.examples.controls/src/org/eclipse/swt/examples/controls/CustomControlView.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.controls;
-
-
-import org.eclipse.swt.examples.controlexample.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * CustomControls is a simple demonstration
- * of the custom controls defined by SWT. It consists of a workbench
- * view and tab folder where each tab in the folder allows the
- * user to interact with a control.
- *
- * @see ViewPart
- */
-public class CustomControlView extends ControlView {
-
- /**
- * Create the example
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite frame) {
- instance = new CustomControlExample(frame);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.launcher/.classpath b/examples/org.eclipse.swt.examples.launcher/.classpath
deleted file mode 100755
index 065ac06e19..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.launcher/.cvsignore b/examples/org.eclipse.swt.examples.launcher/.cvsignore
deleted file mode 100755
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.launcher/.project b/examples/org.eclipse.swt.examples.launcher/.project
deleted file mode 100644
index 08cc7ff241..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.eclipse.swt.examples.launcher
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/examples/org.eclipse.swt.examples.launcher/about.html b/examples/org.eclipse.swt.examples.launcher/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.launcher/build.properties b/examples/org.eclipse.swt.examples.launcher/build.properties
deleted file mode 100755
index 2ca3829db3..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/build.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = doc/,\
- doc-html/,\
- icons/,\
- schema/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.launcher.jar = src/
diff --git a/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal.htm
deleted file mode 100755
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.launcher/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.launcher/doc-html/ngibmcpy.gif
deleted file mode 100755
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.launcher/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html b/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html
deleted file mode 100755
index eaa0c22cc6..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/doc-html/swt_launcher_ex.html
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
- SWT - Example Launcher
-
-
-
-
SWT Example Launcher
-
-
-The Example Launcher is used to launch SWT examples, which can either be Workbench views
-or standalone applications.
-
-
-
-
Workbench views are examples that are integrated into Eclipse. When the launcher
-starts a Workbench view, it is opened in the currently active perspective.
-
Standalone applications are launched in a separate window.
-
-
-
-For information on how to run the standalone examples without the SWT Example Launcher,
-refer to SWT standalone examples setup.
-
-
-The SWT Workbench view examples can also be launched directly without using the SWT Example
-Launcher. SWT Workbench view examples can be found under the SWT Examples category of the
-Show Views dialog.
-
-
-
Running the Example Launcher
-
-
-From Eclipse's Window menu, select Show View > Other.
-In the Show View dialog, expand SWT Examples and select the SWT Example Launcher view.
-A view containing a list of examples will appear in your current perspective.
-When you select an example from the list a brief description of the example is displayed.
-Click on the Run button to launch the example.
-
-This extension point is used to add 'standalone program' and
-'Workbench view'
-launch items to the Launcher, optionally grouping them into
-categories so as to form a multi-tiered hierarchy.
-Standalone programs are executed using the platform's event loop.
-Workbench views are created within the active Workbench Perspective.
Markup
-
<!ELEMENT extension EMPTY>
- <!ATTLIST extension
- point CDATA #REQUIRED
- id CDATA #IMPLIED
- name CDATA #IMPLIED
- >
-
-
point -
id -
name -
-
<!ELEMENT program EMPTY>
- <!ATTLIST program
- mainClass CDATA #REQUIRED
- pluginId CDATA #REQUIRED
- >
-
-
mainClass - The fully-qualified name of the class whose main() method is to be launched.
pluginId - The unique id of the Eclipse Platform plugin containing the program.
id - The unique id of this launch item. Launch items with duplicate id's will be discarded.
category - The unique id of the category this launch item belongs to.
icon - The declaring plugin relative path of an icon to display with this launch item in the Launcher.
enabled - Set to "false" to disable this launch item, or to "true" to enable it (default).
description - The localized plain-text description of this launch item.
-
Example
-
API Information
-
Supplied Implementation
-
-
diff --git a/examples/org.eclipse.swt.examples.launcher/icons/closedFolder.gif b/examples/org.eclipse.swt.examples.launcher/icons/closedFolder.gif
deleted file mode 100755
index beb6ed134c..0000000000
Binary files a/examples/org.eclipse.swt.examples.launcher/icons/closedFolder.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.launcher/icons/generic_example.gif b/examples/org.eclipse.swt.examples.launcher/icons/generic_example.gif
deleted file mode 100755
index f9fb6b0cab..0000000000
Binary files a/examples/org.eclipse.swt.examples.launcher/icons/generic_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.launcher/icons/launcher_example.gif b/examples/org.eclipse.swt.examples.launcher/icons/launcher_example.gif
deleted file mode 100755
index 3ab4d32c05..0000000000
Binary files a/examples/org.eclipse.swt.examples.launcher/icons/launcher_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.launcher/icons/openFolder.gif b/examples/org.eclipse.swt.examples.launcher/icons/openFolder.gif
deleted file mode 100755
index a9c777343c..0000000000
Binary files a/examples/org.eclipse.swt.examples.launcher/icons/openFolder.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.properties b/examples/org.eclipse.swt.examples.launcher/plugin.properties
deleted file mode 100755
index 7b0f95c5de..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/plugin.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTLauncherExample.name = SWT Launcher Example Plugin
-category.SWTExamples.name = SWT Examples
-view.LauncherExample.name = SWT Example Launcher
-
-extension-point.launchItems.name = Launch Items
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.LauncherExample.name = Launcher
-launchitem.LauncherExample.description = \
- The Example Launcher is used to launch SWT examples which can either be \
- Workbench Views, or Standalone applications.\n\n\
- Workbench Views are examples that are integrated into Eclipse. When the Launcher \
- starts a Workbench View, it is opened in the currently active perspective.\n\n\
- Standalone applications are launched in a separate window.
-
-error.CouldNotLoadResources = Unable to load resources
-error.CouldNotFindRegisteredExtensions = Could Not Find Registered Extensions
-error.IncompleteProgramLaunchItem = Incomplete XML ProgramLaunchItem definition, id = {0}
-error.IncompleteViewLaunchItem = Incomplete XML ViewLaunchItem definition, id = {0}
-error.IncompleteLaunchItem = Incomplete or unrecognized XML LaunchItem definition, id = {0}
-
-launchitem.Null.description = <>
-
-launchitem.Missing.name = <>
-launchitem.Missing.description = <>
-
-view.launchGroup.text = Examples
-view.launchButton.text = Run
-view.descriptionGroup.text = Description
-
-run.error.Invocation = A fatal error occurred while launching the program.
-run.error.DoesNotImplementMethod = The class does not implement the open() method.
-run.error.CouldNotFindClass = Could not find the class to run.
-run.error.CouldNotInstantiateClass = Could not instantiate the class to run.
diff --git a/examples/org.eclipse.swt.examples.launcher/plugin.xml b/examples/org.eclipse.swt.examples.launcher/plugin.xml
deleted file mode 100755
index 40281b49cd..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/plugin.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.exsd b/examples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.exsd
deleted file mode 100644
index 3813c9d3fe..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/schema/org.eclipse.swt.examples.launcher.launchItems.exsd
+++ /dev/null
@@ -1,210 +0,0 @@
-
-
-
-
-
-
-
-
- This extension point is used to add 'standalone program' and
-'Workbench view'
-launch items to the Launcher, optionally grouping them into
-categories so as to form a multi-tiered hierarchy.
-Standalone programs are executed using the platform's event loop.
-Workbench views are created within the active Workbench Perspective.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Specifies a "Standalone Program" for a launch item to run.
-
-
-
-
-
-
- The fully-qualified name of the class whose main() method is to be launched.
-
-
-
-
-
-
- The unique id of the Eclipse Platform plugin containing the program.
-
-
-
-
-
-
-
-
-
- Specifies a "Workbench View" for a launch item to activate.
-
-
-
-
-
-
- The unique id of the Workbench View to be activated when the item is launched.
-
-
-
-
-
-
-
-
-
- Specifies a launch item category heading.
-
-
-
-
-
-
- The localized name of this category.
-
-
-
-
-
-
- The unique id of this category. Categories with duplicate id's will be discarded.
-
-
-
-
-
-
- The unique id of the parent category.
-
-
-
-
-
-
- Specifies a launch item category description.
-
-
-
-
-
-
-
-
-
- Specifies a launch item.
-
-
-
-
-
-
-
-
-
-
- The localized name of this launch item.
-
-
-
-
-
-
- The unique id of this launch item. Launch items with duplicate id's will be discarded.
-
-
-
-
-
-
- The unique id of the category this launch item belongs to.
-
-
-
-
-
-
- The declaring plugin relative path of an icon to display with this launch item in the Launcher.
-
-
-
-
-
-
- Set to "false" to disable this launch item, or to "true" to enable it (default).
-
-
-
-
-
-
- The localized plain-text description of this launch item.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.launcher/src/import.properties b/examples/org.eclipse.swt.examples.launcher/src/import.properties
deleted file mode 100644
index 58344f0d3e..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/src/import.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Persist project settings for later import
-natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature
-builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder
-var.ECLIPSE_PLUGINS = <>
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
deleted file mode 100755
index cbe6517c0f..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemDescriptor.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.launcher;
-
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * ItemDescriptor collects information about a launch item.
- */
-class ItemDescriptor {
- private String id;
- private String name;
- private String description;
- private Image icon;
- private String view;
- private String mainType;
- private String pluginId;
- private IConfigurationElement element;
-
-
- /**
- * Constructs an ItemDescriptor.
- *
- * @param id the id
- * @param name the name
- * @param description the description
- * @param icon the icon
- * @param view the host view may be null if it is a standalone application
- * @param mainType the fully qualified class name to run may be null if it is a view
- * @param pluginId the name of the plugin which contains the main class
- */
- public ItemDescriptor(String id, String name, String description,
- Image icon, String view, String mainType, String pluginId, IConfigurationElement element) {
- this.id = id;
- this.name = name;
- this.description = description;
- this.icon = icon;
- this.view = view;
- this.mainType = mainType;
- this.pluginId = pluginId;
- this.element = element;
- }
-
- /**
- * Creates and returns an instance of the extension's specified type,
- * or null if no type was specified by the extension.
- *
- * @return an instance of the extension's specified type or null
- */
- public Object createItemInstance() throws CoreException {
- if (element == null) return null;
- return element.createExecutableExtension(LauncherPlugin.LAUNCH_ITEMS_XML_PROGRAM_CLASS);
- }
-
- /**
- * Returns the ID for this program.
- *
- * @return the user-specified ID for this program
- */
- public String getId() {
- return id;
- }
-
- /**
- * Returns the translated name for the program.
- *
- * @return the name of the program
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns a short description for the program.
- *
- * @return a newline-delimited string describing the program, null if no description is available
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Returns an icon for this descriptor
- *
- * @returns an icon, null if the item is a folder
- */
- public Image getIcon() {
- return icon;
- }
-
- /**
- * Returns the host view for the program.
- *
- * @return the host view, null if the item is a standalone program.
- */
- public String getView () {
- return view;
- }
-
- /**
- * Returns the fully qualified class to run
- * for the program.
- *
- * @return the class to run for the program.
- */
- public String getMainType () {
- return mainType;
- }
-
- /**
- * Returns the name of the plugin that contains the program.
- *
- * @return the name of the plugin that contains the program.
- */
- public String getPluginId () {
- return pluginId;
- }
-
- /**
- * Determines if an item is a folder.
- *
- * @return true if the item is a folder
- */
- public boolean isFolder() {
- return (mainType == null && view == null);
- }
-
- /**
- * Determines the equality of descriptors.
- *
- * @return true if this.getId().equalsIgnoreCase(other.getId())
- */
- public boolean equals(Object other) {
- if (other instanceof ItemDescriptor) {
- ItemDescriptor otherDescriptor = (ItemDescriptor) other;
- return getId().equalsIgnoreCase(otherDescriptor.getId());
- }
- return false;
- }
-
- /**
- * Produces a hashcode.
- *
- * @return the hashcode
- */
- public int hashCode() {
- return id.toUpperCase().hashCode();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemTreeNode.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemTreeNode.java
deleted file mode 100755
index 6088090e96..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/ItemTreeNode.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.launcher;
-
-
-/**
- * Internal class used to store tree structures of ItemDescriptors
- */
-class ItemTreeNode {
- private ItemTreeNode nextSibling;
- private ItemTreeNode firstChild;
- private ItemDescriptor descriptor;
-
- /**
- * Constructs a leaf ItemTreeNode with a given descriptor.
- *
- * @param descriptor the descriptor
- */
- public ItemTreeNode(ItemDescriptor descriptor) {
- this.descriptor = descriptor;
- }
-
- /**
- * Adds a node to the Tree in sorted order by name.
- *
- * @param node the node to add. Note that node.nextSibling must be null
- */
- public void addSortedNode(ItemTreeNode node) {
- if (firstChild == null) {
- firstChild = node;
- } else if (firstChild.descriptor.getName().compareTo(node.descriptor.getName()) > 0) {
- node.nextSibling = firstChild;
- firstChild = node;
- } else {
- ItemTreeNode cursor;
- for (cursor = firstChild; cursor.nextSibling != null; cursor = cursor.nextSibling) {
- ItemTreeNode sibling = cursor.nextSibling;
- if (sibling.descriptor.getName().compareTo(node.descriptor.getName()) > 0) break;
- }
- node.nextSibling = cursor.nextSibling;
- cursor.nextSibling = node;
- }
- }
-
- /**
- * Returns the descriptor for this node.
- *
- * @return the descriptor
- */
- public ItemDescriptor getDescriptor() {
- return descriptor;
- }
-
- /**
- * Returns the next sibling of this node.
- *
- * @return the next sibling, or null if none
- */
- public ItemTreeNode getNextSibling() {
- return nextSibling;
- }
-
- /**
- * Returns the first child of this node.
- *
- * @return the first child, or null if none
- */
- public ItemTreeNode getFirstChild() {
- return firstChild;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
deleted file mode 100755
index 515623353f..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherPlugin.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.launcher;
-
-
-import java.io.*;
-import java.net.*;
-import java.text.*;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.ui.plugin.*;
-import org.osgi.framework.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class LauncherPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static LauncherPlugin plugin;
- private static ResourceBundle resourceBundle;
-
- public static final String
- LAUNCH_ITEMS_POINT_ID = "org.eclipse.swt.examples.launcher.launchItems",
- LAUNCH_ITEMS_XML_CATEGORY = "category",
- LAUNCH_ITEMS_XML_ITEM = "item",
- LAUNCH_ITEMS_XML_ITEM_ICON = "icon",
- LAUNCH_ITEMS_XML_ITEM_DESCRIPTION = "description",
- LAUNCH_ITEMS_XML_PROGRAM = "program",
- LAUNCH_ITEMS_XML_PROGRAM_PLUGIN = "pluginId",
- LAUNCH_ITEMS_XML_PROGRAM_CLASS = "mainClass",
- LAUNCH_ITEMS_XML_VIEW = "view",
- LAUNCH_ITEMS_XML_VIEW_VIEWID = "viewId",
- LAUNCH_ITEMS_XML_ATTRIB_ID = "id",
- LAUNCH_ITEMS_XML_ATTRIB_NAME = "name",
- LAUNCH_ITEMS_XML_ATTRIB_ENABLED = "enabled",
- LAUNCH_ITEMS_XML_ATTRIB_CATEGORY = "category",
- LAUNCH_ITEMS_XML_VALUE_TRUE = "true",
- LAUNCH_ITEMS_XML_VALUE_FALSE = "false";
-
- static final int
- liClosedFolder = 0,
- liOpenFolder = 1,
- liGenericExample = 2;
- static final String[] imageLocations = {
- "icons/closedFolder.gif",
- "icons/openFolder.gif",
- "icons/generic_example.gif" };
- static Image images[];
-
- /**
- * Constructs the LauncherPlugin.
- */
- public LauncherPlugin() {
- super();
- plugin = this;
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- resourceBundle = Platform.getResourceBundle(getBundle());
- }
-
- /**
- * Clean up
- */
- public void stop(BundleContext context) throws Exception {
- freeResources();
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- */
- public static LauncherPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Loads the resources
- */
- public static void initResources() {
- if (images == null) {
- images = new Image[imageLocations.length];
-
- for (int i = 0; i < imageLocations.length; ++i) {
- images[i] = getImageFromPlugin(plugin.getBundle(), imageLocations[i]);
- if (images[i] == null) {
- freeResources();
- logError(getResourceString("error.CouldNotLoadResources"), null);
- throw new IllegalStateException();
- }
- }
- }
- }
-
- /**
- * Frees the resources
- */
- public static void freeResources() {
- if (images != null) {
- for (int i = 0; i < images.length; ++i) {
- final Image image = images[i];
- if (image != null) image.dispose();
- }
- images = null;
- }
- }
-
- /**
- * Log an error to the ILog for this plugin
- *
- * @param message the localized error message text
- * @param exception the associated exception, or null
- */
- public static void logError(String message, Throwable exception) {
- plugin.getLog().log(new Status(
- IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, message, exception));
- }
-
- /**
- * Returns a string from the resource bundle.
- * We don't want to crash because of a missing String.
- * Returns the key if not found.
- */
- public static String getResourceString(String key) {
- try {
- return resourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Returns a string from the resource bundle and binds it
- * with the given arguments. If the key is not found,
- * return the key.
- */
- public static String getResourceString(String key, Object[] args) {
- try {
- return MessageFormat.format(getResourceString(key), args);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Constructs a list of available programs from registered extensions.
- *
- * @return an ItemTreeNode representing the root of a tree of items (the root is not to be displayed)
- */
- public static ItemTreeNode getLaunchItemTree() {
- ItemTreeNode categoryTree =
- new ItemTreeNode(new ItemDescriptor("<>", "<>", null, null, null, null, null, null));
-
- // get the platform's public plugin registry
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- // retrieve all configuration elements registered at our launchItems extension-point
- IConfigurationElement[] configurationElements =
- extensionRegistry.getConfigurationElementsFor(LAUNCH_ITEMS_POINT_ID);
-
- if (configurationElements == null || configurationElements.length == 0) {
- logError(getResourceString("error.CouldNotFindRegisteredExtensions"), null);
- return categoryTree;
- }
-
- /* Collect all launch categories -- coalesce those with same ID */
- HashMap idMap = new HashMap();
- for (int i = 0; i < configurationElements.length; ++i) {
- final IConfigurationElement ce = configurationElements[i];
- final String ceName = ce.getName();
- final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
-
- if (idMap.containsKey(attribId)) continue;
- if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
- final String attribName = getItemName(ce);
- ItemDescriptor theDescriptor = new ItemDescriptor(attribId, attribName,
- getItemDescription(ce), null, null, null, null, ce);
- idMap.put(attribId, new ItemTreeNode(theDescriptor));
- }
- }
-
- /* Generate launch category hierarchy */
- Set tempIdSet = new HashSet(); // used to prevent duplicates from being entered into the tree
- for (int i = 0; i < configurationElements.length; ++i) {
- final IConfigurationElement ce = configurationElements[i];
- final String ceName = ce.getName();
- final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
-
- if (tempIdSet.contains(attribId)) continue;
- if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
- final ItemTreeNode theNode = (ItemTreeNode) idMap.get(attribId);
- addItemByCategory(ce, categoryTree, theNode, idMap);
- tempIdSet.add(attribId);
- }
- }
-
- /* Generate program tree */
- for (int i = 0; i < configurationElements.length; ++i) {
- final IConfigurationElement ce = configurationElements[i];
- final String ceName = ce.getName();
- final String attribId = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ID, null);
-
- if (idMap.containsKey(attribId)) continue;
- if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_CATEGORY)) {
- // ignore
- } else if (ceName.equalsIgnoreCase(LAUNCH_ITEMS_XML_ITEM)) {
- final String enabled = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_ENABLED,
- LAUNCH_ITEMS_XML_VALUE_TRUE);
- if (enabled.equalsIgnoreCase(LAUNCH_ITEMS_XML_VALUE_FALSE)) continue;
- ItemDescriptor theDescriptor = createItemDescriptor(ce, attribId);
-
- if (theDescriptor != null) {
- final ItemTreeNode theNode = new ItemTreeNode(theDescriptor);
- addItemByCategory(ce, categoryTree, theNode, idMap);
- idMap.put(attribId, theNode);
- }
- }
- }
- return categoryTree;
- }
-
-
- /**
- * Adds an item to the category tree.
- */
- private static void addItemByCategory(IConfigurationElement ce, ItemTreeNode root,
- ItemTreeNode theNode, HashMap idMap) {
- final String attribCategory = getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_CATEGORY, null);
-
- // locate the parent node
- ItemTreeNode parentNode = null;
- if (attribCategory != null) {
- parentNode = (ItemTreeNode) idMap.get(attribCategory);
- }
- if (parentNode == null) parentNode = root;
-
- // add the item
- parentNode.addSortedNode(theNode);
- }
-
- /**
- * Creates an ItemDescriptor from an XML definition.
- *
- * @param ce the IConfigurationElement describing the item
- * @param attribId the attribute id
- * @return a new ItemDescriptor, or null if an error occurs
- */
- private static ItemDescriptor createItemDescriptor(IConfigurationElement ce, String attribId) {
- final String attribName = getItemName(ce);
- final Image attribIcon = getItemIcon(ce);
- final String attribDescription = getItemDescription(ce);
-
- IConfigurationElement viewCE = getItemElement(ce, LAUNCH_ITEMS_XML_VIEW);
- if (viewCE != null) {
- //Item is a view
- final String attribView = getItemAttribute(viewCE, LAUNCH_ITEMS_XML_VIEW_VIEWID, null);
- if (attribView == null) {
- logError(getResourceString("error.IncompleteViewLaunchItem",
- new Object[] { attribId } ), null);
- return null;
- }
- return new ItemDescriptor(attribId, attribName, attribDescription,
- attribIcon, attribView, null, null, viewCE);
- } else {
- //Item is a standalone
- IConfigurationElement programCE = getItemElement(ce, LAUNCH_ITEMS_XML_PROGRAM);
- if (programCE != null) {
- final String attribPluginId = getItemAttribute(programCE, LAUNCH_ITEMS_XML_PROGRAM_PLUGIN, null);
- final String attribClass = getItemAttribute(programCE, LAUNCH_ITEMS_XML_PROGRAM_CLASS, null);
- if (attribClass == null || attribPluginId == null) {
- logError(getResourceString("error.IncompleteProgramLaunchItem",
- new Object[] { attribId } ), null);
- return null;
- }
- return new ItemDescriptor(attribId, attribName, attribDescription,
- attribIcon, null, attribClass, attribPluginId, programCE);
- } else {
- logError(getResourceString("error.IncompleteLaunchItem",
- new Object[] { attribId } ), null);
- return null;
- }
- }
- }
-
- /**
- * Returns the first instance of a particular child XML element.
- *
- * @param ce the IConfigurationElement parent
- * @param element the name of the element to fetch
- * @return the element's IConfigurationElement, or null if not found
- */
- private static IConfigurationElement getItemElement(IConfigurationElement ce, String element) {
- IConfigurationElement[] elementCEs = ce.getChildren(element);
- return (elementCEs != null && elementCEs.length != 0) ? elementCEs[0] : null;
- }
-
- /**
- * Returns the value of an XML attribute for an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @param attribute the attribute to fetch
- * @param defaultValue the value to return if the attribute is not found
- * @return the attribute value
- */
- private static String getItemAttribute(IConfigurationElement ce, String attribute, String defaultValue) {
- String value = ce.getAttribute(attribute);
- return (value != null) ? value : defaultValue;
- }
-
- /**
- * Returns the description string given the IConfigurationElement for an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @return a newline-delimited string that describes this item, or null if none
- */
- private static String getItemDescription(IConfigurationElement ce) {
- String description = getItemAttribute(ce, LAUNCH_ITEMS_XML_ITEM_DESCRIPTION, "");
- return (description.length() == 0) ? null : description;
- }
-
- /**
- * Returns the name of an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @return the attribute value
- */
- private static String getItemName(IConfigurationElement ce) {
- return getItemAttribute(ce, LAUNCH_ITEMS_XML_ATTRIB_NAME,
- getResourceString("launchitem.Missing.name"));
- }
-
-
- /**
- * Returns the icon for an item.
- *
- * @param ce the IConfigurationElement describing the item
- * @return an icon
- */
- private static Image getItemIcon(IConfigurationElement ce) {
- String iconPath = getItemAttribute(ce, LAUNCH_ITEMS_XML_ITEM_ICON, "");
- if (iconPath.length() != 0) {
- String symbolicName = ce.getDeclaringExtension().getNamespace();
- Bundle bundle = Platform.getBundle(symbolicName);
- Image icon = getImageFromPlugin(bundle, iconPath);
- if (icon != null) {
- Image[] newImages = new Image[images.length + 1];
- System.arraycopy(images, 0, newImages, 0, images.length);
- newImages[images.length] = icon;
- images = newImages;
- return icon;
- }
- }
- return images[liGenericExample];
- }
-
- /**
- * Gets an image from a path relative to the plugin install directory.
- *
- * @param bundle the plugin descriptor for the plugin with the image
- * @param iconPath the path relative to the install directory
- * @return the image, or null if not found
- */
- private static Image getImageFromPlugin(Bundle bundle, String iconPath) {
- InputStream is = null;
- try {
- URL installUrl = bundle.getEntry("/");
- URL url = new URL(installUrl, iconPath);
- is = url.openConnection().getInputStream();
- ImageData source = new ImageData(is);
- ImageData mask = source.getTransparencyMask();
- Image image = new Image(null, source, mask);
- return image;
- } catch (Throwable ex) {
- return null;
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e) {
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
deleted file mode 100755
index dddc951017..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/LauncherView.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.launcher;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.part.*;
-import java.lang.reflect.*;
-
-/**
- * Launcher uses org.eclipse.swt
- * to launch the other registered examples.
- *
- * @see ViewPart
- */
-public class LauncherView extends ViewPart {
- private Shell workbenchShell;
-
- private Tree launchTree;
- private Text descriptionText;
- private Button runButton;
-
- /**
- * Constructs a LauncherView.
- */
- public LauncherView() {
- LauncherPlugin.initResources();
- }
-
- /**
- * Creates the example.
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite parent) {
- workbenchShell = getSite().getShell();
- parent.setLayout(new SplitLayout());
-
- Group launchGroup = new Group(parent, SWT.NULL);
- launchGroup.setText(LauncherPlugin.getResourceString("view.launchGroup.text"));
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- launchGroup.setLayout(gridLayout);
-
- launchTree = new Tree(launchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
- gridData.horizontalSpan = 2;
- launchTree.setLayoutData(gridData);
- launchTree.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- final ItemDescriptor item = getSelectedItem();
- setDescriptionByItem(item);
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- final ItemDescriptor item = getSelectedItem();
- setDescriptionByItem(item);
- launchItem(getSelectedItem());
- }
- });
- launchTree.addTreeListener(new TreeListener() {
- public void treeCollapsed(TreeEvent event) {
- final TreeItem item = (TreeItem) event.item;
- if (item == null) return;
- item.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
- }
- public void treeExpanded(TreeEvent event) {
- final TreeItem item = (TreeItem) event.item;
- if (item == null) return;
- item.setImage(LauncherPlugin.images[LauncherPlugin.liOpenFolder]);
- }
- });
-
- runButton = new Button(launchGroup, SWT.PUSH);
- runButton.setText(LauncherPlugin.getResourceString("view.launchButton.text"));
- runButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- launchItem(getSelectedItem());
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- }
- });
-
- Group descriptionGroup = new Group(parent, SWT.NULL);
- descriptionGroup.setText(LauncherPlugin.getResourceString("view.descriptionGroup.text"));
- descriptionGroup.setLayout(new FillLayout());
-
- descriptionText = new Text(descriptionGroup, SWT.MULTI | SWT.BORDER |
- SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
-
- setDescriptionByItem(null);
- setItemDescriptors(LauncherPlugin.getLaunchItemTree());
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- launchTree.setFocus();
- runButton.getShell().setDefaultButton(runButton);
- }
-
- /**
- * Called when the View is to be disposed
- */
- public void dispose() {
- workbenchShell = null;
- launchTree = null;
- descriptionText = null;
- runButton = null;
- super.dispose();
- }
-
- /**
- * Installs a new launch list.
- *
- * @param newRoot the new tree of launch items for the UI
- */
- public void setItemDescriptors(final ItemTreeNode newRoot) {
- if (workbenchShell == null) return;
- workbenchShell.getDisplay().syncExec(new Runnable() {
- public void run() {
- if ((launchTree == null) || (launchTree.isDisposed())) return;
- launchTree.removeAll();
-
- for (ItemTreeNode node = newRoot.getFirstChild(); node != null;
- node = node.getNextSibling()) {
- doNode(node, new TreeItem(launchTree, SWT.NONE)); // top-level TreeItem
- }
- }
- private void addGroup(TreeItem parent, ItemTreeNode node) {
- for (;node != null; node = node.getNextSibling()) {
- doNode(node, new TreeItem(parent, SWT.NONE)); // TreeItem at depth > 0
- }
- }
- private void doNode(ItemTreeNode node, TreeItem treeItem) {
- final ItemDescriptor item = node.getDescriptor();
- treeItem.setText(item.getName());
- treeItem.setData(item);
- if (node.getDescriptor().isFolder()) {
- treeItem.setExpanded(false);
- treeItem.setImage(LauncherPlugin.images[LauncherPlugin.liClosedFolder]);
- } else {
- treeItem.setImage(node.getDescriptor().getIcon());
- }
- addGroup(treeItem, node.getFirstChild());
- }
- });
- }
-
- /**
- * Runs the specified launch item.
- *
- * @param itemDescriptor the launch item to execute
- */
- private void launchItem(ItemDescriptor itemDescriptor) {
- /* Case 1: The launch item is a view */
- String pluginViewId = itemDescriptor.getView ();
- if (pluginViewId != null) {
- final IWorkbenchPart workbenchPart = this;
- final IWorkbenchPartSite workbenchPartSite = workbenchPart.getSite();
- final IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
- try {
- workbenchPage.showView(pluginViewId);
- } catch (PartInitException e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.Invocation"), e);
- }
- return;
- }
- /* Case 2: The launch item is a standalone program */
- if (workbenchShell == null) return;
- try {
- Object instance = itemDescriptor.createItemInstance();
- if (instance != null) {
- Display display = workbenchShell.getDisplay();
- Method openMethod = instance.getClass().getDeclaredMethod("open", new Class[] {Display.class});
- openMethod.invoke(instance, new Object[] {display});
- }
- } catch (NoSuchMethodException e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.DoesNotImplementMethod"), null);
- } catch (Exception e) {
- LauncherPlugin.logError(LauncherPlugin.getResourceString("run.error.CouldNotInstantiateClass"), e);
- }
- }
-
- /**
- * Obtains the selected launch item.
- *
- * @return the currently selected ItemDescriptor
- */
- private ItemDescriptor getSelectedItem() {
- final TreeItem[] selections = launchTree.getSelection();
- if (selections.length == 0) return null;
- final ItemDescriptor itemDescriptor = (ItemDescriptor) selections[0].getData();
- return itemDescriptor;
- }
-
- /**
- * Sets the currently visible description text to reflect that of a particular ItemDescriptor.
- *
- * @param itemDescriptor the launch item whose description is to be displayed, or null if none
- */
- private void setDescriptionByItem(ItemDescriptor itemDescriptor) {
- String description;
- if (itemDescriptor == null) {
- description = LauncherPlugin.getResourceString("launchitem.Null.description");
- if (runButton != null) runButton.setEnabled(false);
- } else {
- description = itemDescriptor.getDescription();
- if (description == null)
- description = LauncherPlugin.getResourceString("launchitem.Missing.description");
- if (runButton != null) {
- runButton.setEnabled(itemDescriptor.getView() != null || itemDescriptor.getMainType() != null);
- }
- }
- descriptionText.setText(description);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java b/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java
deleted file mode 100755
index 47dbfddd89..0000000000
--- a/examples/org.eclipse.swt.examples.launcher/src/org/eclipse/swt/examples/launcher/SplitLayout.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.launcher;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * A Layout class that automatically switches from a horizontal split to a vertical
- * split layout to accomodate changing size conditions.
- *
- * Later on we might improve this class to take into account the "preferred" size of
- * the widgets.
- */
-public class SplitLayout extends Layout {
- private static final int
- splitHorizontally = 0,
- splitVertically = 1;
- private int splitDirection = splitHorizontally;
-
- public int spacing = 3;
- public int marginTop = 3;
- public int marginLeft = 3;
- public int marginRight = 3;
- public int marginBottom = 3;
-
- /**
- * Creates a new layout
- */
- public SplitLayout() {
- }
-
- /**
- * @see Layout#computeSize(Composite, int, int, boolean)
- */
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- if (wHint == SWT.DEFAULT) {
- if (hHint == SWT.DEFAULT) {
- Point hSplitSize = computeHSplitSize(composite, wHint, hHint, flushCache);
- Point vSplitSize = computeVSplitSize(composite, wHint, hHint, false);
- int hSplitArea = hSplitSize.x * hSplitSize.y;
- int vSplitArea = vSplitSize.x * vSplitSize.y;
- // Choose direction consuming least area
- if (hSplitArea < vSplitArea) {
- splitDirection = splitHorizontally;
- return hSplitSize;
- } else {
- splitDirection = splitVertically;
- return vSplitSize;
- }
- } else {
- // Constrained in height: split vertically
- splitDirection = splitVertically;
- return computeVSplitSize(composite, wHint, hHint, flushCache);
- }
- } else {
- if (hHint == SWT.DEFAULT) {
- // Constrained in width: split horizontally
- splitDirection = splitHorizontally;
- return computeHSplitSize(composite, wHint, hHint, flushCache);
- } else {
- if (hHint < wHint) {
- splitDirection = splitVertically;
- return computeVSplitSize(composite, wHint, hHint, flushCache);
- } else {
- splitDirection = splitHorizontally;
- return computeHSplitSize(composite, wHint, hHint, flushCache);
- }
- }
- }
- }
- /**
- * @see Layout#layout(Composite, boolean)
- */
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle clientArea = composite.getClientArea();
- computeSize(composite, clientArea.width, clientArea.height, false);
-
- Control[] children = composite.getChildren();
- clientArea.x += marginLeft;
- clientArea.y += marginTop;
- clientArea.width -= marginRight + marginLeft;
- clientArea.height -= marginBottom + marginTop;
- Point position = new Point(clientArea.x, clientArea.y);
-
- for (int i = 0; i < children.length; ++i) {
- final Control child = children[i];
- final Rectangle bounds;
- if (splitDirection == splitHorizontally) {
- int height = clientArea.height / children.length;
- bounds = new Rectangle(position.x, position.y, clientArea.width, height);
- position.y += height + spacing;
- } else {
- int width = clientArea.width / children.length;
- bounds = new Rectangle(position.x, position.y, width, clientArea.height);
- position.x += width + spacing;
- }
- bounds.width = Math.max(bounds.width, 0);
- bounds.height = Math.max(bounds.height, 0);
- child.setBounds(bounds);
- }
- }
-
- private Point computeHSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Point size = new Point(marginLeft + marginRight, marginTop + marginBottom);
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; ++i) {
- final Control child = children[i];
-
- Point childSize = child.computeSize(wHint, hHint, flushCache);
- size.x = Math.max(size.x, childSize.x);
- size.y += childSize.y + spacing;
- }
- return size;
- }
-
- private Point computeVSplitSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Point size = new Point(marginLeft + marginRight, marginTop + marginBottom);
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; ++i) {
- final Control child = children[i];
-
- Point childSize = child.computeSize(wHint, hHint, flushCache);
- size.x += childSize.x + spacing;
- size.y = Math.max(size.y, childSize.y);
- }
- return size;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.layouts/.classpath b/examples/org.eclipse.swt.examples.layouts/.classpath
deleted file mode 100644
index 065ac06e19..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.layouts/.cvsignore b/examples/org.eclipse.swt.examples.layouts/.cvsignore
deleted file mode 100644
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.layouts/.project b/examples/org.eclipse.swt.examples.layouts/.project
deleted file mode 100644
index a6fc2cb975..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.eclipse.swt.examples.layouts
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/examples/org.eclipse.swt.examples.layouts/about.html b/examples/org.eclipse.swt.examples.layouts/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.layouts/build.properties b/examples/org.eclipse.swt.examples.layouts/build.properties
deleted file mode 100644
index 1c236e8ba2..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = doc-html/,\
- icons/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.layouts.jar = src/
diff --git a/examples/org.eclipse.swt.examples.layouts/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.layouts/doc-html/hglegal.htm
deleted file mode 100644
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.layouts/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.layouts/doc-html/ngibmcpy.gif
deleted file mode 100644
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.layouts/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.layouts/doc-html/swt_layout_ex.html b/examples/org.eclipse.swt.examples.layouts/doc-html/swt_layout_ex.html
deleted file mode 100644
index 9857c599fa..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/doc-html/swt_layout_ex.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
- SWT - Layout Example
-
-
-
-
SWT example - Layouts
-
-
-This example is a simple demonstration of common SWT layouts.
-It consists of a tab folder where each tab in the folder allows the
-user to interact with a different SWT layout.
-The user can insert widgets into a layout and set the values of the layout data
-using a property sheet. When the user has a suitable arrangement, the underlying
-code can be generated by clicking on the Code button.
-
-The "Main" class is org.eclipse.swt.examples.layoutexample.LayoutExample.
-
-
-This example can also be run using the Example Launcher.
-Select the Layouts item from the Workbench Views category and click Run.
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.layouts/icons/layouts_example.gif b/examples/org.eclipse.swt.examples.layouts/icons/layouts_example.gif
deleted file mode 100644
index d945dde53b..0000000000
Binary files a/examples/org.eclipse.swt.examples.layouts/icons/layouts_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.layouts/plugin.properties b/examples/org.eclipse.swt.examples.layouts/plugin.properties
deleted file mode 100644
index 59ffc928d5..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/plugin.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTLayoutExample.name = SWT Layout Example Plugin
-category.SWTExamples.name = SWT Examples
-view.LayoutExample.name = SWT Layouts
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.LayoutExample.name = Layouts
-launchitem.LayoutExample.description = \
- This example is a simple demonstration of common SWT layouts. \n\n\
- It consists of a tab folder where each tab allows the \
- user to interact with a different SWT layout.\
- The user can insert widgets into a layout and set the values of the layout data \
- using a property sheet. When the user has a suitable arrangement, code can be \
- generated by clicking on the Code button.
diff --git a/examples/org.eclipse.swt.examples.layouts/plugin.xml b/examples/org.eclipse.swt.examples.layouts/plugin.xml
deleted file mode 100644
index d9390634e4..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/plugin.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.layouts/src/import.properties b/examples/org.eclipse.swt.examples.layouts/src/import.properties
deleted file mode 100644
index 58344f0d3e..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/src/import.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Persist project settings for later import
-natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature
-builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder
-var.ECLIPSE_PLUGINS = <>
diff --git a/examples/org.eclipse.swt.examples.layouts/src/org/eclipse/swt/examples/layouts/LayoutPlugin.java b/examples/org.eclipse.swt.examples.layouts/src/org/eclipse/swt/examples/layouts/LayoutPlugin.java
deleted file mode 100644
index 2f9763335f..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/src/org/eclipse/swt/examples/layouts/LayoutPlugin.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.layouts;
-
-
-import org.eclipse.ui.plugin.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class LayoutPlugin extends AbstractUIPlugin {
- /**
- * The constructor.
- */
- public LayoutPlugin() {
- super();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.layouts/src/org/eclipse/swt/examples/layouts/LayoutView.java b/examples/org.eclipse.swt.examples.layouts/src/org/eclipse/swt/examples/layouts/LayoutView.java
deleted file mode 100644
index a765800c3e..0000000000
--- a/examples/org.eclipse.swt.examples.layouts/src/org/eclipse/swt/examples/layouts/LayoutView.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.layouts;
-
-
-import org.eclipse.swt.examples.layoutexample.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.part.*;
-
-/**
- * Layouts is a simple demonstration
- * of the layouts defined by SWT. It consists of a workbench
- * view and tab folder where each tab in the folder allows the
- * user to interact with a layout.
- *
- * @see ViewPart
- */
-public class LayoutView extends ViewPart {
- LayoutExample instance = null;
-
- /**
- * Create the example
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite frame) {
- instance = new LayoutExample(frame);
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- instance.setFocus();
- }
-
- /**
- * Called when the View is to be disposed
- */
- public void dispose() {
- instance.dispose();
- instance = null;
- super.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.classpath b/examples/org.eclipse.swt.examples.ole.win32/.classpath
deleted file mode 100755
index 065ac06e19..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.cvsignore b/examples/org.eclipse.swt.examples.ole.win32/.cvsignore
deleted file mode 100755
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.ole.win32/.project b/examples/org.eclipse.swt.examples.ole.win32/.project
deleted file mode 100644
index ff00f68d20..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.eclipse.swt.examples.ole.win32
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/examples/org.eclipse.swt.examples.ole.win32/about.html b/examples/org.eclipse.swt.examples.ole.win32/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.ole.win32/build.properties b/examples/org.eclipse.swt.examples.ole.win32/build.properties
deleted file mode 100755
index c30cc18464..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = doc-html/,\
- icons/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.olewin32.jar = src/
diff --git a/examples/org.eclipse.swt.examples.ole.win32/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.ole.win32/doc-html/hglegal.htm
deleted file mode 100755
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.ole.win32/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.ole.win32/doc-html/ngibmcpy.gif
deleted file mode 100755
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/doc-html/swt_ole_ex.html b/examples/org.eclipse.swt.examples.ole.win32/doc-html/swt_ole_ex.html
deleted file mode 100755
index 55fa8f9a08..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/doc-html/swt_ole_ex.html
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
- SWT - OLE Web Browser
-
-
-
-
SWT example - OLE Web Browser
-
-
-This example shows how to embed an Active X control into an SWT application or an Eclipse view.
-
-
-When the view is opened, it will create an instance of the Windows Internet Explorer
-control. The OLE web browser has
-Back and Forward buttons to take you to recently visited pages. The browser also contains
-a Home button to take you to the web browser's home page, a Stop button which stops the
-current transfer, a Search button which will search for text typed in the Address text field, and
-a Refresh button which re-draws the contents of the currently displayed page. There is also a
-Go button which, when clicked, will attempt to load the page specified in the Address field.
-
-
-
Running the example
-
-
-From Eclipse's Window menu select Show View > Other.
-In the Show View dialog, expand SWT Examples and select
-the view named OLE Web Browser (win32). A view containing a web browser will appear.
-
-
-This example can also be run using the Example Launcher.
-Select the OLE Web Browser item from the Win32 only category and click Run.
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/backward_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/backward_nav.gif
deleted file mode 100755
index 5fcf41b783..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/backward_nav.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/forward_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/forward_nav.gif
deleted file mode 100755
index 3b9b6af9b1..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/forward_nav.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/home_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/home_nav.gif
deleted file mode 100755
index 77a2306ed2..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/home_nav.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/refresh_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/refresh_nav.gif
deleted file mode 100755
index e270e18bde..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/refresh_nav.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/search_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/search_nav.gif
deleted file mode 100755
index 73ac91bddb..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/search_nav.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/stop_nav.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/stop_nav.gif
deleted file mode 100755
index 653d347b57..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/stop_nav.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/icons/webbrowser_example.gif b/examples/org.eclipse.swt.examples.ole.win32/icons/webbrowser_example.gif
deleted file mode 100755
index 895e22110d..0000000000
Binary files a/examples/org.eclipse.swt.examples.ole.win32/icons/webbrowser_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.properties b/examples/org.eclipse.swt.examples.ole.win32/plugin.properties
deleted file mode 100755
index f7fa735f62..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/plugin.properties
+++ /dev/null
@@ -1,60 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTOLEExample.name = SWT OLE Example Plugin (Win32)
-category.SWTExamples.name = SWT Examples
-view.OLEWebBrowserExample.name = OLE Web Browser (Win32)
-
-launchcategory.SWTWin32OnlyExamples.name = Win32 only
-launchcategory.SWTWin32OnlyExamples.description = \
- A collection of Standard Widget Toolkit examples for Windows systems only.
-
-launchitem.OLEWebBrowserExample.name = OLE Web Browser
-launchitem.OLEWebBrowserExample.description = \
- This example demonstrates how to embed an Active X control into an SWT application or an Eclipse view.\n\n\
- When the view is opened, it will create an instance of the Windows Internet Explorer \
- control. The OLE Web Browser has \
- Back and Forward buttons to take you to recently visited pages. The browser also contains \
- a Home button to take you to the web browser's home page, a Stop button which stops the \
- current transfer, a Search button which will search for text typed in the Address text field, and \
- a Refresh button which re-draws the contents of the currently displayed page. There is also a \
- Go button which, when clicked, will attempt to load the page specified in the Address field.
-
-browser.Back.text = Backward
-browser.Back.tooltip = Go to previous Web site in the history list
-
-browser.Forward.text = Forward
-browser.Forward.tooltip = Go to next Web site in the history list
-
-browser.Home.text = Home
-browser.Home.tooltip = Go to home Web site
-
-browser.Stop.text = Stop
-browser.Stop.tooltip = Stop loading current Web site
-
-browser.Refresh.text = Refresh
-browser.Refresh.tooltip = Refresh current Web site
-
-browser.Search.text = Search
-browser.Search.tooltip = Search the Web
-
-browser.Address.label = Address :
-
-browser.Go.text = Go
-
-browser.State.Uninitialized.text = Not ready.
-browser.State.Loading.text = Loading Web site...
-browser.State.Loaded.text = Ready.
-browser.State.Interactive.text = Loading Web site...
-browser.State.Complete.text = Done.
-
-error.CouldNotLoadResources = Unable to load resources
-error.CouldNotCreateBrowserControl = Unable to create <>
diff --git a/examples/org.eclipse.swt.examples.ole.win32/plugin.xml b/examples/org.eclipse.swt.examples.ole.win32/plugin.xml
deleted file mode 100755
index 410724fb85..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/plugin.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/import.properties b/examples/org.eclipse.swt.examples.ole.win32/src/import.properties
deleted file mode 100644
index 58344f0d3e..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/src/import.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Persist project settings for later import
-natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature
-builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder
-var.ECLIPSE_PLUGINS = <>
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleBrowserView.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleBrowserView.java
deleted file mode 100755
index 84323f84e6..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleBrowserView.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.ole.win32;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.part.*;
-
-/**
- * Ole uses org.eclipse.swt to demonstrate Win32 OLE / ActiveX
- * integration.
- *
- * @see ViewPart
- */
-public class OleBrowserView extends ViewPart {
-
- private Composite displayArea;
-
- private OleFrame webFrame;
- private OleWebBrowser webBrowser;
- private Text webUrl;
- private OleControlSite webControlSite;
- private ProgressBar webProgress;
- private Label webStatus;
- private Button webNavigateButton;
-
- private ToolItem webCommandBackward;
- private ToolItem webCommandForward;
- private ToolItem webCommandHome;
- private ToolItem webCommandStop;
- private ToolItem webCommandRefresh;
- private ToolItem webCommandSearch;
-
- private boolean activated = false;
-
- private static final int DISPID_AMBIENT_DLCONTROL = -5512;
- private static final int DLCTL_NO_SCRIPTS = 0x80;
-
- /**
- * Constructs the OLE browser view.
- */
- public OleBrowserView() {
- OlePlugin.initResources();
- }
-
- /**
- * Creates the example.
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite parent) {
- displayArea = new Composite(parent, SWT.NONE);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- displayArea.setLayout(gridLayout);
-
- createToolbar();
- createBrowserFrame();
- createStatusArea();
- createBrowserControl();
- }
-
- /**
- * Cleanup
- */
- public void dispose() {
- if (activated) {
- webControlSite.deactivateInPlaceClient();
- activated = false;
- }
- if (webBrowser != null) webBrowser.dispose();
- webBrowser = null;
- super.dispose();
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- webUrl.setFocus();
- }
-
- /**
- * Creates the Web browser toolbar.
- */
- private void createToolbar() {
- // Add a toolbar
- ToolBar bar = new ToolBar(displayArea, SWT.NONE);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 3;
- bar.setLayoutData(gridData);
-
- // Add a button to navigate backwards through previously visited web sites
- webCommandBackward = new ToolItem(bar, SWT.NONE);
- webCommandBackward.setToolTipText(OlePlugin.getResourceString("browser.Back.tooltip"));
- webCommandBackward.setText(OlePlugin.getResourceString("browser.Back.text"));
- webCommandBackward.setImage(OlePlugin.images[OlePlugin.biBack]);
- webCommandBackward.setEnabled(false);
- webCommandBackward.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (webBrowser == null) return;
- webBrowser.GoBack();
- }
- });
-
- // Add a button to navigate forward through previously visited web sites
- webCommandForward = new ToolItem(bar, SWT.NONE);
- webCommandForward.setToolTipText(OlePlugin.getResourceString("browser.Forward.tooltip"));
- webCommandForward.setText(OlePlugin.getResourceString("browser.Forward.text"));
- webCommandForward.setImage(OlePlugin.images[OlePlugin.biForward]);
- webCommandForward.setEnabled(false);
- webCommandForward.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (webBrowser == null) return;
- webBrowser.GoForward();
- }
- });
-
- // Add a separator
- new ToolItem(bar, SWT.SEPARATOR);
-
- // Add a button to navigate to the Home page
- webCommandHome = new ToolItem(bar, SWT.NONE);
- webCommandHome.setToolTipText(OlePlugin.getResourceString("browser.Home.tooltip"));
- webCommandHome.setText(OlePlugin.getResourceString("browser.Home.text"));
- webCommandHome.setImage(OlePlugin.images[OlePlugin.biHome]);
- webCommandHome.setEnabled(false);
- webCommandHome.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (webBrowser == null) return;
- webBrowser.GoHome();
- }
- });
-
- // Add a button to abort web page loading
- webCommandStop = new ToolItem(bar, SWT.NONE);
- webCommandStop.setToolTipText(OlePlugin.getResourceString("browser.Stop.tooltip"));
- webCommandStop.setText(OlePlugin.getResourceString("browser.Stop.text"));
- webCommandStop.setImage(OlePlugin.images[OlePlugin.biStop]);
- webCommandStop.setEnabled(false);
- webCommandStop.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (webBrowser == null) return;
- webBrowser.Stop();
- }
- });
-
- // Add a button to refresh the current web page
- webCommandRefresh = new ToolItem(bar, SWT.NONE);
- webCommandRefresh.setToolTipText(OlePlugin.getResourceString("browser.Refresh.tooltip"));
- webCommandRefresh.setText(OlePlugin.getResourceString("browser.Refresh.text"));
- webCommandRefresh.setImage(OlePlugin.images[OlePlugin.biRefresh]);
- webCommandRefresh.setEnabled(false);
- webCommandRefresh.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (webBrowser == null) return;
- webBrowser.Refresh();
- }
- });
-
- // Add a separator
- new ToolItem(bar, SWT.SEPARATOR);
-
- // Add a button to search the web
- webCommandSearch = new ToolItem(bar, SWT.NONE);
- webCommandSearch.setToolTipText(OlePlugin.getResourceString("browser.Search.tooltip"));
- webCommandSearch.setText(OlePlugin.getResourceString("browser.Search.text"));
- webCommandSearch.setImage(OlePlugin.images[OlePlugin.biSearch]);
- webCommandSearch.setEnabled(false);
- webCommandSearch.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (webBrowser == null) return;
- webBrowser.GoSearch();
- }
- });
-
- // Add a text area for Users to enter a url
- Composite addressBar = new Composite(displayArea, SWT.NONE);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
- gridData.horizontalSpan = 3;
- addressBar.setLayoutData(gridData);
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- addressBar.setLayout(gridLayout);
-
- Label addressLabel = new Label(addressBar, SWT.NONE);
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- addressLabel.setLayoutData(gridData);
- addressLabel.setText(OlePlugin.getResourceString("browser.Address.label"));
- addressLabel.setFont(OlePlugin.browserFont);
-
- webUrl = new Text(addressBar, SWT.SINGLE | SWT.BORDER);
- webUrl.setFont(OlePlugin.browserFont);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
- webUrl.setLayoutData(gridData);
- webUrl.addFocusListener(new FocusAdapter() {
- public void focusGained(FocusEvent e) {
- webNavigateButton.getShell().setDefaultButton(webNavigateButton);
- }
- });
-
- // Add a button to navigate to the web site specified in the Text area defined above
- webNavigateButton = new Button(addressBar, SWT.PUSH);
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- webNavigateButton.setLayoutData(gridData);
- webNavigateButton.setText(OlePlugin.getResourceString("browser.Go.text"));
- webNavigateButton.setFont(OlePlugin.browserFont);
- webNavigateButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- if (webBrowser == null) return;
- webBrowser.Navigate(webUrl.getText());
- }
- });
- }
-
- /**
- * Creates the Web browser OleFrame.
- */
- private void createBrowserFrame() {
- // Every control must have an associated OleFrame:
- webFrame = new OleFrame(displayArea, SWT.NONE);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
- gridData.horizontalSpan = 3;
- webFrame.setLayoutData(gridData);
- }
-
- /**
- * Creates the Web browser status area.
- */
- private void createStatusArea() {
- // Add a progress bar to display downloading progress information
- webProgress = new ProgressBar(displayArea, SWT.BORDER);
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.BEGINNING;
- gridData.verticalAlignment = GridData.FILL;
- webProgress.setLayoutData(gridData);
-
- // Add a label for displaying status messages as they are received from the control
- webStatus = new Label(displayArea, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
- gridData.horizontalSpan = 2;
- webStatus.setLayoutData(gridData);
- webStatus.setFont(OlePlugin.browserFont);
- }
-
- /**
- * Creates Web browser control.
- */
- private void createBrowserControl() {
- try {
- // Create an Automation object for access to extended capabilities
- webControlSite = new OleControlSite(webFrame, SWT.NONE, "Shell.Explorer");
- Variant download = new Variant(DLCTL_NO_SCRIPTS);
- webControlSite.setSiteProperty(DISPID_AMBIENT_DLCONTROL, download);
- OleAutomation oleAutomation = new OleAutomation(webControlSite);
- webBrowser = new OleWebBrowser(oleAutomation);
- } catch (SWTException ex) {
- // Creation may have failed because control is not installed on machine
- Label label = new Label(webFrame, SWT.BORDER);
- OlePlugin.logError(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl"), ex);
- label.setText(OlePlugin.getResourceString("error.CouldNotCreateBrowserControl"));
- return;
- }
-
- // Respond to ProgressChange events by updating the Progress bar
- webControlSite.addEventListener(OleWebBrowser.ProgressChange, new OleListener() {
- public void handleEvent(OleEvent event) {
- Variant progress = event.arguments[0];
- Variant maxProgress = event.arguments[1];
- if (progress == null || maxProgress == null)
- return;
- webProgress.setMaximum(maxProgress.getInt());
- webProgress.setSelection(progress.getInt());
- }
- });
-
- // Respond to StatusTextChange events by updating the Status Text label
- webControlSite.addEventListener(OleWebBrowser.StatusTextChange, new OleListener() {
- public void handleEvent(OleEvent event) {
- Variant statusText = event.arguments[0];
- if (statusText == null) return;
- String text = statusText.getString();
- if (text != null)
- webStatus.setText(text);
- }
- });
-
- // Listen for changes to the ready state and print out the current state
- webControlSite.addPropertyListener(OleWebBrowser.DISPID_READYSTATE, new OleListener() {
- public void handleEvent(OleEvent event) {
- if (event.detail == OLE.PROPERTY_CHANGING) return;
- int state = webBrowser.getReadyState();
- switch (state) {
- case OleWebBrowser.READYSTATE_UNINITIALIZED:
- webStatus.setText(
- OlePlugin.getResourceString("browser.State.Uninitialized.text"));
- webCommandBackward.setEnabled(false);
- webCommandForward.setEnabled(false);
- webCommandHome.setEnabled(false);
- webCommandRefresh.setEnabled(false);
- webCommandStop.setEnabled(false);
- webCommandSearch.setEnabled(false);
- break;
- case OleWebBrowser.READYSTATE_LOADING:
- webStatus.setText(
- OlePlugin.getResourceString("browser.State.Loading.text"));
- webCommandHome.setEnabled(true);
- webCommandRefresh.setEnabled(true);
- webCommandStop.setEnabled(true);
- webCommandSearch.setEnabled(true);
- break;
- case OleWebBrowser.READYSTATE_LOADED:
- webStatus.setText(
- OlePlugin.getResourceString("browser.State.Loaded.text"));
- webCommandStop.setEnabled(true);
- break;
- case OleWebBrowser.READYSTATE_INTERACTIVE:
- webStatus.setText(
- OlePlugin.getResourceString("browser.State.Interactive.text"));
- webCommandStop.setEnabled(true);
- break;
- case OleWebBrowser.READYSTATE_COMPLETE:
- webStatus.setText(
- OlePlugin.getResourceString("browser.State.Complete.text"));
- webCommandStop.setEnabled(false);
- break;
- }
- }
- });
-
- // Listen for changes to the active command states
- webControlSite.addEventListener(OleWebBrowser.CommandStateChange, new OleListener() {
- public void handleEvent(OleEvent event) {
- if (event.type != OleWebBrowser.CommandStateChange) return;
- final int commandID =
- (event.arguments[0] != null) ? event.arguments[0].getInt() : 0;
- final boolean commandEnabled =
- (event.arguments[1] != null) ? event.arguments[1].getBoolean() : false;
-
- switch (commandID) {
- case OleWebBrowser.CSC_NAVIGATEBACK:
- webCommandBackward.setEnabled(commandEnabled);
- break;
- case OleWebBrowser.CSC_NAVIGATEFORWARD:
- webCommandForward.setEnabled(commandEnabled);
- break;
- }
- }
- });
-
- // in place activate the ActiveX control
- activated = (webControlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE) == OLE.S_OK);
- if (activated) webBrowser.GoHome();
- }
-}
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java
deleted file mode 100755
index 88c8dc65d4..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.ole.win32;
-
-
-import java.io.*;
-import java.net.*;
-import java.text.*;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.ui.plugin.*;
-import org.osgi.framework.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class OlePlugin extends AbstractUIPlugin {
- //The shared instance.
- private static OlePlugin plugin;
- private static ResourceBundle resourceBundle;
-
- static final int
- biBack = 0,
- biForward = 1,
- biHome = 2,
- biStop = 3,
- biRefresh = 4,
- biSearch = 5;
- static final String[] imageLocations = {
- "icons/backward_nav.gif",
- "icons/forward_nav.gif",
- "icons/home_nav.gif",
- "icons/stop_nav.gif",
- "icons/refresh_nav.gif",
- "icons/search_nav.gif" };
- static Image images[];
- static Font browserFont;
-
- /**
- * Constructs an OLE plugin.
- */
- public OlePlugin() {
- super();
- plugin = this;
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- resourceBundle = Platform.getResourceBundle(getBundle());
- }
-
- /**
- * Clean up
- */
- public void stop(BundleContext context) throws Exception {
- freeResources();
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- */
- public static OlePlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns a string from the resource bundle.
- * We don't want to crash because of a missing String.
- * Returns the key if not found.
- */
- public static String getResourceString(String key) {
- try {
- return resourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Returns a string from the resource bundle and binds it
- * with the given arguments. If the key is not found,
- * return the key.
- */
- public static String getResourceString(String key, Object[] args) {
- try {
- return MessageFormat.format(getResourceString(key), args);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Log an error to the ILog for this plugin
- *
- * @param message the localized error message text
- * @param exception the associated exception, or null
- */
- public static void logError(String message, Throwable exception) {
- plugin.getLog().log(new Status(
- IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, message, exception));
- }
-
- /**
- * Loads the resources.
- */
- public static void initResources() {
- if (images == null) {
- images = new Image[imageLocations.length];
-
- for (int i = 0; i < imageLocations.length; ++i) {
- images[i] = getImageFromPlugin(plugin.getBundle(), imageLocations[i]);
- if (images[i] == null) {
- freeResources();
- logError(getResourceString("error.CouldNotLoadResources"), null);
- throw new IllegalStateException();
- }
- }
- }
- if (browserFont == null) {
- try {
- browserFont = new Font (null, "MS Sans Serif", 8, SWT.NULL);
- } catch (Throwable ex) {
- }
- }
- if (images == null || browserFont == null) {
- freeResources();
- logError(getResourceString("error.CouldNotLoadResources"), null);
- throw new IllegalStateException();
- }
- }
-
- /**
- * Frees the resources
- */
- public static void freeResources() {
- if (images != null) {
- for (int i = 0; i < images.length; ++i) {
- final Image image = images[i];
- if (image != null) image.dispose();
- }
- images = null;
- }
- if (browserFont != null) browserFont.dispose ();
- browserFont = null;
- }
-
- /**
- * Gets an image from a path relative to the plugin install directory.
- *
- * @param pd the plugin descriptor for the plugin with the image
- * @param iconPath the path relative to the install directory
- * @return the image, or null if not found
- */
- private static Image getImageFromPlugin(Bundle bundle, String iconPath) {
- InputStream is = null;
- try {
- URL installUrl = bundle.getEntry("/");
- URL url = new URL(installUrl, iconPath);
- is = url.openConnection().getInputStream();
- ImageData source = new ImageData(is);
- ImageData mask = source.getTransparencyMask();
- Image image = new Image(null, source, mask);
- return image;
- } catch (Throwable ex) {
- return null;
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e) {
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleWebBrowser.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleWebBrowser.java
deleted file mode 100755
index 38d3534e6b..0000000000
--- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OleWebBrowser.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.ole.win32;
-
-
-import org.eclipse.swt.ole.win32.*;
-
-/**
- * Wrapper for an OleAutomation object used to send commands
- * to a Win32 "Shell.Explorer" OLE control.
- *
- * Instances of this class manage the setup, typical use and teardown of
- * a simple web browser.
- */
-class OleWebBrowser {
- /* See the Windows Platform SDK documentation for more information about the
- * OLE control used here and its usage.
- */
- // Generated from typelib filename: shdocvw.dll
-
- // Constants for WebBrowser CommandStateChange
- public static final int CSC_UPDATECOMMANDS = -1;
- public static final int CSC_NAVIGATEFORWARD = 1;
- public static final int CSC_NAVIGATEBACK = 2;
-
- // COnstants for Web Browser ReadyState
- public static final int READYSTATE_UNINITIALIZED = 0;
- public static final int READYSTATE_LOADING = 1;
- public static final int READYSTATE_LOADED = 2;
- public static final int READYSTATE_INTERACTIVE = 3;
- public static final int READYSTATE_COMPLETE = 4;
-
- // Web Browser Control Events
- public static final int BeforeNavigate = 100; // Fired when a new hyperlink is being navigated to.
- public static final int NavigateComplete = 101; // Fired when the document being navigated to becomes visible and enters the navigation stack.
- public static final int StatusTextChange = 102; // Statusbar text changed.
- public static final int ProgressChange = 108; // Fired when download progress is updated.
- public static final int DownloadComplete = 104; // Download of page complete.
- public static final int CommandStateChange = 105; // The enabled state of a command changed
- public static final int DownloadBegin = 106; // Download of a page started.
- public static final int NewWindow = 107; // Fired when a new window should be created.
- public static final int TitleChange = 113; // Document title changed.
- public static final int FrameBeforeNavigate = 200; // Fired when a new hyperlink is being navigated to in a frame.
- public static final int FrameNavigateComplete = 201; // Fired when a new hyperlink is being navigated to in a frame.
- public static final int FrameNewWindow = 204; // Fired when a new window should be created.
- public static final int Quit = 103; // Fired when application is quiting.
- public static final int WindowMove = 109; // Fired when window has been moved.
- public static final int WindowResize = 110; // Fired when window has been sized.
- public static final int WindowActivate = 111; // Fired when window has been activated.
- public static final int PropertyChange = 112; // Fired when the PutProperty method has been called.
-
- // Web Browser properties
- public static final int DISPID_READYSTATE = -525;
-
- private OleAutomation oleAutomation;
-
- /**
- * Creates a Web browser control.
- *
- * Typical use:
- *
- * OleControlSite oleControlSite = new OleControlSite(oleFrame, style, "Shell.Explorer");
- * OleAutomation oleAutomation = new OleAutomation(oleControlSite);
- * OleWebBrowser webBrowser = new OleWebBrowser(oleControlSite, oleAutomation);
- *
- *
- * @param oleAutomation the OleAutomation object for this control.
- * @param oleControlSite the OleControlSite object for this control.
- */
- public OleWebBrowser(OleAutomation oleAutomation) {
- this.oleAutomation = oleAutomation;
- }
-
-
- /**
- * Disposes of the Web browser control.
- */
- public void dispose() {
- if (oleAutomation != null) oleAutomation.dispose();
- oleAutomation = null;
- }
-
- /*
- * Interact with the Control via OLE Automation
- *
- * Note: You can hard code the DISPIDs if you know them beforehand
- * this is of course the fastest way, but you increase coupling
- * to the control.
- */
-
- /**
- * Returns the current web page title.
- *
- * @return the current web page title String
- */
- public String getLocationName() {
- // dispid=210, type=PROPGET, name="LocationName"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"LocationName"});
- int dispIdMember = rgdispid[0];
- Variant pVarResult = oleAutomation.getProperty(dispIdMember);
- if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR) return null;
- return pVarResult.getString();
- }
-
- /**
- * Returns the current URL.
- *
- * @return the current URL String
- */
- public String getLocationURL() {
- // dispid=211, type=PROPGET, name="LocationURL"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"LocationURL"});
- int dispIdMember = rgdispid[0];
-
- Variant pVarResult = oleAutomation.getProperty(dispIdMember);
- if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR) return null;
- return pVarResult.getString();
- }
-
- /**
- * Returns the current state of the control.
- *
- * @return the current state of the control, one of:
- * READYSTATE_UNINITIALIZED;
- * READYSTATE_LOADING;
- * READYSTATE_LOADED;
- * READYSTATE_INTERACTIVE;
- * READYSTATE_COMPLETE.
- */
- public int getReadyState() {
- // dispid=4294966771, type=PROPGET, name="ReadyState"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"ReadyState"});
- int dispIdMember = rgdispid[0];
-
- Variant pVarResult = oleAutomation.getProperty(dispIdMember);
- if (pVarResult == null || pVarResult.getType() != OLE.VT_I4) return -1;
- return pVarResult.getInt();
- }
-
- /**
- * Navigates backwards through previously visited web sites.
- */
- public void GoBack() {
-
- // dispid=100, type=METHOD, name="GoBack"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoBack"});
- int dispIdMember = rgdispid[0];
- oleAutomation.invoke(dispIdMember);
- }
-
- /**
- * Navigates backwards through previously visited web sites.
- */
- public void GoForward() {
-
- // dispid=101, type=METHOD, name="GoForward"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoForward"});
- int dispIdMember = rgdispid[0];
- oleAutomation.invoke(dispIdMember);
- }
-
- /**
- * Navigates to home page.
- */
- public void GoHome() {
- // dispid=102, type=METHOD, name="GoHome"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoHome"});
- int dispIdMember = rgdispid[0];
- oleAutomation.invoke(dispIdMember);
- }
-
- /**
- * Navigates to user-specified Web search gateway.
- */
- public void GoSearch() {
- // dispid=103, type=METHOD, name="GoSearch"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"GoSearch"});
- int dispIdMember = rgdispid[0];
- oleAutomation.invoke(dispIdMember);
- }
-
- /**
- * Navigates to a particular URL.
- */
- public void Navigate(String url) {
- // dispid=104, type=METHOD, name="Navigate"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"Navigate", "URL"});
- int dispIdMember = rgdispid[0];
-
- Variant[] rgvarg = new Variant[1];
- rgvarg[0] = new Variant(url);
- int[] rgdispidNamedArgs = new int[1];
- rgdispidNamedArgs[0] = rgdispid[1]; // identifier of argument
- oleAutomation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
- }
-
- /**
- * Refreshes the currently viewed page.
- *
- * @return the platform-defined result code for the "Refresh" method invocation
- */
- public void Refresh(){
- // dispid= 4294966746, type=METHOD, name="Refresh"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"Refresh"});
- int dispIdMember = rgdispid[0];
- oleAutomation.invokeNoReply(dispIdMember);
- }
-
- /**
- * Aborts loading of the currnet page.
- *
- * @return the platform-defined result code for the "Stop" method invocation
- */
- public void Stop() {
- // dispid=106, type=METHOD, name="Stop"
- int[] rgdispid = oleAutomation.getIDsOfNames(new String[]{"Stop"});
- int dispIdMember = rgdispid[0];
- oleAutomation.invoke(dispIdMember);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/.classpath b/examples/org.eclipse.swt.examples.paint/.classpath
deleted file mode 100755
index 065ac06e19..0000000000
--- a/examples/org.eclipse.swt.examples.paint/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.paint/.cvsignore b/examples/org.eclipse.swt.examples.paint/.cvsignore
deleted file mode 100755
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.examples.paint/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.paint/.project b/examples/org.eclipse.swt.examples.paint/.project
deleted file mode 100644
index 8d39af0053..0000000000
--- a/examples/org.eclipse.swt.examples.paint/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- org.eclipse.swt.examples.paint
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/examples/org.eclipse.swt.examples.paint/about.html b/examples/org.eclipse.swt.examples.paint/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.examples.paint/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.examples.paint/build.properties b/examples/org.eclipse.swt.examples.paint/build.properties
deleted file mode 100755
index c899ccc30a..0000000000
--- a/examples/org.eclipse.swt.examples.paint/build.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = doc-html/,\
- icons/,\
- plugin.properties,\
- plugin.xml,\
- about.html,\
- *.jar
-
-src.includes = about.html
-
-source.paint.jar = src/
diff --git a/examples/org.eclipse.swt.examples.paint/doc-html/hglegal.htm b/examples/org.eclipse.swt.examples.paint/doc-html/hglegal.htm
deleted file mode 100755
index 621115699c..0000000000
--- a/examples/org.eclipse.swt.examples.paint/doc-html/hglegal.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- Legal Notices
-
-
-
-
-Notices
-(c) Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.
-
-
diff --git a/examples/org.eclipse.swt.examples.paint/doc-html/ngibmcpy.gif b/examples/org.eclipse.swt.examples.paint/doc-html/ngibmcpy.gif
deleted file mode 100755
index c786e43e1f..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/doc-html/ngibmcpy.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/doc-html/swt_paint_ex.html b/examples/org.eclipse.swt.examples.paint/doc-html/swt_paint_ex.html
deleted file mode 100755
index 919f78d4b6..0000000000
--- a/examples/org.eclipse.swt.examples.paint/doc-html/swt_paint_ex.html
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
- SWT - Paint Tool
-
-
-
-
SWT example - Paint Tool
-
-
-This example demonstrates the use of SWT graphics operations in the form of a
-rudimentary bitmap painting program. The Paint Tool implementation also
-demonstrates a mechanism for managing timed GUI operations in the background
-that are triggered by user input.
-
-
-Select a tool with which to draw in the drawing area. There are a number of tools
-to choose from on the toolbar. To change the color selection, click on a color in the
-palette below the drawing area; left-click to set the foreground color, right-click to set the
-background color.
-
-
-
Running the example
-
-
-From Eclipse's Window menu select Show View > Other.
-In the Show View dialog, expand SWT Examples and select
-the view named Paint. A view containing the paint program will appear.
-
-
-This example can also be run using the Example Launcher.
-Select the Paint item from the Workbench Views category and click Run.
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.paint/icons/fill_none.gif b/examples/org.eclipse.swt.examples.paint/icons/fill_none.gif
deleted file mode 100755
index d26dd584e7..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/fill_none.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/fill_outline.gif b/examples/org.eclipse.swt.examples.paint/icons/fill_outline.gif
deleted file mode 100755
index c6ccfee10e..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/fill_outline.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/fill_solid.gif b/examples/org.eclipse.swt.examples.paint/icons/fill_solid.gif
deleted file mode 100755
index cb34e64a30..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/fill_solid.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/linestyle_dash.gif b/examples/org.eclipse.swt.examples.paint/icons/linestyle_dash.gif
deleted file mode 100644
index fb57bb38b7..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/linestyle_dash.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/linestyle_dashdot.gif b/examples/org.eclipse.swt.examples.paint/icons/linestyle_dashdot.gif
deleted file mode 100644
index 322968c30b..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/linestyle_dashdot.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/linestyle_dot.gif b/examples/org.eclipse.swt.examples.paint/icons/linestyle_dot.gif
deleted file mode 100644
index 4937ccb06d..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/linestyle_dot.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/linestyle_solid.gif b/examples/org.eclipse.swt.examples.paint/icons/linestyle_solid.gif
deleted file mode 100644
index 70a57ce2c4..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/linestyle_solid.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/options_font.gif b/examples/org.eclipse.swt.examples.paint/icons/options_font.gif
deleted file mode 100755
index 965fe08560..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/options_font.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/paint_example.gif b/examples/org.eclipse.swt.examples.paint/icons/paint_example.gif
deleted file mode 100755
index c48d9a9567..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/paint_example.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_airbrush.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_airbrush.gif
deleted file mode 100755
index a310edddb2..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_airbrush.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_ellipse.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_ellipse.gif
deleted file mode 100755
index dc2142f8e2..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_ellipse.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_line.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_line.gif
deleted file mode 100755
index 2ff819f129..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_line.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_pencil.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_pencil.gif
deleted file mode 100755
index f16a234c13..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_pencil.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_polyline.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_polyline.gif
deleted file mode 100755
index aa384e9b30..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_polyline.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_rectangle.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_rectangle.gif
deleted file mode 100755
index d26dd584e7..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_rectangle.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_roundedrectangle.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_roundedrectangle.gif
deleted file mode 100755
index bf845d7602..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_roundedrectangle.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/icons/tool_text.gif b/examples/org.eclipse.swt.examples.paint/icons/tool_text.gif
deleted file mode 100755
index 0d7457ffa3..0000000000
Binary files a/examples/org.eclipse.swt.examples.paint/icons/tool_text.gif and /dev/null differ
diff --git a/examples/org.eclipse.swt.examples.paint/plugin.properties b/examples/org.eclipse.swt.examples.paint/plugin.properties
deleted file mode 100755
index 4e0a80b60f..0000000000
--- a/examples/org.eclipse.swt.examples.paint/plugin.properties
+++ /dev/null
@@ -1,134 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-providerName = Eclipse.org
-plugin.SWTPaintExample.name = SWT Paint Example Plugin
-category.SWTExamples.name = SWT Examples
-view.PaintExample.name = Paint
-
-launchcategory.SWTViewExamples.name = Workbench Views
-launchcategory.SWTViewExamples.description = \
- A collection of Standard Widget Toolkit examples that run as Views inside the Workbench. \
- These examples will create a new View in the current Perspective.
-
-launchitem.PaintExample.name = Paint
-launchitem.PaintExample.description = \
- This example demonstrates the use of SWT graphics operations in the form of a \
- rudimentary bitmap painting program. The Airbrush Tool implementation also \
- demonstrates a mechanism for managing timed GUI operations in the background \
- that are triggered by user input.\n\n\
- Select a tool with which to draw in the drawing area. There are a number of tools \
- to choose from on the toolbar. To change the color selection, click on a color in the \
- palette below the drawing area: left-click for the foreground color, right-click for the \
- background color.\n\n\
- Uses SWT's GC and FontDialog, and JFace's InputDialog and action set support.
-
-menu.Tools.label = Tools
-menu.Options.label = Options
-
-tool.Pencil.label = Pencil
-tool.Pencil.tooltip = Pencil tool
-tool.Pencil.image = icons/tool_pencil.gif
-tool.Pencil.description = Selects the Pencil tool.
-
-tool.Airbrush.label = Airbrush
-tool.Airbrush.tooltip = Airbrush tool
-tool.Airbrush.image = icons/tool_airbrush.gif
-tool.Airbrush.description = Selects the Airbrush tool.
-
-tool.Line.label = Line
-tool.Line.tooltip = Line tool
-tool.Line.image = icons/tool_line.gif
-tool.Line.description = Selects the Line tool.
-
-tool.PolyLine.label = Polygon
-tool.PolyLine.tooltip = Polygon tool
-tool.PolyLine.image = icons/tool_polyline.gif
-tool.PolyLine.description = Selects the PolyLine tool.
-
-tool.Rectangle.label = Rectangle
-tool.Rectangle.tooltip = Rectangle tool
-tool.Rectangle.image = icons/tool_rectangle.gif
-tool.Rectangle.description = Selects the Rectangle tool.
-
-tool.Ellipse.label = Ellipse
-tool.Ellipse.tooltip = Ellipse tool
-tool.Ellipse.image = icons/tool_ellipse.gif
-tool.Ellipse.description = Selects the Ellipse tool.
-
-tool.RoundedRectangle.label = Rounded Rectangle
-tool.RoundedRectangle.tooltip = Rounded Rectangle
-tool.RoundedRectangle.image = icons/tool_roundedrectangle.gif
-tool.RoundedRectangle.description = Selects the Rounded Rectangle tool.
-
-tool.Text.label = Text
-tool.Text.tooltip = Text tool
-tool.Text.image = icons/tool_text.gif
-tool.Text.description = Selects the Text tool.
-tool.Text.settings.defaulttext = Hello!
-tool.Text.dialog.title = Text Tool Settings
-tool.Text.dialog.message = Please enter the new text string to be painted.
-
-tool.Null.label =
-
-fill.None.label = No Fill
-fill.None.tooltip = No fill mode
-fill.None.image = icons/fill_none.gif
-fill.None.description = Selects No Fill mode.
-
-fill.Outline.label = Outline Fill
-fill.Outline.tooltip = Outline fill mode
-fill.Outline.image = icons/fill_outline.gif
-fill.Outline.description = Selects Outline Fill mode.
-
-fill.Solid.label = Solid Fill
-fill.Solid.tooltip = Solid fill mode
-fill.Solid.image = icons/fill_solid.gif
-fill.Solid.description = Selects Solid Fill mode.
-
-linestyle.Solid.label = Solid Line
-linestyle.Solid.tooltip = Solid line style
-linestyle.Solid.image = icons/linestyle_solid.gif
-linestyle.Solid.description = Select Solid Line style.
-
-linestyle.Dot.label = Dotted Line
-linestyle.Dot.tooltip = Dotted line style
-linestyle.Dot.image = icons/linestyle_dot.gif
-linestyle.Dot.description = Select Dotted Line style.
-
-linestyle.Dash.label = Dashed Line
-linestyle.Dash.tooltip = Dashed line style
-linestyle.Dash.image = icons/linestyle_dash.gif
-linestyle.Dash.description = Select Dashed Line style.
-
-linestyle.DashDot.label = Dash-Dot Line
-linestyle.DashDot.tooltip = Dash-Dot line style
-linestyle.DashDot.image = icons/linestyle_dashdot.gif
-linestyle.DashDot.description = Select Dash-Dot Line style.
-
-options.Font.label = Text Tool Font
-options.Font.tooltip = Select Text Tool font
-options.Font.image = icons/options_font.gif
-options.Font.description = Selects Text Tool font.
-options.Font.dialog.title = Text Tool Font
-
-settings.AirbrushRadius.text = Airbrush Radius
-settings.AirbrushIntensity.text = Airbrush Intensity
-
-session.Null.message = Select a tool...
-session.ContinuousPaint.message = Click and drag to draw...
-session.DragInteractivePaint.message = Click and drag to preview, release to draw, right-click to cancel...
-session.SegmentedInteractivePaint.message.anchorMode = Click to set anchor...
-session.SegmentedInteractivePaint.message.interactiveMode = Click to draw, double-click to close figure, right-click to cancel...
-session.Text.message = Click to draw text, right-click to edit text...
-
-status.Coord.format = ({0}, {1})
-status.CoordRange.format = ({0}, {1}) - ({2}, {3})
-status.Bar.format = {0} : {1} {2}
diff --git a/examples/org.eclipse.swt.examples.paint/plugin.xml b/examples/org.eclipse.swt.examples.paint/plugin.xml
deleted file mode 100755
index 410bcf5886..0000000000
--- a/examples/org.eclipse.swt.examples.paint/plugin.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.examples.paint/src/import.properties b/examples/org.eclipse.swt.examples.paint/src/import.properties
deleted file mode 100644
index 58344f0d3e..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/import.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# Persist project settings for later import
-natures = org.eclipse.jdt.core.javanature; org.eclipse.pde.PluginNature
-builders = org.eclipse.jdt.core.javabuilder; org.eclipse.pde.ManifestBuilder; org.eclipse.pde.SchemaBuilder
-var.ECLIPSE_PLUGINS = <>
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/AirbrushTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/AirbrushTool.java
deleted file mode 100755
index 5730b4dc13..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/AirbrushTool.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import java.util.Random;
-import org.eclipse.swt.graphics.*;
-
-/**
- * An airbrush tool.
- */
-public class AirbrushTool extends ContinuousPaintSession implements PaintTool {
- private ToolSettings settings;
- private Random random;
- private int cachedRadiusSquared;
- private int cachedNumPoints;
-
- /**
- * Constructs a Tool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public AirbrushTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- random = new Random();
- setRetriggerTimer(10);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- // compute things we need to know for drawing
- settings = toolSettings;
- cachedRadiusSquared = settings.airbrushRadius * settings.airbrushRadius;
- cachedNumPoints = 314 * settings.airbrushIntensity * cachedRadiusSquared / 250000;
- if (cachedNumPoints == 0 && settings.airbrushIntensity != 0)
- cachedNumPoints = 1;
- }
-
- /**
- * Returns the name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.Airbrush.label");
- }
-
- /*
- * Template method for drawing
- */
- protected void render(Point point) {
- // Draws a bunch (cachedNumPoints) of random pixels within a specified circle (cachedRadiusSquared).
- ContainerFigure cfig = new ContainerFigure();
-
- for (int i = 0; i < cachedNumPoints; ++i) {
- int randX, randY;
- do {
- randX = (int) ((random.nextDouble() - 0.5) * settings.airbrushRadius * 2.0);
- randY = (int) ((random.nextDouble() - 0.5) * settings.airbrushRadius * 2.0);
- } while (randX * randX + randY * randY > cachedRadiusSquared);
- cfig.add(new PointFigure(settings.commonForegroundColor, point.x + randX, point.y + randY));
- }
- getPaintSurface().drawFigure(cfig);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/BasicPaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/BasicPaintSession.java
deleted file mode 100755
index 9732189930..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/BasicPaintSession.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-public abstract class BasicPaintSession implements PaintSession {
- /**
- * The paint surface
- */
- private PaintSurface paintSurface;
-
- /**
- * Constructs a PaintSession.
- *
- * @param paintSurface the drawing surface to use
- */
- protected BasicPaintSession(PaintSurface paintSurface) {
- this.paintSurface = paintSurface;
- }
-
- /**
- * Returns the paint surface associated with this paint session.
- *
- * @return the associated PaintSurface
- */
- public PaintSurface getPaintSurface() {
- return paintSurface;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ContainerFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ContainerFigure.java
deleted file mode 100755
index 135067cf4b..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ContainerFigure.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * Container for Figure objects with stacking preview mechanism.
- */
-public class ContainerFigure extends Figure {
- private static final int INITIAL_ARRAY_SIZE = 16;
-
- Figure[] objectStack = null;
- int nextIndex = 0;
-
- /**
- * Constructs an empty Container
- */
- public ContainerFigure() {
- }
- /**
- * Adds an object to the container for later drawing.
- *
- * @param object the object to add to the drawing list
- */
- public void add(Figure object) {
- if (objectStack == null) {
- objectStack = new Figure[INITIAL_ARRAY_SIZE];
- } else if (objectStack.length <= nextIndex) {
- Figure[] newObjectStack = new Figure[objectStack.length * 2];
- System.arraycopy(objectStack, 0, newObjectStack, 0, objectStack.length);
- objectStack = newObjectStack;
- }
- objectStack[nextIndex] = object;
- ++nextIndex;
- }
- /**
- * Determines if the container is empty.
- * @return true if the container is empty
- */
- public boolean isEmpty() {
- return nextIndex == 0;
- }
- /**
- * Adds an object to the container and draws its preview then updates the supplied preview state.
- *
- * @param object the object to add to the drawing list
- * @param gc the GC to draw on
- * @param offset the offset to add to virtual coordinates to get display coordinates
- * @param rememberedState the state returned by a previous drawPreview() or addAndPreview()
- * using this Container, may be null if there was no such previous call
- * @return object state that must be passed to erasePreview() later to erase this object
- */
-// public Object addAndPreview(Figure object, GC gc, Point offset, Object rememberedState) {
-// Object[] stateStack = (Object[]) rememberedState;
-// if (stateStack == null) {
-// stateStack = new Object[INITIAL_ARRAY_SIZE];
-// } else if (stateStack.length <= nextIndex) {
-// Object[] newStateStack = new Object[stateStack.length * 2];
-// System.arraycopy(stateStack, 0, newStateStack, 0, stateStack.length);
-// stateStack = newStateStack;
-// }
-// add(object);
-// stateStack[nextIndex - 1] = object.drawPreview(gc, offset);
-// return stateStack;
-// }
- /**
- * Clears the container.
- *
- * Note that erasePreview() cannot be called after this point to erase any previous
- * drawPreview()'s.
- *
- */
- public void clear() {
- while (--nextIndex > 0) objectStack[nextIndex] = null;
- nextIndex = 0;
- }
- public void draw(FigureDrawContext fdc) {
- for (int i = 0; i < nextIndex; ++i) objectStack[i].draw(fdc);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- for (int i = 0; i < nextIndex; ++i) objectStack[i].addDamagedRegion(fdc, region);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ContinuousPaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ContinuousPaintSession.java
deleted file mode 100755
index 49a724ca02..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ContinuousPaintSession.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * The superclass for paint tools that draw continuously along the path
- * traced by the mouse's movement while the button is depressed
- */
-public abstract class ContinuousPaintSession extends BasicPaintSession {
- /**
- * True if a click-drag is in progress.
- */
- private boolean dragInProgress = false;
-
- /**
- * A cached Point array for drawing.
- */
- private Point[] points = new Point[] { new Point(-1, -1), new Point(-1, -1) };
-
- /**
- * The time to wait between retriggers in milliseconds.
- */
- private int retriggerInterval = 0;
-
- /**
- * The currently valid RetriggerHandler
- */
- protected Runnable retriggerHandler = null;
-
- /**
- * Constructs a ContinuousPaintSession.
- *
- * @param paintSurface the drawing surface to use
- */
- protected ContinuousPaintSession(PaintSurface paintSurface) {
- super(paintSurface);
- }
-
- /**
- * Sets the retrigger timer.
- *
- * After the timer elapses, if the mouse is still hovering over the same point with the
- * drag button pressed, a new render order is issued and the timer is restarted.
- *
- * @param interval the time in milliseconds to wait between retriggers, 0 to disable
- */
- public void setRetriggerTimer(int interval) {
- retriggerInterval = interval;
- }
-
- /**
- * Activates the tool.
- */
- public void beginSession() {
- getPaintSurface().
- setStatusMessage(PaintPlugin.getResourceString("session.ContinuousPaint.message"));
- dragInProgress = false;
- }
-
- /**
- * Deactivates the tool.
- */
- public void endSession() {
- abortRetrigger();
- }
-
- /**
- * Aborts the current operation.
- */
- public void resetSession() {
- abortRetrigger();
- }
-
- /**
- * Handles a mouseDown event.
- *
- * @param event the mouse event detail information
- */
- public final void mouseDown(MouseEvent event) {
- if (event.button != 1) return;
- if (dragInProgress) return; // spurious event
- dragInProgress = true;
-
- points[0].x = event.x;
- points[0].y = event.y;
- render(points[0]);
- prepareRetrigger();
- }
-
- /**
- * Handles a mouseDoubleClick event.
- *
- * @param event the mouse event detail information
- */
- public final void mouseDoubleClick(MouseEvent event) {
- }
-
- /**
- * Handles a mouseUp event.
- *
- * @param event the mouse event detail information
- */
- public final void mouseUp(MouseEvent event) {
- if (event.button != 1) return;
- if (! dragInProgress) return; // spurious event
- abortRetrigger();
- mouseSegmentFinished(event);
- dragInProgress = false;
- }
-
- /**
- * Handles a mouseMove event.
- *
- * @param event the mouse event detail information
- */
- public final void mouseMove(MouseEvent event) {
- final PaintSurface ps = getPaintSurface();
- ps.setStatusCoord(ps.getCurrentPosition());
- if (! dragInProgress) return;
- mouseSegmentFinished(event);
- prepareRetrigger();
- }
-
- /**
- * Handle a rendering segment
- *
- * @param event the mouse event detail information
- */
- private final void mouseSegmentFinished(MouseEvent event) {
- if (points[0].x == -1) return; // spurious event
- if (points[0].x != event.x || points[0].y != event.y) {
- // draw new segment
- points[1].x = event.x;
- points[1].y = event.y;
- renderContinuousSegment();
- }
- }
-
- /**
- * Draws a continuous segment from points[0] to points[1].
- * Assumes points[0] has been drawn already.
- *
- * @post points[0] will refer to the same point as points[1]
- */
- protected void renderContinuousSegment() {
- /* A lazy but effective line drawing algorithm */
- final int dX = points[1].x - points[0].x;
- final int dY = points[1].y - points[0].y;
- int absdX = Math.abs(dX);
- int absdY = Math.abs(dY);
-
- if ((dX == 0) && (dY == 0)) return;
-
- if (absdY > absdX) {
- final int incfpX = (dX << 16) / absdY;
- final int incY = (dY > 0) ? 1 : -1;
- int fpX = points[0].x << 16; // X in fixedpoint format
-
- while (--absdY >= 0) {
- points[0].y += incY;
- points[0].x = (fpX += incfpX) >> 16;
- render(points[0]);
- }
- if (points[0].x == points[1].x) return;
- points[0].x = points[1].x;
- } else {
- final int incfpY = (dY << 16) / absdX;
- final int incX = (dX > 0) ? 1 : -1;
- int fpY = points[0].y << 16; // Y in fixedpoint format
-
- while (--absdX >= 0) {
- points[0].x += incX;
- points[0].y = (fpY += incfpY) >> 16;
- render(points[0]);
- }
- if (points[0].y == points[1].y) return;
- points[0].y = points[1].y;
- }
- render(points[0]);
- }
-
- /**
- * Prepare the retrigger timer
- */
- private final void prepareRetrigger() {
- if (retriggerInterval > 0) {
- /*
- * timerExec() provides a lightweight mechanism for running code at intervals from within
- * the event loop when timing accuracy is not important.
- *
- * Since it is not possible to cancel a timerExec(), we remember the Runnable that is
- * active in order to distinguish the valid one from the stale ones. In practice,
- * if the interval is 1/100th of a second, then creating a few hundred new RetriggerHandlers
- * each second will not cause a significant performance hit.
- */
- Display display = getPaintSurface().getDisplay();
- retriggerHandler = new Runnable() {
- public void run() {
- if (retriggerHandler == this) {
- render(points[0]);
- prepareRetrigger();
- }
- }
- };
- display.timerExec(retriggerInterval, retriggerHandler);
- }
- }
-
- /**
- * Aborts the retrigger timer
- */
- private final void abortRetrigger() {
- retriggerHandler = null;
- }
-
- /**
- * Template method: Renders a point.
- * @param point, the point to render
- */
- protected abstract void render(Point point);
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragPaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragPaintSession.java
deleted file mode 100755
index 539c3b567c..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/DragPaintSession.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.*;
-
-/**
- * The superclass for paint tools that use click-drag-release motions to
- * draw objects.
- */
-public abstract class DragPaintSession extends BasicPaintSession {
- /**
- * True if a click-drag is in progress
- */
- private boolean dragInProgress = false;
-
- /**
- * The position of the first click in a click-drag
- */
- private Point anchorPosition = new Point(-1, -1);
-
- /**
- * A temporary point
- */
- private Point tempPosition = new Point(-1, -1);
-
- /**
- * Constructs a PaintSession.
- *
- * @param getPaintSurface() the drawing surface to use
- */
- protected DragPaintSession(PaintSurface paintSurface) {
- super(paintSurface);
- }
-
- /**
- * Activates the tool.
- */
- public void beginSession() {
- getPaintSurface().
- setStatusMessage(PaintPlugin.getResourceString("session.DragInteractivePaint.message"));
- anchorPosition.x = -1;
- dragInProgress = false;
- }
-
- /**
- * Deactivates the tool.
- */
- public void endSession() {
- }
-
- /**
- * Resets the tool.
- * Aborts any operation in progress.
- */
- public void resetSession() {
- getPaintSurface().clearRubberbandSelection();
- anchorPosition.x = -1;
- dragInProgress = false;
- }
-
- /**
- * Handles a mouseDown event.
- *
- * @param event the mouse event detail information
- */
- public void mouseDown(MouseEvent event) {
- if (event.button != 1) return;
- if (dragInProgress) return; // spurious event
- dragInProgress = true;
-
- anchorPosition.x = event.x;
- anchorPosition.y = event.y;
- }
-
- /**
- * Handles a mouseDoubleClick event.
- *
- * @param event the mouse event detail information
- */
- public void mouseDoubleClick(MouseEvent event) {
- }
-
- /**
- * Handles a mouseUp event.
- *
- * @param event the mouse event detail information
- */
- public void mouseUp(MouseEvent event) {
- if (event.button != 1) {
- resetSession(); // abort if right or middle mouse button pressed
- return;
- }
- if (! dragInProgress) return; // spurious event
- dragInProgress = false;
- if (anchorPosition.x == -1) return; // spurious event
-
- getPaintSurface().commitRubberbandSelection();
- }
-
- /**
- * Handles a mouseMove event.
- *
- * @param event the mouse event detail information
- */
- public void mouseMove(MouseEvent event) {
- final PaintSurface ps = getPaintSurface();
- if (! dragInProgress) {
- ps.setStatusCoord(ps.getCurrentPosition());
- return;
- }
- ps.setStatusCoordRange(anchorPosition, ps.getCurrentPosition());
- ps.clearRubberbandSelection();
- tempPosition.x = event.x;
- tempPosition.y = event.y;
- ps.addRubberbandSelection(createFigure(anchorPosition, tempPosition));
- }
-
- /**
- * Template Method: Creates a Figure for drawing rubberband entities and the final product
- *
- * @param anchor the anchor point
- * @param cursor the point marking the current pointer location
- */
- protected abstract Figure createFigure(Point anchor, Point cursor);
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/EllipseFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/EllipseFigure.java
deleted file mode 100755
index e6a5907b8d..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/EllipseFigure.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Ellipse object
- */
-public class EllipseFigure extends Figure {
- private Color foregroundColor, backgroundColor;
- private int lineStyle, x1, y1, x2, y2;
- /**
- * Constructs an Ellipse
- * These objects are defined by any two diametrically opposing corners of a box
- * bounding the ellipse.
- *
- * @param color the color for this object
- * @param lineStyle the line style for this object
- * @param x1 the virtual X coordinate of the first corner
- * @param y1 the virtual Y coordinate of the first corner
- * @param x2 the virtual X coordinate of the second corner
- * @param y2 the virtual Y coordinate of the second corner
- */
- public EllipseFigure(Color foregroundColor, Color backgroundColor, int lineStyle, int x1, int y1, int x2, int y2) {
- this.foregroundColor = foregroundColor;
- this.backgroundColor = backgroundColor;
- this.lineStyle = lineStyle;
- this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- }
- public void draw(FigureDrawContext fdc) {
- Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
- fdc.gc.setForeground(foregroundColor);
- fdc.gc.setBackground(backgroundColor);
- fdc.gc.setLineStyle(lineStyle);
- fdc.gc.drawOval(r.x, r.y, r.width - 1, r.height - 1);
- fdc.gc.setLineStyle(SWT.LINE_SOLID);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/EllipseTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/EllipseTool.java
deleted file mode 100755
index 785879cdeb..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/EllipseTool.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * A drawing tool.
- */
-public class EllipseTool extends DragPaintSession implements PaintTool {
- private ToolSettings settings;
-
- /**
- * Constructs a EllipseTool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public EllipseTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.Ellipse.label");
- }
-
- /*
- * Template methods for drawing
- */
- protected Figure createFigure(Point a, Point b) {
- ContainerFigure container = new ContainerFigure();
- if (settings.commonFillType != ToolSettings.ftNone)
- container.add(new SolidEllipseFigure(settings.commonBackgroundColor, a.x, a.y, b.x, b.y));
- if (settings.commonFillType != ToolSettings.ftSolid)
- container.add(new EllipseFigure(settings.commonForegroundColor, settings.commonBackgroundColor, settings.commonLineStyle,
- a.x, a.y, b.x, b.y));
- return container;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Figure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Figure.java
deleted file mode 100755
index 6eb305b77f..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/Figure.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * Superinterface for all drawing objects.
- * All drawing objects know how to render themselved to the screen and can draw a
- * temporary version of themselves for previewing the general appearance of the
- * object onscreen before it gets committed.
- */
-public abstract class Figure {
- /**
- * Draws this object.
- *
- * @param fdc a parameter block specifying drawing-related information
- */
- public abstract void draw(FigureDrawContext fdc);
-
- /**
- * Computes the damaged screen region caused by drawing this object (imprecise), then
- * appends it to the supplied region.
- *
- * @param fdc a parameter block specifying drawing-related information
- * @param region a region to which additional damage areas will be added
- */
- public abstract void addDamagedRegion(FigureDrawContext fdc, Region region);
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FigureDrawContext.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FigureDrawContext.java
deleted file mode 100644
index b020ff4902..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/FigureDrawContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-public class FigureDrawContext {
- /*
- *
- * The GC must be set up as follows
- * (it will be returned to this state upon completion of drawing operations)
- *
- *
setXORMode(false)
- *
- *
- */
- public GC gc = null;
- public int xOffset = 0, yOffset = 0; // substract to get GC coords
- public int xScale = 1, yScale = 1;
-
- public Rectangle toClientRectangle(int x1, int y1, int x2, int y2) {
- return new Rectangle(
- Math.min(x1, x2) * xScale - xOffset,
- Math.min(y1, y2) * yScale - yOffset,
- (Math.abs(x2 - x1) + 1) * xScale,
- (Math.abs(y2 - y1) + 1) * yScale);
- }
- public Point toClientPoint(int x, int y) {
- return new Point(x * xScale - xOffset, y * yScale - yOffset);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/LineFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/LineFigure.java
deleted file mode 100755
index ab07a8a676..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/LineFigure.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Line object
- */
-public class LineFigure extends Figure {
- private Color foregroundColor, backgroundColor;
- private int lineStyle, x1, y1, x2, y2;
- /**
- * Constructs a Line
- * These objects are defined by their two end-points.
- *
- * @param color the color for this object
- * @param lineStyle the line style for this object
- * @param x1 the virtual X coordinate of the first end-point
- * @param y1 the virtual Y coordinate of the first end-point
- * @param x2 the virtual X coordinate of the second end-point
- * @param y2 the virtual Y coordinate of the second end-point
- */
- public LineFigure(Color foregroundColor, Color backgroundColor, int lineStyle, int x1, int y1, int x2, int y2) {
- this.foregroundColor = foregroundColor;
- this.backgroundColor = backgroundColor;
- this.lineStyle = lineStyle;
- this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- }
- public void draw(FigureDrawContext fdc) {
- Point p1 = fdc.toClientPoint(x1, y1);
- Point p2 = fdc.toClientPoint(x2, y2);
- fdc.gc.setForeground(foregroundColor);
- fdc.gc.setBackground(backgroundColor);
- fdc.gc.setLineStyle(lineStyle);
- fdc.gc.drawLine(p1.x, p1.y, p2.x, p2.y);
- fdc.gc.setLineStyle(SWT.LINE_SOLID);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/LineTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/LineTool.java
deleted file mode 100755
index 32d0399d51..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/LineTool.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * A line drawing tool
- */
-public class LineTool extends DragPaintSession implements PaintTool {
- private ToolSettings settings;
-
- /**
- * Constructs a LineTool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public LineTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.Line.label");
- }
-
- /*
- * Template methods for drawing
- */
- protected Figure createFigure(Point a, Point b) {
- return new LineFigure(settings.commonForegroundColor, settings.commonBackgroundColor, settings.commonLineStyle,
- a.x, a.y, b.x, b.y);
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintPlugin.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintPlugin.java
deleted file mode 100755
index 5dc3ec57b3..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintPlugin.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.ui.plugin.*;
-import org.osgi.framework.BundleContext;
-
-import java.text.*;
-import java.util.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class PaintPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static PaintPlugin plugin;
- private static ResourceBundle resourceBundle;
-
- /**
- * Constructs the Paint plugin.
- */
- public PaintPlugin() {
- super();
- plugin = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static PaintPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Log an error to the ILog for this plugin
- *
- * @param message the localized error message text
- * @param exception the associated exception, or null
- */
- public static void logError(String message, Throwable exception) {
- plugin.getLog().log(
- new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, message, exception));
- }
-
- /**
- * Returns a string from the resource bundle.
- * We don't want to crash because of a missing String.
- * Returns the key if not found.
- */
- public static String getResourceString(String key) {
- try {
- return resourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- /**
- * Returns a string from the resource bundle and binds it
- * with the given arguments. If the key is not found,
- * return the key.
- */
- public static String getResourceString(String key, Object[] args) {
- try {
- return MessageFormat.format(getResourceString(key), args);
- } catch (MissingResourceException e) {
- return key;
- } catch (NullPointerException e) {
- return "!" + key + "!";
- }
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- resourceBundle = Platform.getResourceBundle(getBundle());
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSession.java
deleted file mode 100755
index 1d6eda21bf..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSession.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.events.*;
-
-/**
- * Manages an interactive paint session.
- * Note that the coordinates received via the listener interfaces are virtualized to zero-origin
- * relative to the painting surface.
- */
-public interface PaintSession extends MouseListener, MouseMoveListener {
- /**
- * Returns the paint surface associated with this paint session
- *
- * @return the associated PaintSurface
- */
- public PaintSurface getPaintSurface();
-
- /**
- * Activates the session.
- *
- * Note: When overriding this method, call super.beginSession() at method start.
- */
- public abstract void beginSession();
-
- /**
- * Deactivates the session.
- *
- * Note: When overriding this method, call super.endSession() at method exit.
- */
- public abstract void endSession();
-
- /**
- * Resets the session.
- * Aborts any operation in progress.
- *
- * Note: When overriding this method, call super.resetSession() at method exit.
- */
- public abstract void resetSession();
-
-
- /**
- * Returns the name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName();
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java
deleted file mode 100755
index a58af26f9f..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintSurface.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-/**
- * Manages a simple drawing surface.
- */
-public class PaintSurface {
- private Point currentPosition = new Point(0, 0);
- private Canvas paintCanvas;
-
- private PaintSession paintSession;
- private Image image;
- private Image paintImage; // buffer for refresh blits
- private int imageWidth, imageHeight;
- private int visibleWidth, visibleHeight;
-
- private FigureDrawContext displayFDC = new FigureDrawContext();
- private FigureDrawContext imageFDC = new FigureDrawContext();
- private FigureDrawContext paintFDC = new FigureDrawContext();
-
- /* Rubberband */
- private ContainerFigure rubberband = new ContainerFigure();
- // the active rubberband selection
- private int rubberbandHiddenNestingCount = 0;
- // always >= 0, if > 0 rubberband has been hidden
-
- /* Status */
- private Text statusText;
- private String statusActionInfo, statusMessageInfo, statusCoordInfo;
-
- /**
- * Constructs a PaintSurface.
- *
- * paintCanvas must have SWT.NO_REDRAW_RESIZE and SWT.NO_BACKGROUND styles,
- * and may have SWT.V_SCROLL and/or SWT.H_SCROLL.
- *
- * @param paintCanvas the Canvas object in which to render
- * @param paintStatus the PaintStatus object to use for providing user feedback
- * @param fillColor the color to fill the canvas with initially
- */
- public PaintSurface(Canvas paintCanvas, Text statusText, Color fillColor) {
- this.paintCanvas = paintCanvas;
- this.statusText = statusText;
- clearStatus();
-
- /* Set up the drawing surface */
- Rectangle displayRect = paintCanvas.getDisplay().getClientArea();
- imageWidth = displayRect.width;
- imageHeight = displayRect.height;
- image = new Image(paintCanvas.getDisplay(), imageWidth, imageHeight);
-
- imageFDC.gc = new GC(image);
- imageFDC.gc.setBackground(fillColor);
- imageFDC.gc.fillRectangle(0, 0, imageWidth, imageHeight);
- displayFDC.gc = new GC(paintCanvas);
-
- /* Initialize the session */
- setPaintSession(null);
-
- /* Add our listeners */
- paintCanvas.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- displayFDC.gc.dispose();
- }
- });
- paintCanvas.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent event) {
- processMouseEventCoordinates(event);
- if (paintSession != null) paintSession.mouseDown(event);
- }
- public void mouseUp(MouseEvent event) {
- processMouseEventCoordinates(event);
- if (paintSession != null) paintSession.mouseUp(event);
- }
- public void mouseDoubleClick(MouseEvent event) {
- processMouseEventCoordinates(event);
- if (paintSession != null) paintSession.mouseDoubleClick(event);
- }
- });
- paintCanvas.addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent event) {
- processMouseEventCoordinates(event);
- if (paintSession != null) paintSession.mouseMove(event);
- }
- });
- paintCanvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent event) {
- if (rubberband.isEmpty()) {
- // Nothing to merge, so we just refresh
- event.gc.drawImage(image,
- displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
- event.x, event.y, event.width, event.height);
- } else {
- /*
- * Avoid flicker when merging overlayed objects by constructing the image on
- * a backbuffer first, then blitting it to the screen.
- */
- // Check that the backbuffer is large enough
- if (paintImage != null) {
- Rectangle rect = paintImage.getBounds();
- if ((event.width + event.x > rect.width) ||
- (event.height + event.y > rect.height)) {
- paintFDC.gc.dispose();
- paintImage.dispose();
- paintImage = null;
- }
- }
- if (paintImage == null) {
- Display display = getDisplay();
- Rectangle rect = display.getClientArea();
- paintImage = new Image(display,
- Math.max(rect.width, event.width + event.x),
- Math.max(rect.height, event.height + event.y));
- paintFDC.gc = new GC(paintImage);
- }
- // Setup clipping and the FDC
- Region clipRegion = new Region();
- event.gc.getClipping(clipRegion);
- paintFDC.gc.setClipping(clipRegion);
- clipRegion.dispose();
-
- paintFDC.xOffset = displayFDC.xOffset;
- paintFDC.yOffset = displayFDC.yOffset;
- paintFDC.xScale = displayFDC.xScale;
- paintFDC.yScale = displayFDC.yScale;
-
- // Merge the overlayed objects into the image, then blit
- paintFDC.gc.drawImage(image,
- displayFDC.xOffset + event.x, displayFDC.yOffset + event.y, event.width, event.height,
- event.x, event.y, event.width, event.height);
- rubberband.draw(paintFDC);
- event.gc.drawImage(paintImage,
- event.x, event.y, event.width, event.height,
- event.x, event.y, event.width, event.height);
- }
- }
- });
- paintCanvas.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent event) {
- handleResize();
- }
- });
-
- /* Set up the paint canvas scroll bars */
- ScrollBar horizontal = paintCanvas.getHorizontalBar();
- horizontal.setVisible(true);
- horizontal.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- scrollHorizontally((ScrollBar)event.widget);
- }
- });
- ScrollBar vertical = paintCanvas.getVerticalBar();
- vertical.setVisible(true);
- vertical.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- scrollVertically((ScrollBar)event.widget);
- }
- });
- handleResize();
- }
-
- /**
- * Disposes of the PaintSurface's resources.
- */
- public void dispose() {
- imageFDC.gc.dispose();
- image.dispose();
- if (paintImage != null) {
- paintImage.dispose();
- paintFDC.gc.dispose();
- }
-
- currentPosition = null;
- paintCanvas = null;
- paintSession = null;
- image = null;
- paintImage = null;
- displayFDC = null;
- imageFDC = null;
- paintFDC = null;
- rubberband = null;
- statusText = null;
- statusActionInfo = null;
- statusMessageInfo = null;
- statusCoordInfo = null;
- }
-
- /**
- * Called when we must grab focus.
- */
- public void setFocus() {
- paintCanvas.setFocus();
- }
-
- /**
- * Returns the Display on which the PaintSurface resides.
- * @return the Display
- */
- public Display getDisplay() {
- return paintCanvas.getDisplay();
- }
-
- /**
- * Returns the Shell in which the PaintSurface resides.
- * @return the Shell
- */
- public Shell getShell() {
- return paintCanvas.getShell();
- }
-
- /**
- * Sets the current paint session.
- *
- * If oldPaintSession != paintSession calls oldPaintSession.end()
- * and paintSession.begin()
- *
- *
- * @param paintSession the paint session to activate; null to disable all sessions
- */
- public void setPaintSession(PaintSession paintSession) {
- if (this.paintSession != null) {
- if (this.paintSession == paintSession) return;
- this.paintSession.endSession();
- }
- this.paintSession = paintSession;
- clearStatus();
- if (paintSession != null) {
- setStatusAction(paintSession.getDisplayName());
- paintSession.beginSession();
- } else {
- setStatusAction(PaintPlugin.getResourceString("tool.Null.label"));
- setStatusMessage(PaintPlugin.getResourceString("session.Null.message"));
- }
- }
-
- /**
- * Returns the current paint session.
- *
- * @return the current paint session, null if none is active
- */
- public PaintSession getPaintSession() {
- return paintSession;
- }
-
- /**
- * Returns the current paint tool.
- *
- * @return the current paint tool, null if none is active (though some other session
- * might be)
- */
- public PaintTool getPaintTool() {
- return (paintSession != null && paintSession instanceof PaintTool) ?
- (PaintTool)paintSession : null;
- }
-
- /**
- * Returns the current position in an interactive operation.
- *
- * @return the last known position of the pointer
- */
- public Point getCurrentPosition() {
- return currentPosition;
- }
-
- /**
- * Draws a Figure object to the screen and to the backing store permanently.
- *
- * @param object the object to draw onscreen
- */
- public void drawFigure(Figure object) {
- object.draw(imageFDC);
- object.draw(displayFDC);
- }
-
- /**
- * Adds a Figure object to the active rubberband selection.
- *
- * This object will be drawn to the screen as a preview and refreshed appropriately
- * until the selection is either cleared or committed.
- *
- *
- * @param object the object to add to the selection
- */
- public void addRubberbandSelection(Figure object) {
- rubberband.add(object);
- if (! isRubberbandHidden()) object.draw(displayFDC);
- }
-
- /**
- * Clears the active rubberband selection.
- *
- * Erases any rubberband objects on the screen then clears the selection.
- *
- */
- public void clearRubberbandSelection() {
- if (! isRubberbandHidden()) {
- Region region = new Region();
- rubberband.addDamagedRegion(displayFDC, region);
- Rectangle r = region.getBounds();
- paintCanvas.redraw(r.x, r.y, r.width, r.height, true);
- region.dispose();
- }
- rubberband.clear();
-
- }
-
- /**
- * Commits the active rubberband selection.
- *
- * Redraws any rubberband objects on the screen as permanent objects then clears the selection.
- *
- */
- public void commitRubberbandSelection() {
- rubberband.draw(imageFDC);
- if (isRubberbandHidden()) rubberband.draw(displayFDC);
- rubberband.clear();
- }
-
- /**
- * Hides the rubberband (but does not eliminate it).
- *
- * Increments by one the rubberband "hide" nesting count. The rubberband
- * is hidden from view (but remains active) if it wasn't already hidden.
- *
- */
- public void hideRubberband() {
- if (rubberbandHiddenNestingCount++ <= 0) {
- Region region = new Region();
- rubberband.addDamagedRegion(displayFDC, region);
- Rectangle r = region.getBounds();
- paintCanvas.redraw(r.x, r.y, r.width, r.height, true);
- region.dispose();
- }
- }
-
- /**
- * Shows (un-hides) the rubberband.
- *
- * Decrements by one the rubberband "hide" nesting count. The rubberband
- * is only made visible when showRubberband() has been called once for each
- * previous hideRubberband(). It is not permitted to call showRubberband() if
- * the rubber band is not presently hidden.
- *
- */
- public void showRubberband() {
- if (rubberbandHiddenNestingCount <= 0)
- throw new IllegalStateException("rubberbandHiddenNestingCount > 0");
- if (--rubberbandHiddenNestingCount == 0) {
- rubberband.draw(displayFDC);
- }
- }
-
- /**
- * Determines if the rubberband is hidden.
- *
- * @return true iff the rubber is hidden
- */
- public boolean isRubberbandHidden() {
- return rubberbandHiddenNestingCount > 0;
- }
-
- /**
- * Handles a horizontal scroll event
- *
- * @param scrollbar the horizontal scroll bar that posted this event
- */
- public void scrollHorizontally(ScrollBar scrollBar) {
- if (image == null) return;
- if (imageWidth > visibleWidth) {
- final int oldOffset = displayFDC.xOffset;
- final int newOffset = Math.min(scrollBar.getSelection(), imageWidth - visibleWidth);
- if (oldOffset != newOffset) {
- paintCanvas.update();
- displayFDC.xOffset = newOffset;
- paintCanvas.scroll(Math.max(oldOffset - newOffset, 0), 0, Math.max(newOffset - oldOffset, 0), 0,
- visibleWidth, visibleHeight, false);
- }
- }
- }
-
- /**
- * Handles a vertical scroll event
- *
- * @param scrollbar the vertical scroll bar that posted this event
- */
- public void scrollVertically(ScrollBar scrollBar) {
- if (image == null) return;
- if (imageHeight > visibleHeight) {
- final int oldOffset = displayFDC.yOffset;
- final int newOffset = Math.min(scrollBar.getSelection(), imageHeight - visibleHeight);
- if (oldOffset != newOffset) {
- paintCanvas.update();
- displayFDC.yOffset = newOffset;
- paintCanvas.scroll(0, Math.max(oldOffset - newOffset, 0), 0, Math.max(newOffset - oldOffset, 0),
- visibleWidth, visibleHeight, false);
- }
- }
- }
-
- /**
- * Handles resize events
- */
- private void handleResize() {
- paintCanvas.update();
-
- Rectangle visibleRect = paintCanvas.getClientArea();
- visibleWidth = visibleRect.width;
- visibleHeight = visibleRect.height;
-
- ScrollBar horizontal = paintCanvas.getHorizontalBar();
- if (horizontal != null) {
- displayFDC.xOffset = Math.min(horizontal.getSelection(), imageWidth - visibleWidth);
- if (imageWidth <= visibleWidth) {
- horizontal.setEnabled(false);
- horizontal.setSelection(0);
- } else {
- final int max = imageWidth - visibleWidth;
- horizontal.setEnabled(true);
- horizontal.setValues(displayFDC.xOffset, 0, imageWidth, visibleWidth,
- 8, visibleWidth);
- }
- }
-
- ScrollBar vertical = paintCanvas.getVerticalBar();
- if (vertical != null) {
- displayFDC.yOffset = Math.min(vertical.getSelection(), imageHeight - visibleHeight);
- if (imageHeight <= visibleHeight) {
- vertical.setEnabled(false);
- vertical.setSelection(0);
- } else {
- final int max = imageHeight - visibleHeight;
- vertical.setEnabled(true);
- vertical.setValues(displayFDC.yOffset, 0, imageHeight, visibleHeight,
- 8, visibleHeight);
- }
- }
- }
-
- /**
- * Virtualizes MouseEvent coordinates and stores the current position.
- */
- private void processMouseEventCoordinates(MouseEvent event) {
- currentPosition.x = event.x =
- Math.min(Math.max(event.x, 0), visibleWidth - 1) + displayFDC.xOffset;
- currentPosition.y = event.y =
- Math.min(Math.max(event.y, 0), visibleHeight - 1) + displayFDC.yOffset;
- }
-
- /**
- * Clears the status bar.
- */
- public void clearStatus() {
- statusActionInfo = "";
- statusMessageInfo = "";
- statusCoordInfo = "";
- updateStatus();
- }
-
- /**
- * Sets the status bar action text.
- *
- * @param action the action in progress, null to clear
- */
- public void setStatusAction(String action) {
- statusActionInfo = (action != null) ? action : "";
- updateStatus();
- }
-
- /**
- * Sets the status bar message text.
- *
- * @param message the message to display, null to clear
- */
- public void setStatusMessage(String message) {
- statusMessageInfo = (message != null) ? message : "";
- updateStatus();
- }
-
- /**
- * Sets the coordinates in the status bar.
- *
- * @param coord the coordinates to display, null to clear
- */
- public void setStatusCoord(Point coord) {
- statusCoordInfo = (coord != null) ? PaintPlugin.getResourceString("status.Coord.format", new Object[]
- { new Integer(coord.x), new Integer(coord.y)}) : "";
- updateStatus();
- }
-
- /**
- * Sets the coordinate range in the status bar.
- *
- * @param a the "from" coordinate, must not be null
- * @param b the "to" coordinate, must not be null
- */
- public void setStatusCoordRange(Point a, Point b) {
- statusCoordInfo = PaintPlugin.getResourceString("status.CoordRange.format", new Object[]
- { new Integer(a.x), new Integer(a.y), new Integer(b.x), new Integer(b.y)});
- updateStatus();
- }
-
- /**
- * Updates the display.
- */
- private void updateStatus() {
- statusText.setText(
- PaintPlugin.getResourceString("status.Bar.format", new Object[]
- { statusActionInfo, statusMessageInfo, statusCoordInfo }));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintTool.java
deleted file mode 100755
index 7ec50d9dbe..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintTool.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-public interface PaintTool extends PaintSession {
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings);
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintView.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintView.java
deleted file mode 100755
index b194b52449..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PaintView.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.resource.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.*;
-import org.eclipse.ui.part.*;
-
-import java.net.*;
-import java.util.*;
-
-/**
- * The view for the paint application.
- * All rendering happens inside the area created by createPartControl().
- *
- * @see ViewPart
- */
-public class PaintView extends ViewPart {
- private Display workbenchDisplay;
-
- // current active settings
- private ToolSettings toolSettings;
-
- // paint surface for drawing
- private PaintSurface paintSurface;
-
- // map action ids to useful data
- private HashMap /* of String to PaintTool */ paintToolMap;
- private HashMap /* of String to Integer */ paintFillTypeMap;
- private HashMap /* of String to Integer */ paintLineStyleMap;
-
- /** UI data **/
- // handle of currently active tool IAction on the UI
- private IAction activeToolAction;
- // handle of currently active filltype IAction on the UI
- private IAction activeFillTypeAction;
- // handle of currently active linetype IAction on the UI
- private IAction activeLineStyleAction;
-
- // handle of active foreground color box Canvas widget
- private Canvas activeForegroundColorCanvas;
- // handle of active background color box Canvas widget
- private Canvas activeBackgroundColorCanvas;
-
- private static final int numPaletteRows = 3;
- private static final int numPaletteCols = 50;
-
- // shared data
- private Color paintColorBlack, paintColorWhite; // alias for paintColors[0] and [1]
- private Color[] paintColors;
- private Font paintDefaultFont; // do not free
-
- /**
- * Constructs a Paint view.
- */
- public PaintView() {
- }
-
- /**
- * Cleanup
- */
- public void dispose() {
- if (paintSurface != null) paintSurface.dispose();
- if (paintColors != null) {
- for (int i = 0; i < paintColors.length; ++i) {
- final Color color = paintColors[i];
- if (color != null) color.dispose();
- }
- }
- paintDefaultFont = null;
- paintColors = null;
- paintSurface = null;
- super.dispose();
- }
-
- /**
- * Called when we must grab focus.
- *
- * @see org.eclipse.ui.part.ViewPart#setFocus
- */
- public void setFocus() {
- paintSurface.setFocus();
- }
-
- /**
- * Creates the example.
- *
- * @see ViewPart#createPartControl
- */
- public void createPartControl(Composite parent) {
- /*** Initialize shared data ***/
- workbenchDisplay = parent.getDisplay();
-
- paintColorWhite = new Color(workbenchDisplay, 255, 255, 255);
- paintColorBlack = new Color(workbenchDisplay, 0, 0, 0);
-
- paintDefaultFont = workbenchDisplay.getSystemFont();
-
- paintColors = new Color[numPaletteCols * numPaletteRows];
- paintColors[0] = paintColorBlack;
- paintColors[1] = paintColorWhite;
- for (int i = 2; i < paintColors.length; i++) {
- paintColors[i] = new Color(workbenchDisplay,
- ((i*7)%255),((i*23)%255), ((i*51)%255));
- }
-
- toolSettings = new ToolSettings();
- toolSettings.commonForegroundColor = paintColorBlack;
- toolSettings.commonBackgroundColor = paintColorWhite;
- toolSettings.commonFont = paintDefaultFont;
-
- /*** Add toolbar contributions ***/
- final IActionBars actionBars = getViewSite().getActionBars();
- IToolBarManager toolbarManager = actionBars.getToolBarManager();
-
- toolbarManager.add(new GroupMarker("group.tools"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.Pencil"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.Airbrush"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.Line"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.PolyLine"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.Rectangle"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.RoundedRectangle"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.Ellipse"));
- toolbarManager.appendToGroup("group.tools", new SelectPaintToolAction("tool.Text"));
- toolbarManager.add(new Separator());
- toolbarManager.add(new GroupMarker("group.options.fill"));
- toolbarManager.appendToGroup("group.options.fill", new SelectFillTypeAction("fill.None"));
- toolbarManager.appendToGroup("group.options.fill", new SelectFillTypeAction("fill.Outline"));
- toolbarManager.appendToGroup("group.options.fill", new SelectFillTypeAction("fill.Solid"));
- toolbarManager.add(new Separator());
- toolbarManager.add(new GroupMarker("group.options.linestyle"));
- toolbarManager.appendToGroup("group.options.linestyle", new SelectLineStyleAction("linestyle.Solid"));
- toolbarManager.appendToGroup("group.options.linestyle", new SelectLineStyleAction("linestyle.Dash"));
- toolbarManager.appendToGroup("group.options.linestyle", new SelectLineStyleAction("linestyle.Dot"));
- toolbarManager.appendToGroup("group.options.linestyle", new SelectLineStyleAction("linestyle.DashDot"));
- toolbarManager.add(new Separator());
- toolbarManager.add(new GroupMarker("group.options"));
- toolbarManager.appendToGroup("group.options", new SelectFontAction("options.Font"));
- actionBars.updateActionBars();
-
- /*** Build GUI ***/
- createGUI(parent);
-
- /*** Set defaults ***/
- setPaintToolByID("tool.Pencil");
- setFillTypeByID("fill.None");
- setLineStyleByID("linestyle.Solid");
- setForegroundColor(paintColorBlack);
- setBackgroundColor(paintColorWhite);
- }
-
- /**
- * Creates the GUI.
- */
- private void createGUI(Composite parent) {
- GridLayout gridLayout;
- GridData gridData;
-
- /*** Create principal GUI layout elements ***/
- Composite displayArea = new Composite(parent, SWT.NONE);
- gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- displayArea.setLayout(gridLayout);
-
- // Creating these elements here avoids the need to instantiate the GUI elements
- // in strict layout order. The natural layout ordering is an artifact of using
- // SWT layouts, but unfortunately it is not the same order as that required to
- // instantiate all of the non-GUI application elements to satisfy referential
- // dependencies. It is possible to reorder the initialization to some extent, but
- // this can be very tedious.
-
- // paint canvas
- final Canvas paintCanvas = new Canvas(displayArea, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL |
- SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
- paintCanvas.setLayoutData(gridData);
- paintCanvas.setBackground(paintColorWhite);
-
- // color selector frame
- final Composite colorFrame = new Composite(displayArea, SWT.NONE);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
- colorFrame.setLayoutData(gridData);
-
- // tool settings frame
- final Composite toolSettingsFrame = new Composite(displayArea, SWT.NONE);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
- toolSettingsFrame.setLayoutData(gridData);
-
- // status text
- final Text statusText = new Text(displayArea, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
- gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
- statusText.setLayoutData(gridData);
-
- /*** Create the remaining application elements inside the principal GUI layout elements ***/
- // paintSurface
- paintSurface = new PaintSurface(paintCanvas, statusText, paintColorWhite);
-
- // paintToolMap
- paintToolMap = new HashMap();
- paintToolMap.put("tool.Pencil", new PencilTool(toolSettings, paintSurface));
- paintToolMap.put("tool.Airbrush", new AirbrushTool(toolSettings, paintSurface));
- paintToolMap.put("tool.Line", new LineTool(toolSettings, paintSurface));
- paintToolMap.put("tool.PolyLine", new PolyLineTool(toolSettings, paintSurface));
- paintToolMap.put("tool.Rectangle", new RectangleTool(toolSettings, paintSurface));
- paintToolMap.put("tool.RoundedRectangle", new RoundedRectangleTool(toolSettings, paintSurface));
- paintToolMap.put("tool.Ellipse", new EllipseTool(toolSettings, paintSurface));
- paintToolMap.put("tool.Text", new TextTool(toolSettings, paintSurface));
- paintToolMap.put("tool.Null", null);
-
- // paintFillTypeMap
- paintFillTypeMap = new HashMap();
- paintFillTypeMap.put("fill.None", new Integer(ToolSettings.ftNone));
- paintFillTypeMap.put("fill.Outline", new Integer(ToolSettings.ftOutline));
- paintFillTypeMap.put("fill.Solid", new Integer(ToolSettings.ftSolid));
-
- // paintLineStyleMap
- paintLineStyleMap = new HashMap();
- paintLineStyleMap.put("linestyle.Solid", new Integer(SWT.LINE_SOLID));
- paintLineStyleMap.put("linestyle.Dash", new Integer(SWT.LINE_DASH));
- paintLineStyleMap.put("linestyle.Dot", new Integer(SWT.LINE_DOT));
- paintLineStyleMap.put("linestyle.DashDot", new Integer(SWT.LINE_DASHDOT));
-
- // colorFrame
- gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- colorFrame.setLayout(gridLayout);
-
- // activeForegroundColorCanvas, activeBackgroundColorCanvas
- activeForegroundColorCanvas = new Canvas(colorFrame, SWT.BORDER);
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.heightHint = 24;
- gridData.widthHint = 24;
- activeForegroundColorCanvas.setLayoutData(gridData);
-
- activeBackgroundColorCanvas = new Canvas(colorFrame, SWT.BORDER);
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.heightHint = 24;
- gridData.widthHint = 24;
- activeBackgroundColorCanvas.setLayoutData(gridData);
-
- // paletteCanvas
- final Canvas paletteCanvas = new Canvas(colorFrame, SWT.BORDER | SWT.NO_BACKGROUND);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.heightHint = 24;
- paletteCanvas.setLayoutData(gridData);
- paletteCanvas.addListener(SWT.MouseDown, new Listener() {
- public void handleEvent(Event e) {
- Rectangle bounds = paletteCanvas.getClientArea();
- Color color = getColorAt(bounds, e.x, e.y);
-
- if (e.button == 1) setForegroundColor(color);
- else setBackgroundColor(color);
- }
- private Color getColorAt(Rectangle bounds, int x, int y) {
- if (bounds.height <= 1 && bounds.width <= 1) return paintColorWhite;
- final int row = (y - bounds.y) * numPaletteRows / bounds.height;
- final int col = (x - bounds.x) * numPaletteCols / bounds.width;
- return paintColors[Math.min(Math.max(row * numPaletteCols + col, 0), paintColors.length - 1)];
- }
- });
- Listener refreshListener = new Listener() {
- public void handleEvent(Event e) {
- if (e.gc == null) return;
- Rectangle bounds = paletteCanvas.getClientArea();
- for (int row = 0; row < numPaletteRows; ++row) {
- for (int col = 0; col < numPaletteCols; ++col) {
- final int x = bounds.width * col / numPaletteCols;
- final int y = bounds.height * row / numPaletteRows;
- final int width = Math.max(bounds.width * (col + 1) / numPaletteCols - x, 1);
- final int height = Math.max(bounds.height * (row + 1) / numPaletteRows - y, 1);
- e.gc.setBackground(paintColors[row * numPaletteCols + col]);
- e.gc.fillRectangle(bounds.x + x, bounds.y + y, width, height);
- }
- }
- }
- };
- paletteCanvas.addListener(SWT.Resize, refreshListener);
- paletteCanvas.addListener(SWT.Paint, refreshListener);
- //paletteCanvas.redraw();
-
- // toolSettingsFrame
- gridLayout = new GridLayout();
- gridLayout.numColumns = 4;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- toolSettingsFrame.setLayout(gridLayout);
-
- Label label = new Label(toolSettingsFrame, SWT.NONE);
- label.setText(PaintPlugin.getResourceString("settings.AirbrushRadius.text"));
-
- final Scale airbrushRadiusScale = new Scale(toolSettingsFrame, SWT.HORIZONTAL);
- airbrushRadiusScale.setMinimum(5);
- airbrushRadiusScale.setMaximum(50);
- airbrushRadiusScale.setSelection(toolSettings.airbrushRadius);
- airbrushRadiusScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
- airbrushRadiusScale.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- toolSettings.airbrushRadius = airbrushRadiusScale.getSelection();
- updateToolSettings();
- }
- });
-
- label = new Label(toolSettingsFrame, SWT.NONE);
- label.setText(PaintPlugin.getResourceString("settings.AirbrushIntensity.text"));
-
- final Scale airbrushIntensityScale = new Scale(toolSettingsFrame, SWT.HORIZONTAL);
- airbrushIntensityScale.setMinimum(1);
- airbrushIntensityScale.setMaximum(100);
- airbrushIntensityScale.setSelection(toolSettings.airbrushIntensity);
- airbrushIntensityScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
- airbrushIntensityScale.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- toolSettings.airbrushIntensity = airbrushIntensityScale.getSelection();
- updateToolSettings();
- }
- });
- }
-
- /**
- * Notifies the tool that its settings have changed.
- */
- private void updateToolSettings() {
- final PaintTool activePaintTool = paintSurface.getPaintTool();
- if (activePaintTool == null) return;
-
- activePaintTool.endSession();
- activePaintTool.set(toolSettings);
- activePaintTool.beginSession();
- }
-
- /**
- * Sets the tool foreground color.
- *
- * @param color the new color to use
- */
- public void setForegroundColor(Color color) {
- if (activeForegroundColorCanvas != null)
- activeForegroundColorCanvas.setBackground(color);
- toolSettings.commonForegroundColor = color;
- updateToolSettings();
- }
-
- /**
- * Set the tool background color.
- *
- * @param color the new color to use
- */
- public void setBackgroundColor(Color color) {
- if (activeBackgroundColorCanvas != null)
- activeBackgroundColorCanvas.setBackground(color);
- toolSettings.commonBackgroundColor = color;
- updateToolSettings();
- }
-
- /**
- * Selects a tool given its ID.
- */
- public void setPaintToolByID(String id) {
- activeToolAction = handleRadioAction(activeToolAction, id);
-
- final PaintTool paintTool = (PaintTool) paintToolMap.get(id);
- paintSurface.setPaintSession(paintTool);
- updateToolSettings();
- }
-
- /**
- * Selects a filltype given its ID.
- */
- public void setFillTypeByID(String id) {
- activeFillTypeAction = handleRadioAction(activeFillTypeAction, id);
-
- final Integer fillType = (Integer) paintFillTypeMap.get(id);
- toolSettings.commonFillType = fillType.intValue();
- updateToolSettings();
- }
-
- /**
- * Selects line type given its ID.
- */
- public void setLineStyleByID(String id) {
- activeLineStyleAction = handleRadioAction(activeLineStyleAction, id);
-
- final Integer lineType = (Integer) paintLineStyleMap.get(id);
- toolSettings.commonLineStyle = lineType.intValue();
- updateToolSettings();
- }
-
- /**
- * Gets the IAction for an ID belonging to a set of mutually exclusive actions, and
- * toggles the old action off if necessary.
- */
- private IAction handleRadioAction(IAction oldAction, String id) {
- IAction action = getActionByID(id);
- if (action != null) {
- if (oldAction != null) oldAction.setChecked(false);
- if (! action.isChecked()) action.setChecked(true);
- return action;
- }
- return oldAction;
- }
-
- /**
- * Gets the IAction representing the UI toolbar button with the specified ID.
- */
- private IAction getActionByID(String id) {
- final IActionBars actionBars = getViewSite().getActionBars();
- IToolBarManager toolbarManager = actionBars.getToolBarManager();
- ActionContributionItem contributionItem = (ActionContributionItem) toolbarManager.find(id);
- if (contributionItem == null) return null;
- return contributionItem.getAction();
- }
-
- /**
- * Returns the Display.
- *
- * @return the display we're using
- */
- public Display getDisplay() {
- return workbenchDisplay;
- }
-
- /**
- * Action set glue.
- */
- abstract class PaintAction extends Action {
- public PaintAction(String id) {
- super();
- setId(id);
-
- try {
- final URL installUrl = PaintPlugin.getDefault().getBundle().getEntry("/");
- final URL imageUrl = new URL(installUrl, PaintPlugin.getResourceString(id + ".image"));
- setImageDescriptor(ImageDescriptor.createFromURL(imageUrl));
- } catch (MalformedURLException e) {
- PaintPlugin.logError("", e);
- }
-
- setText(PaintPlugin.getResourceString(id + ".label"));
- setToolTipText(PaintPlugin.getResourceString(id + ".tooltip"));
- setDescription(PaintPlugin.getResourceString(id + ".description"));
- }
- }
- class SelectPaintToolAction extends PaintAction {
- public SelectPaintToolAction(String id) { super(id); }
- public int getStyle() { return IAction.AS_CHECK_BOX; }
- public void run() { setPaintToolByID(getId()); }
-
- }
- class SelectFillTypeAction extends PaintAction {
- public SelectFillTypeAction(String id) { super(id); }
- public int getStyle() { return IAction.AS_CHECK_BOX; }
- public void run() { setFillTypeByID(getId()); }
- }
- class SelectLineStyleAction extends PaintAction {
- public SelectLineStyleAction(String id) { super(id); }
- public int getStyle() { return IAction.AS_CHECK_BOX; }
- public void run() { setLineStyleByID(getId()); }
- }
- class SelectFontAction extends PaintAction {
- public SelectFontAction(String id) { super(id); }
- public int getStyle() { return IAction.AS_PUSH_BUTTON; }
- public void run() {
- FontDialog fontDialog = new FontDialog(paintSurface.getShell(), SWT.PRIMARY_MODAL);
- FontData[] fontDatum = toolSettings.commonFont.getFontData();
- if (fontDatum != null && fontDatum.length > 0) {
- fontDialog.setFontList(fontDatum);
- }
- fontDialog.setText(PaintPlugin.getResourceString("options.Font.dialog.title"));
-
- paintSurface.hideRubberband();
- FontData fontData = fontDialog.open();
- paintSurface.showRubberband();
- if (fontData != null) {
- try {
- Font font = new Font(workbenchDisplay, fontData);
- toolSettings.commonFont = font;
- updateToolSettings();
- } catch (SWTException e) {
- }
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PencilTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PencilTool.java
deleted file mode 100755
index 08d1dab9e3..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PencilTool.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * A pencil tool.
- */
-public class PencilTool extends ContinuousPaintSession implements PaintTool {
- private ToolSettings settings;
-
- /**
- * Constructs a pencil tool.
- *
- * @param toolSettings the new tool settings
- * @param getPaintSurface() the PaintSurface we will render on.
- */
- public PencilTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns the name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.Pencil.label");
- }
-
- /*
- * Template method for drawing
- */
- public void render(final Point point) {
- final PaintSurface ps = getPaintSurface();
- ps.drawFigure(new PointFigure(settings.commonForegroundColor, point.x, point.y));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PointFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PointFigure.java
deleted file mode 100644
index 4b853693d2..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PointFigure.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Point object
- */
-public class PointFigure extends Figure {
- private Color color;
- private int x, y;
- /**
- * Constructs a Point
- *
- * @param color the color for this object
- * @param x the virtual X coordinate of the first end-point
- * @param y the virtual Y coordinate of the first end-point
- */
- public PointFigure(Color color, int x, int y) {
- this.color = color; this.x = x; this.y = y;
- }
- public void draw(FigureDrawContext fdc) {
- Point p = fdc.toClientPoint(x, y);
- fdc.gc.setBackground(color);
- fdc.gc.fillRectangle(p.x, p.y, 1, 1);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x, y, x, y));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java
deleted file mode 100755
index 03d1583e43..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/PolyLineTool.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * A polyline drawing tool.
- */
-public class PolyLineTool extends SegmentedPaintSession implements PaintTool {
- private ToolSettings settings;
-
- /**
- * Constructs a PolyLineTool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public PolyLineTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns the name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.PolyLine.label");
- }
-
- /*
- * Template methods for drawing
- */
- protected Figure createFigure(Point[] points, int numPoints, boolean closed) {
- ContainerFigure container = new ContainerFigure();
- if (closed && settings.commonFillType != ToolSettings.ftNone && numPoints >= 3) {
- container.add(new SolidPolygonFigure(settings.commonBackgroundColor, points, numPoints));
- }
- if (! closed || settings.commonFillType != ToolSettings.ftSolid || numPoints < 3) {
- for (int i = 0; i < numPoints - 1; ++i) {
- final Point a = points[i];
- final Point b = points[i + 1];
- container.add(new LineFigure(settings.commonForegroundColor, settings.commonBackgroundColor, settings.commonLineStyle,
- a.x, a.y, b.x, b.y));
- }
- if (closed) {
- final Point a = points[points.length - 1];
- final Point b = points[0];
- container.add(new LineFigure(settings.commonForegroundColor, settings.commonBackgroundColor, settings.commonLineStyle,
- a.x, a.y, b.x, b.y));
- }
- }
- return container;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RectangleFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RectangleFigure.java
deleted file mode 100755
index 1f416f8094..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RectangleFigure.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Rectangle object
- */
-public class RectangleFigure extends Figure {
- private Color foregroundColor, backgroundColor;
- private int lineStyle, x1, y1, x2, y2;
- /**
- * Constructs a Rectangle
- * These objects are defined by any two diametrically opposing corners.
- *
- * @param color the color for this object
- * @param lineStyle the line style for this object
- * @param x1 the virtual X coordinate of the first corner
- * @param y1 the virtual Y coordinate of the first corner
- * @param x2 the virtual X coordinate of the second corner
- * @param y2 the virtual Y coordinate of the second corner
- */
- public RectangleFigure(Color foregroundColor, Color backgroundColor, int lineStyle, int x1, int y1, int x2, int y2) {
- this.foregroundColor = foregroundColor;
- this.backgroundColor = backgroundColor;
- this.lineStyle = lineStyle;
- this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- }
- public void draw(FigureDrawContext fdc) {
- Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
- fdc.gc.setForeground(foregroundColor);
- fdc.gc.setBackground(backgroundColor);
- fdc.gc.setLineStyle(lineStyle);
- fdc.gc.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
- fdc.gc.setLineStyle(SWT.LINE_SOLID);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RectangleTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RectangleTool.java
deleted file mode 100755
index d9d6329eff..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RectangleTool.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * A drawing tool.
- */
-public class RectangleTool extends DragPaintSession implements PaintTool {
- private ToolSettings settings;
-
- /**
- * Constructs a RectangleTool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public RectangleTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.Rectangle.label");
- }
-
- /*
- * Template method for drawing
- */
- protected Figure createFigure(Point a, Point b) {
- switch (settings.commonFillType) {
- default:
- case ToolSettings.ftNone:
- return new RectangleFigure(settings.commonForegroundColor, settings.commonBackgroundColor, settings.commonLineStyle,
- a.x, a.y, b.x, b.y);
- case ToolSettings.ftSolid:
- return new SolidRectangleFigure(settings.commonBackgroundColor, a.x, a.y, b.x, b.y);
- case ToolSettings.ftOutline: {
- ContainerFigure container = new ContainerFigure();
- container.add(new SolidRectangleFigure(settings.commonBackgroundColor, a.x, a.y, b.x, b.y));
- container.add(new RectangleFigure(settings.commonForegroundColor, settings.commonBackgroundColor, settings.commonLineStyle,
- a.x, a.y, b.x, b.y));
- return container;
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RoundedRectangleFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RoundedRectangleFigure.java
deleted file mode 100755
index 8b62e49e13..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RoundedRectangleFigure.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Rectangle object
- */
-public class RoundedRectangleFigure extends Figure {
- private Color foregroundColor, backgroundColor;
- private int lineStyle, x1, y1, x2, y2, diameter;
- /**
- * Constructs a Rectangle
- * These objects are defined by any two diametrically opposing corners.
- *
- * @param color the color for this object
- * @param lineStyle the line style for this object
- * @param x1 the virtual X coordinate of the first corner
- * @param y1 the virtual Y coordinate of the first corner
- * @param x2 the virtual X coordinate of the second corner
- * @param y2 the virtual Y coordinate of the second corner
- * @param diameter the diameter of curvature of all four corners
- */
- public RoundedRectangleFigure(Color foregroundColor, Color backgroundColor, int lineStyle, int x1, int y1, int x2, int y2, int diameter) {
- this.foregroundColor = foregroundColor;
- this.backgroundColor = backgroundColor;
- this.lineStyle = lineStyle;
- this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- this.diameter = diameter;
- }
- public void draw(FigureDrawContext fdc) {
- Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
- fdc.gc.setForeground(foregroundColor);
- fdc.gc.setBackground(backgroundColor);
- fdc.gc.setLineStyle(lineStyle);
- fdc.gc.drawRoundRectangle(r.x, r.y, r.width - 1, r.height - 1, diameter, diameter);
- fdc.gc.setLineStyle(SWT.LINE_SOLID);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RoundedRectangleTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RoundedRectangleTool.java
deleted file mode 100755
index 052bbb67a6..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/RoundedRectangleTool.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * A drawing tool.
- */
-public class RoundedRectangleTool extends DragPaintSession implements PaintTool {
- private ToolSettings settings;
-
- /**
- * Constructs a RoundedRectangleTool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public RoundedRectangleTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.RoundedRectangle.label");
- }
-
- /*
- * Template methods for drawing
- */
- protected Figure createFigure(Point a, Point b) {
- ContainerFigure container = new ContainerFigure();
- if (settings.commonFillType != ToolSettings.ftNone)
- container.add(new SolidRoundedRectangleFigure(settings.commonBackgroundColor,
- a.x, a.y, b.x, b.y, settings.roundedRectangleCornerDiameter));
- if (settings.commonFillType != ToolSettings.ftSolid)
- container.add(new RoundedRectangleFigure(settings.commonForegroundColor, settings.commonBackgroundColor,
- settings.commonLineStyle, a.x, a.y, b.x, b.y, settings.roundedRectangleCornerDiameter));
- return container;
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedPaintSession.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedPaintSession.java
deleted file mode 100755
index 342edb134c..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SegmentedPaintSession.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-
-import java.util.*;
-
-/**
- * The superclass for paint tools that contruct objects from individually
- * picked segments.
- */
-public abstract class SegmentedPaintSession extends BasicPaintSession {
- /**
- * The set of control points making up the segmented selection
- */
- private Vector /* of Point */ controlPoints = new Vector();
-
- /**
- * The previous figure (so that we can abort with right-button)
- */
- private Figure previousFigure = null;
-
- /**
- * The current figure (so that we can abort with right-button)
- */
- private Figure currentFigure = null;
-
- /**
- * Constructs a PaintSession.
- *
- * @param paintSurface the drawing surface to use
- */
- protected SegmentedPaintSession(PaintSurface paintSurface) {
- super(paintSurface);
- }
-
- /**
- * Activates the tool.
- */
- public void beginSession() {
- getPaintSurface().setStatusMessage(PaintPlugin.getResourceString(
- "session.SegmentedInteractivePaint.message.anchorMode"));
- previousFigure = null;
- currentFigure = null;
- controlPoints.clear();
- }
-
- /**
- * Deactivates the tool.
- */
- public void endSession() {
- getPaintSurface().clearRubberbandSelection();
- if (previousFigure != null) getPaintSurface().drawFigure(previousFigure);
- }
-
- /**
- * Resets the tool.
- * Aborts any operation in progress.
- */
- public void resetSession() {
- getPaintSurface().clearRubberbandSelection();
- if (previousFigure != null) getPaintSurface().drawFigure(previousFigure);
-
- getPaintSurface().setStatusMessage(PaintPlugin.getResourceString(
- "session.SegmentedInteractivePaint.message.anchorMode"));
- previousFigure = null;
- currentFigure = null;
- controlPoints.clear();
- }
-
- /**
- * Handles a mouseDown event.
- *
- * @param event the mouse event detail information
- */
- public void mouseDown(MouseEvent event) {
- if (event.button != 1) return;
-
- getPaintSurface().setStatusMessage(PaintPlugin.getResourceString(
- "session.SegmentedInteractivePaint.message.interactiveMode"));
- previousFigure = currentFigure;
-
- if (controlPoints.size() > 0) {
- final Point lastPoint = (Point) controlPoints.elementAt(controlPoints.size() - 1);
- if (lastPoint.x == event.x || lastPoint.y == event.y) return; // spurious event
- }
- controlPoints.add(new Point(event.x, event.y));
- }
-
- /**
- * Handles a mouseDoubleClick event.
- *
- * @param event the mouse event detail information
- */
- public void mouseDoubleClick(MouseEvent event) {
- if (event.button != 1) return;
- if (controlPoints.size() >= 2) {
- getPaintSurface().clearRubberbandSelection();
- previousFigure = createFigure(
- (Point[]) controlPoints.toArray(new Point[controlPoints.size()]),
- controlPoints.size(), true);
- }
- resetSession();
- }
-
- /**
- * Handles a mouseUp event.
- *
- * @param event the mouse event detail information
- */
- public void mouseUp(MouseEvent event) {
- if (event.button != 1) {
- resetSession(); // abort if right or middle mouse button pressed
- return;
- }
- }
-
- /**
- * Handles a mouseMove event.
- *
- * @param event the mouse event detail information
- */
- public void mouseMove(MouseEvent event) {
- final PaintSurface ps = getPaintSurface();
- if (controlPoints.size() == 0) {
- ps.setStatusCoord(ps.getCurrentPosition());
- return; // spurious event
- } else {
- ps.setStatusCoordRange((Point) controlPoints.elementAt(controlPoints.size() - 1),
- ps.getCurrentPosition());
- }
-
- ps.clearRubberbandSelection();
- Point[] points = (Point[]) controlPoints.toArray(new Point[controlPoints.size() + 1]);
- points[controlPoints.size()] = ps.getCurrentPosition();
- currentFigure = createFigure(points, points.length, false);
- ps.addRubberbandSelection(currentFigure);
- }
-
- /**
- * Template Method: Creates a Figure for drawing rubberband entities and the final product
- *
- * @param points the array of control points
- * @param numPoints the number of valid points in the array (n >= 2)
- * @param closed true if the user double-clicked on the final control point
- */
- protected abstract Figure createFigure(Point[] points, int numPoints, boolean closed);
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidEllipseFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidEllipseFigure.java
deleted file mode 100755
index e23263de4d..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidEllipseFigure.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Solid Ellipse object
- */
-public class SolidEllipseFigure extends Figure {
- private Color color;
- private int x1, y1, x2, y2;
- /**
- * Constructs a SolidEllipse
- * These objects are defined by any two diametrically opposing corners of a box
- * bounding the ellipse.
- *
- * @param color the color for this object
- * @param x1 the virtual X coordinate of the first corner
- * @param y1 the virtual Y coordinate of the first corner
- * @param x2 the virtual X coordinate of the second corner
- * @param y2 the virtual Y coordinate of the second corner
- */
- public SolidEllipseFigure(Color color, int x1, int y1, int x2, int y2) {
- this.color = color; this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- }
- public void draw(FigureDrawContext fdc) {
- Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
- fdc.gc.setBackground(color);
- fdc.gc.fillOval(r.x, r.y, r.width, r.height);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidPolygonFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidPolygonFigure.java
deleted file mode 100755
index a5aca3dd11..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidPolygonFigure.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Line object
- */
-public class SolidPolygonFigure extends Figure {
- private Color color;
- private int[] points;
- /**
- * Constructs a SolidPolygon
- * These objects are defined by a sequence of vertices.
- *
- * @param color the color for this object
- * @param vertices the array of vertices making up the polygon
- * @param numPoint the number of valid points in the array (n >= 3)
- */
- public SolidPolygonFigure(Color color, Point[] vertices, int numPoints) {
- this.color = color;
- this.points = new int[numPoints * 2];
- for (int i = 0; i < numPoints; ++i) {
- points[i * 2] = vertices[i].x;
- points[i * 2 + 1] = vertices[i].y;
- }
- }
- public void draw(FigureDrawContext fdc) {
- int[] drawPoints = new int[points.length];
- for (int i = 0; i < points.length; i += 2) {
- drawPoints[i] = points[i] * fdc.xScale - fdc.xOffset;
- drawPoints[i + 1] = points[i + 1] * fdc.yScale - fdc.yOffset;
- }
- fdc.gc.setBackground(color);
- fdc.gc.fillPolygon(drawPoints);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- int xmin = Integer.MAX_VALUE, ymin = Integer.MAX_VALUE;
- int xmax = Integer.MIN_VALUE, ymax = Integer.MIN_VALUE;
-
- for (int i = 0; i < points.length; i += 2) {
- if (points[i] < xmin) xmin = points[i];
- if (points[i] > xmax) xmax = points[i];
- if (points[i+1] < ymin) ymin = points[i+1];
- if (points[i+1] > ymax) ymax = points[i+1];
- }
- region.add(fdc.toClientRectangle(xmin, ymin, xmax, ymax));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidRectangleFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidRectangleFigure.java
deleted file mode 100755
index 608a58c4ed..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidRectangleFigure.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D SolidRectangle object
- */
-public class SolidRectangleFigure extends Figure {
- private Color color;
- private int x1, y1, x2, y2;
- /**
- * Constructs a SolidRectangle
- * These objects are defined by any two diametrically opposing corners.
- *
- * @param color the color for this object
- * @param x1 the virtual X coordinate of the first corner
- * @param y1 the virtual Y coordinate of the first corner
- * @param x2 the virtual X coordinate of the second corner
- * @param y2 the virtual Y coordinate of the second corner
- */
- public SolidRectangleFigure(Color color, int x1, int y1, int x2, int y2) {
- this.color = color; this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- }
- public void draw(FigureDrawContext fdc) {
- Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
- fdc.gc.setBackground(color);
- fdc.gc.fillRectangle(r.x, r.y, r.width, r.height);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidRoundedRectangleFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidRoundedRectangleFigure.java
deleted file mode 100755
index 7b4146a342..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/SolidRoundedRectangleFigure.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D SolidRectangle object
- */
-public class SolidRoundedRectangleFigure extends Figure {
- private Color color;
- private int x1, y1, x2, y2, diameter;
- /**
- * Constructs a SolidRectangle
- * These objects are defined by any two diametrically opposing corners.
- *
- * @param color the color for this object
- * @param x1 the virtual X coordinate of the first corner
- * @param y1 the virtual Y coordinate of the first corner
- * @param x2 the virtual X coordinate of the second corner
- * @param y2 the virtual Y coordinate of the second corner
- * @param diameter the diameter of curvature of all four corners
- */
- public SolidRoundedRectangleFigure(Color color, int x1, int y1, int x2, int y2, int diameter) {
- this.color = color; this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2;
- this.diameter = diameter;
- }
- public void draw(FigureDrawContext fdc) {
- Rectangle r = fdc.toClientRectangle(x1, y1, x2, y2);
- fdc.gc.setBackground(color);
- fdc.gc.fillRoundRectangle(r.x, r.y, r.width, r.height, diameter, diameter);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- region.add(fdc.toClientRectangle(x1, y1, x2, y2));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/TextFigure.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/TextFigure.java
deleted file mode 100755
index cdb8929ac3..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/TextFigure.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.swt.graphics.*;
-
-/**
- * 2D Rectangle object
- */
-public class TextFigure extends Figure {
- private Color color;
- private Font font;
- private String text;
- private int x, y;
- /**
- * Constructs a TextFigure
- *
- * @param color the color for this object
- * @param font the font for this object
- * @param text the text to draw, tab and new-line expansion is performed
- * @param x the virtual X coordinate of the top-left corner of the text bounding box
- * @param y the virtual Y coordinate of the top-left corner of the text bounding box
- */
- public TextFigure(Color color, Font font, String text, int x, int y) {
- this.color = color; this.font = font; this.text = text; this.x = x; this.y = y;
- }
- public void draw(FigureDrawContext fdc) {
- Point p = fdc.toClientPoint(x, y);
- fdc.gc.setFont(font);
- fdc.gc.setForeground(color);
- fdc.gc.drawText(text, p.x, p.y, true);
- }
- public void addDamagedRegion(FigureDrawContext fdc, Region region) {
- Font oldFont = fdc.gc.getFont();
- fdc.gc.setFont(font);
- Point textExtent = fdc.gc.textExtent(text);
- fdc.gc.setFont(oldFont);
- region.add(fdc.toClientRectangle(x, y, x + textExtent.x, y + textExtent.y));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/TextTool.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/TextTool.java
deleted file mode 100755
index b5807969fe..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/TextTool.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-
-import org.eclipse.jface.dialogs.*;
-import org.eclipse.swt.events.*;
-
-/**
- * A text drawing tool.
- */
-public class TextTool extends BasicPaintSession implements PaintTool {
- private ToolSettings settings;
- private String drawText = PaintPlugin.getResourceString("tool.Text.settings.defaulttext");
-
- /**
- * Constructs a PaintTool.
- *
- * @param toolSettings the new tool settings
- * @param paintSurface the PaintSurface we will render on.
- */
- public TextTool(ToolSettings toolSettings, PaintSurface paintSurface) {
- super(paintSurface);
- set(toolSettings);
- }
-
- /**
- * Sets the tool's settings.
- *
- * @param toolSettings the new tool settings
- */
- public void set(ToolSettings toolSettings) {
- settings = toolSettings;
- }
-
- /**
- * Returns name associated with this tool.
- *
- * @return the localized name of this tool
- */
- public String getDisplayName() {
- return PaintPlugin.getResourceString("tool.Text.label");
- }
-
- /**
- * Activates the tool.
- */
- public void beginSession() {
- getPaintSurface().setStatusMessage(PaintPlugin.getResourceString(
- "session.Text.message"));
- }
-
- /**
- * Deactivates the tool.
- */
- public void endSession() {
- getPaintSurface().clearRubberbandSelection();
- }
-
- /**
- * Aborts the current operation.
- */
- public void resetSession() {
- getPaintSurface().clearRubberbandSelection();
- }
-
- /**
- * Handles a mouseDown event.
- *
- * @param event the mouse event detail information
- */
- public void mouseDown(MouseEvent event) {
- if (event.button == 1) {
- // draw with left mouse button
- getPaintSurface().commitRubberbandSelection();
- } else {
- // set text with right mouse button
- getPaintSurface().clearRubberbandSelection();
- InputDialog inputDialog = new InputDialog(getPaintSurface().getShell(),
- PaintPlugin.getResourceString("tool.Text.dialog.title"),
- PaintPlugin.getResourceString("tool.Text.dialog.message"),
- drawText, null);
- inputDialog.setBlockOnOpen(true);
- inputDialog.open();
- if (inputDialog.getReturnCode() == InputDialog.OK) drawText = inputDialog.getValue();
- inputDialog.close();
- }
- }
-
- /**
- * Handles a mouseDoubleClick event.
- *
- * @param event the mouse event detail information
- */
- public void mouseDoubleClick(MouseEvent event) {
- }
-
- /**
- * Handles a mouseUp event.
- *
- * @param event the mouse event detail information
- */
- public void mouseUp(MouseEvent event) {
- }
-
- /**
- * Handles a mouseMove event.
- *
- * @param event the mouse event detail information
- */
- public void mouseMove(MouseEvent event) {
- final PaintSurface ps = getPaintSurface();
- ps.setStatusCoord(ps.getCurrentPosition());
- ps.clearRubberbandSelection();
- ps.addRubberbandSelection(
- new TextFigure(settings.commonForegroundColor, settings.commonFont,
- drawText, event.x, event.y));
- }
-}
diff --git a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ToolSettings.java b/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ToolSettings.java
deleted file mode 100755
index 02fb877693..0000000000
--- a/examples/org.eclipse.swt.examples.paint/src/org/eclipse/swt/examples/paint/ToolSettings.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.examples.paint;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-
-/**
- * Tool Settings objects group tool-related configuration information.
- */
-public class ToolSettings {
- public static final int ftNone = 0, ftOutline = 1, ftSolid = 2;
-
- /**
- * commonForegroundColor: current tool foreground colour
- */
- public Color commonForegroundColor;
-
- /**
- * commonBackgroundColor: current tool background colour
- */
- public Color commonBackgroundColor;
-
- /**
- * commonFont: current font
- */
- public Font commonFont;
-
- /**
- * commonFillType: current fill type
- *
One of ftNone, ftOutline, ftSolid.
- */
- public int commonFillType = ftNone;
-
- /**
- * commonLineStyle: current line type
- */
- public int commonLineStyle = SWT.LINE_SOLID;
-
- /**
- * airbrushRadius: coverage radius in pixels
- */
- public int airbrushRadius = 10;
-
- /**
- * airbrushIntensity: average surface area coverage in region defined by radius per "jot"
- */
- public int airbrushIntensity = 30;
-
- /**
- * roundedRectangleCornerDiameter: the diameter of curvature of corners in a rounded rectangle
- */
- public int roundedRectangleCornerDiameter = 16;
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/.classpath b/examples/org.eclipse.swt.opengl.examples/.classpath
deleted file mode 100644
index 8437e3bb55..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.opengl.examples/.project b/examples/org.eclipse.swt.opengl.examples/.project
deleted file mode 100644
index 9112e8e738..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/.project
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- org.eclipse.swt.opengl.examples
-
-
- org.eclipse.swt
- org.eclipse.swt.opengl
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/AntialiasingTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/AntialiasingTab.java
deleted file mode 100644
index 78a1fbb4a9..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/AntialiasingTab.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class AntialiasingTab extends OpenGLTab {
- private Button antiAliasButton;
- private float xPos = 0.0f, yPos = 0.0f, zPos = -6.0f;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(12);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(5);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(12);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(5);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(12);
- zMove.setMinimum(0);
- zMove.setThumb(2);
- zMove.setPageIncrement(2);
- zMove.setSelection(5);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 11;
- }
- });
-
- antiAliasButton = new Button(composite, SWT.CHECK);
- antiAliasButton.setText("Anti-Aliasing");
- antiAliasButton.setSelection(true);
- antiAliasButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (antiAliasButton.getSelection()) {
- GL.glEnable(GL.GL_LINE_SMOOTH);
- } else {
- GL.glDisable(GL.GL_LINE_SMOOTH);
- }
- }
- });
-
- ColorSelectionGroup colorGroup =
- new ColorSelectionGroup(composite, SWT.NONE);
- colorGroup.setText("Foreground color");
- colorGroup.addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GL.glDeleteLists(1, 1);
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Anti-aliasing";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- final float[] BEZIER_POINTS = {
- -1.5f, -1.5f, 4.0f, -0.5f, -1.5f, 2.0f, 0.5f, -1.5f,
- -1.0f, 1.5f, -1.5f, 2.0f, -1.5f, -0.5f, 1.0f, -0.5f,
- -0.5f, 3.0f, 0.5f, -0.5f, 0.0f, 1.5f, -0.5f, -1.0f,
- -1.5f, 0.5f, 4.0f, -0.5f, 0.5f, 0.0f, 0.5f, 0.5f,
- 3.0f, 1.5f, 0.5f, 4.0f, -1.5f, 1.5f, -2.0f, -0.5f,
- 1.5f, -2.0f, 0.5f, 1.5f, 0.0f, 1.5f, 1.5f, -1.0f,
- };
- GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glMap2f(GL.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, BEZIER_POINTS);
- GL.glMapGrid2f(30, 0.0f, 1.0f, 30, 0.0f, 1.0f);
-
- GL.glEnable(GL.GL_AUTO_NORMAL);
- GL.glEnable(GL.GL_LINE_SMOOTH);
- GL.glEnable(GL.GL_LINE_STIPPLE);
- GL.glEnable(GL.GL_BLEND);
- GL.glEnable(GL.GL_MAP2_VERTEX_3);
-
- // create display lists
- GL.glNewList(1, GL.GL_COMPILE);
- GL.glEvalMesh2(GL.GL_LINE, 0, 30, 0, 30);
- GL.glEndList();
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glCallList(1); // draw the beizer surface
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/AreaTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/AreaTab.java
deleted file mode 100644
index 5c6ffab751..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/AreaTab.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class AreaTab extends OpenGLTab {
- abstract class Shape {
- abstract void draw();
- }
- class State {
- private String name;
- private int index;
- /**
- * Constructor.
- *
- * @param name the display name of this state
- * @param index the display list index corresponding to this state
- */
- State (String name, int index) {
- super();
- this.index = index;
- this.name = name;
- }
- void display() {
- GL.glCallList(index);
- }
- void dispose() {
- GL.glDeleteLists(index, 1);
- }
- String getName() {
- return name;
- }
- }
-
- private State[] states;
- private State currentState;
- private float xPos = 0.0f, yPos = 0.0f, zPos = -30.0f;
- private float xRot = 90.0f, yRot = 0.0f, zRot = 0.0f;
- private int quadratic, disk;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(22);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(10);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(22);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(10);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(22);
- zMove.setMinimum(0);
- zMove.setThumb(2);
- zMove.setPageIncrement(2);
- zMove.setSelection(10);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 40;
- }
- });
-
- Group rotationGroup = new Group(composite, SWT.NONE);
- rotationGroup.setText("Rotation");
- rotationGroup.setLayout(new GridLayout(2, false));
-
- new Label(rotationGroup, SWT.NONE).setText("X:");
- final Slider xRotation = new Slider(rotationGroup, SWT.NONE);
- xRotation.setIncrement(10);
- xRotation.setMaximum(362);
- xRotation.setMinimum(0);
- xRotation.setThumb(2);
- xRotation.setPageIncrement(20);
- xRotation.setSelection(90);
- xRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xRot = xRotation.getSelection();
- }
- });
-
- new Label(rotationGroup, SWT.NONE).setText("Y:");
- final Slider yRotation = new Slider(rotationGroup, SWT.NONE);
- yRotation.setIncrement(10);
- yRotation.setMaximum(362);
- yRotation.setMinimum(0);
- yRotation.setThumb(2);
- yRotation.setPageIncrement(20);
- yRotation.setSelection(0);
- yRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yRot = yRotation.getSelection();
- }
- });
-
- new Label(rotationGroup, SWT.NONE).setText("Z:");
- final Slider zRotation = new Slider(rotationGroup, SWT.NONE);
- zRotation.setIncrement(10);
- zRotation.setMaximum(362);
- zRotation.setMinimum(0);
- zRotation.setThumb(2);
- zRotation.setPageIncrement(20);
- zRotation.setSelection(0);
- zRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zRot = zRotation.getSelection();
- }
- });
-
- Composite optionsGroup = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- optionsGroup.setLayout(layout);
-
- new Label(optionsGroup, SWT.NONE).setText("Shape:");
-
- final Combo statesCombo = new Combo(optionsGroup, SWT.READ_ONLY);
- for (int i = 0; i < states.length; i++) {
- statesCombo.add(states[i].getName());
- }
- statesCombo.select(0);
- statesCombo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- currentState = states[statesCombo.getSelectionIndex()];
- }
- });
-
- final Button lightsButton = new Button(composite, SWT.CHECK);
- lightsButton.setText("Lights");
- lightsButton.setSelection(true);
- lightsButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (lightsButton.getSelection()) {
- GL.glEnable(GL.GL_LIGHTING);
- } else {
- GL.glDisable(GL.GL_LIGHTING);
- }
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteQuadric(quadratic);
- GLU.gluDeleteQuadric(disk);
- if (states != null) {
- for (int i = 0; i < states.length; i++) {
- states [i].dispose();
- }
- }
- }
-
- /**
- * Draws the logical AND of two shapes.
- *
- * @param a shape A
- * @param b shape B
- */
- void drawAandB(Shape a, Shape b) {
- // draw parts of B that are inside A
- drawAinsideB(a, b, GL.GL_BACK, GL.GL_NOTEQUAL);
- // we do not want the following to show up
- GL.glColorMask(false, false, false, false);
- // turn on depth testing
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glDepthFunc(GL.GL_ALWAYS);
- // render the front face of B
- b.draw();
- // reset the depth function
- GL.glDepthFunc(GL.GL_LESS);
- // draw parts of A that are inside B
- drawAinsideB(b, a, GL.GL_BACK, GL.GL_NOTEQUAL);
- }
-
- /**
- * Draws the contents of one shape that appear within another.
- *
- * @param a the shape to draw
- * @param b the constraining shape
- * @param face
- * @param test
- */
- void drawAinsideB(Shape a, Shape b, int face, int test) {
- // turn off the color buffer
- GL.glColorMask(false, false, false, false);
- // clear the stencil buffer
- GL.glClearStencil(0);
- GL.glEnable(GL.GL_DEPTH_TEST);
- // set to proper Culling
- GL.glCullFace(face);
- // render shape A
- a.draw();
- // set depth mask
- GL.glDepthMask(false);
- // enable stencil test
- GL.glEnable(GL.GL_STENCIL_TEST);
- GL.glStencilFunc(GL.GL_ALWAYS, 0, 0);
- // set the stencil buffer to increment if the depth test passes
- GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_INCR);
- // turn on back face culling
- GL.glCullFace(GL.GL_BACK);
- // render B
- b.draw();
- // set the stencil buffer to decrement if the depth test passes
- GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_DECR);
- // cull the front face
- GL.glCullFace(GL.GL_FRONT);
- // render B again
- b.draw();
- // set depth mask
- GL.glDepthMask(true);
- GL.glColorMask(true, true, true, true);
- // set the stencil buffer
- GL.glStencilFunc(test, 0, 1);
- // turn off depth testing
- GL.glDisable(GL.GL_DEPTH_TEST);
- // set to proper culling
- GL.glCullFace(face);
- // render A
- a.draw();
- // disable stencil test
- GL.glDisable(GL.GL_STENCIL_TEST);
- }
-
- /**
- * Draws the logical OR of two shapes.
- *
- * @param a shape A
- * @param b shape B
- */
- void drawAorB(Shape a, Shape b) {
- GL.glEnable(GL.GL_DEPTH_TEST);
- a.draw();
- b.draw();
- GL.glDisable(GL.GL_DEPTH_TEST);
- }
-
- /**
- * Draws one shape subtracted from another.
- *
- * @param a the base shape
- * @param b the shape to subtract
- */
- void drawAsubB(Shape a, Shape b) {
- // draw back parts of B inside A
- drawAinsideB(b, a, GL.GL_FRONT, GL.GL_NOTEQUAL);
- // we do not want the following to show up
- GL.glColorMask(false, false, false, false);
- GL.glEnable(GL.GL_DEPTH_TEST);
- // change the depth test to GL_ALWAYS
- GL.glDepthFunc(GL.GL_ALWAYS);
- // render the front face of B
- a.draw();
- // reset the depth function
- GL.glDepthFunc(GL.GL_LESS);
- // draw front parts of A outside B
- drawAinsideB(a, b, GL.GL_BACK, GL.GL_EQUAL);
- }
-
- /**
- * Draws the specifed shape.
- *
- * @param shape the shape to draw
- */
- void drawShape(Shape shape) {
- GL.glEnable(GL.GL_DEPTH_TEST);
- shape.draw();
- GL.glDisable(GL.GL_DEPTH_TEST);
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Area";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- if (!hasStencilSupport()) return;
-
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- float[] lightPos = { 0.0f, 5.0f, -10.0f, 1.0f };
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPos);
- quadratic = GLU.gluNewQuadric();
- disk = GLU.gluNewQuadric();
-
- GL.glEnable(GL.GL_CULL_FACE);
- GL.glEnable(GL.GL_LIST_MODE);
- GL.glEnable(GL.GL_LIGHT0);
- GL.glEnable(GL.GL_LIGHTING);
- GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, GL.GL_TRUE);
-
- final float[] sphereMaterial = { 0.0f, 1.0f, 0.0f, 1.0f };
- final float[] cylinderMaterial = { 1.0f, 0.0f, 0.0f, 1.0f };
-
- Shape sphere = new Shape() {
- public void draw() {
- GL.glMaterialfv(
- GL.GL_FRONT_AND_BACK,
- GL.GL_AMBIENT_AND_DIFFUSE,
- sphereMaterial);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GLU.gluSphere(quadratic, 3, 32, 32);
- }
- };
- Shape cylinder = new Shape() {
- public void draw() {
- GL.glMaterialfv(
- GL.GL_FRONT_AND_BACK,
- GL.GL_AMBIENT_AND_DIFFUSE,
- cylinderMaterial);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GLU.gluQuadricOrientation(disk, GLU.GLU_INSIDE);
- GL.glPushMatrix();
- GL.glTranslatef(1.0f, 1.0f, 0.0f);
- GLU.gluDisk(disk, 0, 3, 32, 32);
- GLU.gluCylinder(quadratic, 3, 3, 6, 32, 32);
- GL.glPushMatrix();
- GL.glTranslatef(0.0f, 0.0f, 6.0f);
- GLU.gluQuadricOrientation(disk, GLU.GLU_OUTSIDE);
- GLU.gluDisk(disk, 0, 3, 32, 32);
- GL.glPopMatrix();
- GL.glPopMatrix();
- }
- };
-
- // create the display lists and states
- states = new State[6];
- int index = 1;
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawShape(cylinder);
- GL.glEndList();
- states[0] = new State("Cylinder",index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawShape(sphere);
- GL.glEndList();
- states[1] = new State("Sphere",index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawAorB(cylinder, sphere);
- GL.glEndList();
- states[2] = new State("Cylinder OR Sphere",index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawAandB(cylinder, sphere);
- GL.glEndList();
- states[3] = new State("Cylinder AND Sphere",index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawAsubB(cylinder, sphere);
- GL.glEndList();
- states[4] = new State("Cylinder SUB Sphere",index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawAsubB(sphere, cylinder);
- GL.glEndList();
- states[5] = new State("Sphere SUB Cylinder",index++);
-
- currentState = states[0];
- }
-
- /**
- * @see OpenGLTab#isStencilSupportNeeded
- */
- boolean isStencilSupportNeeded() {
- return true;
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(
- GL.GL_COLOR_BUFFER_BIT
- | GL.GL_DEPTH_BUFFER_BIT
- | GL.GL_STENCIL_BUFFER_BIT);
-
- GL.glLoadIdentity();
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f);
- GL.glRotatef(yRot, 0.0f, 1.0f, 0.0f);
- GL.glRotatef(zRot, 0.0f, 0.0f, 1.0f);
-
- currentState.display();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java
deleted file mode 100644
index e66b8414c8..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class BezierTab extends SelectionTab {
- private boolean showCtrlPoints = true;
- private Point offset;
- private int currentPoint = -1;
- private int lineDivisions = 30;
- private double[][] ctrlPts = {
- { 1.5, 0.5, 0.0, 0.6, 0.9, 0.0, 0.85, 0.12,
- 0.0, 1.1, 1.0, 0.0, 0.53, 1.4, 0.0
- },
- { 0.53, 1.4, 0.0, 1.03, 1.87, 0.0, 1.52, 0.26,
- 0.0, 1.86, 0.43, 0.0, 1.5, 0.5, 0.0
- }
- };
- private static final int LENGTH = 5;
- private static final int[][] PICK_NAMES = {
- { 1, 2, 3, 4, 5 },
- { 6, 7, 8, 9, 10 }
- };
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- new Label(composite, SWT.NONE).setText("Click and drag points to adjust shape.");
- new Label(composite, SWT.NONE).setText("Line division count:");
- final Slider divisions = new Slider(composite, SWT.NONE);
- divisions.setIncrement(1);
- divisions.setMaximum(52);
- divisions.setMinimum(1);
- divisions.setThumb(2);
- divisions.setPageIncrement(2);
- divisions.setSelection(30);
- divisions.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- lineDivisions = divisions.getSelection();
- }
- });
-
- final Button showPointsButton = new Button(composite, SWT.CHECK);
- showPointsButton.setText("Show Points");
- showPointsButton.setSelection(true);
- showPointsButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- showCtrlPoints = showPointsButton.getSelection();
- }
- });
-
- final Button blendButton = new Button(composite, SWT.CHECK);
- blendButton.setText("Blend");
- blendButton.setSelection(true);
- blendButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (blendButton.getSelection()) {
- GL.glEnable(GL.GL_BLEND);
- } else {
- GL.glDisable(GL.GL_BLEND);
- }
- }
- });
-
- final Button smoothLineButton = new Button(composite, SWT.CHECK);
- smoothLineButton.setText("Smooth Line");
- smoothLineButton.setSelection(true);
- smoothLineButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (smoothLineButton.getSelection()) {
- GL.glEnable(GL.GL_LINE_SMOOTH);
- } else {
- GL.glDisable(GL.GL_LINE_SMOOTH);
- }
- }
- });
-
- final Canvas glCanvas = getGlCanvas();
- glCanvas.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
- offset = null;
- }
-
- });
-
- glCanvas.addListener(SWT.MouseDown, new Listener() {
- public void handleEvent(Event e) {
- e.y = glCanvas.getClientArea().height - e.y;
- if (e.button == 1) {
- if (processSelection(e.x, e.y, 10) > 0) {
- offset = new Point(e.x, e.y);
- } else {
- currentPoint = 0;
- }
- }
- }
- });
-
- glCanvas.addListener(SWT.MouseMove, new Listener() {
- public void handleEvent(Event e) {
- if (offset == null) return;
- int currentSegment = (currentPoint - 1) / LENGTH;
- int current = (currentPoint - 1) * 3;
- if (currentPoint > LENGTH) {
- current = (currentPoint - 6) * 3;
- }
- Rectangle rect = glCanvas.getClientArea();
- e.y = rect.height - e.y;
- if (0 < e.x && e.x < rect.width && 0 < e.y && e.y < rect.height && currentPoint > 0) {
- ctrlPts[currentSegment][current] = (float) e.x / (float) 200;
- ctrlPts[currentSegment][current + 1] = (float) e.y / (float) 200;
- switch (currentPoint) {
- case 10 :
- ctrlPts[0][0] = (float) e.x / (float) 200;
- ctrlPts[0][1] = (float) e.y / (float) 200;
- break;
- case 6 :
- ctrlPts[0][12] = (float) e.x / (float) 200;
- ctrlPts[0][13] = (float) e.y / (float) 200;
- break;
- }
- }
- }
- });
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Bezier";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glPointSize(7.0f);
- GL.glLineWidth(4.0f);
-
- GL.glEnable(GL.GL_AUTO_NORMAL);
- GL.glEnable(GL.GL_MAP1_VERTEX_3);
- GL.glEnable(GL.GL_LINE_SMOOTH);
- GL.glEnable(GL.GL_BLEND);
- }
-
- /**
- * @see SelectionTab.processPick (int[], int)
- */
- void processPick(int[] pSelectBuff, int hits) {
- int counter = 0;
- currentPoint = 0;
- for (int i = 0; i < hits; i++) {
- int count = pSelectBuff[counter];
- counter += 3;
- for (int j = 0; j < count; j++) {
- currentPoint = pSelectBuff[counter];
- counter++;
- }
- }
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(-1.0f, -1.0f, -2.45f);
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- for (int i = 0; i < ctrlPts.length; i++) {
- GL.glMapGrid1d(lineDivisions, 0.0f, 1f);
- GL.glMap1d(GL.GL_MAP1_VERTEX_3, 0, 1, 3, LENGTH, ctrlPts[i]);
- GL.glEvalMesh1(GL.GL_LINE, 0, lineDivisions);
- }
- if (showCtrlPoints) {
- GL.glPushName(0);
- for (int j = 0; j < ctrlPts.length; j++) {
- for (int i = 0; i < LENGTH * 3; i += 3) {
- GL.glLoadName(PICK_NAMES[j][i / 3]);
- GL.glBegin(GL.GL_POINTS);
- if (PICK_NAMES[j][i / 3] == currentPoint) {
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- } else {
- GL.glColor3f(0.0f, 0.0f, 0.0f);
- }
- GL.glVertex3d(ctrlPts[j][i], ctrlPts[j][i + 1], ctrlPts[j][i + 2]);
- GL.glEnd();
- }
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java
deleted file mode 100644
index 7d775ec72f..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class BitmapTextTab extends OpenGLTab {
- private Text messageText;
- private FontData fontData;
- private float[] textColor = { 1.0f, 0.0f, 0.0f };
- private float xPos = -130.0f, yPos = 0.0f;
- private int listIndexBase;
- private final static int LIST_INDEX_SIZE = 256;
- private final static int DEFAULT_FONT_SIZE = 24;
- private final static String DEFAULT_FONT_NAME = "Courier";
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(42);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(7);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = (xMove.getSelection() * 10) - 200;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(42);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(20);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = (yMove.getSelection() * 10) - 200;
- }
- });
-
- Composite textGroup = new Composite(composite,SWT.NONE);
- GridLayout layout = new GridLayout(2,false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- textGroup.setLayout(layout);
- textGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- new Label(textGroup, SWT.NONE).setText("Text:");
- messageText = new Text(textGroup, SWT.BORDER);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.grabExcessHorizontalSpace = true;
- messageText.setLayoutData(data);
- messageText.setText("OpenGL - SWT");
-
- final Button fontSelectButton = new Button(composite, SWT.NONE);
- fontSelectButton.setText("Set Font");
-
- final ColorSelectionGroup colorGroup =
- new ColorSelectionGroup(composite, SWT.NONE);
- colorGroup.setText("Text color");
- colorGroup.addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- }
- });
-
- fontSelectButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- FontDialog fontDialog = new FontDialog(fontSelectButton.getShell());
- fontDialog.setText("Choose Font Options");
- double[] currentColor = new double[4];
- GL.glGetDoublev(GL.GL_CURRENT_COLOR, currentColor);
- fontDialog.setRGB(
- new RGB(
- (int) currentColor[0] * 255,
- (int) currentColor[1] * 255,
- (int) currentColor[2] * 255));
- fontDialog.setFontList(new FontData[] {fontData});
- FontData result = fontDialog.open();
- if (result != null) {
- fontData = result;
- RGB rgb = fontDialog.getRGB();
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- colorGroup.setRGB(rgb);
- getContext().loadBitmapFont(fontData, null, listIndexBase, 32, 96);
- }
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GL.glDeleteLists(listIndexBase, LIST_INDEX_SIZE);
- }
-
- /**
- * Draws the text to the screen
- *
- * @param string the text to draw
- */
- void drawText(String string) {
- char[] stringChars = string.toCharArray();
- int[] text = new int[stringChars.length];
- for (int i = 0; i < text.length; i++) {
- text[i] = (int) stringChars[i];
- }
- // pushes the display list bits
- GL.glPushAttrib(GL.GL_LIST_BIT);
- // sets the base character to 32
- GL.glListBase(listIndexBase - 32);
- GL.glCallLists(text.length, GL.GL_UNSIGNED_INT, text);
- // pops the display list bits
- GL.glPopAttrib();
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Bitmap Text";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glColor3fv(textColor);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glEnable(GL.GL_BLEND);
- // build the initial font
- listIndexBase = GL.glGenLists(LIST_INDEX_SIZE);
- fontData = new FontData();
- fontData.setHeight(DEFAULT_FONT_SIZE);
- fontData.setName(DEFAULT_FONT_NAME);
- getContext().loadBitmapFont(fontData, null, listIndexBase, 32, LIST_INDEX_SIZE);
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glRasterPos2f(xPos, yPos);
- drawText(messageText.getText());
- }
-
- /**
- * @see OpenGLTab#setupViewingArea()
- */
- void setupViewingArea() {
- // use ortho view since this tab does not need any depth
- Rectangle rect = getGlCanvas().getClientArea();
- int width = rect.width;
- int height = rect.height;
- width = Math.max(width, 1);
- GL.glViewport(0, 0, width, height);
- float nRange = 200.0f;
- GL.glMatrixMode(GL.GL_PROJECTION);
- GL.glLoadIdentity();
- if (width <= height) {
- GL.glOrtho(
- -nRange, nRange, -nRange * height / width,
- nRange * height / width, -nRange, nRange);
- } else {
- GL.glOrtho(
- -nRange * height / width, nRange * height / width, -nRange,
- nRange, -nRange, nRange);
- }
- GL.glMatrixMode(GL.GL_MODELVIEW);
- GL.glLoadIdentity();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ColorSelectionGroup.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ColorSelectionGroup.java
deleted file mode 100644
index f0c3cdde9d..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ColorSelectionGroup.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import java.util.Vector;
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.GL;
-import org.eclipse.swt.widgets.*;
-
-class ColorSelectionGroup implements Listener {
- private Color color;
- private Label label;
- private Image image;
- private Button button;
- private Vector listeners = new Vector();
-
- /**
- * Constructor.
- *
- * @param parent the parent composite
- * @param style style bits to be applied to the color group
- */
- ColorSelectionGroup(Composite parent, int style) {
- super();
- initColor(parent.getDisplay());
-
- Composite colorGroup = new Composite(parent, style);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- colorGroup.setLayout(layout);
-// GridData data = new GridData(GridData.FILL_HORIZONTAL);
-// data.grabExcessHorizontalSpace = true;
-// colorGroup.setLayoutData(data);
-
- button = new Button(colorGroup, SWT.NONE);
- button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- image = new Image(button.getDisplay(), 12, 12);
- drawButtonImage();
- button.setImage(image);
- button.addListener(SWT.Selection, this);
- button.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- if (image != null) image.dispose();
- if (color != null) color.dispose();
- }
- });
-
- label = new Label(colorGroup, SWT.NONE);
- label.setText("Color");
-// data = new GridData(GridData.FILL_HORIZONTAL);
-// data.grabExcessHorizontalSpace = true;
-// label.setLayoutData(data);
- }
-
- /**
- * Adds the argument to this group's collection of
- * color selection listeners.
- *
- * @param listener
- */
- void addColorSelectionListener(IColorSelectionListener listener) {
- listeners.addElement(listener);
- }
-
- /**
- * Draws the colored square on the selection button.
- */
- void drawButtonImage() {
- GC gc = new GC(image);
- gc.setBackground(color);
- Rectangle bounds = image.getBounds();
- gc.fillRectangle(0, 0, bounds.width, bounds.height);
- gc.drawRectangle(0, 0, bounds.width - 1, bounds.height - 1);
- gc.dispose();
- }
-
- /**
- * @see org.eclipse.swt.widgets.Listener#handleEvent(Event)
- */
- public void handleEvent(Event e) {
- Shell shell = button.getShell();
- ColorDialog colorDialog = new ColorDialog(shell);
- colorDialog.setRGB(
- new RGB(color.getRed(), color.getGreen(), color.getBlue()));
- RGB rgb = colorDialog.open();
- if (rgb == null) return;
- setRGB(rgb);
- notifyListeners(rgb);
- }
-
- /**
- * Initializes the color by querying for the current color.
- *
- * @param display
- */
- void initColor(Display display) {
- double[] currentColor = new double[4];
- GL.glGetDoublev(GL.GL_CURRENT_COLOR, currentColor);
- RGB rgb =
- new RGB(
- (int) currentColor[0] * 255,
- (int) currentColor[1] * 255,
- (int) currentColor[2] * 255);
- color = new Color(display, rgb);
- }
-
- /**
- * Notifies all registered color selection listeners.
- *
- * @param value
- */
- void notifyListeners(RGB rgb) {
- IColorSelectionListener[] listenersArr =
- new IColorSelectionListener[listeners.size()];
- listeners.copyInto(listenersArr);
- for (int i = 0; i < listenersArr.length; i++) {
- listenersArr [i].handleColorSelection(rgb);
- }
- }
-
- /**
- * Removes the argument from this group's collection of color selection
- * listeners. If the argument is not a registered listener then does
- * nothing.
- *
- * @param listener
- */
- void removeColorSelectionListener(IColorSelectionListener listener) {
- listeners.removeElement(listener);
- }
-
- /**
- * Sets the text for the group's label.
- *
- * @param text the new label text
- */
- void setText(String text) {
- label.setText(text);
- }
-
- /**
- * Sets the current color.
- *
- * @param rgb the rgb of the new color
- */
- void setRGB(RGB rgb) {
- Color oldColor = color;
- color = new Color(button.getDisplay(), rgb);
- drawButtonImage();
- button.setImage(image);
- if (oldColor != null) oldColor.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/FogTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/FogTab.java
deleted file mode 100644
index da017ed1db..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/FogTab.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class FogTab extends OpenGLTab {
-
- private float rotY = 0.0f;
- private float yPos = 0.0f, xPos = 0.0f, zPos = -15.0f;
- private int cubeListIndexBase;
- private final static int[] FOG_TYPES = { GL.GL_LINEAR, GL.GL_EXP, GL.GL_EXP2 };
- private final static String[] FOG_NAMES = { "LINEAR", "GL_EXP", "GL_EXP2" };
- private final static int SLEEP_LENGTH = 0;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(12);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(5);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(12);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(5);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(24);
- zMove.setMinimum(0);
- zMove.setThumb(4);
- zMove.setPageIncrement(2);
- zMove.setSelection(10);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 25;
- }
- });
-
- Composite fogTypesGroup = new Composite(composite,SWT.NONE);
- GridLayout layout = new GridLayout(2,false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- fogTypesGroup.setLayout(layout);
- fogTypesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- new Label(fogTypesGroup, SWT.NONE).setText("Fog Types:");
- final Combo fogTypeCombo = new Combo(fogTypesGroup, SWT.READ_ONLY);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.grabExcessHorizontalSpace = true;
- fogTypeCombo.setLayoutData(data);
- fogTypeCombo.setItems(FOG_NAMES);
- fogTypeCombo.select(0);
-
- new Label(composite, SWT.NONE).setText("Fog Density:");
- final Slider fogDensitySlider = new Slider(composite, SWT.NONE);
- fogDensitySlider.setIncrement(1);
- fogDensitySlider.setMaximum(32);
- fogDensitySlider.setMinimum(0);
- fogDensitySlider.setThumb(2);
- fogDensitySlider.setPageIncrement(5);
- fogDensitySlider.setSelection(0);
- fogDensitySlider.setEnabled(false);
- fogDensitySlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- float fogDensity = ((float)fogDensitySlider.getSelection()) / 100;
- GL.glFogf(GL.GL_FOG_DENSITY, fogDensity);
- }
- });
- fogTypeCombo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- int currentSelection = fogTypeCombo.getSelectionIndex();
- // fog type GL.GL_LINEAR does not utilize fogDensity, but the other fog types do
- fogDensitySlider.setEnabled(currentSelection != 0);
- GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[currentSelection]);
- }
- });
- }
-
- /**
- * Creates a cube at 0,0 in the viewport.
- */
- void createCube() {
- GL.glNewList(cubeListIndexBase, GL.GL_COMPILE);
- GL.glBegin(GL.GL_QUADS);
- // front
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(-0.5f, -0.5f, 0.5f); // bottom left
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(0.5f, -0.5f, 0.5f); // bottom right
- GL.glColor3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.5f, 0.5f, 0.5f); // top right
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(-0.5f, 0.5f, 0.5f); // top left
- // back
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(-0.5f, -0.5f, -0.5f); // bottom left
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.5f, -0.5f, -0.5f); // bottom right
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.5f, 0.5f, -0.5f); // top right
- GL.glColor3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(-0.5f, 0.5f, -0.5f); // top left
- // left
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(-0.5f, -0.5f, -0.5f); // bottom left
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(-0.5f, -0.5f, 0.5f); // bottom right
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(-0.5f, 0.5f, 0.5f); // top right
- GL.glColor3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(-0.5f, 0.5f, -0.5f); // top left
- // right
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(0.5f, -0.5f, 0.5f); // bottom left
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.5f, -0.5f, -0.5f); // bottom right
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.5f, 0.5f, -0.5f); // top right
- GL.glColor3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.5f, 0.5f, 0.5f); // top left
- // top
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.5f, 0.5f, -0.5f);
- GL.glColor3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(-0.5f, 0.5f, -0.5f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(-0.5f, 0.5f, 0.5f);
- GL.glColor3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.5f, 0.5f, 0.5f);
- // bottom
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(0.5f, -0.5f, 0.5f);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(-0.5f, -0.5f, 0.5f);
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(-0.5f, -0.5f, -0.5f);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.5f, -0.5f, -0.5f);
- GL.glEnd();
- GL.glEndList();
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GL.glDeleteLists(cubeListIndexBase, 1);
- }
-
- /**
- * @see OpenGLTab#getSleepLength()
- */
- int getSleepLength() {
- return SLEEP_LENGTH;
- }
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Fog";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- // fog color should be the same as the clear color
- // to look appropriate
- float[] fogColor = { 1.0f, 1.0f, 1.0f, 1.0f };
- GL.glFogfv(GL.GL_FOG_COLOR, fogColor);
- GL.glHint(GL.GL_FOG_HINT, GL.GL_DONT_CARE);
- GL.glFogf(GL.GL_FOG_START, 0);
- GL.glFogf(GL.GL_FOG_DENSITY, 0.0f);
- // set the end of the start distance; anything > 15
- // units from the camera will be covered in fog
- GL.glFogf(GL.GL_FOG_END, 15);
- GL.glFogf(GL.GL_FOG_MODE, FOG_TYPES[0]);
- GL.glEnable(GL.GL_FOG);
- GL.glEnable(GL.GL_DEPTH_TEST);
-
- cubeListIndexBase = GL.glGenLists(1);
- createCube();
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glRotatef(rotY, 0.0f, 1.0f, 0.0f);
-
- GL.glCallList(cubeListIndexBase);
-
- GL.glPushMatrix();
- GL.glTranslatef(3, 0, -3);
- GL.glCallList(cubeListIndexBase);
- GL.glPopMatrix();
-
- GL.glPushMatrix();
- GL.glTranslatef(-3, 0, -3);
- GL.glCallList(cubeListIndexBase);
- GL.glPopMatrix();
-
- GL.glPushMatrix();
- GL.glTranslatef(0, 0, 4);
- GL.glCallList(cubeListIndexBase);
- GL.glPopMatrix();
-
- rotY += 0.6f;
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/GradientTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/GradientTab.java
deleted file mode 100644
index 61e93097d5..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/GradientTab.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class GradientTab extends OpenGLTab {
- private float xPos = 0.0f, yPos = 0.0f, zPos = -7.0f;
- private float xRot = 180.0f, yRot = 180.0f, zRot = 180.0f;
- private int currentSelection = 1;
- private final static float[] BEZIER_COLORS = {
- 0.0f, 1.0f, 0.0f, 0.0f, 0.3f, 0.6f, 0.1f, 0.0f,
- 0.8f, 0.2f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f, 0.8f, 0.8f, 0.8f, 0.0f
- };
- private final static float[] BEZIER_POINTS = {
- -1.5f, -1.5f, 4.0f, -0.5f, -1.5f, 2.0f, 0.5f, -1.5f,
- -1.0f, 1.5f, -1.5f, 2.0f, -1.5f, -0.5f, 1.0f, -0.5f,
- -0.5f, 3.0f, 0.5f, -0.5f, 0.0f, 1.5f, -0.5f, -1.0f,
- -1.5f, 0.5f, 4.0f, -0.5f, 0.5f, 0.0f, 0.5f, 0.5f,
- 3.0f, 1.5f, 0.5f, 4.0f, -1.5f, 1.5f, -2.0f, -0.5f,
- 1.5f, -2.0f, 0.5f, 1.5f, 0.0f, 1.5f, 1.5f, -1.0f,
- };
- private final static String[] OBJECT_NAMES = { "Bezier", "Square" };
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(12);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(5);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(12);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(5);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(12);
- zMove.setMinimum(0);
- zMove.setThumb(2);
- zMove.setPageIncrement(2);
- zMove.setSelection(5);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 12;
- }
- });
-
- Group rotationGroup = new Group(composite, SWT.NONE);
- rotationGroup.setText("Rotation");
- rotationGroup.setLayout(new GridLayout(2, false));
-
- new Label(rotationGroup, SWT.NONE).setText("X:");
- final Slider xRotation = new Slider(rotationGroup, SWT.NONE);
- xRotation.setIncrement(10);
- xRotation.setMaximum(362);
- xRotation.setMinimum(0);
- xRotation.setThumb(2);
- xRotation.setPageIncrement(20);
- xRotation.setSelection(180);
- xRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xRot = xRotation.getSelection();
- }
- });
-
- new Label(rotationGroup, SWT.NONE).setText("Y:");
- final Slider yRotation = new Slider(rotationGroup, SWT.NONE);
- yRotation.setIncrement(10);
- yRotation.setMaximum(362);
- yRotation.setMinimum(0);
- yRotation.setThumb(2);
- yRotation.setPageIncrement(20);
- yRotation.setSelection(180);
- yRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yRot = yRotation.getSelection();
- }
- });
-
- new Label(rotationGroup, SWT.NONE).setText("Z:");
- final Slider zRotation = new Slider(rotationGroup, SWT.NONE);
- zRotation.setIncrement(10);
- zRotation.setMaximum(362);
- zRotation.setMinimum(0);
- zRotation.setThumb(2);
- zRotation.setPageIncrement(20);
- zRotation.setSelection(180);
- zRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zRot = zRotation.getSelection();
- }
- });
-
- Composite objectGroup = new Composite(composite,SWT.NONE);
- GridLayout layout = new GridLayout(2,false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- objectGroup.setLayout(layout);
- objectGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- new Label(objectGroup, SWT.NONE).setText("Object:");
- final Combo objectCombo = new Combo(objectGroup, SWT.READ_ONLY);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.grabExcessHorizontalSpace = true;
- objectCombo.setLayoutData(data);
- objectCombo.setItems(OBJECT_NAMES);
- objectCombo.select(0);
- objectCombo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- currentSelection = objectCombo.getSelectionIndex() + 1;
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GL.glDeleteLists(1, 2);
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Gradients";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
- GL.glMap2f(GL.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, BEZIER_POINTS);
- GL.glMap2f(GL.GL_MAP2_COLOR_4, 0, 1, 4, 1, 0, 1, 4, 6, BEZIER_COLORS);
- GL.glMapGrid2f(20, 0.0f, 1.0f, 20, 0.0f, 1.0f);
- GL.glShadeModel(GL.GL_SMOOTH);
- GL.glEnable(GL.GL_LINE_SMOOTH);
- GL.glEnable(GL.GL_LINE_STIPPLE);
- GL.glEnable(GL.GL_BLEND);
- GL.glEnable(GL.GL_MAP2_COLOR_4);
- GL.glEnable(GL.GL_MAP2_VERTEX_3);
- GL.glEnable(GL.GL_DEPTH_TEST);
-
- // create display lists
- GL.glNewList(1, GL.GL_COMPILE);
- GL.glEvalMesh2(GL.GL_FILL, 0, 20, 0, 20);
- GL.glEndList();
- GL.glNewList(2, GL.GL_COMPILE);
- GL.glBegin(GL.GL_TRIANGLE_FAN);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(0.0f, 0.0f, 0.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.0f, 2.0f, 0.0f);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(-2.0f, 2.0f, 0.0f);
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(-2.0f, 0.0f, 0.0f);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(-2.0f, -2.0f, 0.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.0f, -2.0f, 0.0f);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(2.0f, -2.0f, 0.0f);
- GL.glColor3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3f(2.0f, 0.0f, 0.0f);
- GL.glColor3f(0.0f, 1.0f, 0.0f);
- GL.glVertex3f(2.0f, 2.0f, 0.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.0f, 2.0f, 0.0f);
- GL.glEnd();
- GL.glEndList();
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f);
- GL.glRotatef(yRot, 0.0f, 1.0f, 0.0f);
- GL.glRotatef(zRot, 0.0f, 0.0f, 1.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glCallList(currentSelection);
- }
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/IColorSelectionListener.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/IColorSelectionListener.java
deleted file mode 100644
index 346b5639dc..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/IColorSelectionListener.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-import org.eclipse.swt.graphics.RGB;
-
-
-public interface IColorSelectionListener {
- public void handleColorSelection(RGB rgb);
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/LightTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/LightTab.java
deleted file mode 100644
index 701eb9cefa..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/LightTab.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class LightTab extends OpenGLTab {
- private float[] materialShininess = { 25.0f };
- private float[] lightPosition = { 0.0f, 0.0f, 0.0f, 1.0f };
- private float[][] colorValues = {
- { 1.0f, 1.0f, 1.0f, 1.0f }, // light diffuse
- { 1.0f, 1.0f, 1.0f, 1.0f }, // light ambient
- { 1.0f, 1.0f, 1.0f, 1.0f }, // light specular
- { 0.5f, 0.5f, 0.5f, 1.0f }, // light main ambient
- { 0.0f, 0.0f, 1.0f, 1.0f }, // material diffuse
- { 0.3f, 0.3f, 0.3f, 1.0f }, // material ambient
- { 1.0f, 1.0f, 1.0f, 1.0f } // material specular
- };
- private float yPos = 0.0f, xPos = 0.0f, zPos = -20.0f;
- private int quadratic, sphere;
- // sourceType values: 0 = light, 1 = material
- private int sourceType;
- // lightType values: 0 = diffuse, 1 = ambient, 2 = specular, 3 = main ambient
- private int lightType = 0;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(22);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(10);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(22);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(10);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(22);
- zMove.setMinimum(0);
- zMove.setThumb(2);
- zMove.setPageIncrement(2);
- zMove.setSelection(10);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 30;
- }
- });
-
- Group positionGroup = new Group(composite, SWT.NONE);
- positionGroup.setText("Light Position");
- positionGroup.setLayout(new GridLayout(2, false));
-
- new Label(positionGroup, SWT.NONE).setText("X:");
- final Slider lightX = new Slider(positionGroup, SWT.NONE);
- lightX.setIncrement(1);
- lightX.setMaximum(22);
- lightX.setMinimum(0);
- lightX.setThumb(2);
- lightX.setPageIncrement(2);
- lightX.setSelection(10);
- lightX.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- lightPosition[0] = ((float) lightX.getSelection() * 10) - 100;
- }
- });
-
- new Label(positionGroup, SWT.NONE).setText("Y:");
- final Slider lightY = new Slider(positionGroup, SWT.NONE);
- lightY.setIncrement(1);
- lightY.setMaximum(22);
- lightY.setMinimum(0);
- lightY.setThumb(2);
- lightY.setPageIncrement(2);
- lightY.setSelection(10);
- lightY.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- lightPosition[1] = ((float) lightY.getSelection() * 10) - 100;
- }
- });
-
- new Label(positionGroup, SWT.NONE).setText("Z:");
- final Slider lightZ = new Slider(positionGroup, SWT.NONE);
- lightZ.setIncrement(1);
- lightZ.setMaximum(22);
- lightZ.setMinimum(0);
- lightZ.setThumb(2);
- lightZ.setPageIncrement(2);
- lightZ.setSelection(10);
- lightZ.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- lightPosition[2] = ((float) lightZ.getSelection() * 10) - 20;
- }
- });
-
- Group lightColorsGroup = new Group(composite, SWT.NONE);
- lightColorsGroup.setText("Light Colors");
- lightColorsGroup.setLayout(new GridLayout());
- GridData data = new GridData(GridData.FILL_BOTH);
- lightColorsGroup.setLayoutData(data);
-
- ColorSelectionGroup lightDiffuseButton =
- new ColorSelectionGroup(lightColorsGroup, SWT.NONE);
- lightDiffuseButton.setText("Diffuse");
- lightDiffuseButton.setRGB(
- new RGB(
- (int) (colorValues[0][0] * 255),
- (int) (colorValues[0][1] * 255),
- (int) (colorValues[0][2] * 255)));
- lightDiffuseButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[0][0] = ((float) rgb.red) / 255;
- colorValues[0][1] = ((float) rgb.green) / 255;
- colorValues[0][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- ColorSelectionGroup lightAmbientButton =
- new ColorSelectionGroup(lightColorsGroup, SWT.NONE);
- lightAmbientButton.setText("Ambient");
- lightAmbientButton.setRGB(
- new RGB(
- (int) (colorValues[1][0] * 255),
- (int) (colorValues[1][1] * 255),
- (int) (colorValues[1][2] * 255)));
- lightAmbientButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[1][0] = ((float) rgb.red) / 255;
- colorValues[1][1] = ((float) rgb.green) / 255;
- colorValues[1][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- ColorSelectionGroup lightSpecularButton =
- new ColorSelectionGroup(lightColorsGroup, SWT.NONE);
- lightSpecularButton.setText("Specular");
- lightSpecularButton.setRGB(
- new RGB(
- (int) (colorValues[2][0] * 255),
- (int) (colorValues[2][1] * 255),
- (int) (colorValues[2][2] * 255)));
- lightSpecularButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[2][0] = ((float) rgb.red) / 255;
- colorValues[2][1] = ((float) rgb.green) / 255;
- colorValues[2][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- ColorSelectionGroup lightMainAmbientButton =
- new ColorSelectionGroup(lightColorsGroup, SWT.NONE);
- lightMainAmbientButton.setText("Main Ambient");
- lightMainAmbientButton.setRGB(
- new RGB(
- (int) (colorValues[3][0] * 255),
- (int) (colorValues[3][1] * 255),
- (int) (colorValues[3][2] * 255)));
- lightMainAmbientButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[3][0] = ((float) rgb.red) / 255;
- colorValues[3][1] = ((float) rgb.green) / 255;
- colorValues[3][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- Group materialColorsGroup = new Group(composite, SWT.NONE);
- materialColorsGroup.setText("Material Colors");
- materialColorsGroup.setLayout(new GridLayout());
- data = new GridData(GridData.FILL_BOTH);
- materialColorsGroup.setLayoutData(data);
-
- ColorSelectionGroup materialDiffuseButton =
- new ColorSelectionGroup(materialColorsGroup, SWT.NONE);
- materialDiffuseButton.setText("Diffuse");
- materialDiffuseButton.setRGB(
- new RGB(
- (int) (colorValues[4][0] * 255),
- (int) (colorValues[4][1] * 255),
- (int) (colorValues[4][2] * 255)));
- materialDiffuseButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[4][0] = ((float) rgb.red) / 255;
- colorValues[4][1] = ((float) rgb.green) / 255;
- colorValues[4][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- ColorSelectionGroup materialAmbientButton =
- new ColorSelectionGroup(materialColorsGroup, SWT.NONE);
- materialAmbientButton.setText("Ambient");
- materialAmbientButton.setRGB(
- new RGB(
- (int) (colorValues[5][0] * 255),
- (int) (colorValues[5][1] * 255),
- (int) (colorValues[5][2] * 255)));
- materialAmbientButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[5][0] = ((float) rgb.red) / 255;
- colorValues[5][1] = ((float) rgb.green) / 255;
- colorValues[5][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- ColorSelectionGroup materialSpecularButton =
- new ColorSelectionGroup(materialColorsGroup, SWT.NONE);
- materialSpecularButton.setText("Specular");
- materialSpecularButton.setRGB(
- new RGB(
- (int) (colorValues[6][0] * 255),
- (int) (colorValues[6][1] * 255),
- (int) (colorValues[6][2] * 255)));
- materialSpecularButton
- .addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- colorValues[6][0] = ((float) rgb.red) / 255;
- colorValues[6][1] = ((float) rgb.green) / 255;
- colorValues[6][2] = ((float) rgb.blue) / 255;
- setColorValues();
- }
- });
-
- new Label(composite, SWT.NONE).setText("Material Shininess:");
- final Slider shineSlider = new Slider(composite, SWT.NONE);
- shineSlider.setIncrement(5);
- shineSlider.setMaximum(102);
- shineSlider.setMinimum(0);
- shineSlider.setThumb(2);
- shineSlider.setPageIncrement(10);
- shineSlider.setSelection(25);
- shineSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- materialShininess[0] = shineSlider.getSelection();
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK,
- GL.GL_SHININESS,
- materialShininess);
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteQuadric(quadratic);
- GL.glDeleteLists(sphere, 1);
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Light";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glClearDepth(1.0);
- setColorValues();
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, materialShininess);
- quadratic = GLU.gluNewQuadric();
- GLU.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
- GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST);
- GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glPointSize(2.0f);
- GL.glEnable(GL.GL_LIGHTING);
- GL.glEnable(GL.GL_LIGHT0);
- GL.glEnable(GL.GL_DEPTH_TEST);
- sphere = GL.glGenLists(1);
- GL.glNewList(sphere, GL.GL_COMPILE);
- GLU.gluSphere(quadratic, 3, 32, 32);
- GL.glEndList();
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition);
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glCallList(sphere);
- }
-
- /**
- * Sets the current color values into the rendered display.
- */
- void setColorValues() {
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, colorValues[0]);
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, colorValues[4]);
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, colorValues[5]);
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, colorValues[1]);
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, colorValues[2]);
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, colorValues[6]);
- GL.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, colorValues[3]);
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, materialShininess);
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/NurbTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/NurbTab.java
deleted file mode 100644
index c25e8c6647..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/NurbTab.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class NurbTab extends OpenGLTab {
- private float xPos = -5.0f, yPos = -5.0f, zPos = -25.0f;
- private float xRot = 330.0f, yRot = 0.0f, zRot = 0.0f;
- private int nurb;
-
- /**
- * Returns a 3 dimensional array to store vertex points for the nurb
- * surface.
- *
- * @return the array
- */
- float[][][] buildNurb() {
- float[][][] ctrl = new float[4][4][3];
- for (int i = 0; i < 4; i++) {
- for (int j = 0; j < 4; j++) {
- // set the x value
- ctrl[i][j][0] = 2 * (i + (float) Math.cos(i + j));
- // set the y value
- ctrl[i][j][1] = 2 * (j + (float) Math.cos(i + j));
- // set the z value
- if ((i == 1 && j == 1) || (i == 2 && j == 2)) {
- // this makes the hill
- ctrl[i][j][2] = 6.0f;
- } else {
- ctrl[i][j][2] = 0.0f;
- }
- }
- }
- // sets this particular z value to a large number to make a high
- // hill
- ctrl[2][2][2] = 8.0f;
-
- return ctrl;
- }
-
- /**
- * Returns a 1 dimensional array representing the 3 dimensional
- * argument. This result can be passed to the nurb renderer
- *
- * @param ctrl source 3D array
- * @return 1D array
- */
- float[] convert(float[][][] ctrl) {
- float[] pts =
- new float[ctrl.length * ctrl[0].length * ctrl[0][0].length];
- int row = 0;
- int col = 0;
- // set rowIncr to number of columns * depth
- int rowIncr = ctrl[0].length * ctrl[0][0].length;
- // set colIncr to depth
- int colIncr = ctrl[0][0].length;
- // loop through rows
- for (int i = 0; i < ctrl.length; i++) {
- col = 0;
- // loop through columns
- for (int j = 0; j < ctrl[0].length; j++) {
- // loop through to get the depth values
- for (int k = 0; k < ctrl[0][0].length; k++) {
- pts[row + col + k] = ctrl[i][j][k];
- }
- col += colIncr;
- }
- row += rowIncr;
- }
- return pts;
- }
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(final Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(12);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(5);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(12);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(5);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(12);
- zMove.setMinimum(0);
- zMove.setThumb(2);
- zMove.setPageIncrement(2);
- zMove.setSelection(5);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 30;
- }
- });
-
- Group rotationGroup = new Group(composite, SWT.NONE);
- rotationGroup.setText("Rotation");
- rotationGroup.setLayout(new GridLayout(2, false));
-
- new Label(rotationGroup, SWT.NONE).setText("X:");
- final Slider xRotation = new Slider(rotationGroup, SWT.NONE);
- xRotation.setIncrement(10);
- xRotation.setMaximum(362);
- xRotation.setMinimum(0);
- xRotation.setThumb(2);
- xRotation.setPageIncrement(20);
- xRotation.setSelection(330);
- xRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xRot = xRotation.getSelection();
- }
- });
-
- new Label(rotationGroup, SWT.NONE).setText("Y:");
- final Slider yRotation = new Slider(rotationGroup, SWT.NONE);
- yRotation.setIncrement(10);
- yRotation.setMaximum(362);
- yRotation.setMinimum(0);
- yRotation.setThumb(2);
- yRotation.setPageIncrement(20);
- yRotation.setSelection(0);
- yRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yRot = yRotation.getSelection();
- }
- });
-
- new Label(rotationGroup, SWT.NONE).setText("Z:");
- final Slider zRotation = new Slider(rotationGroup, SWT.NONE);
- zRotation.setIncrement(10);
- zRotation.setMaximum(362);
- zRotation.setMinimum(0);
- zRotation.setThumb(2);
- zRotation.setPageIncrement(20);
- zRotation.setSelection(0);
- zRotation.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zRot = zRotation.getSelection();
- }
- });
-
- new Label(composite, SWT.NONE).setText("Sampling Tolerance:");
- final Slider sSlider = new Slider(composite, SWT.NONE);
- sSlider.setIncrement(1);
- sSlider.setMaximum(101);
- sSlider.setMinimum(0);
- sSlider.setThumb(2);
- sSlider.setPageIncrement(2);
- sSlider.setSelection(75);
- sSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- GLU.gluNurbsProperty(
- nurb,
- GLU.GLU_SAMPLING_TOLERANCE,
- sSlider.getSelection() + 1);
- }
- });
-
- final Button fillButton = new Button(composite, SWT.CHECK);
- fillButton.setText("Fill");
- fillButton.setSelection(true);
- fillButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (fillButton.getSelection()) {
- GLU.gluNurbsProperty(
- nurb,
- GLU.GLU_DISPLAY_MODE,
- GLU.GLU_FILL);
- } else {
- GLU.gluNurbsProperty(
- nurb,
- GLU.GLU_DISPLAY_MODE,
- GLU.GLU_OUTLINE_POLYGON);
- }
- }
- });
-
- ColorSelectionGroup colorGroup =
- new ColorSelectionGroup(composite, SWT.NONE);
- colorGroup.setText("Foreground color");
- colorGroup.addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteNurbsRenderer(nurb);
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Nurb";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- // set up material color which helps show curves
- float mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
- float mat_shininess[] = { 100.0f };
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, mat_specular);
- GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, mat_shininess);
- GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
-
- GL.glEnable(GL.GL_LIGHTING);
- GL.glEnable(GL.GL_LIGHT0);
- GL.glEnable(GL.GL_COLOR_MATERIAL);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glEnable(GL.GL_AUTO_NORMAL);
- GL.glEnable(GL.GL_NORMALIZE);
-
- nurb = GLU.gluNewNurbsRenderer();
-
- GLU.gluNurbsProperty(
- nurb,
- GLU.GLU_SAMPLING_METHOD,
- GLU.GLU_PATH_LENGTH);
- // sampling tolerance is specific for GLU.GLU_PATH_LENGTH
- GLU.gluNurbsProperty(nurb, GLU.GLU_SAMPLING_TOLERANCE, 75.0f);
- GLU.gluNurbsProperty(nurb, GLU.GLU_DISPLAY_MODE, GLU.GLU_FILL);
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- // do translation and rotation
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f);
- GL.glRotatef(yRot, 0.0f, 1.0f, 0.0f);
- GL.glRotatef(zRot, 0.0f, 0.0f, 1.0f);
- // define nurbs surface
- float[] knots = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f };
- GLU.gluBeginSurface(nurb);
- GLU.gluNurbsSurface(
- nurb, 8, knots, 8, knots, 12, 3,
- convert(buildNurb()), 4, 4, GL.GL_MAP2_VERTEX_3);
- GLU.gluEndSurface(nurb);
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ObjectsTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ObjectsTab.java
deleted file mode 100644
index 3ef288e451..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ObjectsTab.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class ObjectsTab extends OpenGLTab {
- private class Shape {
- private String name;
- private int index;
- /**
- * Constructor.
- *
- * @param name the display name of this shape
- * @param index the display list index corresponding to this shape
- */
- Shape(String name, int index) {
- super();
- this.index = index;
- this.name = name;
- }
- void dispose() {
- GL.glDeleteLists(index, 1);
- }
- void draw() {
- GL.glCallList(index);
- }
- String getName() {
- return name;
- }
- }
-
- private Shape[] shapes;
- private Shape currentShape;
- private float xRot = 0.0f, yRot = 0.0f;
- private boolean fill = true;
- private int quadratic;
- private final static int SLEEP_LENGTH = 50;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(final Composite composite) {
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- Composite controls = new Composite(composite, SWT.NONE);
- controls.setLayout(layout);
-
- new Label(controls, SWT.NONE).setText("Object:");
- final Combo objectsCombo = new Combo(controls, SWT.READ_ONLY);
- for (int i = 0; i < shapes.length; i++) {
- objectsCombo.add(shapes[i].getName());
- }
- objectsCombo.select(0);
- objectsCombo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- currentShape = shapes[objectsCombo.getSelectionIndex()];
- }
- });
-
- final Button fillToggleButton = new Button(controls, SWT.CHECK);
- fillToggleButton.setText("Fill");
- fillToggleButton.setSelection(true);
- fillToggleButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- fill = fillToggleButton.getSelection();
- }
- });
-
- ColorSelectionGroup colorGroup =
- new ColorSelectionGroup(composite, SWT.NONE);
- colorGroup.setText("Foreground color");
- colorGroup.addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteQuadric(quadratic);
- for (int i = 0; i < shapes.length; i++) {
- shapes [i].dispose();
- }
- }
-
- /**
- * Creates a circle centered at 0,0 in the viewport.
- *
- * @param radius
- * @param xShrink
- * @param yShrink
- */
- void drawCircle(float radius, float xShrink, float yShrink) {
- GL.glBegin(GL.GL_POLYGON);
- float dia = (float) 2.0 * (float) Math.PI;
- for (float angle = 0.0f; angle <= dia; angle += 0.1f) {
- GL.glVertex2d(radius * Math.cos(angle), radius * Math.sin(angle));
- }
- GL.glEnd();
- }
-
- /**
- * Creates a cube centered at 0,0 in the viewport.
- *
- * @param width
- * @param height
- * @param depth
- */
- void drawCube(float width, float height, float depth) {
- GL.glBegin(GL.GL_QUADS);
- // front
- GL.glVertex3f(-width, -height, depth); // bottom left
- GL.glVertex3f(width, -height, depth); // bottom right
- GL.glVertex3f(width, height, depth); // top right
- GL.glVertex3f(-width, height, depth); // top left
- // back
- GL.glVertex3f(-width, -height, -depth); // bottom left
- GL.glVertex3f(width, -height, -depth); // bottom right
- GL.glVertex3f(width, height, -depth); // top right
- GL.glVertex3f(-width, height, -depth); // top left
- // left
- GL.glVertex3f(-width, -height, -depth); // bottom left
- GL.glVertex3f(-width, -height, depth); // bottom right
- GL.glVertex3f(-width, height, depth); // top right
- GL.glVertex3f(-width, height, -depth); // top left
- // right
- GL.glVertex3f(width, -height, depth); // bottom left
- GL.glVertex3f(width, -height, -depth); // bottom right
- GL.glVertex3f(width, height, -depth); // top right
- GL.glVertex3f(width, height, depth); // top left
- // top
- GL.glVertex3f(width, height, -depth); // back right
- GL.glVertex3f(-width, height, -depth); // back left
- GL.glVertex3f(-width, height, depth); // front left
- GL.glVertex3f(width, height, depth); // front right
- // bottom
- GL.glVertex3f(width, -height, depth); // front right
- GL.glVertex3f(-width, -height, depth); // front left
- GL.glVertex3f(-width, -height, -depth); // back left
- GL.glVertex3f(width, -height, -depth); // back right
- GL.glEnd();
- }
-
- /**
- * Creates a pyramid centered at 0,0 in the viewport.
- *
- * @param width
- * @param height
- * @param depth
- */
- void drawPyramid(float width, float height, float depth) {
- GL.glBegin(GL.GL_TRIANGLES);
- // front
- GL.glVertex3f(0.0f, height, 0.0f); // top
- GL.glVertex3f(-width, -height, depth); // left
- GL.glVertex3f(width, -height, depth); // right
- // left
- GL.glVertex3f(0.0f, height, 0.0f); // top
- GL.glVertex3f(-width, -height, -depth); // left
- GL.glVertex3f(-width, -height, depth); // right
- // front
- GL.glVertex3f(-width, -height, -depth); // left
- GL.glVertex3f(0.0f, height, 0.0f); // top
- GL.glVertex3f(width, -height, -depth); // right
- // right
- GL.glVertex3f(0.0f, height, 0.0f); // top
- GL.glVertex3f(width, -height, depth); // left
- GL.glVertex3f(width, -height, -depth); // right
- GL.glEnd();
- GL.glBegin(GL.GL_QUADS);
- // bottom
- GL.glVertex3f(-width, -height, depth); // front left
- GL.glVertex3f(-width, -height, -depth); // back left
- GL.glVertex3f(width, -height, -depth); // back right
- GL.glVertex3f(width, -height, depth); // front right
- GL.glEnd();
- }
-
- /**
- * Creates a square centered at 0,0 in the viewport.
- *
- * @param width
- * @param height
- */
- void drawSquare(float width, float height) {
- GL.glBegin(GL.GL_QUADS);
- GL.glVertex3f(-width, -height, 0.0f); // bottom left
- GL.glVertex3f(width, -height, 0.0f); // bottom right
- GL.glVertex3f(width, height, 0.0f); // top right
- GL.glVertex3f(-width, height, 0.0f); // top left
- GL.glEnd();
- }
-
- /**
- * This method is from glut_shapes.c .
- *
- * @param r
- * @param R
- * @param nsides
- * @param rings
- */
- void drawTorus(float r, float R, int nsides, int rings) {
- float ringDelta = 2.0f * (float) Math.PI / rings;
- float sideDelta = 2.0f * (float) Math.PI / nsides;
- float theta = 0.0f;
- float cosTheta = 1.0f;
- float sinTheta = 0.0f;
-
- for (int i = rings - 1; i >= 0; i--) {
- float theta1 = theta + ringDelta;
- float cosTheta1 = (float) Math.cos(theta1);
- float sinTheta1 = (float) Math.sin(theta1);
- GL.glBegin(GL.GL_QUAD_STRIP);
- float phi = 0.0f;
-
- for (int j = nsides; j >= 0; j--) {
- phi += sideDelta;
- float cosPhi = (float) Math.cos(phi);
- float sinPhi = (float) Math.sin(phi);
- float dist = R + r * cosPhi;
- GL.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
- GL.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
- GL.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
- GL.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
- }
-
- GL.glEnd();
- theta = theta1;
- cosTheta = cosTheta1;
- sinTheta = sinTheta1;
- }
- }
-
- /**
- * Creates a triangle centered at 0,0 in the viewport.
- *
- * @param width
- * @param height
- */
- void drawTriangle(float width, float height) {
- GL.glBegin(GL.GL_TRIANGLES);
- GL.glVertex3f(0.0f, height, 0.0f); // middle
- GL.glVertex3f(-width, -height, 0.0f); // left
- GL.glVertex3f(width, -height, 0.0f); // right
- GL.glEnd();
- }
-
- /**
- * @see OpenGLTab#getSleepLength()
- */
- int getSleepLength() {
- return SLEEP_LENGTH;
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Objects";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
- GL.glClearDepth(1.0);
- quadratic = GLU.gluNewQuadric();
- GLU.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
- GL.glLineWidth(2);
-
- GL.glEnable(GL.GL_DEPTH_TEST);
-
- // create the display lists and shapes
- shapes = new Shape[11];
- int index = 1;
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawTriangle(2.0f, 2.0f);
- GL.glEndList();
- shapes[0] = new Shape("Triangle", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawPyramid(2.0f, 2.0f, 2.0f);
- GL.glEndList();
- shapes[1] = new Shape("Pyramid", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawSquare(2.0f, 2.0f);
- GL.glEndList();
- shapes[2] = new Shape("Square", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawCube(2.0f, 2.0f, 2.0f);
- GL.glEndList();
- shapes[3] = new Shape("Cube", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawCircle(2.0f, 0.0f, 0.0f);
- GL.glEndList();
- shapes[4] = new Shape("Circle", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- GLU.gluPartialDisk(quadratic, 0.5, 2.0, 18, 18, 90, 125);
- GL.glEndList();
- shapes[5] = new Shape("Partial Disk", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- GLU.gluDisk(quadratic, 0.5, 2.0, 18, 18);
- GL.glEndList();
- shapes[6] = new Shape("Disk", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- drawTorus(1, 2, 18, 18);
- GL.glEndList();
- shapes[7] = new Shape("Torus", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- GLU.gluSphere(quadratic, 2.0, 18, 18);
- GL.glEndList();
- shapes[8] = new Shape("Sphere", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- GLU.gluCylinder(quadratic, 2.0, 2.0, 4, 18, 18);
- GL.glEndList();
- shapes[9] = new Shape("Cylinder", index++);
-
- GL.glNewList(index, GL.GL_COMPILE);
- GLU.gluCylinder(quadratic, 0, 2.0, 4, 18, 18);
- GL.glEndList();
- shapes[10] = new Shape("Cone", index++);
-
- currentShape = shapes[0];
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(0.0f, 0.0f, -14.0f);
- // rotate around X and Y axis
- GL.glRotatef(yRot, 0.0f, 1.0f, 0.0f);
- GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f);
- // sets polygon fill mode
- if (fill) {
- GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
- } else {
- GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
- }
- currentShape.draw();
- yRot += 1.5;
- xRot += 1.5;
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OpenGLExample.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OpenGLExample.java
deleted file mode 100644
index b3fced6f1b..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OpenGLExample.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class OpenGLExample {
- private TabFolder tabFolder;
- private OpenGLTab[] tabs;
- private int sleep;
-
- /**
- * Renders the scene of the current tab.
- */
- void display() {
- int index = tabFolder.getSelectionIndex();
- tabs[index].render();
- tabs[index].swap();
- }
-
- /**
- * Disposes of all contained tabs.
- */
- void dispose() {
- tabFolder = null;
- for (int i = 0; i < tabs.length; i++) {
- tabs[i].dispose();
- }
- }
-
- /**
- * Runs the OpenGL example
- */
- void run() {
- final Display display = new Display();
- final Shell shell =
- new Shell(display, SWT.SHELL_TRIM | SWT.NO_BACKGROUND);
- shell.setLayout(new FillLayout());
-
- tabFolder = new TabFolder(shell, SWT.NONE);
- tabs =
- new OpenGLTab[] {
- new AntialiasingTab(),
- new AreaTab(),
- new BezierTab(),
- new BitmapTextTab(),
- new FogTab(),
- new GradientTab(),
- new LightTab(),
- new NurbTab(),
- new ObjectsTab(),
- new OutlineTextTab(), /* outline tab is win32-only */
- new ReflectionTab(),
- new StencilTab(),
- new TextureTab(),
- new TransparencyTab()};
-
- for (int i = 0; i < tabs.length; i++) {
- TabItem item = new TabItem(tabFolder, SWT.NONE);
- item.setText(tabs[i].getTabText());
- item.setControl(tabs[i].createTabFolderPage(tabFolder));
- }
-
- tabFolder.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- OpenGLTab tab = tabs[tabFolder.getSelectionIndex()];
- tab.setCurrent();
- sleep = tab.getSleepLength();
- }
- });
- if (tabs.length > 0) {
- tabs[0].setCurrent();
- sleep = tabs[0].getSleepLength();
- }
-
- shell.setText("OpenGL Example");
- Runnable timer = new Runnable() {
- public void run() {
- if (shell.isDisposed()) return;
- display();
- display.timerExec(sleep, this);
- }
- };
- timer.run();
- shell.addListener(SWT.Dispose, new Listener() {
- public void handleEvent(Event e) {
- dispose();
- }
- });
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-
- /**
- * Invokes as a standalone program.
- */
- public static void main(String[] args) {
- new OpenGLExample().run();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OpenGLTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OpenGLTab.java
deleted file mode 100644
index d8523b9e0c..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OpenGLTab.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-
-/**
- * OpenGLTab is the abstract superclass of every page
- * in the example's tab folder. Each page in the tab folder
- * displays a different example.
- *
- * An OpenGLTab itself is not a control but instead provides a hierarchy
- * with which to share code that is common to every page in the folder.
- */
-abstract class OpenGLTab {
- private Canvas glCanvas;
- private Composite tabFolderPage;
- private GLContext context;
- private boolean stencilSupport;
- private final static int DEFAULT_SLEEP_LENGTH = 100;
-
- /**
- * Creates this tab's controls. Subclasses must override.
- *
- * @param composite the parent composite
- */
- abstract void createControls(Composite composite);
-
- /**
- * Creates the OpenGL canvas on which all drawing is done.
- */
- void createOpenGLContext() {
- context = new GLContext(glCanvas);
- setCurrent();
- setupViewingArea();
- }
-
- /**
- * Creates the tab folder page.
- *
- * @param tabFolder the parent tab folder
- * @return the new page
- */
- Composite createTabFolderPage(TabFolder tabFolder) {
- tabFolderPage = new Composite(tabFolder, SWT.NONE);
- tabFolderPage.setLayout(new GridLayout(2, false));
-
- GridData gridData = new GridData();
- gridData.heightHint = 400;
- gridData.widthHint = 400;
- gridData.verticalAlignment = GridData.BEGINNING;
- glCanvas = new Canvas(tabFolderPage, SWT.NONE);
- glCanvas.setLayout(new GridLayout());
- glCanvas.setLayoutData(gridData);
- glCanvas.setSize(400, 400); // needed for windows
-
- gridData = new GridData();
- gridData.verticalAlignment = GridData.BEGINNING;
- Composite controlComposite = new Composite(tabFolderPage, SWT.NONE);
- controlComposite.setLayout(new GridLayout());
- controlComposite.setLayoutData(gridData);
-
- // create the OpenGL Screen and controls
- createOpenGLContext();
-
- // determine if native stencil support is available
- int[] param = new int[1];
- GL.glGetIntegerv(GL.GL_STENCIL_BITS, param);
- stencilSupport = param[0] != 0;
-
- init();
-
- if (!isStencilSupportNeeded() || hasStencilSupport()) {
- createControls(controlComposite);
- } else {
- Label label = new Label(controlComposite, SWT.NONE);
- label.setText("This tab requires native stencil support.");
- }
-
- return tabFolderPage;
- }
-
- /**
- * Disposes all resources allocated by this tab.
- */
- void dispose() {
- context.dispose();
- }
-
- /**
- * Returns the context for this tab.
- *
- * @return GLContext
- */
- GLContext getContext() {
- return context;
- }
-
- /**
- * Returns the glCanvas for this tab.
- *
- * @return Canvas
- */
- Canvas getGlCanvas() {
- return glCanvas;
- }
-
- /**
- * Returns the length of time in milliseconds that the example
- * should sleep between animation redraws. As this length
- * increases, user responsiveness increases and the frequency of
- * animation redraws decreases. Subclasses with moving animations
- * may wish to override this default implementation to return a
- * smaller value if their animations do not occur frequently enough.
- *
- * @return the length of time in milliseconds to sleep between redraws
- */
- int getSleepLength() {
- return DEFAULT_SLEEP_LENGTH;
- }
-
- /**
- * Returns the text for this tab. Subclasses must override.
- *
- * @return the text for the tab item
- */
- abstract String getTabText();
-
- /**
- * Returns whether this machine has native stencils support.
- *
- * @return boolean
- */
- boolean hasStencilSupport() {
- return stencilSupport;
- }
-
- /**
- * Initialize OpenGL resources for this tab. Subclasses must override.
- */
- abstract void init();
-
- /**
- * Loads a texture.
- *
- * @param context
- * @param fileName
- * @param index
- * @param texture[]
- */
- static void loadTexture(GLContext context, String fileName, int index, int[] texture) {
- GL.glBindTexture(GL.GL_TEXTURE_2D, texture[index]);
- ImageData source =
- new ImageData(OpenGLTab.class.getResourceAsStream(fileName));
- Image image = new Image(Display.getCurrent(), source);
- Image newImage = new Image(Display.getCurrent(), 256, 256);
- GC gc = new GC(newImage);
- gc.drawImage(image, 0, 0, source.width, source.height, 0, 0, 256, 256);
- source = newImage.getImageData();
- gc.dispose();
- source = context.convertImageData(source);
- newImage.dispose();
- image.dispose();
- GL.glTexImage2D(
- GL.GL_TEXTURE_2D, 0, 3,
- source.width, source.height, 0,
- GL.GL_RGB, GL.GL_UNSIGNED_BYTE, source.data);
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
- GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
- }
-
- /**
- * Renders this tab.
- */
- void render() {
- if (!isStencilSupportNeeded() || hasStencilSupport()) {
- renderScene();
- } else {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT);
- }
- }
-
- /**
- * Renders the scene for this tab. Subclasses must override.
- */
- abstract void renderScene();
-
- /**
- * Returns whether this tab requires stencil support in order to display
- * properly. Subclasses may wish to override this method.
- *
- * @return boolean
- */
- boolean isStencilSupportNeeded() {
- return false;
- }
-
- /**
- * Sets this rendering context to be current.
- */
- void setCurrent() {
- context.setCurrent();
- }
-
- /**
- * Sets up the viewing area for the OpenGL screen. The default
- * behavior is to use a perspective view, but there also exist frustrum
- * and ortho views. Subclasses may wish to override this method.
- */
- void setupViewingArea() {
- Rectangle rect = glCanvas.getClientArea();
- int width = rect.width;
- int height = rect.height;
- height = Math.max(height, 1);
- GL.glViewport(0, 0, width, height);
- GL.glMatrixMode(GL.GL_PROJECTION); // select the projection matrix
- GL.glLoadIdentity(); // reset the projection matrix
- float fAspect = (float) width / (float) height;
- GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
- GL.glMatrixMode(GL.GL_MODELVIEW); // select the modelview matrix
- GL.glLoadIdentity();
- }
-
- /**
- * Swaps the buffers.
- */
- void swap() {
- context.swapBuffers();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java
deleted file mode 100644
index 7dc74a82e3..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class OutlineTextTab extends OpenGLTab {
- private Text messageText;
- private FontData fontData;
- private float[] textColor = { 1.0f, 0.0f, 0.0f };
- private boolean fill = true;
- private float extrude = 0.0f;
- private float xPos = 0.0f, yPos = 0.0f, zPos = -10.0f;
- private float xRot = 0.0f;
- private int listIndexBase;
- private final static int LIST_INDEX_SIZE = 256;
- private final static int DEFAULT_FONT_SIZE = 24;
- private final static String DEFAULT_FONT_NAME = "Arial";
- private final static int SLEEP_LENGTH = 50;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(final Composite composite) {
- if (!SWT.getPlatform().startsWith("win32")) {
- new Label(composite, SWT.NONE).setText("This tab requires win32.");
- return;
- }
-
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(22);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(10);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(22);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(10);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 10;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(22);
- zMove.setMinimum(0);
- zMove.setThumb(2);
- zMove.setPageIncrement(2);
- zMove.setSelection(10);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 20;
- }
- });
-
- Composite textGroup = new Composite(composite,SWT.NONE);
- GridLayout layout = new GridLayout(2,false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- textGroup.setLayout(layout);
- textGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- new Label(textGroup, SWT.NONE).setText("Text:");
- messageText = new Text(textGroup, SWT.BORDER);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.grabExcessHorizontalSpace = true;
- messageText.setLayoutData(data);
- messageText.setText("OpenGL - SWT");
-
- new Label(composite, SWT.NONE).setText("Extrude:");
- final Slider extrudeSlider = new Slider(composite, SWT.NONE);
- extrudeSlider.setIncrement(1);
- extrudeSlider.setMaximum(22);
- extrudeSlider.setMinimum(0);
- extrudeSlider.setThumb(2);
- extrudeSlider.setPageIncrement(2);
- extrudeSlider.setSelection(0);
- extrudeSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- extrude = (float) extrudeSlider.getSelection() / 10;
- getContext().loadOutlineFont(
- fontData, extrudeSlider.getDisplay(),
- listIndexBase, 0, 255, 0.0f, extrude,
- fill ? GL.GL_POLYGON : GL.GL_LINE,
- null);
- }
- });
-
- final Button fontSelectButton = new Button(composite, SWT.NONE);
- fontSelectButton.setText("Set Font");
- final ColorSelectionGroup colorGroup =
- new ColorSelectionGroup(composite, SWT.NONE);
- colorGroup.setText("Text color");
- colorGroup.addColorSelectionListener(new IColorSelectionListener() {
- public void handleColorSelection(RGB rgb) {
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- }
- });
-
- fontSelectButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- FontDialog fontDialog = new FontDialog(fontSelectButton.getShell());
- fontDialog.setText("Choose Font Options");
- double[] currentColor = new double[4];
- GL.glGetDoublev(GL.GL_CURRENT_COLOR, currentColor);
- fontDialog.setRGB(
- new RGB(
- (int) currentColor[0] * 255,
- (int) currentColor[1] * 255,
- (int) currentColor[2] * 255));
- fontDialog.setFontList(new FontData[] {fontData});
- FontData result = fontDialog.open();
- if (result != null) {
- fontData = result;
- RGB rgb = fontDialog.getRGB();
- GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue);
- colorGroup.setRGB(rgb);
- getContext().loadOutlineFont(
- fontData, fontSelectButton.getDisplay(),
- listIndexBase, 0, 255, 0.0f, extrude,
- fill ? GL.GL_POLYGON : GL.GL_LINE,
- null);
- }
- }
- });
-
- final Button fillButton = new Button(composite, SWT.CHECK);
- fillButton.setText("Fill");
- fillButton.setSelection(true);
- fillButton.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- fill = fillButton.getSelection();
- getContext().loadOutlineFont(
- fontData, fillButton.getDisplay(),
- listIndexBase, 0, 255, 0.0f, extrude,
- fill ? GL.GL_POLYGON : GL.GL_LINE,
- null);
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GL.glDeleteLists(listIndexBase, LIST_INDEX_SIZE);
- }
-
- /**
- * Draws the text to the screen
- *
- * @param string the text to draw
- */
- void drawText(String string) {
- char[] stringChars = string.toCharArray();
- int[] text = new int[stringChars.length];
- for (int i = 0; i < text.length; i++) {
- text[i] = (int) stringChars[i];
- }
- GL.glPushAttrib(GL.GL_LIST_BIT);
- GL.glListBase(listIndexBase);
- GL.glCallLists(text.length, GL.GL_UNSIGNED_INT, text);
- GL.glPopAttrib();
- }
-
- /**
- * @see OpenGLTab#getSleepLength()
- */
- int getSleepLength() {
- return SLEEP_LENGTH;
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Outline Text";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glColor3fv(textColor);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glEnable(GL.GL_BLEND);
- // build the initial font
- listIndexBase = GL.glGenLists(LIST_INDEX_SIZE);
- fontData = new FontData();
- fontData.setHeight(DEFAULT_FONT_SIZE);
- fontData.setName(DEFAULT_FONT_NAME);
- getContext().loadOutlineFont(
- fontData, getGlCanvas().getDisplay(),
- listIndexBase, 0, 255, 0f, extrude,
- fill ? GL.GL_POLYGON : GL.GL_LINE,
- null);
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f); // rotate on X axis
- // use GL.glScalef to change size since outline fonts
- // don't support size
- float size = (float) fontData.getHeight() / 24;
- GL.glScalef(size, size, 1.0f);
- // draw the text, assuming that we're running on win32
- if (messageText != null) drawText(messageText.getText());
- xRot += 1.2f;
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ReflectionTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ReflectionTab.java
deleted file mode 100644
index 883bda00f6..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/ReflectionTab.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class ReflectionTab extends OpenGLTab {
- private float ballY = 0.0f;
- private float ballZ = 1.6666666f;
- private float ballX = 0.0f;
- private float ballRot = 0.0f;
- private float cubeX = 2.5f;
- private float cubeY = -2.0f;
- private float cubeZ = 2.0f;
- private float xPos = 0.0f;
- private float yPos = 0.0f;
- private float zPos = 22.0f;
- private float ballRotSpeed = 0.0f;
- private int quadratic;
- private int[] textures = new int[3];
- private final static int
- LIST_INDEX_BALL = 1,LIST_INDEX_BOX = 2,
- LIST_INDEX_MIRROR = 3, LIST_INDEX_ROOM = 4;
- private final static int
- TEXTURE_INDEX_BALL = 0, TEXTURE_INDEX_FLOOR = 1,
- TEXTURE_INDEX_BOX = 2;
- private final static String[] IMAGES = {
- "images/Ball.jpg", "images/Floor.jpg", "images/Box.bmp" };
- private final static int SLEEP_LENGTH = 50;
-
- /**
- * Draws the ball
- */
- void createBall() {
- GL.glNewList(LIST_INDEX_BALL, GL.GL_COMPILE);
- GL.glColor3f(1.0f, 1.0f, 1.0f);
- GL.glBindTexture(GL.GL_TEXTURE_2D, textures[TEXTURE_INDEX_BALL]);
- GLU.gluSphere(quadratic, 0.35f, 32, 16);
- GL.glDisable(GL.GL_BLEND);
- GL.glEndList();
- }
-
- /**
- * Draws the box
- */
- void createBox() {
- float size = 1.0f;
- GL.glNewList(LIST_INDEX_BOX, GL.GL_COMPILE);
- GL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glBindTexture(GL.GL_TEXTURE_2D, textures[TEXTURE_INDEX_BOX]);
- GL.glBegin(GL.GL_QUADS);
- // front
- GL.glNormal3f(0.0f, 0.0f, 1.0f);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-size, -size, size);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(size, -size, size);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(size, size, size);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-size, size, size);
- // back
- GL.glNormal3f(0.0f, 0.0f, -1.0f);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-size, -size, -size);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(size, -size, -size);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(size, size, -size);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-size, size, -size);
- // left
- GL.glNormal3f(-1.0f, 0.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-size, -size, -size);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(-size, -size, size);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(-size, size, size);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-size, size, -size);
- // right
- GL.glNormal3f(1.0f, 0.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(size, -size, -size);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(size, -size, size);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(size, size, size);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(size, size, -size);
- // top
- GL.glNormal3f(0.0f, 1.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(size, size, -size);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(-size, size, -size);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(-size, size, size);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(size, size, size);
- // bottom
- GL.glNormal3f(0.0f, -1.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(size, -size, -size);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(-size, -size, -size);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(-size, -size, size);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(size, -size, size);
- GL.glEnd();
- GL.glEndList();
- }
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group ballTranslation = new Group(composite, SWT.NONE);
- ballTranslation.setLayout(new GridLayout(2, false));
- ballTranslation.setText("Ball Translation");
-
- new Label(ballTranslation, SWT.NONE).setText("X:");
- final Slider ballXPosSlider = new Slider(ballTranslation, SWT.NONE);
- ballXPosSlider.setIncrement(1);
- ballXPosSlider.setMaximum(38);
- ballXPosSlider.setMinimum(0);
- ballXPosSlider.setThumb(2);
- ballXPosSlider.setPageIncrement(2);
- ballXPosSlider.setSelection(18);
- ballXPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- ballX = (float) (ballXPosSlider.getSelection() - 18) / 5;
- }
- });
-
- new Label(ballTranslation, SWT.NONE).setText("Y:");
- final Slider ballYPosSlider = new Slider(ballTranslation, SWT.NONE);
- ballYPosSlider.setIncrement(1);
- ballYPosSlider.setMaximum(38);
- ballYPosSlider.setMinimum(0);
- ballYPosSlider.setThumb(2);
- ballYPosSlider.setPageIncrement(2);
- ballYPosSlider.setSelection(18);
- ballYPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- ballY = (float) (ballYPosSlider.getSelection() - 18) / 5;
- }
- });
-
- new Label(ballTranslation, SWT.NONE).setText("Z:");
- final Slider ballZPosSlider = new Slider(ballTranslation, SWT.NONE);
- ballZPosSlider.setIncrement(1);
- ballZPosSlider.setMaximum(24);
- ballZPosSlider.setMinimum(0);
- ballZPosSlider.setThumb(1);
- ballZPosSlider.setPageIncrement(2);
- ballZPosSlider.setSelection(4);
- ballZPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- ballZ = (float) (ballZPosSlider.getSelection() + 1) / 3;
- }
- });
-
- Group cubeTranslation = new Group(composite, SWT.NONE);
- cubeTranslation.setLayout(new GridLayout(2, false));
- cubeTranslation.setText("Cube Translation");
-
- new Label(cubeTranslation, SWT.NONE).setText("X:");
- final Slider cubeXPosSlider = new Slider(cubeTranslation, SWT.NONE);
- cubeXPosSlider.setIncrement(1);
- cubeXPosSlider.setMaximum(14);
- cubeXPosSlider.setMinimum(0);
- cubeXPosSlider.setThumb(2);
- cubeXPosSlider.setPageIncrement(2);
- cubeXPosSlider.setSelection(11);
- cubeXPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- cubeX = (float) (cubeXPosSlider.getSelection() - 6) / 2;
- }
- });
-
- new Label(cubeTranslation, SWT.NONE).setText("Y:");
- final Slider cubeYPosSlider = new Slider(cubeTranslation, SWT.NONE);
- cubeYPosSlider.setIncrement(1);
- cubeYPosSlider.setMaximum(14);
- cubeYPosSlider.setMinimum(0);
- cubeYPosSlider.setThumb(2);
- cubeYPosSlider.setPageIncrement(2);
- cubeYPosSlider.setSelection(2);
- cubeYPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- cubeY = (float) (cubeYPosSlider.getSelection() - 6) / 2;
- }
- });
-
- new Label(cubeTranslation, SWT.NONE).setText("Z:");
- final Slider cubeZPosSlider = new Slider(cubeTranslation, SWT.NONE);
- cubeZPosSlider.setIncrement(1);
- cubeZPosSlider.setMaximum(10);
- cubeZPosSlider.setMinimum(1);
- cubeZPosSlider.setThumb(1);
- cubeZPosSlider.setPageIncrement(2);
- cubeZPosSlider.setSelection(2);
- cubeZPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- cubeZ = (float) (cubeZPosSlider.getSelection() + 2) / 2;
- }
- });
-
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setLayout(new GridLayout(2, false));
- movementGroup.setText("Room Rotation");
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider screenXPosSlider = new Slider(movementGroup, SWT.NONE);
- screenXPosSlider.setIncrement(1);
- screenXPosSlider.setMaximum(42);
- screenXPosSlider.setMinimum(0);
- screenXPosSlider.setThumb(2);
- screenXPosSlider.setPageIncrement(2);
- screenXPosSlider.setSelection(20);
- screenXPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = screenXPosSlider.getSelection() - 20;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider screenYPosSlider = new Slider(movementGroup, SWT.NONE);
- screenYPosSlider.setIncrement(1);
- screenYPosSlider.setMaximum(42);
- screenYPosSlider.setMinimum(0);
- screenYPosSlider.setThumb(2);
- screenYPosSlider.setPageIncrement(2);
- screenYPosSlider.setSelection(20);
- screenYPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = screenYPosSlider.getSelection() - 20;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider screenZPosSlider = new Slider(movementGroup, SWT.NONE);
- screenZPosSlider.setIncrement(1);
- screenZPosSlider.setMaximum(42);
- screenZPosSlider.setMinimum(0);
- screenZPosSlider.setThumb(2);
- screenZPosSlider.setPageIncrement(2);
- screenZPosSlider.setSelection(20);
- screenZPosSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = screenZPosSlider.getSelection() + 2;
- }
- });
-
- new Label(composite, SWT.NONE).setText("Ball Rotation Speed:");
- final Slider ballRotSlider = new Slider(composite, SWT.NONE);
- ballRotSlider.setIncrement(1);
- ballRotSlider.setMaximum(22);
- ballRotSlider.setMinimum(0);
- ballRotSlider.setThumb(2);
- ballRotSlider.setPageIncrement(2);
- ballRotSlider.setSelection(0);
- ballRotSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- ballRotSpeed = ballRotSlider.getSelection();
- }
- });
- }
-
- /**
- * Draws the mirror
- */
- void createMirror() {
- GL.glNewList(LIST_INDEX_MIRROR, GL.GL_COMPILE);
- GL.glDisable(GL.GL_TEXTURE_2D);
- GL.glColor4f(1.0f, 1.0f, 1.0f, 0.4f);
- GL.glNormal3f(0.0f, 0.0f, 1.0f);
- GL.glBegin(GL.GL_QUADS);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-2.0f, 2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(-2.0f, -2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(2.0f, -2.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(2.0f, 2.0f, 0.0f);
- GL.glEnd();
- GL.glEnable(GL.GL_TEXTURE_2D);
- GL.glEndList();
- }
-
- /**
- * Draws the room
- */
- void createRoom() {
- GL.glNewList(LIST_INDEX_ROOM, GL.GL_COMPILE);
- GL.glDisable(GL.GL_TEXTURE_2D);
- GL.glBegin(GL.GL_QUADS);
- // left wall
- GL.glNormal3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(-4.0f, 4.0f, 0.0f);
- GL.glVertex3f(-4.0f, 4.0f, 6.0f);
- GL.glVertex3f(-4.0f, -4.0f, 6.0f);
- GL.glVertex3f(-4.0f, -4.0f, 0.0f);
- // right wall
- GL.glNormal3f(-1.0f, 0.0f, 01.0f);
- GL.glVertex3f(4.0f, 4.0f, 0.0f);
- GL.glVertex3f(4.0f, 4.0f, 6.0f);
- GL.glVertex3f(4.0f, -4.0f, 6.0f);
- GL.glVertex3f(4.0f, -4.0f, 0.0f);
- // ceiling
- GL.glNormal3f(0.0f, -1.0f, 0.0f);
- GL.glColor3f(0.9f, 0.9f, 0.9f);
- GL.glVertex3f(-4.0f, 4.0f, 0.0f);
- GL.glVertex3f(-4.0f, 4.0f, 6.0f);
- GL.glVertex3f(4.0f, 4.0f, 6.0f);
- GL.glVertex3f(4.0f, 4.0f, 0.0f);
- GL.glEnd();
- // back wall with triangle strip to illiminate t-intersections
- GL.glBegin(GL.GL_TRIANGLE_STRIP);
- GL.glNormal3f(0.0f, 0.0f, 1.0f);
- GL.glVertex3d(-4.0, -4.0, 0.0);
- GL.glVertex3d(-2.2, -4.0, 0.0);
- GL.glVertex3d(-2.2, -2.2, 0.0);
- GL.glVertex3d(2.2, -4.0, 0.0);
- GL.glVertex3d(2.2, -2.2, 0.0);
- GL.glVertex3d(4.0, -4.0, 0.0);
- GL.glVertex3d(2.2, -2.2, 0.0);
- GL.glVertex3d(4.0, -2.2, 0.0);
- GL.glVertex3d(2.2, 2.2, 0.0);
- GL.glVertex3d(4.0, 2.2, 0.0);
- GL.glVertex3d(2.2, 2.2, 0.0);
- GL.glVertex3d(4.0, 4.0, 0.0);
- GL.glVertex3d(2.2, 2.2, 0.0);
- GL.glVertex3d(2.2, 4.0, 0.0);
- GL.glVertex3d(-2.2, 2.2, 0.0);
- GL.glVertex3d(-2.2, 4.0, 0.0);
- GL.glVertex3d(-4.0, 4.0, 0.0);
- GL.glVertex3d(-2.2, 2.2, 0.0);
- GL.glVertex3d(-4.0, 2.2, 0.0);
- GL.glVertex3d(-2.2, -2.2, 0.0);
- GL.glVertex3d(-4.0, -2.2, 0.0);
- GL.glVertex3d(-4.0, -4.0, 0.0);
- GL.glEnd();
- GL.glEnable(GL.GL_TEXTURE_2D);
- // draw floor
- GL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glBindTexture(GL.GL_TEXTURE_2D, textures[TEXTURE_INDEX_FLOOR]);
- GL.glNormal3f(0.0f, 1.0f, 0.0f);
- GL.glBegin(GL.GL_QUADS);
- // floor
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-4.0f, -4.0f, 6.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(-4.0f, -4.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(4.0f, -4.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(4.0f, -4.0f, 6.0f);
- GL.glEnd();
- // draw mirror frame
- GL.glBindTexture(GL.GL_TEXTURE_2D, textures[TEXTURE_INDEX_BOX]);
- GL.glNormal3f(0.0f, 0.0f, 1.0f);
- GL.glBegin(GL.GL_QUADS);
- // top
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-2.2f, 2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(2.2f, 2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(2.2f, 2.2f, 0.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-2.2f, 2.2f, 0.0f);
- // right
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(2.0f, 2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(2.0f, -2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(2.2f, -2.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(2.2f, 2.0f, 0.0f);
- // bottom
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-2.2f, -2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(2.2f, -2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(2.2f, -2.2f, 0.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-2.2f, -2.2f, 0.0f);
- // left
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-2.0f, 2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(-2.0f, -2.0f, 0.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(-2.2f, -2.0f, 0.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-2.2f, 2.0f, 0.0f);
- GL.glEnd();
- GL.glEndList();
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteQuadric(quadratic);
- GL.glDeleteLists(LIST_INDEX_BALL, 1);
- GL.glDeleteLists(LIST_INDEX_BOX, 1);
- GL.glDeleteLists(LIST_INDEX_MIRROR, 1);
- GL.glDeleteLists(LIST_INDEX_ROOM, 1);
- }
-
- /**
- * @see OpenGLTab#getSleepLength()
- */
- int getSleepLength() {
- return SLEEP_LENGTH;
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Reflection";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- if (!hasStencilSupport()) return;
-
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glClearDepth(1.0f);
- GL.glClearStencil(0);
- GL.glGenTextures(IMAGES.length, textures);
- for (int i = 0; i < IMAGES.length; i++) {
- loadTexture(getContext(), IMAGES[i], i, textures);
- }
-
- GL.glShadeModel(GL.GL_SMOOTH);
- quadratic = GLU.gluNewQuadric();
- GLU.gluQuadricNormals(quadratic, GL.GL_SMOOTH);
- GLU.gluQuadricTexture(quadratic, true);
- GL.glDepthFunc(GL.GL_LEQUAL);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
-
- // set up the lights
- float[] LightAmb = { 0.7f, 0.7f, 0.7f, 1.0f };
- float[] LightDif = { 1.0f, 1.0f, 1.0f, 1.0f };
- float[] lightsAmbient = { 0.5f, 0.5f, 0.5f, 1.0f };
- GL.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, lightsAmbient);
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, LightAmb);
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, LightDif);
-
- GL.glEnable(GL.GL_LIGHT0);
- GL.glEnable(GL.GL_LIGHTING);
- GL.glEnable(GL.GL_LINE_SMOOTH);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glEnable(GL.GL_TEXTURE_2D);
- GL.glEnable(GL.GL_BLEND);
-
- createRoom();
- createBall();
- createBox();
- createMirror();
- }
-
- /**
- * @see OpenGLTab#isStencilSupportNeeded
- */
- boolean isStencilSupportNeeded() {
- return true;
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(
- GL.GL_COLOR_BUFFER_BIT
- | GL.GL_DEPTH_BUFFER_BIT
- | GL.GL_STENCIL_BUFFER_BIT);
-
- GL.glLoadIdentity();
- GLU.gluLookAt(xPos, yPos, zPos, 0, 0, 0, 0, 1, 0);
- // clip plane equation
- double clipEquation[] = { 0.0f, 0.0f, -1.0f, 0.0f };
- float[] LightPos = { 0.0f, 2.0f, 7.0f, 1.0f };
- GL.glColorMask(false, false, false, false);
- // enable stencil buffer for "marking" the mirror
- GL.glEnable(GL.GL_STENCIL_TEST);
- // set the stencil buffer to 1 where a polygon is drawn
- GL.glStencilFunc(GL.GL_ALWAYS, 1, 1);
- GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_REPLACE);
- GL.glDisable(GL.GL_DEPTH_TEST);
- GL.glCallList(LIST_INDEX_MIRROR);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glColorMask(true, true, true, true);
- GL.glStencilFunc(GL.GL_EQUAL, 1, 1);
- // draw where the stencil is 1
- GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);
- GL.glEnable(GL.GL_CLIP_PLANE0);
- GL.glClipPlane(GL.GL_CLIP_PLANE0, clipEquation);
- GL.glPushMatrix();
- GL.glScalef(1.0f, 1.0f, -1.0f);
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, LightPos);
- GL.glCallList(LIST_INDEX_ROOM); // reflection
- GL.glPushMatrix();
- GL.glTranslatef(cubeX, cubeY, cubeZ);
- GL.glCallList(LIST_INDEX_BOX); // reflection
- GL.glPopMatrix();
- GL.glTranslatef(ballX, ballY, ballZ);
- GL.glRotatef(ballRot, 1.0f, 0.0f, 0.0f);
- GL.glCallList(LIST_INDEX_BALL); // reflection
- GL.glPopMatrix();
- GL.glDisable(GL.GL_CLIP_PLANE0);
- GL.glDisable(GL.GL_STENCIL_TEST);
- GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, LightPos);
- GL.glEnable(GL.GL_BLEND);
- GL.glDisable(GL.GL_LIGHTING);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- GL.glCallList(LIST_INDEX_MIRROR);
- GL.glEnable(GL.GL_LIGHTING);
- GL.glDisable(GL.GL_BLEND);
- GL.glCallList(LIST_INDEX_ROOM);
- GL.glPushMatrix();
- GL.glTranslatef(cubeX, cubeY, cubeZ);
- GL.glCallList(LIST_INDEX_BOX);
- GL.glPopMatrix();
- GL.glTranslatef(ballX, ballY, ballZ);
- GL.glRotatef(ballRot, 1.0f, 0.0f, 0.0f);
- GL.glCallList(LIST_INDEX_BALL);
- ballRot += ballRotSpeed;
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java
deleted file mode 100644
index e4c8fa8859..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.opengl.*;
-
-abstract class SelectionTab extends OpenGLTab {
- private final static int BUFFER_LENGTH = 64;
-
- /**
- * Sets the selected object. Subclasses must override this method.
- */
- abstract void processPick(int[] pSelectBuff, int hits);
-
- /**
- * Invoke processPick for the object at the specified coordinate.
- */
- int processSelection(int xPos, int yPos, int pointSize) {
- int[] selectBuffer = new int[BUFFER_LENGTH];
- int[] viewport = new int[4];
- // new fix for sun jre
- int ptr = getContext().getSelectBufferPtr(selectBuffer);
-
- GL.glSelectBuffer(BUFFER_LENGTH, ptr);
- GL.glGetIntegerv(GL.GL_VIEWPORT, viewport);
- GL.glRenderMode(GL.GL_SELECT);
- GL.glMatrixMode(GL.GL_PROJECTION);
- GL.glPushMatrix();
- GL.glLoadIdentity();
- GLU.gluPickMatrix(xPos, yPos, pointSize, pointSize, viewport);
- Rectangle rect = getGlCanvas().getClientArea();
- float fAspect = (float) rect.width / (float) rect.height;
- GLU.gluPerspective(45.0f, fAspect, 0.5f, 600.0f);
- GL.glMatrixMode(GL.GL_MODELVIEW);
- GL.glInitNames();
- render();
- int hits = GL.glRenderMode(GL.GL_RENDER);
- // new fix for sun jre
- // must be called after render mode is switched
- getContext().getSelectBuffer(ptr, selectBuffer);
- if (hits != 0) processPick(selectBuffer, hits);
- GL.glMatrixMode(GL.GL_PROJECTION);
- GL.glPopMatrix();
- GL.glMatrixMode(GL.GL_MODELVIEW);
- return hits;
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/StencilTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/StencilTab.java
deleted file mode 100644
index be5f4a4063..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/StencilTab.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class StencilTab extends OpenGLTab {
- private abstract class Shape {
- private String name;
- /**
- * Constructor
- *
- * @param name the shape's name
- */
- Shape(String name) {
- super();
- this.name = name;
- }
- /**
- * Draws this shape.
- */
- abstract void draw();
- /**
- * Returns the name.
- *
- * @return String
- */
- String getName() {
- return name;
- }
- }
-
- private Shape[] shapes = new Shape[5];
- private Shape currentShape;
- private float xPos = 0, yPos = 0;
- private float size = 0.45f;
- private int texture;
- private int quadratic;
- private final static String IMAGE = "images/splash.bmp";
- private final static int SLEEP_LENGTH = 50;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Composite controls = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- controls.setLayout(layout);
- new Label(controls, SWT.NONE).setText("Object:");
- final Combo shapeCombo = new Combo(controls, SWT.READ_ONLY);
- for (int i = 0; i < shapes.length; i++) {
- shapeCombo.add(shapes[i].getName());
- }
- shapeCombo.select(0);
- shapeCombo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- currentShape = shapes[shapeCombo.getSelectionIndex()];
- }
- });
-
- new Label(composite, SWT.NONE).setText("Size:");
- final Slider sizeSlider = new Slider(composite, SWT.HORIZONTAL);
- sizeSlider.setValues(0, 15, 75, 5, 5, 10);
- sizeSlider.setSelection(45);
- sizeSlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- size = ((float) sizeSlider.getSelection()) / 100;
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteQuadric(quadratic);
- }
-
- /**
- * @see OpenGLTab#getSleepLength()
- */
- int getSleepLength() {
- return SLEEP_LENGTH;
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Stencil";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- if (!hasStencilSupport()) return;
-
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glClearDepth(1.0f);
- int[] textureOut = new int[1];
- GL.glGenTextures(1, textureOut);
- loadTexture(getContext(), IMAGE, 0, textureOut);
- this.texture = textureOut[0];
- quadratic = GLU.gluNewQuadric();
- GLU.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
- GL.glDepthFunc(GL.GL_LEQUAL);
- GL.glEnable(GL.GL_STENCIL_TEST);
- GL.glEnable(GL.GL_TEXTURE_2D);
- GL.glEnable(GL.GL_DEPTH_TEST);
- // create shapes
- shapes[0] = new Shape("Triangle") {
- public void draw() {
- GL.glBegin(GL.GL_TRIANGLES);
- GL.glVertex3f(0.0f, size, 0.0f);
- GL.glVertex3f(-size, -size, 0.0f);
- GL.glVertex3f(size, -size, 0.0f);
- GL.glEnd();
- }
- };
-
- shapes[1] = new Shape("Disk") {
- public void draw() {
- GLU.gluDisk(quadratic, 0.0f, size, 32, 32);
- }
- };
-
- shapes[2] = new Shape("Square") {
- public void draw() {
- GL.glRectf(-size, -size, size, size);
- }
- };
-
- shapes[3] = new Shape("Hour Glass") {
- public void draw() {
- GL.glBegin(GL.GL_TRIANGLES);
- GL.glVertex3f(0.0f, size, 0.0f);
- GL.glVertex3f(-size, -size, 0.0f);
- GL.glVertex3f(size, -size, 0.0f);
- GL.glVertex3f(0.0f, -size, 0.0f);
- GL.glVertex3f(size, size, 0.0f);
- GL.glVertex3f(-size, size, 0.0f);
- GL.glEnd();
- }
- };
-
- shapes[4] = new Shape("Star") {
- public void draw() {
- GL.glBegin(GL.GL_TRIANGLES);
- GL.glVertex3f(-0.3f, 0, 0.0f);
- GL.glVertex3f(2 * size - 0.3f, 0, 0.0f);
- GL.glVertex3f(size - 0.3f, 2 * size * 0.85f, 0.0f);
- GL.glVertex3f(2 * size - 0.3f, size, 0.0f);
- GL.glVertex3f(0 - 0.3f, size, 0.0f);
- GL.glVertex3f(size - 0.3f, -size * 0.85f, 0.0f);
- GL.glEnd();
- }
- };
-
- currentShape = shapes[0];
- }
-
- /**
- * @see OpenGLTab#isStencilSupportNeeded
- */
- boolean isStencilSupportNeeded() {
- return true;
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(
- GL.GL_COLOR_BUFFER_BIT
- | GL.GL_DEPTH_BUFFER_BIT
- | GL.GL_STENCIL_BUFFER_BIT);
-
- GL.glLoadIdentity();
- GL.glTranslatef(
- (float) (1.5 * Math.cos(xPos)),
- (float) (1.0 * Math.sin(yPos)),
- -3.0f);
- xPos += 0.15f;
- yPos += 0.3f;
-
- GL.glColorMask(false, false, false, false);
- GL.glStencilFunc(GL.GL_ALWAYS, 1, 1);
- GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_REPLACE);
- GL.glDisable(GL.GL_DEPTH_TEST);
- GL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
- currentShape.draw();
-
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glColorMask(true, true, true, true);
- GL.glStencilFunc(GL.GL_EQUAL, 1, 1);
- GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);
-
- GL.glLoadIdentity();
- // load the texture behind the stencil object
- GL.glTranslatef(0.0f, 0.0f, -3.1f);
- GL.glBindTexture(GL.GL_TEXTURE_2D, texture);
- GL.glBegin(GL.GL_QUADS);
- GL.glTexCoord2f(0.0f, 0.0f);
- GL.glVertex3f(-0.85f, -0.85f, 1.0f);
- GL.glTexCoord2f(1.0f, 0.0f);
- GL.glVertex3f(0.85f, -0.85f, 1.0f);
- GL.glTexCoord2f(1.0f, 1.0f);
- GL.glVertex3f(0.85f, 0.85f, 1.0f);
- GL.glTexCoord2f(0.0f, 1.0f);
- GL.glVertex3f(-0.85f, 0.85f, 1.0f);
- GL.glEnd();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/TextureTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/TextureTab.java
deleted file mode 100644
index 1375b6fdca..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/TextureTab.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class TextureTab extends OpenGLTab {
- private float yrot = 0, zrot = 0;
- private float xPos = 0.0f, yPos = 0.0f, zPos = -20;
- private int texture = 0;
- private float[][][] points = new float[45][45][3];
- private final static String IMAGE = "images/splash.bmp";
- private final static int SLEEP_LENGTH = 50;
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Group movementGroup = new Group(composite, SWT.NONE);
- movementGroup.setText("Translation");
- movementGroup.setLayout(new GridLayout(2, false));
-
- new Label(movementGroup, SWT.NONE).setText("X:");
- final Slider xMove = new Slider(movementGroup, SWT.NONE);
- xMove.setIncrement(1);
- xMove.setMaximum(12);
- xMove.setMinimum(0);
- xMove.setThumb(2);
- xMove.setPageIncrement(2);
- xMove.setSelection(5);
- xMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- xPos = xMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Y:");
- final Slider yMove = new Slider(movementGroup, SWT.NONE);
- yMove.setIncrement(1);
- yMove.setMaximum(12);
- yMove.setMinimum(0);
- yMove.setThumb(2);
- yMove.setPageIncrement(2);
- yMove.setSelection(5);
- yMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- yPos = yMove.getSelection() - 5;
- }
- });
-
- new Label(movementGroup, SWT.NONE).setText("Z:");
- final Slider zMove = new Slider(movementGroup, SWT.NONE);
- zMove.setIncrement(1);
- zMove.setMaximum(24);
- zMove.setMinimum(0);
- zMove.setThumb(4);
- zMove.setPageIncrement(2);
- zMove.setSelection(10);
- zMove.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- zPos = zMove.getSelection() - 30;
- }
- });
- }
-
- /**
- * @see OpenGLTab#getSleepLength()
- */
- int getSleepLength() {
- return SLEEP_LENGTH;
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Texture";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- //GL.glClearColor(0.0f, 0.0f, 0.3f, 1.0f);
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glClearDepth(1.0f);
- int[] textureOut = new int[1];
- GL.glGenTextures(1, textureOut);
- loadTexture(getContext(), IMAGE, 0, textureOut);
- texture = textureOut[0];
- GL.glDepthFunc(GL.GL_LEQUAL);
- GL.glPolygonMode(GL.GL_BACK, GL.GL_FILL);
- GL.glPolygonMode(GL.GL_FRONT, GL.GL_LINE);
- GL.glEnable(GL.GL_LIST_MODE);
- GL.glEnable(GL.GL_TEXTURE_2D);
- GL.glEnable(GL.GL_DEPTH_TEST);
- // initialize points
- for (int x = 0; x < 45; x++) {
- for (int y = 0; y < 45; y++) {
- points[x][y][0] = x / 5.0f - 4.5f;
- points[x][y][1] = y / 5.0f - 4.5f;
- points[x][y][2] =
- (float) Math.sin(
- (((x / 5.0f) * 40.0f) / 360.0f) * Math.PI * 2);
- }
- }
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- GL.glClear(
- GL.GL_COLOR_BUFFER_BIT
- | GL.GL_DEPTH_BUFFER_BIT
- | GL.GL_STENCIL_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(xPos, yPos, zPos);
- GL.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
- GL.glRotatef(zrot, 0.0f, 0.0f, 1.0f);
- GL.glBindTexture(GL.GL_TEXTURE_2D, texture);
-
- GL.glBegin(GL.GL_QUADS);
- for (int x = 0; x < 44; x++) {
- for (int y = 0; y < 44; y++) {
- float fx = x / 44.0f;
- float fy = y / 44.0f;
- float fxb = (x + 1) / 44.0f;
- float fyb = (y + 1) / 44.0f;
- GL.glTexCoord2f(fx, fy);
- GL.glVertex3f(
- points[x][y][0],
- points[x][y][1],
- points[x][y][2]);
- GL.glTexCoord2f(fx, fyb);
- GL.glVertex3f(
- points[x][y + 1][0],
- points[x][y + 1][1],
- points[x][y + 1][2]);
- GL.glTexCoord2f(fxb, fyb);
- GL.glVertex3f(
- points[x + 1][y + 1][0],
- points[x + 1][y + 1][1],
- points[x + 1][y + 1][2]);
- GL.glTexCoord2f(fxb, fy);
- GL.glVertex3f(
- points[x + 1][y][0],
- points[x + 1][y][1],
- points[x + 1][y][2]);
- }
- }
- GL.glEnd();
- // perform wave motion
- for (int y = 0; y < 45; y++) {
- float hold = points[0][y][2];
- for (int x = 0; x < 44; x++) {
- points[x][y][2] = points[x + 1][y][2];
- }
- points[44][y][2] = hold;
- }
- yrot += 0.9f;
- zrot += 0.6f;
- }
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/TransparencyTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/TransparencyTab.java
deleted file mode 100644
index 11f39fbe63..0000000000
--- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/TransparencyTab.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.opengl.examples;
-
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-class TransparencyTab extends SelectionTab {
- private float[] alphas = { 0.3f, 0.5f, 1.0f };
- private int quadratic;
- private int currentSelection = 1;
- private final static int
- INDEX_TRIANGLE = 1, INDEX_SPHERE = 2, INDEX_DISK = 3;
- private final static String[] OBJECTS = {"Triangle", "Sphere", "Disk" };
-
- /**
- * @see OpenGLTab#createControls(Composite)
- */
- void createControls(Composite composite) {
- Composite objectGroup = new Composite(composite, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- objectGroup.setLayout(layout);
- objectGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
-
- new Label(objectGroup, SWT.NONE).setText("Object:");
- final Combo objectCombo = new Combo(objectGroup, SWT.READ_ONLY);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- data.grabExcessHorizontalSpace = true;
- objectCombo.setLayoutData(data);
- objectCombo.setItems(OBJECTS);
- objectCombo.select(0);
-
- new Label(composite, SWT.NONE).setText("Transparency:");
- final Slider transparencySlider = new Slider(composite, SWT.HORIZONTAL);
- transparencySlider.setValues(0, 0, 11, 1, 1, 2);
- transparencySlider.setSelection(7);
- transparencySlider.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- float alpha = transparencySlider.getSelection();
- alpha = 1.0f - alpha / 10;
- alphas[currentSelection - 1] = alpha;
- }
- });
- objectCombo.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- currentSelection = objectCombo.getSelectionIndex() + 1;
- transparencySlider.setSelection(
- (int) ((1.0f - alphas[currentSelection - 1]) * 10));
- }
- });
-
- final Canvas glCanvas = getGlCanvas();
- glCanvas.addMouseListener(new MouseAdapter() {
- public void mouseUp(MouseEvent e) {
- Rectangle rect = glCanvas.getClientArea();
- e.y = rect.height - e.y;
- if (e.button == 1) {
- processSelection(e.x, e.y, 2);
- transparencySlider.setSelection(
- (int) ((1.0f - alphas[currentSelection - 1]) * 10));
- objectCombo.select(currentSelection - 1);
- }
- }
- });
- }
-
- /**
- * @see OpenGLTab#dispose()
- */
- void dispose() {
- super.dispose();
- GLU.gluDeleteQuadric(quadratic);
- GL.glDeleteLists(INDEX_DISK, 1);
- GL.glDeleteLists(INDEX_SPHERE, 1);
- GL.glDeleteLists(INDEX_TRIANGLE, 1);
- }
-
- /**
- * @see OpenGLTab#getTabText()
- */
- String getTabText() {
- return "Transparency";
- }
-
- /**
- * @see OpenGLTab#init()
- */
- void init() {
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
- quadratic = GLU.gluNewQuadric();
- GLU.gluQuadricNormals(quadratic, GLU.GLU_SMOOTH);
- GL.glEnable(GL.GL_CULL_FACE);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glEnable(GL.GL_BLEND);
- // create display lists
- GL.glNewList(INDEX_SPHERE, GL.GL_COMPILE);
- GLU.gluQuadricDrawStyle(quadratic, GLU.GLU_FILL);
- GLU.gluSphere(quadratic, 1.5, 32, 32);
- GL.glEndList();
- GL.glNewList(INDEX_DISK, GL.GL_COMPILE);
- GLU.gluQuadricDrawStyle(quadratic, GLU.GLU_FILL);
- GLU.gluDisk(quadratic, 1.0, 3, 32, 32);
- GL.glEndList();
- GL.glNewList(INDEX_TRIANGLE, GL.GL_COMPILE);
- GL.glBegin(GL.GL_TRIANGLES);
- GL.glVertex3f(0.0f, 2.0f, 0.0f);
- GL.glVertex3f(-2.0f, -2.0f, 2.0f);
- GL.glVertex3f(2.0f, -2.0f, 2.0f);
- GL.glEnd();
- GL.glEndList();
- }
-
- /**
- * @see SelectionTab.processPick (int[], int)
- */
- void processPick(int[] pSelectBuff, int hits) {
- int count, zDepth;
- int tempSelection = pSelectBuff[3];
- zDepth = pSelectBuff[2];
- // pick object with largest z value
- for (int i = 4; i <= 4 * (hits - 1); i = i + 4) {
- if (zDepth > pSelectBuff[i + 2]) {
- zDepth = pSelectBuff[i + 2];
- tempSelection = pSelectBuff[i + 3];
- }
- }
- if (tempSelection > 0) currentSelection = tempSelection;
- }
-
- /**
- * @see OpenGLTab#renderScene()
- */
- void renderScene() {
- // draw items with transparent qualities in reverse Z order
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(0.0f, 0.0f, -14.0f);
- GL.glPushName(0);
-
- // draw disk
- GL.glPushMatrix();
- GL.glTranslatef(-1.0f, 0.0f, 1.0f);
- GL.glColor4f(0.0f, 1.0f, 0.0f, alphas[2]);
- GL.glLoadName(INDEX_DISK);
- GL.glCallList(INDEX_DISK);
- if (currentSelection == INDEX_DISK) {
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GLU.gluQuadricDrawStyle(quadratic, GLU.GLU_LINE);
- GLU.gluDisk(quadratic, 0.98, 3.02, 32, 32);
- }
- GL.glPopMatrix();
-
- // draw triangle
- GL.glTranslatef(0.0f, 0.0f, +3.0f);
- GL.glLoadName(INDEX_TRIANGLE);
- GL.glColor4f(1.0f, 0.0f, 0.0f, alphas[0]);
- GL.glCallList(INDEX_TRIANGLE);
- GL.glPointSize(5.0f);
- if (currentSelection == INDEX_TRIANGLE) {
- GL.glBegin(GL.GL_POINTS);
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GL.glVertex3f(0.0f, 2.0f, 0.0f);
- GL.glVertex3f(-2.0f, -2.0f, 2.0f);
- GL.glVertex3f(2.0f, -2.0f, 2.0f);
- GL.glEnd();
- }
-
- // draw sphere
- GL.glPushMatrix();
- GL.glTranslatef(1.0f, 0.0f, +3.0f);
- GL.glColor4f(0.0f, 0.0f, 1.0f, alphas[1]);
- GL.glLoadName(INDEX_SPHERE);
- GL.glCallList(INDEX_SPHERE);
- if (currentSelection == INDEX_SPHERE) {
- GL.glColor3f(1.0f, 0.0f, 0.0f);
- GLU.gluQuadricDrawStyle(quadratic, GLU.GLU_LINE);
- GLU.gluSphere(quadratic, 1.51, 8, 8);
- }
- GL.glPopMatrix();
- }
-}
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Ball.jpg b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Ball.jpg
deleted file mode 100644
index 6890d26807..0000000000
Binary files a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Ball.jpg and /dev/null differ
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Box.bmp b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Box.bmp
deleted file mode 100644
index 5eef6630d3..0000000000
Binary files a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Box.bmp and /dev/null differ
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Floor.jpg b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Floor.jpg
deleted file mode 100644
index 4934c9c82a..0000000000
Binary files a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/Floor.jpg and /dev/null differ
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/splash.bmp b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/splash.bmp
deleted file mode 100644
index 6ec75da1a8..0000000000
Binary files a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/splash.bmp and /dev/null differ
diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/untitled.jpg b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/untitled.jpg
deleted file mode 100644
index f5d6aa11d5..0000000000
Binary files a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/images/untitled.jpg and /dev/null differ
diff --git a/examples/org.eclipse.swt.snippets/.classpath b/examples/org.eclipse.swt.snippets/.classpath
deleted file mode 100644
index 065ac06e19..0000000000
--- a/examples/org.eclipse.swt.snippets/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.snippets/.cvsignore b/examples/org.eclipse.swt.snippets/.cvsignore
deleted file mode 100644
index c5e82d7458..0000000000
--- a/examples/org.eclipse.swt.snippets/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/.project b/examples/org.eclipse.swt.snippets/.project
deleted file mode 100644
index 069b3a1b00..0000000000
--- a/examples/org.eclipse.swt.snippets/.project
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
- org.eclipse.swt.examples
-
-
- org.eclipse.swt
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.pde.PluginNature
-
-
diff --git a/examples/org.eclipse.swt.snippets/about.html b/examples/org.eclipse.swt.snippets/about.html
deleted file mode 100644
index 9db411aab9..0000000000
--- a/examples/org.eclipse.swt.snippets/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-About
-
-
-
-
About This Content
-
-
20th June, 2002
-
License
-
Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html.
-For purposes of the CPL, "Program" will mean the Content.
-
-
Contributions
-
-
If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
-
-
If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or
-other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.
-
-
-
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/build.properties b/examples/org.eclipse.swt.snippets/build.properties
deleted file mode 100644
index 6bd494b6cb..0000000000
--- a/examples/org.eclipse.swt.snippets/build.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.swtsnippets.jar = src/
diff --git a/examples/org.eclipse.swt.snippets/plugin.properties b/examples/org.eclipse.swt.snippets/plugin.properties
deleted file mode 100644
index cfc2a843ce..0000000000
--- a/examples/org.eclipse.swt.snippets/plugin.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName = SWT Snippets
-providerName = Eclipse.org
diff --git a/examples/org.eclipse.swt.snippets/plugin.xml b/examples/org.eclipse.swt.snippets/plugin.xml
deleted file mode 100644
index 1190339a0a..0000000000
--- a/examples/org.eclipse.swt.snippets/plugin.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet1.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet1.java
deleted file mode 100644
index 9492aba36d..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet1.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: Hello World
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.widgets.*;
-
-public class Snippet1 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell(display);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet10.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet10.java
deleted file mode 100644
index 7205af668e..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet10.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-public class Snippet10 {
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java
deleted file mode 100644
index bbb1c4d92c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Font example snippet: create a large font for use by a text widget
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet100 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setBounds(10, 10, 200, 200);
- Text text = new Text(shell, SWT.MULTI);
- text.setBounds(10, 10, 150, 150);
- Font initialFont = text.getFont();
- FontData[] fontData = initialFont.getFontData();
- for (int i = 0; i < fontData.length; i++) {
- fontData[i].setHeight(24);
- }
- Font newFont = new Font(display, fontData);
- text.setFont(newFont);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- newFont.dispose();
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.java
deleted file mode 100644
index 6a94d7de5c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Table example snippet: insert a table item (at an index)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet101 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Table table = new Table (shell, SWT.BORDER | SWT.MULTI);
- table.setSize (200, 200);
- for (int i=0; i<12; i++) {
- TableItem item = new TableItem (table, SWT.NONE);
- item.setText ("Item " + i);
- }
- TableItem item = new TableItem (table, SWT.NONE, 1);
- item.setText ("*** New Item " + table.indexOf (item) + " ***");
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-
-}
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.java
deleted file mode 100644
index 881a72a031..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Tree example snippet: insert a tree item (at an index)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet102 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Tree tree = new Tree (shell, SWT.BORDER | SWT.MULTI);
- tree.setSize (200, 200);
- for (int i=0; i<12; i++) {
- TreeItem item = new TreeItem (tree, SWT.NONE);
- item.setText ("Item " + i);
- }
- TreeItem item = new TreeItem (tree, SWT.NONE, 1);
- TreeItem [] items = tree.getItems ();
- int index = 0;
- while (index < items.length && items [index] != item) index++;
- item.setText ("*** New Item " + index + " ***");
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.java
deleted file mode 100644
index a75a7c4858..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Table example snippet: update table item text
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet103 {
-
-static char content = 'a';
-public static void main(String[] args) {
- final Display display = new Display();
- Shell shell = new Shell(display);
- shell.setBounds(10, 10, 200, 240);
- Table table = new Table(shell, SWT.NONE);
- table.setBounds(10, 10, 160, 160);
-
- final TableItem[] items = new TableItem[4];
- for (int i = 0; i < 4; i++) {
- new TableColumn(table, SWT.NONE).setWidth(40);
- }
- for (int i = 0; i < 4; i++) {
- items[i] = new TableItem(table, SWT.NONE);
- populateItem(items[i]);
- }
-
- Button button = new Button(shell, SWT.PUSH);
- button.setBounds(10, 180, 50, 30);
- button.setText("Change");
- button.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- for (int i = 0; i < 4; i++) {
- populateItem(items[i]);
- }
- }
- });
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-
-static void populateItem(TableItem item) {
- String stringContent = String.valueOf(content);
- item.setText(
- new String[] {
- stringContent,
- stringContent,
- stringContent,
- stringContent });
- content++;
- if (content > 'z') content = 'a';
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet104.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet104.java
deleted file mode 100644
index e40d1c59e6..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet104.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Shell example snippet: create a splash screen
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet104 {
-
-public static void main(String[] args) {
- final Display display = new Display();
- final int [] count = new int [] {4};
- final Image image = new Image(display, 300, 300);
- final Shell splash = new Shell(SWT.ON_TOP);
- final ProgressBar bar = new ProgressBar(splash, SWT.NONE);
- bar.setMaximum(count[0]);
- Label label = new Label(splash, SWT.NONE);
- label.setImage(image);
- FormLayout layout = new FormLayout();
- splash.setLayout(layout);
- FormData labelData = new FormData ();
- labelData.right = new FormAttachment (100, 0);
- labelData.bottom = new FormAttachment (100, 0);
- label.setLayoutData(labelData);
- FormData progressData = new FormData ();
- progressData.left = new FormAttachment (0, 5);
- progressData.right = new FormAttachment (100, -5);
- progressData.bottom = new FormAttachment (100, -5);
- bar.setLayoutData(progressData);
- splash.pack();
- Rectangle splashRect = splash.getBounds();
- Rectangle displayRect = display.getBounds();
- int x = (displayRect.width - splashRect.width) / 2;
- int y = (displayRect.height - splashRect.height) / 2;
- splash.setLocation(x, y);
- splash.open();
- display.asyncExec(new Runnable() {
- public void run() {
- Shell [] shells = new Shell[count[0]];
- for (int i=0; i 0) {
- buffer.append(readBuffer, 0, n);
- }
- textString = buffer.toString();
- stream.close();
- } catch (IOException e) {
- MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
- box.setMessage("Error reading file:\n" + name);
- box.open();
- return;
- }
- } catch (FileNotFoundException e) {
- MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
- box.setMessage("File not found:\n" + name);
- box.open();
- return;
- }
- text.setText(textString);
- }
-
- void menuFont() {
- FontDialog fontDialog = new FontDialog(shell);
- fontDialog.setFontList(font.getFontData());
- FontData fontData = fontDialog.open();
- if (fontData != null) {
- if (font != null) font.dispose();
- font = new Font(display, fontData);
- text.setFont(font);
- }
- }
-
- void menuForegroundColor() {
- ColorDialog colorDialog = new ColorDialog(shell);
- colorDialog.setRGB(foregroundColor.getRGB());
- RGB rgb = colorDialog.open();
- if (rgb != null) {
- if (foregroundColor != null) foregroundColor.dispose();
- foregroundColor = new Color(display, rgb);
- text.setForeground(foregroundColor);
- }
- }
-
- void menuBackgroundColor() {
- ColorDialog colorDialog = new ColorDialog(shell);
- colorDialog.setRGB(backgroundColor.getRGB());
- RGB rgb = colorDialog.open();
- if (rgb != null) {
- if (backgroundColor != null) backgroundColor.dispose();
- backgroundColor = new Color(display, rgb);
- text.setBackground(backgroundColor);
- }
- }
-
- void menuPrint() {
- PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
- PrinterData data = dialog.open();
- if (data == null) return;
- if (data.printToFile) {
- data.fileName = "print.out"; // you probably want to ask the user for a filename
- }
-
- /* Get the text to print from the Text widget (you could get it from anywhere, i.e. your java model) */
- textToPrint = text.getText();
-
- /* Do the printing in a background thread so that spooling does not freeze the UI. */
- printer = new Printer(data);
- Thread printingThread = new Thread("Printing") {
- public void run() {
- print(printer);
- printer.dispose();
- }
- };
- printingThread.start();
- }
-
- void print(Printer printer) {
- if (printer.startJob("Text")) { // the string is the job name - shows up in the printer's job list
- Rectangle clientArea = printer.getClientArea();
- Rectangle trim = printer.computeTrim(0, 0, 0, 0);
- Point dpi = printer.getDPI();
- leftMargin = dpi.x + trim.x; // one inch from left side of paper
- rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one inch from right side of paper
- topMargin = dpi.y + trim.y; // one inch from top edge of paper
- bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one inch from bottom edge of paper
-
- /* Create a buffer for computing tab width. */
- int tabSize = 4; // is tab width a user setting in your UI?
- StringBuffer tabBuffer = new StringBuffer(tabSize);
- for (int i = 0; i < tabSize; i++) tabBuffer.append(' ');
- tabs = tabBuffer.toString();
-
- /* Create printer GC, and create and set the printer font & foreground color. */
- gc = new GC(printer);
-
- FontData fontData = font.getFontData()[0];
- printerFont = new Font(printer, fontData.getName(), fontData.getHeight(), fontData.getStyle());
- gc.setFont(printerFont);
- tabWidth = gc.stringExtent(tabs).x;
- lineHeight = gc.getFontMetrics().getHeight();
-
- RGB rgb = foregroundColor.getRGB();
- printerForegroundColor = new Color(printer, rgb);
- gc.setForeground(printerForegroundColor);
-
- rgb = backgroundColor.getRGB();
- printerBackgroundColor = new Color(printer, rgb);
- gc.setBackground(printerBackgroundColor);
-
- /* Print text to current gc using word wrap */
- printText();
- printer.endJob();
-
- /* Cleanup graphics resources used in printing */
- printerFont.dispose();
- printerForegroundColor.dispose();
- printerBackgroundColor.dispose();
- gc.dispose();
- }
- }
-
- void printText() {
- printer.startPage();
- wordBuffer = new StringBuffer();
- x = leftMargin;
- y = topMargin;
- index = 0;
- end = textToPrint.length();
- while (index < end) {
- char c = textToPrint.charAt(index);
- index++;
- if (c != 0) {
- if (c == 0x0a || c == 0x0d) {
- if (c == 0x0d && index < end && textToPrint.charAt(index) == 0x0a) {
- index++; // if this is cr-lf, skip the lf
- }
- printWordBuffer();
- newline();
- } else {
- if (c != '\t') {
- wordBuffer.append(c);
- }
- if (Character.isWhitespace(c)) {
- printWordBuffer();
- if (c == '\t') {
- x += tabWidth;
- }
- }
- }
- }
- }
- if (y + lineHeight <= bottomMargin) {
- printer.endPage();
- }
- }
-
- void printWordBuffer() {
- if (wordBuffer.length() > 0) {
- String word = wordBuffer.toString();
- int wordWidth = gc.stringExtent(word).x;
- if (x + wordWidth > rightMargin) {
- /* word doesn't fit on current line, so wrap */
- newline();
- }
- gc.drawString(word, x, y, false);
- x += wordWidth;
- wordBuffer = new StringBuffer();
- }
- }
-
- void newline() {
- x = leftMargin;
- y += lineHeight;
- if (y + lineHeight > bottomMargin) {
- printer.endPage();
- if (index + 1 < end) {
- y = topMargin;
- printer.startPage();
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet134.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet134.java
deleted file mode 100644
index cfeeade297..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet134.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Shell example snippet: create a non-rectangular window
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet134 {
-
-static int[] circle(int r, int offsetX, int offsetY) {
- int[] polygon = new int[8 * r + 4];
- //x^2 + y^2 = r^2
- for (int i = 0; i < 2 * r + 1; i++) {
- int x = i - r;
- int y = (int)Math.sqrt(r*r - x*x);
- polygon[2*i] = offsetX + x;
- polygon[2*i+1] = offsetY + y;
- polygon[8*r - 2*i - 2] = offsetX + x;
- polygon[8*r - 2*i - 1] = offsetY - y;
- }
- return polygon;
-}
-
-public static void main(String[] args) {
- final Display display = new Display();
- //Shell must be created with style SWT.NO_TRIM
- final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
- shell.setBackground(display.getSystemColor(SWT.COLOR_RED));
- //define a region that looks like a key hole
- Region region = new Region();
- region.add(circle(67, 67, 67));
- region.subtract(circle(20, 67, 50));
- region.subtract(new int[]{67, 50, 55, 105, 79, 105});
- //define the shape of the shell using setRegion
- shell.setRegion(region);
- Rectangle size = region.getBounds();
- shell.setSize(size.width, size.height);
- //add ability to move shell around
- Listener l = new Listener() {
- Point origin;
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.MouseDown:
- origin = new Point(e.x, e.y);
- break;
- case SWT.MouseUp:
- origin = null;
- break;
- case SWT.MouseMove:
- if (origin != null) {
- Point p = display.map(shell, null, e.x, e.y);
- shell.setLocation(p.x - origin.x, p.y - origin.y);
- }
- break;
- }
- }
- };
- shell.addListener(SWT.MouseDown, l);
- shell.addListener(SWT.MouseUp, l);
- shell.addListener(SWT.MouseMove, l);
- //add ability to close shell
- Button b = new Button(shell, SWT.PUSH);
- b.setBackground(shell.getBackground());
- b.setText("close");
- b.pack();
- b.setLocation(10, 68);
- b.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- shell.close();
- }
- });
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- region.dispose();
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet135.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet135.java
deleted file mode 100644
index 7f8e7a56e2..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet135.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: embed Swing/AWT in SWT
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.awt.EventQueue;
-import java.io.*;
-import java.util.*;
-import javax.swing.*;
-import javax.swing.table.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.awt.SWT_AWT;
-
-public class Snippet135 {
-
- static class FileTableModel extends AbstractTableModel {
- File[] files;
- String[] columnsName = {"Name", "Size", "Date Modified"};
-
- public FileTableModel (File[] files) {
- this.files = files;
- }
- public int getColumnCount () {
- return columnsName.length;
- }
- public Class getColumnClass (int col) {
- if (col == 1) return Long.class;
- if (col == 2) return Date.class;
- return String.class;
- }
- public int getRowCount () {
- return files == null ? 0 : files.length;
- }
- public Object getValueAt (int row, int col) {
- if (col == 0) return files[row].getName();
- if (col == 1) return new Long(files[row].length());
- if (col == 2) return new Date(files[row].lastModified());
- return "";
- }
- public String getColumnName (int col) {
- return columnsName[col];
- }
- }
-
- public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setText("SWT and Swing/AWT Example");
-
- Listener exitListener = new Listener() {
- public void handleEvent(Event e) {
- MessageBox dialog = new MessageBox(shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
- dialog.setText("Question");
- dialog.setMessage("Exit?");
- if (e.type == SWT.Close) e.doit = false;
- if (dialog.open() != SWT.OK) return;
- shell.dispose();
- }
- };
- Listener aboutListener = new Listener() {
- public void handleEvent(Event e) {
- final Shell s = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- s.setText("About");
- GridLayout layout = new GridLayout(1, false);
- layout.verticalSpacing = 20;
- layout.marginHeight = layout.marginWidth = 10;
- s.setLayout(layout);
- Label label = new Label(s, SWT.NONE);
- label.setText("SWT and AWT Example.");
- Button button = new Button(s, SWT.PUSH);
- button.setText("OK");
- GridData data = new GridData();
- data.horizontalAlignment = GridData.CENTER;
- button.setLayoutData(data);
- button.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- s.dispose();
- }
- });
- s.pack();
- Rectangle parentBounds = shell.getBounds();
- Rectangle bounds = s.getBounds();
- int x = parentBounds.x + (parentBounds.width - bounds.width) / 2;
- int y = parentBounds.y + (parentBounds.height - bounds.height) / 2;
- s.setLocation(x, y);
- s.open();
- while (!s.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- }
- };
- shell.addListener(SWT.Close, exitListener);
- Menu mb = new Menu(shell, SWT.BAR);
- MenuItem fileItem = new MenuItem(mb, SWT.CASCADE);
- fileItem.setText("&File");
- Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
- fileItem.setMenu(fileMenu);
- MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
- exitItem.setText("&Exit\tCtrl+X");
- exitItem.setAccelerator(SWT.CONTROL + 'X');
- exitItem.addListener(SWT.Selection, exitListener);
- MenuItem aboutItem = new MenuItem(fileMenu, SWT.PUSH);
- aboutItem.setText("&About\tCtrl+A");
- aboutItem.setAccelerator(SWT.CONTROL + 'A');
- aboutItem.addListener(SWT.Selection, aboutListener);
- shell.setMenuBar(mb);
-
- RGB color = shell.getBackground().getRGB();
- Label separator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
- Label locationLb = new Label(shell, SWT.NONE);
- locationLb.setText("Location:");
- Composite locationComp = new Composite(shell, SWT.EMBEDDED);
- ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
- ToolItem exitToolItem = new ToolItem(toolBar, SWT.PUSH);
- exitToolItem.setText("&Exit");
- exitToolItem.addListener(SWT.Selection, exitListener);
- ToolItem aboutToolItem = new ToolItem(toolBar, SWT.PUSH);
- aboutToolItem.setText("&About");
- aboutToolItem.addListener(SWT.Selection, aboutListener);
- Label separator2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
- final Composite comp = new Composite(shell, SWT.NONE);
- final Tree fileTree = new Tree(comp, SWT.SINGLE | SWT.BORDER);
- Sash sash = new Sash(comp, SWT.VERTICAL);
- Composite tableComp = new Composite(comp, SWT.EMBEDDED);
- Label separator3 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
- Composite statusComp = new Composite(shell, SWT.EMBEDDED);
-
- java.awt.Frame locationFrame = SWT_AWT.new_Frame(locationComp);
- final java.awt.TextField locationText = new java.awt.TextField();
- locationFrame.add(locationText);
-
- java.awt.Frame fileTableFrame = SWT_AWT.new_Frame(tableComp);
- java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
- fileTableFrame.add(panel);
- final JTable fileTable = new JTable(new FileTableModel(null));
- fileTable.setDoubleBuffered(true);
- fileTable.setShowGrid(false);
- fileTable.createDefaultColumnsFromModel();
- JScrollPane scrollPane = new JScrollPane(fileTable);
- panel.add(scrollPane);
-
- java.awt.Frame statusFrame = SWT_AWT.new_Frame(statusComp);
- statusFrame.setBackground(new java.awt.Color(color.red, color.green, color.blue));
- final java.awt.Label statusLabel = new java.awt.Label();
- statusFrame.add(statusLabel);
- statusLabel.setText("Select a file");
-
- sash.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- if (e.detail == SWT.DRAG) return;
- GridData data = (GridData)fileTree.getLayoutData();
- Rectangle trim = fileTree.computeTrim(0, 0, 0, 0);
- data.widthHint = e.x - trim.width;
- comp.layout();
- }
- });
-
- File[] roots = File.listRoots();
- for (int i = 0; i < roots.length; i++) {
- File file = roots[i];
- TreeItem treeItem = new TreeItem(fileTree, SWT.NONE);
- treeItem.setText(file.getAbsolutePath());
- treeItem.setData(file);
- TreeItem dumyItem = new TreeItem(treeItem, SWT.NONE);
- }
- fileTree.addListener(SWT.Expand, new Listener() {
- public void handleEvent(Event e) {
- TreeItem item = (TreeItem)e.item;
- if (item == null) return;
- if (item.getItemCount() == 1) {
- TreeItem firstItem = item.getItems()[0];
- if (firstItem.getData() != null) return;
- firstItem.dispose();
- } else {
- return;
- }
- File root = (File)item.getData();
- File[] files = root.listFiles();
- if (files == null) return;
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
- if (file.isDirectory()) {
- TreeItem treeItem = new TreeItem(item, SWT.NONE);
- treeItem.setText(file.getName());
- treeItem.setData(file);
- TreeItem dumyItem = new TreeItem(treeItem, SWT.NONE);
- }
- }
- }
- });
- fileTree.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- TreeItem item = (TreeItem)e.item;
- if (item == null) return;
- final File root = (File)item.getData();
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- statusLabel.setText(root.getAbsolutePath());
- locationText.setText(root.getAbsolutePath());
- fileTable.setModel(new FileTableModel(root.listFiles()));
- }
- });
- }
- });
-
- GridLayout layout = new GridLayout(4, false);
- layout.marginWidth = layout.marginHeight = 0;
- layout.horizontalSpacing = layout.verticalSpacing = 1;
- shell.setLayout(layout);
- GridData data;
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 4;
- separator1.setLayoutData(data);
- data = new GridData();
- data.horizontalSpan = 1;
- data.horizontalIndent = 10;
- locationLb.setLayoutData(data);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
- data.heightHint = locationText.getPreferredSize().height;
- locationComp.setLayoutData(data);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- toolBar.setLayoutData(data);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 4;
- separator2.setLayoutData(data);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 4;
- comp.setLayoutData(data);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 4;
- separator3.setLayoutData(data);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 4;
- data.heightHint = statusLabel.getPreferredSize().height;
- statusComp.setLayoutData(data);
-
- layout = new GridLayout(3, false);
- layout.marginWidth = layout.marginHeight = 0;
- layout.horizontalSpacing = layout.verticalSpacing = 1;
- comp.setLayout(layout);
- data = new GridData(GridData.FILL_VERTICAL);
- data.widthHint = 200;
- fileTree.setLayoutData(data);
- data = new GridData(GridData.FILL_VERTICAL);
- sash.setLayoutData(data);
- data = new GridData(GridData.FILL_BOTH);
- tableComp.setLayoutData(data);
-
- shell.open();
- while(!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet136.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet136.java
deleted file mode 100644
index 99b6510ac1..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet136.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Browser example snippet: render HTML from memory
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet136 {
- public static void main(String [] args) {
- String html = "HTML Test";
- for (int i = 0; i < 100; i++) html += "
This is line "+i+"
";
- html += "";
-
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Browser browser = new Browser(shell, SWT.NONE);
- browser.setText(html);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
-
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet137.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet137.java
deleted file mode 100644
index 06b54feeca..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet137.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Browser example snippet: render HTML that includes relative links from memory
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet137 {
-
-public static void main(String [] args) {
- /* Relative links: use the HTML base tag */
- String html = ""+
- ""+
- "HTML Test"+
- "local link";
-
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Browser browser = new Browser(shell, SWT.NONE);
- browser.setText(html);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet138.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet138.java
deleted file mode 100644
index 841dc592aa..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet138.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: set icons with different resolutions
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet138 {
- public static void main(String[] args) {
- Display display = new Display();
-
- Image small = new Image(display, 16, 16);
- GC gc = new GC(small);
- gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
- gc.fillArc(0, 0, 16, 16, 45, 270);
- gc.dispose();
-
- Image large = new Image(display, 32, 32);
- gc = new GC(large);
- gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
- gc.fillArc(0, 0, 32, 32, 45, 270);
- gc.dispose();
-
- /* Provide different resolutions for icons to get
- * high quality rendering wherever the OS needs
- * large icons. For example, the ALT+TAB window
- * on certain systems uses a larger icon.
- */
- Shell shell = new Shell(display);
- shell.setText("Small and Large icons");
- shell.setImages(new Image[] {small, large});
-
- /* No large icon: the OS will scale up the
- * small icon when it needs a large one.
- */
- Shell shell2 = new Shell(display);
- shell2.setText("Small icon");
- shell2.setImage(small);
-
- shell.open();
- shell2.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet139.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet139.java
deleted file mode 100644
index 028e580d86..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet139.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * This snippet was adapted from org.eclipse.draw2d.ImageUtilities in
- * http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/?cvsroot=Tools_Project
- * by Pratik Shah.
- *
- * example snippet: rotate and flip an image
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet139 {
-
-static ImageData rotate(ImageData srcData, int direction) {
- int bytesPerPixel = srcData.bytesPerLine / srcData.width;
- int destBytesPerLine = (direction == SWT.DOWN)? srcData.width * bytesPerPixel : srcData.height * bytesPerPixel;
- byte[] newData = new byte[srcData.data.length];
- int width = 0, height = 0;
- for (int srcY = 0; srcY < srcData.height; srcY++) {
- for (int srcX = 0; srcX < srcData.width; srcX++) {
- int destX = 0, destY = 0, destIndex = 0, srcIndex = 0;
- switch (direction){
- case SWT.LEFT: // left 90 degrees
- destX = srcY;
- destY = srcData.width - srcX - 1;
- width = srcData.height;
- height = srcData.width;
- break;
- case SWT.RIGHT: // right 90 degrees
- destX = srcData.height - srcY - 1;
- destY = srcX;
- width = srcData.height;
- height = srcData.width;
- break;
- case SWT.DOWN: // 180 degrees
- destX = srcData.width - srcX - 1;
- destY = srcData.height - srcY - 1;
- width = srcData.width;
- height = srcData.height;
- break;
- }
- destIndex = (destY * destBytesPerLine) + (destX * bytesPerPixel);
- srcIndex = (srcY * srcData.bytesPerLine) + (srcX * bytesPerPixel);
- System.arraycopy(srcData.data, srcIndex, newData, destIndex, bytesPerPixel);
- }
- }
- // destBytesPerLine is used as scanlinePad to ensure that no padding is required
- return new ImageData(width, height, srcData.depth, srcData.palette, destBytesPerLine, newData);
-}
-static ImageData flip(ImageData srcData, boolean vertical) {
- int bytesPerPixel = srcData.bytesPerLine / srcData.width;
- int destBytesPerLine = srcData.width * bytesPerPixel;
- byte[] newData = new byte[srcData.data.length];
- for (int srcY = 0; srcY < srcData.height; srcY++) {
- for (int srcX = 0; srcX < srcData.width; srcX++) {
- int destX = 0, destY = 0, destIndex = 0, srcIndex = 0;
- if (vertical){
- destX = srcX;
- destY = srcData.height - srcY - 1;
- } else {
- destX = srcData.width - srcX - 1;
- destY = srcY;
- }
- destIndex = (destY * destBytesPerLine) + (destX * bytesPerPixel);
- srcIndex = (srcY * srcData.bytesPerLine) + (srcX * bytesPerPixel);
- System.arraycopy(srcData.data, srcIndex, newData, destIndex, bytesPerPixel);
- }
- }
- // destBytesPerLine is used as scanlinePad to ensure that no padding is required
- return new ImageData(srcData.width, srcData.height, srcData.depth, srcData.palette, destBytesPerLine, newData);
-}
-
-public static void main(String[] args) {
- Display display = new Display();
-
- // create an image with the word "hello" on it
- final Image image0 = new Image(display, 50, 30);
- GC gc = new GC(image0);
- gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
- gc.fillRectangle(image0.getBounds());
- gc.drawString("hello", 5, 5, true);
- gc.dispose();
-
- ImageData data = image0.getImageData();
- // rotate and flip this image
- final Image image1 = new Image(display, rotate(data, SWT.LEFT));
- final Image image2 = new Image(display, rotate(data, SWT.RIGHT));
- final Image image3 = new Image(display, rotate(data, SWT.DOWN));
- final Image image4 = new Image(display, flip(data, true));
- final Image image5 = new Image(display, flip(data, false));
-
- Shell shell = new Shell(display);
- // draw the results on the shell
- shell.addPaintListener(new PaintListener(){
- public void paintControl(PaintEvent e) {
- e.gc.drawText("Original Image:", 10, 10, true);
- e.gc.drawImage(image0, 10, 40);
- e.gc.drawText("Left, Right, 180:", 10, 80, true);
- e.gc.drawImage(image1, 10, 110);
- e.gc.drawImage(image2, 50, 110);
- e.gc.drawImage(image3, 90, 110);
- e.gc.drawText("Flipped Vertical, Horizontal:", 10, 170, true);
- e.gc.drawImage(image4, 10, 200);
- e.gc.drawImage(image5, 70, 200);
- }
- });
- shell.setSize(300, 300);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- image0.dispose();
- image1.dispose();
- image2.dispose();
- image3.dispose();
- image4.dispose();
- image5.dispose();
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet14.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet14.java
deleted file mode 100644
index ff0109bfbc..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet14.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Control example snippet: detect mouse enter, exit and hover events
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet14 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setSize (100, 100);
- shell.addListener (SWT.MouseEnter, new Listener () {
- public void handleEvent (Event e) {
- System.out.println ("ENTER");
- }
- });
- shell.addListener (SWT.MouseExit, new Listener () {
- public void handleEvent (Event e) {
- System.out.println ("EXIT");
- }
- });
- shell.addListener (SWT.MouseHover, new Listener () {
- public void handleEvent (Event e) {
- System.out.println ("HOVER");
- }
- });
- shell.open ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet140.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet140.java
deleted file mode 100644
index 40c8b27c81..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet140.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * CoolBar example snippet: drop-down a chevron menu containing hidden tool items
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet140 {
- static Display display;
- static Shell shell;
- static CoolBar coolBar;
- static Menu chevronMenu = null;
-
-public static void main (String [] args) {
- display = new Display ();
- shell = new Shell (display);
- shell.setLayout(new GridLayout());
- coolBar = new CoolBar(shell, SWT.FLAT | SWT.BORDER);
- coolBar.setLayoutData(new GridData(GridData.FILL_BOTH));
- ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT | SWT.WRAP);
- int minWidth = 0;
- for (int j = 0; j < 5; j++) {
- int width = 0;
- ToolItem item = new ToolItem(toolBar, SWT.PUSH);
- item.setText("B" + j);
- width = item.getWidth();
- /* find the width of the widest tool */
- if (width > minWidth) minWidth = width;
- }
- CoolItem coolItem = new CoolItem(coolBar, SWT.DROP_DOWN);
- coolItem.setControl(toolBar);
- Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point coolSize = coolItem.computeSize (size.x, size.y);
- coolItem.setMinimumSize(minWidth, coolSize.y);
- coolItem.setPreferredSize(coolSize);
- coolItem.setSize(coolSize);
- coolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- if (event.detail == SWT.ARROW) {
- CoolItem item = (CoolItem) event.widget;
- Rectangle itemBounds = item.getBounds ();
- Point pt = coolBar.toDisplay(new Point(itemBounds.x, itemBounds.y));
- itemBounds.x = pt.x;
- itemBounds.y = pt.y;
- ToolBar toolBar = (ToolBar) item.getControl ();
- ToolItem[] tools = toolBar.getItems ();
-
- int i = 0;
- while (i < tools.length) {
- Rectangle toolBounds = tools[i].getBounds ();
- pt = toolBar.toDisplay(new Point(toolBounds.x, toolBounds.y));
- toolBounds.x = pt.x;
- toolBounds.y = pt.y;
-
- /* Figure out the visible portion of the tool by looking at the
- * intersection of the tool bounds with the cool item bounds. */
- Rectangle intersection = itemBounds.intersection (toolBounds);
-
- /* If the tool is not completely within the cool item bounds, then it
- * is partially hidden, and all remaining tools are completely hidden. */
- if (!intersection.equals (toolBounds)) break;
- i++;
- }
-
- /* Create a menu with items for each of the completely hidden buttons. */
- if (chevronMenu != null) chevronMenu.dispose();
- chevronMenu = new Menu (coolBar);
- for (int j = i; j < tools.length; j++) {
- MenuItem menuItem = new MenuItem (chevronMenu, SWT.PUSH);
- menuItem.setText (tools[j].getText());
- }
-
- /* Drop down the menu below the chevron, with the left edges aligned. */
- pt = coolBar.toDisplay(new Point(event.x, event.y));
- chevronMenu.setLocation (pt.x, pt.y);
- chevronMenu.setVisible (true);
- }
- }
- });
-
- shell.pack();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet141.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet141.java
deleted file mode 100644
index 476ccb6414..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet141.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Image example snippet: display an animated GIF
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet141 {
- static Display display;
- static Shell shell;
- static GC shellGC;
- static Color shellBackground;
- static ImageLoader loader;
- static ImageData[] imageDataArray;
- static Thread animateThread;
- static Image image;
- static final boolean useGIFBackground = false;
-
- public static void main(String[] args) {
- display = new Display();
- shell = new Shell(display);
- shell.setSize(300, 300);
- shell.open();
- shellGC = new GC(shell);
- shellBackground = shell.getBackground();
-
- FileDialog dialog = new FileDialog(shell);
- dialog.setFilterExtensions(new String[] {"*.gif"});
- String fileName = dialog.open();
- if (fileName != null) {
- loader = new ImageLoader();
- try {
- imageDataArray = loader.load(fileName);
- if (imageDataArray.length > 1) {
- animateThread = new Thread("Animation") {
- public void run() {
- /* Create an off-screen image to draw on, and fill it with the shell background. */
- Image offScreenImage = new Image(display, loader.logicalScreenWidth, loader.logicalScreenHeight);
- GC offScreenImageGC = new GC(offScreenImage);
- offScreenImageGC.setBackground(shellBackground);
- offScreenImageGC.fillRectangle(0, 0, loader.logicalScreenWidth, loader.logicalScreenHeight);
-
- try {
- /* Create the first image and draw it on the off-screen image. */
- int imageDataIndex = 0;
- ImageData imageData = imageDataArray[imageDataIndex];
- if (image != null && !image.isDisposed()) image.dispose();
- image = new Image(display, imageData);
- offScreenImageGC.drawImage(
- image,
- 0,
- 0,
- imageData.width,
- imageData.height,
- imageData.x,
- imageData.y,
- imageData.width,
- imageData.height);
-
- /* Now loop through the images, creating and drawing each one
- * on the off-screen image before drawing it on the shell. */
- int repeatCount = loader.repeatCount;
- while (loader.repeatCount == 0 || repeatCount > 0) {
- switch (imageData.disposalMethod) {
- case SWT.DM_FILL_BACKGROUND:
- /* Fill with the background color before drawing. */
- Color bgColor = null;
- if (useGIFBackground && loader.backgroundPixel != -1) {
- bgColor = new Color(display, imageData.palette.getRGB(loader.backgroundPixel));
- }
- offScreenImageGC.setBackground(bgColor != null ? bgColor : shellBackground);
- offScreenImageGC.fillRectangle(imageData.x, imageData.y, imageData.width, imageData.height);
- if (bgColor != null) bgColor.dispose();
- break;
- case SWT.DM_FILL_PREVIOUS:
- /* Restore the previous image before drawing. */
- offScreenImageGC.drawImage(
- image,
- 0,
- 0,
- imageData.width,
- imageData.height,
- imageData.x,
- imageData.y,
- imageData.width,
- imageData.height);
- break;
- }
-
- imageDataIndex = (imageDataIndex + 1) % imageDataArray.length;
- imageData = imageDataArray[imageDataIndex];
- image.dispose();
- image = new Image(display, imageData);
- offScreenImageGC.drawImage(
- image,
- 0,
- 0,
- imageData.width,
- imageData.height,
- imageData.x,
- imageData.y,
- imageData.width,
- imageData.height);
-
- /* Draw the off-screen image to the shell. */
- shellGC.drawImage(offScreenImage, 0, 0);
-
- /* Sleep for the specified delay time (adding commonly-used slow-down fudge factors). */
- try {
- int ms = imageData.delayTime * 10;
- if (ms < 20) ms += 30;
- if (ms < 30) ms += 10;
- Thread.sleep(ms);
- } catch (InterruptedException e) {
- }
-
- /* If we have just drawn the last image, decrement the repeat count and start again. */
- if (imageDataIndex == imageDataArray.length - 1) repeatCount--;
- }
- } catch (SWTException ex) {
- System.out.println("There was an error animating the GIF");
- } finally {
- if (offScreenImage != null && !offScreenImage.isDisposed()) offScreenImage.dispose();
- if (offScreenImageGC != null && !offScreenImageGC.isDisposed()) offScreenImageGC.dispose();
- if (image != null && !image.isDisposed()) image.dispose();
- }
- }
- };
- animateThread.setDaemon(true);
- animateThread.start();
- }
- } catch (SWTException ex) {
- System.out.println("There was an error loading the GIF");
- }
- }
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet142.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet142.java
deleted file mode 100644
index 90cd4125f2..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet142.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * UI Automation (for testing tools) snippet: post mouse events
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet142 {
-
-public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- final Button button = new Button(shell,SWT.NONE);
- button.setSize(100,100);
- button.setText("Click");
- shell.pack();
- shell.open();
- button.addListener(SWT.MouseDown, new Listener() {
- public void handleEvent(Event e){
- System.out.println("Mouse Down (button: " + e.button + " x: " + e.x + " y: " + e.y + ")");
- }
- });
- final Point pt = display.map(shell, null, 50, 50);
- new Thread(){
- Event event;
- public void run(){
- try {
- Thread.sleep(300);
- } catch (InterruptedException e) {}
- event = new Event();
- event.type = SWT.MouseMove;
- event.x = pt.x;
- event.y = pt.y;
- display.post(event);
- try {
- Thread.sleep(300);
- } catch (InterruptedException e) {}
- event.type = SWT.MouseDown;
- event.button = 1;
- display.post(event);
- try {
- Thread.sleep(300);
- } catch (InterruptedException e) {}
- event.type = SWT.MouseUp;
- display.post(event);
- }
- }.start();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet143.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet143.java
deleted file mode 100644
index d513439c01..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet143.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Tray example snippet: place an icon with a popup menu on the system tray
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet143 {
-
-public static void main(String[] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Image image = new Image (display, 16, 16);
- final Tray tray = display.getSystemTray ();
- final TrayItem item = new TrayItem (tray, SWT.NONE);
- item.setToolTipText("SWT TrayItem");
- item.addListener (SWT.Show, new Listener () {
- public void handleEvent (Event event) {
- System.out.println("show");
- }
- });
- item.addListener (SWT.Hide, new Listener () {
- public void handleEvent (Event event) {
- System.out.println("hide");
- }
- });
- item.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event event) {
- System.out.println("selection");
- }
- });
- item.addListener (SWT.DefaultSelection, new Listener () {
- public void handleEvent (Event event) {
- System.out.println("default selection");
- }
- });
- final Menu menu = new Menu (shell, SWT.POP_UP);
- for (int i = 0; i < 8; i++) {
- MenuItem mi = new MenuItem (menu, SWT.PUSH);
- mi.setText ("Item" + i);
- }
- item.addListener (SWT.MenuDetect, new Listener () {
- public void handleEvent (Event event) {
- menu.setVisible (true);
- }
- });
- item.setImage (image);
- shell.setBounds(50, 50, 300, 200);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- image.dispose ();
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet144.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet144.java
deleted file mode 100644
index 4970babf4c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet144.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Virtual Table example snippet: create a table with 1,000,000 items
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet144 {
-
-static final int COUNT = 1000000;
-
-public static void main(String[] args) {
- Display display = new Display ();
- final Shell shell = new Shell (display);
- shell.setLayout (new RowLayout (SWT.VERTICAL));
- final Table table = new Table (shell, SWT.VIRTUAL | SWT.BORDER);
- table.addListener (SWT.SetData, new Listener () {
- public void handleEvent (Event event) {
- TableItem item = (TableItem) event.item;
- int index = table.indexOf (item);
- item.setText ("Item " + index);
- System.out.println (item.getText ());
- }
- });
- table.setLayoutData (new RowData (200, 200));
- Button button = new Button (shell, SWT.PUSH);
- button.setText ("Add Items");
- final Label label = new Label(shell, SWT.NONE);
- button.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event event) {
- long t1 = System.currentTimeMillis ();
- table.setItemCount (COUNT);
- long t2 = System.currentTimeMillis ();
- label.setText ("Items: " + COUNT + ", Time: " + (t2 - t1) + " (ms)");
- shell.layout ();
- }
- });
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet145.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet145.java
deleted file mode 100644
index eee2f9770a..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet145.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * TextLayout example snippet: draw internationalized styled text on a shell
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-
-public class Snippet145 {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell (display);
-
- Font font1 = new Font(display, "Tahoma", 14, SWT.BOLD);
- Font font2 = new Font(display, "MS Mincho", 20, SWT.ITALIC);
- Font font3 = new Font(display, "Arabic Transparent", 18, SWT.NORMAL);
-
- Color blue = display.getSystemColor(SWT.COLOR_BLUE);
- Color green = display.getSystemColor(SWT.COLOR_GREEN);
- Color yellow = display.getSystemColor(SWT.COLOR_YELLOW);
- Color gray = display.getSystemColor(SWT.COLOR_GRAY);
-
- final TextLayout layout = new TextLayout(display);
- TextStyle style1 = new TextStyle(font1, yellow, blue);
- TextStyle style2 = new TextStyle(font2, green, null);
- TextStyle style3 = new TextStyle(font3, blue, gray);
-
- layout.setText("English \u65E5\u672C\u8A9E \u0627\u0644\u0639\u0631\u0628\u064A\u0651\u0629");
- layout.setStyle(style1, 0, 6);
- layout.setStyle(style2, 8, 10);
- layout.setStyle(style3, 13, 21);
-
- shell.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
- shell.addListener(SWT.Paint, new Listener() {
- public void handleEvent (Event event) {
- layout.draw(event.gc, 10, 10);
- }
- });
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- font1.dispose();
- font2.dispose();
- font3.dispose();
- layout.dispose();
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet146.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet146.java
deleted file mode 100644
index f461762676..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet146.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * UI Automation (for testing tools) snippet: post key events
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet146 {
-
-public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- final Text text = new Text(shell, SWT.BORDER);
- text.setSize(text.computeSize(150, SWT.DEFAULT));
- shell.pack();
- shell.open();
- new Thread(){
- public void run(){
- String string = "Love the method.";
- for (int i = 0; i < string.length(); i++) {
- char ch = string.charAt(i);
- boolean shift = Character.isUpperCase(ch);
- ch = Character.toLowerCase(ch);
- if (shift) {
- Event event = new Event();
- event.type = SWT.KeyDown;
- event.keyCode = SWT.SHIFT;
- display.post(event);
- }
- Event event = new Event();
- event.type = SWT.KeyDown;
- event.character = ch;
- display.post(event);
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {}
- event.type = SWT.KeyUp;
- display.post(event);
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {}
- if (shift) {
- event = new Event();
- event.type = SWT.KeyUp;
- event.keyCode = SWT.SHIFT;
- display.post(event);
- }
- }
- }
- }.start();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet147.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet147.java
deleted file mode 100644
index 57857b0520..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet147.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Text example snippet: stop CR from going to the default button
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet147 {
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
- Combo combo = new Combo(shell, SWT.NONE);
- combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- combo.setText("Here is some text");
- combo.addSelectionListener(new SelectionAdapter() {
- public void widgetDefaultSelected(SelectionEvent e) {
- System.out.println("Combo default selected (overrides default button)");
- }
- });
- combo.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- e.detail = SWT.TRAVERSE_NONE;
- }
- }
- });
- Button button = new Button(shell, SWT.PUSH);
- button.setText("Ok");
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- System.out.println("Button selected");
- }
- });
- shell.setDefaultButton(button);
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet148.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet148.java
deleted file mode 100644
index 0de0f3388c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet148.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Text example snippet: check if the browser is available or not
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.browser.*;
-
-public class Snippet148 {
-
- public static void main(String[] args) {
- final Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Browser browser = null;
- try {
- browser = new Browser(shell, SWT.NONE);
- } catch (SWTError e) {
- /* The Browser widget throws an SWTError if it fails to
- * instantiate properly. Application code should catch
- * this SWTError and disable any feature requiring the
- * Browser widget.
- * Platform requirements for the SWT Browser widget are available
- * from the SWT FAQ website.
- */
- }
- if (browser != null) {
- /* The Browser widget can be used */
- browser.setUrl("http://www.eclipse.org");
- }
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
-
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet149.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet149.java
deleted file mode 100644
index a79726b944..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet149.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * TableEditor example snippet: place a progress bar in a table
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.custom.*;
-
-public class Snippet149 {
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout (new FillLayout ());
- Table table = new Table (shell, SWT.BORDER);
- table.setHeaderVisible (true);
- for (int i=0; i<2; i++) {
- TableColumn column = new TableColumn (table, SWT.NONE);
- }
- table.getColumn (0).setText ("Task");
- table.getColumn (1).setText ("Progress");
- for (int i=0; i<4; i++) {
- TableItem item = new TableItem (table, SWT.NONE);
- item.setText ("Task " + i);
- ProgressBar bar = new ProgressBar (table, SWT.NONE);
- bar.setSelection (i * 25);
- TableEditor editor = new TableEditor (table);
- editor.grabHorizontal = editor.grabVertical = true;
- editor.setEditor (bar, item, 1);
- }
- table.getColumn (0).pack ();
- table.getColumn (1).setWidth (128);
- shell.pack ();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet15.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet15.java
deleted file mode 100644
index 5328052fc7..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet15.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Tree example snippet: create a tree
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet15 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- final Tree tree = new Tree (shell, SWT.BORDER);
- tree.setSize (100, 100);
- shell.setSize (200, 200);
- for (int i=0; i<4; i++) {
- TreeItem iItem = new TreeItem (tree, 0);
- iItem.setText ("TreeItem (0) -" + i);
- for (int j=0; j<4; j++) {
- TreeItem jItem = new TreeItem (iItem, 0);
- jItem.setText ("TreeItem (1) -" + j);
- for (int k=0; k<4; k++) {
- TreeItem kItem = new TreeItem (jItem, 0);
- kItem.setText ("TreeItem (2) -" + k);
- for (int l=0; l<4; l++) {
- TreeItem lItem = new TreeItem (kItem, 0);
- lItem.setText ("TreeItem (3) -" + l);
- }
- }
- }
- }
- shell.open ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java
deleted file mode 100644
index 54fb72092b..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * CoolBar example snippet: create a coolbar (relayout when resized)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet150 {
-
-static int itemCount;
-static CoolItem createItem(CoolBar coolBar, int count) {
- ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT);
- for (int i = 0; i < count; i++) {
- ToolItem item = new ToolItem(toolBar, SWT.PUSH);
- item.setText(itemCount++ +"");
- }
- toolBar.pack();
- Point size = toolBar.getSize();
- CoolItem item = new CoolItem(coolBar, SWT.NONE);
- item.setControl(toolBar);
- Point preferred = item.computeSize(size.x, size.y);
- item.setPreferredSize(preferred);
- return item;
-}
-
-public static void main(String[] args) {
- Display display = new Display();
- final Shell shell = new Shell(display);
- CoolBar coolBar = new CoolBar(shell, SWT.NONE);
- createItem(coolBar, 3);
- createItem(coolBar, 2);
- createItem(coolBar, 3);
- createItem(coolBar, 4);
- int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
- Text text = new Text(shell, style);
- FormLayout layout = new FormLayout();
- shell.setLayout(layout);
- FormData coolData = new FormData();
- coolData.left = new FormAttachment(0);
- coolData.right = new FormAttachment(100);
- coolData.top = new FormAttachment(0);
- coolBar.setLayoutData(coolData);
- coolBar.addListener(SWT.Resize, new Listener() {
- public void handleEvent(Event event) {
- shell.layout();
- }
- });
- FormData textData = new FormData();
- textData.left = new FormAttachment(0);
- textData.right = new FormAttachment(100);
- textData.top = new FormAttachment(coolBar);
- textData.bottom = new FormAttachment(100);
- text.setLayoutData(textData);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java
deleted file mode 100644
index 612057cdb0..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Create a virtual table and add 1000 entries to it every 500 ms.
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.util.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet151 {
-
-static int[] data = new int[0];
-
-public static void main (String [] args) {
- final Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
- final Table table = new Table(shell, SWT.BORDER | SWT.VIRTUAL);
- table.addListener(SWT.SetData, new Listener() {
- public void handleEvent(Event e) {
- TableItem item = (TableItem)e.item;
- int index = table.indexOf(item);
- item.setText("Item "+data[index]);
- }
- });
- Thread thread = new Thread() {
- public void run() {
- int count = 0;
- Random random = new Random();
- while (count++ < 500) {
- if (table.isDisposed()) return;
- // add 10 random numbers to array and sort
- int grow = 10;
- int[] newData = new int[data.length + grow];
- System.arraycopy(data, 0, newData, 0, data.length);
- int index = data.length;
- data = newData;
- for (int j = 0; j < grow; j++) {
- data[index++] = random.nextInt();
- }
- Arrays.sort(data);
- display.syncExec(new Runnable() {
- public void run() {
- if (table.isDisposed()) return;
- table.setItemCount(data.length);
- table.clearAll();
- }
- });
- try {Thread.sleep(500);} catch (Throwable t) {}
- }
- }
- };
- thread.start();
- shell.open ();
- while (!shell.isDisposed() || thread.isAlive()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet152.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet152.java
deleted file mode 100644
index 92ef6cc11c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet152.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Control example snippet: update a status line when an item is armed
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet152 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- FormLayout layout = new FormLayout();
- shell.setLayout(layout);
- final Label label = new Label(shell, SWT.BORDER);
- Listener armListener = new Listener() {
- public void handleEvent(Event event) {
- MenuItem item = (MenuItem) event.widget;
- label.setText(item.getText());
- label.update();
- }
- };
- Listener showListener = new Listener() {
- public void handleEvent(Event event) {
- Menu menu = (Menu) event.widget;
- MenuItem item = menu.getParentItem();
- if (item != null) {
- label.setText(item.getText());
- label.update();
- }
- }
- };
- Listener hideListener = new Listener() {
- public void handleEvent(Event event) {
- label.setText("");
- label.update();
- }
- };
- FormData labelData = new FormData();
- labelData.left = new FormAttachment(0);
- labelData.right = new FormAttachment(100);
- labelData.bottom = new FormAttachment(100);
- label.setLayoutData(labelData);
- Menu menuBar = new Menu(shell, SWT.BAR);
- shell.setMenuBar(menuBar);
- MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
- fileItem.setText("File");
- fileItem.addListener(SWT.Arm, armListener);
- MenuItem editItem = new MenuItem(menuBar, SWT.CASCADE);
- editItem.setText("Edit");
- editItem.addListener(SWT.Arm, armListener);
- Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
- fileMenu.addListener(SWT.Hide, hideListener);
- fileMenu.addListener(SWT.Show, showListener);
- fileItem.setMenu(fileMenu);
- String[] fileStrings = { "New", "Close", "Exit" };
- for (int i = 0; i < fileStrings.length; i++) {
- MenuItem item = new MenuItem(fileMenu, SWT.PUSH);
- item.setText(fileStrings[i]);
- item.addListener(SWT.Arm, armListener);
- }
- Menu editMenu = new Menu(shell, SWT.DROP_DOWN);
- editMenu.addListener(SWT.Hide, hideListener);
- editMenu.addListener(SWT.Show, showListener);
- String[] editStrings = { "Cut", "Copy", "Paste" };
- editItem.setMenu(editMenu);
- for (int i = 0; i < editStrings.length; i++) {
- MenuItem item = new MenuItem(editMenu, SWT.PUSH);
- item.setText(editStrings[i]);
- item.addListener(SWT.Arm, armListener);
- }
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet153.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet153.java
deleted file mode 100644
index 39818d0915..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet153.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ToolBar example snippet: update a status line when the pointer enters a ToolItem
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet153 {
-
-static String statusText = "";
-public static void main(String[] args) {
- final Display display = new Display();
- Shell shell = new Shell(display);
- shell.setBounds(10, 10, 200, 200);
- final ToolBar bar = new ToolBar(shell, SWT.BORDER);
- bar.setBounds(10, 10, 150, 50);
- final Label statusLine = new Label(shell, SWT.BORDER);
- statusLine.setBounds(10, 90, 150, 30);
- new ToolItem(bar, SWT.NONE).setText("item 1");
- new ToolItem(bar, SWT.NONE).setText("item 2");
- new ToolItem(bar, SWT.NONE).setText("item 3");
- bar.addMouseMoveListener(new MouseMoveListener() {
- public void mouseMove(MouseEvent e) {
- ToolItem item = bar.getItem(new Point(e.x, e.y));
- String name = "";
- if (item != null) {
- name = item.getText();
- }
- if (!statusText.equals(name)) {
- statusLine.setText(name);
- statusText = name;
- }
- }
- });
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
deleted file mode 100644
index 693f14bc6f..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet154.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: embed a JTable in SWT (no flicker)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.awt.BorderLayout;
-import java.awt.Frame;
-import java.awt.Panel;
-import javax.swing.*;
-import java.util.Vector;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.awt.SWT_AWT;
-
-public class Snippet154 {
-
- public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
-
- Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED);
-
- /*
- * Set a Windows specific AWT property that prevents heavyweight
- * components from erasing their background. Note that this
- * is a global property and cannot be scoped. It might not be
- * suitable for your application.
- */
- try {
- System.setProperty("sun.awt.noerasebackground","true");
- } catch (NoSuchMethodError error) {}
-
- /* Create and setting up frame */
- Frame frame = SWT_AWT.new_Frame(composite);
- Panel panel = new Panel(new BorderLayout()) {
- public void update(java.awt.Graphics g) {
- /* Do not erase the background */
- paint(g);
- }
- };
- frame.add(panel);
- JRootPane root = new JRootPane();
- panel.add(root);
- java.awt.Container contentPane = root.getContentPane();
-
- /* Creating components */
- int nrows = 1000, ncolumns = 10;
- Vector rows = new Vector();
- for (int i = 0; i < nrows; i++) {
- Vector row = new Vector();
- for (int j = 0; j < ncolumns; j++) {
- row.addElement("Item " + i + "-" + j);
- }
- rows.addElement(row);
- }
- Vector columns = new Vector();
- for (int i = 0; i < ncolumns; i++) {
- columns.addElement("Column " + i);
- }
- JTable table = new JTable(rows, columns);
- table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
- table.createDefaultColumnsFromModel();
- JScrollPane scrollPane = new JScrollPane(table);
- contentPane.setLayout(new BorderLayout());
- contentPane.add(scrollPane);
-
- shell.open();
- while(!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet155.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet155.java
deleted file mode 100644
index 09f7aebbf0..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet155.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: draw an X using AWT Graphics
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.awt.Frame;
-import java.awt.Canvas;
-import java.awt.Graphics;
-import java.awt.Dimension;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.awt.SWT_AWT;
-
-public class Snippet155 {
-
- public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Composite composite = new Composite(shell, SWT.EMBEDDED);
-
- /* Draw an X using AWT */
- Frame frame = SWT_AWT.new_Frame(composite);
- Canvas canvas = new Canvas() {
- public void paint (Graphics g) {
- Dimension d = getSize();
- g.drawLine(0, 0, d.width, d.height);
- g.drawLine(d.width, 0, 0, d.height);
- }
- };
- frame.add(canvas);
-
- shell.open();
- while(!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
- }
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet156.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet156.java
deleted file mode 100644
index 8698e33e20..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet156.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: convert between SWT Image and AWT BufferedImage
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Insets;
-import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.DirectColorModel;
-import java.awt.image.IndexColorModel;
-import java.awt.image.WritableRaster;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-
-public class Snippet156 {
-
-static BufferedImage convertToAWT(ImageData data) {
- ColorModel colorModel = null;
- PaletteData palette = data.palette;
- if (palette.isDirect) {
- colorModel = new DirectColorModel(data.depth, palette.redMask, palette.greenMask, palette.blueMask);
- BufferedImage bufferedImage = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(data.width, data.height), false, null);
- WritableRaster raster = bufferedImage.getRaster();
- int[] pixelArray = new int[3];
- for (int y = 0; y < data.height; y++) {
- for (int x = 0; x < data.width; x++) {
- int pixel = data.getPixel(x, y);
- RGB rgb = palette.getRGB(pixel);
- pixelArray[0] = rgb.red;
- pixelArray[1] = rgb.green;
- pixelArray[2] = rgb.blue;
- raster.setPixels(x, y, 1, 1, pixelArray);
- }
- }
- return bufferedImage;
- } else {
- RGB[] rgbs = palette.getRGBs();
- byte[] red = new byte[rgbs.length];
- byte[] green = new byte[rgbs.length];
- byte[] blue = new byte[rgbs.length];
- for (int i = 0; i < rgbs.length; i++) {
- RGB rgb = rgbs[i];
- red[i] = (byte)rgb.red;
- green[i] = (byte)rgb.green;
- blue[i] = (byte)rgb.blue;
- }
- if (data.transparentPixel != -1) {
- colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue, data.transparentPixel);
- } else {
- colorModel = new IndexColorModel(data.depth, rgbs.length, red, green, blue);
- }
- BufferedImage bufferedImage = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(data.width, data.height), false, null);
- WritableRaster raster = bufferedImage.getRaster();
- int[] pixelArray = new int[1];
- for (int y = 0; y < data.height; y++) {
- for (int x = 0; x < data.width; x++) {
- int pixel = data.getPixel(x, y);
- pixelArray[0] = pixel;
- raster.setPixel(x, y, pixelArray);
- }
- }
- return bufferedImage;
- }
-}
-
-static ImageData convertToSWT(BufferedImage bufferedImage) {
- if (bufferedImage.getColorModel() instanceof DirectColorModel) {
- DirectColorModel colorModel = (DirectColorModel)bufferedImage.getColorModel();
- PaletteData palette = new PaletteData(colorModel.getRedMask(), colorModel.getGreenMask(), colorModel.getBlueMask());
- ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette);
- WritableRaster raster = bufferedImage.getRaster();
- int[] pixelArray = new int[3];
- for (int y = 0; y < data.height; y++) {
- for (int x = 0; x < data.width; x++) {
- raster.getPixel(x, y, pixelArray);
- int pixel = palette.getPixel(new RGB(pixelArray[0], pixelArray[1], pixelArray[2]));
- data.setPixel(x, y, pixel);
- }
- }
- return data;
- } else if (bufferedImage.getColorModel() instanceof IndexColorModel) {
- IndexColorModel colorModel = (IndexColorModel)bufferedImage.getColorModel();
- int size = colorModel.getMapSize();
- byte[] reds = new byte[size];
- byte[] greens = new byte[size];
- byte[] blues = new byte[size];
- colorModel.getReds(reds);
- colorModel.getGreens(greens);
- colorModel.getBlues(blues);
- RGB[] rgbs = new RGB[size];
- for (int i = 0; i < rgbs.length; i++) {
- rgbs[i] = new RGB(reds[i] & 0xFF, greens[i] & 0xFF, blues[i] & 0xFF);
- }
- PaletteData palette = new PaletteData(rgbs);
- ImageData data = new ImageData(bufferedImage.getWidth(), bufferedImage.getHeight(), colorModel.getPixelSize(), palette);
- data.transparentPixel = colorModel.getTransparentPixel();
- WritableRaster raster = bufferedImage.getRaster();
- int[] pixelArray = new int[1];
- for (int y = 0; y < data.height; y++) {
- for (int x = 0; x < data.width; x++) {
- raster.getPixel(x, y, pixelArray);
- data.setPixel(x, y, pixelArray[0]);
- }
- }
- return data;
- }
- return null;
-}
-
-static ImageData createSampleImage(Display display) {
- Image image = new Image(display, 100, 100);
- Rectangle bounds = image.getBounds();
- GC gc = new GC(image);
- gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
- gc.fillRectangle(bounds);
- gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
- gc.fillOval(0, 0, bounds.width, bounds.height);
- gc.setForeground(display.getSystemColor(SWT.COLOR_RED));
- gc.drawLine(0, 0, bounds.width, bounds.height);
- gc.drawLine(bounds.width, 0, 0, bounds.height);
- gc.dispose();
- ImageData data = image.getImageData();
- image.dispose();
- return data;
-}
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setText("SWT Image");
- ImageData data;
- if (args.length > 0) {
- String fileName = args[0];
- data = new ImageData(fileName);
- } else {
- data = createSampleImage(display);
- }
- final Image swtImage = new Image(display, data);
- final BufferedImage awtImage = convertToAWT(data);
- final Image swtImage2 = new Image(display, convertToSWT(awtImage));
- shell.addListener(SWT.Paint, new Listener() {
- public void handleEvent(Event e) {
- int y = 10;
- if (swtImage != null) {
- e.gc.drawImage(swtImage, 10, y);
- y += swtImage.getBounds().height + 10;
- }
- if (swtImage2 != null) {
- e.gc.drawImage(swtImage2, 10, y);
- }
- }
- });
- Frame frame = new Frame() {
- public void paint(Graphics g) {
- Insets insets = getInsets();
- if (awtImage != null) {
- g.drawImage(awtImage, 10 + insets.left, 10 + insets.top, null);
- }
- }
- };
- frame.setTitle("AWT Image");
- shell.setLocation(50, 50);
- Rectangle bounds = swtImage.getBounds();
- shell.setSize(bounds.width + 50, bounds.height * 2 + 100);
- Point size = shell.getSize();
- Point location = shell.getLocation();
- Insets insets = frame.getInsets();
- frame.setLocation(location.x + size.x + 10, location.y);
- frame.setSize(size.x - (insets.left + insets.right), size.y - (insets.top + insets.bottom));
- frame.setVisible(true);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- if (swtImage != null) swtImage.dispose();
- if (swtImage2 != null) swtImage.dispose();
- frame.dispose();
- System.exit(0);
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet157.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet157.java
deleted file mode 100644
index b966aecdc9..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet157.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * example snippet: Embed Word in an applet
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import java.applet.*;
-
-public class Snippet157 extends Applet {
-
- org.eclipse.swt.widgets.Display display;
- org.eclipse.swt.widgets.Shell swtParent;
- java.awt.Canvas awtParent;
-
-public void init () {
- Thread thread = new Thread (new Runnable () {
- public void run () {
- setLayout(new java.awt.GridLayout (1, 1));
- awtParent = new java.awt.Canvas ();
- add (awtParent);
- display = new org.eclipse.swt.widgets.Display ();
- swtParent = org.eclipse.swt.awt.SWT_AWT.new_Shell (display, awtParent);
- swtParent.setLayout (new org.eclipse.swt.layout.FillLayout ());
- org.eclipse.swt.ole.win32.OleFrame frame = new org.eclipse.swt.ole.win32.OleFrame (swtParent, org.eclipse.swt.SWT.NONE);
- org.eclipse.swt.ole.win32.OleClientSite site;
- try {
- site = new org.eclipse.swt.ole.win32.OleClientSite (frame, org.eclipse.swt.SWT.NONE, "Word.Document");
- } catch (org.eclipse.swt.SWTException e) {
- String str = "Create OleClientSite Error" + e.toString ();
- System.out.println (str);
- return;
- }
- setSize (500, 500);
- validate ();
- site.doVerb (org.eclipse.swt.ole.win32.OLE.OLEIVERB_SHOW);
-
- while (swtParent != null && !swtParent.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- }
- });
- thread.start ();
-}
- public void stop (){
- if (display != null && !display.isDisposed ()){
- display.syncExec(new Runnable () {
- public void run () {
- if (swtParent != null && !swtParent.isDisposed ()) swtParent.dispose ();
- swtParent = null;
- display.dispose ();
- display = null;
- }
- });
- remove (awtParent);
- awtParent = null;
- }
- }
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet158.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet158.java
deleted file mode 100644
index 6be7c80ee4..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet158.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: determine native data types available (motif only)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.motif.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet158 extends ByteArrayTransfer {
-
-private static Snippet158 _instance = new Snippet158();
-private int[] ids;
-private String[] names;
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Table control = new Table(shell, SWT.NONE);
- TableItem item = new TableItem(control, SWT.NONE);
- item.setText("Drag data over this site to see the native transfer type.");
- DropTarget target = new DropTarget(control, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_MOVE);
- target.setTransfer(new Transfer[] {Snippet158.getInstance()});
- target.addDropListener(new DropTargetAdapter() {
- public void dragEnter(DropTargetEvent event) {
- String ops = "";
- if ((event.operations & DND.DROP_COPY) != 0) ops += "Copy;";
- if ((event.operations & DND.DROP_MOVE) != 0) ops += "Move;";
- if ((event.operations & DND.DROP_LINK) != 0) ops += "Link;";
- control.removeAll();
- TableItem item1 = new TableItem(control,SWT.NONE);
- item1.setText("Allowed Operations are "+ops);
-
- if (event.detail == DND.DROP_DEFAULT) {
- if ((event.operations & DND.DROP_COPY) != 0) {
- event.detail = DND.DROP_COPY;
- } else if ((event.operations & DND.DROP_LINK) != 0) {
- event.detail = DND.DROP_LINK;
- } else if ((event.operations & DND.DROP_MOVE) != 0) {
- event.detail = DND.DROP_MOVE;
- }
- }
-
- TransferData[] data = event.dataTypes;
- for (int i = 0; i < data.length; i++) {
- int id = data[i].type;
- String name = getNameFromId(id);
- TableItem item2 = new TableItem(control,SWT.NONE);
- item2.setText("Data type is "+id+" "+name);
- }
- }
- });
-
- shell.setSize(400, 400);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-
-public static Snippet158 getInstance () {
- return _instance;
-}
-Snippet158() {
-}
-public void javaToNative (Object object, TransferData transferData) {
-}
-public Object nativeToJava(TransferData transferData){
- return "Hello World";
-}
-protected String[] getTypeNames(){
- return names;
-}
-static int shellHandle;
-protected int[] getTypeIds(){
- if (ids == null) {
- Display display = Display.getCurrent();
- int widgetClass = OS.topLevelShellWidgetClass ();
- shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);
- OS.XtSetMappedWhenManaged (shellHandle, false);
- OS.XtRealizeWidget (shellHandle);
-
- ids = new int[840];
- names = new String[840];
- for (int i = 0; i < ids.length; i++) {
- ids[i] = i+i;
- names[i] = getNameFromId(i+1);
- }
- }
- return ids;
-}
-static String getNameFromId(int id) {
- int xDisplay = OS.XtDisplay (shellHandle);
- int ptr = 0;
- try {
- ptr = OS.XmGetAtomName(xDisplay, id);
- } catch (Throwable t) {
- }
- if (ptr == 0) return "invalid "+id;
- int length = OS.strlen(ptr);
- byte[] nameBuf = new byte[length];
- OS.memmove(nameBuf, ptr, length);
- OS.XFree(ptr);
- return new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet159.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet159.java
deleted file mode 100644
index 360d88dd40..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet159.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Browser example snippet: modify HTML title tag
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet159 {
- public static void main(String [] args) {
- final String newTitle = "New Value for Title";
- Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Browser browser = new Browser(shell, SWT.NONE);
- browser.addTitleListener(new TitleListener() {
- public void changed(TitleEvent event) {
- System.out.println("TitleEvent: "+event.title);
- shell.setText(event.title);
- }
- });
- browser.addProgressListener(new ProgressListener() {
- public void changed(ProgressEvent event) {
- }
- public void completed(ProgressEvent event) {
- /* Set HTML title tag using JavaScript and DOM when page has been loaded */
- boolean result = browser.execute("document.title='"+newTitle+"'");
- if (!result) {
- /* Script may fail or may not be supported on certain platforms. */
- System.out.println("Script was not executed.");
- }
- }
- });
- /* Load an HTML document */
- browser.setUrl("http://www.eclipse.org");
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
-
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet16.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet16.java
deleted file mode 100644
index aeaf9bf1f8..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet16.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Display example snippet: create one repeating timer (every 500 ms)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet16 {
-
-public static void main (String [] args) {
- final Display display = new Display ();
- final Shell shell = new Shell (display);
- final int time = 500;
- Runnable timer = new Runnable () {
- public void run () {
- Point point = display.getCursorLocation ();
- Rectangle rect = shell.getBounds ();
- if (rect.contains (point)) {
- System.out.println ("In");
- } else {
- System.out.println ("Out");
- }
- display.timerExec (time, this);
- }
- };
- display.timerExec (time, timer);
- shell.setSize (200, 200);
- shell.open ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet160.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet160.java
deleted file mode 100644
index e444ced40b..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet160.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Browser example snippet: query DOM node value
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet160 {
- public static void main(String [] args) {
- final String html = "Snippet
Best Friends
Cat and Dog
";
- Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Browser browser = new Browser(shell, SWT.NONE);
- browser.addStatusTextListener(new StatusTextListener() {
- public void changed(StatusTextEvent event) {
- browser.setData("query", event.text);
- }
- });
- browser.addProgressListener(new ProgressListener() {
- public void changed(ProgressEvent event) {
- }
- public void completed(ProgressEvent event) {
- /*
- * Use JavaScript to query the desired node content through the Document Object Model
- *
- * Assign result to the window property status to pass the result to the StatusTextListener
- * This trick is required since execute does not return the String
- * directly.
- */
- boolean result = browser.execute("window.status=document.getElementById('myid').childNodes[0].nodeValue;");
- if (!result) {
- /* Script may fail or may not be supported on certain platforms. */
- System.out.println("Script was not executed.");
- return;
- }
- String value = (String)browser.getData("query");
- System.out.println("Node value: "+value);
- }
- });
- /* Load an HTML document */
- browser.setText(html);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
-
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet161.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet161.java
deleted file mode 100644
index 0d80f4e38d..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet161.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Browser example snippet: modify DOM (executing javascript)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.browser.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet161 {
- public static void main(String [] args) {
- final String html = "Snippet
Best Friends
Cat and Dog
";
- Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Browser browser = new Browser(shell, SWT.BORDER);
- Composite comp = new Composite(shell, SWT.NONE);
- comp.setLayout(new FillLayout(SWT.VERTICAL));
- final Text text = new Text(comp, SWT.MULTI);
- text.setText("var newNode = document.createElement('P'); \r\n"+
- "var text = document.createTextNode('At least when I am around');\r\n"+
- "newNode.appendChild(text);\r\n"+
- "document.getElementById('myid').appendChild(newNode);\r\n"+
- "\r\n"+
- "document.bgColor='yellow';");
- final Button button = new Button(comp, SWT.PUSH);
- button.setText("Execute Script");
- button.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- boolean result = browser.execute(text.getText());
- if (!result) {
- /* Script may fail or may not be supported on certain platforms. */
- System.out.println("Script was not executed.");
- }
- }
- });
- browser.setText(html);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-}
-
-
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet162.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet162.java
deleted file mode 100644
index 01125ae178..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet162.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Adding an accessible listener to provide state information
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.accessibility.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet162 {
-
-final static String STATE = "CheckedIndices";
-
-public static void main (String [] args) {
- final Display display = new Display ();
- Image checkedImage = getCheckedImage (display);
- Image uncheckedImage = getUncheckedImage (display);
- Shell shell = new Shell (display);
- shell.setLayout (new FillLayout ());
- final Table table = new Table (shell, SWT.BORDER);
- TableColumn column1 = new TableColumn (table, SWT.NONE);
- TableColumn column2 = new TableColumn (table, SWT.NONE);
- TableColumn column3 = new TableColumn (table, SWT.NONE);
- TableItem item1 = new TableItem (table, SWT.NONE);
- item1.setText (new String [] {"first item", "a", "b"});
- item1.setImage (1, uncheckedImage);
- item1.setImage (2, uncheckedImage);
- item1.setData (STATE, null);
- TableItem item2 = new TableItem (table, SWT.NONE);
- item2.setText (new String [] {"second item", "c", "d"});
- item2.setImage (1, uncheckedImage);
- item2.setImage (2, checkedImage);
- item2.setData (STATE, new int [] {2});
- TableItem item3 = new TableItem (table, SWT.NONE);
- item3.setText (new String [] {"third", "e", "f"});
- item3.setImage (1, checkedImage);
- item3.setImage (2, checkedImage);
- item3.setData (STATE, new int [] {1, 2});
- column1.pack ();
- column2.pack ();
- column3.pack ();
- Accessible accessible = table.getAccessible ();
- accessible.addAccessibleListener (new AccessibleAdapter () {
- public void getName (AccessibleEvent e) {
- super.getName (e);
- if (e.childID >= 0 && e.childID < table.getItemCount ()) {
- TableItem item = table.getItem (e.childID);
- Point pt = display.getCursorLocation ();
- pt = display.map (null, table, pt);
- for (int i = 0; i < table.getColumnCount (); i++) {
- if (item.getBounds (i).contains (pt)) {
- int [] data = (int []) item.getData (STATE);
- boolean checked = false;
- if (data != null) {
- for (int j = 0; j < data.length; j++) {
- if (data [j] == i) {
- checked = true;
- break;
- }
- }
- }
- e.result = item.getText (i) + " " + (checked ? "checked" : "unchecked");
- break;
- }
- }
- }
- }
- });
- accessible.addAccessibleControlListener (new AccessibleControlAdapter () {
- public void getState (AccessibleControlEvent e) {
- super.getState (e);
- if (e.childID >= 0 && e.childID < table.getItemCount ()) {
- TableItem item = table.getItem (e.childID);
- int [] data = (int []) item.getData (STATE);
- if (data != null) {
- Point pt = display.getCursorLocation ();
- pt = display.map (null, table, pt);
- for (int i = 0; i < data.length; i++) {
- if (item.getBounds (data [i]).contains (pt)) {
- e.detail |= ACC.STATE_CHECKED;
- break;
- }
- }
- }
- }
- }
- });
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- checkedImage.dispose ();
- uncheckedImage.dispose ();
- display.dispose ();
-}
-
-static Image getCheckedImage (Display display) {
- Image image = new Image (display, 16, 16);
- GC gc = new GC (image);
- gc.setBackground (display.getSystemColor (SWT.COLOR_YELLOW));
- gc.fillOval (0, 0, 16, 16);
- gc.setForeground (display.getSystemColor (SWT.COLOR_DARK_GREEN));
- gc.drawLine (0, 0, 16, 16);
- gc.drawLine (16, 0, 0, 16);
- gc.dispose ();
- return image;
-}
-
-static Image getUncheckedImage (Display display) {
- Image image = new Image (display, 16, 16);
- GC gc = new GC (image);
- gc.setBackground (display.getSystemColor (SWT.COLOR_YELLOW));
- gc.fillOval (0, 0, 16, 16);
- gc.dispose ();
- return image;
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet163.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet163.java
deleted file mode 100644
index 425078cb3c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet163.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Setting the font style, foreground and background colors of StyledText
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet163 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- StyledText text = new StyledText (shell, SWT.BORDER);
- text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
- // make 0123456789 appear bold
- StyleRange style1 = new StyleRange();
- style1.start = 0;
- style1.length = 10;
- style1.fontStyle = SWT.BOLD;
- text.setStyleRange(style1);
- // make ABCDEFGHIJKLM have a red font
- StyleRange style2 = new StyleRange();
- style2.start = 11;
- style2.length = 13;
- style2.foreground = display.getSystemColor(SWT.COLOR_RED);
- text.setStyleRange(style2);
- // make NOPQRSTUVWXYZ have a blue background
- StyleRange style3 = new StyleRange();
- style3.start = 25;
- style3.length = 13;
- style3.background = display.getSystemColor(SWT.COLOR_BLUE);
- text.setStyleRange(style3);
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java
deleted file mode 100644
index d53ac73f80..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet164.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Override the text that is spoken for a native Button.
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.accessibility.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet164 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setBounds(10, 10, 200, 200);
-
- Button button1 = new Button (shell, SWT.PUSH);
- button1.setText("&Typical button");
- button1.setBounds(10,10,180,30);
- Button button2 = new Button (shell, SWT.PUSH);
- button2.setText("&Overidden button");
- button2.setBounds(10,50,180,30);
- button2.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result = "Speak this instead of the button text";
- }
- });
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet165.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet165.java
deleted file mode 100644
index 24e17344ac..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet165.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Create a CTabFolder with min and max buttons, as well as close button and
- * image only on selected tab.
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet165 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Image image = new Image(display, 16, 16);
- GC gc = new GC(image);
- gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
- gc.fillRectangle(0, 0, 16, 16);
- gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
- gc.fillRectangle(3, 3, 10, 10);
- gc.dispose();
- final Shell shell = new Shell (display);
- shell.setLayout(new GridLayout());
- final CTabFolder folder = new CTabFolder(shell, SWT.BORDER);
- folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- folder.setSimple(false);
- folder.setUnselectedImageVisible(false);
- folder.setUnselectedCloseVisible(false);
- for (int i = 0; i < 8; i++) {
- CTabItem item = new CTabItem(folder, SWT.CLOSE);
- item.setText("Item "+i);
- item.setImage(image);
- Text text = new Text(folder, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
- text.setText("Text for item "+i+"\n\none, two, three\n\nabcdefghijklmnop");
- item.setControl(text);
- }
- folder.setMinimizeVisible(true);
- folder.setMaximizeVisible(true);
- folder.addCTabFolder2Listener(new CTabFolder2Adapter() {
- public void minimize(CTabFolderEvent event) {
- folder.setMinimized(true);
- shell.layout(true);
- }
- public void maximize(CTabFolderEvent event) {
- folder.setMaximized(true);
- folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- shell.layout(true);
- }
- public void restore(CTabFolderEvent event) {
- folder.setMinimized(false);
- folder.setMaximized(false);
- folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- shell.layout(true);
- }
- });
- shell.setSize(300, 300);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- image.dispose();
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java
deleted file mode 100644
index e51305f0d4..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet166.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Create a ScrolledComposite with wrapping content.
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet166 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Image image1 = display.getSystemImage(SWT.ICON_WORKING);
- Image image2 = display.getSystemImage(SWT.ICON_QUESTION);
- Image image3 = display.getSystemImage(SWT.ICON_ERROR);
-
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
-
- final ScrolledComposite scrollComposite = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.BORDER);
-
- final Composite parent = new Composite(scrollComposite, SWT.NONE);
- for(int i = 0; i <= 50; i++) {
- Label label = new Label(parent, SWT.NONE);
- if (i % 3 == 0) label.setImage(image1);
- if (i % 3 == 1) label.setImage(image2);
- if (i % 3 == 2) label.setImage(image3);
- }
- RowLayout layout = new RowLayout(SWT.HORIZONTAL);
- layout.wrap = true;
- parent.setLayout(layout);
-
- scrollComposite.setContent(parent);
- scrollComposite.setExpandVertical(true);
- scrollComposite.setExpandHorizontal(true);
- scrollComposite.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- Rectangle r = scrollComposite.getClientArea();
- scrollComposite.setMinSize(parent.computeSize(r.width, SWT.DEFAULT));
- }
- });
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet167.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet167.java
deleted file mode 100644
index 6a29c3b6ac..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet167.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Create two ScrolledComposites that scroll in tandem.
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet167 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
-
- final ScrolledComposite sc1 = new ScrolledComposite (shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- Button button1 = new Button (sc1, SWT.PUSH);
- button1.setText ("Button 1");
- button1.setSize (400, 400);
- sc1.setContent (button1);
-
- final ScrolledComposite sc2 = new ScrolledComposite (shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- Button button2 = new Button(sc2, SWT.PUSH);
- button2.setText ("Button 2");
- button2.setSize (400, 400);
- sc2.setContent (button2);
-
- final ScrollBar vBar1 = sc1.getVerticalBar ();
- final ScrollBar vBar2 = sc2.getVerticalBar ();
- final ScrollBar hBar1 = sc1.getHorizontalBar ();
- final ScrollBar hBar2 = sc2.getHorizontalBar ();
- SelectionListener listener1 = new SelectionAdapter () {
- public void widgetSelected (SelectionEvent e) {
- sc2.setOrigin (
- hBar1.getSelection (),
- vBar1.getSelection ());
- }
- };
- SelectionListener listener2 = new SelectionAdapter () {
- public void widgetSelected (SelectionEvent e) {
- sc1.setOrigin (
- hBar2.getSelection (),
- vBar2.getSelection ());
- }
- };
- vBar1.addSelectionListener (listener1);
- hBar1.addSelectionListener (listener1);
- vBar2.addSelectionListener (listener2);
- hBar2.addSelectionListener (listener2);
-
- shell.setSize (600, 300);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet168.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet168.java
deleted file mode 100644
index 498b8a3ff0..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet168.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Draw lines and polygons with different cap and join styles
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet168 {
-
-public static void main(String[] args) {
- final Display display = new Display();
- Shell shell = new Shell(display);
- shell.addListener(SWT.Paint, new Listener() {
- public void handleEvent(Event event) {
- int x = 20, y = 20, w = 120, h = 60;
- GC gc = event.gc;
- gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
- gc.setLineWidth(10);
- int[] caps = {SWT.CAP_FLAT, SWT.CAP_ROUND, SWT.CAP_SQUARE};
- for (int i = 0; i < caps.length; i++) {
- gc.setLineCap(caps[i]);
- gc.drawLine(x, y, x + w, y);
- y += 20;
- }
- int[] joins = {SWT.JOIN_BEVEL, SWT.JOIN_MITER, SWT.JOIN_ROUND};
- for (int i = 0; i < joins.length; i++) {
- gc.setLineJoin(joins[i]);
- gc.drawPolygon(new int[] {x, y, x + w/2, y + h, x + w, y});
- y += h + 20;
- }
- }
- });
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet169.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet169.java
deleted file mode 100644
index a3f6db120e..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet169.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Make a toggle button have radio behavior
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet169 {
-public static void main (String [] args) {
- Display display = new Display ();
- final Shell shell = new Shell (display);
- shell.setLayout (new FillLayout ());
- Listener listener = new Listener () {
- public void handleEvent (Event e) {
- Control [] children = shell.getChildren ();
- for (int i=0; i " + string);
- }
- });
- shell.open ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet170.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet170.java
deleted file mode 100644
index e67739d52c..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet170.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Create a Tree with columns
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet170 {
- public static void main(String[] args) {
- Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- Tree tree = new Tree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- tree.setHeaderVisible(true);
- TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
- column1.setText("Column 1");
- column1.setWidth(200);
- TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
- column2.setText("Column 2");
- column2.setWidth(200);
- TreeColumn column3 = new TreeColumn(tree, SWT.RIGHT);
- column3.setText("Column 3");
- column3.setWidth(200);
- for (int i = 0; i < 4; i++) {
- TreeItem item = new TreeItem(tree, SWT.NONE);
- item.setText(new String[] { "item " + i, "abc", "defghi" });
- for (int j = 0; j < 4; j++) {
- TreeItem subItem = new TreeItem(item, SWT.NONE);
- subItem.setText(new String[] { "subitem " + j, "jklmnop", "qrs" });
- for (int k = 0; k < 4; k++) {
- TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
- subsubItem.setText(new String[] { "subsubitem " + k, "tuv", "wxyz" });
- }
- }
- }
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.dispose();
- }
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java
deleted file mode 100644
index ffd19f1014..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet171.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: define data transfer types that subclass each
- * other
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.io.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet171 {
-
-/*
- * The data being transferred is an array of type MyType where
- * MyType is define as:
- */
-static class MyType {
- String fileName;
- long fileLength;
- long lastModified;
-}
-
-static class MyTransfer extends ByteArrayTransfer {
-
- private static final String MYTYPENAME = "MytypeTransfer";
- private static final int MYTYPEID = registerType(MYTYPENAME);
- private static MyTransfer _instance = new MyTransfer();
-
- public static Transfer getInstance() {
- return _instance;
- }
-
- byte[] javaToByteArray(Object object) {
- MyType data = (MyType) object;
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream writeOut = new DataOutputStream(out);
- byte[] buffer = data.fileName.getBytes();
- writeOut.writeInt(buffer.length);
- writeOut.write(buffer);
- writeOut.writeLong(data.fileLength);
- writeOut.writeLong(data.lastModified);
- buffer = out.toByteArray();
- writeOut.close();
- return buffer;
- } catch (IOException e) {
- }
- return null;
- }
-
- Object byteArrayToJava(byte[] bytes) {
- MyType data = new MyType();
- try {
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream readIn = new DataInputStream(in);
- int size = readIn.readInt();
- byte[] buffer = new byte[size];
- readIn.read(buffer);
- data.fileName = new String(buffer);
- data.fileLength = readIn.readLong();
- data.lastModified = readIn.readLong();
- readIn.close();
- } catch (IOException ex) {
- return null;
- }
- return data;
- }
-
- public void javaToNative(Object object, TransferData transferData) {
- if (!checkMyType(object) || !isSupportedType(transferData)) {
- DND.error(DND.ERROR_INVALID_DATA);
- }
- byte[] buffer = javaToByteArray(object);
- super.javaToNative(buffer, transferData);
- }
-
- public Object nativeToJava(TransferData transferData) {
- if (isSupportedType(transferData)) {
- byte[] buffer = (byte[]) super.nativeToJava(transferData);
- if (buffer == null)
- return null;
- return byteArrayToJava(buffer);
- }
- return null;
- }
-
- protected String[] getTypeNames() {
- return new String[] { MYTYPENAME };
- }
-
- protected int[] getTypeIds() {
- return new int[] { MYTYPEID };
- }
-
- boolean checkMyType(Object object) {
- return object != null && object instanceof MyType;
- }
-
- protected boolean validate(Object object) {
- return checkMyType(object);
- }
-}
-
-/*
- * The data being transferred is an array of type MyType2
- * where MyType2 is define as:
- */
-static class MyType2 extends MyType {
- String version;
-}
-
-static class MyTransfer2 extends MyTransfer {
-
- private static final String MYTYPE2NAME = "Mytype2Transfer";
- private static final int MYTYPE2ID = registerType(MYTYPE2NAME);
- private static MyTransfer _instance = new MyTransfer2();
-
- public static Transfer getInstance() {
- return _instance;
- }
-
- protected String[] getTypeNames() {
- return new String[] { MYTYPE2NAME };
- }
-
- protected int[] getTypeIds() {
- return new int[] { MYTYPE2ID };
- }
-
- byte[] javaToByteArray(Object object) {
- MyType2 data = (MyType2) object;
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- DataOutputStream writeOut = new DataOutputStream(out);
- byte[] buffer = data.fileName.getBytes();
- writeOut.writeInt(buffer.length);
- writeOut.write(buffer);
- writeOut.writeLong(data.fileLength);
- writeOut.writeLong(data.lastModified);
- buffer = data.version.getBytes();
- writeOut.writeInt(buffer.length);
- writeOut.write(buffer);
- buffer = out.toByteArray();
- writeOut.close();
- return buffer;
- } catch (IOException e) {
- }
- return null;
- }
-
- Object byteArrayToJava(byte[] bytes) {
- MyType2 data = new MyType2();
- try {
- ByteArrayInputStream in = new ByteArrayInputStream(bytes);
- DataInputStream readIn = new DataInputStream(in);
- int size = readIn.readInt();
- byte[] buffer = new byte[size];
- readIn.read(buffer);
- data.fileName = new String(buffer);
- data.fileLength = readIn.readLong();
- data.lastModified = readIn.readLong();
- size = readIn.readInt();
- buffer = new byte[size];
- readIn.read(buffer);
- data.version = new String(buffer);
- readIn.close();
- } catch (IOException ex) {
- return null;
- }
- return data;
- }
-
- public void javaToNative(Object object, TransferData transferData) {
- if (!checkMyType2(object)) {
- DND.error(DND.ERROR_INVALID_DATA);
- }
- super.javaToNative(object, transferData);
- }
-
- boolean checkMyType2(Object object) {
- if (!checkMyType(object))
- return false;
- return object != null && object instanceof MyType2;
- }
-
- protected boolean validate(Object object) {
- return checkMyType2(object);
- }
-}
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Label label1 = new Label(shell, SWT.BORDER | SWT.WRAP);
- label1.setText("Drag Source for MyData and MyData2");
- final Label label2 = new Label(shell, SWT.BORDER | SWT.WRAP);
- label2.setText("Drop Target for MyData");
- final Label label3 = new Label(shell, SWT.BORDER | SWT.WRAP);
- label3.setText("Drop Target for MyData2");
-
- DragSource source = new DragSource(label1, DND.DROP_COPY);
- source.setTransfer(new Transfer[] { MyTransfer.getInstance(),
- MyTransfer2.getInstance() });
- source.addDragListener(new DragSourceAdapter() {
- public void dragSetData(DragSourceEvent event) {
- MyType2 myType = new MyType2();
- myType.fileName = "C:\\abc.txt";
- myType.fileLength = 1000;
- myType.lastModified = 12312313;
- myType.version = "version 2";
- event.data = myType;
- }
- });
- DropTarget targetMyType = new DropTarget(label2, DND.DROP_COPY | DND.DROP_DEFAULT);
- targetMyType.setTransfer(new Transfer[] { MyTransfer.getInstance() });
- targetMyType.addDropListener(new DropTargetAdapter() {
- public void dragEnter(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT)
- event.detail = DND.DROP_COPY;
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT)
- event.detail = DND.DROP_COPY;
- }
-
- public void drop(DropTargetEvent event) {
- if (event.data != null) {
- MyType myType = (MyType) event.data;
- if (myType != null) {
- String string = "MyType: " + myType.fileName;
- label2.setText(string);
- }
- }
- }
-
- });
- DropTarget targetMyType2 = new DropTarget(label3, DND.DROP_COPY | DND.DROP_DEFAULT);
- targetMyType2.setTransfer(new Transfer[] { MyTransfer2.getInstance() });
- targetMyType2.addDropListener(new DropTargetAdapter() {
- public void dragEnter(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT)
- event.detail = DND.DROP_COPY;
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT)
- event.detail = DND.DROP_COPY;
- }
-
- public void drop(DropTargetEvent event) {
- if (event.data != null) {
- MyType2 myType = (MyType2) event.data;
- if (myType != null) {
- String string = "MyType2: " + myType.fileName + ":"
- + myType.version;
- label3.setText(string);
- }
- }
- }
-
- });
- shell.setSize(300, 200);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet172.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet172.java
deleted file mode 100644
index 9e60bf5993..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet172.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * GridLayout snippet: align widgets in a GridLayout
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet172 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- GridLayout layout = new GridLayout(4, false);
- shell.setLayout(layout);
-
- Button b = new Button(shell, SWT.PUSH);
- b.setText("LEFT, TOP");
- b.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("LEFT, CENTER");
- b.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("LEFT, BOTTOM");
- b.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("LEFT, FILL");
- b.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("CENTER, TOP");
- b.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("CENTER, CENTER");
- b.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("CENTER, BOTTOM");
- b.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("CENTER, FILL");
- b.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("RIGHT, TOP");
- b.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("RIGHT, CENTER");
- b.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("RIGHT, BOTTOM");
- b.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("RIGHT, FILL");
- b.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("FILL, TOP");
- b.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("FILL, CENTER");
- b.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("FILL, BOTTOM");
- b.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true, 1, 1));
- b = new Button(shell, SWT.PUSH);
- b.setText("FILL, FILL");
- b.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
-
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet173.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet173.java
deleted file mode 100644
index 8d6dae4977..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet173.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Browser snippet: bring up a browser (pop-up blocker)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.browser.*;
-
-public class Snippet173 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setText("Main Window");
- shell.setLayout(new FillLayout());
- Browser browser = new Browser(shell, SWT.NONE);
- initialize(display, browser);
- shell.open();
- /* any website with popups */
- browser.setUrl("http://www.cnn.com");
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
- }
-
-/* register WindowEvent listeners */
-static void initialize(final Display display, Browser browser) {
- browser.addOpenWindowListener(new OpenWindowListener() {
- public void open(WindowEvent event) {
- Shell shell = new Shell(display);
- shell.setText("New Window");
- shell.setLayout(new FillLayout());
- Browser browser = new Browser(shell, SWT.NONE);
- initialize(display, browser);
- event.browser = browser;
- }
- });
- browser.addVisibilityWindowListener(new VisibilityWindowListener() {
- public void hide(WindowEvent event) {
- Browser browser = (Browser)event.widget;
- Shell shell = browser.getShell();
- shell.setVisible(false);
- }
- public void show(WindowEvent event) {
- Browser browser = (Browser)event.widget;
- final Shell shell = browser.getShell();
- /* popup blocker - ignore windows with no style */
- if (!event.addressBar && !event.menuBar && !event.statusBar && !event.toolBar) {
- System.out.println("Popup blocked.");
- event.display.asyncExec(new Runnable() {
- public void run() {
- shell.close();
- }
- });
- return;
- }
- if (event.location != null) shell.setLocation(event.location);
- if (event.size != null) {
- Point size = event.size;
- shell.setSize(shell.computeSize(size.x, size.y));
- }
- shell.open();
- }
- });
- browser.addCloseWindowListener(new CloseWindowListener() {
- public void close(WindowEvent event) {
- Browser browser = (Browser)event.widget;
- Shell shell = browser.getShell();
- shell.close();
- }
- });
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java
deleted file mode 100644
index 40757e51bf..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet174.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Sebastian Davids - initial implementation
- * IBM Corporation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * SWT OpenGL snippet: draw a square
- *
- * This snippet requires the experimental org.eclipse.swt.opengl plugin, which
- * is not included in swt by default. For information on this plugin see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/opengl/opengl.html
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.opengl.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet174 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setText("OpenGL in SWT");
- shell.setLayout(new FillLayout());
- final Canvas canvas = new Canvas(shell, SWT.NO_BACKGROUND);
- canvas.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- resize(canvas);
- }
- });
- final GLContext context = init(canvas);
- shell.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- context.dispose();
- }
- });
- new Runnable() {
- public void run() {
- if (canvas.isDisposed()) return;
- render();
- context.swapBuffers();
- canvas.getDisplay().timerExec(50, this);
- }
- }.run();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-
-static GLContext init(Canvas canvas) {
- GLContext context = new GLContext(canvas);
- context.setCurrent();
- resize(canvas);
- GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
- GL.glColor3f(0.0f, 0.0f, 0.0f);
- GL.glClearDepth(1.0f);
- GL.glEnable(GL.GL_DEPTH_TEST);
- GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);
- return context;
-}
-
-static void render() {
- GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- GL.glLoadIdentity();
- GL.glTranslatef(0.0f, 0.0f, -6.0f);
- GL.glBegin(GL.GL_QUADS);
- GL.glVertex3f(-1.0f, 1.0f, 0.0f);
- GL.glVertex3f(1.0f, 1.0f, 0.0f);
- GL.glVertex3f(1.0f, -1.0f, 0.0f);
- GL.glVertex3f(-1.0f, -1.0f, 0.0f);
- GL.glEnd();
-}
-
-static void resize(Canvas canvas) {
- Rectangle rect = canvas.getClientArea();
- int width = rect.width;
- int height = Math.max(rect.height, 1);
- GL.glViewport(0, 0, width, height);
- GL.glMatrixMode(GL.GL_PROJECTION);
- GL.glLoadIdentity();
- float aspect = (float) width / (float) height;
- GLU.gluPerspective(45.0f, aspect, 0.5f, 400.0f);
- GL.glMatrixMode(GL.GL_MODELVIEW);
- GL.glLoadIdentity();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet175.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet175.java
deleted file mode 100644
index c9406e5126..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet175.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-/*
- * Exclude a widget from a GridLayout
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-public class Snippet175 {
-
-public static void main(String[] args) {
-
- Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setLayout(new GridLayout(3, false));
-
- Button b = new Button(shell, SWT.PUSH);
- b.setText("Button 0");
-
- final Button bHidden = new Button(shell, SWT.PUSH);
- bHidden.setText("Button 1");
- GridData data = new GridData();
- data.exclude = true;
- data.horizontalSpan = 2;
- data.horizontalAlignment = SWT.FILL;
- bHidden.setLayoutData(data);
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 2");
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 3");
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 4");
-
- b = new Button(shell, SWT.CHECK);
- b.setText("hide");
- b.setSelection(true);
- b.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event e) {
- Button b = (Button) e.widget;
- GridData data = (GridData) bHidden.getLayoutData();
- data.exclude = b.getSelection();
- bHidden.setVisible(!data.exclude);
- shell.layout(false);
- }
- });
- shell.setSize(400, 400);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet176.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet176.java
deleted file mode 100644
index 911f700070..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet176.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * GridLayout snippet: align widgets in a horizontal row
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet176 {
-
- public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- RowLayout layout = new RowLayout(SWT.HORIZONTAL);
- layout.wrap = true;
- layout.fill = false;
- layout.justify = true;
- shell.setLayout(layout);
-
- Button b = new Button(shell, SWT.PUSH);
- b.setText("Button 1");
- b = new Button(shell, SWT.PUSH);
-
- b.setText("Button 2");
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 3");
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Not shown");
- b.setVisible(false);
- RowData data = new RowData();
- data.exclude = true;
- b.setLayoutData(data);
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 200 high");
- data = new RowData();
- data.height = 200;
- b.setLayoutData(data);
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 200 wide");
- data = new RowData();
- data.width = 200;
- b.setLayoutData(data);
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet177.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet177.java
deleted file mode 100644
index 71ed499440..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet177.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * GridLayout snippet: align widgets in a vertical column
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet177 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- RowLayout layout = new RowLayout(SWT.VERTICAL);
- layout.wrap = true;
- layout.fill = true;
- layout.justify = false;
- shell.setLayout(layout);
-
- Button b = new Button(shell, SWT.PUSH);
- b.setText("Button 1");
- b = new Button(shell, SWT.PUSH);
-
- b.setText("Button 2");
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 3");
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Not shown");
- b.setVisible(false);
- RowData data = new RowData();
- data.exclude = true;
- b.setLayoutData(data);
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 200 high");
- data = new RowData();
- data.height = 200;
- b.setLayoutData(data);
-
- b = new Button(shell, SWT.PUSH);
- b.setText("Button 200 wide");
- data = new RowData();
- data.width = 200;
- b.setLayoutData(data);
-
- shell.pack();
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet178.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet178.java
deleted file mode 100644
index 9c98bfefb0..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet178.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * How to access About, Preferences and Quit menus on carbon.
- * NOTE: This snippet uses internal SWT packages that are
- * subject to change without notice.
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.carbon.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet178 {
-
- private static final int kHICommandPreferences = ('p' << 24) + ('r' << 16)
- + ('e' << 8) + 'f';
-
- private static final int kHICommandAbout = ('a' << 24) + ('b' << 16)
- + ('o' << 8) + 'u';
-
- private static final int kHICommandServices = ('s' << 24) + ('e' << 16)
- + ('r' << 8) + 'v';
-
-public static void main(String[] arg) {
- Display.setAppName("AppMenu"); // sets name in Dock
- Display display = new Display();
- hookApplicationMenu(display, "About AppMenu");
- Shell shell = new Shell(display);
- shell.setText("Main Window");
- shell.open();
- while (!shell.isDisposed())
- if (!display.readAndDispatch())
- display.sleep();
-
- display.dispose();
-}
-
-static void hookApplicationMenu(Display display, final String aboutName) {
- // Callback target
- Object target = new Object() {
- int commandProc(int nextHandler, int theEvent, int userData) {
- if (OS.GetEventKind(theEvent) == OS.kEventProcessCommand) {
- HICommand command = new HICommand();
- OS.GetEventParameter(theEvent, OS.kEventParamDirectObject,
- OS.typeHICommand, null, HICommand.sizeof, null,
- command);
- switch (command.commandID) {
- case kHICommandPreferences:
- return handleCommand("Preferences"); //$NON-NLS-1$
- case kHICommandAbout:
- return handleCommand(aboutName);
- default:
- break;
- }
- }
- return OS.eventNotHandledErr;
- }
-
- int handleCommand(String command) {
- Shell shell = new Shell();
- MessageBox preferences = new MessageBox(shell, SWT.ICON_WARNING);
- preferences.setText(command);
- preferences.open();
- shell.dispose();
- return OS.noErr;
- }
- };
-
- final Callback commandCallback = new Callback(target, "commandProc", 3); //$NON-NLS-1$
- int commandProc = commandCallback.getAddress();
- if (commandProc == 0) {
- commandCallback.dispose();
- return; // give up
- }
-
- // Install event handler for commands
- int[] mask = new int[] { OS.kEventClassCommand, OS.kEventProcessCommand };
- OS.InstallEventHandler(OS.GetApplicationEventTarget(), commandProc,
- mask.length / 2, mask, 0, null);
-
- // create About ... menu command
- int[] outMenu = new int[1];
- short[] outIndex = new short[1];
- if (OS.GetIndMenuItemWithCommandID(0, kHICommandPreferences, 1,
- outMenu, outIndex) == OS.noErr
- && outMenu[0] != 0) {
- int menu = outMenu[0];
-
- int l = aboutName.length();
- char buffer[] = new char[l];
- aboutName.getChars(0, l, buffer, 0);
- int str = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault,
- buffer, l);
- OS.InsertMenuItemTextWithCFString(menu, str, (short) 0, 0,
- kHICommandAbout);
- OS.CFRelease(str);
-
- // add separator between About & Preferences
- OS.InsertMenuItemTextWithCFString(menu, 0, (short) 1,
- OS.kMenuItemAttrSeparator, 0);
-
- // enable pref menu
- OS.EnableMenuCommand(menu, kHICommandPreferences);
-
- // disable services menu
- OS.DisableMenuCommand(menu, kHICommandServices);
- }
-
- // schedule disposal of callback object
- display.disposeExec(new Runnable() {
- public void run() {
- commandCallback.dispose();
- }
- });
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java
deleted file mode 100644
index f82cd1b106..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ToolBar example snippet: create a tool bar (text)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet18 {
-
-public static void main (String [] args) {
- Shell shell = new Shell ();
- ToolBar bar = new ToolBar (shell, SWT.BORDER);
- for (int i=0; i<8; i++) {
- ToolItem item = new ToolItem (bar, SWT.PUSH);
- item.setText ("Item " + i);
- }
- bar.pack ();
- shell.open ();
- Display display = shell.getDisplay ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet19.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet19.java
deleted file mode 100644
index 54c34e6a46..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet19.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Text example snippet: verify input (only allow digits)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet19 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Text text = new Text (shell, SWT.BORDER | SWT.V_SCROLL);
- text.setBounds (10, 10, 200, 200);
- text.addListener (SWT.Verify, new Listener () {
- public void handleEvent (Event e) {
- String text = e.text;
- char [] chars = new char [text.length ()];
- text.getChars (0, chars.length, chars, 0);
- for (int i=0; i= hPage) {
- if (hPage <= 0) hSelection = 0;
- origin.x = -hSelection;
- }
- if (vSelection >= vPage) {
- if (vPage <= 0) vSelection = 0;
- origin.y = -vSelection;
- }
- shell.redraw ();
- }
- });
- shell.addListener (SWT.Paint, new Listener () {
- public void handleEvent (Event e) {
- GC gc = e.gc;
- gc.drawImage (image, origin.x, origin.y);
- Rectangle rect = image.getBounds ();
- Rectangle client = shell.getClientArea ();
- int marginWidth = client.width - rect.width;
- if (marginWidth > 0) {
- gc.fillRectangle (rect.width, 0, marginWidth, client.height);
- }
- int marginHeight = client.height - rect.height;
- if (marginHeight > 0) {
- gc.fillRectangle (0, rect.height, client.width, marginHeight);
- }
- }
- });
- shell.setSize (200, 150);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet49.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet49.java
deleted file mode 100644
index d23f4db5b1..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet49.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ToolBar example snippet: create tool bar (wrap on resize)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet49 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- final Shell shell = new Shell (display);
- final ToolBar toolBar = new ToolBar (shell, SWT.WRAP);
- for (int i=0; i<12; i++) {
- ToolItem item = new ToolItem (toolBar, SWT.PUSH);
- item.setText ("Item " + i);
- }
- shell.addListener (SWT.Resize, new Listener () {
- public void handleEvent (Event e) {
- Rectangle rect = shell.getClientArea ();
- Point size = toolBar.computeSize (rect.width, SWT.DEFAULT);
- toolBar.setSize (size);
- }
- });
- toolBar.pack ();
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet5.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet5.java
deleted file mode 100644
index a6f64aa1e1..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet5.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ScrolledComposite example snippet: scroll a control in a scrolled composite
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.custom.*;
-
-public class Snippet5 {
-
-public static void main (String [] args)
-{
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
-
- // this button is always 400 x 400. Scrollbars appear if the window is resized to be
- // too small to show part of the button
- ScrolledComposite c1 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- Button b1 = new Button(c1, SWT.PUSH);
- b1.setText("fixed size button");
- b1.setSize(400, 400);
- c1.setContent(b1);
-
- // this button has a minimum size of 400 x 400. If the window is resized to be big
- // enough to show more than 400 x 400, the button will grow in size. If the window
- // is made too small to show 400 x 400, scrollbars will appear.
- ScrolledComposite c2 = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- Button b2 = new Button(c2, SWT.PUSH);
- b2.setText("expanding button");
- c2.setContent(b2);
- c2.setExpandHorizontal(true);
- c2.setExpandVertical(true);
- c2.setMinWidth(400);
- c2.setMinHeight(400);
-
- shell.setSize(600, 300);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet50.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet50.java
deleted file mode 100644
index 9009af18fb..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet50.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Shell example snippet: create a dialog shell
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.widgets.*;
-
-public class Snippet50 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setText ("Shell");
- shell.setSize (200, 200);
- shell.open ();
- Shell dialog = new Shell (shell);
- dialog.setText ("Dialog");
- dialog.setSize (200, 200);
- dialog.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet51.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet51.java
deleted file mode 100644
index a81a0c083a..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet51.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Table example snippet: scroll a table (set the top index)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet51 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Table table = new Table (shell, SWT.BORDER | SWT.MULTI);
- table.setSize (200, 200);
- for (int i=0; i<128; i++) {
- TableItem item = new TableItem (table, SWT.NONE);
- item.setText ("Item " + i);
- }
- table.setTopIndex (95);
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet52.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet52.java
deleted file mode 100644
index a04f0f727d..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet52.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Table example snippet: select an index (select and scroll)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet52 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Table table = new Table (shell, SWT.BORDER | SWT.MULTI);
- table.setSize (200, 200);
- for (int i=0; i<128; i++) {
- TableItem item = new TableItem (table, SWT.NONE);
- item.setText ("Item " + i);
- }
- table.setSelection (95);
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet53.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet53.java
deleted file mode 100644
index 4280520936..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet53.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Table example snippet: remove selected items
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet53 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- final Table table = new Table (shell, SWT.BORDER | SWT.MULTI);
- table.setSize (200, 200);
- for (int i=0; i<128; i++) {
- TableItem item = new TableItem (table, SWT.NONE);
- item.setText ("Item " + i);
- }
- Menu menu = new Menu (shell, SWT.POP_UP);
- table.setMenu (menu);
- MenuItem item = new MenuItem (menu, SWT.PUSH);
- item.setText ("Delete Selection");
- item.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event event) {
- table.remove (table.getSelectionIndices ());
- }
- });
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet54.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet54.java
deleted file mode 100644
index 1b99c19db9..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet54.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Sash example snippet: create a sash (allow it to be moved)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet54 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- final Sash sash = new Sash (shell, SWT.BORDER | SWT.VERTICAL);
- sash.setBounds (10, 10, 32, 100);
- sash.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- sash.setBounds (e.x, e.y, e.width, e.height);
- }
- });
- shell.open ();
- sash.setFocus ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet55.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet55.java
deleted file mode 100644
index 78dc86e8cf..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet55.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Text example snippet: resize a text control (show about 10 characters)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet55 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Text text = new Text (shell, SWT.BORDER);
- int columns = 10;
- GC gc = new GC (text);
- FontMetrics fm = gc.getFontMetrics ();
- int width = columns * fm.getAverageCharWidth ();
- int height = fm.getHeight ();
- gc.dispose ();
- text.setSize (text.computeSize (width, height));
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet56.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet56.java
deleted file mode 100644
index 2becb5ac15..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet56.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ProgressBar example snippet: update a progress bar (from another thread)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet56 {
-
- public static void main(String[] args) {
- final Display display = new Display();
- Shell shell = new Shell(display);
- final ProgressBar bar = new ProgressBar(shell, SWT.SMOOTH);
- bar.setBounds(10, 10, 200, 32);
- shell.open();
- final int maximum = bar.getMaximum();
- new Thread() {
- public void run() {
- for (final int[] i = new int[1]; i[0] <= maximum; i[0]++) {
- try {Thread.sleep (100);} catch (Throwable th) {}
- if (display.isDisposed()) return;
- display.asyncExec(new Runnable() {
- public void run() {
- if (bar.isDisposed ()) return;
- bar.setSelection(i[0]);
- }
- });
- }
- }
- }.start();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose();
- }
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet57.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet57.java
deleted file mode 100644
index d4c16a49a9..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet57.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ProgressBar example snippet: update a progress bar (from the UI thread)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet57 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- ProgressBar bar = new ProgressBar (shell, SWT.SMOOTH);
- bar.setBounds (10, 10, 200, 32);
- shell.open ();
- for (int i=0; i<=bar.getMaximum (); i++) {
- try {Thread.sleep (100);} catch (Throwable th) {}
- bar.setSelection (i);
- }
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet58.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet58.java
deleted file mode 100644
index 3a01609b2e..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet58.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * ToolBar example snippet: place a combo box in a tool bar
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet58 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- ToolBar bar = new ToolBar (shell, SWT.BORDER);
- for (int i=0; i<4; i++) {
- ToolItem item = new ToolItem (bar, 0);
- item.setText ("Item " + i);
- }
- ToolItem sep = new ToolItem (bar, SWT.SEPARATOR);
- int start = bar.getItemCount ();
- for (int i=start; i area.height) {
- // Subtract the scrollbar width from the total column width
- // if a vertical scrollbar will be required
- Point vBarSize = table.getVerticalBar().getSize();
- width -= vBarSize.x;
- }
- Point oldSize = table.getSize();
- if (oldSize.x > area.width) {
- // table is getting smaller so make the columns
- // smaller first and then resize the table to
- // match the client area width
- column1.setWidth(width/3);
- column2.setWidth(width - column1.getWidth());
- table.setSize(area.width, area.height);
- } else {
- // table is getting bigger so make the table
- // bigger first and then make the columns wider
- // to match the client area width
- table.setSize(area.width, area.height);
- column1.setWidth(width/3);
- column2.setWidth(width - column1.getWidth());
- }
- }
- });
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet78.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet78.java
deleted file mode 100644
index 474fb739fc..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet78.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: drag text between two labels
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet78 {
-
-public static void main (String [] args) {
-
- Display display = Display.getDefault ();
- final Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
- final Label label1 = new Label (shell, SWT.BORDER);
- label1.setText ("TEXT");
- final Label label2 = new Label (shell, SWT.BORDER);
- setDragDrop (label1);
- setDragDrop (label2);
- shell.setSize (200, 200);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-public static void setDragDrop (final Label label) {
-
- Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
-
- final DragSource source = new DragSource (label, operations);
- source.setTransfer(types);
- source.addDragListener (new DragSourceListener () {
- public void dragStart(DragSourceEvent event) {
- event.doit = (label.getText ().length () != 0);
- }
- public void dragSetData (DragSourceEvent event) {
- event.data = label.getText ();
- }
- public void dragFinished(DragSourceEvent event) {
- if (event.detail == DND.DROP_MOVE)
- label.setText ("");
- }
- });
-
- DropTarget target = new DropTarget(label, operations);
- target.setTransfer(types);
- target.addDropListener (new DropTargetAdapter() {
- public void drop(DropTargetEvent event) {
- if (event.data == null) {
- event.detail = DND.DROP_NONE;
- return;
- }
- label.setText ((String) event.data);
- }
- });
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java
deleted file mode 100644
index 193510e056..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet79.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: define my own data transfer type
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import java.io.*;
-
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet79 {
-
-/* The data being transferred is an array of type MyType where MyType is define as: */
-static class MyType {
- String fileName;
- long fileLength;
- long lastModified;
-}
-
-static class MyTransfer extends ByteArrayTransfer {
-
- private static final String MYTYPENAME = "name_for_my_type";
- private static final int MYTYPEID = registerType (MYTYPENAME);
- private static MyTransfer _instance = new MyTransfer ();
-
-public static MyTransfer getInstance () {
- return _instance;
-}
-
-public void javaToNative (Object object, TransferData transferData) {
- if (!checkMyType(object) || !isSupportedType (transferData)) {
- DND.error(DND.ERROR_INVALID_DATA);
- }
- MyType [] myTypes = (MyType []) object;
- try {
- // write data to a byte array and then ask super to convert to pMedium
- ByteArrayOutputStream out = new ByteArrayOutputStream ();
- DataOutputStream writeOut = new DataOutputStream (out);
- for (int i = 0, length = myTypes.length; i < length; i++) {
- byte [] buffer = myTypes [i].fileName.getBytes ();
- writeOut.writeInt (buffer.length);
- writeOut.write (buffer);
- writeOut.writeLong (myTypes [i].fileLength);
- writeOut.writeLong (myTypes [i].lastModified);
- }
- byte [] buffer = out.toByteArray ();
- writeOut.close ();
- super.javaToNative (buffer, transferData);
- }
- catch (IOException e) {}
-}
-
-public Object nativeToJava (TransferData transferData) {
- if (isSupportedType (transferData)) {
- byte [] buffer = (byte []) super.nativeToJava (transferData);
- if (buffer == null) return null;
-
- MyType [] myData = new MyType [0];
- try {
- ByteArrayInputStream in = new ByteArrayInputStream (buffer);
- DataInputStream readIn = new DataInputStream (in);
- while (readIn.available () > 20) {
- MyType datum = new MyType ();
- int size = readIn.readInt ();
- byte [] name = new byte [size];
- readIn.read (name);
- datum.fileName = new String (name);
- datum.fileLength = readIn.readLong ();
- datum.lastModified = readIn.readLong ();
- MyType [] newMyData = new MyType [myData.length + 1];
- System.arraycopy (myData, 0, newMyData, 0, myData.length);
- newMyData [myData.length] = datum;
- myData = newMyData;
- }
- readIn.close ();
- }
- catch (IOException ex) {
- return null;
- }
- return myData;
- }
-
- return null;
-}
-
-protected String [] getTypeNames () {
- return new String [] {MYTYPENAME};
-}
-
-protected int [] getTypeIds () {
- return new int [] {MYTYPEID};
-}
-
-boolean checkMyType(Object object) {
- if (object == null ||
- !(object instanceof MyType[]) ||
- ((MyType[])object).length == 0) {
- return false;
- }
- MyType[] myTypes = (MyType[])object;
- for (int i = 0; i < myTypes.length; i++) {
- if (myTypes[i] == null ||
- myTypes[i].fileName == null ||
- myTypes[i].fileName.length() == 0) {
- return false;
- }
- }
- return true;
-}
-
-protected boolean validate(Object object) {
- return checkMyType(object);
-}
-}
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout (new FillLayout ());
- final Label label1 = new Label (shell, SWT.BORDER | SWT.WRAP);
- label1.setText ("Drag Source for MyData[]");
- final Label label2 = new Label (shell, SWT.BORDER | SWT.WRAP);
- label2.setText ("Drop Target for MyData[]");
-
- DragSource source = new DragSource (label1, DND.DROP_COPY);
- source.setTransfer (new Transfer [] {MyTransfer.getInstance ()});
- source.addDragListener (new DragSourceAdapter () {
- public void dragSetData (DragSourceEvent event) {
- MyType myType1 = new MyType ();
- myType1.fileName = "C:\\abc.txt";
- myType1.fileLength = 1000;
- myType1.lastModified = 12312313;
- MyType myType2 = new MyType ();
- myType2.fileName = "C:\\xyz.txt";
- myType2.fileLength = 500;
- myType2.lastModified = 12312323;
- event.data = new MyType [] {myType1, myType2};
- }
- });
- DropTarget target = new DropTarget (label2, DND.DROP_COPY | DND.DROP_DEFAULT);
- target.setTransfer (new Transfer [] {MyTransfer.getInstance ()});
- target.addDropListener (new DropTargetAdapter () {
- public void dragEnter (DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT) {
- event.detail = DND.DROP_COPY;
- }
- }
-
- public void dragOperationChanged (DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT) {
- event.detail = DND.DROP_COPY;
- }
- }
-
- public void drop (DropTargetEvent event) {
- if (event.data != null) {
- MyType [] myTypes = (MyType []) event.data;
- if (myTypes != null) {
- String string = "";
- for (int i = 0; i < myTypes.length; i++) {
- string += myTypes [i].fileName + " ";
- }
- label2.setText (string);
- }
- }
- }
-
- });
- shell.setSize (200, 200);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet8.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet8.java
deleted file mode 100644
index 8de2f4921e..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet8.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Tree example snippet: create a tree (lazy)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-import java.io.*;
-
-public class Snippet8 {
-
-public static void main (String [] args) {
- final Display display = new Display ();
- final Shell shell = new Shell (display);
- shell.setText ("Lazy Tree");
- shell.setLayout (new FillLayout ());
- final Tree tree = new Tree (shell, SWT.BORDER);
- File [] roots = File.listRoots ();
- for (int i=0; i 0) {
- TreeItem[] newSelection = new TreeItem[revisedSelection.length + 1];
- System.arraycopy(revisedSelection, 0, newSelection, 0, revisedSelection.length);
- newSelection[revisedSelection.length] = selection[i];
- revisedSelection = newSelection;
- }
- }
- tree.setSelection(revisedSelection);
- }
- });
-
- shell.setSize(300, 300);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet81.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet81.java
deleted file mode 100644
index ce49638e32..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet81.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * OLE and ActiveX example snippet: browse the typelibinfo for a program id
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.ole.win32.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet81 {
-
-public static void main(String[] args) {
-
- if (args.length == 0) {
- System.out.println("Usage: java Main ");
- return;
- }
-
- String progID = args[0];
-
- Shell shell = new Shell();
-
- OleFrame frame = new OleFrame(shell, SWT.NONE);
- OleControlSite site = null;
- OleAutomation auto = null;
- try {
- site = new OleControlSite(frame, SWT.NONE, progID);
- auto = new OleAutomation(site);
- } catch (SWTException ex) {
- System.out.println("Unable to open type library for "+progID);
- return;
- }
-
- TYPEATTR typeattr = auto.getTypeInfoAttributes();
- if (typeattr != null) {
- if (typeattr.cFuncs > 0) System.out.println("Functions for "+progID+" :\n");
- for (int i = 0; i < typeattr.cFuncs; i++) {
- OleFunctionDescription data = auto.getFunctionDescription(i);
- String argList = "";
- int firstOptionalArgIndex = data.args.length - data.optionalArgCount;
- for (int j = 0; j < data.args.length; j++) {
- argList += "[";
- if (j >= firstOptionalArgIndex) argList += "optional, ";
- argList += getDirection(data.args[j].flags)+"] "+getTypeName(data.args[j].type)+" "+data.args[j].name;
- if ( j < data.args.length - 1) argList += ", ";
- }
- System.out.println(getInvokeKind(data.invokeKind)+" (id = "+data.id+") : "
- +"\n\tSignature : "+getTypeName(data.returnType)+" "+data.name+"("+argList+")"
- +"\n\tDescription : "+data.documentation
- +"\n\tHelp File : "+data.helpFile+"\n");
- }
-
- if (typeattr.cVars > 0) System.out.println("\n\nVariables for "+progID+" :\n");
- for (int i = 0; i < typeattr.cVars; i++) {
- OlePropertyDescription data = auto.getPropertyDescription(i);
- System.out.println("PROPERTY (id = "+data.id+") :"
- +"\n\tName : "+data.name
- +"\n\tType : "+getTypeName(data.type)+"\n");
- }
- }
-
- auto.dispose();
- shell.dispose();
-
-}
-private static String getTypeName(int type) {
- switch (type) {
- case OLE.VT_BOOL : return "boolean";
- case OLE.VT_R4 : return "float";
- case OLE.VT_R8 : return "double";
- case OLE.VT_I4 : return "int";
- case OLE.VT_DISPATCH : return "IDispatch";
- case OLE.VT_UNKNOWN : return "IUnknown";
- case OLE.VT_I2 : return "short";
- case OLE.VT_BSTR : return "String";
- case OLE.VT_VARIANT : return "Variant";
- case OLE.VT_CY : return "Currency";
- case OLE.VT_DATE : return "Date";
- case OLE.VT_UI1 : return "unsigned char";
- case OLE.VT_UI4 : return "unsigned int";
- case OLE.VT_USERDEFINED : return "UserDefined";
- case OLE.VT_HRESULT : return "int";
- case OLE.VT_VOID : return "void";
-
- case OLE.VT_BYREF | OLE.VT_BOOL : return "boolean *";
- case OLE.VT_BYREF | OLE.VT_R4 : return "float *";
- case OLE.VT_BYREF | OLE.VT_R8 : return "double *";
- case OLE.VT_BYREF | OLE.VT_I4 : return "int *";
- case OLE.VT_BYREF | OLE.VT_DISPATCH : return "IDispatch *";
- case OLE.VT_BYREF | OLE.VT_UNKNOWN : return "IUnknown *";
- case OLE.VT_BYREF | OLE.VT_I2 : return "short *";
- case OLE.VT_BYREF | OLE.VT_BSTR : return "String *";
- case OLE.VT_BYREF | OLE.VT_VARIANT : return "Variant *";
- case OLE.VT_BYREF | OLE.VT_CY : return "Currency *";
- case OLE.VT_BYREF | OLE.VT_DATE : return "Date *";
- case OLE.VT_BYREF | OLE.VT_UI1 : return "unsigned char *";
- case OLE.VT_BYREF | OLE.VT_UI4 : return "unsigned int *";
- case OLE.VT_BYREF | OLE.VT_USERDEFINED : return "UserDefined *";
- }
- return "unknown "+ type;
-}
-private static String getDirection(int direction){
- String dirString = "";
- boolean comma = false;
- if ((direction & OLE.IDLFLAG_FIN) != 0) {
- dirString += "in";
- comma = true;
- }
- if ((direction & OLE.IDLFLAG_FOUT) != 0){
- if (comma) dirString += ", ";
- dirString += "out";
- comma = true;
- }
- if ((direction & OLE.IDLFLAG_FLCID) != 0){
- if (comma) dirString += ", ";
- dirString += "lcid";
- comma = true;
- }
- if ((direction & OLE.IDLFLAG_FRETVAL) != 0){
- if (comma) dirString += ", ";
- dirString += "retval";
- }
-
- return dirString;
-}
-private static String getInvokeKind(int invKind) {
- switch (invKind) {
- case OLE.INVOKE_FUNC : return "METHOD";
- case OLE.INVOKE_PROPERTYGET : return "PROPERTY GET";
- case OLE.INVOKE_PROPERTYPUT : return "PROPERTY PUT";
- case OLE.INVOKE_PROPERTYPUTREF : return "PROPERTY PUT BY REF";
- }
- return "unknown "+invKind;
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet82.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet82.java
deleted file mode 100644
index aff7291240..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet82.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * CTabFolder example snippet: prevent an item from closing
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet82 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- CTabFolder folder = new CTabFolder(shell, SWT.CLOSE);
- for (int i = 0; i < 4; i++) {
- CTabItem item = new CTabItem(folder, SWT.NONE);
- item.setText("Item "+i);
- Text text = new Text(folder, SWT.BORDER | SWT.MULTI);
- text.setText("Content for Item "+i);
- item.setControl(text);
- }
-
- final CTabItem specialItem = new CTabItem(folder, SWT.NONE);
- specialItem.setText("Don't Close Me");
- Text text = new Text(folder, SWT.BORDER | SWT.MULTI);
- text.setText("This tab can never be closed");
- specialItem.setControl(text);
-
- folder.addCTabFolder2Listener(new CTabFolder2Adapter() {
- public void close(CTabFolderEvent event) {
- if (event.item.equals(specialItem)) {
- event.doit = false;
- }
- }
- });
- shell.setSize(400, 400);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java
deleted file mode 100644
index e1fab825ce..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet83.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: determine data types available (win32 only)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.internal.ole.win32.*;
-import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet83 extends ByteArrayTransfer {
-
-private static Snippet83 _instance = new Snippet83();
-private int[] ids;
-private String[] names;
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Table control = new Table(shell, SWT.NONE);
- TableItem item = new TableItem(control, SWT.NONE);
- item.setText("Drag data over this site to see the native transfer type.");
- DropTarget target = new DropTarget(control, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_MOVE);
- target.setTransfer(new Transfer[] {Snippet83.getInstance()});
- target.addDropListener(new DropTargetAdapter() {
- public void dragEnter(DropTargetEvent event) {
- String ops = "";
- if ((event.operations & DND.DROP_COPY) != 0) ops += "Copy;";
- if ((event.operations & DND.DROP_MOVE) != 0) ops += "Move;";
- if ((event.operations & DND.DROP_LINK) != 0) ops += "Link;";
- control.removeAll();
- TableItem item1 = new TableItem(control,SWT.NONE);
- item1.setText("Allowed Operations are "+ops);
-
- if (event.detail == DND.DROP_DEFAULT) {
- if ((event.operations & DND.DROP_COPY) != 0) {
- event.detail = DND.DROP_COPY;
- } else if ((event.operations & DND.DROP_LINK) != 0) {
- event.detail = DND.DROP_LINK;
- } else if ((event.operations & DND.DROP_MOVE) != 0) {
- event.detail = DND.DROP_MOVE;
- }
- }
-
- TransferData[] data = event.dataTypes;
- for (int i = 0; i < data.length; i++) {
- int id = data[i].type;
- String name = getNameFromId(id);
- TableItem item2 = new TableItem(control,SWT.NONE);
- item2.setText("Data type is "+id+" "+name);
- }
- }
- });
-
- shell.setSize(400, 400);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-
-public static Snippet83 getInstance () {
- return _instance;
-}
-Snippet83() {
- ids = new int[80000];
- names = new String[80000];
- for (int i = 0; i < ids.length; i++) {
- ids[i] = i;
- names[i] = getNameFromId(i);
- }
-}
-public void javaToNative (Object object, TransferData transferData) {
-}
-public Object nativeToJava(TransferData transferData){
- return "Hello World";
-}
-protected String[] getTypeNames(){
- return names;
-}
-protected int[] getTypeIds(){
- return ids;
-}
-static String getNameFromId(int id) {
- String name = null;
- int maxSize = 128;
- TCHAR buffer = new TCHAR(0, maxSize);
- int size = COM.GetClipboardFormatName(id, buffer, maxSize);
- String type = null;
- if (size != 0) {
- name = buffer.toString(0, size);
- } else {
- switch (id) {
- case COM.CF_HDROP:
- name = "CF_HDROP";
- break;
- case COM.CF_TEXT:
- name = "CF_TEXT";
- break;
- case COM.CF_BITMAP:
- name = "CF_BITMAP";
- break;
- case COM.CF_METAFILEPICT:
- name = "CF_METAFILEPICT";
- break;
- case COM.CF_SYLK:
- name = "CF_SYLK";
- break;
- case COM.CF_DIF:
- name = "CF_DIF";
- break;
- case COM.CF_TIFF:
- name = "CF_TIFF";
- break;
- case COM.CF_OEMTEXT:
- name = "CF_OEMTEXT";
- break;
- case COM.CF_DIB:
- name = "CF_DIB";
- break;
- case COM.CF_PALETTE:
- name = "CF_PALETTE";
- break;
- case COM.CF_PENDATA:
- name = "CF_PENDATA";
- break;
- case COM.CF_RIFF:
- name = "CF_RIFF";
- break;
- case COM.CF_WAVE:
- name = "CF_WAVE";
- break;
- case COM.CF_UNICODETEXT:
- name = "CF_UNICODETEXT";
- break;
- case COM.CF_ENHMETAFILE:
- name = "CF_ENHMETAFILE";
- break;
- case COM.CF_LOCALE:
- name = "CF_LOCALE";
- break;
- case COM.CF_MAX:
- name = "CF_MAX";
- break;
- }
-
- }
- return name;
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet84.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet84.java
deleted file mode 100644
index 03c67e1278..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet84.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: define a default operation (in this example, Copy)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet84 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Text text = new Text(shell, SWT.BORDER | SWT.MULTI);
- DropTarget target = new DropTarget(text, DND.DROP_DEFAULT | DND.DROP_COPY);
- target.setTransfer(new Transfer[] {TextTransfer.getInstance()});
- target.addDropListener(new DropTargetAdapter() {
- public void dragEnter(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT) event.detail = DND.DROP_COPY;
- }
- public void dragOperationChanged(DropTargetEvent event) {
- if (event.detail == DND.DROP_DEFAULT) event.detail = DND.DROP_COPY;
- }
- public void drop(DropTargetEvent event) {
- text.setText((String)event.data);
- }
- });
-
- shell.setSize(400, 400);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet85.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet85.java
deleted file mode 100644
index eb6abfd7f7..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet85.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * PocketPC example snippet: Hello World
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet85 {
-
-public static void main(String[] args) {
- Display display = new Display();
-
- /*
- * Create a Shell with the default style
- * i.e. full screen, no decoration on PocketPC.
- */
- Shell shell = new Shell(display);
-
- /*
- * Set a text so that the top level Shell
- * also appears in the PocketPC task list
- */
- shell.setText("Main");
-
- /*
- * Set a menubar to follow UI guidelines
- * on PocketPC
- */
- Menu mb = new Menu(shell, SWT.BAR);
- shell.setMenuBar(mb);
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet86.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet86.java
deleted file mode 100644
index 74b30bb231..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet86.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * PocketPC Shell example snippet: 'Ok' button
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet86 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display, SWT.CLOSE);
- shell.setText("Main");
- Menu mb = new Menu(shell, SWT.BAR);
- shell.setMenuBar(mb);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet87.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet87.java
deleted file mode 100644
index a829f08f76..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet87.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * PocketPC Shell example snippet: resize automatically as SIP is on or off
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet87 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display, SWT.RESIZE);
- shell.setText("Main");
- Menu mb = new Menu(shell, SWT.BAR);
- shell.setMenuBar(mb);
- /* Add a button to make the resize more visual */
- FillLayout layout = new FillLayout();
- shell.setLayout(layout);
- Button button = new Button(shell, SWT.PUSH);
- button.setText("Main");
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet88.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet88.java
deleted file mode 100644
index 3b89f60363..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet88.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * TableEditor example snippet: edit the text of a table item (in place)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet88 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new FillLayout());
- final Table table = new Table(shell, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
- TableColumn column1 = new TableColumn(table, SWT.NONE);
- TableColumn column2 = new TableColumn(table, SWT.NONE);
- for (int i = 0; i < 10; i++) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText(new String[] {"item " + i, "edit this value"});
- }
- column1.pack();
- column2.pack();
-
- final TableEditor editor = new TableEditor(table);
- //The editor must have the same size as the cell and must
- //not be any smaller than 50 pixels.
- editor.horizontalAlignment = SWT.LEFT;
- editor.grabHorizontal = true;
- editor.minimumWidth = 50;
- // editing the second column
- final int EDITABLECOLUMN = 1;
-
- table.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- // Clean up any previous editor control
- Control oldEditor = editor.getEditor();
- if (oldEditor != null) oldEditor.dispose();
-
- // Identify the selected row
- TableItem item = (TableItem)e.item;
- if (item == null) return;
-
- // The control that will be the editor must be a child of the Table
- Text newEditor = new Text(table, SWT.NONE);
- newEditor.setText(item.getText(EDITABLECOLUMN));
- newEditor.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Text text = (Text)editor.getEditor();
- editor.getItem().setText(EDITABLECOLUMN, text.getText());
- }
- });
- newEditor.selectAll();
- newEditor.setFocus();
- editor.setEditor(newEditor, item, EDITABLECOLUMN);
- }
- });
- shell.setSize(300, 300);
- shell.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet89.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet89.java
deleted file mode 100644
index 011186409a..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet89.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Menu example snippet: create a menu with radio items
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-
-public class Snippet89 {
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- Menu menu = new Menu (shell, SWT.POP_UP);
- for (int i=0; i<4; i++) {
- MenuItem item = new MenuItem (menu, SWT.RADIO);
- item.setText ("Item " + i);
- item.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- MenuItem item = (MenuItem)e.widget;
- if (item.getSelection ()) {
- System.out.println (item + " selected");
- } else {
- System.out.println (item + " unselected");
- }
- }
- });
- }
- shell.setMenu (menu);
- shell.setSize (300, 300);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet9.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet9.java
deleted file mode 100644
index 4dae67c730..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet9.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Composite example snippet: scroll a child control automatically
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet9 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- final Shell shell = new Shell (display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL);
- final Composite composite = new Composite (shell, SWT.BORDER);
- composite.setSize (200, 400);
- final ScrollBar hBar = shell.getHorizontalBar ();
- hBar.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- Point location = composite.getLocation ();
- location.x = -hBar.getSelection ();
- composite.setLocation (location);
- }
- });
- final ScrollBar vBar = shell.getVerticalBar ();
- vBar.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- Point location = composite.getLocation ();
- location.y = -vBar.getSelection ();
- composite.setLocation (location);
- }
- });
- shell.addListener (SWT.Resize, new Listener () {
- public void handleEvent (Event e) {
- Point size = composite.getSize ();
- Rectangle rect = shell.getClientArea ();
- hBar.setMaximum (size.x);
- vBar.setMaximum (size.y);
- hBar.setThumb (Math.min (size.x, rect.width));
- vBar.setThumb (Math.min (size.y, rect.height));
- int hPage = size.x - rect.width;
- int vPage = size.y - rect.height;
- int hSelection = hBar.getSelection ();
- int vSelection = vBar.getSelection ();
- Point location = composite.getLocation ();
- if (hSelection >= hPage) {
- if (hPage <= 0) hSelection = 0;
- location.x = -hSelection;
- }
- if (vSelection >= vPage) {
- if (vPage <= 0) vSelection = 0;
- location.y = -vSelection;
- }
- composite.setLocation (location);
- }
- });
- shell.open ();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet90.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet90.java
deleted file mode 100644
index 0511208abb..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet90.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Tree example snippet: detect mouse down in a tree item
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet90 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- final Tree tree = new Tree (shell, SWT.BORDER | SWT.MULTI);
- for (int i=0; i<12; i++) {
- TreeItem treeItem = new TreeItem (tree, SWT.NULL);
- treeItem.setText ("Item " + i);
- }
- tree.addListener (SWT.MouseDown, new Listener () {
- public void handleEvent (Event event) {
- Point point = new Point (event.x, event.y);
- TreeItem item = tree.getItem (point);
- if (item != null) {
- System.out.println ("Mouse down: " + item);
- }
- }
- });
- tree.setSize (200, 200);
- shell.setSize (300, 300);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet91.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet91.java
deleted file mode 100644
index 242ea2d391..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet91.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Drag and Drop example snippet: drag leaf items in a tree
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet91 {
-
-public static void main (String [] args) {
-
- final Display display = Display.getDefault ();
- final Shell shell = new Shell (display);
- shell.setLayout(new FillLayout());
- final Tree tree = new Tree(shell, SWT.BORDER);
- for (int i = 0; i < 3; i++) {
- TreeItem item = new TreeItem(tree, SWT.NONE);
- item.setText("item "+i);
- for (int j = 0; j < 3; j++) {
- TreeItem subItem = new TreeItem(item, SWT.NONE);
- subItem.setText("item "+i+" "+j);
- for (int k = 0; k < 3; k++) {
- TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
- subsubItem.setText("item "+i+" "+j+" "+k);
- }
- }
- }
-
- Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
- int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
-
- final DragSource source = new DragSource (tree, operations);
- source.setTransfer(types);
- final TreeItem[] dragSourceItem = new TreeItem[1];
- source.addDragListener (new DragSourceListener () {
- public void dragStart(DragSourceEvent event) {
- TreeItem[] selection = tree.getSelection();
- if (selection.length > 0 && selection[0].getItemCount() == 0) {
- event.doit = true;
- dragSourceItem[0] = selection[0];
- } else {
- event.doit = false;
- }
- };
- public void dragSetData (DragSourceEvent event) {
- event.data = dragSourceItem[0].getText();
- }
- public void dragFinished(DragSourceEvent event) {
- if (event.detail == DND.DROP_MOVE)
- dragSourceItem[0].dispose();
- dragSourceItem[0] = null;
- }
- });
-
- DropTarget target = new DropTarget(tree, operations);
- target.setTransfer(types);
- target.addDropListener (new DropTargetAdapter() {
- public void dragOver(DropTargetEvent event) {
- event.feedback = DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
- if (event.item != null) {
- TreeItem item = (TreeItem)event.item;
- Point pt = display.map(null, tree, event.x, event.y);
- Rectangle bounds = item.getBounds();
- if (pt.y < bounds.y + bounds.height/3) {
- event.feedback |= DND.FEEDBACK_INSERT_BEFORE;
- } else if (pt.y > bounds.y + 2*bounds.height/3) {
- event.feedback |= DND.FEEDBACK_INSERT_AFTER;
- } else {
- event.feedback |= DND.FEEDBACK_SELECT;
- }
- }
- }
- public void drop(DropTargetEvent event) {
- if (event.data == null) {
- event.detail = DND.DROP_NONE;
- return;
- }
- String text = (String)event.data;
- if (event.item == null) {
- TreeItem item = new TreeItem(tree, SWT.NONE);
- item.setText(text);
- } else {
- TreeItem item = (TreeItem)event.item;
- Point pt = display.map(null, tree, event.x, event.y);
- Rectangle bounds = item.getBounds();
- TreeItem parent = item.getParentItem();
- if (parent != null) {
- TreeItem[] items = parent.getItems();
- int index = 0;
- for (int i = 0; i < items.length; i++) {
- if (items[i] == item) {
- index = i;
- break;
- }
- }
- if (pt.y < bounds.y + bounds.height/3) {
- TreeItem newItem = new TreeItem(parent, SWT.NONE, index);
- newItem.setText(text);
- } else if (pt.y > bounds.y + 2*bounds.height/3) {
- TreeItem newItem = new TreeItem(parent, SWT.NONE, index+1);
- newItem.setText(text);
- } else {
- TreeItem newItem = new TreeItem(item, SWT.NONE);
- newItem.setText(text);
- }
-
- } else {
- TreeItem[] items = tree.getItems();
- int index = 0;
- for (int i = 0; i < items.length; i++) {
- if (items[i] == item) {
- index = i;
- break;
- }
- }
- if (pt.y < bounds.y + bounds.height/3) {
- TreeItem newItem = new TreeItem(tree, SWT.NONE, index);
- newItem.setText(text);
- } else if (pt.y > bounds.y + 2*bounds.height/3) {
- TreeItem newItem = new TreeItem(tree, SWT.NONE, index+1);
- newItem.setText(text);
- } else {
- TreeItem newItem = new TreeItem(item, SWT.NONE);
- newItem.setText(text);
- }
- }
-
-
- }
- }
- });
-
- shell.setSize (400, 400);
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet92.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet92.java
deleted file mode 100644
index 1dbd768fd1..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet92.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Cursor example snippet: create a cursor from a source and a mask
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet92 {
-
-public static void main (String [] args) {
- Display display = new Display();
- Color white = display.getSystemColor (SWT.COLOR_WHITE);
- Color black = display.getSystemColor (SWT.COLOR_BLACK);
-
- //Create a source ImageData of depth 1 (monochrome)
- PaletteData palette = new PaletteData (new RGB [] {white.getRGB(), black.getRGB(),});
- ImageData sourceData = new ImageData (20, 20, 1, palette);
- for (int i = 0; i < 10; i ++) {
- for (int j = 0; j < 20; j++) {
- sourceData.setPixel(i, j, 1);
- }
- }
-
- //Create a mask ImageData of depth 1 (monochrome)
- palette = new PaletteData (new RGB [] {white.getRGB(), black.getRGB(),});
- ImageData maskData = new ImageData (20, 20, 1, palette);
- for (int i = 0; i < 20; i ++) {
- for (int j = 0; j < 10; j++) {
- maskData.setPixel(i, j, 1);
- }
- }
- //Create cursor
- Cursor cursor = new Cursor(display, sourceData, maskData, 10, 10);
-
- Shell shell = new Shell(display);
- final Image source = new Image (display,sourceData);
- final Image mask = new Image (display, maskData);
- //Draw source and mask just to show what they look like
- shell.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- GC gc = e.gc;
- gc.drawString("source: ", 10, 10);
- gc.drawImage(source, 0, 0, 20, 20, 50, 10, 20, 20);
- gc.drawString("mask: ",10, 40);
- gc.drawImage(mask, 0, 0, 20, 20, 50, 40, 20, 20);
- }
- });
- shell.setSize(150, 150);
- shell.open();
- shell.setCursor(cursor);
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- cursor.dispose();
- source.dispose();
- mask.dispose();
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet93.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet93.java
deleted file mode 100644
index 617182fe06..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet93.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * GC example snippet: measure a string
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.*;
-
-public class Snippet93 {
-
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.setLayout (new RowLayout ());
- Label label = new Label (shell, SWT.NULL);
- GC gc = new GC (label);
- Point size = gc.textExtent ("Hello");
- gc.dispose ();
- label.setText ("Hello -> " + size);
- shell.pack ();
- shell.open ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- display.dispose ();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet94.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet94.java
deleted file mode 100644
index 7ac0764dec..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet94.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Clipboard example snippet: copy and paste data with the clipboard
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet94 {
-
-public static void main( String[] args) {
- Display display = Display.getDefault ();
- final Clipboard cb = new Clipboard(display);
- final Shell shell = new Shell (display);
- shell.setLayout(new FormLayout());
- final Text text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
-
- Button copy = new Button(shell, SWT.PUSH);
- copy.setText("Copy");
- copy.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- String textData = text.getSelectionText();
- TextTransfer textTransfer = TextTransfer.getInstance();
- cb.setContents(new Object[]{textData}, new Transfer[]{textTransfer});
- }
- });
-
- Button paste = new Button(shell, SWT.PUSH);
- paste.setText("Paste");
- paste.addListener (SWT.Selection, new Listener () {
- public void handleEvent (Event e) {
- TextTransfer transfer = TextTransfer.getInstance();
- String data = (String)cb.getContents(transfer);
- if (data != null) {
- text.insert(data);
- }
- }
- });
-
- FormData data = new FormData();
- data.right = new FormAttachment(100, -5);
- data.top = new FormAttachment(0, 5);
- copy.setLayoutData(data);
-
- data = new FormData();
- data.right = new FormAttachment(100, -5);
- data.top = new FormAttachment(copy, 5);
- paste.setLayoutData(data);
-
- data = new FormData();
- data.left = new FormAttachment(0, 5);
- data.top = new FormAttachment(0, 5);
- data.right = new FormAttachment(copy, -5);
- data.bottom = new FormAttachment(100, -5);
- text.setLayoutData(data);
-
- shell.setSize(200, 200);
- shell.open();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
- }
- cb.dispose();
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet95.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet95.java
deleted file mode 100644
index aa2b627368..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet95.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * GC example snippet: capture a widget image with a GC
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet95 {
-
-public static void main(String[] args) {
- final Display display = new Display();
- final Shell shell = new Shell(display);
- shell.setText("Widget");
- shell.setBounds(10, 10, 200, 200);
-
- final Table table = new Table(shell, SWT.MULTI);
- table.setLinesVisible(true);
- table.setBounds(10, 10, 100, 100);
- for (int i = 0; i < 9; i++) {
- new TableItem(table, SWT.NONE).setText("item" + i);
- }
-
- Button button = new Button(shell, SWT.PUSH);
- button.setText("Capture");
- button.setBounds(10, 140, 50, 20);
- button.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- Point tableSize = table.getSize();
- GC gc = new GC(table);
- final Image image =
- new Image(display, tableSize.x, tableSize.y);
- gc.copyArea(image, 0, 0);
- gc.dispose();
-
- Shell popup = new Shell(shell);
- popup.setText("Image");
- popup.setBounds(50, 50, 200, 200);
- popup.addListener(SWT.Close, new Listener() {
- public void handleEvent(Event event) {
- image.dispose();
- }
- });
-
- Canvas canvas = new Canvas(popup, SWT.NONE);
- canvas.setBounds(10, 10, 150, 150);
- canvas.addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- e.gc.drawImage(image, 0, 0);
- }
- });
- popup.open();
- }
- });
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java
deleted file mode 100644
index d6688c0658..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet96.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * TableCursor example snippet: navigate a table cells with arrow keys.
- * Edit when user hits Return key. Exit edit mode by hitting Escape (cancels edit)
- * or Return (applies edit to table).
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.layout.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet96 {
-
-public static void main(String[] args) {
- Display display = new Display();
- Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
-
- // create a a table with 3 columns and fill with data
- final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- TableColumn column1 = new TableColumn(table, SWT.NONE);
- TableColumn column2 = new TableColumn(table, SWT.NONE);
- TableColumn column3 = new TableColumn(table, SWT.NONE);
- for (int i = 0; i < 100; i++) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText(new String[] {"cell " + i + " 0", "cell " + i + " 1", "cell " + i + " 2" });
- }
- column1.pack();
- column2.pack();
- column3.pack();
-
- // create a TableCursor to navigate around the table
- final TableCursor cursor = new TableCursor(table, SWT.NONE);
- // create an editor to edit the cell when the user hits "ENTER"
- // while over a cell in the table
- final ControlEditor editor = new ControlEditor(cursor);
- editor.grabHorizontal = true;
- editor.grabVertical = true;
-
- cursor.addSelectionListener(new SelectionAdapter() {
- // when the TableEditor is over a cell, select the corresponding row in
- // the table
- public void widgetSelected(SelectionEvent e) {
- table.setSelection(new TableItem[] { cursor.getRow()});
- }
- // when the user hits "ENTER" in the TableCursor, pop up a text editor so that
- // they can change the text of the cell
- public void widgetDefaultSelected(SelectionEvent e) {
- final Text text = new Text(cursor, SWT.NONE);
- TableItem row = cursor.getRow();
- int column = cursor.getColumn();
- text.setText(row.getText(column));
- text.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- // close the text editor and copy the data over
- // when the user hits "ENTER"
- if (e.character == SWT.CR) {
- TableItem row = cursor.getRow();
- int column = cursor.getColumn();
- row.setText(column, text.getText());
- text.dispose();
- }
- // close the text editor when the user hits "ESC"
- if (e.character == SWT.ESC) {
- text.dispose();
- }
- }
- });
- editor.setEditor(text);
- text.setFocus();
- }
- });
- // Hide the TableCursor when the user hits the "CTRL" or "SHIFT" key.
- // This alows the user to select multiple items in the table.
- cursor.addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.CTRL
- || e.keyCode == SWT.SHIFT
- || (e.stateMask & SWT.CONTROL) != 0
- || (e.stateMask & SWT.SHIFT) != 0) {
- cursor.setVisible(false);
- }
- }
- });
- // Show the TableCursor when the user releases the "SHIFT" or "CTRL" key.
- // This signals the end of the multiple selection task.
- table.addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent e) {
- if (e.keyCode == SWT.CONTROL && (e.stateMask & SWT.SHIFT) != 0)
- return;
- if (e.keyCode == SWT.SHIFT && (e.stateMask & SWT.CONTROL) != 0)
- return;
- if (e.keyCode != SWT.CONTROL
- && (e.stateMask & SWT.CONTROL) != 0)
- return;
- if (e.keyCode != SWT.SHIFT && (e.stateMask & SWT.SHIFT) != 0)
- return;
-
- TableItem[] selection = table.getSelection();
- TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
- table.showItem(row);
- cursor.setSelection(row, 0);
- cursor.setVisible(true);
- cursor.setFocus();
- }
- });
-
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- display.dispose();
-}
-}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet97.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet97.java
deleted file mode 100644
index 2fdbc59df6..0000000000
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet97.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.snippets;
-
-/*
- * Menu example snippet: fill a menu dynamically (when menu shown)
- *
- * For a list of all SWT example snippets see
- * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
- */
-import org.eclipse.swt.*;
-import org.eclipse.swt.widgets.*;
-
-public class Snippet97 {
-
-public static void main (String [] args) {
- final Display display = new Display ();
- Shell shell = new Shell (display);
- final Tree tree = new Tree (shell, SWT.BORDER | SWT.MULTI);
- final Menu menu = new Menu (shell, SWT.POP_UP);
- tree.setMenu (menu);
- for (int i=0; i<12; i++) {
- TreeItem item = new TreeItem (tree, SWT.NULL);
- item.setText ("Item " + i);
- }
- menu.addListener (SWT.Show, new Listener () {
- public void handleEvent (Event event) {
- MenuItem [] menuItems = menu.getItems ();
- for (int i=0; i