Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod2004-04-14 20:03:24 +0000
committerCarolyn MacLeod2004-04-14 20:03:24 +0000
commit764505ee5e2dff35c0844ae597d3bfe8f86b01b7 (patch)
tree50b61e0aabeca77fa445a3e1fc29823ed82d7d25
parent2bc859b256c89ecf2683208fab7687a9c6854dd4 (diff)
downloadeclipse.platform.swt-764505ee5e2dff35c0844ae597d3bfe8f86b01b7.tar.gz
eclipse.platform.swt-764505ee5e2dff35c0844ae597d3bfe8f86b01b7.tar.xz
eclipse.platform.swt-764505ee5e2dff35c0844ae597d3bfe8f86b01b7.zip
*** empty log message ***
-rw-r--r--examples/org.eclipse.swt.examples/src/examples_control.properties8
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java83
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java68
-rwxr-xr-xexamples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java51
4 files changed, 158 insertions, 52 deletions
diff --git a/examples/org.eclipse.swt.examples/src/examples_control.properties b/examples/org.eclipse.swt.examples/src/examples_control.properties
index 507c6e281c..3ca6d46ba1 100644
--- a/examples/org.eclipse.swt.examples/src/examples_control.properties
+++ b/examples/org.eclipse.swt.examples/src/examples_control.properties
@@ -144,13 +144,11 @@ DropDownData_6 =
DropDownData_7 = Strawberries
DropDownData_8 = The Longest String
Colors = Colors and Font
-Table_Item_Colors = Table Item 0 Colors
-Tree_Item_Colors = Tree Item 1 Colors
-CTab_Item_Colors = Tab Item 0 Colors
+Table_Item_Colors = Row 0 Colors and Font
+Tree_Item_Colors = Node 1 Colors and Font
+CTab_Item_Colors = CTab 0 Colors and Font
Background_Color = Background Color
Foreground_Color = Foreground Color
-Item_Background_Color = Item Background Color
-Item_Foreground_Color = Item Foreground Color
Font = &Font...
Defaults = &Defaults
Wrap_Text = Jack and Jill went up the hill to fetch a pail of water, \
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java
index 8d67eb9b0d..7170214fa2 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CTabFolderTab.java
@@ -23,8 +23,7 @@ class CTabFolderTab extends Tab {
/* Example widgets and groups that contain them */
CTabFolder tabFolder1;
- CTabItem tabItem0;
- Group tabFolderGroup, tabItemGroup;
+ Group tabFolderGroup, itemGroup;
/* Style widgets added to the "Style" group */
Button topButton, bottomButton, flatButton, closeButton;
@@ -34,9 +33,10 @@ class CTabFolderTab extends Tab {
ControlExample.getResourceString("CTabItem1_2")};
/* Controls and resources added to the "Colors" group */
- Button itemForegroundButton, itemBackgroundButton;
+ Button itemForegroundButton, itemBackgroundButton, itemFontButton;
Color itemForegroundColor, itemBackgroundColor;
Image itemForegroundImage, itemBackgroundImage;
+ Font itemFont;
/* Other widgets added to the "Other" group */
Button setSimpleTabButton, setImageButton;
@@ -54,20 +54,24 @@ class CTabFolderTab extends Tab {
void createColorGroup () {
super.createColorGroup();
- tabItemGroup = new Group (colorGroup, SWT.NONE);
- tabItemGroup.setText (ControlExample.getResourceString ("CTab_Item_Colors"));
+ itemGroup = new Group (colorGroup, SWT.NONE);
+ itemGroup.setText (ControlExample.getResourceString ("CTab_Item_Colors"));
GridData data = new GridData ();
data.horizontalSpan = 2;
- tabItemGroup.setLayoutData (data);
- tabItemGroup.setLayout (new GridLayout (2, false));
- new Label (tabItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Foreground_Color"));
- itemForegroundButton = new Button (tabItemGroup, SWT.PUSH);
- new Label (tabItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Background_Color"));
- itemBackgroundButton = new Button (tabItemGroup, SWT.PUSH);
+ itemGroup.setLayoutData (data);
+ itemGroup.setLayout (new GridLayout (2, false));
+ new Label (itemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Foreground_Color"));
+ itemForegroundButton = new Button (itemGroup, SWT.PUSH);
+ new Label (itemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Background_Color"));
+ itemBackgroundButton = new Button (itemGroup, SWT.PUSH);
+ itemFontButton = new Button (itemGroup, SWT.PUSH);
+ itemFontButton.setText(ControlExample.getResourceString("Font"));
+ itemFontButton.setLayoutData(new GridData (GridData.HORIZONTAL_ALIGN_FILL));
Shell shell = colorGroup.getShell ();
final ColorDialog foregroundDialog = new ColorDialog (shell);
final ColorDialog backgroundDialog = new ColorDialog (shell);
+ final FontDialog fontDialog = new FontDialog (shell);
int imageSize = 12;
Display display = shell.getDisplay ();
@@ -79,7 +83,7 @@ class CTabFolderTab extends Tab {
itemForegroundButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
Color oldColor = itemForegroundColor;
- if (oldColor == null) oldColor = tabItem0.getForeground ();
+ if (oldColor == null) oldColor = tabFolder1.getItem (0).getForeground ();
foregroundDialog.setRGB(oldColor.getRGB());
RGB rgb = foregroundDialog.open();
if (rgb == null) return;
@@ -93,7 +97,7 @@ class CTabFolderTab extends Tab {
itemBackgroundButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
Color oldColor = itemBackgroundColor;
- if (oldColor == null) oldColor = tabItem0.getBackground ();
+ if (oldColor == null) oldColor = tabFolder1.getItem (0).getBackground ();
backgroundDialog.setRGB(oldColor.getRGB());
RGB rgb = backgroundDialog.open();
if (rgb == null) return;
@@ -103,14 +107,30 @@ class CTabFolderTab extends Tab {
if (oldColor != null) oldColor.dispose ();
}
});
+ itemFontButton.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ Font oldFont = itemFont;
+ if (oldFont == null) oldFont = tabFolder1.getItem (0).getFont ();
+ fontDialog.setFontList(oldFont.getFontData());
+ FontData fontData = fontDialog.open ();
+ if (fontData == null) return;
+ oldFont = itemFont;
+ itemFont = new Font (event.display, fontData);
+ setItemFont ();
+ setExampleWidgetSize ();
+ if (oldFont != null) oldFont.dispose ();
+ }
+ });
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
if (itemBackgroundImage != null) itemBackgroundImage.dispose();
if (itemForegroundImage != null) itemForegroundImage.dispose();
if (itemBackgroundColor != null) itemBackgroundColor.dispose();
if (itemForegroundColor != null) itemForegroundColor.dispose();
+ if (itemFont != null) itemFont.dispose();
itemBackgroundColor = null;
- itemForegroundColor = null;
+ itemForegroundColor = null;
+ itemFont = null;
}
});
}
@@ -174,7 +194,6 @@ class CTabFolderTab extends Tab {
Label label = new Label(tabFolder1, SWT.NONE);
label.setText(ControlExample.getResourceString("CTabItem_content") + ": " + i);
item.setControl(label);
- if (i == 0) tabItem0 = item;
}
tabFolder1.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
@@ -286,6 +305,11 @@ class CTabFolderTab extends Tab {
itemBackgroundColor = null;
setItemBackground ();
if (oldColor != null) oldColor.dispose();
+ Font oldFont = font;
+ itemFont = null;
+ setItemFont ();
+ setExampleWidgetSize ();
+ if (oldFont != null) oldFont.dispose();
}
/**
@@ -297,6 +321,8 @@ class CTabFolderTab extends Tab {
setImages ();
setItemBackground ();
setItemForeground ();
+ setItemFont ();
+ setExampleWidgetSize ();
}
/**
@@ -323,26 +349,33 @@ class CTabFolderTab extends Tab {
}
/**
- * Sets the background color of the Node 1 TreeItems.
+ * Sets the background color of CTabItem 0.
*/
void setItemBackground () {
- tabItem0.setBackground (itemBackgroundColor);
+ tabFolder1.getItem (0).setBackground (itemBackgroundColor);
/* Set the background button's color to match the color just set. */
Color color = itemBackgroundColor;
- if (color == null) color = tabItem0.getBackground ();
- drawImage (itemForegroundImage, color);
- itemBackgroundButton.setImage (itemForegroundImage);
+ if (color == null) color = tabFolder1.getItem (0).getBackground ();
+ drawImage (itemBackgroundImage, color);
+ itemBackgroundButton.setImage (itemBackgroundImage);
}
/**
- * Sets the foreground color of Node 1 TreeItems.
+ * Sets the foreground color of CTabItem 0.
*/
void setItemForeground () {
- tabItem0.setForeground (itemForegroundColor);
+ tabFolder1.getItem (0).setForeground (itemForegroundColor);
/* Set the foreground button's color to match the color just set. */
Color color = itemForegroundColor;
- if (color == null) color = tabItem0.getForeground ();
- drawImage (itemBackgroundImage, color);
- itemForegroundButton.setImage (itemBackgroundImage);
+ if (color == null) color = tabFolder1.getItem (0).getForeground ();
+ drawImage (itemForegroundImage, color);
+ itemForegroundButton.setImage (itemForegroundImage);
+ }
+
+ /**
+ * Sets the font of CTabItem 0.
+ */
+ void setItemFont () {
+ tabFolder1.getItem (0).setFont (itemFont);
}
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
index 84cfa7e769..d98e3ac7ad 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java
@@ -20,7 +20,7 @@ import org.eclipse.swt.events.*;
class TableTab extends ScrollableTab {
/* Example widgets and groups that contain them */
Table table1;
- Group tableGroup, tableItemGroup;
+ Group tableGroup, itemGroup;
/* Style widgets added to the "Style" group */
Button checkButton, fullSelectionButton, hideSelectionButton;
@@ -29,9 +29,10 @@ class TableTab extends ScrollableTab {
Button headerVisibleButton, linesVisibleButton;
/* Controls and resources added to the "Colors" group */
- Button itemForegroundButton, itemBackgroundButton;
+ Button itemForegroundButton, itemBackgroundButton, itemFontButton;
Color itemForegroundColor, itemBackgroundColor;
Image itemForegroundImage, itemBackgroundImage;
+ Font itemFont;
static String [] columnTitles = {ControlExample.getResourceString("TableTitle_0"),
ControlExample.getResourceString("TableTitle_1"),
@@ -66,20 +67,24 @@ class TableTab extends ScrollableTab {
void createColorGroup () {
super.createColorGroup();
- tableItemGroup = new Group (colorGroup, SWT.NONE);
- tableItemGroup.setText (ControlExample.getResourceString ("Table_Item_Colors"));
+ itemGroup = new Group (colorGroup, SWT.NONE);
+ itemGroup.setText (ControlExample.getResourceString ("Table_Item_Colors"));
GridData data = new GridData ();
data.horizontalSpan = 2;
- tableItemGroup.setLayoutData (data);
- tableItemGroup.setLayout (new GridLayout (2, false));
- new Label (tableItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Foreground_Color"));
- itemForegroundButton = new Button (tableItemGroup, SWT.PUSH);
- new Label (tableItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Background_Color"));
- itemBackgroundButton = new Button (tableItemGroup, SWT.PUSH);
+ itemGroup.setLayoutData (data);
+ itemGroup.setLayout (new GridLayout (2, false));
+ new Label (itemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Foreground_Color"));
+ itemForegroundButton = new Button (itemGroup, SWT.PUSH);
+ new Label (itemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Background_Color"));
+ itemBackgroundButton = new Button (itemGroup, SWT.PUSH);
+ itemFontButton = new Button (itemGroup, SWT.PUSH);
+ itemFontButton.setText(ControlExample.getResourceString("Font"));
+ itemFontButton.setLayoutData(new GridData (GridData.HORIZONTAL_ALIGN_FILL));
Shell shell = colorGroup.getShell ();
final ColorDialog foregroundDialog = new ColorDialog (shell);
final ColorDialog backgroundDialog = new ColorDialog (shell);
+ final FontDialog fontDialog = new FontDialog (shell);
int imageSize = 12;
Display display = shell.getDisplay ();
@@ -115,14 +120,30 @@ class TableTab extends ScrollableTab {
if (oldColor != null) oldColor.dispose ();
}
});
+ itemFontButton.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ Font oldFont = itemFont;
+ if (oldFont == null) oldFont = table1.getItem (0).getFont ();
+ fontDialog.setFontList(oldFont.getFontData());
+ FontData fontData = fontDialog.open ();
+ if (fontData == null) return;
+ oldFont = itemFont;
+ itemFont = new Font (event.display, fontData);
+ setItemFont ();
+ setExampleWidgetSize ();
+ if (oldFont != null) oldFont.dispose ();
+ }
+ });
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
if (itemBackgroundImage != null) itemBackgroundImage.dispose();
if (itemForegroundImage != null) itemForegroundImage.dispose();
if (itemBackgroundColor != null) itemBackgroundColor.dispose();
if (itemForegroundColor != null) itemForegroundColor.dispose();
+ if (itemFont != null) itemFont.dispose();
itemBackgroundColor = null;
itemForegroundColor = null;
+ itemFont = null;
}
});
}
@@ -271,6 +292,11 @@ class TableTab extends ScrollableTab {
itemBackgroundColor = null;
setItemBackground ();
if (oldColor != null) oldColor.dispose();
+ Font oldFont = font;
+ itemFont = null;
+ setItemFont ();
+ setExampleWidgetSize ();
+ if (oldFont != null) oldFont.dispose();
}
/**
@@ -281,8 +307,8 @@ class TableTab extends ScrollableTab {
/* Set the background button's color to match the color just set. */
Color color = itemBackgroundColor;
if (color == null) color = table1.getItem (0).getBackground ();
- drawImage (itemForegroundImage, color);
- itemBackgroundButton.setImage (itemForegroundImage);
+ drawImage (itemBackgroundImage, color);
+ itemBackgroundButton.setImage (itemBackgroundImage);
}
/**
@@ -293,15 +319,27 @@ class TableTab extends ScrollableTab {
/* Set the foreground button's color to match the color just set. */
Color color = itemForegroundColor;
if (color == null) color = table1.getItem (0).getForeground ();
- drawImage (itemBackgroundImage, color);
- itemForegroundButton.setImage (itemBackgroundImage);
+ drawImage (itemForegroundImage, color);
+ itemForegroundButton.setImage (itemForegroundImage);
}
/**
+ * Sets the font of TableItem 0.
+ */
+ void setItemFont () {
+ table1.getItem (0).setFont (itemFont);
+ packColumns ();
+ }
+
+ /**
* Sets the font of the "Example" widgets.
*/
void setExampleWidgetFont () {
super.setExampleWidgetFont();
+ packColumns ();
+ }
+
+ void packColumns () {
for (int i = 0; i < columnTitles.length; i++) {
TableColumn tableColumn = table1.getColumn(i);
tableColumn.pack();
@@ -315,6 +353,8 @@ class TableTab extends ScrollableTab {
super.setExampleWidgetState ();
setItemBackground ();
setItemForeground ();
+ setItemFont ();
+ setExampleWidgetSize ();
setWidgetHeaderVisible ();
setWidgetLinesVisible ();
checkButton.setSelection ((table1.getStyle () & SWT.CHECK) != 0);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
index 8e933cda36..0952918ee3 100755
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java
@@ -27,9 +27,10 @@ class TreeTab extends ScrollableTab {
Button checkButton;
/* Controls and resources added to the "Colors" group */
- Button itemForegroundButton, itemBackgroundButton;
+ Button itemForegroundButton, itemBackgroundButton, itemFontButton;
Color itemForegroundColor, itemBackgroundColor;
Image itemForegroundImage, itemBackgroundImage;
+ Font itemFont;
/**
* Creates the Tab within a given instance of ControlExample.
@@ -50,14 +51,18 @@ class TreeTab extends ScrollableTab {
data.horizontalSpan = 2;
treeItemGroup.setLayoutData (data);
treeItemGroup.setLayout (new GridLayout (2, false));
- new Label (treeItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Foreground_Color"));
+ new Label (treeItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Foreground_Color"));
itemForegroundButton = new Button (treeItemGroup, SWT.PUSH);
- new Label (treeItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Item_Background_Color"));
+ new Label (treeItemGroup, SWT.NONE).setText (ControlExample.getResourceString ("Background_Color"));
itemBackgroundButton = new Button (treeItemGroup, SWT.PUSH);
+ itemFontButton = new Button (treeItemGroup, SWT.PUSH);
+ itemFontButton.setText(ControlExample.getResourceString("Font"));
+ itemFontButton.setLayoutData(new GridData (GridData.HORIZONTAL_ALIGN_FILL));
Shell shell = colorGroup.getShell ();
final ColorDialog foregroundDialog = new ColorDialog (shell);
final ColorDialog backgroundDialog = new ColorDialog (shell);
+ final FontDialog fontDialog = new FontDialog (shell);
int imageSize = 12;
Display display = shell.getDisplay ();
@@ -93,14 +98,30 @@ class TreeTab extends ScrollableTab {
if (oldColor != null) oldColor.dispose ();
}
});
+ itemFontButton.addSelectionListener(new SelectionAdapter () {
+ public void widgetSelected (SelectionEvent event) {
+ Font oldFont = itemFont;
+ if (oldFont == null) oldFont = textNode1.getFont ();
+ fontDialog.setFontList(oldFont.getFontData());
+ FontData fontData = fontDialog.open ();
+ if (fontData == null) return;
+ oldFont = itemFont;
+ itemFont = new Font (event.display, fontData);
+ setItemFont ();
+ setExampleWidgetSize ();
+ if (oldFont != null) oldFont.dispose ();
+ }
+ });
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
if (itemBackgroundImage != null) itemBackgroundImage.dispose();
if (itemForegroundImage != null) itemForegroundImage.dispose();
if (itemBackgroundColor != null) itemBackgroundColor.dispose();
if (itemForegroundColor != null) itemForegroundColor.dispose();
+ if (itemFont != null) itemFont.dispose();
itemBackgroundColor = null;
itemForegroundColor = null;
+ itemFont = null;
}
});
}
@@ -228,6 +249,11 @@ class TreeTab extends ScrollableTab {
itemBackgroundColor = null;
setItemBackground ();
if (oldColor != null) oldColor.dispose();
+ Font oldFont = font;
+ itemFont = null;
+ setItemFont ();
+ setExampleWidgetSize ();
+ if (oldFont != null) oldFont.dispose();
}
/**
@@ -237,6 +263,8 @@ class TreeTab extends ScrollableTab {
super.setExampleWidgetState ();
setItemBackground ();
setItemForeground ();
+ setItemFont ();
+ setExampleWidgetSize ();
checkButton.setSelection ((tree1.getStyle () & SWT.CHECK) != 0);
}
@@ -249,12 +277,12 @@ class TreeTab extends ScrollableTab {
/* Set the background button's color to match the color just set. */
Color color = itemBackgroundColor;
if (color == null) color = textNode1.getBackground ();
- drawImage (itemForegroundImage, color);
- itemBackgroundButton.setImage (itemForegroundImage);
+ drawImage (itemBackgroundImage, color);
+ itemBackgroundButton.setImage (itemBackgroundImage);
}
/**
- * Sets the foreground color of Node 1 TreeItems.
+ * Sets the foreground color of the Node 1 TreeItems.
*/
void setItemForeground () {
textNode1.setForeground (itemForegroundColor);
@@ -262,8 +290,15 @@ class TreeTab extends ScrollableTab {
/* Set the foreground button's color to match the color just set. */
Color color = itemForegroundColor;
if (color == null) color = textNode1.getForeground ();
- drawImage (itemBackgroundImage, color);
- itemForegroundButton.setImage (itemBackgroundImage);
+ drawImage (itemForegroundImage, color);
+ itemForegroundButton.setImage (itemForegroundImage);
}
+ /**
+ * Sets the font of the Node 1 TreeItems.
+ */
+ void setItemFont () {
+ textNode1.setFont (itemFont);
+ imageNode1.setFont (itemFont);
+ }
}

Back to the top