Make first real commit: copy of CaRMetal 4.2.8

This commit is contained in:
Glen Whitney 2018-09-04 22:51:42 -04:00
parent 002acfc88e
commit c312811084
1120 changed files with 226843 additions and 1 deletions

BIN
eric/bar/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,678 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eric.bar;
import eric.JZirkelCanvas;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import eric.JEricPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import eric.controls.JCanvasButton;
import eric.controls.JCanvasPanel;
import eric.controls.JCanvasPopup;
import eric.controls.JCanvasSlider;
import eric.controls.JCanvasTxtfield;
import eric.textfieldpopup.JTextFieldPopup;
/**
*
* @author erichake
*/
public class JControlProperties extends JProperties {
/**
*
*/
JCanvasPanel JCP;
myJSliderShowTicks jsShowTicks;
myJSliderSnapTicks jsSnapTicks;
myJSliderMin jsMin;
myJSliderMax jsMax;
myJSliderTicks jsTicks;
myJComment jsComment;
myJSliderUnit jsUnit;
myJSliderShowComment jsShowcom;
myJSliderShowVal jsShowval;
myJSliderShowUnit jsShowunit;
myJPopupItems jsPopupitems;
public JControlProperties(final int w, final int h) {
super(w, h);
jsShowTicks=new myJSliderShowTicks(Loc("ctrlshowticks"), true, 200,
TextFieldHeight);
jsSnapTicks=new myJSliderSnapTicks(Loc("ctrlsnap"), true, 200,
TextFieldHeight);
jsMin=new myJSliderMin("min:", "", 50, 150, TextFieldHeight);
jsMax=new myJSliderMax("max:", "", 50, 150, TextFieldHeight);
jsTicks=new myJSliderTicks(Loc("ctrltickspacing"), "", 100, 200,
TextFieldHeight);
jsComment=new myJComment(Loc("expl"), "", 100, 250, TextFieldHeight);
jsUnit=new myJSliderUnit(Loc("unit"), "", 100, 250, TextFieldHeight);
jsShowcom=new myJSliderShowComment("", true, 18, TextFieldHeight);
jsShowval=new myJSliderShowVal(Loc("ctrlshowvalue"), true, 200,
TextFieldHeight);
jsShowunit=new myJSliderShowUnit("", true, 18, TextFieldHeight);
jsPopupitems=new myJPopupItems("", 250, TextFieldHeight*3+2);
}
public void setObject(final JCanvasPanel jcp) {
if (JZirkelCanvas.getCurrentZF()==null) {
return;
}
ZF=JZirkelCanvas.getCurrentZF();
ZC=JZirkelCanvas.getCurrentZC();
JCP=jcp;
//O=JCP.O;
setObject(JCP.O);
Cn=ZC.getConstruction();
this.clearAll();
addName();
addCommonProps();
addJSliderProps();
addJPopupProps();
addConditionals();
selectTab(1);
this.revalidate();
this.repaint();
}
private void addName() {
final JEricPanel rubname=new myRub();
name.init();
rubname.add(name);
addMain(margin(5));
addMain(rubname);
addMain(margin(5));
final JEricPanel rub=new myRub();
addMain(rub);
}
private void addCommonProps() {
jsComment.init();
jsUnit.init();
jsShowcom.init();
jsShowval.init();
jsShowunit.init();
final ContentLine l1=new ContentLine();
l1.add(jsShowcom);
l1.add(jsComment);
final ContentLine l2=new ContentLine();
l2.add(jsShowunit);
l2.add(jsUnit);
final JEricPanel rub4=new myRub();
rub4.add(margintop(2));
rub4.add(l1);
if ((JCP instanceof JCanvasTxtfield)||(JCP instanceof JCanvasButton)) {
rub4.add(margintop(jsShowval.H*2+2));
} else {
rub4.add(margintop(1));
rub4.add(l2);
rub4.add(margintop(1));
rub4.add(jsShowval);
}
addToNum(rub4);
addToNum(new myRubSep());
}
private void addJSliderProps() {
if (!(JCP instanceof JCanvasSlider)) {
return;
}
jsShowTicks.init();
jsSnapTicks.init();
jsMin.init();
jsMax.init();
jsTicks.init();
final JEricPanel rub1=new myRub();
rub1.add(margintop(2));
rub1.add(jsTicks);
rub1.add(margintop(1));
rub1.add(jsSnapTicks);
rub1.add(margintop(1));
rub1.add(jsShowTicks);
addToNum(rub1);
addToNum(new myRubSep());
final JEricPanel rub2=new myRub();
rub2.add(margintop(2));
rub2.add(jsMin);
rub2.add(margintop(jsMin.H+2));
rub2.add(jsMax);
addToNum(rub2);
}
private void addJPopupProps() {
if (!(JCP instanceof JCanvasPopup)) {
return;
}
final JEricPanel rub2=new myRub();
rub2.add(margintop(2));
jsPopupitems.init();
rub2.add(jsPopupitems);
addToNum(rub2);
}
private void addConditionals() {
final JEricPanel rub=new myRub();
chidden.init();
csuperhidden.init();
rub.add(margintop(1));
rub.add(chidden);
rub.add(margintop(2*chidden.H+3));
addToConditional(rub);
}
// class myJSliderName extends myJLine {
//
// public myJSliderName(String comment, String txt, int comwidth, int width,
// int height) {
// super(comment, txt, comwidth, width, height);
// this.JTF.setHorizontalAlignment(SwingConstants.CENTER);
//
// }
//
// public void doAction(Component e) {
// JTextField jtf = (JTextField) e;
// if (O.getName().equals(jtf.getText())) {
// return;
// }
// O.setName(jtf.getText());
// O.setShowName(true);
// show.forceSelect(2); // Force the ShowName icon to be selected
// if (ZC != null) {
// ZC.repaint();
// }
// }
//
// public void init() {
// setText(O.getName());
// }
// }
class myJComment extends myJLine {
/**
*
*/
public myJComment(final String comment, final String txt,
final int comwidth, final int width, final int height) {
super(comment, txt, comwidth, width, height, true);
carPopup.setDisabled(","+JTextFieldPopup.LATEXMENU+","+JTextFieldPopup.FUNCTIONMENU+",");
}
@Override
public void doAction(final Component e) {
JCP.setComment(getText());
}
public void init() {
setText(JCP.getComment());
}
}
class myJSliderUnit extends myJLine {
/**
*
*/
public myJSliderUnit(final String comment, final String txt,
final int comwidth, final int width, final int height) {
super(comment, txt, comwidth, width, height, true);
carPopup.setDisabled(","+JTextFieldPopup.LATEXMENU+","+JTextFieldPopup.FUNCTIONMENU+",");
}
@Override
public void doAction(final Component e) {
JCP.setUnit(getText());
}
public void init() {
setText(JCP.getUnit());
}
}
class myJSliderShowComment extends myJLine {
/**
*
*/
public myJSliderShowComment(final String comment, final boolean bool,
final int width, final int height) {
super(comment, bool, width, height);
}
@Override
public void doAction(final Component e) {
JCP.setShowComment(!isSelected());
}
public void init() {
setSelected(JCP.getShowComment());
}
}
class myJSliderShowVal extends myJLine {
/**
*
*/
public myJSliderShowVal(final String comment, final boolean bool,
final int width, final int height) {
super(comment, bool, width, height);
}
@Override
public void doAction(final Component e) {
JCP.setShowVal(!isSelected());
}
public void init() {
setSelected(JCP.getShowVal());
}
}
class myJSliderShowUnit extends myJLine {
/**
*
*/
public myJSliderShowUnit(final String comment, final boolean bool,
final int width, final int height) {
super(comment, bool, width, height);
}
@Override
public void doAction(final Component e) {
JCP.setShowUnit(!isSelected());
}
public void init() {
setSelected(JCP.getShowUnit());
}
}
class myJSliderShowTicks extends myJLine {
/**
*
*/
public myJSliderShowTicks(final String comment, final boolean bool,
final int width, final int height) {
super(comment, bool, width, height);
}
@Override
public void doAction(final Component e) {
((JCanvasSlider) JCP).setShowTicks(!isSelected());
}
public void init() {
setSelected(((JCanvasSlider) JCP).getShowTicks());
}
}
class myJSliderSnapTicks extends myJLine {
/**
*
*/
public myJSliderSnapTicks(final String comment, final boolean bool,
final int width, final int height) {
super(comment, bool, width, height);
}
@Override
public void doAction(final Component e) {
((JCanvasSlider) JCP).setSnap(!isSelected());
}
public void init() {
setSelected(((JCanvasSlider) JCP).getSnap());
}
}
class myJSliderMin extends myJLine {
/**
*
*/
String current;
String origin;
public myJSliderMin(final String comment, final String txt,
final int comwidth, final int width, final int height) {
super(comment, txt, comwidth, width, height);
}
@Override
public void doAction(final Component e) {
if ((current.equals(getText()))||(!(isValidExpression(getText())))) {
return;
}
current=getText();
}
@Override
public void doQuitMe(final Component e) {
if (!(isValidExpression(getText()))) {
JOptionPane.showMessageDialog(null, Loc("error"));
((JCanvasSlider) JCP).setMin(ValueOf(origin));
setText(origin);
JTF.requestFocus();
return;
}
current=getText();
((JCanvasSlider) JCP).setMin(ValueOf(current));
jsMax.setText(((JCanvasSlider) JCP).getMax());
}
public void init() {
current=String.valueOf(((JCanvasSlider) JCP).getMin());
origin=current;
setText(current);
System.out.println(JTF.getText());
}
}
class myJSliderMax extends myJLine {
/**
*
*/
String current;
String origin;
public myJSliderMax(final String comment, final String txt,
final int comwidth, final int width, final int height) {
super(comment, txt, comwidth, width, height);
}
@Override
public void doAction(final Component e) {
if ((current.equals(getText()))||(!(isValidExpression(getText())))) {
return;
}
current=getText();
}
@Override
public void doQuitMe(final Component e) {
if (!(isValidExpression(getText()))) {
JOptionPane.showMessageDialog(null, Loc("error"));
((JCanvasSlider) JCP).setMax(ValueOf(origin));
setText(origin);
JTF.requestFocus();
return;
}
current=getText();
((JCanvasSlider) JCP).setMax(ValueOf(current));
jsMin.setText(((JCanvasSlider) JCP).getMin());
}
public void init() {
current=String.valueOf(((JCanvasSlider) JCP).getMax());
origin=current;
setText(current);
}
}
class myJSliderTicks extends myJLine {
/**
*
*/
String current, origin;
public myJSliderTicks(final String comment, final String txt,
final int comwidth, final int width, final int height) {
super(comment, txt, comwidth, width, height);
}
@Override
public void doAction(final Component e) {
if ((current.equals(getText()))||(!(isValidExpression(getText())))) {
return;
}
current=getText();
((JCanvasSlider) JCP).setTicks(ValueOf(current));
}
@Override
public void doQuitMe(final Component e) {
if (!(isValidExpression(getText()))) {
JOptionPane.showMessageDialog(null, Loc("error"));
((JCanvasSlider) JCP).setTicks(ValueOf(origin));
setText(origin);
return;
}
current=getText();
((JCanvasSlider) JCP).setTicks(ValueOf(current));
}
public void init() {
current=String.valueOf(((JCanvasSlider) JCP).getTicks());
origin=current;
setText(current);
}
}
class txtfieldTemplate extends myJLine {
/**
*
*/
public txtfieldTemplate(final String comment, final String txt,
final int comwidth, final int width, final int height) {
super(comment, txt, comwidth, width, height, true);
}
@Override
public void doAction(final Component e) {
}
@Override
public void doQuitMe(final Component e) {
}
public void init() {
}
}
class myJPopupItems extends ContentLine {
/**
*
*/
JButton carBTN=null;
JTextArea JTX;
public myJPopupItems(final String mytxt, final int width,
final int height) {
super(width, height);
this.setFocusable(false);
this.add(margin(5));
JTX=new JTextArea(mytxt);
JTX.setFont(F_TextArea);
JTX.setBackground(new Color(245, 246, 255));
// JTX.setBorder(BorderFactory.createEtchedBorder());
JTX.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(final KeyEvent e) {
doAction(e.getComponent());
}
});
JTX.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(final FocusEvent e) {
// JTX.selectAll();
carBTN.setEnabled(true);
}
@Override
public void focusLost(final FocusEvent e) {
carBTN.setEnabled(false);
doQuitMe(e.getComponent());
}
});
JTX.setLineWrap(true);
//
final JScrollPane jstxt=new JScrollPane(JTX);
jstxt.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jstxt.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
// jstxt.setViewportView(JTX);
// fixsize(jstxt,PW-11,h);
this.add(jstxt);
final ImageIcon carimg=new ImageIcon(getClass().getResource(
"/eric/GUI/icons/bar/carbtn.png"));
final ImageIcon carimg_dis=new ImageIcon(getClass().getResource(
"/eric/GUI/icons/bar/carbtn_dis.png"));
carBTN=new JButton(carimg);
carBTN.setDisabledIcon(carimg_dis);
// carbtn.setRolloverIcon(closeoverimg);
carBTN.setBorder(BorderFactory.createEmptyBorder());
carBTN.setOpaque(false);
carBTN.setContentAreaFilled(false);
carBTN.setFocusable(false);
carBTN.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
doShowPopup(e);
}
});
carBTN.setEnabled(false);
this.add(margin(2));
this.add(carBTN);
}
public void doShowPopup(final MouseEvent e) {
if (carBTN.isEnabled()) {
final JTextFieldPopup mypop=new JTextFieldPopup(JTX);
mypop.setDisabled(","+JTextFieldPopup.LATEXMENU+","+JTextFieldPopup.FUNCTIONMENU+",");
mypop.addPopupMenuListener(new PopupMenuListener() {
public void popupMenuWillBecomeVisible(
final PopupMenuEvent arg0) {
}
public void popupMenuWillBecomeInvisible(
final PopupMenuEvent arg0) {
doAction(JTX);
}
public void popupMenuCanceled(final PopupMenuEvent arg0) {
}
});
mypop.openMenu(e);
}
}
public void setText(final String txt) {
JTX.setText(txt);
}
public String getText() {
return JTX.getText();
}
public void doAction(final Component cp) {
if (getObject().getText().equals(getText())) {
return;
}
((JCanvasPopup) JCP).setItems(getText());
// O.setLines(getText());
// O.setText(getText(), true);
// ZC.recompute();
// ZC.validate();
// ZC.repaint();
}
public void doQuitMe(final Component cp) {
}
public void init() {
// setText(O.getLines());
setText(((JCanvasPopup) JCP).getItems());
}
}
}

