Fixes incorrect painting of the call peer menu (and chat Smileys menu) on Windows.

cusax-fix
Yana Stamcheva 16 years ago
parent 7282d6fc03
commit 1e1c6b5a95

@ -185,4 +185,4 @@ service.gui.CALL_PEER_NAME_BACKGROUND=A6D6FF
service.gui.CALL_MEMBER_NAME_BACKGROUND=BDFFA3
# Conference call local user title panel background color.
service.gui.CALL_LOCAL_USER_BACKGROUND=398bcc
service.gui.CALL_LOCAL_USER_BACKGROUND=A6D6FF

@ -26,8 +26,8 @@
*
* @author Yana Stamcheva
*/
public class CallPeerActionMenuBar
extends SIPCommMenuBar
public class CallPeerMenu
extends SIPCommMenu
implements CallPeerListener,
PropertyChangeListener
{
@ -52,24 +52,20 @@ public class CallPeerActionMenuBar
* <tt>callPeer</tt>.
* @param peer the <tt>CallPeer</tt> associated with the contained menus
*/
public CallPeerActionMenuBar(CallPeer peer)
public CallPeerMenu(CallPeer peer)
{
this.callPeer = peer;
SIPCommMenu menu = new SIPCommMenu();
menu.setPreferredSize(new Dimension(20, 20));
this.setOpaque(false);
menu.setOpaque(false);
this.setPreferredSize(new Dimension(20, 20));
// Should explicitly remove any border in order to align correctly the
// icon.
menu.setBorder(BorderFactory.createEmptyBorder());
menu.setIcon(new ImageIcon(ImageLoader
this.setBorder(BorderFactory.createEmptyBorder());
this.setIcon(new ImageIcon(ImageLoader
.getImage(ImageLoader.CALL_PEER_TOOLS)));
menu.setIconTextGap(0);
menu.addItem(
this.setIconTextGap(0);
this.addItem(
GuiActivator.getResources().getI18NString("service.gui.HANG_UP"),
null,
new ActionListener()
@ -83,10 +79,10 @@ public void actionPerformed(ActionEvent e)
initHoldMenuItem();
initMuteMenuItem();
menu.add(holdMenuItem);
menu.add(muteMenuItem);
this.add(holdMenuItem);
this.add(muteMenuItem);
menu.addItem(
this.addItem(
GuiActivator.getResources().getI18NString(
"service.gui.TRANSFER_BUTTON_TOOL_TIP"),
null,
@ -98,8 +94,6 @@ public void actionPerformed(ActionEvent e)
}
});
this.add(menu);
// Add the call peer listener that would notify us for call peer state
// changes. We'll be using these notifications in order to update the
// hold menu item state.

@ -42,9 +42,9 @@ public class ConferencePeerPanel
private CallPeer callPeer;
/**
* The action menu available for all call peers.
* The tools menu available for each peer.
*/
private CallPeerActionMenuBar actionMenuBar;
private CallPeerMenu callPeerMenu;
/**
* The label showing whether the voice has been set to mute.
@ -101,7 +101,9 @@ public ConferencePeerPanel( CallDialog callDialog,
{
this.callDialog = callDialog;
this.setPeerName(protocolProvider.getAccountID().getUserID());
this.setPeerName(protocolProvider.getAccountID().getUserID()
+ " (" + GuiActivator.getResources()
.getI18NString("service.gui.ACCOUNT_ME").toLowerCase() + ")");
this.setTitleBackground(
new Color(GuiActivator.getResources().getColor(
@ -128,8 +130,12 @@ public ConferencePeerPanel(CallDialog callDialog, CallPeer callPeer)
// We initialize the status bar for call peers only.
this.initStatusBar(callPeer);
actionMenuBar = new CallPeerActionMenuBar(callPeer);
this.addToNameBar(actionMenuBar);
callPeerMenu = new CallPeerMenu(callPeer);
SIPCommMenuBar menuBar = new SIPCommMenuBar();
menuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
menuBar.add(callPeerMenu);
this.addToNameBar(menuBar);
this.setTitleBackground(
new Color(GuiActivator.getResources().getColor(

@ -13,7 +13,6 @@
import javax.swing.event.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.swing.*;
@ -26,15 +25,13 @@
* @author Lubomir Marinov
*/
public class SmileysSelectorBox
extends SIPCommMenuBar
extends SIPCommMenu
implements ActionListener,
MouseListener,
PopupMenuListener
{
private final ChatWritePanel chatWritePanel;
private final SIPCommMenu selectorBox = new SIPCommMenu();
private final JLabel smileyTextLabel = new JLabel();
private final JLabel smileyDescriptionLabel = new JLabel();
@ -49,15 +46,13 @@ public SmileysSelectorBox(ChatWritePanel writePanel)
this.chatWritePanel = writePanel;
this.setOpaque(false);
this.selectorBox.setOpaque(false);
// Should explicitly remove any border in order to align correctly the
// icon.
this.selectorBox.setBorder(BorderFactory.createEmptyBorder());
this.selectorBox.setIcon(new ImageIcon(ImageLoader
this.setBorder(BorderFactory.createEmptyBorder());
this.setIcon(new ImageIcon(ImageLoader
.getImage(ImageLoader.SMILIES_ICON)));
JPopupMenu popupMenu = this.selectorBox.getPopupMenu();
JPopupMenu popupMenu = this.getPopupMenu();
popupMenu.setLayout(new GridBagLayout());
popupMenu.setBackground(Color.WHITE);
@ -67,8 +62,6 @@ public SmileysSelectorBox(ChatWritePanel writePanel)
* they are not always necessary.
*/
popupMenu.addPopupMenuListener(this);
this.add(selectorBox);
}
/**
@ -97,7 +90,7 @@ private Dimension calculateGridDimensions(int itemsCount)
*/
public void open()
{
this.selectorBox.doClick();
this.doClick();
}
/**
@ -107,12 +100,13 @@ public void open()
*/
public boolean isMenuSelected()
{
return selectorBox.isPopupMenuVisible();
return isPopupMenuVisible();
}
/**
* Writes the symbol corresponding to a chosen smiley icon to the write
* message area at the end of the current text.
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e)
{
@ -126,34 +120,12 @@ public void actionPerformed(ActionEvent e)
clearMouseOverEffects(smileyItem);
}
/**
* Sets the given text to this smiley selector box. The given text will be
* position by default on the bottom of the icon.
*
* @param text the text to be added to this selector box.
*/
public void setText(String text)
{
this.selectorBox.setText(text);
this.selectorBox.setFont(getFont().deriveFont(Font.BOLD, 10f));
this.selectorBox.setVerticalTextPosition(SwingConstants.BOTTOM);
this.selectorBox.setHorizontalTextPosition(SwingConstants.CENTER);
this.selectorBox.setForeground(new Color(GuiActivator.getResources()
.getColor("service.gui.CHAT_MENU_FOREGROUND")));
}
public void paintComponent(Graphics g)
{
}
/**
* A custom menu item, which paints round border over selection.
*/
private static class SmileyMenuItem
extends JMenuItem
{
/**
* The <tt>Smiley</tt> depicted by this instance.
*/
@ -177,6 +149,7 @@ public SmileyMenuItem(Smiley smiley)
/**
* Changes the static image of the underlying smiley with a dynamic one.
* Also shows the description and smiley string in the description area.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mouseEntered(MouseEvent e)
{
@ -193,6 +166,7 @@ public void mouseEntered(MouseEvent e)
/**
* Clears all mouse over effects when the mouse has exited the smiley area.
* @param e the <tt>MouseEvent</tt> that notified us
*/
public void mouseExited(MouseEvent e)
{
@ -201,17 +175,11 @@ public void mouseExited(MouseEvent e)
this.clearMouseOverEffects(smileyItem);
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e)
{
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e) {}
/**
* Clears all mouse over effects for the given smiley item. This method
@ -230,27 +198,26 @@ private void clearMouseOverEffects(SmileyMenuItem smileyItem)
smileyDescriptionLabel.setText("");
}
/*
/**
* Implements PopupMenuListener#popupMenuCanceled(PopupMenuEvent). Does
* nothing.
* @param e the <tt>PopupMenuEvent</tt>
*/
public void popupMenuCanceled(PopupMenuEvent e)
{
}
public void popupMenuCanceled(PopupMenuEvent e) {}
/*
/**
* Implements
* PopupMenuListener#popupMenuWillBecomeInvisible(PopupMenuEvent). Does
* nothing.
* @param e the <tt>PopupMenuEvent</tt>
*/
public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
{
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
/*
/**
* Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent).
* Loads the smileys and creates the UI to represent them when they are
* first necessary.
* @param e the <tt>PopupMenuEvent</tt> that notified us
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent e)
{

@ -47,6 +47,7 @@ public class EditTextToolBar
/**
* Creates an instance and constructs the <tt>EditTextToolBar</tt>.
* @param writePanel the panel containing the chat write area
*/
public EditTextToolBar(ChatWritePanel writePanel)
{
@ -79,7 +80,11 @@ public void actionPerformed(ActionEvent event)
this.smileysBox.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M");
this.add(smileysBox);
SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar();
smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
smileyMenuBar.add(smileysBox);
this.add(smileyMenuBar);
}
/**

@ -19,34 +19,67 @@
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.swing.*;
/**
* The panel shown on the top of the contact list. It contains user name,
* current status menu and the avatar of the user.
*
* @author Yana Stamcheva
*/
public class AccountStatusPanel
extends TransparentPanel
implements RegistrationStateChangeListener
{
/**
* The desired height of the avatar.
*/
private static final int AVATAR_ICON_HEIGHT = 45;
/**
* The desired width of the avatar.
*/
private static final int AVATAR_ICON_WIDTH = 45;
/**
* The image object storing the avatar.
*/
private final FramedImage accountImageLabel;
/**
* The label showing the name of the user.
*/
private final JLabel accountNameLabel
= new JLabel(
GuiActivator
.getResources().getI18NString("service.gui.ACCOUNT_ME"));
/**
* The background color property.
*/
private final Color bgColor
= new Color(
GuiActivator
.getResources()
= new Color(GuiActivator.getResources()
.getColor("service.gui.LOGO_BAR_BACKGROUND"));
/**
* The background image property.
*/
private final Image logoBgImage
= ImageLoader.getImage(ImageLoader.WINDOW_TITLE_BAR);
/**
* The combo box containing status menu.
*/
private final GlobalStatusSelectorBox statusComboBox;
/**
* TexturePaint used to paint background image.
*/
private final TexturePaint texture;
/**
* Creates an instance of <tt>AccountStatusPanel</tt> by specifying the
* main window, where this panel is added.
* @param mainFrame the main window, where this panel is added
*/
public AccountStatusPanel(MainFrame mainFrame)
{
super(new BorderLayout(10, 0));
@ -96,6 +129,12 @@ public AccountStatusPanel(MainFrame mainFrame)
bgImage.getHeight(null)));
}
/**
* Adds the account given by <tt>protocolProvider</tt> in the contained
* status combo box.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account to add
*/
public void addAccount(ProtocolProviderService protocolProvider)
{
statusComboBox.addAccount(protocolProvider);
@ -103,6 +142,12 @@ public void addAccount(ProtocolProviderService protocolProvider)
protocolProvider.addRegistrationStateChangeListener(this);
}
/**
* Removes the account given by <tt>protocolProvider</tt> from the contained
* status combo box.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account to remove
*/
public void removeAccount(ProtocolProviderService protocolProvider)
{
statusComboBox.removeAccount(protocolProvider);
@ -110,28 +155,63 @@ public void removeAccount(ProtocolProviderService protocolProvider)
protocolProvider.removeRegistrationStateChangeListener(this);
}
/**
* Checks if an account corresponding to the given <tt>protocolProvider</tt>
* is contained in the contained status combo box.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account to check for
* @return <tt>true</tt> to indicate that an account corresponding to the
* given <tt>protocolProvider</tt> is contained in the status box,
* <tt>false</tt> - otherwise
*/
public boolean containsAccount(ProtocolProviderService protocolProvider)
{
return statusComboBox.containsAccount(protocolProvider);
}
/**
* Returns the last used presence status for the given
* <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account we're looking for
* @return the last used presence status for the given
* <tt>protocolProvider</tt>
*/
public Object getLastPresenceStatus(
ProtocolProviderService protocolProvider)
{
return statusComboBox.getLastPresenceStatus(protocolProvider);
}
/**
* Returns the last used status for the given <tt>protocolProvider</tt>
* as a String.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the account we're looking for
* @return a String representation of the last used status for the given
* <tt>protocolProvider</tt>
*/
public String getLastStatusString(ProtocolProviderService protocolProvider)
{
return statusComboBox.getLastStatusString(protocolProvider);
}
/**
* Updates the current status of the <tt>protocolProvider</tt> with the
* <tt>newStatus</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt> to update
* @param newStatus the new status to set
*/
public void updateStatus( ProtocolProviderService protocolProvider,
PresenceStatus newStatus)
{
statusComboBox.updateStatus(protocolProvider, newStatus);
}
/**
* Updates the current status of the <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt> to update
*/
public void updateStatus( ProtocolProviderService protocolProvider)
{
statusComboBox.updateStatus(protocolProvider);
@ -227,6 +307,10 @@ else if (lastName != null)
}
}
/**
* Paints this component.
* @param g the <tt>Graphics</tt> object used for painting
*/
public void paintComponent(Graphics g)
{
super.paintComponent(g);

@ -42,33 +42,67 @@ public class GlobalStatusSelectorBox
extends StatusSelectorMenu
implements ActionListener
{
/**
* The indent of the image.
*/
private static final int IMAGE_INDENT = 10;
/**
* The arrow icon shown on the right of the status and indicating that
* this is a menu.
*/
private final Image arrowImage
= ImageLoader.getImage(ImageLoader.DOWN_ARROW_ICON);
private final Logger logger = Logger.getLogger(GlobalStatusSelectorBox.class);
/**
* The object used for logging.
*/
private final Logger logger
= Logger.getLogger(GlobalStatusSelectorBox.class);
/**
* Mapping of <tt>ProtocolProviderService</tt> and corresponding
* <tt>StatusSelectorMenu</tt>.
*/
private final Map<ProtocolProviderService, StatusSelectorMenu> accountMenus
= new Hashtable<ProtocolProviderService, StatusSelectorMenu>();
/**
* The main application window.
*/
private final MainFrame mainFrame;
// private ImageIcon dndIcon = new ImageIcon(
// ImageLoader.getImage(ImageLoader.USER_DND_ICON));
/**
* The item corresponding to the online status.
*/
private final JMenuItem onlineItem;
/**
* The item corresponding to the offline status.
*/
private final JMenuItem offlineItem;
/**
* The item corresponding to the away status.
*/
private final JMenuItem awayItem;
// private JMenuItem dndItem = new JMenuItem(
// GuiActivator.getResources().getI18NString("service.gui.DND_STATUS").getText(),
// GuiActivator.getResources().getI18NString("service.gui.DND_STATUS")
// .getText(),
// dndIcon);
/**
* The item corresponding to the free for chat status.
*/
private final JMenuItem ffcItem;
/**
* The width of the text.
*/
private int textWidth = 0;
/**
@ -119,6 +153,14 @@ public GlobalStatusSelectorBox(MainFrame mainFrame)
computeTextWidth();
}
/**
* Creates a menu item with the given <tt>textKey</tt>, <tt>iconID</tt> and
* <tt>name</tt>.
* @param textKey the text of the item
* @param iconID the icon of the item
* @param name the name of the item
* @return the created <tt>JMenuItem</tt>
*/
private JMenuItem createMenuItem(
String textKey,
ImageID iconID,
@ -137,6 +179,11 @@ private JMenuItem createMenuItem(
return menuItem;
}
/**
* Adds a status menu for the account given by <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>, for which
* to add a status menu
*/
public void addAccount(ProtocolProviderService protocolProvider)
{
boolean isHidden
@ -161,6 +208,12 @@ public void addAccount(ProtocolProviderService protocolProvider)
this.accountMenus.put(protocolProvider, statusSelectorMenu);
}
/**
* Removes the status menu corresponding to the account given by
* <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>, which
* menu to remove
*/
public void removeAccount(ProtocolProviderService protocolProvider)
{
StatusSelectorMenu statusSelectorMenu
@ -170,14 +223,23 @@ public void removeAccount(ProtocolProviderService protocolProvider)
this.accountMenus.remove(protocolProvider);
}
/**
* Checks if a menu for the given <tt>protocolProvider</tt> exists.
* @param protocolProvider the <tt>ProtocolProviderService</tt> to check
* @return <tt>true</tt> to indicate that a status menu for the given
* <tt>protocolProvider</tt> already exists, otherwise returns
* <tt>false</tt>
*/
public boolean containsAccount(ProtocolProviderService protocolProvider)
{
return accountMenus.containsKey(protocolProvider);
}
/**
* Returns TRUE if there are selected status selector boxes, otherwise
* returns FALSE.
* Returns <tt>true</tt> if there are selected status selector boxes,
* otherwise returns <tt>false</tt>.
* @return <tt>true</tt> if there are selected status selector boxes,
* otherwise returns <tt>false</tt>
*/
public boolean hasSelectedMenus()
{
@ -190,13 +252,15 @@ public boolean hasSelectedMenus()
/**
* Handles the <tt>ActionEvent</tt> triggered when one of the items
* in the list is selected.
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e)
{
JMenuItem menuItem = (JMenuItem) e.getSource();
String itemName = menuItem.getName();
Iterator<ProtocolProviderService> pProviders = mainFrame.getProtocolProviders();
Iterator<ProtocolProviderService> pProviders
= mainFrame.getProtocolProviders();
while (pProviders.hasNext())
{
@ -376,9 +440,12 @@ else if (itemName.equals(Constants.AWAY_STATUS))
if (status != null)
{
if (currentStatus.getStatus() < PresenceStatus.AVAILABLE_THRESHOLD
&& currentStatus.getStatus() >= PresenceStatus.ONLINE_THRESHOLD
&& currentStatus.getStatus() > status.getStatus())
if (currentStatus.getStatus()
< PresenceStatus.AVAILABLE_THRESHOLD
&& currentStatus.getStatus()
>= PresenceStatus.ONLINE_THRESHOLD
&& currentStatus.getStatus()
> status.getStatus())
{
status = currentStatus;
}
@ -397,6 +464,11 @@ else if (itemName.equals(Constants.AWAY_STATUS))
}
}
/**
* Updates the status of the given <tt>protocolProvider</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the menu to update
*/
public void updateStatus(ProtocolProviderService protocolProvider)
{
StatusSelectorMenu accountMenu = accountMenus.get(protocolProvider);
@ -435,6 +507,13 @@ public void updateStatus(ProtocolProviderService protocolProvider)
this.updateGlobalStatus();
}
/**
* Updates the status of the given <tt>protocolProvider</tt> with the given
* <tt>presenceStatus</tt>.
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* corresponding to the menu to update
* @param presenceStatus the new status to set
*/
public void updateStatus(ProtocolProviderService protocolProvider,
PresenceStatus presenceStatus)
{
@ -540,9 +619,10 @@ private class PublishPresenceStatusThread
private OperationSetPresence presence;
/**
*
* @param presence
* @param status
* Publishes the given <tt>status</tt> through the given
* <tt>presence</tt> operation set.
* @param presence the operation set through which we publish the status
* @param status the status to publish
*/
public PublishPresenceStatusThread( OperationSetPresence presence,
PresenceStatus status)
@ -717,6 +797,7 @@ public String getLastStatusString(ProtocolProviderService protocolProvider)
/**
* Overwrites the <tt>paintComponent(Graphics g)</tt> method in order to
* provide a new look and the mouse moves over this component.
* @param g the <tt>Graphics</tt> object used for painting
*/
public void paintComponent(Graphics g)
{
@ -743,7 +824,8 @@ public void paintComponent(Graphics g)
}
/**
* Computes the width of the text in pixels in order to position the arrow during its painting.
* Computes the width of the text in pixels in order to position the arrow
* during its painting.
*/
private void computeTextWidth()
{

Loading…
Cancel
Save