Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1981 converting option colors to theme colors and font usages to theme properties

ghidragon45395d757553
diff --git a/Ghidra/Debug/Debugger/data/debugger.theme.properties b/Ghidra/Debug/Debugger/data/debugger.theme.properties
index fd4f5fe7fe..08ed39fc5b 100644
--- a/Ghidra/Debug/Debugger/data/debugger.theme.properties
+++ b/Ghidra/Debug/Debugger/data/debugger.theme.properties
@@ -63,6 +63,8 @@ color.debugger.plugin.resources.breakpoint.marker.disabled.ineffective = color.d
icon.debugger.object.populated = object-populated.png
icon.debugger.object.unpopulated = object-unpopulated.png
+font.debugger.object.tree.renderer = Tahoma-plain-11
+
icon.debugger.display.graph = breakpoint-enable.png // TODO this icon was missing 'breakpoints.png'
icon.debugger.display.graph.filtered = icon.debugger.display.graph
icon.debugger.display.xml = text-xml.png
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/ObjectTreeCellRenderer.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/ObjectTreeCellRenderer.java
index 87fd6f04a9..6541145314 100644
--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/ObjectTreeCellRenderer.java
+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/objects/components/ObjectTreeCellRenderer.java
@@ -23,21 +23,18 @@ import javax.swing.tree.TreePath;
import docking.widgets.tree.support.GTreeRenderer;
import generic.theme.GThemeDefaults.Colors.Tables;
+import generic.theme.Gui;
import ghidra.app.plugin.core.debug.gui.objects.DebuggerObjectsProvider;
import ghidra.app.plugin.core.debug.gui.objects.ObjectContainer;
import ghidra.dbg.target.TargetExecutionStateful;
import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
import ghidra.dbg.target.TargetObject;
-import ghidra.util.SystemUtilities;
// TODO: In the new scheme, I'm not sure this is applicable anymore.
class ObjectTreeCellRenderer extends GTreeRenderer {
+ private static final String FONT_ID = "font.debugger.object.tree.renderer";
private final DebuggerObjectsProvider provider;
- private Font defaultFont =
- SystemUtilities.adjustForFontSizeOverride(new Font("Tahoma", Font.PLAIN, 11));
- private Font unsubscribedFont =
- SystemUtilities.adjustForFontSizeOverride(new Font("Tahoma", Font.ITALIC, 11));
public ObjectTreeCellRenderer(DebuggerObjectsProvider provider) {
this.provider = provider;
@@ -102,7 +99,11 @@ class ObjectTreeCellRenderer extends GTreeRenderer {
}
}
}
- component.setFont(container.isSubscribed() ? defaultFont : unsubscribedFont);
+ Font font = Gui.getFont(FONT_ID);
+ if (container.isSubscribed()) {
+ font = font.deriveFont(Font.ITALIC);
+ }
+ component.setFont(font);
}
return component;
}
diff --git a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/HelloWorldComponentProvider.java b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/HelloWorldComponentProvider.java
index b3c8d19ac5..f0701444f8 100644
--- a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/HelloWorldComponentProvider.java
+++ b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/HelloWorldComponentProvider.java
@@ -122,7 +122,7 @@ public class HelloWorldComponentProvider extends ComponentProviderAdapter {
panel.setBorder(BorderFactory.createTitledBorder("Example of a Component"));
activeButtonObj = new MyButton("Hello World");
Font f = activeButtonObj.getFont();
- activeButtonObj.setFont(new Font(f.getFontName(), Font.BOLD, 14));
+ activeButtonObj.setFont(f.deriveFont(Font.BOLD, 14));
panel.add(activeButtonObj);
mainPanel.add(panel, BorderLayout.CENTER);
}
diff --git a/Ghidra/Features/Base/data/base.listing.theme.properties b/Ghidra/Features/Base/data/base.listing.theme.properties
index f3be488dee..a5f34d42e5 100644
--- a/Ghidra/Features/Base/data/base.listing.theme.properties
+++ b/Ghidra/Features/Base/data/base.listing.theme.properties
@@ -76,7 +76,8 @@ color.bg.listing.comparison.operand = chartreuse
color.bg.listing.comparison.code.units.diff = silver
color.bg.listing.comparison.code.units.unmatched = skyblue
-
+font.listing.base = font.monospaced
+font.listing.header = SansSerif-PLAIN-11
[Dark Defaults]
diff --git a/Ghidra/Features/Base/data/base.programgraph.theme.properties b/Ghidra/Features/Base/data/base.programgraph.theme.properties
index 82779dc413..a460530063 100644
--- a/Ghidra/Features/Base/data/base.programgraph.theme.properties
+++ b/Ghidra/Features/Base/data/base.programgraph.theme.properties
@@ -1,7 +1,8 @@
[Defaults]
-
+color.bg.plugin.programgraph.vertex.selection = color.graphdisplay.vertex.selected
+color.bg.plugin.programgraph.edge.selection = color.graphdisplay.edge.selected
color.bg.plugin.programgraph.edge.call.callother.override = red
color.bg.plugin.programgraph.edge.call.computed = cyan
@@ -50,7 +51,7 @@ color.bg.plugin.programgraph.vertex.entry.nexus = wheat
color.bg.plugin.programgraph.vertex.instruction = blue
color.bg.plugin.programgraph.vertex.stack = green
-
+font.plugin.programgraph = font.graphdisplay.default
[Dark Defaults]
diff --git a/Ghidra/Features/Base/data/base.theme.properties b/Ghidra/Features/Base/data/base.theme.properties
index 98fe2c5c59..ea463db94d 100644
--- a/Ghidra/Features/Base/data/base.theme.properties
+++ b/Ghidra/Features/Base/data/base.theme.properties
@@ -158,8 +158,18 @@ color.bg.plugin.windowlocation.screens = orange
color.bg.plugin.windowlocation.window.selected = rgba(0, 255, 0, 200)
color.fg.plugin.windowlocation.window.text = gray
-
-
+font.print = SansSerif-PLAIN-10
+font.plugin.console = font.monospaced
+font.plugin.service.text.editor = font.monospaced
+font.plugin.scripts.text.editor = font.monospaced
+font.plugin.assembly.dual.text.field = font.monospaced
+font.plugin.instruction.table.renderer = courier-plain-14
+font.plugin.entropy.label.knot = SansSerif-BOLD-12
+font.plugin.instruction.info = font.monospaced[14]
+font.plugin.tabs = SansSerif-PLAIN-11
+font.plugin.tabs.list = SansSerif-BOLD-9
+font.plugin.tips = Dialog-PLAIN-12
+font.plugin.tips.label = font.plugin.tips[BOLD]
[Dark Defaults]
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tool/ViewInstructionDetailsAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tool/ViewInstructionDetailsAction.java
index c1da04e5b4..97910b13c5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tool/ViewInstructionDetailsAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tool/ViewInstructionDetailsAction.java
@@ -15,15 +15,8 @@
*/
package ghidra.app.merge.tool;
-import ghidra.app.context.ListingActionContext;
-import ghidra.app.context.ListingContextAction;
-import ghidra.app.merge.listing.CodeUnitDetails;
-import ghidra.program.model.address.Address;
-import ghidra.program.model.listing.*;
-import ghidra.program.util.ProgramLocation;
-import ghidra.util.HelpLocation;
-
-import java.awt.*;
+import java.awt.Dimension;
+import java.awt.Insets;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
@@ -33,6 +26,14 @@ import docking.DialogComponentProvider;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.fieldpanel.FieldPanel;
+import generic.theme.Gui;
+import ghidra.app.context.ListingActionContext;
+import ghidra.app.context.ListingContextAction;
+import ghidra.app.merge.listing.CodeUnitDetails;
+import ghidra.program.model.address.Address;
+import ghidra.program.model.listing.*;
+import ghidra.program.util.ProgramLocation;
+import ghidra.util.HelpLocation;
public class ViewInstructionDetailsAction extends ListingContextAction {
@@ -47,8 +48,8 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
setKeyBindingData(new KeyBindingData(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK |
InputEvent.SHIFT_DOWN_MASK));
setEnabled(true);
- setDescription("Display a dialog indicating details, such as references, for the "
- + "instruction at the current cursor location.");
+ setDescription("Display a dialog indicating details, such as references, for the " +
+ "instruction at the current cursor location.");
setHelpLocation(HELP_LOCATION);
}
@@ -87,13 +88,11 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
}
private JScrollPane createDetailsPane(String details) {
- Font font = new Font("Monospaced", Font.PLAIN, 12);
-
JTextArea textArea = new JTextArea();
+ Gui.registerFont(textArea, "font.monospaced");
textArea.setLineWrap(false);
textArea.setEditable(false);
textArea.setMargin(new Insets(5, 5, 5, 5));
- textArea.setFont(font);
textArea.setOpaque(true);
textArea.setCaretPosition(0);
textArea.setText(details);
@@ -102,8 +101,10 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
JViewport vp = scrolledDetails.getViewport();
vp.add(textArea);
- scrolledDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- scrolledDetails.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
+ scrolledDetails
+ .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ scrolledDetails
+ .setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
return scrolledDetails;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tree/TreeChangePanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tree/TreeChangePanel.java
index 8edc137bd5..09b03e4193 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tree/TreeChangePanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/tree/TreeChangePanel.java
@@ -75,7 +75,7 @@ class TreeChangePanel extends JPanel {
treeNameLabel = new GDLabel("Tree Name");
Font font = treeNameLabel.getFont();
- font = new Font(font.getName(), Font.BOLD, font.getSize());
+ font = font.deriveFont(Font.BOLD);
treeNameLabel.setFont(font);
nameLabel = new GDLabel("Name Changed");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/ArchiveDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/ArchiveDialog.java
index 266649b249..16468e6176 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/ArchiveDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/ArchiveDialog.java
@@ -94,7 +94,7 @@ public class ArchiveDialog extends DialogComponentProvider {
}
});
Font font = archiveBrowse.getFont();
- archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
+ archiveBrowse.setFont(font.deriveFont(Font.BOLD));
archiveBrowse.setName("archiveBrowse");
// Layout the components.
@@ -269,8 +269,10 @@ public class ArchiveDialog extends DialogComponentProvider {
return true;
}
- return file.getAbsolutePath().toLowerCase().endsWith(
- ArchivePlugin.ARCHIVE_EXTENSION);
+ return file.getAbsolutePath()
+ .toLowerCase()
+ .endsWith(
+ ArchivePlugin.ARCHIVE_EXTENSION);
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/RestoreDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/RestoreDialog.java
index 8dbf68512f..30dc9cfebd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/RestoreDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/archive/RestoreDialog.java
@@ -114,7 +114,7 @@ public class RestoreDialog extends DialogComponentProvider {
}
});
Font font = archiveBrowse.getFont();
- archiveBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
+ archiveBrowse.setFont(font.deriveFont(Font.BOLD));
restoreLabel = new GDLabel(" Restore Directory ");
restoreField = new JTextField();
@@ -131,7 +131,7 @@ public class RestoreDialog extends DialogComponentProvider {
}
});
font = restoreBrowse.getFont();
- restoreBrowse.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
+ restoreBrowse.setFont(font.deriveFont(Font.BOLD));
projectNameLabel = new GDLabel(" Project Name ");
projectNameField = new JTextField();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java
index 32d6e328ef..2a0068ac4f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/assembler/AssemblyDualTextField.java
@@ -27,8 +27,7 @@ import docking.EmptyBorderToggleButton;
import docking.widgets.autocomplete.*;
import docking.widgets.label.GDLabel;
import docking.widgets.textfield.TextFieldLinker;
-import generic.theme.GColor;
-import generic.theme.GIcon;
+import generic.theme.*;
import generic.theme.GThemeDefaults.Colors;
import ghidra.GhidraApplicationLayout;
import ghidra.GhidraLaunchable;
@@ -62,7 +61,7 @@ import ghidra.util.NumericUtilities;
* Otherwise, the usual autocompletion behavior is applied automatically.
*/
public class AssemblyDualTextField {
-
+ private static final String FONT_ID = "font.plugin.assembly.dual.text.field";
private static Color FG_PREFERENCE_MOST =
new GColor("color.fg.plugin.assembler.completion.most");
private static Color FG_PREFERENCE_MIDDLE =
@@ -659,8 +658,7 @@ public class AssemblyDualTextField {
* @param field the field to configure
*/
protected void configureField(JTextField field) {
- Font mono = new Font(Font.MONOSPACED, Font.PLAIN, 12); // TODO: Font size from options
- field.setFont(mono);
+ Gui.registerFont(field, FONT_ID);
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java
index 85eae792f6..16edd2b078 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java
@@ -26,9 +26,10 @@ import javax.swing.text.Document;
import docking.*;
import docking.action.*;
import generic.theme.GIcon;
+import generic.theme.Gui;
import ghidra.app.services.*;
import ghidra.framework.main.ConsoleTextPane;
-import ghidra.framework.options.OptionsChangeListener;
+import ghidra.framework.options.OptionType;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.PluginTool;
@@ -36,21 +37,21 @@ import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.SymbolIterator;
import ghidra.program.model.symbol.SymbolTable;
-import ghidra.util.*;
+import ghidra.util.HelpLocation;
+import ghidra.util.Msg;
public class ConsoleComponentProvider extends ComponentProviderAdapter
- implements ConsoleService, OptionsChangeListener {
+ implements ConsoleService {
private static final String OLD_NAME = "ConsolePlugin";
private static final String NAME = "Console";
- private static final Font DEFAULT_FONT = new Font("monospaced", Font.PLAIN, 12);
+ private static final String DEFAULT_FONT_ID = "font.plugin.console";
private static final String FONT_OPTION_LABEL = "Font";
private static final String FONT_DESCRIPTION =
"This is the font that will be used in the Console. " +
"Double-click the font example to change it.";
- private Font font;
private ConsoleTextPane textPane;
private JScrollPane scroller;
private JComponent component;
@@ -103,27 +104,16 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
private void createOptions() {
ToolOptions options = tool.getOptions("Console");
HelpLocation help = new HelpLocation(getOwner(), getOwner());
- options.registerOption(FONT_OPTION_LABEL, DEFAULT_FONT, help, FONT_DESCRIPTION);
+ options.registerOption(FONT_OPTION_LABEL, OptionType.FONT_TYPE, DEFAULT_FONT_ID, help,
+ FONT_DESCRIPTION);
options.setOptionsHelpLocation(help);
- font = options.getFont(FONT_OPTION_LABEL, DEFAULT_FONT);
- font = SystemUtilities.adjustForFontSizeOverride(font);
- options.addOptionsChangeListener(this);
- }
-
- @Override
- public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
- Object newValue) {
- if (optionName.equals(FONT_OPTION_LABEL)) {
- font = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
- textPane.setFont(font);
- }
}
private void build() {
textPane = new ConsoleTextPane(tool);
textPane.setName("CONSOLE");
- textPane.setFont(font);
+ Gui.registerFont(textPane, DEFAULT_FONT_ID);
textPane.setEditable(false);
textPane.addMouseMotionListener(new MouseMotionAdapter() {
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java
index c790337e8c..b8eaf1cd15 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembledViewPlugin.java
@@ -491,7 +491,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
OptionsGui.BACKGROUND.getDefaultColor());
// font
- font = opt.getFont(ADDRESS_FONT_OPTION, FieldFactory.DEFAULT_FIELD_FONT);
+ font = Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID);
contentList.setForeground(addressForegroundColor);
contentList.setBackground(backgroundColor);
@@ -580,7 +580,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
contentList.setBackground(backgroundColor);
}
else if (optionName.equals(ADDRESS_FONT_OPTION)) {
- font = (Font) newValue;
+ font = Gui.getFont(FieldFactory.BASE_LISTING_FONT_ID);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/editor/TextEditorComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/editor/TextEditorComponentProvider.java
index f8be13eae8..0fd822fcb4 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/editor/TextEditorComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/editor/TextEditorComponentProvider.java
@@ -19,8 +19,6 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.io.*;
-import java.util.Iterator;
-import java.util.List;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@@ -36,7 +34,7 @@ import docking.options.editor.FontEditor;
import docking.widgets.OptionDialog;
import docking.widgets.filechooser.GhidraFileChooser;
import generic.theme.GIcon;
-import ghidra.framework.options.SaveState;
+import generic.theme.Gui;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
@@ -45,24 +43,9 @@ import resources.Icons;
public class TextEditorComponentProvider extends ComponentProviderAdapter {
private static final String TITLE = "Text Editor";
-
+ private static final String FONT_ID = "font.plugin.service.text.editor";
private static final int MAX_UNDO_REDO_SIZE = 50;
- static Font defaultFont = new Font("monospaced", Font.PLAIN, 12);
-
- static void restoreState(SaveState saveState) {
- String name = saveState.getString("DEFAULT_FONT_NAME", "Monospaced");
- int style = saveState.getInt("DEFAULT_FONT_STYLE", Font.PLAIN);
- int size = saveState.getInt("DEFAULT_FONT_SIZE", 12);
- defaultFont = new Font(name, style, size);
- }
-
- static void saveState(SaveState saveState) {
- saveState.putString("DEFAULT_FONT_NAME", defaultFont.getName());
- saveState.putInt("DEFAULT_FONT_STYLE", defaultFont.getStyle());
- saveState.putInt("DEFAULT_FONT_SIZE", defaultFont.getSize());
- }
-
private TextEditorManagerPlugin plugin;
private GhidraFileChooser chooser;
private File textFile;
@@ -289,16 +272,9 @@ public class TextEditorComponentProvider extends ComponentProviderAdapter {
protected void doSelectFont() {
FontEditor editor = new FontEditor();
- editor.setValue(defaultFont);
+ editor.setValue(Gui.getFont(FONT_ID));
editor.showDialog();
- defaultFont = (Font) editor.getValue();
-
- List<TextEditorComponentProvider> values = plugin.getEditors();
- Iterator<TextEditorComponentProvider> iterator = values.iterator();
- while (iterator.hasNext()) {
- TextEditorComponentProvider editorComponent = iterator.next();
- editorComponent.textarea.setFont(defaultFont);
- }
+ Gui.setFont(FONT_ID, (Font) editor.getValue());
}
private void save() {
@@ -391,8 +367,7 @@ public class TextEditorComponentProvider extends ComponentProviderAdapter {
private KeyMasterTextArea(String text) {
super(text);
-
- setFont(defaultFont);
+ Gui.registerFont(this, FONT_ID);
setName("EDITOR");
setWrapStyleWord(false);
Document document = getDocument();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/fallthrough/FallThroughDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/fallthrough/FallThroughDialog.java
index 5b62e4aa60..3d58ff0476 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/fallthrough/FallThroughDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/fallthrough/FallThroughDialog.java
@@ -25,6 +25,7 @@ import javax.swing.event.ChangeListener;
import docking.DialogComponentProvider;
import docking.widgets.button.GRadioButton;
import docking.widgets.label.GDLabel;
+import generic.theme.Gui;
import ghidra.app.util.AddressInput;
import ghidra.program.model.address.Address;
import ghidra.util.HelpLocation;
@@ -162,8 +163,7 @@ class FallThroughDialog extends DialogComponentProvider implements ChangeListene
addressLabel = new GDLabel("01001000");
- Font font = addressLabel.getFont();
- Font monoFont = new Font("monospaced", font.getStyle(), font.getSize());
+ Font monoFont = Gui.getFont("font.monospaced");
addressLabel.setFont(monoFont);
instLabel = new GDLabel("jmp DAT_01001000");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java
index 270620a717..e70bc184b9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/AbstractInstructionTable.java
@@ -15,8 +15,6 @@
*/
package ghidra.app.plugin.core.instructionsearch.ui;
-import java.awt.Font;
-
import javax.swing.JToolBar;
import javax.swing.table.TableCellRenderer;
@@ -58,8 +56,7 @@ public abstract class AbstractInstructionTable extends GhidraTable {
protected JToolBar toolbar;
- protected InstructionTableCellRenderer renderer =
- new InstructionTableCellRenderer(new Font("Courier", Font.PLAIN, 14));
+ protected InstructionTableCellRenderer renderer = new InstructionTableCellRenderer();
protected InstructionSearchData searchData;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java
index 07e9a79018..d6833c37a8 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/ui/InstructionTableCellRenderer.java
@@ -30,9 +30,10 @@ import ghidra.util.table.GhidraTableCellRenderer;
* while adding some custom logic for changing background/foreground attributes.
*/
public class InstructionTableCellRenderer extends GhidraTableCellRenderer {
+ private static final String FONT_ID = "font.plugin.instruction.table.renderer";
- public InstructionTableCellRenderer(Font font) {
- super(font);
+ public InstructionTableCellRenderer() {
+ super(Gui.getFont(FONT_ID));
}
/**
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java
index a4e177db9c..99172e061e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterPanel.java
@@ -29,20 +29,21 @@ import javax.swing.text.*;
import docking.DockingUtils;
import docking.actions.KeyBindingUtils;
import generic.theme.GColor;
+import generic.theme.Gui;
import generic.util.WindowUtilities;
import ghidra.app.plugin.core.console.CodeCompletion;
-import ghidra.framework.options.OptionsChangeListener;
-import ghidra.framework.options.ToolOptions;
+import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
-import ghidra.util.*;
+import ghidra.util.HelpLocation;
+import ghidra.util.Msg;
public class InterpreterPanel extends JPanel implements OptionsChangeListener {
- private static final String COLOR_ID = "interpreterpanel.color";
private static final String COMPLETION_WINDOW_TRIGGER_LABEL = "Completion Window Trigger";
private static final String COMPLETION_WINDOW_TRIGGER_DESCRIPTION =
"The key binding used to show the auto-complete window " +
"(for those consoles that have auto-complete).";
+ private static final String FONT_ID = "font.plugin.console";
private static final String FONT_OPTION_LABEL = "Font";
private static final String FONT_DESCRIPTION =
"This is the font that will be used in the Console. " +
@@ -70,8 +71,6 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
private PrintWriter outWriter;
private PrintWriter errWriter;
- private Font basicFont = getBasicFont();
- private Font basicBoldFont = getBoldFont(basicFont);
private SimpleAttributeSet STDOUT_SET;
private SimpleAttributeSet STDERR_SET;
private SimpleAttributeSet STDIN_SET;
@@ -83,14 +82,6 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
private boolean caretGuard = true;
private PluginTool tool;
- private static Font getBasicFont() {
- return new Font(Font.MONOSPACED, Font.PLAIN, 20);
- }
-
- private static Font getBoldFont(Font font) {
- return font.deriveFont(Font.BOLD);
- }
-
private static SimpleAttributeSet createAttributes(Font font, Color color) {
SimpleAttributeSet attributeSet = new SimpleAttributeSet();
attributeSet.addAttribute(StyleConstants.FontFamily, font.getFamily());
@@ -370,15 +361,14 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
}
}
- private void updateFontAttributes(Font newFont) {
- basicFont = newFont;
- basicBoldFont = getBoldFont(newFont);
- STDOUT_SET = createAttributes(basicFont, NORMAL_COLOR);
- STDERR_SET = createAttributes(basicFont, ERROR_COLOR);
- STDIN_SET = createAttributes(basicBoldFont, NORMAL_COLOR);
+ private void updateFontAttributes(Font font) {
+ Font boldFont = font.deriveFont(Font.BOLD);
+ STDOUT_SET = createAttributes(font, NORMAL_COLOR);
+ STDERR_SET = createAttributes(font, ERROR_COLOR);
+ STDIN_SET = createAttributes(boldFont, NORMAL_COLOR);
- setTextPaneFont(inputTextPane, basicBoldFont);
- setTextPaneFont(promptTextPane, basicFont);
+ setTextPaneFont(inputTextPane, boldFont);
+ setTextPaneFont(promptTextPane, font);
setPrompt(promptTextPane.getText());
}
@@ -389,13 +379,13 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
HelpLocation help = new HelpLocation(getName(), "ConsolePlugin");
options.setOptionsHelpLocation(help);
- options.registerOption(FONT_OPTION_LABEL, basicFont, help, FONT_DESCRIPTION);
+ options.registerOption(FONT_OPTION_LABEL, OptionType.FONT_TYPE, FONT_ID, help,
+ FONT_DESCRIPTION);
options.registerOption(COMPLETION_WINDOW_TRIGGER_LABEL, CompletionWindowTrigger.TAB, help,
COMPLETION_WINDOW_TRIGGER_DESCRIPTION);
- basicFont = options.getFont(FONT_OPTION_LABEL, basicFont);
- basicFont = SystemUtilities.adjustForFontSizeOverride(basicFont);
- updateFontAttributes(basicFont);
+ Font font = Gui.getFont(FONT_ID);
+ updateFontAttributes(font);
completionWindowTrigger =
options.getEnum(COMPLETION_WINDOW_TRIGGER_LABEL, CompletionWindowTrigger.TAB);
@@ -413,8 +403,8 @@ public class InterpreterPanel extends JPanel implements OptionsChangeListener {
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
if (optionName.equals(FONT_OPTION_LABEL)) {
- basicFont = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
- updateFontAttributes(basicFont);
+ Font font = Gui.getFont(FONT_ID);
+ updateFontAttributes(font);
}
else if (optionName.equals(COMPLETION_WINDOW_TRIGGER_LABEL)) {
completionWindowTrigger = (CompletionWindowTrigger) newValue;
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/label/LabelHistoryPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/label/LabelHistoryPanel.java
index cd60813c14..b58a5832b2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/label/LabelHistoryPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/label/LabelHistoryPanel.java
@@ -27,6 +27,7 @@ import javax.swing.table.TableColumnModel;
import docking.widgets.GenericDateCellRenderer;
import docking.widgets.table.GTableCellRenderer;
import docking.widgets.table.GTableCellRenderingData;
+import generic.theme.Gui;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.LabelHistory;
import ghidra.util.table.GhidraTable;
@@ -126,16 +127,11 @@ class LabelHistoryPanel extends JPanel {
private Font monoFont;
- LabelCellRenderer() {
- Font f = getFont();
- monoFont = new Font("monospaced", f.getStyle(), f.getSize());
- }
-
@Override
public Component getTableCellRendererComponent(GTableCellRenderingData data) {
Component c = super.getTableCellRendererComponent(data);
- c.setFont(monoFont);
+ c.setFont(Gui.getFont("font.monospaced"));
return c;
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java
index 8d9c464fd6..8bf93f2d48 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/EntropyOverviewOptionsManager.java
@@ -39,34 +39,29 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
"Color to use for highlighting a specific range of entropy values";
private static final String KNOT_TYPE_STRING = "Type of range to highlight";
- private static final String KNOT1_COLOR_STRING = "Range 1 color";
- private static final String KNOT1_TYPE_STRING = "Entropy Range 1";
- private static final Color KNOT1_DEF_COLOR =
- new GColor("color.bg.plugin.overview.entropy.knot.1");
+ private static final String KNOT1_COLOR_OPTION_NAME = "Range 1 color";
+ private static final String KNOT1_TYPE_OPTION_NAME = "Entropy Range 1";
+ private static final Color KNOT1_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.1");
private static final EntropyKnot KNOT1_DEF_TYPE = EntropyKnot.COMPRESSED;
- private static final String KNOT2_COLOR_STRING = "Range 2 color";
- private static final String KNOT2_TYPE_STRING = "Entropy Range 2";
- private static final Color KNOT2_DEF_COLOR =
- new GColor("color.bg.plugin.overview.entropy.knot.2");
+ private static final String KNOT2_COLOR_OPTION_NAME = "Range 2 color";
+ private static final String KNOT2_TYPE_OPTION_NAME = "Entropy Range 2";
+ private static final Color KNOT2_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.2");
private static final EntropyKnot KNOT2_DEF_TYPE = EntropyKnot.X86;
- private static final String KNOT3_COLOR_STRING = "Range 3 color";
- private static final String KNOT3_TYPE_STRING = "Entropy Range 3";
- private static final Color KNOT3_DEF_COLOR =
- new GColor("color.bg.plugin.overview.entropy.knot.3");
+ private static final String KNOT3_COLOR_OPTION_NAME = "Range 3 color";
+ private static final String KNOT3_TYPE_OPTION_NAME = "Entropy Range 3";
+ private static final Color KNOT3_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.3");
private static final EntropyKnot KNOT3_DEF_TYPE = EntropyKnot.ASCII;
- private static final String KNOT4_COLOR_STRING = "Range 4 color";
- private static final String KNOT4_TYPE_STRING = "Entropy Range 4";
- private static final Color KNOT4_DEF_COLOR =
- new GColor("color.bg.plugin.overview.entropy.knot.4");
+ private static final String KNOT4_COLOR_OPTION_NAME = "Range 4 color";
+ private static final String KNOT4_TYPE_OPTION_NAME = "Entropy Range 4";
+ private static final Color KNOT4_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.4");
private static final EntropyKnot KNOT4_DEF_TYPE = EntropyKnot.UTF16;
- private static final String KNOT5_COLOR_STRING = "Range 5 color";
- private static final String KNOT5_TYPE_STRING = "Entropy Range 5";
- private static final Color KNOT5_DEF_COLOR =
- new GColor("color.bg.plugin.overview.entropy.knot.5");
+ private static final String KNOT5_COLOR_OPTION_NAME = "Range 5 color";
+ private static final String KNOT5_TYPE_OPTION_NAME = "Entropy Range 5";
+ private static final Color KNOT5_COLOR = new GColor("color.bg.plugin.overview.entropy.knot.5");
private static final EntropyKnot KNOT5_DEF_TYPE = EntropyKnot.NONE;
private static final Color PALETTE_COLOR_HIGH =
@@ -75,15 +70,10 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
new GColor("color.bg.plugin.overview.entropy.palette.base.low");
private EntropyChunkSize chunksize;
- private Color knot1color;
private EntropyKnot knot1type;
- private Color knot2color;
private EntropyKnot knot2type;
- private Color knot3color;
private EntropyKnot knot3type;
- private Color knot4color;
private EntropyKnot knot4type;
- private Color knot5color;
private EntropyKnot knot5type;
private OverviewPalette palette = new OverviewPalette(256, UNINITIALIZED_COLOR);
private EntropyOverviewColorService service;
@@ -97,17 +87,22 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
options.setOptionsHelpLocation(help);
options.registerOption(CHUNKSIZE_STRING, CHUNKSIZE_DEF, help, CHUNKSIZE_DESC_STRING);
- options.registerOption(KNOT1_COLOR_STRING, KNOT1_DEF_COLOR, help, KNOT_COLOR_STRING);
- options.registerOption(KNOT2_COLOR_STRING, KNOT2_DEF_COLOR, help, KNOT_COLOR_STRING);
- options.registerOption(KNOT3_COLOR_STRING, KNOT3_DEF_COLOR, help, KNOT_COLOR_STRING);
- options.registerOption(KNOT4_COLOR_STRING, KNOT4_DEF_COLOR, help, KNOT_COLOR_STRING);
- options.registerOption(KNOT5_COLOR_STRING, KNOT5_DEF_COLOR, help, KNOT_COLOR_STRING);
-
- options.registerOption(KNOT1_TYPE_STRING, KNOT1_DEF_TYPE, help, KNOT_TYPE_STRING);
- options.registerOption(KNOT2_TYPE_STRING, KNOT2_DEF_TYPE, help, KNOT_TYPE_STRING);
- options.registerOption(KNOT3_TYPE_STRING, KNOT3_DEF_TYPE, help, KNOT_TYPE_STRING);
- options.registerOption(KNOT4_TYPE_STRING, KNOT4_DEF_TYPE, help, KNOT_TYPE_STRING);
- options.registerOption(KNOT5_TYPE_STRING, KNOT5_DEF_TYPE, help, KNOT_TYPE_STRING);
+ options.registerOption(KNOT1_COLOR_OPTION_NAME, KNOT1_COLOR, help,
+ KNOT_COLOR_STRING);
+ options.registerOption(KNOT2_COLOR_OPTION_NAME, KNOT2_COLOR, help,
+ KNOT_COLOR_STRING);
+ options.registerOption(KNOT3_COLOR_OPTION_NAME, KNOT3_COLOR, help,
+ KNOT_COLOR_STRING);
+ options.registerOption(KNOT4_COLOR_OPTION_NAME, KNOT4_COLOR, help,
+ KNOT_COLOR_STRING);
+ options.registerOption(KNOT5_COLOR_OPTION_NAME, KNOT5_COLOR, help,
+ KNOT_COLOR_STRING);
+
+ options.registerOption(KNOT1_TYPE_OPTION_NAME, KNOT1_DEF_TYPE, help, KNOT_TYPE_STRING);
+ options.registerOption(KNOT2_TYPE_OPTION_NAME, KNOT2_DEF_TYPE, help, KNOT_TYPE_STRING);
+ options.registerOption(KNOT3_TYPE_OPTION_NAME, KNOT3_DEF_TYPE, help, KNOT_TYPE_STRING);
+ options.registerOption(KNOT4_TYPE_OPTION_NAME, KNOT4_DEF_TYPE, help, KNOT_TYPE_STRING);
+ options.registerOption(KNOT5_TYPE_OPTION_NAME, KNOT5_DEF_TYPE, help, KNOT_TYPE_STRING);
readOptions(options);
updatePalettes();
@@ -124,17 +119,11 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
private void readOptions(ToolOptions options) {
chunksize = options.getEnum(CHUNKSIZE_STRING, CHUNKSIZE_DEF);
- knot1color = options.getColor(KNOT1_COLOR_STRING, KNOT1_DEF_COLOR);
- knot2color = options.getColor(KNOT2_COLOR_STRING, KNOT2_DEF_COLOR);
- knot3color = options.getColor(KNOT3_COLOR_STRING, KNOT3_DEF_COLOR);
- knot4color = options.getColor(KNOT4_COLOR_STRING, KNOT4_DEF_COLOR);
- knot5color = options.getColor(KNOT5_COLOR_STRING, KNOT5_DEF_COLOR);
-
- knot1type = options.getEnum(KNOT1_TYPE_STRING, KNOT1_DEF_TYPE);
- knot2type = options.getEnum(KNOT2_TYPE_STRING, KNOT2_DEF_TYPE);
- knot3type = options.getEnum(KNOT3_TYPE_STRING, KNOT3_DEF_TYPE);
- knot4type = options.getEnum(KNOT4_TYPE_STRING, KNOT4_DEF_TYPE);
- knot5type = options.getEnum(KNOT5_TYPE_STRING, KNOT5_DEF_TYPE);
+ knot1type = options.getEnum(KNOT1_TYPE_OPTION_NAME, KNOT1_DEF_TYPE);
+ knot2type = options.getEnum(KNOT2_TYPE_OPTION_NAME, KNOT2_DEF_TYPE);
+ knot3type = options.getEnum(KNOT3_TYPE_OPTION_NAME, KNOT3_DEF_TYPE);
+ knot4type = options.getEnum(KNOT4_TYPE_OPTION_NAME, KNOT4_DEF_TYPE);
+ knot5type = options.getEnum(KNOT5_TYPE_OPTION_NAME, KNOT5_DEF_TYPE);
}
@@ -161,23 +150,23 @@ public class EntropyOverviewOptionsManager implements OptionsChangeListener {
private void addPaletteKnots() {
EntropyRecord rec = knot1type.getRecord();
if (rec != null) {
- addPaletteKnot(rec.name, knot1color, rec.center, rec.width);
+ addPaletteKnot(rec.name, KNOT1_COLOR, rec.center, rec.width);
}
rec = knot2type.getRecord();
if (rec != null) {
- addPaletteKnot(rec.name, knot2color, rec.center, rec.width);
+ addPaletteKnot(rec.name, KNOT2_COLOR, rec.center, rec.width);
}
rec = knot3type.getRecord();
if (rec != null) {
- addPaletteKnot(rec.name, knot3color, rec.center, rec.width);
+ addPaletteKnot(rec.name, KNOT3_COLOR, rec.center, rec.width);
}
rec = knot4type.getRecord();
if (rec != null) {
- addPaletteKnot(rec.name, knot4color, rec.center, rec.width);
+ addPaletteKnot(rec.name, KNOT4_COLOR, rec.center, rec.width);
}
rec = knot5type.getRecord();
if (rec != null) {
- addPaletteKnot(rec.name, knot5color, rec.center, rec.width);
+ addPaletteKnot(rec.name, KNOT5_COLOR, rec.center, rec.width);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotLabelPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotLabelPanel.java
index 5074b55d98..20453c9c9c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotLabelPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotLabelPanel.java
@@ -21,9 +21,10 @@ import java.util.ArrayList;
import javax.swing.JPanel;
import generic.theme.GThemeDefaults.Colors.Java;
+import generic.theme.Gui;
public class KnotLabelPanel extends JPanel {
- private static final Font FONT = new Font("Times New Roman", Font.BOLD, 16);
+ private static final String FONT_ID = "font.plugin.entropy.label.knot";
private int topBottomMargin = 10;
private OverviewPalette palette;
@@ -47,7 +48,7 @@ public class KnotLabelPanel extends JPanel {
g.setColor(getBackground());
g.fillRect(0, 0, width, height);
int paletteSize = palette.getSize();
- g.setFont(FONT);
+ g.setFont(Gui.getFont(FONT_ID));
FontMetrics fontMetrics = g.getFontMetrics();
int ascent = fontMetrics.getAscent();
int descent = fontMetrics.getDescent();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotPanel.java
deleted file mode 100644
index 344c1e25f7..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/overview/entropy/KnotPanel.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.overview.entropy;
-
-import java.awt.*;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.util.ArrayList;
-
-import javax.swing.*;
-import javax.swing.border.LineBorder;
-import javax.swing.event.ChangeListener;
-
-import docking.util.GraphicsUtils;
-import docking.widgets.label.GLabel;
-import generic.theme.GColor;
-import generic.theme.GThemeDefaults.Colors.Java;
-
-/**
- * Class used by the entropy legend panel to show known entropy ranges.
- */
-public class KnotPanel extends JPanel implements ComponentListener {
-
- private static final int SPACING = 5;
- private static final Font FONT = new Font("SansSerif", Font.PLAIN, 10);
- private static final Color FG_COLOR_TEXT =
- new GColor("color.bg.plugin.overview.entropy.palette.text");
-
- private OverviewPalette palette = null;
- private FontMetrics metrics;
-
- private ChangeListener paletteListener = e -> buildLabels();
-
- public KnotPanel() {
- super();
- addComponentListener(this);
- metrics = getFontMetrics(FONT);
- setPreferredSize(
- new Dimension(100, SPACING + metrics.getMaxAscent() + metrics.getMaxDescent()));
- }
-
- public void oldPaintComponent(Graphics g) {
- super.paintComponent(g);
- g.setColor(getBackground());
- Rectangle clip = g.getClipBounds();
- g.fillRect(clip.x, clip.y, clip.width, clip.height);
-
- if (palette == null) {
- return;
- }
-
- g.setFont(FONT);
- int height = getHeight();
- int width = getWidth();
- int palsize = palette.getSize();
- int fontHeight = metrics.getMaxAscent() + metrics.getMaxDescent();
- int baseline = (height - fontHeight - 1) / 2 + metrics.getMaxAscent();
-
- ArrayList<KnotRecord> knots = palette.getKnots();
- for (KnotRecord rec : knots) {
- g.setColor(Java.BORDER);
- int start = (rec.start * width) / palsize;
- int end = (rec.end * width) / palsize;
- g.drawLine(start, 0, start, height - 1);
- g.drawLine(end, 0, end, height - 1);
- g.drawLine(start, height - 1, end, height - 1);
-
- FontMetrics currentMetrics = metrics;
- int w = currentMetrics.stringWidth(rec.name);
- int knotwidth = end - start;
- while (w > knotwidth) {
- currentMetrics = getSmallerFontMetrics(currentMetrics);
- w = currentMetrics.stringWidth(rec.name);
-
- if (currentMetrics.getFont().getSize() <= 4) {
- break; // can't go any smaller
- }
- }
-
- g.setColor(FG_COLOR_TEXT);
- if (w < knotwidth) { // we found a suitable font
- g.setFont(currentMetrics.getFont());
- GraphicsUtils.drawString(this, g, rec.name, start + (knotwidth - 1) / 2 - w / 2,
- baseline);
- g.setFont(FONT);
- }
- else { // must be no room to paint the string, even with a small font
- String ellipsis = "...";
- w = metrics.stringWidth(ellipsis);
- GraphicsUtils.drawString(this, g, ellipsis, start + (knotwidth - 1) / 2 - w / 2,
- baseline);
- }
-
- // reset the font
- currentMetrics = metrics;
- }
-
- }
-
- private FontMetrics getSmallerFontMetrics(FontMetrics fontMetrics) {
- Font currentFont = fontMetrics.getFont();
- int size = currentFont.getSize();
- Font newFont = currentFont.deriveFont((float) --size);
- return getFontMetrics(newFont);
- }
-
- public void setPalette(OverviewPalette pal) {
- palette = pal;
- palette.addPaletteListener(paletteListener);
- buildLabels();
- repaint();
- }
-
- private void buildLabels() {
- removeAll();
- setLayout(null);
-
- int paletteSize = palette.getSize();
- Container parent = getParent();
-
- ArrayList<KnotRecord> knots = palette.getKnots();
- for (KnotRecord record : knots) {
- JLabel label = new GLabel(record.name);
- label.setFont(FONT);
- label.setBorder(new ToplessLineBorder(Java.BORDER));
- label.setHorizontalAlignment(SwingConstants.CENTER);
- label.setToolTipText(record.name);
-
- int height = getHeight();
- int width = getWidth();
- int start = (record.start * width) / paletteSize;
- int end = (record.end * width) / paletteSize;
-
- int labelWidth = end - start;
- int labelHeight = height - 1;
- int x = start + ((end - start >> 1) - (labelWidth >> 1));
- int y = 0;
-
- label.setBounds(x, y, labelWidth, labelHeight);
- add(label);
- }
- invalidate();
- if (parent != null) {
- parent.validate();
- }
- }
-
- public void refresh() {
- buildLabels();
- repaint();
- }
-
- @Override
- public void componentResized(ComponentEvent e) {
- refresh();
- }
-
- @Override
- public void componentHidden(ComponentEvent e) {
- }
-
- @Override
- public void componentMoved(ComponentEvent e) {
- }
-
- @Override
- public void componentShown(ComponentEvent e) {
- }
-
- private class ToplessLineBorder extends LineBorder {
-
- public ToplessLineBorder(Color color) {
- super(color);
- }
-
- @Override
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- super.paintBorder(c, g, x, y - 1, width, height + 1);
- }
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/printing/PrintOptionsDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/printing/PrintOptionsDialog.java
index 6ea1b7ed7a..059cd32b20 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/printing/PrintOptionsDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/printing/PrintOptionsDialog.java
@@ -23,13 +23,12 @@ import javax.swing.*;
import docking.DialogComponentProvider;
import docking.widgets.button.GRadioButton;
import docking.widgets.checkbox.GCheckBox;
+import generic.theme.Gui;
import ghidra.util.HelpLocation;
public class PrintOptionsDialog extends DialogComponentProvider {
- private final Font HEADER_FONT = new Font("SansSerif", Font.PLAIN, 10);
- private final FontMetrics HEADER_METRICS = rootPanel.getFontMetrics(HEADER_FONT);
-
+ private static final String FONT_ID = "font.print";
private boolean selectionEnabled;
private boolean cancelled = false;
@@ -163,11 +162,11 @@ public class PrintOptionsDialog extends DialogComponentProvider {
}
public Font getHeaderFont() {
- return HEADER_FONT;
+ return Gui.getFont(FONT_ID);
}
public FontMetrics getHeaderMetrics() {
- return HEADER_METRICS;
+ return rootPanel.getFontMetrics(getHeaderFont());
}
public boolean showHeader() {
@@ -183,7 +182,8 @@ public class PrintOptionsDialog extends DialogComponentProvider {
}
public int getHeaderHeight() {
- return HEADER_METRICS.getMaxAscent() + HEADER_METRICS.getMaxDescent();
+ FontMetrics metrics = getHeaderMetrics();
+ return metrics.getMaxAscent() + metrics.getMaxDescent();
}
public void setSelectionEnabled(boolean selectionEnabled) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/processors/InstructionInfoProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/processors/InstructionInfoProvider.java
index 9cad4e9a0c..6f3397b4b4 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/processors/InstructionInfoProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/processors/InstructionInfoProvider.java
@@ -21,6 +21,7 @@ import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import docking.widgets.checkbox.GCheckBox;
+import generic.theme.Gui;
import ghidra.app.plugin.processors.sleigh.SleighDebugLogger;
import ghidra.app.plugin.processors.sleigh.SleighDebugLogger.SleighDebugMode;
import ghidra.framework.model.DomainObjectChangedEvent;
@@ -38,6 +39,7 @@ import ghidra.util.table.GhidraTable;
*
*/
class InstructionInfoProvider extends ComponentProviderAdapter implements DomainObjectListener {
+ private static final String FONT_ID = "font.plugin.instruction.info";
private JPanel mainPanel;
private JSplitPane pane;
private ShowInstructionInfoPlugin plugin;
@@ -99,14 +101,12 @@ class InstructionInfoProvider extends ComponentProviderAdapter implements Domain
mainPanel = new JPanel(new BorderLayout());
instructionText = new JTextArea();
- Font defaultFont = instructionText.getFont();
- Font fixedWidthFont = new Font("monospaced", defaultFont.getStyle(), 14);
- instructionText.setFont(fixedWidthFont);
+ Gui.registerFont(instructionText, FONT_ID);
instructionText.setEditable(false);
operandModel = new OperandModel();
opTable = new GhidraTable(operandModel);
- opTable.setFont(fixedWidthFont);
+ Gui.registerFont(opTable, FONT_ID);
opTable.setPreferredScrollableViewportSize(new Dimension(425, 105));
//opTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/progmgr/MultiTabPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/progmgr/MultiTabPanel.java
index 9296770605..739e66634e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/progmgr/MultiTabPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/progmgr/MultiTabPanel.java
@@ -27,8 +27,7 @@ import javax.swing.border.*;
import docking.actions.KeyBindingUtils;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GIconLabel;
-import generic.theme.GColor;
-import generic.theme.GIcon;
+import generic.theme.*;
import generic.util.WindowUtilities;
import ghidra.framework.model.ProjectLocator;
import ghidra.program.model.listing.Program;
@@ -39,7 +38,8 @@ import resources.Icons;
* Panel to show a "tab" for an object. ChangeListeners are notified when a tab is selected.
*/
public class MultiTabPanel extends JPanel {
-
+ private static final String FONT_TABS_ID = "font.plugin.tabs";
+ private static final String FONT_TABS_LIST_ID = "font.plugin.tabs.list";
//@formatter:off
private final static Color SELECTED_TAB_COLOR = new GColor("color.bg.listing.tabs.selected");
private final static Color HIGHLIGHTED_TAB_BG_COLOR = new GColor("color.bg.listing.tabs.highlighted");
@@ -61,8 +61,6 @@ public class MultiTabPanel extends JPanel {
private static final Color BG_COLOR_MORE_TABS_HOVER =
new GColor("color.bg.listing.tabs.more.tabs.hover");
- private static final Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 11);
- private static final Font LIST_LABEL_FONT = new Font("Tahoma", Font.BOLD, 9);
private static final String DEFAULT_HIDDEN_COUNT_STR = "99";
/** A list of tabs that are hidden from view due to space constraints */
@@ -220,7 +218,7 @@ public class MultiTabPanel extends JPanel {
JLabel nameLabel = new GDLabel();
nameLabel.setIconTextGap(1);
nameLabel.setName("objectName"); // junit access
- nameLabel.setFont(LABEL_FONT);
+ Gui.registerFont(nameLabel, FONT_TABS_ID);
Color foregroundColor = isSelected ? TEXT_SELECTION_COLOR : TEXT_NON_SELECTION_COLOR;
nameLabel.setForeground(foregroundColor);
@@ -637,7 +635,7 @@ public class MultiTabPanel extends JPanel {
private JLabel createLabel() {
JLabel newLabel = new GDLabel(DEFAULT_HIDDEN_COUNT_STR, LIST_ICON, SwingConstants.LEFT);
newLabel.setIconTextGap(0);
- newLabel.setFont(LIST_LABEL_FONT);
+ Gui.registerFont(newLabel, FONT_TABS_LIST_ID);
newLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 4));
newLabel.setToolTipText("Show Tab List");
newLabel.setName("showList");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/EditReferencesProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/EditReferencesProvider.java
index d633b1980a..41dbbd3899 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/EditReferencesProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/EditReferencesProvider.java
@@ -1026,8 +1026,7 @@ public class EditReferencesProvider extends ComponentProviderAdapter
RefCellTextRenderer() {
defaultFont = getFont();
- boldFont = new Font(defaultFont.getName(), defaultFont.getStyle() | Font.BOLD,
- defaultFont.getSize());
+ boldFont = defaultFont.deriveFont(defaultFont.getStyle() | Font.BOLD);
setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0));
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/InstructionPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/InstructionPanel.java
index 0cca408775..98d27c2227 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/InstructionPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/InstructionPanel.java
@@ -33,6 +33,7 @@ import docking.dnd.DropTgtAdapter;
import docking.dnd.Droppable;
import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors;
+import generic.theme.Gui;
import ghidra.app.util.*;
import ghidra.app.util.viewer.field.BrowserCodeUnitFormat;
import ghidra.program.model.address.Address;
@@ -64,7 +65,6 @@ class InstructionPanel extends JPanel implements ChangeListener {
private JLabel[] operandLabels;
private DropTarget[] dropTargets; // 0: mnemonic, >= 1: operands
private JPanel innerPanel;
- private Font monoFont;
private int activeIndex;
private int activeSubIndex;
private CodeUnit currentCodeUnit;
@@ -207,14 +207,11 @@ class InstructionPanel extends JPanel implements ChangeListener {
setBorder(border);
addressLabel = new GDLabel("FFFFFFFF"); // use a default
-
- Font font = addressLabel.getFont();
- monoFont = new Font("monospaced", font.getStyle(), font.getSize());
- addressLabel.setFont(monoFont);
+ Gui.registerFont(addressLabel, "font.monospaced");
addressLabel.setName("addressLabel");
mnemonicLabel = new GDLabel("movl");
- mnemonicLabel.setFont(monoFont);
+ Gui.registerFont(mnemonicLabel, "font.monospaced");
mnemonicLabel.setName("mnemonicLabel");
mnemonicLabel.addMouseListener(mouseListener);
@@ -222,8 +219,8 @@ class InstructionPanel extends JPanel implements ChangeListener {
for (int i = 0; i < operandLabels.length; i++) {
operandLabels[i] = new GDLabel("%ebp, ");
operandLabels[i].setName("operandLabels[" + i + "]");
- operandLabels[i].setFont(monoFont);
operandLabels[i].addMouseListener(mouseListener);
+ Gui.registerFont(operandLabels[i], "font.monospaced");
}
innerPanel = new JPanel();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/RegisterValuesPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/RegisterValuesPanel.java
index 616d8f23ec..ba003a05ed 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/RegisterValuesPanel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/RegisterValuesPanel.java
@@ -28,6 +28,7 @@ import docking.widgets.OptionDialog;
import docking.widgets.table.*;
import generic.theme.GColor;
import generic.theme.GThemeDefaults.Colors.Palette;
+import generic.theme.Gui;
import ghidra.app.cmd.register.SetRegisterCmd;
import ghidra.app.events.ProgramSelectionPluginEvent;
import ghidra.app.services.*;
@@ -497,7 +498,7 @@ class RegisterValueRenderer extends GTableCellRenderer {
RegisterValueRenderer(JTable table) {
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
- setFont(new Font("monospaced", Font.PLAIN, 12));
+ Gui.registerFont(this, "font.monospaced");
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/SetRegisterValueDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/SetRegisterValueDialog.java
index 8a6c51ff82..a077bf5ceb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/SetRegisterValueDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/register/SetRegisterValueDialog.java
@@ -28,6 +28,7 @@ import javax.swing.event.ChangeListener;
import docking.DialogComponentProvider;
import docking.widgets.combobox.GComboBox;
import docking.widgets.label.GLabel;
+import generic.theme.Gui;
import ghidra.app.util.bean.FixedBitSizeValueField;
import ghidra.program.model.address.*;
import ghidra.program.model.lang.Register;
@@ -92,7 +93,7 @@ public class SetRegisterValueDialog extends DialogComponentProvider {
registerChanged();
}
});
- f = new Font("monospaced", Font.PLAIN, 13);
+ f = Gui.getFont("font.monospaced");
addressRangeList = new JList();
addressRangeList.setEnabled(false);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java
index 81fb4dc803..878c7c00cb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptEditorComponentProvider.java
@@ -20,8 +20,6 @@ import java.awt.Font;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.io.*;
-import java.util.Collection;
-import java.util.Iterator;
import javax.swing.*;
import javax.swing.text.Document;
@@ -35,14 +33,15 @@ import docking.widgets.OptionDialog;
import generic.jar.ResourceFile;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Colors;
+import generic.theme.Gui;
import ghidra.app.script.GhidraScriptUtil;
-import ghidra.framework.options.SaveState;
import ghidra.util.*;
import ghidra.util.datastruct.FixedSizeStack;
import resources.Icons;
public class GhidraScriptEditorComponentProvider extends ComponentProvider {
static final String EDITOR_COMPONENT_NAME = "EDITOR";
+ private static final String FONT_ID = "font.plugin.scripts.text.editor";
static final String CHANGE_DESTINATION_TITLE = "Where Would You Like to Store Your Changes?";
static final String FILE_ON_DISK_CHANGED_TITLE = "File Changed on Disk";
@@ -55,21 +54,6 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
private static final int MAX_UNDO_REDO_SIZE = 50;
- private static Font defaultFont = new Font("monospaced", Font.PLAIN, 12);
-
- static void restoreState(SaveState saveState) {
- String name = saveState.getString("DEFAULT_FONT_NAME", "Monospaced");
- int style = saveState.getInt("DEFAULT_FONT_STYLE", Font.PLAIN);
- int size = saveState.getInt("DEFAULT_FONT_SIZE", 12);
- defaultFont = new Font(name, style, size);
- }
-
- static void saveState(SaveState saveState) {
- saveState.putString("DEFAULT_FONT_NAME", defaultFont.getName());
- saveState.putInt("DEFAULT_FONT_STYLE", defaultFont.getStyle());
- saveState.putInt("DEFAULT_FONT_SIZE", defaultFont.getSize());
- }
-
private GhidraScriptMgrPlugin plugin;
private GhidraScriptComponentProvider provider;
private String title;
@@ -520,18 +504,11 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
}
}
- private void doSelectFont() {
+ protected void doSelectFont() {
FontEditor editor = new FontEditor();
- editor.setValue(defaultFont);
+ editor.setValue(Gui.getFont(FONT_ID));
editor.showDialog();
- defaultFont = (Font) editor.getValue();
-
- Collection<GhidraScriptEditorComponentProvider> values = provider.getEditorMap().values();
- Iterator<GhidraScriptEditorComponentProvider> iterator = values.iterator();
- while (iterator.hasNext()) {
- GhidraScriptEditorComponentProvider editorComponent = iterator.next();
- editorComponent.textArea.setFont(defaultFont);
- }
+ Gui.setFont(FONT_ID, (Font) editor.getValue());
}
private void save() {
@@ -681,7 +658,7 @@ public class GhidraScriptEditorComponentProvider extends ComponentProvider {
private KeyMasterTextArea(String text) {
super(text);
- setFont(defaultFont);
+ Gui.registerFont(this, FONT_ID);
setName(EDITOR_COMPONENT_NAME);
setWrapStyleWord(false);
Document document = getDocument();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptMgrPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptMgrPlugin.java
index f8d22be170..1aba81aaae 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptMgrPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/script/GhidraScriptMgrPlugin.java
@@ -78,14 +78,12 @@ public class GhidraScriptMgrPlugin extends ProgramPlugin implements GhidraScript
public void readConfigState(SaveState saveState) {
super.readConfigState(saveState);
provider.readConfigState(saveState);
- GhidraScriptEditorComponentProvider.restoreState(saveState);
}
@Override
public void writeConfigState(SaveState saveState) {
super.writeConfigState(saveState);
provider.writeConfigState(saveState);
- GhidraScriptEditorComponentProvider.saveState(saveState);
}
GhidraState getCurrentState() {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
index 1ccd817b04..04b7ed27bd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java
@@ -387,10 +387,10 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_NAME, true, null,
"Toggles highlight search results");
- opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
- PluginConstants.SEARCH_HIGHLIGHT_COLOR_ID, null, "The search result highlight color");
- opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
- PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_ID, null,
+ opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
+ PluginConstants.SEARCH_HIGHLIGHT_COLOR, null, "The search result highlight color");
+ opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
+ PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR, null,
"The search result highlight color for the currently selected match");
opt.addOptionsChangeListener(this);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java
index e44b83f771..55ba8c4a4c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java
@@ -435,10 +435,10 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_NAME, true, loc,
"Determines whether to highlight the matched string for a search in the listing.");
- opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
- PluginConstants.SEARCH_HIGHLIGHT_COLOR_ID, null, "The search result highlight color");
- opt.registerThemeColorOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
- PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_ID, null,
+ opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_COLOR_OPTION_NAME,
+ PluginConstants.SEARCH_HIGHLIGHT_COLOR, null, "The search result highlight color");
+ opt.registerOption(PluginConstants.SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME,
+ PluginConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR, null,
"The search result highlight color for the currently selected match");
searchLimit =
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/totd/TipOfTheDayDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/totd/TipOfTheDayDialog.java
index a1fde10264..fc5a3a0721 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/totd/TipOfTheDayDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/totd/TipOfTheDayDialog.java
@@ -15,7 +15,8 @@
*/
package ghidra.app.plugin.core.totd;
-import java.awt.*;
+import java.awt.BorderLayout;
+import java.awt.Component;
import java.util.List;
import javax.swing.*;
@@ -28,8 +29,11 @@ import docking.widgets.label.GLabel;
import generic.theme.GIcon;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Java;
+import generic.theme.Gui;
class TipOfTheDayDialog extends DialogComponentProvider {
+ private static final String FONT_ID = "font.plugin.tips";
+ private static final String FONT_LABEL_ID = "font.plugin.tips.label";
private static final int _24_HOURS = 86400000;
private TipOfTheDayPlugin plugin;
private JCheckBox showTipsCheckbox;
@@ -53,7 +57,7 @@ class TipOfTheDayDialog extends DialogComponentProvider {
tipArea = new JTextArea(4, 30);
tipArea.setEditable(false);
- tipArea.setFont(new Font("dialog", Font.PLAIN, 12));
+ tipArea.setFont(Gui.getFont(FONT_ID));
tipArea.setWrapStyleWord(true);
tipArea.setLineWrap(true);
tipArea.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@@ -87,7 +91,7 @@ class TipOfTheDayDialog extends DialogComponentProvider {
panel.setBackground(Colors.BACKGROUND);
JLabel label = new GLabel("Did you know...", tipIcon, SwingConstants.LEFT);
- label.setFont(new Font("dialog", Font.BOLD, 12));
+ Gui.registerFont(label, FONT_LABEL_ID);
panel.add(label, BorderLayout.NORTH);
panel.add(tipScroll, BorderLayout.CENTER);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/BlockPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/BlockPanel.java
deleted file mode 100644
index 56a2484de5..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/BlockPanel.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.util;
-
-import java.awt.*;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-
-import javax.swing.*;
-
-import docking.widgets.label.GDLabel;
-import generic.theme.GThemeDefaults.Colors;
-import ghidra.app.util.viewer.util.AddressPixelMap;
-import ghidra.program.model.mem.MemoryBlock;
-
-public class BlockPanel extends JPanel implements ComponentListener {
- private static final long serialVersionUID = 1L;
- private static final int SPACING = 5;
- private static final Font FONT = new Font("SansSerif", Font.PLAIN, 10);
- private AddressPixelMap map;
- private FontMetrics metrics;
-
- public BlockPanel() {
- super();
- setBackground(Colors.BACKGROUND);
- addComponentListener(this);
- metrics = getFontMetrics(FONT);
- setPreferredSize(
- new Dimension(100, SPACING + metrics.getMaxAscent() + metrics.getMaxDescent()));
- }
-
- @Override
- public void paintComponent(Graphics g) {
-
- g.setColor(Colors.FOREGROUND);
- g.setFont(FONT);
- int height = getHeight();
-
- MemoryBlock[] blocks = map.getBlocks();
- if (blocks == null) {
- return;
- }
-
- for (MemoryBlock block : blocks) {
- Rectangle rect = map.getBlockPosition(block);
- g.drawLine(rect.x, 0, rect.x, height - 1);
- }
- g.drawLine(getWidth() - 1, 0, getWidth() - 1, height - 1);
-
- g.drawLine(0, height - 1, getWidth() - 1, height - 1);
- }
-
- @Override
- protected void paintChildren(Graphics g) {
- //
- // clear the background; paint our labels; paint our divider lines
- //
- Color oldColor = g.getColor();
- g.setColor(getBackground());
- Rectangle clip = g.getClipBounds();
- g.fillRect(clip.x, clip.y, clip.width, clip.height);
- g.setColor(oldColor);
- super.paintChildren(g);
- paintComponent(g);
- }
-
- public void setMemoryBlockMap(AddressPixelMap map) {
- this.map = map;
- repaint();
- }
-
- /** Creates labels for the block names */
- private void buildLabels() {
- removeAll();
- setLayout(null);
-
- Container parent = getParent();
-
- MemoryBlock[] blocks = map.getBlocks();
- if (blocks == null) {
- return;
- }
-
- for (MemoryBlock block : blocks) {
- JLabel label = new GDLabel(block.getName());
- label.setFont(FONT);
- label.setHorizontalAlignment(SwingConstants.CENTER);
- label.setToolTipText(block.getName());
-
- Rectangle rect = map.getBlockPosition(block);
- int height = getHeight();
- int width = metrics.stringWidth(block.getName());
- if (rect.width < width) {
- label.setText("...");
- }
- int labelWidth = Math.min(rect.width, width);
- labelWidth = Math.max(labelWidth, 3);
- int labelHeight = height - 1;
- int x = rect.x + (rect.width - 1) / 2 - labelWidth / 2;
- int y = 0;
-
- label.setBounds(x, y, labelWidth, labelHeight);
- add(label);
- }
- invalidate();
- if (parent != null) {
- parent.validate();
- }
- }
-
- public void refresh() {
- buildLabels();
- repaint();
- }
-
- @Override
- public void componentResized(ComponentEvent e) {
- refresh();
- }
-
- @Override
- public void componentHidden(ComponentEvent e) {
- }
-
- @Override
- public void componentMoved(ComponentEvent e) {
- }
-
- @Override
- public void componentShown(ComponentEvent e) {
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java
index a11d2be67e..654a37c021 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/PluginConstants.java
@@ -90,8 +90,7 @@ public interface PluginConstants {
* Color for highlighting for searches.
*/
public static final String SEARCH_HIGHLIGHT_COLOR_OPTION_NAME = " Highlight Color";
- public static final String SEARCH_HIGHLIGHT_COLOR_ID = "color.bg.search.highlight";
- public static final Color SEARCH_HIGHLIGHT_COLOR = new GColor(SEARCH_HIGHLIGHT_COLOR_ID);
+ public static final Color SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.search.highlight");
/**
* Default highlight color used when something to highlight is at the current
@@ -99,9 +98,7 @@ public interface PluginConstants {
*/
public static final String SEARCH_HIGHLIGHT_CURRENT_COLOR_OPTION_NAME =
"Highlight Color for Current Match";
- public static final String SEARCH_HIGHLIGHT_CURRENT_COLOR_ID =
- "color.bg.search.current.line.highlight";
public static final Color SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR =
- new GColor(SEARCH_HIGHLIGHT_CURRENT_COLOR_ID);
+ new GColor("color.bg.search.current.line.highlight");
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bean/FixedBitSizeValueField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bean/FixedBitSizeValueField.java
index 39efb19014..98643e5d1d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bean/FixedBitSizeValueField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bean/FixedBitSizeValueField.java
@@ -28,6 +28,7 @@ import javax.swing.text.*;
import docking.widgets.SmallBorderButton;
import generic.theme.GIcon;
+import generic.theme.Gui;
public class FixedBitSizeValueField extends JPanel {
@@ -64,7 +65,7 @@ public class FixedBitSizeValueField extends JPanel {
}
add(valueField, BorderLayout.CENTER);
- Font f2 = new Font("monospaced", Font.PLAIN, 14);
+ Font f2 = Gui.getFont("font.monospaced");
valueField.setFont(f2);
valueField.setMargin(new Insets(0, 2, 0, 2));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java
index 71bd42d72e..93b36675f9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/AbstractVariableFieldFactory.java
@@ -24,7 +24,6 @@ import ghidra.app.util.viewer.options.ScreenElement;
import ghidra.framework.options.Options;
import ghidra.program.model.listing.Parameter;
import ghidra.program.model.listing.Variable;
-import ghidra.util.SystemUtilities;
public abstract class AbstractVariableFieldFactory extends FieldFactory {
@@ -110,7 +109,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {
Object newValue) {
if (optionName.equals(FONT_OPTION_NAME)) {
- baseFont = SystemUtilities.adjustForFontSizeOverride((Font) newValue);
+ baseFont = (Font) newValue;
setMetrics(baseFont, parameterFieldOptions[CUSTOM_PARAM_INDEX]);
setMetrics(baseFont, parameterFieldOptions[DYNAMIC_PARAM_INDEX]);
}
@@ -133,7 +132,7 @@ public abstract class AbstractVariableFieldFactory extends FieldFactory {
private void setMetrics(Font newFont, ParameterFieldOptions paramFieldOptions) {
paramFieldOptions.defaultMetrics = Toolkit.getDefaultToolkit().getFontMetrics(newFont);
for (int i = 0; i < paramFieldOptions.fontMetrics.length; i++) {
- Font font = new Font(newFont.getFamily(), i, newFont.getSize());
+ Font font = newFont.deriveFont(i); // i is looping over the 4 font styles PLAIN, BOLD, ITALIC, and BOLDITALIC
paramFieldOptions.fontMetrics[i] = Toolkit.getDefaultToolkit().getFontMetrics(font);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java
index fad3b41394..56d3b81b3a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/CommentUtils.java
@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.widgets.fieldpanel.field.*;
import generic.theme.GThemeDefaults.Colors;
+import generic.theme.Gui;
import ghidra.program.model.listing.Program;
import ghidra.util.StringUtilities;
import ghidra.util.WordLocation;
@@ -94,7 +95,7 @@ public class CommentUtils {
}
private static AttributedString createPrototype() {
- Font dummyFont = new Font("monospaced", Font.PLAIN, 12);
+ Font dummyFont = Gui.getFont("font.monospaced");
@SuppressWarnings("deprecation")
FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(dummyFont);
return new AttributedString("", Colors.FOREGROUND, fontMetrics);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java
index 5ac2a79af3..fb495845dc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/field/FieldFactory.java
@@ -21,6 +21,7 @@ import java.math.BigInteger;
import docking.widgets.fieldpanel.support.FieldLocation;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Palette;
+import generic.theme.Gui;
import ghidra.app.util.HighlightProvider;
import ghidra.app.util.viewer.format.FieldFormatModel;
import ghidra.app.util.viewer.options.OptionsGui;
@@ -41,7 +42,7 @@ import ghidra.util.classfinder.ExtensionPoint;
*/
public abstract class FieldFactory implements ExtensionPoint {
public static final String FONT_OPTION_NAME = "BASE FONT";
- public static final Font DEFAULT_FIELD_FONT = new Font("monospaced", Font.PLAIN, 12);
+ public static final String BASE_LISTING_FONT_ID = "font.listing.base";
protected FieldFormatModel model;
protected String name;
@@ -86,8 +87,7 @@ public abstract class FieldFactory implements ExtensionPoint {
}
protected void initDisplayOptions() {
- baseFont = SystemUtilities.adjustForFontSizeOverride(
- displayOptions.getFont(FONT_OPTION_NAME, DEFAULT_FIELD_FONT));
+ baseFont = Gui.getFont(BASE_LISTING_FONT_ID);
// For most fields (defined in optionsGui) these will be set. But "ad hoc" fields won't,
// so register something. A second registration won't change the original
@@ -351,7 +351,7 @@ public abstract class FieldFactory implements ExtensionPoint {
private void setMetrics(Font newFont) {
defaultMetrics = Toolkit.getDefaultToolkit().getFontMetrics(newFont);
for (int i = 0; i < fontMetrics.length; i++) {
- Font font = new Font(newFont.getFamily(), i, newFont.getSize());
+ Font font = newFont.deriveFont(i); // i is looping over the 4 font styles PLAIN, BOLD, ITALIC, and BOLDITALIC
fontMetrics[i] = Toolkit.getDefaultToolkit().getFontMetrics(font);
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldHeaderComp.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldHeaderComp.java
index 5e3f274584..1df5816d7b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldHeaderComp.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/format/FieldHeaderComp.java
@@ -23,6 +23,7 @@ import javax.swing.border.Border;
import docking.widgets.label.GDLabel;
import generic.theme.GColor;
+import generic.theme.Gui;
import ghidra.app.util.viewer.field.FieldFactory;
import ghidra.util.HelpLocation;
import ghidra.util.Swing;
@@ -33,6 +34,8 @@ import help.HelpService;
* Class manage a header for the FieldViewer.
*/
public class FieldHeaderComp extends JPanel {
+ private static final String FONT_ID = "font.listing.header";
+
private enum CursorState {
NOWHERE, NEAR_EDGE, OVER_FIELD
}
@@ -87,7 +90,7 @@ public class FieldHeaderComp extends JPanel {
defaultButtonBgColor = label.getBackground();
defaultButtonFgColor = label.getForeground();
label.setBorder(BorderFactory.createCompoundBorder(border2, border1));
- label.setFont(new Font("Tahoma", Font.PLAIN, 11));
+ label.setFont(Gui.getFont(FONT_ID));
Dimension d = label.getPreferredSize();
rowHeight = d.height;
this.setMinimumSize(new Dimension(0, 2 * rowHeight));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java
index 920fa05650..7e3dd4ebdd 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/viewer/options/ListingDisplayOptionsEditor.java
@@ -21,6 +21,7 @@ import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
+import generic.theme.Gui;
import ghidra.GhidraOptions;
import ghidra.framework.options.*;
@@ -28,7 +29,7 @@ import ghidra.framework.options.*;
* Class for editing Listing display properties.
*/
public class ListingDisplayOptionsEditor implements OptionsEditor {
- public static final Font DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 12);
+ public static final String DEFAULT_FONT_ID = "font.listing.base";
private OptionsGui optionsGui;
private Options options;
@@ -53,8 +54,8 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {
private void registerOptions() {
String prefix = "Sets the ";
- options.registerOption(GhidraOptions.OPTION_BASE_FONT, DEFAULT_FONT, null,
- prefix + GhidraOptions.OPTION_BASE_FONT);
+ options.registerOption(GhidraOptions.OPTION_BASE_FONT, OptionType.FONT_TYPE,
+ DEFAULT_FONT_ID, null, prefix + GhidraOptions.OPTION_BASE_FONT);
for (ScreenElement element : OptionsGui.elements) {
String colorOptionName = element.getColorOptionName();
options.registerOption(colorOptionName, element.getDefaultColor(), null,
@@ -68,7 +69,7 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {
public void apply() {
if (optionsGui != null) {
- Font font = options.getFont(GhidraOptions.OPTION_BASE_FONT, DEFAULT_FONT);
+ Font font = Gui.getFont(DEFAULT_FONT_ID);
Font newFont = optionsGui.getBaseFont();
if (!newFont.equals(font)) {
options.setFont(GhidraOptions.OPTION_BASE_FONT, newFont);
@@ -123,7 +124,7 @@ public class ListingDisplayOptionsEditor implements OptionsEditor {
@Override
public JComponent getEditorComponent(Options editableOptions,
EditorStateFactory editorStateFactory) {
- Font font = options.getFont(GhidraOptions.OPTION_BASE_FONT, DEFAULT_FONT);
+ Font font = Gui.getFont(DEFAULT_FONT_ID);
for (ScreenElement element : OptionsGui.elements) {
Color c = options.getColor(element.getColorOptionName(), element.getDefaultColor());
int style = options.getInt(element.getStyleOptionName(), -1);
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/framework/main/ConsoleTextPane.java b/Ghidra/Features/Base/src/main/java/ghidra/framework/main/ConsoleTextPane.java
index 5801b9bd6c..84a501aa27 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/framework/main/ConsoleTextPane.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/framework/main/ConsoleTextPane.java
@@ -22,6 +22,7 @@ import javax.swing.JTextPane;
import javax.swing.text.*;
import generic.theme.GColor;
+import generic.theme.Gui;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg;
@@ -202,7 +203,7 @@ public class ConsoleTextPane extends JTextPane implements OptionsChangeListener
}
private void createAttribtues() {
- createAttributes(new Font("monospaced", Font.PLAIN, 12));
+ createAttributes(Gui.getFont("font.monospaced"));
}
private void createAttributes(Font font) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/graph/ProgramGraphDisplayOptions.java b/Ghidra/Features/Base/src/main/java/ghidra/graph/ProgramGraphDisplayOptions.java
index 1bea16f958..cc385a1665 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/graph/ProgramGraphDisplayOptions.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/graph/ProgramGraphDisplayOptions.java
@@ -18,7 +18,6 @@ package ghidra.graph;
import static ghidra.graph.ProgramGraphType.*;
import static ghidra.service.graph.VertexShape.*;
-import generic.theme.GColor;
import ghidra.framework.plugintool.PluginTool;
import ghidra.service.graph.GraphDisplayOptions;
import ghidra.service.graph.VertexShape;
@@ -40,60 +39,64 @@ public class ProgramGraphDisplayOptions extends GraphDisplayOptions {
@Override
protected void initializeDefaults() {
setDefaultVertexShape(ELLIPSE);
- setDefaultVertexColor(new GColor("color.bg.plugin.programgraph.vertex.default"));
- setDefaultEdgeColor(new GColor("color.bg.plugin.programgraph.edge.default"));
+ setDefaultVertexColor("color.bg.plugin.programgraph.vertex.default");
+ setDefaultEdgeColor("color.bg.plugin.programgraph.edge.default");
+ setVertexSelectionColor("color.bg.plugin.programgraph.vertex.selection");
+ setEdgeSelectionColor("color.bg.plugin.programgraph.edge.selection");
setFavoredEdgeType(FALL_THROUGH);
//@formatter:off
- configureVertexType(BODY, RECTANGLE, new GColor("color.bg.plugin.programgraph.vertex.body"));
- configureVertexType(ENTRY, TRIANGLE_DOWN, new GColor("color.bg.plugin.programgraph.vertex.entry"));
- configureVertexType(EXIT, TRIANGLE_UP, new GColor("color.bg.plugin.programgraph.vertex.exit"));
- configureVertexType(SWITCH, DIAMOND, new GColor("color.bg.plugin.programgraph.vertex.switch"));
- configureVertexType(EXTERNAL, RECTANGLE, new GColor("color.bg.plugin.programgraph.vertex.external"));
- configureVertexType(BAD, ELLIPSE, new GColor("color.bg.plugin.programgraph.vertex.bad"));
- configureVertexType(DATA, ELLIPSE, new GColor("color.bg.plugin.programgraph.vertex.data"));
- configureVertexType(ENTRY_NEXUS, ELLIPSE, new GColor("color.bg.plugin.programgraph.vertex.entry.nexus"));
- configureVertexType(INSTRUCTION, VertexShape.HEXAGON, new GColor("color.bg.plugin.programgraph.vertex.instruction"));
- configureVertexType(STACK, RECTANGLE, new GColor("color.bg.plugin.programgraph.vertex.stack"));
+ configureVertexType(BODY, RECTANGLE, "color.bg.plugin.programgraph.vertex.body");
+ configureVertexType(ENTRY, TRIANGLE_DOWN, "color.bg.plugin.programgraph.vertex.entry");
+ configureVertexType(EXIT, TRIANGLE_UP, "color.bg.plugin.programgraph.vertex.exit");
+ configureVertexType(SWITCH, DIAMOND, "color.bg.plugin.programgraph.vertex.switch");
+ configureVertexType(EXTERNAL, RECTANGLE, "color.bg.plugin.programgraph.vertex.external");
+ configureVertexType(BAD, ELLIPSE, "color.bg.plugin.programgraph.vertex.bad");
+ configureVertexType(DATA, ELLIPSE, "color.bg.plugin.programgraph.vertex.data");
+ configureVertexType(ENTRY_NEXUS, ELLIPSE, "color.bg.plugin.programgraph.vertex.entry.nexus");
+ configureVertexType(INSTRUCTION, VertexShape.HEXAGON, "color.bg.plugin.programgraph.vertex.instruction");
+ configureVertexType(STACK, RECTANGLE, "color.bg.plugin.programgraph.vertex.stack");
- configureEdgeType(ENTRY_EDGE, new GColor("color.bg.plugin.programgraph.edge.entry"));
- configureEdgeType(FALL_THROUGH, new GColor("color.bg.plugin.programgraph.edge.fall.through"));
- configureEdgeType(UNCONDITIONAL_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.unconditional"));
- configureEdgeType(UNCONDITIONAL_CALL, new GColor("color.bg.plugin.programgraph.edge.call.unconditional"));
- configureEdgeType(TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.terminator"));
- configureEdgeType(JUMP_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.jump.terminator"));
- configureEdgeType(INDIRECTION, new GColor("color.bg.plugin.programgraph.edge.indirection"));
+ configureEdgeType(ENTRY_EDGE, "color.bg.plugin.programgraph.edge.entry");
+ configureEdgeType(FALL_THROUGH, "color.bg.plugin.programgraph.edge.fall.through");
+ configureEdgeType(UNCONDITIONAL_JUMP, "color.bg.plugin.programgraph.edge.jump.unconditional");
+ configureEdgeType(UNCONDITIONAL_CALL, "color.bg.plugin.programgraph.edge.call.unconditional");
+ configureEdgeType(TERMINATOR, "color.bg.plugin.programgraph.edge.terminator");
+ configureEdgeType(JUMP_TERMINATOR, "color.bg.plugin.programgraph.edge.jump.terminator");
+ configureEdgeType(INDIRECTION, "color.bg.plugin.programgraph.edge.indirection");
- configureEdgeType(CONDITIONAL_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.conditional"));
- configureEdgeType(CONDITIONAL_CALL, new GColor("color.bg.plugin.programgraph.edge.call.conditional"));
- configureEdgeType(CONDITIONAL_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.conditional.terminator"));
- configureEdgeType(CONDITIONAL_CALL_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.call.conditional.terminator"));
+ configureEdgeType(CONDITIONAL_JUMP, "color.bg.plugin.programgraph.edge.jump.conditional");
+ configureEdgeType(CONDITIONAL_CALL, "color.bg.plugin.programgraph.edge.call.conditional");
+ configureEdgeType(CONDITIONAL_TERMINATOR, "color.bg.plugin.programgraph.edge.conditional.terminator");
+ configureEdgeType(CONDITIONAL_CALL_TERMINATOR, "color.bg.plugin.programgraph.edge.call.conditional.terminator");
- configureEdgeType(COMPUTED_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.computed"));
- configureEdgeType(COMPUTED_CALL, new GColor("color.bg.plugin.programgraph.edge.call.computed"));
- configureEdgeType(COMPUTED_CALL_TERMINATOR, new GColor("color.bg.plugin.programgraph.edge.call.computed.terminator"));
+ configureEdgeType(COMPUTED_JUMP, "color.bg.plugin.programgraph.edge.jump.computed");
+ configureEdgeType(COMPUTED_CALL, "color.bg.plugin.programgraph.edge.call.computed");
+ configureEdgeType(COMPUTED_CALL_TERMINATOR, "color.bg.plugin.programgraph.edge.call.computed.terminator");
- configureEdgeType(CONDITIONAL_COMPUTED_CALL, new GColor("color.bg.plugin.programgraph.edge.call.conditional.computed"));
- configureEdgeType(CONDITIONAL_COMPUTED_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.conitional.computed"));
+ configureEdgeType(CONDITIONAL_COMPUTED_CALL, "color.bg.plugin.programgraph.edge.call.conditional.computed");
+ configureEdgeType(CONDITIONAL_COMPUTED_JUMP, "color.bg.plugin.programgraph.edge.jump.conitional.computed");
- configureEdgeType(CALL_OVERRIDE_UNCONDITIONAL, new GColor("color.bg.plugin.programgraph.edge.call.unconditional.override"));
- configureEdgeType(JUMP_OVERRIDE_UNCONDITIONAL, new GColor("color.bg.plugin.programgraph.edge.jump.unconditional.override"));
- configureEdgeType(CALLOTHER_OVERRIDE_CALL, new GColor("color.bg.plugin.programgraph.edge.call.callother.override"));
- configureEdgeType(CALLOTHER_OVERRIDE_JUMP, new GColor("color.bg.plugin.programgraph.edge.jump.callother.override"));
+ configureEdgeType(CALL_OVERRIDE_UNCONDITIONAL, "color.bg.plugin.programgraph.edge.call.unconditional.override");
+ configureEdgeType(JUMP_OVERRIDE_UNCONDITIONAL, "color.bg.plugin.programgraph.edge.jump.unconditional.override");
+ configureEdgeType(CALLOTHER_OVERRIDE_CALL, "color.bg.plugin.programgraph.edge.call.callother.override");
+ configureEdgeType(CALLOTHER_OVERRIDE_JUMP, "color.bg.plugin.programgraph.edge.jump.callother.override");
- configureEdgeType(READ, new GColor("color.bg.plugin.programgraph.edge.read"));
- configureEdgeType(WRITE, new GColor("color.bg.plugin.programgraph.edge.write"));
- configureEdgeType(READ_WRITE, new GColor("color.bg.plugin.programgraph.edge.read.write"));
- configureEdgeType(UNKNOWN_DATA, new GColor("color.bg.plugin.programgraph.edge.data.unknown"));
- configureEdgeType(EXTERNAL_REF, new GColor("color.bg.plugin.programgraph.edge.external.ref"));
+ configureEdgeType(READ, "color.bg.plugin.programgraph.edge.read");
+ configureEdgeType(WRITE, "color.bg.plugin.programgraph.edge.write");
+ configureEdgeType(READ_WRITE, "color.bg.plugin.programgraph.edge.read.write");
+ configureEdgeType(UNKNOWN_DATA, "color.bg.plugin.programgraph.edge.data.unknown");
+ configureEdgeType(EXTERNAL_REF, "color.bg.plugin.programgraph.edge.external.ref");
- configureEdgeType(READ_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.read.indirect"));
- configureEdgeType(WRITE_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.write.indirect"));
- configureEdgeType(READ_WRITE_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.read.write.indirect"));
- configureEdgeType(DATA_INDIRECT, new GColor("color.bg.plugin.programgraph.edge.data.indirect"));
+ configureEdgeType(READ_INDIRECT, "color.bg.plugin.programgraph.edge.read.indirect");
+ configureEdgeType(WRITE_INDIRECT, "color.bg.plugin.programgraph.edge.write.indirect");
+ configureEdgeType(READ_WRITE_INDIRECT, "color.bg.plugin.programgraph.edge.read.write.indirect");
+ configureEdgeType(DATA_INDIRECT, "color.bg.plugin.programgraph.edge.data.indirect");
- configureEdgeType(PARAM, new GColor("color.bg.plugin.programgraph.edge.param"));
- configureEdgeType(THUNK, new GColor("color.bg.plugin.programgraph.edge.thunk"));
+ configureEdgeType(PARAM, "color.bg.plugin.programgraph.edge.param");
+ configureEdgeType(THUNK, "color.bg.plugin.programgraph.edge.thunk");
+
+ setFont("font.plugin.programgraph");
//@formatter:on
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/plugin/importer/ImporterDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/plugin/importer/ImporterDialog.java
index 1d8b0a8367..12b447bc45 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/plugin/importer/ImporterDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/plugin/importer/ImporterDialog.java
@@ -243,7 +243,7 @@ public class ImporterDialog extends DialogComponentProvider {
});
Font font = languageButton.getFont();
- languageButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
+ languageButton.setFont(font.deriveFont(Font.BOLD));
JPanel panel = new JPanel(new BorderLayout());
panel.add(languageTextField, BorderLayout.CENTER);
diff --git a/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java b/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java
index 5e4de27ad0..a3cb362d54 100644
--- a/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java
+++ b/Ghidra/Features/Base/src/test/java/ghidra/framework/data/OptionsDBTest.java
@@ -309,7 +309,6 @@ public class OptionsDBTest extends AbstractGenericTest {
assertEquals(Palette.BLUE, options.getColor("Foo", null));
options.restoreDefaultValue("Foo");
assertEquals(Palette.RED, options.getColor("Foo", null));
-
}
@Test
diff --git a/Ghidra/Features/BytePatterns/data/bytepatterns.theme.properties b/Ghidra/Features/BytePatterns/data/bytepatterns.theme.properties
index 2991f66d52..650b2fc49e 100644
--- a/Ghidra/Features/BytePatterns/data/bytepatterns.theme.properties
+++ b/Ghidra/Features/BytePatterns/data/bytepatterns.theme.properties
@@ -12,6 +12,7 @@ icon.bytepatterns.pattern.mining.analyzer = magnifier.png
icon.bytepatterns.function.bit.patterns.disabled = ledred.png
icon.bytepatterns.function.bit.patterns.enabled = ledgreen.png
+font.bytepatterns.table = monospaced-PLAIN-16
[Dark Defaults]
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ByteSequenceTableModel.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ByteSequenceTableModel.java
index 7f712ca961..c476481a98 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ByteSequenceTableModel.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ByteSequenceTableModel.java
@@ -18,15 +18,13 @@
*/
package ghidra.bitpatterns.gui;
-import java.awt.Font;
+import java.awt.Component;
import java.util.List;
-import javax.swing.JTable;
-import javax.swing.table.TableModel;
-
import docking.widgets.table.AbstractDynamicTableColumn;
import docking.widgets.table.TableColumnDescriptor;
import docking.widgets.table.threaded.ThreadedTableModelStub;
+import generic.theme.Gui;
import ghidra.bitpatterns.info.ByteSequenceRowObject;
import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider;
@@ -38,7 +36,7 @@ import ghidra.util.table.column.GColumnRenderer;
import ghidra.util.task.TaskMonitor;
public class ByteSequenceTableModel extends ThreadedTableModelStub<ByteSequenceRowObject> {
- private static final int MONOSPACE_FONT_SIZE = 16;
+ private static final String FONT_ID = "font.bytepatterns.table";
List<ByteSequenceRowObject> rowObjects;
public ByteSequenceTableModel(FunctionBitPatternsExplorerPlugin plugin,
@@ -51,10 +49,13 @@ public class ByteSequenceTableModel extends ThreadedTableModelStub<ByteSequenceR
* Displays the byte sequences in monospace font
*/
protected GColumnRenderer<String> monospacedRenderer = new AbstractGColumnRenderer<String>() {
+
@Override
- protected void configureFont(JTable table, TableModel model, int column) {
- Font f = new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
- setFont(f);
+ public Component getTableCellRendererComponent(
+ docking.widgets.table.GTableCellRenderingData data) {
+ Component component = super.getTableCellRendererComponent(data);
+ component.setFont(Gui.getFont(FONT_ID));
+ return component;
}
@Override
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ClosedPatternTableModel.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ClosedPatternTableModel.java
index 98d4a8d0f9..be2d50dd9f 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ClosedPatternTableModel.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/ClosedPatternTableModel.java
@@ -15,15 +15,13 @@
*/
package ghidra.bitpatterns.gui;
-import java.awt.Font;
+import java.awt.Component;
import java.util.List;
-import javax.swing.JTable;
-import javax.swing.table.TableModel;
-
import docking.widgets.table.AbstractDynamicTableColumn;
import docking.widgets.table.TableColumnDescriptor;
import docking.widgets.table.threaded.ThreadedTableModelStub;
+import generic.theme.Gui;
import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.util.datastruct.Accumulator;
@@ -42,12 +40,13 @@ public class ClosedPatternTableModel extends ThreadedTableModelStub<ClosedPatter
private List<ClosedPatternRowObject> rowObjects;
private static final String MODEL_NAME = "Closed Patterns";
- private static final int MONOSPACE_FONT_SIZE = 16;
+
+ protected static final String FONT_ID = "font.bytepatterns.table";
/**
* Creates a table model for closed patterns mined from byte sequences
- * @param rowObjects
- * @param serviceProvider
+ * @param rowObjects the row objects
+ * @param serviceProvider the service provider
*/
public ClosedPatternTableModel(List<ClosedPatternRowObject> rowObjects,
ServiceProvider serviceProvider) {
@@ -57,11 +56,12 @@ public class ClosedPatternTableModel extends ThreadedTableModelStub<ClosedPatter
}
protected GColumnRenderer<String> monospacedRenderer = new AbstractGColumnRenderer<String>() {
- @Override
- protected void configureFont(JTable table, TableModel model, int column) {
- Font f = new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
- setFont(f);
- }
+ public java.awt.Component getTableCellRendererComponent(
+ docking.widgets.table.GTableCellRenderingData data) {
+ Component component = super.getTableCellRendererComponent(data);
+ component.setFont(Gui.getFont(FONT_ID));
+ return component;
+ };
@Override
public String getFilterString(String t, Settings settings) {
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternEvalTabelModel.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternEvalTabelModel.java
index c0e85191c5..9b835cd00a 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternEvalTabelModel.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternEvalTabelModel.java
@@ -15,14 +15,12 @@
*/
package ghidra.bitpatterns.gui;
-import java.awt.Font;
+import java.awt.Component;
import java.util.List;
-import javax.swing.JTable;
-import javax.swing.table.TableModel;
-
import docking.widgets.table.AbstractDynamicTableColumn;
import docking.widgets.table.TableColumnDescriptor;
+import generic.theme.Gui;
import ghidra.bitpatterns.info.PatternEvalRowObject;
import ghidra.bitpatterns.info.PatternMatchType;
import ghidra.docking.settings.Settings;
@@ -37,7 +35,7 @@ import ghidra.util.table.column.GColumnRenderer;
import ghidra.util.task.TaskMonitor;
public class PatternEvalTabelModel extends AddressBasedTableModel<PatternEvalRowObject> {
- private static final int MONOSPACE_FONT_SIZE = 14;
+ protected static final String FONT_ID = "font.bytepatterns.table";
private List<PatternEvalRowObject> rowObjects;
/**
@@ -62,10 +60,11 @@ public class PatternEvalTabelModel extends AddressBasedTableModel<PatternEvalRow
protected final GColumnRenderer<String> monospacedRenderer =
new AbstractGColumnRenderer<String>() {
@Override
- protected void configureFont(JTable table, TableModel model, int column) {
- Font f =
- new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
- setFont(f);
+ public java.awt.Component getTableCellRendererComponent(
+ docking.widgets.table.GTableCellRenderingData data) {
+ Component component = super.getTableCellRendererComponent(data);
+ component.setFont(Gui.getFont(FONT_ID));
+ return component;
}
@Override
diff --git a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternInfoTableModel.java b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternInfoTableModel.java
index 440c040715..51720e1cd3 100644
--- a/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternInfoTableModel.java
+++ b/Ghidra/Features/BytePatterns/src/main/java/ghidra/bitpatterns/gui/PatternInfoTableModel.java
@@ -15,14 +15,12 @@
*/
package ghidra.bitpatterns.gui;
-import java.awt.Font;
-
-import javax.swing.JTable;
-import javax.swing.table.TableModel;
+import java.awt.Component;
import docking.widgets.table.AbstractDynamicTableColumn;
import docking.widgets.table.TableColumnDescriptor;
import docking.widgets.table.threaded.ThreadedTableModelStub;
+import generic.theme.Gui;
import ghidra.bitpatterns.info.PatternType;
import ghidra.docking.settings.Settings;
import ghidra.framework.plugintool.ServiceProvider;
@@ -42,7 +40,7 @@ public class PatternInfoTableModel extends ThreadedTableModelStub<PatternInfoRow
private FunctionBitPatternsExplorerPlugin plugin;
private static final int NOTE_COLUMN = 2;
private static final int ALIGNMENT_COLUMN = 5;
- private static final int MONOSPACE_FONT_SIZE = 14;
+ protected static final String FONT_ID = "font.bytepatterns.table";
public PatternInfoTableModel(FunctionBitPatternsExplorerPlugin plugin) {
super(MODEL_NAME, plugin.getTool());
@@ -56,10 +54,11 @@ public class PatternInfoTableModel extends ThreadedTableModelStub<PatternInfoRow
}
protected GColumnRenderer<String> monospacedRenderer = new AbstractGColumnRenderer<String>() {
- @Override
- protected void configureFont(JTable table, TableModel model, int column) {
- Font f = new Font("monospaced", getFixedWidthFont().getStyle(), MONOSPACE_FONT_SIZE);
- setFont(f);
+ public Component getTableCellRendererComponent(
+ docking.widgets.table.GTableCellRenderingData data) {
+ Component component = super.getTableCellRendererComponent(data);
+ component.setFont(Gui.getFont(FONT_ID));
+ return component;
}
@Override
diff --git a/Ghidra/Features/ByteViewer/data/byteviewer.theme.properties b/Ghidra/Features/ByteViewer/data/byteviewer.theme.properties
index 4597060c40..33410878cf 100644
--- a/Ghidra/Features/ByteViewer/data/byteviewer.theme.properties
+++ b/Ghidra/Features/ByteViewer/data/byteviewer.theme.properties
@@ -3,15 +3,17 @@
color.bg.byteviewer = color.bg
color.bg.byteviewer.highlight = yellow
-color.fg.byteviewer.novalue = blue
+color.fg.byteviewer.separator = blue
color.fg.byteviewer.changed = red
-color.cursor.focused.byteviewer.current = color.cursor.focused
-color.cursor.focused.byteviewer.noncurrent = black
-color.cursor.unfocused.byteviewer = color.cursor.unfocused
+color.cursor.byteviewer.focused.active = color.cursor.focused
+color.cursor.byteviewer.focused.not.active = black
+color.cursor.byteviewer.unfocused = color.cursor.unfocused
icon.plugin.byteviewer.provider = binaryData.gif
icon.plugin.byteviewer.options = wrench.png
-
+font.byteviewer = font.monospaced
+font.byteviewer.header = SansSerif-PLAIN-11
+font.byteviewer.status = SansSerif-PLAIN-11
[Dark Defaults]
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java
index b798f81677..3f8ecca425 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponent.java
@@ -730,9 +730,9 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
createFields();
setCursorOn(true);
- editColor = ByteViewerComponentProvider.DEFAULT_EDIT_COLOR;
- currentCursorColor = ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR;
- setNonFocusCursorColor(ByteViewerComponentProvider.DEFAULT_NONFOCUS_CURSOR_COLOR);
+ editColor = ByteViewerComponentProvider.CHANGED_VALUE_COLOR;
+ currentCursorColor = ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR;
+ setNonFocusCursorColor(ByteViewerComponentProvider.CURSOR_NOT_FOCUSED_COLOR);
setFocusedCursorColor(currentCursorColor);
updateColorRunner = () -> updateColor();
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java
index c0d44ae871..fca9079b14 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerComponentProvider.java
@@ -25,8 +25,7 @@ import java.util.List;
import javax.swing.JComponent;
import docking.action.ToggleDockingAction;
-import generic.theme.GColor;
-import generic.theme.GIcon;
+import generic.theme.*;
import ghidra.GhidraOptions;
import ghidra.GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES;
import ghidra.app.plugin.core.format.*;
@@ -54,42 +53,40 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
private static final String OFFSET_NAME = "Offset";
static final int DEFAULT_NUMBER_OF_CHARS = 8;
- static final Font DEFAULT_FONT = new Font("Monospaced", Font.PLAIN, 12);
+ static final String DEFAULT_FONT_ID = "font.byteviewer";
static final int DEFAULT_BYTES_PER_LINE = 16;
//@formatter:off
static final String FG = "byteviewer.color.fg";
static final String CURSOR = "byteviewer.color.cursor";
- static final Color DEFAULT_MISSING_VALUE_COLOR = new GColor("color.fg.byteviewer.novalue");
- static final Color DEFAULT_EDIT_COLOR = new GColor("color.fg.byteviewer.changed");
- static final Color DEFAULT_CURRENT_CURSOR_COLOR = new GColor("color.cursor.focused.byteviewer.current");
- static final Color DEFAULT_CURSOR_COLOR = new GColor("color.cursor.focused.byteviewer.noncurrent");
- static final Color DEFAULT_NONFOCUS_CURSOR_COLOR = new GColor("color.cursor.unfocused.byteviewer");
+
+ static final Color SEPARATOR_COLOR = new GColor("color.fg.byteviewer.separator");
+ static final Color CHANGED_VALUE_COLOR = new GColor("color.fg.byteviewer.changed");
+ static final Color CURSOR_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.active");
+ static final Color CURSOR_NON_ACTIVE_COLOR = new GColor("color.cursor.byteviewer.focused.not.active");
+ static final Color CURSOR_NOT_FOCUSED_COLOR = new GColor("color.cursor.byteviewer.unfocused");
+
+ static final Color CURRENT_LINE_COLOR = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;
//@formatter:on
- private static final Color DEFAULT_CURSOR_LINE_COLOR = GhidraOptions.DEFAULT_CURSOR_LINE_COLOR;
-
static final String DEFAULT_INDEX_NAME = "Addresses";
- static final String OPTION_EDIT_COLOR = "Edit Cursor Color";
- static final String OPTION_SEPARATOR_COLOR = "Block Separator Color";
- static final String OPTION_CURRENT_VIEW_CURSOR_COLOR = "Current View Cursor Color";
- static final String OPTION_CURSOR_COLOR = "Cursor Color";
+ static final String SEPARATOR_COLOR_OPTION_NAME = "Block Separator Color";
+ static final String CHANGED_VALUE_COLOR_OPTION_NAME = "Changed Values Color";
+ static final String CURSOR_ACTIVE_COLOR_OPTION_NAME = "Active Cursor Color";
+ static final String CURSOR_NON_ACTIVE_COLOR_OPTION_NAME = "Non-Active Cursor Color";
+ static final String CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME = "Non-Focused Cursor Color";
+
static final String OPTION_FONT = "Font";
- static final String OPTION_NONFOCUS_CURSOR_COLOR = "Non-Focus Cursor Color";
private static final String DEFAULT_VIEW = "Hex";
- private static final String OPTION_CURRENT_LINE_COLOR =
+ private static final String CURRENT_LINE_COLOR_OPTION_NAME =
GhidraOptions.HIGHLIGHT_CURSOR_LINE_COLOR_OPTION_NAME;
private static final String OPTION_HIGHLIGHT_CURSOR_LINE =
GhidraOptions.HIGHLIGHT_CURSOR_LINE_OPTION_NAME;
protected ByteViewerPanel panel;
- private Color editColor;
- private Color currentCursorColor;
- private Color defaultCursorColor;
-
private int bytesPerLine;
private int offset;
private int hexGroupSize = 1;
@@ -174,26 +171,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
if (options.getName().equals("ByteViewer")) {
-
- if (optionName.equals(OPTION_CURRENT_VIEW_CURSOR_COLOR)) {
- panel.setCurrentCursorColor((Color) newValue);
- }
- else if (optionName.equals(OPTION_CURSOR_COLOR)) {
- panel.setCursorColor((Color) newValue);
- }
- else if (optionName.equals(OPTION_CURRENT_LINE_COLOR)) {
- panel.setCurrentCursorLineColor((Color) newValue);
- }
- else if (optionName.equals(OPTION_EDIT_COLOR)) {
- panel.setEditColor((Color) newValue);
- }
- else if (optionName.equals(OPTION_SEPARATOR_COLOR)) {
- panel.setSeparatorColor((Color) newValue);
- }
- else if (optionName.equals(OPTION_NONFOCUS_CURSOR_COLOR)) {
- panel.setNonFocusCursorColor((Color) newValue);
- }
- else if (optionName.equals(OPTION_FONT)) {
+ if (optionName.equals(OPTION_FONT)) {
setFont(SystemUtilities.adjustForFontSizeOverride((Font) newValue));
}
}
@@ -220,48 +198,45 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
HelpLocation help = new HelpLocation("ByteViewerPlugin", "Option");
opt.setOptionsHelpLocation(help);
- opt.registerOption(OPTION_SEPARATOR_COLOR, DEFAULT_MISSING_VALUE_COLOR, help,
+ opt.registerOption(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR, help,
"Color used for separator shown between memory blocks.");
- opt.registerOption(OPTION_SEPARATOR_COLOR, DEFAULT_MISSING_VALUE_COLOR, help,
- "Color used for separator shown between memory blocks.");
- opt.registerOption(OPTION_EDIT_COLOR, DEFAULT_EDIT_COLOR,
+
+ opt.registerOption(CHANGED_VALUE_COLOR_OPTION_NAME, CHANGED_VALUE_COLOR,
new HelpLocation("ByteViewerPlugin", "EditColor"),
- "Color of cursor when the current view is in edit mode and can support editing.");
- opt.registerOption(OPTION_CURRENT_VIEW_CURSOR_COLOR, DEFAULT_CURRENT_CURSOR_COLOR, help,
- "Color of cursor when it is in the current view.");
- opt.registerOption(OPTION_NONFOCUS_CURSOR_COLOR, DEFAULT_NONFOCUS_CURSOR_COLOR, help,
- "Color of cursor when it is not the current view.");
- opt.registerOption(OPTION_CURSOR_COLOR, DEFAULT_CURSOR_COLOR, help,
- "Color of cursor for other views other than the current view.");
- opt.registerOption(OPTION_FONT, DEFAULT_FONT, help, "Font used in the views.");
- opt.registerOption(OPTION_CURRENT_LINE_COLOR, DEFAULT_CURSOR_LINE_COLOR, help,
+ "Color of changed bytes when editing.");
+
+ opt.registerOption(CURSOR_ACTIVE_COLOR_OPTION_NAME, CURSOR_ACTIVE_COLOR,
+ help, "Color of cursor in the active view.");
+
+ opt.registerOption(CURSOR_NON_ACTIVE_COLOR_OPTION_NAME,
+ CURSOR_NON_ACTIVE_COLOR,
+ help, "Color of cursor in the non-active views.");
+
+ opt.registerOption(CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME,
+ CURSOR_NOT_FOCUSED_COLOR,
+ help, "Color of cursor when the byteview does not have focus.");
+
+ opt.registerOption(CURRENT_LINE_COLOR_OPTION_NAME,
+ GhidraOptions.DEFAULT_CURSOR_LINE_COLOR, help,
"Color of the line containing the cursor");
+
+ opt.registerOption(OPTION_FONT, OptionType.FONT_TYPE, DEFAULT_FONT_ID, help,
+ "Font used in the views.");
opt.registerOption(OPTION_HIGHLIGHT_CURSOR_LINE, true, help,
"Toggles highlighting background color of line containing the cursor");
- Color missingValueColor = opt.getColor(OPTION_SEPARATOR_COLOR, DEFAULT_MISSING_VALUE_COLOR);
+ Color missingValueColor = opt.getColor(SEPARATOR_COLOR_OPTION_NAME, SEPARATOR_COLOR);
panel.setSeparatorColor(missingValueColor);
- editColor = opt.getColor(OPTION_EDIT_COLOR, DEFAULT_EDIT_COLOR);
- currentCursorColor =
- opt.getColor(OPTION_CURRENT_VIEW_CURSOR_COLOR, DEFAULT_CURRENT_CURSOR_COLOR);
- panel.setCurrentCursorColor(currentCursorColor);
-
- Color nonFocusCursorColor =
- opt.getColor(OPTION_NONFOCUS_CURSOR_COLOR, DEFAULT_NONFOCUS_CURSOR_COLOR);
- panel.setNonFocusCursorColor(nonFocusCursorColor);
-
- defaultCursorColor = opt.getColor(OPTION_CURSOR_COLOR, DEFAULT_CURSOR_COLOR);
- panel.setCursorColor(defaultCursorColor);
-
- Color cursorLineColor = opt.getColor(OPTION_CURRENT_LINE_COLOR, DEFAULT_CURSOR_LINE_COLOR);
- panel.setCurrentCursorLineColor(cursorLineColor);
+ panel.setCurrentCursorColor(CURSOR_ACTIVE_COLOR);
+ panel.setNonFocusCursorColor(CURSOR_NOT_FOCUSED_COLOR);
+ panel.setCursorColor(CURSOR_NON_ACTIVE_COLOR);
+ panel.setCurrentCursorLineColor(CURRENT_LINE_COLOR);
- Font font =
- SystemUtilities.adjustForFontSizeOverride(opt.getFont(OPTION_FONT, DEFAULT_FONT));
+ Font font = Gui.getFont(DEFAULT_FONT_ID);
FontMetrics fm = panel.getFontMetrics(font);
- panel.restoreConfigState(fm, editColor);
+ panel.restoreConfigState(fm, CHANGED_VALUE_COLOR);
opt.addOptionsChangeListener(this);
@@ -279,6 +254,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
/**
* Set the offset that is applied to each block.
+ * @param blockOffset the new block offset
*/
void setBlockOffset(int blockOffset) {
if (blockOffset == offset) {
@@ -311,6 +287,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
/**
* Get the number of bytes displayed in a line.
+ * @return the number of bytes displayed in a line
*/
int getBytesPerLine() {
return bytesPerLine;
@@ -318,13 +295,14 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
/**
* Get the offset that should be applied to each byte block.
+ * @return the offset that should be applied to each byte block
*/
int getOffset() {
return offset;
}
Color getCursorColor() {
- return defaultCursorColor;
+ return CURSOR_NON_ACTIVE_COLOR;
}
int getGroupSize() {
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHeader.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHeader.java
index 06c7577c6a..a3b15b5438 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHeader.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerHeader.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +15,6 @@
*/
package ghidra.app.plugin.core.byteviewer;
-import ghidra.util.table.GhidraTable;
-
import java.awt.*;
import java.util.HashMap;
import java.util.Iterator;
@@ -26,6 +23,9 @@ import javax.swing.*;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.*;
+import generic.theme.Gui;
+import ghidra.util.table.GhidraTable;
+
/**
* JTableHeader that uses the default table column model to manage
* TableColumns. Sizes the column according to its corresponding viewer
@@ -33,6 +33,7 @@ import javax.swing.table.*;
*/
class ByteViewerHeader extends JTableHeader implements Scrollable {
+ private static final String FONT_ID = "font.byteviewer.header";
private TableColumnModel columnModel;
private Component container;
@@ -50,8 +51,7 @@ class ByteViewerHeader extends JTableHeader implements Scrollable {
this.container = container;
components = new HashMap<Component, TableColumn>();
- Font font = new Font("Tahoma", Font.PLAIN, 11);
- setFont(font);
+ Gui.registerFont(this, FONT_ID);
setResizingAllowed(false);
table = new GhidraTable();
setTable(table);
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java
index 84bc547ca6..15285f732c 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPanel.java
@@ -32,6 +32,7 @@ import docking.widgets.indexedscrollpane.*;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel;
import generic.theme.GColor;
+import generic.theme.Gui;
import ghidra.app.plugin.core.format.*;
import ghidra.app.util.viewer.listingpanel.AddressSetDisplayListener;
import ghidra.program.model.address.AddressSet;
@@ -45,11 +46,12 @@ import help.Help;
import help.HelpService;
/**
- * Top level component that contains has a scrolled pane for the panel of components that show the
+ * Top level component that has a scrolled pane for the panel of components that show the
* view for each format.
*/
public class ByteViewerPanel extends JPanel
implements TableColumnModelListener, LayoutModel, LayoutListener {
+ private static final String FONT_STATUS_ID = "font.byteviewer.status";
// private ByteViewerPlugin plugin;
private List<ByteViewerComponent> viewList; // list of field viewers
private FieldPanel indexPanel; // panel for showing indexes
@@ -94,7 +96,7 @@ public class ByteViewerPanel extends JPanel
viewList = new ArrayList<>();
indexMap = new IndexMap();
create();
- editColor = ByteViewerComponentProvider.DEFAULT_EDIT_COLOR;
+ editColor = ByteViewerComponentProvider.CHANGED_VALUE_COLOR;
}
/**
@@ -812,7 +814,7 @@ public class ByteViewerPanel extends JPanel
columnHeader = new ByteViewerHeader(this);
- fm = getFontMetrics(ByteViewerComponentProvider.DEFAULT_FONT);
+ fm = getFontMetrics(Gui.getFont(ByteViewerComponentProvider.DEFAULT_FONT_ID));
fontHeight = fm.getHeight();
// for the index/address column
@@ -864,15 +866,14 @@ public class ByteViewerPanel extends JPanel
insertionField = new GDLabel("00000000");
insertionField.setName("Insertion");
- Font f = new Font("SansSerif", Font.PLAIN, 11);
- startLabel.setFont(f);
- endLabel.setFont(f);
- offsetLabel.setFont(f);
- insertionLabel.setFont(f);
- startField.setFont(f);
- endField.setFont(f);
- offsetField.setFont(f);
- insertionField.setFont(f);
+ Gui.registerFont(startLabel, FONT_STATUS_ID);
+ Gui.registerFont(endLabel, FONT_STATUS_ID);
+ Gui.registerFont(offsetLabel, FONT_STATUS_ID);
+ Gui.registerFont(insertionLabel, FONT_STATUS_ID);
+ Gui.registerFont(startField, FONT_STATUS_ID);
+ Gui.registerFont(endField, FONT_STATUS_ID);
+ Gui.registerFont(offsetField, FONT_STATUS_ID);
+ Gui.registerFont(insertionField, FONT_STATUS_ID);
// make a panel for each label/value pair
JPanel p1 = new JPanel(new PairLayout(0, 5));
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java
index 81ed547bfb..622ebf3ca6 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/FieldFactory.java
@@ -61,8 +61,8 @@ class FieldFactory {
this.highlightFactory = new SimpleHighlightFactory(highlightProvider);
charWidth = fm.charWidth('W');
width = charWidth * model.getDataUnitSymbolSize();
- editColor = ByteViewerComponentProvider.DEFAULT_EDIT_COLOR;
- separatorColor = ByteViewerComponentProvider.DEFAULT_MISSING_VALUE_COLOR;
+ editColor = ByteViewerComponentProvider.CHANGED_VALUE_COLOR;
+ separatorColor = ByteViewerComponentProvider.SEPARATOR_COLOR;
unitByteSize = model.getUnitByteSize();
}
diff --git a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java
index cb7ae28d6c..a2e94b586a 100644
--- a/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java
+++ b/Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/IndexFieldFactory.java
@@ -48,7 +48,7 @@ class IndexFieldFactory {
charWidth = fm.charWidth('W');
width = ByteViewerComponentProvider.DEFAULT_NUMBER_OF_CHARS * charWidth;
- missingValueColor = ByteViewerComponentProvider.DEFAULT_MISSING_VALUE_COLOR;
+ missingValueColor = ByteViewerComponentProvider.SEPARATOR_COLOR;
}
/**
diff --git a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerConnectedToolBehaviorTest.java b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerConnectedToolBehaviorTest.java
index 55433aacda..771f573696 100644
--- a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerConnectedToolBehaviorTest.java
+++ b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerConnectedToolBehaviorTest.java
@@ -157,7 +157,8 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
});
assertTrue(action.isSelected());
final ByteViewerComponent c = panelOne.getCurrentComponent();
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR,
+ c.getFocusedCursorColor());
runSwing(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
@@ -167,7 +168,7 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
ByteViewerComponent c2 = panel2.getCurrentComponent();
ByteField f2 = c2.getField(BigInteger.ZERO, 0);
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, f2.getForeground());
+ assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR, f2.getForeground());
}
@Test
@@ -188,7 +189,8 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
});
assertTrue(action.isSelected());
final ByteViewerComponent c = panelOne.getCurrentComponent();
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR,
+ c.getFocusedCursorColor());
runSwing(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
c.keyPressed(ev, loc.getIndex(), loc.getFieldNum(), loc.getRow(), loc.getCol(),
@@ -198,7 +200,7 @@ public class ByteViewerConnectedToolBehaviorTest extends AbstractGhidraHeadedInt
ByteViewerComponent c2 = panel2.getCurrentComponent();
ByteField f2 = c2.getField(BigInteger.ZERO, 0);
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, f2.getForeground());
+ assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR, f2.getForeground());
undo(program);
diff --git a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java
index dc98e794e5..00a5fe6d49 100644
--- a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java
+++ b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin2Test.java
@@ -148,7 +148,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
});
assertTrue(action.isSelected());
final ByteViewerComponent c = panel.getCurrentComponent();
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
SwingUtilities.invokeAndWait(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_A, 'a');
@@ -157,7 +157,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
});
program.flushEvents();
assertEquals((byte) 0xa0, program.getMemory().getByte(getAddr(0x01001000)));
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR,
((ByteField) c.getCurrentField()).getForeground());
SwingUtilities.invokeAndWait(() -> {
@@ -165,7 +165,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
action.actionPerformed(new ActionContext());
});
assertTrue(!action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
c.getFocusedCursorColor());
}
@@ -192,7 +192,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
});
assertTrue(action.isSelected());
final ByteViewerComponent c = panel.getCurrentComponent();
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
SwingUtilities.invokeAndWait(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_A, 'a');
@@ -205,7 +205,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals(b, program.getMemory().getByte(addr));
Color fg = ((ByteField) c.getCurrentField()).getForeground();
if (fg != null) {
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR, fg);
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR, fg);
}
Window w = windowForComponent(plugin.getProvider().getComponent());
String str = findLabelStr(w, "Tool Status");
@@ -251,7 +251,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals((byte) 0xa0, program.getMemory().getByte(addr));
FieldLocation loc = getFieldLocation(addr);
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
}
@@ -296,21 +296,21 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals((byte) 0xa0, program.getMemory().getByte(addr));
FieldLocation loc = getFieldLocation(addr);
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
final ByteViewerComponent asciiC = findComponent(panel, "Ascii");
SwingUtilities.invokeAndWait(() -> panel.setCurrentView(asciiC));
loc = getFieldLocation(addr);
field = asciiC.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
final ByteViewerComponent hexIntC = findComponent(panel, "HexInteger");
SwingUtilities.invokeAndWait(() -> panel.setCurrentView(hexIntC));
loc = getFieldLocation(addr);
field = asciiC.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
}
@Test
@@ -346,7 +346,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
Color fg = field.getForeground();
assertTrue(fg == null ||
- ByteViewerComponentProvider.DEFAULT_CURSOR_COLOR == field.getForeground());
+ ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
redo(program);
program.flushEvents();
@@ -354,7 +354,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
// field color should show edit color
loc = getFieldLocation(addr);
field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
}
@@ -404,19 +404,19 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
FieldLocation loc2 = new FieldLocation(0, 1, 0, 0); // second byte on first line
undo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
- testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
+ testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
undo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
- testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
+ testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
undo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
testFieldColor(loc2, null);
undo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
testFieldColor(loc2, null);
undo(program);
@@ -425,24 +425,24 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
assertTrue(!program.canUndo());
redo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
testFieldColor(loc2, null);
redo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
testFieldColor(loc2, null);
redo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
- testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
+ testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
redo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
- testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
+ testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
redo(program);
- testFieldColor(loc1, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
- testFieldColor(loc2, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ testFieldColor(loc1, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
+ testFieldColor(loc2, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
assertTrue(program.canUndo());
}
@@ -493,14 +493,14 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
Color fg = field.getForeground();
assertTrue(fg == null ||
- ByteViewerComponentProvider.DEFAULT_CURSOR_COLOR == field.getForeground());
+ ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
redo(program);
// field color should show edit color
loc = getFieldLocation(addr);
field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
}
@@ -558,10 +558,10 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Color fg = field.getForeground();
if (i == 4) {
assertTrue(fg == null ||
- ByteViewerComponentProvider.DEFAULT_CURSOR_COLOR == field.getForeground());
+ ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR == field.getForeground());
}
else {
- assertEquals(fg, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ assertEquals(fg, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
}
}
assertTrue(!program.canUndo());
@@ -573,7 +573,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
FieldLocation loc = c.getCursorLocation();
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
Color fg = field.getForeground();
- assertEquals(fg, ByteViewerComponentProvider.DEFAULT_EDIT_COLOR);
+ assertEquals(fg, ByteViewerComponentProvider.CHANGED_VALUE_COLOR);
}
assertTrue(program.canUndo());
@@ -593,7 +593,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
});
assertTrue(action.isSelected());
final ByteViewerComponent c = panel.getCurrentComponent();
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
byte value = program.getMemory().getByte(getAddr(0x01001000));
SwingUtilities.invokeAndWait(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_P, 'p');
@@ -623,7 +623,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
});
waitForPostedSwingRunnables();
assertTrue(action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
SwingUtilities.invokeAndWait(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_Z, 'z');
@@ -634,14 +634,14 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Address addr = getAddr(0x01001000);
assertEquals((byte) 0x7a, program.getMemory().getByte(addr));
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
SwingUtilities.invokeAndWait(() -> {
action.setSelected(false);
action.actionPerformed(new ActionContext());
});
assertTrue(!action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
c.getFocusedCursorColor());
}
@@ -663,7 +663,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
action.actionPerformed(new ActionContext());
});
assertTrue(action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
SwingUtilities.invokeAndWait(() -> {
FieldLocation loc = getFieldLocation(addr);
@@ -676,14 +676,14 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
assertEquals((byte) 0x40, program.getMemory().getByte(addr));
FieldLocation loc = getFieldLocation(addr);
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
SwingUtilities.invokeAndWait(() -> {
action.setSelected(false);
action.actionPerformed(new ActionContext());
});
assertTrue(!action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
c.getFocusedCursorColor());
}
@@ -705,7 +705,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
action.actionPerformed(new ActionContext());
});
assertTrue(action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
byte value = program.getMemory().getByte(getAddr(0x01001000));
SwingUtilities.invokeAndWait(() -> {
@@ -735,7 +735,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
action.actionPerformed(new ActionContext());
});
assertTrue(action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, c.getFocusedCursorColor());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, c.getFocusedCursorColor());
SwingUtilities.invokeAndWait(() -> {
KeyEvent ev = new KeyEvent(c, 0, new Date().getTime(), 0, KeyEvent.VK_1, '1');
@@ -744,7 +744,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
});
program.flushEvents();
assertEquals((byte) 0x10, program.getMemory().getByte(getAddr(0x01001003)));
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR,
((ByteField) c.getCurrentField()).getForeground());
SwingUtilities.invokeAndWait(() -> {
@@ -752,7 +752,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
action.actionPerformed(new ActionContext());
});
assertTrue(!action.isSelected());
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR,
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR,
c.getFocusedCursorColor());
}
@@ -802,7 +802,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
// verify that the bytes are rendered in red
FieldLocation loc = getFieldLocation(addr);
ByteField field = c.getField(loc.getIndex(), loc.getFieldNum());
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR, field.getForeground());
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR, field.getForeground());
addr = addr.add(i);
}
}
@@ -1216,7 +1216,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Options opt = tool.getOptions("ByteViewer");
// change the color for Current View Cursor Color
- putColor(opt, ByteViewerComponentProvider.OPTION_CURRENT_VIEW_CURSOR_COLOR, Palette.GREEN);
+ putColor(opt, ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR_OPTION_NAME, Palette.GREEN);
ByteViewerComponent c = panel.getCurrentComponent();
assertEquals(Palette.GREEN, c.getFocusedCursorColor());
@@ -1236,7 +1236,8 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Options opt = tool.getOptions("ByteViewer");
// change the color for Current View Cursor Color
- putColor(opt, ByteViewerComponentProvider.OPTION_CURSOR_COLOR, Palette.GREEN);
+ putColor(opt, ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR_OPTION_NAME,
+ Palette.GREEN);
ByteViewerComponent c = findComponent(panel, "Octal");
assertEquals(Palette.GREEN, c.getNonFocusCursorColor());
@@ -1255,7 +1256,8 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Options opt = tool.getOptions("ByteViewer");
// change the color for Current View Cursor Color
- putColor(opt, ByteViewerComponentProvider.OPTION_NONFOCUS_CURSOR_COLOR, Palette.CYAN);
+ putColor(opt, ByteViewerComponentProvider.CURSOR_NOT_FOCUSED_COLOR_OPTION_NAME,
+ Palette.CYAN);
ByteViewerComponent c = findComponent(panel, "Octal");
assertEquals(Palette.CYAN, c.getNonFocusCursorColor());
@@ -1283,7 +1285,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Options opt = tool.getOptions("ByteViewer");
// change the color for Edit Color
- putColor(opt, ByteViewerComponentProvider.OPTION_EDIT_COLOR, Palette.GREEN);
+ putColor(opt, ByteViewerComponentProvider.CHANGED_VALUE_COLOR_OPTION_NAME, Palette.GREEN);
final FieldLocation loc = getFieldLocation(getAddr(0x01001000));
SwingUtilities.invokeAndWait(() -> {
@@ -1341,7 +1343,7 @@ public class ByteViewerPlugin2Test extends AbstractGhidraHeadedIntegrationTest {
Options opt = tool.getOptions("ByteViewer");
// change the color for block separator
- putColor(opt, ByteViewerComponentProvider.OPTION_SEPARATOR_COLOR, Palette.GREEN);
+ putColor(opt, ByteViewerComponentProvider.SEPARATOR_COLOR_OPTION_NAME, Palette.GREEN);
ByteViewerComponent c = panel.getCurrentComponent();
FieldLocation loc = getFieldLocation(getAddr(0x0f001000));
diff --git a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPluginFormatsTest.java b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPluginFormatsTest.java
index cbd4235eaf..5af1ec61a5 100644
--- a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPluginFormatsTest.java
+++ b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerPluginFormatsTest.java
@@ -292,7 +292,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
hexComp.setCursorPosition(l.getIndex(), l.getFieldNum(), 0, 0);
});
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
+ assertEquals(ByteViewerComponentProvider.CHANGED_VALUE_COLOR,
((ByteField) hexComp.getCurrentField()).getForeground());
}
@@ -342,7 +342,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
// does not support editing
Color fg = ((ByteField) c.getCurrentField()).getForeground();
if (fg != null) {
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR, fg);
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR, fg);
}
}
@@ -391,7 +391,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
// does not support editing
Color fg = ((ByteField) c.getCurrentField()).getForeground();
if (fg != null) {
- assertEquals(ByteViewerComponentProvider.DEFAULT_CURRENT_CURSOR_COLOR, fg);
+ assertEquals(ByteViewerComponentProvider.CURSOR_ACTIVE_COLOR, fg);
}
}
@@ -436,7 +436,7 @@ public class ByteViewerPluginFormatsTest extends AbstractGhidraHeadedIntegration
intComp.setCursorPosition(l.getIndex(), l.getFieldNum(), 0, 0);
});
// color should indicate the edit
- assertEquals(ByteViewerComponentProvider.DEFAULT_EDIT_COLOR,
+ assertEquals(ByteViewerComponentProvider.CURSOR_NON_ACTIVE_COLOR,
((ByteField) intComp.getCurrentField()).getForeground());
}
diff --git a/Ghidra/Features/Decompiler/data/decompiler.theme.properties b/Ghidra/Features/Decompiler/data/decompiler.theme.properties
index 1e072fd83c..05bf6e874e 100644
--- a/Ghidra/Features/Decompiler/data/decompiler.theme.properties
+++ b/Ghidra/Features/Decompiler/data/decompiler.theme.properties
@@ -13,7 +13,6 @@ color.fg.decompiler.type = mediumBlue
color.fg.decompiler.parameter = darkMagenta
color.fg.decompiler.global = darkCyan
-color.bg.decompiler.middle.mouse = rgba(255,255,0,.5)
color.bg.decompiler.current.variable = rgba(255,255,0,0.5)
color.fg.line.numbers = gray
@@ -33,13 +32,13 @@ color.bg.decompiler.pcode.dfg.edge.default = navy
color.bg.decompiler.pcode.dfg.edge.selected = deeppink
color.bg.decompiler.pcode.dfg.edge.within.block = black
color.bg.decompiler.pcode.dfg.edge.between.blocks = red
-
+font.decompiler.pcode.dfg = font.graphdisplay.default
icon.decompiler.action.provider = decompileFunction.gif
icon.decompiler.action.provider.clone = icon.provider.clone
icon.decompiler.action.export = page_edit.png
-
+font.decompiler = font.monospaced
[Dark Defaults]
color.fg.decompiler.keyword = peru
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java
index b9f026dab5..98fd46429b 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompileOptions.java
@@ -25,10 +25,11 @@ import java.awt.event.MouseEvent;
import java.io.IOException;
import generic.theme.GColor;
+import generic.theme.Gui;
+import ghidra.GhidraOptions;
import ghidra.GhidraOptions.CURSOR_MOUSE_BUTTON_NAMES;
import ghidra.app.util.HelpTopics;
-import ghidra.framework.options.Options;
-import ghidra.framework.options.ToolOptions;
+import ghidra.framework.options.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.database.ProgramCompilerSpec;
@@ -38,7 +39,6 @@ import ghidra.program.model.listing.Program;
import ghidra.program.model.pcode.ElementId;
import ghidra.program.model.pcode.Encoder;
import ghidra.util.HelpLocation;
-import ghidra.util.SystemUtilities;
/**
* Configuration options for the decompiler
@@ -303,62 +303,57 @@ public class DecompileOptions {
private final static IntegerFormatEnum INTEGERFORMAT_OPTIONDEFAULT = IntegerFormatEnum.BestFit; // Must match PrintLanguage::resetDefaultsInternal
private IntegerFormatEnum integerFormat;
- private final static Color HIGHLIGHT_MIDDLE_MOUSE_DEF = new GColor("color.bg.decompiler.middle.mouse");
- private Color middleMouseHighlightColor;
private int middleMouseHighlightButton = MouseEvent.BUTTON2;
private final static String HIGHLIGHT_CURRENT_VARIABLE_MSG ="Display.Color for Current Variable Highlight";
- private final static Color HIGHLIGHT_CURRENT_VARIABLE_DEF = new GColor("color.bg.decompiler.current.variable");
- private Color currentVariableHighlightColor;
+ private final static Color HIGHLIGHT_CURRENT_VARIABLE_COLOR = new GColor("color.bg.decompiler.current.variable");
private final static String HIGHLIGHT_KEYWORD_MSG = "Display.Color for Keywords";
- private final static Color HIGHLIGHT_KEYWORD_DEF = new GColor("color.fg.decompiler.keyword");
- private Color keywordColor;
+ private final static Color HIGHLIGHT_KEYWORD_COLOR = new GColor("color.fg.decompiler.keyword");
+
private final static String HIGHLIGHT_FUNCTION_MSG = "Display.Color for Function names";
- private final static Color HIGHLIGHT_FUNCTION_DEF = new GColor("color.fg.decompiler.keyword");
- private Color functionColor;
+ private final static Color HIGHLIGHT_FUNCTION_COLOR = new GColor("color.fg.decompiler.function.name");
+
private final static String HIGHLIGHT_COMMENT_MSG = "Display.Color for Comments";
- private final static Color HIGHLIGHT_COMMENT_DEF = new GColor("color.fg.decompiler.comment");
- private Color commentColor;
+ private final static Color HIGHLIGHT_COMMENT_COLOR = new GColor( "color.fg.decompiler.comment");
+
private final static String HIGHLIGHT_VARIABLE_MSG = "Display.Color for Variables";
- private final static Color HIGHLIGHT_VARIABLE_DEF = new GColor( "color.fg.decompiler.variable");
- private Color variableColor;
+ private final static Color HIGHLIGHT_VARIABLE_COLOR = new GColor("color.fg.decompiler.variable");
+
private final static String HIGHLIGHT_CONST_MSG = "Display.Color for Constants";
- private final static Color HIGHLIGHT_CONST_DEF = new GColor( "color.fg.decompiler.constant");
- private Color constantColor;
+ private final static Color HIGHLIGHT_CONST_COLOR = new GColor("color.fg.decompiler.constant");
+
private final static String HIGHLIGHT_TYPE_MSG = "Display.Color for Types";
- private final static Color HIGHLIGHT_TYPE_DEF = new GColor( "color.fg.decompiler.type");
- private Color typeColor;
+ private final static Color HIGHLIGHT_TYPE_COLOR = new GColor("color.fg.decompiler.type");
+
private final static String HIGHLIGHT_PARAMETER_MSG = "Display.Color for Parameters";
- private final static Color HIGHLIGHT_PARAMETER_DEF = new GColor( "color.fg.decompiler.parameter");
- private Color parameterColor;
+ private final static Color HIGHLIGHT_PARAMETER_COLOR = new GColor("color.fg.decompiler.parameter");
+
private final static String HIGHLIGHT_GLOBAL_MSG = "Display.Color for Globals";
- private final static Color HIGHLIGHT_GLOBAL_DEF = new GColor( "color.fg.decompiler.global");
private Color globalColor;
private final static String HIGHLIGHT_SPECIAL_MSG = "Display.Color for Special";
private final static Color HIGHLIGHT_SPECIAL_DEF = Color.decode("0xCC0033");
private Color specialColor;
+ private final static Color HIGHLIGHT_GLOBAL_COLOR = new GColor("color.fg.decompiler.global");
private final static String HIGHLIGHT_DEFAULT_MSG = "Display.Color Default";
- private final static Color HIGHLIGHT_DEFAULT_DEF = new GColor("color.fg.decompiler");
- private Color defaultColor;
- //@formatter:on
+ private final static Color HIGHLIGHT_DEFAULT_COLOR = new GColor("color.fg.decompiler");
+
+ private static final String SEARCH_HIGHLIGHT_MSG = "Display.Color for Highlighting Find Matches";
+ private static final Color SEARCH_HIGHLIGHT_COLOR = new GColor("color.bg.decompiler.highlights.search");
- private static final String CODE_VIEWER_BACKGROUND_COLOR_MSG = "Display.Background Color";
- private static final Color CODE_VIEWER_BACKGROUND_COLOR = new GColor("color.bg.decompiler");
- private Color codeViewerBackgroundColor;
- private static final String SEARCH_HIGHLIGHT_MSG =
- "Display.Color for Highlighting Find Matches";
- private static final Color SEARCH_HIGHLIGHT_DEF =
- new GColor("color.bg.decompiler.highlights.search");
- private Color defaultSearchHighlightColor = SEARCH_HIGHLIGHT_DEF;
+ //@formatter:on
+
+ private static final String BACKGROUND_COLOR_MSG = "Display.Background Color";
+ private static final String BACKGROUND_COLOR_ID = "color.bg.decompiler";
+ private static final Color BACKGROUND_COLOR = new GColor(BACKGROUND_COLOR_ID);
// Color applied to a token to indicate warning/error
private final static Color ERROR_COLOR = new GColor("color.fg.decompiler.comment");
final static String FONT_MSG = "Display.Font";
- final static Font DEFAULT_FONT = new Font(Font.MONOSPACED, Font.PLAIN, 12);
- private Font defaultFont;
+ final static String DEFAULT_FONT_ID = "font.decompiler";
+ private Font font;
private final static String CACHED_RESULTS_SIZE_MSG = "Cache Size (Functions)";
private final static int SUGGESTED_CACHED_RESULTS_SIZE = 10;
@@ -405,6 +400,7 @@ public class DecompileOptions {
commentHeadInclude = COMMENTHEAD_OPTIONDEFAULT;
namespaceStrategy = NAMESPACE_OPTIONDEFAULT;
integerFormat = INTEGERFORMAT_OPTIONDEFAULT;
+<<<<<<< Upstream, based on origin/master
keywordColor = HIGHLIGHT_KEYWORD_DEF;
functionColor = HIGHLIGHT_FUNCTION_DEF;
commentColor = HIGHLIGHT_COMMENT_DEF;
@@ -417,6 +413,8 @@ public class DecompileOptions {
defaultColor = HIGHLIGHT_DEFAULT_DEF;
codeViewerBackgroundColor = CODE_VIEWER_BACKGROUND_COLOR;
defaultFont = DEFAULT_FONT;
+=======
+>>>>>>> 47fa38a GP-1981 converting option colors to theme colors and font usages to theme properties
displayLineNumbers = LINE_NUMBER_DEF;
displayLanguage = ProgramCompilerSpec.DECOMPILER_OUTPUT_DEF;
protoEvalModel = "default";
@@ -469,6 +467,7 @@ public class DecompileOptions {
commentHeadInclude = opt.getBoolean(COMMENTHEAD_OPTIONSTRING, COMMENTHEAD_OPTIONDEFAULT);
namespaceStrategy = opt.getEnum(NAMESPACE_OPTIONSTRING, NAMESPACE_OPTIONDEFAULT);
integerFormat = opt.getEnum(INTEGERFORMAT_OPTIONSTRING, INTEGERFORMAT_OPTIONDEFAULT);
+<<<<<<< Upstream, based on origin/master
keywordColor = opt.getColor(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_DEF);
typeColor = opt.getColor(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_DEF);
functionColor = opt.getColor(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_DEF);
@@ -486,6 +485,8 @@ public class DecompileOptions {
defaultFont = opt.getFont(FONT_MSG, DEFAULT_FONT);
defaultFont = SystemUtilities.adjustForFontSizeOverride(defaultFont);
defaultSearchHighlightColor = opt.getColor(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_DEF);
+=======
+>>>>>>> 47fa38a GP-1981 converting option colors to theme colors and font usages to theme properties
displayLineNumbers = opt.getBoolean(LINE_NUMBER_MSG, LINE_NUMBER_DEF);
decompileTimeoutSeconds = opt.getInt(DECOMPILE_TIMEOUT, SUGGESTED_DECOMPILE_TIMEOUT_SECS);
payloadLimitMBytes = opt.getInt(PAYLOAD_LIMIT, SUGGESTED_MAX_PAYLOAD_BYTES);
@@ -503,9 +504,6 @@ public class DecompileOptions {
PluginTool tool = ownerPlugin.getTool();
Options toolOptions = tool.getOptions(CATEGORY_BROWSER_FIELDS);
- middleMouseHighlightColor =
- toolOptions.getColor(HIGHLIGHT_COLOR_NAME, HIGHLIGHT_MIDDLE_MOUSE_DEF);
-
CURSOR_MOUSE_BUTTON_NAMES mouseEvent =
toolOptions.getEnum(CURSOR_HIGHLIGHT_BUTTON_NAME, CURSOR_MOUSE_BUTTON_NAMES.MIDDLE);
middleMouseHighlightButton = mouseEvent.getMouseEventID();
@@ -622,43 +620,47 @@ public class DecompileOptions {
opt.registerOption(INTEGERFORMAT_OPTIONSTRING, INTEGERFORMAT_OPTIONDEFAULT,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayIntegerFormat"),
INTEGERFORMAT_OPTIONDESCRIPTION);
- opt.registerOption(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_DEF,
+ opt.registerOption(HIGHLIGHT_KEYWORD_MSG, HIGHLIGHT_KEYWORD_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting keywords.");
- opt.registerOption(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_DEF,
+ opt.registerOption(HIGHLIGHT_TYPE_MSG, HIGHLIGHT_TYPE_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting types.");
- opt.registerOption(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_DEF,
+ opt.registerOption(HIGHLIGHT_FUNCTION_MSG, HIGHLIGHT_FUNCTION_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting function names.");
- opt.registerOption(HIGHLIGHT_COMMENT_MSG, HIGHLIGHT_COMMENT_DEF,
+ opt.registerOption(HIGHLIGHT_COMMENT_MSG, HIGHLIGHT_COMMENT_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting comments.");
- opt.registerOption(HIGHLIGHT_VARIABLE_MSG, HIGHLIGHT_VARIABLE_DEF,
+ opt.registerOption(HIGHLIGHT_VARIABLE_MSG, HIGHLIGHT_VARIABLE_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting variables.");
- opt.registerOption(HIGHLIGHT_CONST_MSG, HIGHLIGHT_CONST_DEF,
+ opt.registerOption(HIGHLIGHT_CONST_MSG, HIGHLIGHT_CONST_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting constants.");
- opt.registerOption(HIGHLIGHT_PARAMETER_MSG, HIGHLIGHT_PARAMETER_DEF,
+ opt.registerOption(HIGHLIGHT_PARAMETER_MSG, HIGHLIGHT_PARAMETER_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting parameters.");
- opt.registerOption(HIGHLIGHT_GLOBAL_MSG, HIGHLIGHT_GLOBAL_DEF,
+ opt.registerOption(HIGHLIGHT_GLOBAL_MSG, HIGHLIGHT_GLOBAL_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for highlighting global variables.");
+<<<<<<< Upstream, based on origin/master
opt.registerOption(HIGHLIGHT_SPECIAL_MSG, HIGHLIGHT_SPECIAL_DEF,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayTokenColor"),
"Color used for volatile or other exceptional variables.");
opt.registerOption(HIGHLIGHT_DEFAULT_MSG, HIGHLIGHT_DEFAULT_DEF,
+=======
+ opt.registerOption(HIGHLIGHT_DEFAULT_MSG, HIGHLIGHT_DEFAULT_COLOR,
+>>>>>>> 47fa38a GP-1981 converting option colors to theme colors and font usages to theme properties
new HelpLocation(HelpTopics.DECOMPILER, "DisplayColorDefault"),
"The color used when a specific color is not specified.");
- opt.registerOption(CODE_VIEWER_BACKGROUND_COLOR_MSG, CODE_VIEWER_BACKGROUND_COLOR,
+ opt.registerOption(BACKGROUND_COLOR_MSG, BACKGROUND_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayBackgroundColor"),
"The background color of the decompiler window.");
- opt.registerOption(FONT_MSG, DEFAULT_FONT,
+ opt.registerOption(FONT_MSG, OptionType.FONT_TYPE, DEFAULT_FONT_ID,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayFont"),
"The font used to render text in the decompiler.");
- opt.registerOption(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_DEF,
+ opt.registerOption(SEARCH_HIGHLIGHT_MSG, SEARCH_HIGHLIGHT_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayFindHighlight"),
"The color used to highlight matches using the Find Dialog.");
opt.registerOption(LINE_NUMBER_MSG, LINE_NUMBER_DEF,
@@ -675,7 +677,8 @@ public class DecompileOptions {
opt.registerOption(MAX_INSTRUCTIONS, SUGGESTED_MAX_INSTRUCTIONS,
new HelpLocation(HelpTopics.DECOMPILER, "GeneralMaxInstruction"),
"The maximum number of instructions decompiled in a single function");
- opt.registerOption(HIGHLIGHT_CURRENT_VARIABLE_MSG, HIGHLIGHT_CURRENT_VARIABLE_DEF,
+ opt.registerOption(HIGHLIGHT_CURRENT_VARIABLE_MSG,
+ HIGHLIGHT_CURRENT_VARIABLE_COLOR,
new HelpLocation(HelpTopics.DECOMPILER, "DisplayCurrentHighlight"),
"Current variable highlight");
opt.registerOption(CACHED_RESULTS_SIZE_MSG, SUGGESTED_CACHED_RESULTS_SIZE,
@@ -816,56 +819,56 @@ public class DecompileOptions {
* @return color associated with keyword tokens
*/
public Color getKeywordColor() {
- return keywordColor;
+ return HIGHLIGHT_KEYWORD_COLOR;
}
/**
* @return color associated with data-type tokens
*/
public Color getTypeColor() {
- return typeColor;
+ return HIGHLIGHT_TYPE_COLOR;
}
/**
* @return color associated with a function name token
*/
public Color getFunctionColor() {
- return functionColor;
+ return HIGHLIGHT_FUNCTION_COLOR;
}
/**
* @return color used to display comments
*/
public Color getCommentColor() {
- return commentColor;
+ return HIGHLIGHT_COMMENT_COLOR;
}
/**
* @return color associated with constant tokens
*/
public Color getConstantColor() {
- return constantColor;
+ return HIGHLIGHT_CONST_COLOR;
}
/**
* @return color associated with (local) variable tokens
*/
public Color getVariableColor() {
- return variableColor;
+ return HIGHLIGHT_VARIABLE_COLOR;
}
/**
* @return color associated with parameter tokens
*/
public Color getParameterColor() {
- return parameterColor;
+ return HIGHLIGHT_PARAMETER_COLOR;
}
/**
* @return color associated with global variable tokens
*/
public Color getGlobalColor() {
- return globalColor;
+ return HIGHLIGHT_GLOBAL_COLOR;
}
/**
@@ -879,7 +882,7 @@ public class DecompileOptions {
* @return color for generic syntax or other unspecified tokens
*/
public Color getDefaultColor() {
- return defaultColor;
+ return HIGHLIGHT_DEFAULT_COLOR;
}
/**
@@ -892,29 +895,29 @@ public class DecompileOptions {
/**
* @return the background color for the decompiler window
*/
- public Color getCodeViewerBackgroundColor() {
- return codeViewerBackgroundColor;
+ public Color getBackgroundColor() {
+ return BACKGROUND_COLOR;
}
/**
* @return the color used display the current highlighted variable
*/
public Color getCurrentVariableHighlightColor() {
- return currentVariableHighlightColor;
+ return HIGHLIGHT_CURRENT_VARIABLE_COLOR;
}
/**
* @return color used to highlight token(s) selected with a middle button clock
*/
public Color getMiddleMouseHighlightColor() {
- return middleMouseHighlightColor;
+ return GhidraOptions.DEFAULT_HIGHLIGHT_COLOR;
}
/**
* @return color used to highlight search results
*/
public Color getSearchHighlightColor() {
- return defaultSearchHighlightColor;
+ return SEARCH_HIGHLIGHT_COLOR;
}
public int getMiddleMouseHighlightButton() {
@@ -1014,7 +1017,7 @@ public class DecompileOptions {
}
public Font getDefaultFont() {
- return defaultFont;
+ return Gui.getFont(DEFAULT_FONT_ID);
}
public int getDefaultTimeout() {
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java
index 3093467b74..86fc41927f 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerPanel.java
@@ -118,7 +118,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
layoutController = new ClangLayoutController(options, this, metrics, hlFactory);
fieldPanel = new DecompilerFieldPanel(layoutController);
- setBackground(options.getCodeViewerBackgroundColor());
+ setBackground(options.getBackgroundColor());
scroller = new IndexedScrollPane(fieldPanel);
fieldPanel.addFieldSelectionListener(this);
@@ -522,7 +522,8 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
return;
}
- List<ClangToken> tokens = DecompilerUtils.getTokensFromView(layoutController.getFields(), address);
+ List<ClangToken> tokens =
+ DecompilerUtils.getTokensFromView(layoutController.getFields(), address);
goToBeginningOfLine(tokens);
}
@@ -572,7 +573,8 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
return;
}
- int firstLineNumber = DecompilerUtils.findIndexOfFirstField(tokens, layoutController.getFields());
+ int firstLineNumber =
+ DecompilerUtils.findIndexOfFirstField(tokens, layoutController.getFields());
if (firstLineNumber != -1) {
fieldPanel.goTo(BigInteger.valueOf(firstLineNumber), 0, 0, 0, false);
}
@@ -631,7 +633,8 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
fieldSelection = new FieldSelection();
}
else {
- List<ClangToken> tokens = DecompilerUtils.getTokens(layoutController.getRoot(), selection);
+ List<ClangToken> tokens =
+ DecompilerUtils.getTokens(layoutController.getRoot(), selection);
fieldSelection = DecompilerUtils.getFieldSelection(tokens);
}
fieldPanel.setSelection(fieldSelection);
@@ -1161,7 +1164,7 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
}
public void optionsChanged(DecompileOptions decompilerOptions) {
- setBackground(decompilerOptions.getCodeViewerBackgroundColor());
+ setBackground(decompilerOptions.getBackgroundColor());
currentVariableHighlightColor = options.getCurrentVariableHighlightColor();
middleMouseHighlightColor = decompilerOptions.getMiddleMouseHighlightColor();
middleMouseHighlightButton = decompilerOptions.getMiddleMouseHighlightButton();
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/PCodeDfgDisplayOptions.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/PCodeDfgDisplayOptions.java
index 55c6125508..d01ba7b102 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/PCodeDfgDisplayOptions.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/PCodeDfgDisplayOptions.java
@@ -18,9 +18,6 @@ package ghidra.app.plugin.core.decompile.actions;
import static ghidra.app.plugin.core.decompile.actions.PCodeDfgGraphType.*;
import static ghidra.service.graph.VertexShape.*;
-import java.awt.Color;
-
-import generic.theme.GColor;
import ghidra.framework.plugintool.PluginTool;
import ghidra.service.graph.*;
@@ -30,31 +27,21 @@ import ghidra.service.graph.*;
public class PCodeDfgDisplayOptions extends GraphDisplayOptions {
public static final String SHAPE_ATTRIBUTE = "Shape";
- private static final Color BG_VERTEX_DEFAULT =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.default");
- private static final Color BG_VERTEX_SELECTED =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.selected");
- private static final Color BG_VERTEX_CONSTANT =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.constant");
- private static final Color BG_VERTEX_REGISTER =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.register");
- private static final Color BG_VERTEX_UNIQUE =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.unique");
- private static final Color BG_VERTEX_PERSISTENT =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.persistent");
- private static final Color BG_VERTEX_ADDRESS_TIED =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.address.tied");
- private static final Color BG_VERTEX_OP =
- new GColor("color.bg.decompiler.pcode.dfg.vertex.op");
+ // @formatter:off
+ private static final String BG_VERTEX_DEFAULT = "color.bg.decompiler.pcode.dfg.vertex.default";
+ private static final String BG_VERTEX_SELECTED ="color.bg.decompiler.pcode.dfg.vertex.selected";
+ private static final String BG_VERTEX_CONSTANT ="color.bg.decompiler.pcode.dfg.vertex.constant";
+ private static final String BG_VERTEX_REGISTER ="color.bg.decompiler.pcode.dfg.vertex.register";
+ private static final String BG_VERTEX_UNIQUE ="color.bg.decompiler.pcode.dfg.vertex.unique";
+ private static final String BG_VERTEX_PERSISTENT ="color.bg.decompiler.pcode.dfg.vertex.persistent";
+ private static final String BG_VERTEX_ADDRESS_TIED ="color.bg.decompiler.pcode.dfg.vertex.address.tied";
+ private static final String BG_VERTEX_OP ="color.bg.decompiler.pcode.dfg.vertex.op";
- private static final Color BG_EDGE_DEFAULT =
- new GColor("color.bg.decompiler.pcode.dfg.edge.default");
- private static final Color BG_EDGE_SELECTED =
- new GColor("color.bg.decompiler.pcode.dfg.edge.selected");
- private static final Color BG_EDGE_WITHIN_BLOCK =
- new GColor("color.bg.decompiler.pcode.dfg.edge.within.block");
- private static final Color BG_EDGE_BETWEEN_BLOCKS =
- new GColor("color.bg.decompiler.pcode.dfg.edge.between.blocks");
+ private static final String BG_EDGE_DEFAULT ="color.bg.decompiler.pcode.dfg.edge.default";
+ private static final String BG_EDGE_SELECTED ="color.bg.decompiler.pcode.dfg.edge.selected";
+ private static final String BG_EDGE_WITHIN_BLOCK ="color.bg.decompiler.pcode.dfg.edge.within.block";
+ private static final String BG_EDGE_BETWEEN_BLOCKS ="color.bg.decompiler.pcode.dfg.edge.between.blocks";
+ // @formatter:on
/**
* constructor
@@ -89,5 +76,7 @@ public class PCodeDfgDisplayOptions extends GraphDisplayOptions {
configureEdgeType(DEFAULT_EDGE, BG_EDGE_DEFAULT);
configureEdgeType(WITHIN_BLOCK, BG_EDGE_WITHIN_BLOCK);
configureEdgeType(BETWEEN_BLOCKS, BG_EDGE_BETWEEN_BLOCKS);
+
+ setFont("font.decompiler.pcode.dfg");
}
}
diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidDebugUtils.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidDebugUtils.java
index 4e3b2e2423..e6a27900f4 100644
--- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidDebugUtils.java
+++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidDebugUtils.java
@@ -15,7 +15,6 @@
*/
package ghidra.feature.fid.debug;
-import java.awt.Font;
import java.util.*;
import javax.swing.*;
@@ -29,7 +28,6 @@ import ghidra.util.NumericUtilities;
* Utility class to handle some debug functions for the FID database.
*/
public class FidDebugUtils {
- public static final Font MONOSPACED_FONT = new Font("monospaced", Font.PLAIN, 12);
/**
* Search the FID system for function records by name substring.
diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidFunctionDebugPanel.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidFunctionDebugPanel.java
index bed86e1b2c..4a9912130b 100644
--- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidFunctionDebugPanel.java
+++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidFunctionDebugPanel.java
@@ -21,6 +21,7 @@ import java.awt.event.ActionListener;
import javax.swing.*;
import docking.widgets.label.GDLabel;
+import generic.theme.Gui;
import ghidra.feature.fid.db.*;
import ghidra.feature.fid.service.FidService;
import ghidra.program.model.lang.LanguageID;
@@ -55,7 +56,7 @@ public class FidFunctionDebugPanel extends JPanel {
JButton button = new JButton(text);
button.addActionListener(listener);
button.setHorizontalAlignment(SwingConstants.LEFT);
- button.setFont(FidDebugUtils.MONOSPACED_FONT);
+ button.setFont(Gui.getFont("font.monospaced"));
add(button);
}
@@ -66,7 +67,7 @@ public class FidFunctionDebugPanel extends JPanel {
private void addLabel(String text) {
JLabel label = new GDLabel(text);
label.setHorizontalAlignment(SwingConstants.LEFT);
- label.setFont(FidDebugUtils.MONOSPACED_FONT);
+ label.setFont(Gui.getFont("font.monospaced"));
add(label);
}
diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchDebugDialog.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchDebugDialog.java
index 817ca11cbe..6792ca0c14 100644
--- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchDebugDialog.java
+++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchDebugDialog.java
@@ -21,6 +21,7 @@ import javax.swing.*;
import docking.DialogComponentProvider;
import docking.widgets.label.GDLabel;
+import generic.theme.Gui;
import ghidra.feature.fid.db.FidFileManager;
import ghidra.feature.fid.db.FidQueryService;
import ghidra.feature.fid.plugin.FidPlugin;
@@ -75,13 +76,13 @@ public class FidSearchDebugDialog extends DialogComponentProvider {
private JLabel getPreparedLabel(String text) {
JLabel label = new GDLabel(text, SwingConstants.RIGHT);
- label.setFont(FidDebugUtils.MONOSPACED_FONT);
+ label.setFont(Gui.getFont("font.monospaced"));
return label;
}
private JTextField getPreparedTextField() {
JTextField textField = new JTextField(25);
- textField.setFont(FidDebugUtils.MONOSPACED_FONT);
+ textField.setFont(Gui.getFont("font.monospaced"));
return textField;
}
diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchResultFrame.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchResultFrame.java
index 2824cb401a..38baae3065 100644
--- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchResultFrame.java
+++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/debug/FidSearchResultFrame.java
@@ -26,6 +26,7 @@ import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import docking.widgets.table.*;
+import generic.theme.Gui;
import ghidra.feature.fid.db.*;
import ghidra.feature.fid.service.FidService;
import ghidra.util.Msg;
@@ -64,7 +65,7 @@ public class FidSearchResultFrame extends JFrame implements FidQueryCloseListene
private void buildFrame() {
GTableCellRenderer renderer = new GTableCellRenderer();
- renderer.setFont(FidDebugUtils.MONOSPACED_FONT);
+ renderer.setFont(Gui.getFont("font.monospaced"));
int columnCount = table.getColumnCount();
for (int ii = 0; ii < columnCount; ++ii) {
Class<?> columnClass = table.getColumnClass(ii);
diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/plugin/PopulateFidDialog.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/plugin/PopulateFidDialog.java
index 9ea0309e4e..5fdb212694 100644
--- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/plugin/PopulateFidDialog.java
+++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/plugin/PopulateFidDialog.java
@@ -15,7 +15,8 @@
*/
package ghidra.feature.fid.plugin;
-import java.awt.*;
+import java.awt.BorderLayout;
+import java.awt.Component;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -279,10 +280,7 @@ public class PopulateFidDialog extends DialogComponentProvider {
}
private JButton createBrowseButton() {
- JButton browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
- Font font = browseButton.getFont();
- browseButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
- return browseButton;
+ return ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
}
private static class LibraryChoice {
diff --git a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffDetailsProvider.java b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffDetailsProvider.java
index a918b5d66c..10609fffb8 100644
--- a/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffDetailsProvider.java
+++ b/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/DiffDetailsProvider.java
@@ -30,6 +30,7 @@ import docking.action.DockingAction;
import docking.action.ToolBarData;
import docking.widgets.checkbox.GCheckBox;
import generic.theme.GIcon;
+import generic.theme.Gui;
import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.Plugin;
@@ -288,13 +289,12 @@ public class DiffDetailsProvider extends ComponentProviderAdapter {
}
private JScrollPane createDetailsPane() {
- Font font = new Font("Monospaced", Font.PLAIN, 12);
textPane = new JTextPane();
doc = textPane.getStyledDocument();
textPane.setName(DIFF_DETAILS_TEXT_AREA);
textPane.setEditable(false);
textPane.setMargin(new Insets(5, 5, 5, 5));
- textPane.setFont(font);
+ Gui.registerFont(textPane, "font.monospaced");
textPane.setOpaque(true);
textPane.setCaretPosition(0);
JScrollPane scrolledDetails = new JScrollPane(textPane);
diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/NewSessionPanel.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/NewSessionPanel.java
index d82beac3db..06f14ae77a 100644
--- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/NewSessionPanel.java
+++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/wizard/NewSessionPanel.java
@@ -79,8 +79,6 @@ public class NewSessionPanel extends AbstractMageJPanel<VTWizardStateKey> {
JButton browseFolderButton =
ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
browseFolderButton.addActionListener(e -> browseDataTreeFolders());
- Font font = browseFolderButton.getFont();
- browseFolderButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
JLabel newSessionLabel = new GDLabel("New Session Name: ");
newSessionLabel.setToolTipText("The name for the new Version Tracking Session");
diff --git a/Ghidra/Framework/Docking/data/docking.theme.properties b/Ghidra/Framework/Docking/data/docking.theme.properties
index 7a5a190cc8..11ba048b3a 100644
--- a/Ghidra/Framework/Docking/data/docking.theme.properties
+++ b/Ghidra/Framework/Docking/data/docking.theme.properties
@@ -221,9 +221,10 @@ icon.task.progress.hourglass.11 = hourglass24_11.png
// Fonts
-
-
-
+font.splash.header.default = Serif-BOLD-35
+font.splash.status = Serif-BOLD-12
+font.table.header.number = arial-BOLD-12
+font.input.hint = monospaced-PLAIN-10
[Dark Defaults]
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/framework/ApplicationInformationDisplayFactory.java b/Ghidra/Framework/Docking/src/main/java/docking/framework/ApplicationInformationDisplayFactory.java
index 1723bc2816..d9c063901c 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/framework/ApplicationInformationDisplayFactory.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/framework/ApplicationInformationDisplayFactory.java
@@ -23,8 +23,7 @@ import javax.swing.*;
import docking.widgets.label.GIconLabel;
import docking.widgets.label.GLabel;
-import generic.theme.GColor;
-import generic.theme.GIcon;
+import generic.theme.*;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.framework.Application;
import ghidra.framework.PluggableServiceRegistry;
@@ -126,7 +125,7 @@ public class ApplicationInformationDisplayFactory {
JLabel nameLabel = new GLabel(Application.getName());
nameLabel.setForeground(Palette.GRAY);
- Font newFont = new Font("Garamond", Font.BOLD, 35);
+ Font newFont = Gui.getFont("font.splash.header.default");
nameLabel.setFont(newFont);
nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
nameLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java b/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java
index d8d9466b74..a3c3a99b74 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java
@@ -25,6 +25,7 @@ import javax.swing.border.BevelBorder;
import docking.*;
import docking.widgets.label.GDLabel;
import generic.theme.GColor;
+import generic.theme.Gui;
import generic.util.WindowUtilities;
import ghidra.framework.Application;
import ghidra.util.Msg;
@@ -39,6 +40,8 @@ public class SplashScreen extends JWindow {
private static final Color BG_COLOR = new GColor("color.bg.splashscreen");
+ private static final String FONT_ID = "font.splash.status";
+
private static SplashScreen splashWindow; // splash window displayed while ghidra is coming up
private static DockingFrame hiddenFrame;
private static JLabel statusLabel;
@@ -300,9 +303,9 @@ public class SplashScreen extends JWindow {
}
private Component createStatusComponent() {
- Font f = new Font("serif", Font.BOLD, 12);
statusLabel = new GDLabel(" Loading...");
- statusLabel.setFont(f);
+ Gui.registerFont(statusLabel, FONT_ID);
+ statusLabel.setFont(Gui.getFont(FONT_ID));
statusLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 2, 10));
statusLabel.setOpaque(true);
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/options/editor/ButtonPanelFactory.java b/Ghidra/Framework/Docking/src/main/java/docking/options/editor/ButtonPanelFactory.java
index 96c8b122e9..68147cd3fe 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/options/editor/ButtonPanelFactory.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/options/editor/ButtonPanelFactory.java
@@ -116,10 +116,6 @@ public class ButtonPanelFactory {
return 10;
}
};
- /**
- * Font for the browse button label.
- */
- public final static Font BROWSE_FONT = new Font("Dialog", Font.BOLD, 12);
/**
* internal values used when creating the panels and buttons
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/options/editor/FileChooserEditor.java b/Ghidra/Framework/Docking/src/main/java/docking/options/editor/FileChooserEditor.java
index 7362459aaf..82d3a743f6 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/options/editor/FileChooserEditor.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/options/editor/FileChooserEditor.java
@@ -16,7 +16,6 @@
package docking.options.editor;
import java.awt.Component;
-import java.awt.Font;
import java.awt.event.MouseListener;
import java.beans.PropertyEditorSupport;
import java.io.File;
@@ -107,9 +106,6 @@ public class FileChooserEditor extends PropertyEditorSupport {
textField.setText(currentFileValue != null ? currentFileValue.getAbsolutePath() : "");
browseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
- Font f = browseButton.getFont();
- f = new Font(f.getName(), Font.BOLD, f.getSize());
- browseButton.setFont(f);
add(textField);
add(Box.createHorizontalStrut(5));
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java
index e65591431f..89e27eaba4 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeColorTableModel.java
@@ -66,7 +66,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
load();
fireTableDataChanged();
}
-
+
/**
* Returns the original value for the current theme
*/
@@ -77,7 +77,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
private void load() {
currentValues = Gui.getAllValues();
colors = currentValues.getColors();
- themeValues = new GThemeValueMap(currentValues);
+ themeValues = Gui.getThemeValues();
defaultValues = Gui.getDefaults();
lightDefaultValues = Gui.getApplicationLightDefaults();
darkDefaultValues = Gui.getApplicationDarkDefaults();
@@ -189,7 +189,7 @@ public class ThemeColorTableModel extends GDynamicColumnTableModel<ColorValue, O
private class ThemeColorRenderer extends AbstractGColumnRenderer<ResolvedColor> {
public ThemeColorRenderer() {
- setFont(new Font("Monospaced", Font.PLAIN, 12));
+ setFont(Gui.getFont("font.monospaced"));
}
@Override
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTable.java b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTable.java
index 6f9293e8f9..698e2d1ace 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTable.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTable.java
@@ -106,6 +106,9 @@ public class ThemeFontTable extends JPanel implements ActionContextProvider {
@Override
public ActionContext getActionContext(MouseEvent e) {
+ if (e == null) {
+ return null;
+ }
if (e.getSource() == table) {
FontValue currentValue = filterTable.getSelectedRowObject();
if (currentValue == null) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTableModel.java b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTableModel.java
index 05e229dc90..24e1628707 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTableModel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeFontTableModel.java
@@ -66,7 +66,7 @@ public class ThemeFontTableModel extends GDynamicColumnTableModel<FontValue, Obj
private void load() {
currentValues = Gui.getAllValues();
fonts = currentValues.getFonts();
- themeValues = new GThemeValueMap(currentValues);
+ themeValues = Gui.getThemeValues();
defaultValues = Gui.getDefaults();
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeIconTableModel.java b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeIconTableModel.java
index e4888b8368..c7f95abe59 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeIconTableModel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/theme/gui/ThemeIconTableModel.java
@@ -16,7 +16,6 @@
package docking.theme.gui;
import java.awt.Component;
-import java.awt.Font;
import java.util.Comparator;
import java.util.List;
import java.util.function.Supplier;
@@ -67,7 +66,7 @@ public class ThemeIconTableModel extends GDynamicColumnTableModel<IconValue, Obj
private void load() {
currentValues = Gui.getAllValues();
icons = currentValues.getIcons();
- themeValues = new GThemeValueMap(currentValues);
+ themeValues = Gui.getThemeValues();
defaultValues = Gui.getDefaults();
}
@@ -175,7 +174,7 @@ public class ThemeIconTableModel extends GDynamicColumnTableModel<IconValue, Obj
private class ThemeIconRenderer extends AbstractGColumnRenderer<ResolvedIcon> {
public ThemeIconRenderer() {
- setFont(new Font("Monospaced", Font.PLAIN, 12));
+ setFont(Gui.getFont("font.monospaced"));
}
@Override
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/AbstractGCellRenderer.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/AbstractGCellRenderer.java
index 3af1c238de..e7e201fd91 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/AbstractGCellRenderer.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/AbstractGCellRenderer.java
@@ -120,7 +120,7 @@ public abstract class AbstractGCellRenderer extends GDHtmlLabel {
super.setFont(f);
defaultFont = f;
fixedWidthFont = new Font("monospaced", defaultFont.getStyle(), defaultFont.getSize());
- boldFont = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize());
+ boldFont = f.deriveFont(Font.BOLD);
}
protected void superSetFont(Font font) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tabbedpane/DockingTabRenderer.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tabbedpane/DockingTabRenderer.java
index f17ad35135..6b355e8167 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tabbedpane/DockingTabRenderer.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tabbedpane/DockingTabRenderer.java
@@ -20,9 +20,10 @@ import java.awt.event.*;
import javax.swing.*;
+import docking.CloseIcon;
import docking.widgets.EmptyBorderButton;
import docking.widgets.label.GDLabel;
-import resources.ResourceManager;
+import generic.theme.GColor;
/**
* A widget that can be used to render an icon, title and close button for JTabbedPane. You would
@@ -31,10 +32,9 @@ import resources.ResourceManager;
public class DockingTabRenderer extends JPanel {
private static final int MAX_TITLE_LENGTH = 25;
- private Icon EMPTY_ICON =
- ResourceManager.getScaledIcon(ResourceManager.loadImage("images/close16.gif"), 8, 8);
- private Icon CLOSE_ICON =
- ResourceManager.getScaledIcon(ResourceManager.loadImage("images/close16.gif"), 8, 8);
+ private Icon CLOSE_ICON = new CloseIcon(8, 1, new GColor("color.fg.button"));
+ private Icon EMPTY_ICON = CLOSE_ICON;
+ //TODO if we don't want the close icon to come and go, then this class can be greatly simplified
private JLabel titleLabel;
private JLabel iconLabel;
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableHeaderRenderer.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableHeaderRenderer.java
index 3f83921acd..1e80335dff 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableHeaderRenderer.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableHeaderRenderer.java
@@ -23,8 +23,7 @@ import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.table.*;
-import generic.theme.GColor;
-import generic.theme.GIcon;
+import generic.theme.*;
import resources.*;
import resources.icons.EmptyIcon;
import resources.icons.TranslateIcon;
@@ -314,6 +313,7 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
private class NumberPainterIcon implements Icon {
+ private static final String FONT_ID = "font.table.header.number";
private final int iconWidth;
private int numberWidth;
private final int iconHeight;
@@ -324,9 +324,7 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
this.iconHeight = height;
this.numberText = numberText;
- int fontSize = 12;
- String fontFamily = "arial";
- Font font = new Font(fontFamily, Font.BOLD, fontSize);
+ Font font = Gui.getFont(FONT_ID);
FontMetrics fontMetrics = getFontMetrics(font);
numberWidth = fontMetrics.stringWidth(numberText);
}
@@ -344,9 +342,7 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
- int fontSize = 12;
- String fontFamily = "arial";
- Font font = new Font(fontFamily, Font.BOLD, fontSize);
+ Font font = Gui.getFont(FONT_ID);
g.setFont(font);
FontMetrics fontMetrics = g.getFontMetrics();
int numberHeight = fontMetrics.getAscent();
@@ -363,8 +359,8 @@ public class GTableHeaderRenderer extends DefaultTableCellRenderer {
AttributedString as = new AttributedString(numberText);
as.addAttribute(TextAttribute.FOREGROUND, SORT_NUMBER_FG_COLOR);
as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
- as.addAttribute(TextAttribute.FAMILY, fontFamily);
- as.addAttribute(TextAttribute.SIZE, (float) fontSize);
+ as.addAttribute(TextAttribute.FAMILY, font.getFamily());
+ as.addAttribute(TextAttribute.SIZE, font.getSize2D());
g.drawString(as.getIterator(), startX, textBaseline);
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/HexOrDecimalInput.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/HexOrDecimalInput.java
index 224fbf091d..c847e77364 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/HexOrDecimalInput.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/HexOrDecimalInput.java
@@ -24,8 +24,10 @@ import javax.swing.text.*;
import docking.util.GraphicsUtils;
import generic.theme.GThemeDefaults.Colors.Messages;
+import generic.theme.Gui;
public class HexOrDecimalInput extends JTextField {
+ private static final String FONT_ID = "font.input.hint";
private boolean isHexMode = false;
private boolean allowsNegative = true;
private Long currentValue;
@@ -128,7 +130,7 @@ public class HexOrDecimalInput extends JTextField {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
- Font font = new Font("Monospaced", Font.PLAIN, 10);
+ Font font = Gui.getFont(FONT_ID);
Font savedFont = g.getFont();
g.setFont(font);
g.setColor(Messages.HINT);
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/IntegerTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/IntegerTextField.java
index 6a22570d44..26711c5433 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/IntegerTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/IntegerTextField.java
@@ -28,6 +28,7 @@ import javax.swing.text.*;
import docking.DockingUtils;
import docking.util.GraphicsUtils;
import generic.theme.GThemeDefaults.Colors.Messages;
+import generic.theme.Gui;
import ghidra.util.SystemUtilities;
/**
@@ -635,13 +636,13 @@ public class IntegerTextField {
*/
private class MyTextField extends JTextField {
- private Font hintFont = new Font("Monospaced", Font.PLAIN, 10);
+ private static final String FONT_ID = "font.input.hint";
private int hintWidth;
public MyTextField(int columns) {
super(columns);
- FontMetrics fontMetrics = getFontMetrics(hintFont);
+ FontMetrics fontMetrics = getFontMetrics(Gui.getFont(FONT_ID));
String mode = isHexMode ? "Hex" : "Dec";
hintWidth = fontMetrics.stringWidth(mode);
@@ -682,7 +683,7 @@ public class IntegerTextField {
}
Font savedFont = g.getFont();
- g.setFont(hintFont);
+ g.setFont(Gui.getFont(FONT_ID));
g.setColor(Messages.HINT);
Dimension size = getSize();
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/LocalDateTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/LocalDateTextField.java
index bdf9e96a16..fb190f0e6e 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/LocalDateTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/textfield/LocalDateTextField.java
@@ -32,6 +32,7 @@ import javax.swing.event.*;
import docking.util.GraphicsUtils;
import generic.theme.GThemeDefaults.Colors.Messages;
+import generic.theme.Gui;
import ghidra.util.SystemUtilities;
/**
@@ -227,12 +228,14 @@ public class LocalDateTextField {
private class MyTextField extends JTextField {
+ private static final String FONT_ID = "font.input.hint";
+
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (showFieldDecoration) {
- Font font = new Font("Monospaced", Font.PLAIN, 10);
+ Font font = Gui.getFont(FONT_ID);
Font savedFont = g.getFont();
g.setFont(font);
g.setColor(Messages.HINT);
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/support/GTreeRenderer.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/support/GTreeRenderer.java
index 57537ed5a1..8c1f37b767 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/support/GTreeRenderer.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/support/GTreeRenderer.java
@@ -142,7 +142,7 @@ public class GTreeRenderer extends DefaultTreeCellRenderer implements GComponent
// Bug Alert!:
// We must create a new font here and not use deriveFont(). Using derive font has
// bugs when calculating the string width for a bold derived font.
- cachedBoldFont = new Font(font.getFamily(), Font.BOLD, font.getSize());
+ cachedBoldFont = font.deriveFont(Font.BOLD);
}
return bold ? cachedBoldFont : cachedDefaultFont;
}
diff --git a/Ghidra/Framework/Generic/data/generic.theme.properties b/Ghidra/Framework/Generic/data/generic.theme.properties
index 4b94fe1ccd..647404d954 100644
--- a/Ghidra/Framework/Generic/data/generic.theme.properties
+++ b/Ghidra/Framework/Generic/data/generic.theme.properties
@@ -2,10 +2,10 @@
// Fonts
font.standard = [font]panel.font
-font.monospaced = font.standard[monospaced]
font.bold = font.standard[bold]
font.italics = font.standard[italic]
font.bold.italic = font.standard[bold][italic]
+font.monospaced = monospaced-PLAIN-12
[Dark Defaults]
\ No newline at end of file
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
index a630722b7d..584b03d0b6 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
@@ -45,6 +45,7 @@ import org.junit.runner.Description;
import generic.jar.ResourceFile;
import generic.test.rule.Repeated;
import generic.test.rule.RepeatedTestRule;
+import generic.theme.Gui;
import generic.util.WindowUtilities;
import ghidra.GhidraTestApplicationLayout;
import ghidra.framework.Application;
@@ -1584,7 +1585,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
}
});
// Fix up the default fonts that Java 1.5.0 changed to Courier, which looked terrible.
- Font f = new Font("Monospaced", Font.PLAIN, 12);
+ Font f = Gui.getFont("font.monospaced");
UIManager.put("PasswordField.font", f);
UIManager.put("TextArea.font", f);
}
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/theme/AbstractThemeReader.java b/Ghidra/Framework/Generic/src/main/java/generic/theme/AbstractThemeReader.java
index 80b5b95b4d..db44f4e11b 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/theme/AbstractThemeReader.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/theme/AbstractThemeReader.java
@@ -78,14 +78,19 @@ public abstract class AbstractThemeReader {
String value = section.getValue(key);
int lineNumber = section.getLineNumber(key);
if (ColorValue.isColorKey(key)) {
- valueMap.addColor(parseColorProperty(key, value, lineNumber));
+ ColorValue colorValue = parseColorProperty(key, value, lineNumber);
+ ColorValue oldValue = valueMap.addColor(colorValue);
+ reportDuplicateKey(oldValue, lineNumber);
}
else if (FontValue.isFontKey(key)) {
- valueMap.addFont(parseFontProperty(key, value, lineNumber));
+ FontValue oldValue = valueMap.addFont(parseFontProperty(key, value, lineNumber));
+ reportDuplicateKey(oldValue, lineNumber);
}
else if (IconValue.isIconKey(key)) {
if (!GTheme.JAVA_ICON.equals(value)) {
- valueMap.addIcon(parseIconProperty(key, value, lineNumber));
+ IconValue oldValue =
+ valueMap.addIcon(parseIconProperty(key, value, lineNumber));
+ reportDuplicateKey(oldValue, lineNumber);
}
}
else {
@@ -94,6 +99,12 @@ public abstract class AbstractThemeReader {
}
}
+ private void reportDuplicateKey(ThemeValue<?> oldValue, int lineNumber) {
+ if (oldValue != null) {
+ error(lineNumber, "Duplicate id found: \"" + oldValue.getId() + "\"");
+ }
+ }
+
private IconValue parseIconProperty(String key, String value, int lineNumber) {
try {
return IconValue.parse(key, value);
@@ -280,6 +291,10 @@ public abstract class AbstractThemeReader {
error(lineNumber, "Missing value for propery line: \"" + line + "\"");
return;
}
+ if (properties.containsKey(key)) {
+ error(lineNumber, "Duplicate key found in this file!: " + key + "\"");
+ return;
+ }
properties.put(key, value);
lineNumbers.put(key, lineNumber);
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/theme/GThemeValueMap.java b/Ghidra/Framework/Generic/src/main/java/generic/theme/GThemeValueMap.java
index 6da376d243..0d0ded0fcb 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/theme/GThemeValueMap.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/theme/GThemeValueMap.java
@@ -51,33 +51,39 @@ public class GThemeValueMap {
* Adds the {@link ColorValue} to the map. If a ColorValue already exists in the map with
* the same id, it will be replaced
* @param value the {@link ColorValue} to store in the map.
+ * @return the previous value for the color key or null if no previous value existed
*/
- public void addColor(ColorValue value) {
+ public ColorValue addColor(ColorValue value) {
if (value != null) {
- colorMap.put(value.getId(), value);
+ return colorMap.put(value.getId(), value);
}
+ return null;
}
/**
* Adds the {@link FontValue} to the map. If a FontValue already exists in the map with
* the same id, it will be replaced
* @param value the {@link FontValue} to store in the map.
+ * @return the previous value for the font key or null if no previous value existed
*/
- public void addFont(FontValue value) {
+ public FontValue addFont(FontValue value) {
if (value != null) {
- fontMap.put(value.getId(), value);
+ return fontMap.put(value.getId(), value);
}
+ return null;
}
/**
* Adds the {@link IconValue} to the map. If a IconValue already exists in the map with
* the same id, it will be replaced
* @param value the {@link IconValue} to store in the map.
+ * @return the previous value for the icon key or null if no previous value existed
*/
- public void addIcon(IconValue value) {
+ public IconValue addIcon(IconValue value) {
if (value != null) {
- iconMap.put(value.getId(), value);
+ return iconMap.put(value.getId(), value);
}
+ return null;
}
/**
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java b/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java
index 27570ac605..98b141ca6a 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/theme/Gui.java
@@ -286,6 +286,24 @@ public class Gui {
return new GThemeValueMap(currentValues);
}
+ /**
+ * Returns the theme values as defined by the current theme, ignoring any unsaved changes that
+ * are currently applied to the application.
+ * @return the theme values as defined by the current theme, ignoring any unsaved changes that
+ * are currently applied to the application.
+ */
+ public static GThemeValueMap getThemeValues() {
+ GThemeValueMap map = new GThemeValueMap();
+ map.load(javaDefaults);
+ map.load(systemValues);
+ map.load(applicationDefaults);
+ if (activeTheme.useDarkDefaults()) {
+ map.load(applicationDarkDefaults);
+ }
+ map.load(activeTheme);
+ return map;
+ }
+
/**
* Returns a {@link GThemeValueMap} contains all values that differ from the default
* values (values defined by the {@link LookAndFeel} or in the theme.properties files.
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/theme/IconValue.java b/Ghidra/Framework/Generic/src/main/java/generic/theme/IconValue.java
index 09a426078f..39dd8c9a81 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/theme/IconValue.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/theme/IconValue.java
@@ -193,8 +193,8 @@ public class IconValue extends ThemeValue<Icon> {
@Override
protected Icon getUnresolvedReferenceValue(String unresolvedId) {
Msg.warn(this,
- "Could not resolve indirect icon path for" + unresolvedId +
- ", using last resort default");
+ "Could not resolve indirect icon path for \"" + unresolvedId +
+ "\", using last resort default");
return LAST_RESORT_DEFAULT;
}
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java
index dd25542adf..65544fccd1 100644
--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java
+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/AbstractOptions.java
@@ -25,8 +25,8 @@ import java.util.*;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
-import ghidra.util.HelpLocation;
-import ghidra.util.Msg;
+import generic.theme.*;
+import ghidra.util.*;
import ghidra.util.datastruct.WeakDataStructureFactory;
import ghidra.util.datastruct.WeakSet;
import ghidra.util.exception.AssertException;
@@ -59,6 +59,8 @@ public abstract class AbstractOptions implements Options {
protected Map<String, OptionsEditor> optionsEditorMap;
protected Map<String, HelpLocation> categoryHelpMap;
protected Map<String, AliasBinding> aliasMap;
+ protected ThemeListener themeListener;
+ protected Map<String, String> themeToOptionMap = new HashMap<>();
protected AbstractOptions(String name) {
this.name = name;
@@ -67,7 +69,8 @@ public abstract class AbstractOptions implements Options {
optionsEditorMap = new HashMap<>();
categoryHelpMap = new HashMap<>();
aliasMap = new HashMap<>();
-
+ themeListener = this::themeChanged;
+ Gui.addThemeListener(themeListener);
}
protected abstract Option createRegisteredOption(String optionName, OptionType type,
@@ -131,15 +134,32 @@ public abstract class AbstractOptions implements Options {
public synchronized void registerOption(String optionName, OptionType type, Object defaultValue,
HelpLocation help, String description, PropertyEditor editor) {
- if (type == OptionType.COLOR_TYPE) {
-// Msg.warn(this, "Registering color: " + optionName,
-// ReflectionUtilities.createJavaFilteredThrowable());
- }
if (type == OptionType.NO_TYPE) {
throw new IllegalArgumentException(
"Can't register an option of type: " + OptionType.NO_TYPE);
}
+ if (type == OptionType.COLOR_TYPE) {
+ if (defaultValue instanceof GColor gColor) {
+ registerThemeColor(optionName, gColor.getId(), help, description);
+ return;
+ }
+ warnNonThemeValue("Registering non theme color: " + optionName);
+ }
+ if (type == OptionType.FONT_TYPE) {
+ if (defaultValue instanceof String fontId) {
+ registerThemeFont(optionName, fontId, help, description);
+ return;
+ }
+ String message = "Registering non theme font: " + optionName;
+ if (SystemUtilities.isInDevelopmentMode()) {
+ Msg.warn(this, message, ReflectionUtilities.createJavaFilteredThrowable());
+ }
+ else {
+ Msg.warn(this, message);
+ }
+ }
+
if (!type.isCompatible(defaultValue)) {
throw new IllegalStateException(
"Given default value does not match the given OptionType! OptionType = " + type +
@@ -167,27 +187,40 @@ public abstract class AbstractOptions implements Options {
valueMap.put(optionName, option);
}
- @Override
- public void registerThemeColorOption(String optionName, String colorId, HelpLocation help,
+ protected void warnNonThemeValue(String message) {
+ if (SystemUtilities.isInDevelopmentMode()) {
+ Msg.warn(this, message, ReflectionUtilities.createJavaFilteredThrowable());
+ }
+ else {
+ Msg.warn(this, message);
+ }
+ }
+
+ private void registerThemeColor(String optionName, String colorId, HelpLocation help,
String description) {
Option currentOption = getExistingComptibleOption(optionName, OptionType.COLOR_TYPE);
if (currentOption != null && currentOption instanceof ThemeColorOption) {
currentOption.updateRegistration(description, help, null, null);
return;
}
+ description += " (Theme Color: " + colorId + ")";
Option option = new ThemeColorOption(optionName, colorId, description, help);
valueMap.put(optionName, option);
}
- @Override
- public void registerThemeFontOption(String optionName, String fontId, HelpLocation help,
+ private void registerThemeFont(String optionName, String fontId, HelpLocation help,
String description) {
+ if (Gui.getFont(fontId) == null) {
+ throw new IllegalArgumentException("Invalid theme font id: \"" + fontId + "\"");
+ }
Option currentOption = getExistingComptibleOption(optionName, OptionType.FONT_TYPE);
if (currentOption != null && currentOption instanceof ThemeFontOption) {
currentOption.updateRegistration(description, help, null, null);
return;
}
+ description += " (Theme Font: " + fontId + ")";
Option option = new ThemeFontOption(optionName, fontId, description, help);
+ themeToOptionMap.put(fontId, optionName);
valueMap.put(optionName, option);
}
@@ -831,6 +864,18 @@ public abstract class AbstractOptions implements Options {
return new ArrayList<>(leafNames);
}
+ private void themeChanged(ThemeEvent e) {
+ if (!e.hasAnyFontChanged()) {
+ return;
+ }
+ for (String fontId : themeToOptionMap.keySet()) {
+ if (e.isFontChanged(fontId)) {
+ String optionName = themeToOptionMap.get(fontId);
+ notifyOptionChanged(optionName, null, Gui.getFont(fontId));
+ }
+ }
+ }
+
//==================================================================================================
// Inner Classes
//==================================================================================================
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java
index 8c21f59f29..256d38df63 100644
--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java
+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/Options.java
@@ -149,32 +149,6 @@ public interface Options {
public void registerOption(String optionName, OptionType type, Object defaultValue,
HelpLocation help, String description, PropertyEditor editor);
- /**
- * Registers a theme color as an option. Doing this allows the color to be edited in the
- * options Gui, but all changes result in a theme change and not an options change. In other
- * words, changes to this option causes a theme change and is saved to a theme instead of in
- * the tool with normal options
- * @param optionName the option name to bind to a theme color id
- * @param colorId the theme color id to be affected if a users changes this color option
- * @param help the {@link HelpLocation} for more information on how this color is used
- * @param description a short description of how this color is used
- */
- public void registerThemeColorOption(String optionName, String colorId, HelpLocation help,
- String description);
-
- /**
- * Registers a theme font as an option. Doing this allows the font to be edited in the
- * options Gui, but all changes result in a theme change and not an options change. In other
- * words, changes to this option causes a theme change and is saved to a theme instead of in
- * the tool with normal options
- * @param optionName the option name to bind to a theme font id
- * @param fontId the theme font id to be affected if a users changes this font option
- * @param help the {@link HelpLocation} for more information on how this font is used
- * @param description a short description of how this font is used
- */
- public void registerThemeFontOption(String optionName, String fontId, HelpLocation help,
- String description);
-
/**
* Register the options editor that will handle the editing for all the options or a sub group of options.
* @param editor the custom editor panel to be used to edit the options or sub group of options.
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java
index 9d3cdbbffe..734bbccf2f 100644
--- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java
+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/options/SubOptions.java
@@ -92,18 +92,6 @@ public class SubOptions implements Options {
options.registerOption(prefix + optionName, type, defaultValue, help, description, editor);
}
- @Override
- public void registerThemeColorOption(String optionName, String colorId, HelpLocation help,
- String description) {
- options.registerThemeColorOption(prefix + optionName, colorId, help, description);
- }
-
- @Override
- public void registerThemeFontOption(String optionName, String fontId, HelpLocation help,
- String description) {
- options.registerThemeFontOption(prefix + optionName, fontId, help, description);
- }
-
@Override
public void putObject(String optionName, Object obj) {
options.putObject(prefix + optionName, obj);
diff --git a/Ghidra/Framework/Graph/data/graph.theme.properties b/Ghidra/Framework/Graph/data/graph.theme.properties
index c80585c98d..a7c99e2955 100644
--- a/Ghidra/Framework/Graph/data/graph.theme.properties
+++ b/Ghidra/Framework/Graph/data/graph.theme.properties
@@ -28,8 +28,8 @@ color.visualgraph.view.satellite.edge.hovered = color.palette.lime
# graph display
-color.graphdisplay.vertex = green
-color.graphdisplay.edge = green
+color.graphdisplay.vertex.default = green
+color.graphdisplay.edge.default = green
color.graphdisplay.vertex.selected = blue
color.graphdisplay.edge.selected = blue
@@ -37,6 +37,8 @@ icon.graph.satellite = network-wireless-16.png
icon.graph.satellite.large = network-wireless.png
icon.graph.layout.default = color_swatch.png
+font.graphdisplay.default = dialog-bold-18
+font.graph.component.message = SansSerif-BOLDITALIC-18
[Dark Defaults]
diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/GraphComponent.java b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/GraphComponent.java
index 80c2e91b7a..17035b15a3 100644
--- a/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/GraphComponent.java
+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/graph/viewer/GraphComponent.java
@@ -43,8 +43,7 @@ import edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer;
import edu.uci.ics.jung.visualization.renderers.Renderer;
import edu.uci.ics.jung.visualization.renderers.Renderer.Vertex;
import edu.uci.ics.jung.visualization.util.Caching;
-import generic.theme.GColor;
-import generic.theme.GIcon;
+import generic.theme.*;
import generic.theme.GThemeDefaults.Colors;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.graph.VisualGraph;
@@ -1002,6 +1001,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
private class MessagePaintable implements Paintable {
+ private static final String FONT_ID = "font.graph.component.message";
private final Color backgroundColor = new GColor("color.bg.visualgraph.message");
private String message = null;
@@ -1017,7 +1017,7 @@ public class GraphComponent<V extends VisualVertex, E extends VisualEdge<V>, G e
// this composite softens the text and color of the message
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SrcOver.getRule(), .60f));
- Font font = new Font("Sanf Serif", Font.BOLD | Font.ITALIC, 18);
+ Font font = Gui.getFont(FONT_ID);
g.setFont(font);
Rectangle stringBounds =
diff --git a/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java b/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java
index a3568a3bd4..044592d846 100644
--- a/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java
+++ b/Ghidra/Framework/Graph/src/main/java/ghidra/service/graph/GraphDisplayOptions.java
@@ -26,6 +26,7 @@ import javax.swing.event.ChangeListener;
import docking.Tool;
import docking.options.editor.*;
import generic.theme.GColor;
+import generic.theme.Gui;
import ghidra.framework.options.*;
import ghidra.util.HelpLocation;
import ghidra.util.WebColors;
@@ -66,8 +67,8 @@ public class GraphDisplayOptions implements OptionsChangeListener {
private Color vertexSelectionColor = new GColor("color.graphdisplay.vertex.selected");
private Color edgeSelectionColor = new GColor("color.graphdisplay.edge.selected");
- private Color defaultVertexColor = new GColor("color.graphdisplay.vertex");
- private Color defaultEdgeColor = new GColor("color.graphdisplay.edge");
+ private Color defaultVertexColor = new GColor("color.graphdisplay.vertex.default");
+ private Color defaultEdgeColor = new GColor("color.graphdisplay.edge.default");
private String favoredEdgeType;
private VertexShape defaultVertexShape = VertexShape.RECTANGLE;
@@ -80,11 +81,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
private String defaultLayoutAlgorithmName = LayoutAlgorithmNames.MIN_CROSS_COFFMAN_GRAHAM;
private boolean useIcons = true;
private GraphLabelPosition labelPosition = GraphLabelPosition.SOUTH;
- private Font font = new Font("Dialog", Font.BOLD, 18);
+ private Font font = Gui.getFont("font.graphdisplay.default");
+ private String themeFontId = null;
private int arrowLength = 15;
private int maxNodeCount = 500; // graph display struggles with too many nodes
+ private Set<String> vertexRegistrations = new HashSet<>();
+ private Set<String> edgeRegistrations = new HashSet<>();
+ private Set<String> defaultRegistrations = new HashSet<>();
+
/**
* Constructs a new GraphTypeDisplayOptions for the given {@link GraphType}
* @param graphType The {@link GraphType} for which to define display options
@@ -155,6 +161,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
this.defaultVertexColor = Objects.requireNonNull(color);
}
+ /**
+ * Sets the default color to be used by vertices that don't have a vertex type set. The
+ * color is set via a themeColorId, which means the client defined a theme color for this.
+ * @param themeColorId the theme color id to use for the default vertex color
+ */
+ public void setDefaultVertexColor(String themeColorId) {
+ this.defaultVertexColor = new GColor(themeColorId);
+ defaultRegistrations.add(DEFAULT_VERTEX_COLOR);
+ }
+
/**
* Sets the default color to be used by edges that don't have a edge type set
* @param color the default edge shape
@@ -163,6 +179,16 @@ public class GraphDisplayOptions implements OptionsChangeListener {
this.defaultEdgeColor = Objects.requireNonNull(color);
}
+ /**
+ * Sets the default color to be used by vertices that don't have a vertex type set. The
+ * color is set via a themeColorId, which means the client defined a theme color for this.
+ * @param themeColorId the theme color id to use for the default vertex color
+ */
+ public void setDefaultEdgeColor(String themeColorId) {
+ this.defaultEdgeColor = new GColor(themeColorId);
+ defaultRegistrations.add(DEFAULT_EDGE_COLOR);
+ }
+
/**
* Returns the default color for edges that don't have an edge type set
* @return the default color for edges that don't have an edge type set
@@ -353,7 +379,9 @@ public class GraphDisplayOptions implements OptionsChangeListener {
}
/**
- * Sets the color for vertices with the given vertex type
+ * Sets the color for vertices with the given vertex type. Note that this method does not
+ * allow the vertex color to be registered in tool options.
+ * See {@link #setVertexColor(String, String)}.
* @param vertexType the vertex type for which to set its color
* @param color the color to use for vertices with the given vertex type
*/
@@ -362,6 +390,18 @@ public class GraphDisplayOptions implements OptionsChangeListener {
vertexColorMap.put(vertexType, Objects.requireNonNull(color));
}
+ /**
+ * Sets the vertex color using a theme color id. By using a theme color id, this property
+ * is eligible to be registered as a tool option.
+ * @param vertexType the vertex type for which to set its color
+ * @param themeColorId the theme color id of the color for this vertex type
+ */
+ public void setVertexColor(String vertexType, String themeColorId) {
+ checkVertexType(vertexType);
+ vertexColorMap.put(vertexType, new GColor(Objects.requireNonNull(themeColorId)));
+ vertexRegistrations.add(vertexType);
+ }
+
private String getVertexShapeName(String vertexType) {
VertexShape vertexShape = vertexShapeMap.getOrDefault(vertexType, defaultVertexShape);
return vertexShape.getName();
@@ -386,6 +426,18 @@ public class GraphDisplayOptions implements OptionsChangeListener {
return edgeColorMap.getOrDefault(edgeType, defaultEdgeColor);
}
+ /**
+ * Sets the edge color using a theme color id. By using a theme color id, this property
+ * is eligible to be registered as a tool option.
+ * @param edgeType the edge type for which to set its color
+ * @param themeColorId the theme color id of the color for this edge type
+ */
+ public void setEdgeColor(String edgeType, String themeColorId) {
+ checkEdgeType(edgeType);
+ edgeColorMap.put(edgeType, new GColor(Objects.requireNonNull(themeColorId)));
+ edgeRegistrations.add(edgeType);
+ }
+
/**
* Sets the color for edges with the given edge type
* @param edgeType the edge type for which to set its color
@@ -459,13 +511,24 @@ public class GraphDisplayOptions implements OptionsChangeListener {
}
/**
- * Sets the vertex selection color
+ * Sets the vertex selection color. Use this method only if this color does not appear in
+ * the tool options.
* @param vertexSelectionColor the color to use for highlighting selected vertices
*/
public void setVertexSelectionColor(Color vertexSelectionColor) {
this.vertexSelectionColor = vertexSelectionColor;
}
+ /**
+ * Sets the vertex selection color using the theme color defined by the given color id. This
+ * method will allow the property to be registered to the tool options.
+ * @param themeColorId the color id to use for highlighting vertices.
+ */
+ public void setVertexSelectionColor(String themeColorId) {
+ this.vertexSelectionColor = new GColor(themeColorId);
+ defaultRegistrations.add(VERTEX_SELECTION_COLOR);
+ }
+
/**
* Returns the color for edge selections
* @return the color fore edge selections
@@ -475,13 +538,24 @@ public class GraphDisplayOptions implements OptionsChangeListener {
}
/**
- * Sets the edge selection color
+ * Sets the edge selection color. Using the method means the color will not appear in the
+ * tool options.
* @param edgeSelectionColor color to use for highlighting selected edges
*/
public void setEdgeSelectionColor(Color edgeSelectionColor) {
this.edgeSelectionColor = edgeSelectionColor;
}
+ /**
+ * Sets the edge selection color using the theme color defined by the given color id. This
+ * method will allow the property to be registered to the tool options.
+ * @param themeColorId the color id to use for highlighting edges.
+ */
+ public void setEdgeSelectionColor(String themeColorId) {
+ this.edgeSelectionColor = new GColor(themeColorId);
+ defaultRegistrations.add(EDGE_SELECTION_COLOR);
+ }
+
/**
* Returns the name of the default graph layout algorithm
* @return the name of the default graph layout algorithms
@@ -543,6 +617,11 @@ public class GraphDisplayOptions implements OptionsChangeListener {
this.font = font;
}
+ public void setFont(String themeFontId) {
+ this.themeFontId = themeFontId;
+ this.font = Gui.getFont(themeFontId);
+ }
+
/**
* Returns the font being used to render vertex labels
* @return the font being used to render vertex labels
@@ -617,25 +696,48 @@ public class GraphDisplayOptions implements OptionsChangeListener {
}
/**
- * Sets default values for vertex types
+ * Sets default values for vertex types. This method does not allow the vertexType color to
+ * be eligible to be registered as a tool option.
* @param vertexType the vertex type whose default color and shape are being defined
* @param vertexShape the default vertex shape for the given vertex type
* @param color the default color for the given vertex type
*/
protected void configureVertexType(String vertexType, VertexShape vertexShape, Color color) {
- checkVertexType(vertexType);
- vertexShapeMap.put(vertexType, vertexShape);
- vertexColorMap.put(vertexType, color);
+ setVertexColor(vertexType, color);
+ setVertexShape(vertexType, vertexShape);
}
/**
- * Sets default values for edge types
+ * Sets default values for vertex types using theme color ids. This makes them eligible to be
+ * registered as tool options.
+ * @param vertexType the vertex type whose default color and shape are being defined
+ * @param vertexShape the default vertex shape for the given vertex type
+ * @param themeColorId the color id for the theme color to be used as the color.
+ */
+ protected void configureVertexType(String vertexType, VertexShape vertexShape,
+ String themeColorId) {
+ setVertexColor(vertexType, themeColorId);
+ setVertexShape(vertexType, vertexShape);
+ }
+
+ /**
+ * Sets default values for edge types. This method does not allow the vertexType color to
+ * be eligible to be registered as a tool option.
* @param edgeType the edge type whose default color and shape are being defined
* @param color the default color for the given edge type
*/
protected void configureEdgeType(String edgeType, Color color) {
- checkEdgeType(edgeType);
- edgeColorMap.put(edgeType, color);
+ setEdgeColor(edgeType, color);
+ }
+
+ /**
+ * Sets default values for edge types using theme color ids. This makes them eligible to be
+ * registered as tool options.
+ * @param edgeType the edge type whose default color and shape are being defined
+ * @param themeColorId the color id for the theme color to be used as the color.
+ */
+ protected void configureEdgeType(String edgeType, String themeColorId) {
+ setEdgeColor(edgeType, themeColorId);
}
/**
@@ -727,8 +829,10 @@ public class GraphDisplayOptions implements OptionsChangeListener {
Options options = rootOptions.getOptions(VERTEX_COLORS);
for (String vertexType : graphType.getVertexTypes()) {
- options.registerOption(vertexType, OptionType.COLOR_TYPE, getVertexColor(vertexType),
- help, "Choose the color for this vertex type");
+ if (vertexRegistrations.contains(vertexType)) {
+ options.registerOption(vertexType, OptionType.COLOR_TYPE,
+ getVertexColor(vertexType), help, "Choose the color for this vertex type");
+ }
}
List<String> list = new ArrayList<>(graphType.getVertexTypes());
OptionsEditor editor = new ScrollableOptionsEditor(VERTEX_COLORS, list);
@@ -755,8 +859,10 @@ public class GraphDisplayOptions implements OptionsChangeListener {
Options options = rootOptions.getOptions(EDGE_COLORS);
for (String edgeType : graphType.getEdgeTypes()) {
- options.registerOption(edgeType, OptionType.COLOR_TYPE, getEdgeColor(edgeType), help,
- "Choose the color for this edge type");
+ if (edgeRegistrations.contains(edgeType)) {
+ options.registerOption(edgeType, OptionType.COLOR_TYPE, getEdgeColor(edgeType),
+ help, "Choose the color for this edge type");
+ }
}
List<String> list = new ArrayList<>(graphType.getEdgeTypes());
OptionsEditor editor = new ScrollableOptionsEditor(EDGE_COLORS, list);
@@ -764,29 +870,45 @@ public class GraphDisplayOptions implements OptionsChangeListener {
}
private void registerMiscellaneousOptions(Options rootOptions, HelpLocation help) {
+ List<String> optionNamesInDisplayOrder = new ArrayList<>();
Options options = rootOptions.getOptions(MISCELLANEOUS_OPTIONS);
+ optionNamesInDisplayOrder.add(MAX_NODES_SIZE);
options.registerOption(MAX_NODES_SIZE, OptionType.INT_TYPE, maxNodeCount, help,
"Graphs with more than this number of nodes will not be displayed. (Large graphs can cause Ghidra to become unstable/sluggish)");
StringWithChoicesEditor editor = new StringWithChoicesEditor(VertexShape.getShapeNames());
- options.registerOption(VERTEX_SELECTION_COLOR, OptionType.COLOR_TYPE, vertexSelectionColor,
- help, "Color for highlighting selected vertices");
+ if (defaultRegistrations.contains(VERTEX_SELECTION_COLOR)) {
+ optionNamesInDisplayOrder.add(VERTEX_SELECTION_COLOR);
+ options.registerOption(VERTEX_SELECTION_COLOR, OptionType.COLOR_TYPE,
+ vertexSelectionColor, help, "Color for highlighting selected vertices");
+ }
- options.registerOption(EDGE_SELECTION_COLOR, OptionType.COLOR_TYPE, edgeSelectionColor,
- help, "Color for highlighting selected edge");
+ if (defaultRegistrations.contains(EDGE_SELECTION_COLOR)) {
+ optionNamesInDisplayOrder.add(EDGE_SELECTION_COLOR);
+ options.registerOption(EDGE_SELECTION_COLOR, OptionType.COLOR_TYPE, edgeSelectionColor,
+ help, "Color for highlighting selected edge");
+ }
+ if (defaultRegistrations.contains(DEFAULT_VERTEX_COLOR)) {
+ optionNamesInDisplayOrder.add(DEFAULT_VERTEX_COLOR);
+ options.registerOption(DEFAULT_VERTEX_COLOR, OptionType.COLOR_TYPE, defaultVertexColor,
+ help, "Color for vertices that have no vertex type defined");
+ }
+
+ if (defaultRegistrations.contains(DEFAULT_EDGE_COLOR)) {
+ optionNamesInDisplayOrder.add(DEFAULT_EDGE_COLOR);
+ options.registerOption(DEFAULT_EDGE_COLOR, OptionType.COLOR_TYPE, defaultEdgeColor,
+ help, "Color for edge that have no edge type defined");
+ }
+
+ optionNamesInDisplayOrder.add(DEFAULT_VERTEX_SHAPE);
options.registerOption(DEFAULT_VERTEX_SHAPE, OptionType.STRING_TYPE,
defaultVertexShape.getName(), help,
"Shape for vertices that have no vertex type defined", editor);
- options.registerOption(DEFAULT_VERTEX_COLOR, OptionType.COLOR_TYPE, defaultVertexColor,
- help, "Color for vertices that have no vertex type defined");
-
- options.registerOption(DEFAULT_EDGE_COLOR, OptionType.COLOR_TYPE, defaultEdgeColor, help,
- "Color for edge that have no edge type defined");
-
+ optionNamesInDisplayOrder.add(FAVORED_EDGE_TYPE);
List<String> edgeTypes = graphType.getEdgeTypes();
if (!edgeTypes.isEmpty()) {
editor = new StringWithChoicesEditor(edgeTypes);
@@ -794,32 +916,24 @@ public class GraphDisplayOptions implements OptionsChangeListener {
"Favored edge is used to influence layout algorithms", editor);
}
+ optionNamesInDisplayOrder.add(DEFAULT_LAYOUT_ALGORITHM);
editor = new StringWithChoicesEditor(LayoutAlgorithmNames.getLayoutAlgorithmNames());
options.registerOption(DEFAULT_LAYOUT_ALGORITHM, OptionType.STRING_TYPE,
defaultLayoutAlgorithmName, help, "Initial layout algorithm", editor);
- options.registerOption(USE_ICONS, OptionType.BOOLEAN_TYPE, useIcons, help,
- "If true, vertices are drawn using pre-rendered images versus compact shapes");
-
+ optionNamesInDisplayOrder.add(LABEL_POSITION);
options.registerOption(LABEL_POSITION, OptionType.ENUM_TYPE, labelPosition, help,
"Relative postion of labels to vertex shape (Only applicable if \"Use Icons\" is true");
- options.registerOption(FONT, OptionType.FONT_TYPE, font, help,
- "Font to use for vertex labels");
-
- List<String> optionNamesInDisplayOrder = new ArrayList<>();
+ if (themeFontId != null) {
+ optionNamesInDisplayOrder.add(FONT);
+ options.registerOption(FONT, OptionType.FONT_TYPE, themeFontId, help,
+ "Font to use for vertex labels");
+ }
- optionNamesInDisplayOrder.add(MAX_NODES_SIZE);
- optionNamesInDisplayOrder.add(VERTEX_SELECTION_COLOR);
- optionNamesInDisplayOrder.add(EDGE_SELECTION_COLOR);
- optionNamesInDisplayOrder.add(DEFAULT_VERTEX_COLOR);
- optionNamesInDisplayOrder.add(DEFAULT_EDGE_COLOR);
- optionNamesInDisplayOrder.add(DEFAULT_VERTEX_SHAPE);
- optionNamesInDisplayOrder.add(FAVORED_EDGE_TYPE);
- optionNamesInDisplayOrder.add(DEFAULT_LAYOUT_ALGORITHM);
- optionNamesInDisplayOrder.add(LABEL_POSITION);
- optionNamesInDisplayOrder.add(FONT);
optionNamesInDisplayOrder.add(USE_ICONS);
+ options.registerOption(USE_ICONS, OptionType.BOOLEAN_TYPE, useIcons, help,
+ "If true, vertices are drawn using pre-rendered images versus compact shapes");
OptionsEditor optionsEditor =
new ScrollableOptionsEditor(MISCELLANEOUS_OPTIONS, optionNamesInDisplayOrder);
diff --git a/Ghidra/Framework/Project/data/project.theme.properties b/Ghidra/Framework/Project/data/project.theme.properties
index 9c26ee46f6..b9533c2bbe 100644
--- a/Ghidra/Framework/Project/data/project.theme.properties
+++ b/Ghidra/Framework/Project/data/project.theme.properties
@@ -82,6 +82,10 @@ icon.project.info.convert = wand.png
icon.extension.configure = plugin.png
icon.plugin.manager.default = plasma.png
+font.help.about = font.monospaced
+font.keybindings.status = SansSerif-PLAIN-11
+font.task.viewer = SansSerif-BOLD-36
+font.user.agreement = SansSerif-PLAIN-16
[Dark Defaults]
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/core/help/AboutDomainObjectUtils.java b/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/core/help/AboutDomainObjectUtils.java
index cfca80bd71..0dd3b1bf97 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/core/help/AboutDomainObjectUtils.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/core/help/AboutDomainObjectUtils.java
@@ -30,6 +30,7 @@ import docking.dnd.GClipboard;
import docking.dnd.StringTransferable;
import docking.widgets.OptionDialog;
import docking.widgets.label.GIconLabel;
+import generic.theme.Gui;
import generic.theme.GThemeDefaults.Colors.Java;
import ghidra.framework.model.DomainFile;
import ghidra.framework.plugintool.PluginTool;
@@ -38,6 +39,7 @@ import ghidra.util.Msg;
import ghidra.util.layout.PairLayout;
public class AboutDomainObjectUtils {
+ private static final String FONT_ID = "font.help.about";
private static final MouseListener COPY_MOUSE_LISTENER = new PopupMouseListener();
@@ -88,7 +90,6 @@ public class AboutDomainObjectUtils {
private static JComponent getAboutPanel(DomainFile domainFile, Map<String, String> metadata,
String additionalInfo) {
- Font font = new Font("Monospaced", Font.PLAIN, 12);
JPanel aboutPanel = new JPanel(new PairLayout());
JScrollPane propertyScroll = new JScrollPane(aboutPanel);
@@ -111,7 +112,7 @@ public class AboutDomainObjectUtils {
if (additionalInfo != null && additionalInfo.length() > 0) {
JTextArea auxArea = new JTextArea(additionalInfo);
- auxArea.setFont(font);
+ Gui.registerFont(auxArea, FONT_ID);
DockingUtils.setTransparent(auxArea);
auxArea.setEditable(false);
auxArea.setCaretPosition(0); // move cursor to BOF...
@@ -136,7 +137,7 @@ public class AboutDomainObjectUtils {
Component[] comps = aboutPanel.getComponents();
for (Component comp : comps) {
- comp.setFont(font);
+ Gui.registerFont(comp, FONT_ID);
}
aboutPanel.invalidate();
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/ImportGhidraToolsDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/ImportGhidraToolsDialog.java
index 235f27074f..2d8de9eea8 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/ImportGhidraToolsDialog.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/ImportGhidraToolsDialog.java
@@ -223,7 +223,7 @@ class ImportGhidraToolsDialog extends DialogComponentProvider {
if (boldFont == null) {
Font font = list.getFont();
- boldFont = new Font(font.getName(), font.getStyle() | Font.BOLD, font.getSize());
+ boldFont = font.deriveFont(font.getStyle() | Font.BOLD);
}
if (index == -1) {
int selected = list.getSelectedIndex();
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SaveDataDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SaveDataDialog.java
index b6241928c4..5eb54c70f9 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SaveDataDialog.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/SaveDataDialog.java
@@ -283,7 +283,7 @@ public class SaveDataDialog extends DialogComponentProvider {
if (boldFont == null) {
Font font = list.getFont();
- boldFont = new Font(font.getName(), font.getStyle() | Font.BOLD, font.getSize());
+ boldFont = font.deriveFont(font.getStyle() | Font.BOLD);
}
// set color to red if file cannot be saved 'as is'
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/UserAgreementDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/UserAgreementDialog.java
index b2cc8fb9d4..bdb487faf0 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/UserAgreementDialog.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/UserAgreementDialog.java
@@ -26,6 +26,7 @@ import docking.DockingWindowManager;
import docking.framework.DockingApplicationConfiguration;
import docking.framework.DockingApplicationLayout;
import docking.widgets.label.GDLabel;
+import generic.theme.Gui;
import ghidra.framework.Application;
import ghidra.util.HTMLUtilities;
import ghidra.util.Msg;
@@ -36,12 +37,11 @@ import utility.application.ApplicationLayout;
public class UserAgreementDialog extends DialogComponentProvider {
private static final String USER_AGREEMENT_FILENAME = "UserAgreement.html";
- private boolean showAgreementChoices;
+ private static final String FONT_ID = "font.user.agreement";
private boolean exitOnCancel;
public UserAgreementDialog(boolean showAgreementChoices, boolean exitOnCancel) {
super("", true, false, true, false);
- this.showAgreementChoices = showAgreementChoices;
this.exitOnCancel = exitOnCancel;
addWorkPanel(buildWorkPanel());
addOKButton();
@@ -57,7 +57,7 @@ public class UserAgreementDialog extends DialogComponentProvider {
}
private JComponent buildWorkPanel() {
- Font font = new Font("Default", Font.PLAIN, 16);
+ Font font = Gui.getFont(FONT_ID);
JPanel panel = new JPanel(new BorderLayout());
JLabel label = new GDLabel("Ghidra User Agreement", SwingConstants.CENTER);
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/KeyBindingsPanel.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/KeyBindingsPanel.java
index cf7c282814..fcc5185041 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/KeyBindingsPanel.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/KeyBindingsPanel.java
@@ -36,6 +36,7 @@ import docking.tool.util.DockingToolConstants;
import docking.widgets.*;
import docking.widgets.label.GIconLabel;
import docking.widgets.table.*;
+import generic.theme.Gui;
import generic.util.action.ReservedKeyBindings;
import ghidra.framework.options.Options;
import ghidra.framework.options.ToolOptions;
@@ -60,7 +61,7 @@ public class KeyBindingsPanel extends JPanel {
private final static int KEY_BINDING = 1;
private final static int PLUGIN_NAME = 2;
- private static final int FONT_SIZE = 11;
+ private static final String FONT_ID = "font.keybindings.status";
private JTextPane statusLabel;
private GTable actionTable;
@@ -236,9 +237,7 @@ public class KeyBindingsPanel extends JPanel {
// make sure the label gets enough space
statusLabel.setPreferredSize(new Dimension(0, STATUS_LABEL_HEIGHT));
-
- Font f = new Font("SansSerif", Font.PLAIN, FONT_SIZE);
- statusLabel.setFont(f);
+ statusLabel.setFont(Gui.getFont(FONT_ID));
helpButton = new EmptyBorderButton(Icons.HELP_ICON);
helpButton.setEnabled(false);
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java
index 07dd42def6..1c49721a1b 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/dialog/PluginInstallerDialog.java
@@ -237,8 +237,7 @@ public class PluginInstallerDialog extends DialogComponentProvider {
NameCellRenderer() {
defaultFont = getFont();
- boldFont = new Font(defaultFont.getName(), defaultFont.getStyle() | Font.BOLD,
- defaultFont.getSize());
+ boldFont = defaultFont.deriveFont(defaultFont.getStyle() | Font.BOLD);
setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
}
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/task/gui/taskview/TaskViewer.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/task/gui/taskview/TaskViewer.java
index ba5c9f577d..829e787adf 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/task/gui/taskview/TaskViewer.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/task/gui/taskview/TaskViewer.java
@@ -27,6 +27,7 @@ import org.jdesktop.animation.timing.*;
import docking.util.GraphicsUtils;
import generic.theme.GThemeDefaults.Colors.Palette;
+import generic.theme.Gui;
import ghidra.framework.task.*;
import ghidra.framework.task.gui.GProgressBar;
import ghidra.util.SystemUtilities;
@@ -248,6 +249,7 @@ public class TaskViewer {
}
private class MessageCanvas extends JComponent {
+ private static final String FONT_ID = "font.task.viewer";
private Rectangle messageDimension;
@Override
@@ -258,7 +260,7 @@ public class TaskViewer {
Graphics2D g2 = (Graphics2D) g;
g2.setComposite(SCROLLED_TEXT_ALPHA_COMPOSITE);
- Font font = new Font("Sanf Serif", Font.BOLD, 36);
+ Font font = Gui.getFont(FONT_ID);
g.setFont(font);
g.setColor(Palette.BLUE);
if (messageDimension == null) {
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformer.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformer.java
index 2ee82d5b61..b7800805aa 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformer.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformer.java
@@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils;
import docking.framework.DockingApplicationConfiguration;
import docking.widgets.label.GDLabel;
import generic.theme.GThemeDefaults.Colors.Messages;
+import generic.theme.Gui;
import ghidra.GhidraApplicationLayout;
import ghidra.GhidraLaunchable;
import ghidra.framework.Application;
@@ -895,7 +896,7 @@ public class DataTypeArchiveTransformer implements GhidraLaunchable {
});
// Fix up the default fonts that Java 1.5.0 changed to Courier, which looked terrible.
- Font f = new Font("Monospaced", Font.PLAIN, 12);
+ Font f = Gui.getFont("font.monospaced");
UIManager.put("PasswordField.font", f);
UIManager.put("TextArea.font", f);
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformerPanel.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformerPanel.java
index a00cf45c2f..b056f0a037 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformerPanel.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/data/DataTypeArchiveTransformerPanel.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import javax.swing.*;
+import docking.options.editor.ButtonPanelFactory;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.filechooser.GhidraFileChooser;
import docking.widgets.label.GHtmlLabel;
@@ -86,7 +87,7 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
gbc.gridx = 2;
gbc.gridwidth = 1;
- JButton oldBrowseButton = new JButton(DOT_DOT_DOT);
+ JButton oldBrowseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
oldBrowseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -98,8 +99,6 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
}
}
});
- Font font = oldBrowseButton.getFont();
- oldBrowseButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
filePanel.add(oldBrowseButton, gbc);
gbc.gridx = 3;
@@ -125,7 +124,7 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
gbc.gridx = 2;
gbc.gridwidth = 1;
- JButton newBrowseButton = new JButton(DOT_DOT_DOT);
+ JButton newBrowseButton = ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
newBrowseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -137,8 +136,6 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
}
}
});
- Font font = newBrowseButton.getFont();
- newBrowseButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
filePanel.add(newBrowseButton, gbc);
}
@@ -158,7 +155,9 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
gbc.gridx = 2;
gbc.gridwidth = 1;
- JButton destinationBrowseButton = new JButton(DOT_DOT_DOT);
+ JButton destinationBrowseButton =
+ ButtonPanelFactory.createButton(ButtonPanelFactory.BROWSE_TYPE);
+
destinationBrowseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -170,8 +169,6 @@ public class DataTypeArchiveTransformerPanel extends JPanel {
}
}
});
- Font font = destinationBrowseButton.getFont();
- destinationBrowseButton.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
filePanel.add(destinationBrowseButton, gbc);
}