5315
eric/bar/JProperties.java Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,326 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eric.bar;
import eric.GUI.palette.PaletteManager;
import eric.GUI.pipe_tools;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import eric.JEricPanel;
import rene.gui.Global;
import rene.zirkel.objects.ConstructionObject;
import eric.controls.JCanvasPanel;
import eric.macros.CreateMacroDialog;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
/**
*
* @author erichake
*/
public class JPropertiesBar extends JFrame implements MouseListener,
MouseMotionListener {
static private int Bx=0, By=0, Bwidth=1078, Bheight=60;
CPane CP;
TitleBar titlebar;
static JControlProperties Content;
private MouseEvent pressed;
private Point location;
private static JPropertiesBar JPB=null;
public JPropertiesBar() {
JPB=this;
Bx=Global.getParameter("props.paletteX", 0);
if (Bx<Global.getScreenX()) {
Bx=Global.getScreenX();
}
By=Global.getScreenY();
CP=new CPane();
setContentPane(CP);
titlebar=new TitleBar(this, 18);
Content=new JControlProperties(Bwidth-titlebar.getSize().width,
Bheight);
Content.addPanel(Global.Loc("props.aspecttab"));
Content.addPanel(Global.Loc("props.numerictab"));
Content.addPanel(Global.Loc("props.conditionaltab"));
Content.selectTab(Global.getParameter("props.selectedtab", 0));
CP.add(titlebar);
CP.add(Content);
setSize(Bwidth+2, Bheight+2);
setLocation(Bx, By);
setUndecorated(true);
// Attention : setFocusable commenté pour la 3.5.5 beta 3, car cela interdit le
// "echap" défini juste après...
// setFocusable(true);
KeyStroke key=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, "escape");
getRootPane().getActionMap().put("escape", new AbstractAction() {
@Override
public void actionPerformed(final ActionEvent arg0) {
PaletteManager.setSelected_with_clic("move", true);
CreateMacroDialog.quit();
}
});
}
public static int getBarHeight() {
if ((JPB!=null)&&(JPB.isVisible())) {
return Bheight;
} else {
return 0;
}
}
public static void clearme() {
Content.clearme();
}
public void refresh() {
Content.refresh();
}
public void showme(final boolean vis) {
if (vis) {
setVisible(true);
pipe_tools.setWindowBounds();
pipe_tools.toFront();
} else {
setVisible(false);
}
}
public static void ShowHideBar(){
if (JPB!=null){
JPB.showme(!JPB.isVisible());
}
}
static public boolean isBarVisible() {
return ((JPB!=null)&&(JPB.isVisible()));
}
static public void EditObjects(ArrayList<ConstructionObject> v){
if ((JPB!=null)&&(v!=null)&&(v.size()>0)) {
JPB.setObjects(v);
}
}
static public void EditObject(final ConstructionObject o) {
EditObject(o, true, true);
}
static public void EditObject(final ConstructionObject o,
final boolean forcevisible, final boolean forcefocus) {
if ((JPB!=null)&&(o!=null)) {
JPB.setObject(o, forcevisible, forcefocus);
}
}
static public void EditObject(final JCanvasPanel jcp) {
if ((JPB!=null)&&(jcp.O!=null)) {
JPB.setObject(jcp);
}
}
static public void SelectPropertiesTab(final int i) {
JPB.selectTab(i);
}
static public void RefreshBar() {
if (JPB!=null) {
JPB.refresh();
}
}
// Only called at first launch (applet or application) :
static public void CreatePropertiesBar() {
JPB=new JPropertiesBar();
JPB.showme(false);
}
private void setObjects(ArrayList<ConstructionObject> v) {
showme(true);
Content.setObjects(v);
}
public void setObject(final ConstructionObject O,
final boolean forcevisible, final boolean forcefocus) {
if (forcevisible) {
showme(true);
}
if ((!this.isVisible())&&(!forcefocus)) {
return;
}
Content.setObject(O, forcevisible, forcefocus);
}
public void selectTab(final int i) {
Content.selectTab(i);
}
public void setObject(final JCanvasPanel jcp) {
showme(true);
Content.setObject(jcp);
}
private static void fixsize(final JComponent cp, final int w, final int h) {
final Dimension d=new Dimension(w, h);
cp.setMaximumSize(d);
cp.setMinimumSize(d);
cp.setPreferredSize(d);
cp.setSize(d);
}
private class TitleBar extends JEricPanel {
ImageIcon closeimg=new ImageIcon(getClass().getResource(
"gui/Pclose.png"));
ImageIcon closeoverimg=new ImageIcon(getClass().getResource(
"gui/Pcloseover.png"));
ImageIcon myicon=new ImageIcon(getClass().getResource(
"gui/titlebar.png"));
JButton closebtn;
JPropertiesBar Mother;
@Override
public void paintComponent(final java.awt.Graphics g) {
final java.awt.Dimension d=this.getSize();
g.drawImage(myicon.getImage(), 0, 0, d.width, d.height, this);
super.paintComponent(g);
}
public TitleBar(final JPropertiesBar parent, final int width) {
Mother=parent;
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
// this.setAlignmentX(0F);
this.setOpaque(false);
fixsize(this, width, Bheight);
this.addMouseListener(parent);
this.addMouseMotionListener(parent);
closebtn=new JButton(closeimg);
closebtn.setRolloverIcon(closeoverimg);
closebtn.setBorder(BorderFactory.createEmptyBorder());
closebtn.setOpaque(false);
closebtn.setContentAreaFilled(false);
closebtn.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
// Mother.setVisible(false);
Mother.showme(false);
}
});
this.add(closebtn);
}
}
private class CPane extends JEricPanel {
public CPane() {
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
this.setOpaque(false);
this.setBorder(BorderFactory.createLineBorder(
new Color(80, 80, 80), 1));
}
}
private void setBarLocation(final MouseEvent me) {
location=getLocation(location);
int x=location.x-pressed.getX()+me.getX();
if (x<Global.getScreenX()+20) {
x=Global.getScreenX();
} else if (x+Bwidth>Global.getScreenX()+Global.getScreenW()-20) {
x=Global.getScreenX()+Global.getScreenW()-Bwidth;
}
setLocation(x, Global.getScreenY());
Toolkit.getDefaultToolkit().sync();
}
@Override
public void mouseDragged(final MouseEvent me) {
setBarLocation(me);
}
@Override
public void mousePressed(final MouseEvent me) {
pressed=me;
}
@Override
public void mouseMoved(final MouseEvent e) {
}
@Override
public void mouseReleased(final MouseEvent e) {
setBarLocation(e);
Global.setParameter("props.paletteX", getLocation().x);
Bx=getLocation().x;
By=getLocation().y;
pipe_tools.setWindowLocation();
pipe_tools.toFront();
}
@Override
public void mouseClicked(final MouseEvent e) {
}
@Override
public void mouseEntered(final MouseEvent e) {
}
@Override
public void mouseExited(final MouseEvent e) {
}
}

