org.eclipse.swt.widgets.FontDialog Java Examples
The following examples show how to use
org.eclipse.swt.widgets.FontDialog.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PWFontChooser.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * @see org.eclipse.nebula.widgets.opal.preferencewindow.widgets.PWChooser#setButtonAction(org.eclipse.swt.widgets.Text, * org.eclipse.swt.widgets.Button) */ @Override protected void setButtonAction(final Text text, final Button button) { fontData = (FontData) PreferenceWindow.getInstance().getValueFor(getPropertyKey()); button.addListener(SWT.Selection, event -> { final FontDialog dialog = new FontDialog(text.getShell()); final FontData result = dialog.open(); if (result != null && result.getName() != null && !"".equals(result.getName().trim())) { fontData = result; PreferenceWindow.getInstance().setValue(getPropertyKey(), result); text.setText(buildFontInformation()); } }); }
Example #2
Source File: SWTFontChooser.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
public void choose(UIFontChooserHandler selectionHandler) { FontDialog dlg = new FontDialog(this.window.getControl()); if( this.text != null ) { dlg.setText(this.text); } Font defaultFont = null; if( this.defaultModel != null ) { defaultFont = new SWTFont(this.window.getControl().getDisplay(), this.defaultModel).getControl(); dlg.setFontList(defaultFont.getFontData()); } FontData fd = dlg.open(); if( defaultFont != null ) { defaultFont.dispose(); } selectionHandler.onSelectFont(fd != null ? new UIFontModel(fd.getName(), fd.getHeight(), ((fd.getStyle() & SWT.BOLD) != 0), ((fd.getStyle() & SWT.ITALIC) != 0)) : null); }
Example #3
Source File: Txt2DatDialog.java From ldparteditor with MIT License | 6 votes |
@Override public int open() { super.create(); // MARK All final listeners will be configured here.. spn_interpolateFlatness[0].addValueChangeListener(spn -> ts.setInterpolateFlatness(spn.getValue())); spn_flatness[0].addValueChangeListener(spn -> ts.setFlatness(spn.getValue())); spn_fontHeight[0].addValueChangeListener(spn -> ts.setFontHeight(spn.getValue())); spn_deltaAngle[0].addValueChangeListener(spn -> ts.setDeltaAngle(spn.getValue())); WidgetUtil(btn_chooseFont[0]).addSelectionListener(e -> { final FontDialog fd = new FontDialog(getShell()); final FontData data = ts.getFontData(); fd.setFontList(new FontData[]{data}); if (ts.getRGB() != null) { fd.setRGB(ts.getRGB()); } ts.setFontData(fd.open()); ts.setRGB(fd.getRGB()); }); txt_text[0].addModifyListener(e -> ts.setText(txt_text[0].getText())); return super.open(); }
Example #4
Source File: FontPicker.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public FontPicker(final Composite parent, Font originalFont) { super(parent, SWT.NONE); if (originalFont == null) throw new IllegalArgumentException("null"); update(originalFont.getFontData()[0]); addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setFontList(fontData); FontData selected = dialog.open(); if (selected != null) { update(selected); pack(true); } } }); }
Example #5
Source File: FontPicker.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public FontPicker(final Composite parent, Font originalFont) { super(parent, SWT.NONE); if (originalFont == null) throw new IllegalArgumentException("null"); update(originalFont.getFontData()[0]); addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setFontList(fontData); FontData selected = dialog.open(); if (selected != null) { update(selected); pack(true); } } }); }
Example #6
Source File: PTFontEditor.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * @see org.eclipse.nebula.widgets.opal.propertytable.editor.PTChooserEditor#openWindow(org.eclipse.nebula.widgets.opal.propertytable.PTWidget, * org.eclipse.swt.widgets.Item, org.eclipse.nebula.widgets.opal.propertytable.PTProperty) */ @Override protected void openWindow(final PTWidget widget, final Item item, final PTProperty property) { final FontDialog dialog = new FontDialog(widget.getWidget().getShell()); final FontData result = dialog.open(); if (result != null && result.getName() != null && !"".equals(result.getName().trim())) { property.setValue(result); if (item instanceof TableItem) { ((TableItem) item).setText(1, getTextFor(property)); } else { ((TreeItem) item).setText(1, getTextFor(property)); } } }
Example #7
Source File: FontEditor.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void widgetSelected(final SelectionEvent e) { final FontDialog dialog = new FontDialog(WorkbenchHelper.getShell()); dialog.setEffectsVisible(false); FontData data = toFontData(currentValue); dialog.setFontList(new FontData[] { data }); data = dialog.open(); if (data != null) { modifyAndDisplayValue(toGamaFont(data)); } }
Example #8
Source File: ThemePreferencePage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void createFontArea(Composite composite) { Composite themesComp = new Composite(composite, SWT.NONE); themesComp.setLayout(new GridLayout(3, false)); themesComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Label label = new Label(themesComp, SWT.NONE); label.setText(Messages.ThemePreferencePage_FontNameLabel); fFont = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT); fFontText = new Text(themesComp, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY); fFontText.setText(toString(fFont)); fFontText.setFont(fFont); fFontText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); Button selectFontButton = new Button(themesComp, SWT.PUSH); selectFontButton.setText(Messages.ThemePreferencePage_SelectFontButtonLabel); selectFontButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final FontDialog fontDialog = new FontDialog(getShell()); fontDialog.setFontList(fFont.getFontData()); final FontData data = fontDialog.open(); if (data != null) { setFont(new Font(fFont.getDevice(), fontDialog.getFontList())); } } }); }