Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2004-05-20 05:57:50 +0000
committerCarolyn MacLeod2004-05-20 05:57:50 +0000
commit75db647896117977768e2f1c7925d404f61d65fd (patch)
tree3368f5fbfe9b56dea4b732c070f3531659b656d6 /examples
parentc4f32bf69c6a0ce8ee58309208e5da44bb3fb885 (diff)
downloadeclipse.platform.swt-75db647896117977768e2f1c7925d404f61d65fd.tar.gz
eclipse.platform.swt-75db647896117977768e2f1c7925d404f61d65fd.tar.xz
eclipse.platform.swt-75db647896117977768e2f1c7925d404f61d65fd.zip
add italic to styled text tabv3053a
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/examples_control.properties1
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java37
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold.bmpbin134 -> 110 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold_mask.bmpbin134 -> 110 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic.bmpbin0 -> 110 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic_mask.bmpbin0 -> 110 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red.bmpbin334 -> 214 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red_mask.bmpbin134 -> 110 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow.bmpbin352 -> 214 bytes
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow_mask.bmpbin134 -> 110 bytes
10 files changed, 31 insertions, 7 deletions
diff --git a/examples/org.eclipse.swt.examples/src/examples_control.properties b/examples/org.eclipse.swt.examples/src/examples_control.properties
index 85ff7a6e4d..f2bee63745 100644
--- a/examples/org.eclipse.swt.examples/src/examples_control.properties
+++ b/examples/org.eclipse.swt.examples/src/examples_control.properties
@@ -158,6 +158,7 @@ Background_Style = Background Style
StyledText_Styles = Text Styles
StyledText_Style_Instructions = Select text, then style.
Bold = Bold
+Italic = Italic
Fill = Horizontal Fill
TabItem1_0 = Tab 0
TabItem1_1 = Tab 1
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
index 233c336d15..87749f66d9 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/StyledTextTab.java
@@ -27,8 +27,8 @@ class StyledTextTab extends ScrollableTab {
Button wrapButton, readOnlyButton, fullSelectionButton;
/* Buttons for adding StyleRanges to StyledText */
- Button boldButton, redButton, yellowButton;
- Image boldImage, redImage, yellowImage;
+ Button boldButton, italicButton, redButton, yellowButton;
+ Image boldImage, italicImage, redImage, yellowImage;
/**
* Creates the Tab within a given instance of ControlExample.
@@ -114,19 +114,22 @@ class StyledTextTab extends ScrollableTab {
final Display display = controlGroup.getDisplay ();
styledTextStyleGroup = new Group (controlGroup, SWT.NONE);
styledTextStyleGroup.setText (ControlExample.getResourceString ("StyledText_Styles"));
- styledTextStyleGroup.setLayout (new GridLayout(2, false));
- styledTextStyleGroup.setLayoutData (new GridData (GridData.HORIZONTAL_ALIGN_FILL));
+ styledTextStyleGroup.setLayout (new GridLayout(5, false));
+ GridData data = new GridData (GridData.HORIZONTAL_ALIGN_FILL);
+ data.horizontalSpan = 2;
+ styledTextStyleGroup.setLayoutData (data);
/* Get images */
boldImage = createBitmapImage (display, "bold");
+ italicImage = createBitmapImage (display, "italic");
redImage = createBitmapImage (display, "red");
yellowImage = createBitmapImage (display, "yellow");
/* Create controls to modify the StyledText */
Label label = new Label (styledTextStyleGroup, SWT.NONE);
label.setText (ControlExample.getResourceString ("StyledText_Style_Instructions"));
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 5;
label.setLayoutData(data);
new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Bold"));
boldButton = new Button (styledTextStyleGroup, SWT.PUSH);
@@ -139,15 +142,34 @@ class StyledTextTab extends ScrollableTab {
for (int i = sel.x; i<sel.x+sel.y; i++) {
StyleRange range = styledText.getStyleRangeAtOffset(i);
if (range == null) {style = new StyleRange(i, 1, null, null, SWT.BOLD);}
- else {style = new StyleRange(i, 1, range.foreground, range.background, SWT.BOLD);};
+ else {style = new StyleRange(i, 1, range.foreground, range.background, range.fontStyle | SWT.BOLD);};
styledText.setStyleRange(style);
}
styledText.setSelectionRange(sel.x + sel.y, 0);
}
});
+ new Label (styledTextStyleGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Foreground_Style"));
redButton = new Button (styledTextStyleGroup, SWT.PUSH);
redButton.setImage (redImage);
+ new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Italic"));
+ italicButton = new Button (styledTextStyleGroup, SWT.PUSH);
+ italicButton.setImage (italicImage);
+ italicButton.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent e) {
+ Point sel = styledText.getSelectionRange();
+ if ((sel == null) || (sel.y == 0)) return;
+ StyleRange style;
+ for (int i = sel.x; i<sel.x+sel.y; i++) {
+ StyleRange range = styledText.getStyleRangeAtOffset(i);
+ if (range == null) {style = new StyleRange(i, 1, null, null, SWT.ITALIC);}
+ else {style = new StyleRange(i, 1, range.foreground, range.background, range.fontStyle | SWT.ITALIC);};
+ styledText.setStyleRange(style);
+ }
+ styledText.setSelectionRange(sel.x + sel.y, 0);
+ }
+ });
+ new Label (styledTextStyleGroup, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label (styledTextStyleGroup, SWT.NONE).setText (ControlExample.getResourceString ("Background_Style"));
yellowButton = new Button (styledTextStyleGroup, SWT.PUSH);
yellowButton.setImage (yellowImage);
@@ -186,6 +208,7 @@ class StyledTextTab extends ScrollableTab {
yellowButton.addDisposeListener(new DisposeListener () {
public void widgetDisposed (DisposeEvent e) {
boldImage.dispose();
+ italicImage.dispose();
redImage.dispose();
yellowImage.dispose();
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold.bmp
index a3184bb26c..15136cbf7c 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold.bmp
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold_mask.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold_mask.bmp
index 382751efa3..7863429f50 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold_mask.bmp
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/bold_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic.bmp
new file mode 100644
index 0000000000..82071f6bdd
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic_mask.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic_mask.bmp
new file mode 100644
index 0000000000..caf2354d48
--- /dev/null
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/italic_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red.bmp
index 88c63be336..9a563ff34a 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red.bmp
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red_mask.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red_mask.bmp
index 6ce92645e5..1359c081de 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red_mask.bmp
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/red_mask.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow.bmp
index 631d0690fa..4da9c1de3f 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow.bmp
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow.bmp
Binary files differ
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow_mask.bmp b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow_mask.bmp
index 6ce92645e5..1359c081de 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow_mask.bmp
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/yellow_mask.bmp
Binary files differ

Back to the top