166
eric/bar/JTabPanel.java Normal file
View file

@ -0,0 +1,166 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eric.bar;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import eric.JEricPanel;
import javax.swing.SwingConstants;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class JTabPanel extends JEricPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
JEricPanel LeftPanel = new JEricPanel();
JEricPanel SouthPanel = new JEricPanel();
JEricPanel RightPanel = new JEricPanel();
ArrayList Panes = new ArrayList();
JTabPanelTitleBar JTitle;
int Leftmargin = 5;// margin before the tabs
int Rightmargin = 35;// margin after the tabs
int TabHeight = 18; // tab title line height
int TabTitleSize = 11; // Tab title font size
int TabTitleMargin = 5; // space before and after the Tab Title
@Override
public void paintComponent(final Graphics g) {
super.paintComponent(g);
final ImageIcon myicon = new ImageIcon(getClass().getResource(
"gui/panel_back.png"));
final java.awt.Dimension d = this.getSize();
g.drawImage(myicon.getImage(), 0, 0, d.width, d.height, this);
}
public JTabPanel(final int w, final int h) {
this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
LeftPanel.setLayout(new BoxLayout(LeftPanel, BoxLayout.Y_AXIS));
RightPanel.setLayout(new BoxLayout(RightPanel, BoxLayout.Y_AXIS));
SouthPanel.setLayout(new BoxLayout(SouthPanel, BoxLayout.X_AXIS));
JTitle = new JTabPanelTitleBar(this);
LeftPanel.add(JTitle);
LeftPanel.add(SouthPanel);
add(LeftPanel);
add(RightPanel);
RightPanel.setOpaque(false);
SouthPanel.setOpaque(false);
LeftPanel.setOpaque(false);
SouthPanel.setAlignmentX(0.0f);
SouthPanel.setAlignmentY(0.0f);
fixsize(this, w, h);
// this.setBorder(BorderFactory.createLineBorder(new
// Color(82,82,82),1));
}
public void add(final JComponent cp, final int i) {
final JEricPanel mypane = (JEricPanel) Panes.get(i);
mypane.add(cp);
}
public void addMain(final JComponent cp) {
SouthPanel.add(cp);
}
public void setMainCenteredContent(final JComponent cp) {
final JEricPanel myjp1 = new JEricPanel();
myjp1.setOpaque(false);
final JEricPanel myjp2 = new JEricPanel();
myjp2.setOpaque(false);
SouthPanel.add(myjp1);
SouthPanel.add(cp);
SouthPanel.add(myjp2);
}
public void clearAll() {
SouthPanel.removeAll();
SouthPanel.revalidate();
for (int i = 0; i < Panes.size(); i++) {
final JEricPanel mypane = (JEricPanel) Panes.get(i);
mypane.removeAll();
mypane.revalidate();
}
}
public void addPanel(final String name) {
JTitle.addTabTitle(name);
final JEricPanel mypane = new JEricPanel();
mypane.setLayout(new BoxLayout(mypane, BoxLayout.X_AXIS));
mypane.setOpaque(false);
String str = Global.Loc("props.help");
str = str.replace("<br>", " ");
Panes.add(mypane);
JTitle.revalidate();
fixsize(LeftPanel, JTitle.getSize().width, this.getSize().height);
fixsize(SouthPanel, JTitle.getSize().width, this.getSize().height
- TabHeight);
fixsize(RightPanel, this.getSize().width - LeftPanel.getSize().width,
this.getSize().height);
final JLabel hlp = new JLabel(str);
hlp.setOpaque(false);
hlp.setFont(new Font("System", 0, 12));
hlp.setHorizontalAlignment(SwingConstants.CENTER);
hlp.setVerticalAlignment(SwingConstants.CENTER);
fixsize(hlp, 600, RightPanel.getSize().height);
hlp.setForeground(new Color(100, 100, 100));
mypane.add(hlp);
mypane.revalidate();
}
public void selectTab(final int i) {
JTitle.selectTabTitle(i);
RightPanel.removeAll();
final JEricPanel mypane = (JEricPanel) Panes.get(i);
fixsize(mypane, RightPanel.getSize().width, RightPanel.getSize().height);
RightPanel.add(mypane);
RightPanel.revalidate();
RightPanel.repaint();
JTitle.repaint();
Global.setParameter("props.selectedtab", i);
}
private void fixsize(final JComponent cp, final int w, final int h) {
final Dimension d = new Dimension(w, h);
cp.setMaximumSize(d);
cp.setMinimumSize(d);
cp.setPreferredSize(d);
cp.setSize(d);
}
}

