1999-01-09 10:37:40 +03:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License
|
|
|
|
* Version 1.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.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS"
|
|
|
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
|
|
|
* the License for the specific language governing rights and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Grendel mail/news client.
|
|
|
|
*
|
1999-03-07 05:46:50 +03:00
|
|
|
* The Initial Developer of the Original Code is Jeff Galyan
|
|
|
|
* <talisman@anamorphic.com>. Portions created by Jeff Galyan are
|
|
|
|
* Copyright (C) 1997 Jeff Galyan. All Rights Reserved.
|
1999-01-09 10:37:40 +03:00
|
|
|
*
|
1999-04-18 03:53:53 +04:00
|
|
|
* Contributors: Edwin Woudt <edwin@woudt.nl>
|
1999-01-09 10:37:40 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
package grendel.widgets;
|
|
|
|
|
1999-04-18 03:53:53 +04:00
|
|
|
import java.awt.Dimension;
|
|
|
|
import java.awt.Font;
|
1999-01-09 10:37:40 +03:00
|
|
|
import java.awt.GridBagConstraints;
|
1999-04-18 03:53:53 +04:00
|
|
|
import java.awt.Insets;
|
1999-01-09 10:37:40 +03:00
|
|
|
|
1999-04-18 03:53:53 +04:00
|
|
|
import java.net.URL;
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory;
|
|
|
|
import javax.swing.ImageIcon;
|
1999-01-09 10:37:40 +03:00
|
|
|
import javax.swing.JToolBar;
|
1999-04-18 03:53:53 +04:00
|
|
|
import javax.swing.JButton;
|
1999-01-09 10:37:40 +03:00
|
|
|
|
|
|
|
import grendel.ui.ToolBarLayout;
|
1999-04-18 03:53:53 +04:00
|
|
|
import grendel.ui.UIAction;
|
1999-01-09 10:37:40 +03:00
|
|
|
|
|
|
|
import grendel.widgets.Animation;
|
|
|
|
import grendel.widgets.Spring;
|
1999-06-13 04:45:40 +04:00
|
|
|
import grendel.widgets.ToolBarButton;
|
1999-01-09 10:37:40 +03:00
|
|
|
|
|
|
|
public class GrendelToolBar extends JToolBar {
|
|
|
|
|
1999-06-14 07:57:04 +04:00
|
|
|
private ToolBarLayout layout;
|
1999-01-09 10:37:40 +03:00
|
|
|
|
1999-06-14 07:57:04 +04:00
|
|
|
public GrendelToolBar() {
|
|
|
|
super();
|
|
|
|
layout = new ToolBarLayout();
|
|
|
|
setLayout(layout);
|
|
|
|
setFloatable(false);
|
|
|
|
}
|
1999-01-09 10:37:40 +03:00
|
|
|
|
1999-06-14 07:57:04 +04:00
|
|
|
public Spring makeNewSpring() {
|
|
|
|
return layout.createSpring();
|
|
|
|
}
|
1999-01-09 10:37:40 +03:00
|
|
|
|
1999-06-14 07:57:04 +04:00
|
|
|
public void addButton(UIAction aActionListener,
|
1999-04-18 03:53:53 +04:00
|
|
|
String aImageName,
|
|
|
|
String aText,
|
|
|
|
String aToolTip) {
|
1999-06-14 07:57:04 +04:00
|
|
|
ToolBarButton b = new ToolBarButton();
|
|
|
|
|
|
|
|
b.setHorizontalTextPosition(JButton.CENTER);
|
|
|
|
b.setVerticalTextPosition(JButton.BOTTOM);
|
|
|
|
Font f=b.getFont();
|
|
|
|
Font nf=new Font(f.getName(), Font.PLAIN, f.getSize()-2);
|
|
|
|
b.setFont(nf);
|
|
|
|
b.setText(aText);
|
|
|
|
|
|
|
|
b.setRolloverEnabled(true);
|
|
|
|
b.setBorder(BorderFactory.createEmptyBorder());
|
|
|
|
b.setToolTipText(aToolTip);
|
1999-04-18 03:53:53 +04:00
|
|
|
|
1999-06-14 07:57:04 +04:00
|
|
|
URL iconUrl = getClass().getResource("toolbar/mozilla/" + aImageName + ".gif");
|
|
|
|
b.setIcon(new ImageIcon(iconUrl));
|
|
|
|
|
|
|
|
Dimension d=b.getPreferredSize();
|
|
|
|
double w=d.getWidth();
|
|
|
|
if (w > 52) {
|
|
|
|
d = new Dimension((int)w, 50);
|
|
|
|
} else {
|
|
|
|
d = new Dimension(52, 50);
|
1999-04-18 03:53:53 +04:00
|
|
|
}
|
1999-06-14 07:57:04 +04:00
|
|
|
b.setMinimumSize(d);
|
|
|
|
b.setMaximumSize(d);
|
|
|
|
b.setPreferredSize(d);
|
|
|
|
|
|
|
|
if (aActionListener != null) {
|
|
|
|
b.addActionListener(aActionListener);
|
|
|
|
} else {
|
|
|
|
b.setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
add(b);
|
|
|
|
|
|
|
|
}
|
1999-01-09 10:37:40 +03:00
|
|
|
|
|
|
|
}
|