mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2026-10-24 23:02:27 +00:00
Adding font resizing.
This commit is contained in:
1 parent
bab8b8696c
commit
556a080106
5 files changed
+102
-21
No files matched your search
+5
-12
@@ -33,7 +33,6 @@ import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
@@ -74,8 +73,6 @@ public class FileViewerWindow {
|
||||
// May or may not be setup
|
||||
private Optional<ToolItem> disassemblyToolItem = Optional.empty();
|
||||
private Optional<ToolItem> shapeTableToolItem = Optional.empty();
|
||||
|
||||
private Font courier;
|
||||
|
||||
private ContentTypeAdapter contentTypeAdapter;
|
||||
private Map<Class<?>,FilterAdapter> nativeFilterAdapterMap;
|
||||
@@ -96,7 +93,7 @@ public class FileViewerWindow {
|
||||
* Construct the file viewer window.
|
||||
*/
|
||||
public FileViewerWindow(Shell parentShell, FileEntry fileEntry, ImageManager imageManager, FileFilter nativeFilter) {
|
||||
this.parentShell = shell;
|
||||
this.parentShell = parentShell;
|
||||
this.fileEntry = fileEntry;
|
||||
this.imageManager = imageManager;
|
||||
this.nativeFilter = nativeFilter;
|
||||
@@ -127,8 +124,6 @@ public class FileViewerWindow {
|
||||
content.setLayoutData(gridData);
|
||||
content.addListener(SWT.KeyUp, createToolbarCommandHandler());
|
||||
|
||||
courier = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL); //$NON-NLS-1$
|
||||
|
||||
nativeFilterAdapter.display();
|
||||
|
||||
shell.open();
|
||||
@@ -222,10 +217,11 @@ public class FileViewerWindow {
|
||||
* Dispose of all shared resources.
|
||||
*/
|
||||
protected void dispose(DisposeEvent event) {
|
||||
courier.dispose();
|
||||
if (nativeFilterAdapter != null) nativeFilterAdapter.dispose();
|
||||
hexFilterAdapter.dispose();
|
||||
rawDumpFilterAdapter.dispose();
|
||||
if (hexFilterAdapter != null) hexFilterAdapter.dispose();
|
||||
if (rawDumpFilterAdapter != null) rawDumpFilterAdapter.dispose();
|
||||
if (disassemblyFilterAdapter != null) disassemblyFilterAdapter.dispose();
|
||||
if (shapeTableFilterAdapter != null) shapeTableFilterAdapter.dispose();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@@ -440,9 +436,6 @@ public class FileViewerWindow {
|
||||
public void setContentTypeAdapter(ContentTypeAdapter adapter) {
|
||||
this.contentTypeAdapter = adapter;
|
||||
}
|
||||
public Font getCourierFont() {
|
||||
return courier;
|
||||
}
|
||||
public void setFilterToolItemSelection(boolean nativeSelected, boolean hexSelected, boolean dumpSelected,
|
||||
boolean disassemblySelected, boolean shapeTableSelected) {
|
||||
if (nativeToolItem != null) nativeToolItem.setSelection(nativeSelected);
|
||||
|
||||
+34
-3
@@ -27,6 +27,7 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
@@ -41,7 +42,9 @@ public class ApplesoftFilterAdapter extends FilterAdapter {
|
||||
private Color separatorColor;
|
||||
private Color stringColor;
|
||||
private Color tokenColor;
|
||||
|
||||
private int fontSize = 10;
|
||||
private Font courier;
|
||||
|
||||
public ApplesoftFilterAdapter(FileViewerWindow window, String text, String toolTipText, Image image) {
|
||||
super(window, text, toolTipText, image);
|
||||
}
|
||||
@@ -66,10 +69,14 @@ public class ApplesoftFilterAdapter extends FilterAdapter {
|
||||
separatorColor.dispose();
|
||||
tokenColor.dispose();
|
||||
stringColor.dispose();
|
||||
if (courier != null) {
|
||||
courier.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createStyledText() {
|
||||
courier = new Font(getComposite().getDisplay(), "Courier", fontSize, SWT.NORMAL); //$NON-NLS-1$
|
||||
|
||||
if (Display.isSystemDarkTheme()) {
|
||||
separatorColor = new Color(getComposite().getDisplay(), 255, 128, 128);
|
||||
tokenColor = new Color(getComposite().getDisplay(), 192, 192, 255);
|
||||
@@ -82,7 +89,7 @@ public class ApplesoftFilterAdapter extends FilterAdapter {
|
||||
|
||||
styledText = new StyledText(getComposite(), SWT.NONE);
|
||||
styledText.setForeground(getComposite().getForeground());
|
||||
styledText.setFont(getCourierFont());
|
||||
styledText.setFont(courier);
|
||||
styledText.setEditable(false);
|
||||
|
||||
ApplesoftTokenizer tokenizer = new ApplesoftTokenizer(getFileEntry());
|
||||
@@ -128,4 +135,28 @@ public class ApplesoftFilterAdapter extends FilterAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseSize() {
|
||||
fontSize++;
|
||||
updateFontSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseSize() {
|
||||
fontSize--;
|
||||
if (fontSize < 8) {
|
||||
fontSize = 8;
|
||||
}
|
||||
updateFontSize();
|
||||
}
|
||||
|
||||
public void updateFontSize() {
|
||||
Font oldFont = courier;
|
||||
courier = new Font(getComposite().getDisplay(), "Courier", fontSize, SWT.NORMAL); //$NON-NLS-1$
|
||||
styledText.setFont(courier);
|
||||
if (oldFont != null) {
|
||||
oldFont.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
-1
@@ -27,6 +27,7 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyleRange;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
||||
@@ -40,6 +41,8 @@ public class BusinessBASICFilterAdapter extends FilterAdapter {
|
||||
private Color separatorColor;
|
||||
private Color stringColor;
|
||||
private Color tokenColor;
|
||||
private int fontSize = 10;
|
||||
private Font courier;
|
||||
|
||||
public BusinessBASICFilterAdapter(FileViewerWindow window, String text, String toolTipText, Image image) {
|
||||
super(window, text, toolTipText, image);
|
||||
@@ -65,17 +68,22 @@ public class BusinessBASICFilterAdapter extends FilterAdapter {
|
||||
separatorColor.dispose();
|
||||
tokenColor.dispose();
|
||||
stringColor.dispose();
|
||||
if (courier != null) {
|
||||
courier.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void createStyledText() {
|
||||
courier = new Font(getComposite().getDisplay(), "Courier", fontSize, SWT.NORMAL); //$NON-NLS-1$
|
||||
|
||||
separatorColor = new Color(getComposite().getDisplay(), 192, 0, 0);
|
||||
tokenColor = new Color(getComposite().getDisplay(), 0, 0, 192);
|
||||
stringColor = new Color(getComposite().getDisplay(), 0, 192, 0);
|
||||
|
||||
styledText = new StyledText(getComposite(), SWT.NONE);
|
||||
styledText.setForeground(getComposite().getForeground());
|
||||
styledText.setFont(getCourierFont());
|
||||
styledText.setFont(courier);
|
||||
styledText.setEditable(false);
|
||||
|
||||
BusinessBASICTokenizer tokenizer = new BusinessBASICTokenizer(getFileEntry());
|
||||
@@ -140,4 +148,28 @@ public class BusinessBASICFilterAdapter extends FilterAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseSize() {
|
||||
fontSize++;
|
||||
updateFontSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseSize() {
|
||||
fontSize--;
|
||||
if (fontSize < 8) {
|
||||
fontSize = 8;
|
||||
}
|
||||
updateFontSize();
|
||||
}
|
||||
|
||||
public void updateFontSize() {
|
||||
Font oldFont = courier;
|
||||
courier = new Font(getComposite().getDisplay(), "Courier", fontSize, SWT.NORMAL); //$NON-NLS-1$
|
||||
styledText.setFont(courier);
|
||||
if (oldFont != null) {
|
||||
oldFont.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -27,7 +27,6 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.ToolBar;
|
||||
@@ -114,9 +113,6 @@ public abstract class FilterAdapter {
|
||||
protected void setContentTypeAdapter(ContentTypeAdapter adapter) {
|
||||
window.setContentTypeAdapter(adapter);
|
||||
}
|
||||
protected Font getCourierFont() {
|
||||
return window.getCourierFont();
|
||||
}
|
||||
protected Listener getToolbarCommandHandler() {
|
||||
return window.createToolbarCommandHandler();
|
||||
}
|
||||
|
||||
+30
-1
@@ -23,6 +23,7 @@ import com.webcodepro.applecommander.ui.swt.FileViewerWindow;
|
||||
import com.webcodepro.applecommander.ui.swt.util.contentadapter.StyledTextAdapter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.StyledText;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
|
||||
@@ -33,6 +34,8 @@ import org.eclipse.swt.graphics.Point;
|
||||
*/
|
||||
public class TextFilterAdapter extends FilterAdapter {
|
||||
private String textContent;
|
||||
private int fontSize = 10;
|
||||
private Font courier;
|
||||
|
||||
public TextFilterAdapter(FileViewerWindow window, String text, String toolTipText, Image image) {
|
||||
super(window, text, toolTipText, image);
|
||||
@@ -50,10 +53,23 @@ public class TextFilterAdapter extends FilterAdapter {
|
||||
return new String(getFileFilter().filter(getFileEntry()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
if (courier != null) {
|
||||
courier.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTextWidget(String textContents) {
|
||||
if (courier != null) {
|
||||
courier.dispose();
|
||||
}
|
||||
courier = new Font(getComposite().getDisplay(), "Courier", fontSize, SWT.NORMAL); //$NON-NLS-1$
|
||||
|
||||
StyledText styledText = new StyledText(getComposite(), SWT.NONE);
|
||||
styledText.setText(textContents);
|
||||
styledText.setFont(getCourierFont());
|
||||
styledText.setFont(courier);
|
||||
styledText.setEditable(false);
|
||||
//styledText.setWordWrap(true); // seems to throw size out-of-whack
|
||||
Point size = styledText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
|
||||
@@ -67,4 +83,17 @@ public class TextFilterAdapter extends FilterAdapter {
|
||||
getToolItem().setSelection(true);
|
||||
setContentTypeAdapter(new StyledTextAdapter(styledText, getFileEntry().getFilename()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void increaseSize() {
|
||||
fontSize++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decreaseSize() {
|
||||
fontSize--;
|
||||
if (fontSize < 8) {
|
||||
fontSize = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user