new tabs graphics, new colors, horizontally aligned toolbar

This commit is contained in:
benfry
2005-03-31 07:03:54 +00:00
parent d9dc850322
commit 733ff72e6b
17 changed files with 139 additions and 93 deletions

View File

@@ -76,9 +76,13 @@ public class PdeEditor extends JFrame
JSplitPane splitPane;
JPanel consolePanel;
JLabel lineNumberComponent;
// currently opened program
public PdeSketch sketch;
PdeEditorLineStatus lineStatus;
public JEditTextArea textarea;
PdeEditorListener listener;
@@ -171,23 +175,35 @@ public class PdeEditor extends JFrame
Container pain = getContentPane();
pain.setLayout(new BorderLayout());
buttons = new PdeEditorButtons(this);
pain.add("West", buttons);
Box box = Box.createVerticalBox();
JPanel rightPanel = new JPanel();
rightPanel.setLayout(new BorderLayout());
Box upper = Box.createVerticalBox();
//JPanel box = new JPanel();
//box.setLayout(new FlowLayout(FlowLayout.VERTICAL));
buttons = new PdeEditorButtons(this);
//pain.add("West", buttons);
//box.add(buttons);
upper.add(buttons);
//JPanel rightPanel = new JPanel();
//rightPanel.setLayout(new BorderLayout());
header = new PdeEditorHeader(this);
rightPanel.add(header, BorderLayout.NORTH);
//rightPanel.add(header, BorderLayout.NORTH);
//box.add(header);
upper.add(header);
textarea = new JEditTextArea(new PdeTextAreaDefaults());
textarea.setRightClickPopup(new TextAreaPopup());
textarea.setTokenMarker(new PdeKeywords());
textarea.setHorizontalOffset(5);
textarea.setHorizontalOffset(6);
//textarea.setBorder(new EmptyBorder(0, 20, 0, 0));
//textarea.setBackground(Color.white);
//textarea.setMaximumSize(new Dimension(3000, 3000));
// assemble console panel, consisting of status area and the console itself
consolePanel = new JPanel();
//System.out.println(consolePanel.getInsets());
@@ -199,13 +215,27 @@ public class PdeEditor extends JFrame
console = new PdeEditorConsole(this);
consolePanel.add(console, BorderLayout.CENTER);
/*
lineNumberComponent = new JLabel(" 1234"); //, JLabel.LEFT);
lineNumberComponent.setBackground(Color.BLACK);
lineNumberComponent.setForeground(Color.WHITE);
lineNumberComponent.setFont(new Font("SansSerif", Font.PLAIN, 10));
box.add(lineNumberComponent);
*/
lineStatus = new PdeEditorLineStatus(textarea);
consolePanel.add(lineStatus, BorderLayout.SOUTH);
//box.add(lineStatus);
upper.add(textarea);
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
textarea, consolePanel);
upper, consolePanel);
//textarea, consolePanel);
splitPane.setOneTouchExpandable(true);
// repaint child panes while resizing
splitPane.setContinuousLayout(true);
// if window increases in size, give all of increase to textarea (top pane)
// if window increases in size, give all of increase to
// the textarea in the uppper pane
splitPane.setResizeWeight(1D);
// to fix ugliness.. normally macosx java 1.3 puts an
@@ -220,14 +250,25 @@ public class PdeEditor extends JFrame
splitPane.setDividerSize(dividerSize);
}
rightPanel.add(splitPane, BorderLayout.CENTER);
splitPane.setMinimumSize(new Dimension(600, 600));
//splitPane.setBackground(Color.RED);
//splitPane.setMaximumSize(new Dimension(3000, 3000));
///rightPanel.add(splitPane, BorderLayout.CENTER);
box.add(splitPane);
pain.add("Center", rightPanel);
//setBackground(Color.green);
//box.add(textarea);
//box.add(consolePanel);
//pain.add("Center", rightPanel);
// hopefully these are no longer needed w/ swing
// (har har har.. that was wishful thinking)
listener = new PdeEditorListener(this, textarea);
textarea.pdeEditorListener = listener;
//textarea.editorListener = listener;
//pain.add("West", box);
pain.add(box);
// set the undo stuff for this feller
Document document = textarea.getDocument();

