From a72473efd0f5c6a57017a0e7ebf04bfee0eea803 Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 6 Jun 2002 18:22:46 +0000 Subject: [PATCH] skinnable ui dreck --- processing/app/PdeApplet.java | 15 ++++++------ processing/app/PdeEditor.java | 25 +++++++++++++------- processing/app/PdeEditorButtons.java | 5 +++- processing/app/PdeEditorHeader.java | 23 +++++++++++++++---- processing/app/PdeEditorStatus.java | 34 ++++++++++++++++++---------- 5 files changed, 70 insertions(+), 32 deletions(-) diff --git a/processing/app/PdeApplet.java b/processing/app/PdeApplet.java index ebacde0e7..bfe896dcd 100644 --- a/processing/app/PdeApplet.java +++ b/processing/app/PdeApplet.java @@ -307,13 +307,14 @@ public class PdeApplet extends Applet return !isApplet(); } - static public Font getFont(String which) { - if (which.equals("editor")) { - // 'Monospaced' and 'courier' also caused problems.. ;-/ - //return new Font("monospaced", Font.PLAIN, 12); - return new Font("Monospaced", Font.PLAIN, 12); - } - return null; + static public Font getFont(String which, Font otherwise) { + //System.out.println("getting font '" + which + "'"); + String str = get(which); + if (str == null) return otherwise; // ENABLE LATER + StringTokenizer st = new StringTokenizer(str, ","); + return new Font(st.nextToken(), + st.nextToken().equals("bold") ? Font.BOLD : Font.PLAIN, + Integer.parseInt(st.nextToken())); } #endif // PLAYER diff --git a/processing/app/PdeEditor.java b/processing/app/PdeEditor.java index 8b858bbc9..030fe9245 100644 --- a/processing/app/PdeEditor.java +++ b/processing/app/PdeEditor.java @@ -63,7 +63,6 @@ public class PdeEditor extends Panel /*implements PdeEnvironment*/ { Label dummy = new Label(); dummy.setBackground(buttonBgColor); - //dummy.setBackground(new Color(0, 100, 0)); leftPanel.add("Center", dummy); add("West", leftPanel); @@ -113,9 +112,14 @@ public class PdeEditor extends Panel /*implements PdeEnvironment*/ { */ if (program == null) program = DEFAULT_PROGRAM; - textarea = new TextArea(program, 20, 60, - TextArea.SCROLLBARS_VERTICAL_ONLY); - textarea.setFont(PdeApplet.getFont("editor")); + textarea = + new TextArea(program, + PdeApplet.getInteger("editor.program.rows", 20), + PdeApplet.getInteger("editor.program.columns", 60), + TextArea.SCROLLBARS_VERTICAL_ONLY); + textarea.setFont(PdeApplet.getFont("editor.program.font", + new Font("Monospaced", + Font.PLAIN, 12))); //right.add("Center", textarea); rightPanel.add("Center", textarea); @@ -131,14 +135,19 @@ public class PdeEditor extends Panel /*implements PdeEnvironment*/ { statusPanel.add("North", errorLabel); */ status = new PdeEditorStatus(this); - statusPanel.add("North", status); + statusPanel.add("North", status); PdeEditorLabel stdoutLabel = new PdeEditorLabel(2); - Color stdoutBgColor = new Color(26, 26, 26); - Color stdoutFgColor = new Color(153, 153, 153); + Color stdoutBgColor = + PdeApplet.getColor("editor.console.bgcolor", new Color(26, 26, 26)); + Color stdoutFgColor = + PdeApplet.getColor("editor.console.fgcolor", new Color(153, 153, 153)); stdoutLabel.setBackground(stdoutBgColor); stdoutLabel.setForeground(stdoutFgColor); - stdoutLabel.setFont(new Font("monospaced", Font.PLAIN, 11)); + Font stdoutFont = + PdeApplet.getFont("editor.console.font", + new Font("monospaced", Font.PLAIN, 11)); + stdoutLabel.setFont(stdoutFont); //stdoutLabel.setText("Test the print"); //stdoutLabel.setInsets(new Insets(4, 4, 4, 4)); statusPanel.add("South", stdoutLabel); diff --git a/processing/app/PdeEditorButtons.java b/processing/app/PdeEditorButtons.java index 713b86797..250ae9e1f 100644 --- a/processing/app/PdeEditorButtons.java +++ b/processing/app/PdeEditorButtons.java @@ -83,7 +83,10 @@ public class PdeEditorButtons extends Panel { setLayout(null); status = new Label(); - status.setFont(new Font("SansSerif", Font.PLAIN, 10)); + status.setFont(PdeApplet.getFont("editor.buttons.status.font", + new Font("SansSerif", Font.PLAIN, 10))); + status.setForeground(PdeApplet.getColor("editor.buttons.status.color", + Color.black)); //status.setForeground(Color.black); //status.setBackground(Color.yellow); add(status); diff --git a/processing/app/PdeEditorHeader.java b/processing/app/PdeEditorHeader.java index 5ce6d28f3..d4f8b4be6 100644 --- a/processing/app/PdeEditorHeader.java +++ b/processing/app/PdeEditorHeader.java @@ -16,9 +16,13 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ { static final String PROJECT_TITLER = "sketch"; static final String USER_TITLER = "user"; - static final Color primaryColor = Color.white; - static final Color secondaryColor = new Color(153, 153, 153); - static final Color backgroundColor = new Color(51, 51, 51); + //static final Color primaryColor = Color.white; + //static final Color secondaryColor = new Color(153, 153, 153); + //static final Color backgroundColor = new Color(51, 51, 51); + + static Color primaryColor; // = Color.white; + static Color secondaryColor; // = new Color(153, 153, 153); + static Color backgroundColor; // = new Color(51, 51, 51); PdeEditor editor; @@ -45,6 +49,15 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ { this.editor = editor; this.project = project; this.user = user; + + if (primaryColor == null) { + backgroundColor = PdeApplet.getColor("editor.header.bgcolor", + new Color(51, 51, 51)); + primaryColor = PdeApplet.getColor("editor.header.fgcolor1", + new Color(255, 255, 255)); + secondaryColor = PdeApplet.getColor("editor.header.fgcolor2", + new Color(153, 153, 153)); + } } @@ -97,7 +110,9 @@ public class PdeEditorHeader extends Panel /* implements ActionListener*/ { Graphics g = offscreen.getGraphics(); if (font == null) { - font = new Font("SansSerif", Font.PLAIN, 12); + //font = new Font("SansSerif", Font.PLAIN, 12); + font = PdeApplet.getFont("editor.header.font", + new Font("SansSerif", Font.PLAIN, 12)); g.setFont(font); metrics = g.getFontMetrics(); fontAscent = metrics.getAscent(); diff --git a/processing/app/PdeEditorStatus.java b/processing/app/PdeEditorStatus.java index 491d88627..78d7d7c07 100644 --- a/processing/app/PdeEditorStatus.java +++ b/processing/app/PdeEditorStatus.java @@ -3,18 +3,9 @@ import java.awt.event.*; public class PdeEditorStatus extends Panel implements ActionListener { + static Color bgColor[]; + static Color fgColor[]; - static final Color bgColor[] = { - new Color(102, 102, 102), - new Color(102, 26, 0), - new Color(204, 153, 0) - }; - - static final Color fgColor[] = { - new Color(255, 255, 255), - new Color(255, 255, 255), - new Color(0, 0, 0) - }; static final int NOTICE = 0; static final int ERROR = 1; @@ -47,6 +38,23 @@ public class PdeEditorStatus extends Panel implements ActionListener { public PdeEditorStatus(PdeEditor editor) { this.editor = editor; empty(); + + if (bgColor == null) { + bgColor = new Color[3]; + bgColor[0] = PdeApplet.getColor("editor.status.notice.bgcolor", + new Color(102, 102, 102)); + bgColor[1] = PdeApplet.getColor("editor.status.error.bgcolor", + new Color(102, 26, 0)); + bgColor[2] = PdeApplet.getColor("editor.status.prompt.bgcolor", + new Color(204, 153, 0)); + fgColor = new Color[3]; + fgColor[0] = PdeApplet.getColor("editor.status.notice.fgcolor", + new Color(255, 255, 255)); + fgColor[1] = PdeApplet.getColor("editor.status.error.fgcolor", + new Color(255, 255, 255)); + fgColor[2] = PdeApplet.getColor("editor.status.prompt.fgcolor", + new Color(0, 0, 0)); + } } @@ -145,7 +153,9 @@ public class PdeEditorStatus extends Panel implements ActionListener { Graphics g = offscreen.getGraphics(); if (font == null) { - font = new Font("SansSerif", Font.PLAIN, 10); + font = PdeApplet.getFont("editor.status.font", + new Font("SansSerif", Font.PLAIN, 10)); + //font = new Font("SansSerif", Font.PLAIN, 10); g.setFont(font); metrics = g.getFontMetrics(); fontAscent = metrics.getAscent();