View file

@ -0,0 +1,173 @@
/*
Copyright 2006 Eric Hakenholz
This file is part of C.a.R. software.
C.a.R. is a free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
C.a.R. is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eric.bar;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.util.ArrayList;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import eric.JEricPanel;
import javax.swing.SwingConstants;
import rene.gui.Global;
/**
*
* @author erichake
*/
public class JTabPanelTitleBar extends JEricPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
ArrayList TabTitles = new ArrayList();
JTabPanel Mother;
@Override
public void paintComponent(final Graphics g) {
super.paintComponent(g);
final ImageIcon myicon1 = new ImageIcon(getClass().getResource(
"gui/titles_back.png"));
final ImageIcon myicon2 = new ImageIcon(getClass().getResource(
"gui/title_back_end.png"));
final java.awt.Dimension d = this.getSize();
g.drawImage(myicon1.getImage(), 0, 0, d.width, d.height, this);
g.drawImage(myicon2.getImage(), d.width - d.height, 0, this);
}
public JTabPanelTitleBar(final JTabPanel parent) {
Mother = parent;
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setAlignmentX(0.0f);
setAlignmentY(0.0f);
add(margin(Mother.Leftmargin));
add(margin(Mother.Rightmargin));
}
public void addTabTitle(final String name) {
final int cnt = this.getComponentCount();
final JTabTitle jtt = new JTabTitle(Mother, name);
TabTitles.add(jtt);
this.add(jtt, cnt - 1);
fixsize(this, getLeftWidth(), Mother.TabHeight);
}
public void selectTabTitle(final int n) {
for (int i = 0; i < TabTitles.size(); i++) {
((JTabTitle) TabTitles.get(i)).setSelected(i == n);
}
}
public int getLeftWidth() {
int w = Mother.Leftmargin + Mother.Rightmargin;
for (int i = 0; i < TabTitles.size(); i++) {
final JTabTitle jtt = (JTabTitle) TabTitles.get(i);
w += jtt.getSize().width;
}
return w;
}
static JEricPanel margin(final int w) {
final JEricPanel mypan = new JEricPanel();
fixsize(mypan, w, 1);
mypan.setOpaque(false);
mypan.setFocusable(false);
return mypan;
}
static void fixsize(final JComponent cp, final int w, final int h) {
final Dimension d = new Dimension(w, h);
cp.setMaximumSize(d);
cp.setMinimumSize(d);
cp.setPreferredSize(d);
cp.setSize(d);
}
}
class JTabTitle extends JEricPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
boolean isActive = false;
JTabPanel Mother;
int Pos;
JLabel JLB = new JLabel();
ImageIcon IcON = new ImageIcon(getClass().getResource("gui/tab_on.png"));
ImageIcon IcOFF = new ImageIcon(getClass().getResource("gui/tab_off.png"));
@Override
public void paintComponent(final Graphics g) {
super.paintComponent(g);
final ImageIcon icn = (isActive) ? IcON : IcOFF;
final java.awt.Dimension d = this.getSize();
g.drawImage(icn.getImage(), 0, 0, d.width, d.height, this);
}
public JTabTitle(final JTabPanel parent, final String txt) {
Mother = parent;
Pos = Mother.Panes.size();
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
setOpaque(false);
// JTabPanelTitleBar.fixsize(this,Mother.TabWidth,Mother.TabHeight);
JTabPanelTitleBar.fixsize(this, titleWidth(txt) + 2
* Mother.TabTitleMargin, Mother.TabHeight);
JLB.setText(txt);
JLB.setFont(new Font(Global.GlobalFont, 0, 11));
JLB.setOpaque(false);
JLB.setHorizontalAlignment(SwingConstants.CENTER);
JLB.setVerticalAlignment(SwingConstants.BOTTOM);
JLB.setForeground(new Color(40, 40, 40));
JTabPanelTitleBar.fixsize(JLB, titleWidth(txt) + 2
* Mother.TabTitleMargin, Mother.TabHeight);
// JTabPanelTitleBar.fixsize(JLB,Mother.TabWidth,Mother.TabHeight);
JLB.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mousePressed(final java.awt.event.MouseEvent evt) {
Mother.selectTab(Pos);
Mother.repaint();
}
});
this.add(JLB);
}
private int titleWidth(final String s) {
// FontMetrics fm = getFontMetrics(getFont());
final FontMetrics fm = getFontMetrics(new Font(Global.GlobalFont, 0,
Mother.TabTitleSize));
return fm.stringWidth(s);
}
public void setSelected(final boolean b) {
isActive = b;
}
}

BIN
eric/bar/gui/Pclose.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

BIN
eric/bar/gui/Pcloseover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

BIN
eric/bar/gui/chkboxOFF.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

BIN
eric/bar/gui/chkboxON.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

BIN
eric/bar/gui/panel_back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

BIN
eric/bar/gui/sep.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

BIN
eric/bar/gui/tab_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

BIN
eric/bar/gui/tab_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

BIN
eric/bar/gui/titlebar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B