View File

@@ -35,21 +35,22 @@ import javax.swing.event.*;
public class PdeEditorButtons extends JComponent implements MouseInputListener {
static final String title[] = {
"", "run", "stop", "new", "open", "save", "export"
"Run", "Stop", "New", "Open", "Save", "Export"
//"run", "stop", "new", "open", "save", "export"
};
static final int BUTTON_COUNT = title.length;
static final int BUTTON_WIDTH = PdePreferences.GRID_SIZE;
static final int BUTTON_HEIGHT = PdePreferences.GRID_SIZE;
static final int BUTTON_WIDTH = 27; //PdePreferences.GRID_SIZE;
static final int BUTTON_HEIGHT = 32; //PdePreferences.GRID_SIZE;
static final int BUTTON_GAP = 15; //BUTTON_WIDTH / 2;
static final int NOTHING = 0;
static final int RUN = 1;
static final int STOP = 2;
static final int RUN = 0;
static final int STOP = 1;
static final int NEW = 3;
static final int OPEN = 4;
static final int SAVE = 5;
static final int EXPORT = 6;
static final int NEW = 2;
static final int OPEN = 3;
static final int SAVE = 4;
static final int EXPORT = 5;
static final int INACTIVE = 0;
static final int ROLLOVER = 1;
@@ -78,13 +79,13 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
Image stateImage[];
int which[]; // mapping indices to implementation
int x1, x2;
int y1[], y2[];
int x1[], x2[];
int y1, y2;
String status;
Font statusFont;
Color statusColor;
int statusY;
//int statusY;
public PdeEditorButtons(PdeEditor editor) {
@@ -94,7 +95,7 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
buttonCount = 0;
which = new int[BUTTON_COUNT];
which[buttonCount++] = NOTHING;
//which[buttonCount++] = NOTHING;
which[buttonCount++] = RUN;
which[buttonCount++] = STOP;
which[buttonCount++] = NEW;
@@ -108,57 +109,36 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
status = "";
//setLayout(null);
//status = new JLabel();
statusFont = PdePreferences.getFont("buttons.status.font");
statusColor = PdePreferences.getColor("buttons.status.color");
//add(status);
//status.setBounds(-5, BUTTON_COUNT * BUTTON_HEIGHT,
// BUTTON_WIDTH + 15, BUTTON_HEIGHT);
//status.setAlignment(Label.CENTER);
statusY = (BUTTON_COUNT + 1) * BUTTON_HEIGHT;
//statusY = (BUTTON_COUNT + 1) * BUTTON_HEIGHT;
addMouseListener(this);
addMouseMotionListener(this);
}
/*
public void update() {
paint(this.getGraphics());
}
public void update(Graphics g) {
paint(g);
}
*/
//public void paintComponent(Graphics g) {
//super.paintComponent(g);
//}
public void paintComponent(Graphics screen) {
if (inactive == null) {
inactive = new Image[BUTTON_COUNT];
rollover = new Image[BUTTON_COUNT];
active = new Image[BUTTON_COUNT];
//state = new int[BUTTON_COUNT];
int IMAGE_SIZE = 33;
for (int i = 0; i < BUTTON_COUNT; i++) {
inactive[i] = createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
Graphics g = inactive[i].getGraphics();
g.drawImage(buttons, -(i*BUTTON_WIDTH), -2*BUTTON_HEIGHT, null);
g.drawImage(buttons, -(i*IMAGE_SIZE) - 3, -2*IMAGE_SIZE, null);
rollover[i] = createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
g = rollover[i].getGraphics();
g.drawImage(buttons, -(i*BUTTON_WIDTH), -1*BUTTON_HEIGHT, null);
g.drawImage(buttons, -(i*IMAGE_SIZE) - 3, -1*IMAGE_SIZE, null);
active[i] = createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
g = active[i].getGraphics();
g.drawImage(buttons, -(i*BUTTON_WIDTH), -0*BUTTON_HEIGHT, null);
g.drawImage(buttons, -(i*IMAGE_SIZE) - 3, -0*IMAGE_SIZE, null);
}
state = new int[buttonCount];
@@ -174,17 +154,18 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
width = size.width;
height = size.height;
x1 = 0;
x2 = BUTTON_WIDTH;
y1 = 0;
y2 = BUTTON_HEIGHT;
y1 = new int[buttonCount];
y2 = new int[buttonCount];
x1 = new int[buttonCount];
x2 = new int[buttonCount];
int offsetY = 0;
int offsetX = 3;
for (int i = 0; i < buttonCount; i++) {
y1[i] = offsetY;
y2[i] = offsetY + BUTTON_HEIGHT;
offsetY = y2[i];
x1[i] = offsetX;
if (i == 2) x1[i] += BUTTON_GAP;
x2[i] = x1[i] + BUTTON_WIDTH;
offsetX = x2[i];
}
}
Graphics g = offscreen.getGraphics();
@@ -192,24 +173,24 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
g.fillRect(0, 0, width, height);
for (int i = 0; i < buttonCount; i++) {
//g.drawImage(stateImage[i], x1[i], y1, null);
g.drawImage(stateImage[i], x1, y1[i], null);
g.drawImage(stateImage[i], x1[i], y1, null);
}
g.setColor(statusColor);
g.setFont(statusFont);
// if i ever find the guy who wrote the java2d api,
// i will hurt him. or just laugh in his face. or pity him.
/*
// if i ever find the guy who wrote the java2d api, i will hurt him.
Graphics2D g2 = (Graphics2D) g;
FontRenderContext frc = g2.getFontRenderContext();
float statusW = (float) statusFont.getStringBounds(status, frc).getWidth();
float statusX = (getSize().width - statusW) / 2;
//int statusWidth = g.getFontMetrics().stringWidth(status);
//int statusX = (getSize().width - statusWidth) / 2;
g2.drawString(status, statusX, statusY);
*/
//int statusY = (BUTTON_HEIGHT + statusFont.getAscent()) / 2;
int statusY = (BUTTON_HEIGHT + g.getFontMetrics().getAscent()) / 2;
g.drawString(status, buttonCount * BUTTON_WIDTH + 2 * BUTTON_GAP, statusY);
screen.drawImage(offscreen, 0, 0, null);
}
@@ -233,8 +214,8 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
public void handleMouse(int x, int y) {
if (currentRollover != -1) {
if ((y > y1[currentRollover]) && (x > x1) &&
(y < y2[currentRollover]) && (x < x2)) {
if ((x > x1[currentRollover]) && (y > y1) &&
(x < x2[currentRollover]) && (y < y2)) {
return;
} else {
@@ -258,13 +239,12 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
private int findSelection(int x, int y) {
// if app loads slowly and cursor is near the buttons
// when it comes up, the app may not have time to load
if ((y1 == null) || (y2 == null)) return -1;
if ((x1 == null) || (x2 == null)) return -1;
for (int i = 0; i < buttonCount; i++) {
if ((x > x1) && (y > y1[i]) &&
(x < x2) && (y < y2[i])) {
//if ((x > x1[i]) && (y > y1) &&
//(x < x2[i]) && (y < y2)) {
if ((y > y1) && (x > x1[i]) &&
(y < y2) && (x < x2[i])) {
//System.out.println("sel is " + i);
return i;
}
}
@@ -301,13 +281,7 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
if (state[OPEN] != INACTIVE) {
setState(OPEN, INACTIVE, true);
}
// kludge
//for (int i = 0; i < BUTTON_COUNT; i++) {
//messageClear(title[i]);
//}
status = "";
//mouseMove(e);
handleMouse(e.getX(), e.getY());
}
@@ -405,6 +379,7 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
status = msg;
}
public void messageClear(String msg) {
//if (status.getText().equals(msg + " ")) status.setText(PdeEditor.EMPTY);
if (status.equals(msg)) status = "";
@@ -412,6 +387,17 @@ public class PdeEditorButtons extends JComponent implements MouseInputListener {
public Dimension getPreferredSize() {
return new Dimension(BUTTON_WIDTH, (BUTTON_COUNT + 1)*BUTTON_HEIGHT);
return new Dimension((BUTTON_COUNT + 1)*BUTTON_WIDTH, BUTTON_HEIGHT);
//return new Dimension(BUTTON_WIDTH, (BUTTON_COUNT + 1)*BUTTON_HEIGHT);
}
public Dimension getMinimumSize() {
return getPreferredSize();
}
public Dimension getMaximumSize() {
return new Dimension(3000, BUTTON_HEIGHT);
}
}

View File

@@ -172,7 +172,8 @@ public class PdeEditorHeader extends JComponent {
hideItem.setEnabled(sketch.current != sketch.code[0]);
//int x = 0; //PdePreferences.GUI_SMALL;
int x = (PdeBase.platform == PdeBase.MACOSX) ? 0 : 1;
//int x = (PdeBase.platform == PdeBase.MACOSX) ? 0 : 1;
int x = 6; // offset from left edge of the component
for (int i = 0; i < sketch.codeCount; i++) {
PdeCode code = sketch.code[i];

View File

@@ -343,7 +343,8 @@ public class PdeSketchbook {
// rebuild the popup menu
menu.removeAll();
item = new JMenuItem("Open...");
//item = new JMenuItem("Open...");
item = PdeEditor.newJMenuItem("Open...", 'O', false);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.handleOpen(null);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -116,15 +116,15 @@ editor.eolmarkers.color=#99991A
editor.invalid=false
editor.invalid.style=#7E7E00,bold
buttons.bgcolor = #999988
buttons.status.font = SansSerif,plain,10
buttons.status.color = #333322
buttons.bgcolor = #66665A
buttons.status.font = SansSerif,plain,12
buttons.status.color = #FFFFFF
# settings for the tabs at the top
# actual tab images are stored in the lib/ folder
header.bgcolor = #4C4C3E
header.text.selected.color = #ffffff
header.text.unselected.color = #999988
header.bgcolor = #999988
header.text.selected.color = #1A1A00
header.text.unselected.color = #ffffff
header.text.font = SansSerif,plain,12
console = true
@@ -146,7 +146,7 @@ console.auto_clear = true
console.length = 500
status.notice.fgcolor = #ffffff
status.notice.bgcolor = #666666
status.notice.bgcolor = #bbbbaa
status.error.fgcolor = #ffffff
status.error.bgcolor = #662000
status.prompt.fgcolor = #000000
@@ -239,3 +239,9 @@ preproc.imports.jdk14 = javax.xml.parsers,javax.xml.transform,javax.xml.transfor
# set the browser to be used on linux
browser.linux = mozilla
# coloring for the editor line number status bar at the bottom of the screen
linestatus.bgcolor = #66665a
linestatus.font = SansSerif,plain,10
linestatus.color = #ffffff
linestatus.height = 20

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 B

After

Width:  |  Height:  |  Size: 55 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 B

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 B

After

Width:  |  Height:  |  Size: 54 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 B

After

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 B

After

Width:  |  Height:  |  Size: 63 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

After

Width:  |  Height:  |  Size: 100 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 B

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 B

After

Width:  |  Height:  |  Size: 61 B

View File

@@ -532,9 +532,9 @@ public class PApplet extends Applet
setBounds((winW - width)/2,
insets.top + ((winH - insets.top - insets.bottom) - height)/2,
winW, winH);
} else {
//} else {
//System.out.println("frame was null");
setBounds(0, 0, width, height);
//setBounds(0, 0, width, height);
}
}

View File

@@ -1,8 +1,15 @@
0079 core
_ size() doing a setBounds() is really bad
_ because it means things can't be embedded properly
_ printarr() of null array crashes without an error
_ actually, errors from many crashes not coming through on the mac?
_ proper full screen code for present mode
_ why do mouse motion events go away in full screen mode
_ or with a Window object
createGraphics and placement issues
_ make pappletgl work back inside papplet
_ and then size(300, 300, DEPTH) etc

View File

@@ -1,6 +1,10 @@
0079 pde
_ implement horizontal version of PdeEditorButtons
X add ctrl-o to the open menu
X implement horizontal version of PdeEditorButtons
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1076707944
X add line numbers
X add extra space to bottom on osx
...