Skip to content

Commit

Permalink
Fixes two Mac display issues. Now it looks good on OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
zathras committed Apr 15, 2018
1 parent 7114d07 commit 2b15912
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/com/jovial/jrpn/GButton.java
Expand Up @@ -174,11 +174,17 @@ protected void drawWhiteLabel(Graphics2D g, int offsetX, int offsetY) {
// joins the sqrt symbol.
public static class Sqrt extends GButton {
int sqrtWidth;
int overlineWidth;
int xWidth;
int blueHeight;
private final static String overline = "\u203E\u203E";
@Override
public void alignText() {
super.alignText();
sqrtWidth = scaleInfo.blueFontMetrics.stringWidth("\u221A"); // √
FontMetrics fm = scaleInfo.blueFontMetrics;
sqrtWidth = fm.stringWidth("\u221A"); // √
overlineWidth = fm.stringWidth(overline);
xWidth = fm.stringWidth("x");
blueHeight = scaleInfo.blueFontMetrics.getAscent();
}

Expand All @@ -202,9 +208,11 @@ protected void drawBlueLabel(Graphics2D g, int offsetX, int offsetY) {
shiftLeft = 1;
}
// TODO: Make the shiftLeft factor and minimum be items that can be configured.
y -= shiftUp;
x += sqrtWidth - shiftLeft;
g.drawString("x\u0305", x, y);
y -= shiftUp;
g.drawString("x", x + (overlineWidth - xWidth)/2, y);
g.drawString("\u203E\u203E", x, y);
// I saw an issue on OSX with combining overline (\u0305)
}
}
}
3 changes: 2 additions & 1 deletion src/com/jovial/jrpn/fmMain.java
Expand Up @@ -318,10 +318,11 @@ private void initComponents() throws InterruptedException {
jSeparator7 = new javax.swing.JPopupMenu.Separator();
mHelpAbout = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
System.exit(0);
}
});
addComponentListener(new java.awt.event.ComponentAdapter() {
Expand Down

0 comments on commit 2b15912

Please sign in to comment.