- Allow to add plugins in an "invisible" toolbar on the right of the status combo box in the contact list window.

- Paint more rounded selection and rollover for menus.
- Remove unused class.
cusax-fix
Yana Stamcheva 16 years ago
parent a4a55eae96
commit 8b96fe14a2

@ -50,7 +50,7 @@ protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
int menuHeight = menuItem.getHeight();
g.setColor(Color.LIGHT_GRAY);
g.fillRoundRect(0, 0, menuWidth, menuHeight, 8, 8);
g.fillRoundRect(0, 0, menuWidth, menuHeight, 20, 20);
}
finally
{

@ -86,7 +86,7 @@ public MainToolBar(ChatWindow messageWindow)
pluginContainer
= new PluginContainer(this, Container.CONTAINER_CHAT_TOOL_BAR);
this.messageWindow.addChatChangeListener(this);
}

@ -1,192 +0,0 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.menus;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.Container;
/**
* @author Yana Stamcheva
*/
public class MoreButton
extends AbstractPluginComponent
implements FocusListener,
MouseListener
{
private JLabel label;
private JPopupMenu menu;
private final Map<String, Component> menuItemsTable =
new Hashtable<String, Component>();
public MoreButton()
{
super(Container.CONTAINER_MAIN_TOOL_BAR);
}
public Object getComponent()
{
if (label == null)
{
label
= new JLabel(
new ImageIcon(
ImageLoader.getImage(ImageLoader.MORE_BUTTON)),
JLabel.CENTER);
label.setVerticalTextPosition(SwingConstants.BOTTOM);
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setToolTipText(
GuiActivator.getResources().getI18NString("service.gui.MORE"));
label.addFocusListener(this);
label.addMouseListener(this);
}
return label;
}
public String getName()
{
return "";
}
public void setMouseOver(boolean isMouseOver)
{
if (label != null)
label.repaint();
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
this.setMouseOver(true);
}
public void mouseExited(MouseEvent e)
{
this.setMouseOver(false);
}
public void mousePressed(MouseEvent e)
{
if (label != null)
return;
label.requestFocus();
if (menu == null)
menu = createMenu();
if (!menu.isVisible())
{
Point locationOnScreen = label.getLocationOnScreen();
menu.setLocation(
locationOnScreen.x,
locationOnScreen.y + label.getHeight());
menu.setVisible(true);
}
else
menu.setVisible(false);
}
public void mouseReleased(MouseEvent e)
{
}
public void focusGained(FocusEvent arg0)
{
}
public void focusLost(FocusEvent arg0)
{
if (menu != null)
menu.setVisible(false);
}
public void addMenuItem(final JComponent c)
{
String name = c.getToolTipText();
if (!this.containsItem(name))
{
JMenuItem item = new JMenuItem(name);
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
MouseEvent mouseEvent
= new MouseEvent(c,
MouseEvent.MOUSE_PRESSED,
System.currentTimeMillis(),
MouseEvent.BUTTON1,
c.getX(),
c.getY(),
1,
false);
for (MouseListener l : c.getMouseListeners())
{
l.mousePressed(mouseEvent);
l.mouseReleased(mouseEvent);
l.mouseClicked(mouseEvent);
}
if (menu != null)
menu.setVisible(false);
}
});
if (menu == null)
menu = createMenu();
menu.add(item);
menuItemsTable.put(name, item);
}
}
public void removeMenuItem(JComponent c)
{
String name = c.getToolTipText();
Component item = this.menuItemsTable.get(name);
if (item != null)
{
if (menu != null)
menu.remove(item);
menuItemsTable.remove(name);
}
}
public int getItemsCount()
{
return menuItemsTable.size();
}
public boolean containsItem(String name)
{
return menuItemsTable.containsKey(name);
}
private JPopupMenu createMenu()
{
return new JPopupMenu();
}
}

@ -15,6 +15,7 @@
import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.Container;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.swing.*;
@ -75,6 +76,11 @@ public class AccountStatusPanel
*/
private final TexturePaint texture;
/**
* Container for plugins.
*/
private final PluginContainer pluginContainer;
/**
* Creates an instance of <tt>AccountStatusPanel</tt> by specifying the
* main window, where this panel is added.
@ -105,13 +111,27 @@ public AccountStatusPanel(MainFrame mainFrame)
// Align status combo box with account name field.
statusComboBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
TransparentPanel statusToolsPanel
= new TransparentPanel(new BorderLayout());
SIPCommMenuBar statusMenuBar = new SIPCommMenuBar();
statusMenuBar.setLayout(new BorderLayout(0, 0));
statusMenuBar.add(statusComboBox);
statusToolsPanel.add(statusMenuBar, BorderLayout.WEST);
TransparentPanel pluginPanel
= new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
pluginContainer = new PluginContainer(
new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)),
Container.CONTAINER_MAIN_TOOL_BAR);
statusToolsPanel.add(pluginPanel, BorderLayout.EAST);
Container rightPanel = new TransparentPanel(new GridLayout(0, 1, 0, 0));
TransparentPanel rightPanel
= new TransparentPanel(new GridLayout(0, 1, 0, 0));
rightPanel.add(accountNameLabel);
rightPanel.add(statusMenuBar);
rightPanel.add(statusToolsPanel);
this.add(accountImageLabel, BorderLayout.WEST);
this.add(rightPanel, BorderLayout.CENTER);

@ -150,7 +150,7 @@ public GlobalStatusSelectorBox(MainFrame mainFrame)
this.setToolTipText("<html><b>Set global status</b></html>");
this.setUI(new SIPCommStatusMenuUI());
computeTextWidth();
fitSizeToText();
}
/**
@ -569,7 +569,7 @@ private void updateGlobalStatus()
JMenuItem item = getItemFromStatus(status);
setSelected(new SelectedObject(item.getText(), item.getIcon(), item));
computeTextWidth();
fitSizeToText();
this.revalidate();
setSystrayIcon(status);
@ -827,16 +827,16 @@ public void paintComponent(Graphics g)
* Computes the width of the text in pixels in order to position the arrow
* during its painting.
*/
private void computeTextWidth()
private void fitSizeToText()
{
String text = getText();
textWidth
= (text == null)
? 0
: SwingUtilities
.computeStringWidth(
getFontMetrics(getFont()),
text);
: GuiUtils.getStringWidth(this, text);
this.setPreferredSize(new Dimension(
textWidth + 2*IMAGE_INDENT + arrowImage.getWidth(null) + 5, 20));
}
}

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.chat;
package net.java.sip.communicator.impl.gui.utils;
import java.awt.*;
import java.util.*;

@ -172,7 +172,7 @@ private void internalPaintComponent(Graphics g)
g.setColor(new Color(1.0f, 1.0f, 1.0f, visibility));
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 10, 10);
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 20, 20);
g.setColor(UIManager.getColor("Menu.foreground"));

Loading…
Cancel
Save