aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2011-03-30 18:21:04 +0000
committerYana Stamcheva <yana@jitsi.org>2011-03-30 18:21:04 +0000
commit0f2094fde54dbaf258fc56770f2623b2ac57034b (patch)
treec07c19a37e753c3142271993054461fc8b988e0d /src
parentaec830f961671dc33ed32453bf7fd4c1a72dbc42 (diff)
downloadjitsi-0f2094fde54dbaf258fc56770f2623b2ac57034b.zip
jitsi-0f2094fde54dbaf258fc56770f2623b2ac57034b.tar.gz
jitsi-0f2094fde54dbaf258fc56770f2623b2ac57034b.tar.bz2
Fixes colors and paddings in the search field.
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java64
-rw-r--r--src/net/java/sip/communicator/util/swing/SIPCommTextField.java40
-rw-r--r--src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java51
3 files changed, 127 insertions, 28 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java
index 89c2a05..af725aa 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFieldUI.java
@@ -59,10 +59,28 @@ public class SearchFieldUI
private boolean isCallIconVisible = false;
/**
+ * Indicates if the call button is enabled in this search field.
+ */
+ private boolean isCallButtonEnabled = true;
+
+ /**
* Creates a <tt>SIPCommTextFieldUI</tt>.
*/
public SearchFieldUI()
{
+ // Indicates if the big call button outside the search is enabled.
+ String callButtonEnabledString = UtilActivator.getResources()
+ .getSettingsString("impl.gui.CALL_BUTTON_ENABLED");
+
+ if (callButtonEnabledString != null
+ && callButtonEnabledString.length() > 0)
+ {
+ // If the outside call button is enabled the call button in this
+ // search field is disabled.
+ isCallButtonEnabled
+ = !new Boolean(callButtonEnabledString).booleanValue();
+ }
+
loadSkin();
}
@@ -74,11 +92,14 @@ public class SearchFieldUI
{
super.installListeners();
- getComponent().addMouseListener(
- new TextFieldMouseListener());
+ if (isCallButtonEnabled)
+ {
+ getComponent().addMouseListener(
+ new TextFieldMouseListener());
- getComponent().addMouseMotionListener(
- new TextFieldMouseMotionListener());
+ getComponent().addMouseMotionListener(
+ new TextFieldMouseMotionListener());
+ }
}
/**
@@ -111,15 +132,16 @@ public class SearchFieldUI
g2.drawImage(searchIcon.getImage(), c.getX() + 5, dy + 1, null);
- // Paint call button.
- Rectangle callRect = getCallButtonRect();
- int dx = callRect.x;
- dy = callRect.y;
-
if (c.getText() != null
&& c.getText().length() > 0
- && CallManager.getTelephonyProviders().size() > 0)
+ && CallManager.getTelephonyProviders().size() > 0
+ && isCallButtonEnabled)
{
+ // Paint call button.
+ Rectangle callRect = getCallButtonRect();
+ int dx = callRect.x;
+ dy = callRect.y;
+
if (isCallMouseOver)
g2.drawImage(callRolloverIcon, dx, dy, null);
else
@@ -150,8 +172,11 @@ public class SearchFieldUI
if ((rect.width > 0) && (rect.height > 0))
{
rect.x += searchIcon.getIconWidth() + 8;
- rect.width -= searchIcon.getIconWidth()
- + callRolloverIcon.getWidth(null) + 15;
+ rect.width -= searchIcon.getIconWidth() + 8;
+
+ if (isCallButtonEnabled)
+ rect.width -= callRolloverIcon.getWidth(null) + 12;
+
return rect;
}
return null;
@@ -324,11 +349,14 @@ public class SearchFieldUI
searchIcon = UtilActivator.getResources()
.getImage("service.gui.icons.SEARCH_ICON");
- callIcon = UtilActivator.getResources()
- .getImage("service.gui.buttons.SEARCH_CALL_ICON").getImage();
+ if (isCallButtonEnabled)
+ {
+ callIcon = UtilActivator.getResources()
+ .getImage("service.gui.buttons.SEARCH_CALL_ICON").getImage();
- callRolloverIcon = UtilActivator.getResources()
- .getImage("service.gui.buttons.SEARCH_CALL_ROLLOVER_ICON")
- .getImage();
+ callRolloverIcon = UtilActivator.getResources()
+ .getImage("service.gui.buttons.SEARCH_CALL_ROLLOVER_ICON")
+ .getImage();
+ }
}
-}
+} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java
index 4af8d57..a1cb22c 100644
--- a/src/net/java/sip/communicator/util/swing/SIPCommTextField.java
+++ b/src/net/java/sip/communicator/util/swing/SIPCommTextField.java
@@ -45,6 +45,16 @@ public class SIPCommTextField
private boolean isDefaultTextVisible;
/**
+ * The color of the foreground.
+ */
+ private Color foregroundColor = Color.BLACK;
+
+ /**
+ * The foreground color of the default text.
+ */
+ private Color defaultTextColor = Color.GRAY;
+
+ /**
* Creates an instance of <tt>SIPCommTextField</tt> by specifying the text
* we would like to show by default in it.
* @param text the text we would like to enter by default
@@ -60,7 +70,7 @@ public class SIPCommTextField
}
this.setFont(getFont().deriveFont(10f));
- this.setForeground(Color.GRAY);
+ this.setForeground(defaultTextColor);
this.addMouseListener(this);
this.addFocusListener(this);
@@ -133,7 +143,7 @@ public class SIPCommTextField
setDefaultText();
else
{
- this.setForeground(Color.BLACK);
+ this.setForeground(foregroundColor);
super.setText(text);
}
}
@@ -144,7 +154,7 @@ public class SIPCommTextField
private void setDefaultText()
{
super.setText(defaultText);
- this.setForeground(Color.GRAY);
+ this.setForeground(defaultTextColor);
}
/**
@@ -155,7 +165,7 @@ public class SIPCommTextField
if (super.getText().equals(defaultText))
{
super.setText("");
- this.setForeground(Color.BLACK);
+ this.setForeground(foregroundColor);
}
}
@@ -232,6 +242,26 @@ public class SIPCommTextField
}
/**
+ * Sets the foreground color.
+ *
+ * @param c the color to set for the text field foreground
+ */
+ public void setForegroundColor(Color c)
+ {
+ foregroundColor = c;
+ }
+
+ /**
+ * Sets the foreground color of the default text shown in this text field.
+ *
+ * @param c the color to set
+ */
+ public void setDefaultTextColor(Color c)
+ {
+ defaultTextColor = c;
+ }
+
+ /**
* Notifies all registered <tt>TextFieldChangeListener</tt>s that a change
* has occurred in the text contained in this field.
* @param eventType the type of the event to transfer
@@ -245,4 +275,4 @@ public class SIPCommTextField
case 1: l.textRemoved(); break;
}
}
-}
+} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java b/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java
index a0ab417..0e76c37 100644
--- a/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java
+++ b/src/net/java/sip/communicator/util/swing/plaf/SIPCommTextFieldUI.java
@@ -62,6 +62,34 @@ public class SIPCommTextFieldUI
private boolean isDeleteIconVisible = false;
/**
+ * The start background gradient color.
+ */
+ private final Color bgStartColor
+ = new Color(UtilActivator.getResources().getColor(
+ "service.gui.SEARCH_BACKGROUND"));
+
+ /**
+ * The end background gradient color.
+ */
+ private final Color bgEndColor
+ = new Color(UtilActivator.getResources().getColor(
+ "service.gui.SEARCH_GRADIENT"));
+
+ /**
+ * The start background gradient color.
+ */
+ private final Color bgBorderStartColor
+ = new Color(UtilActivator.getResources().getColor(
+ "service.gui.SEARCH_BORDER"));
+
+ /**
+ * The end background gradient color.
+ */
+ private final Color bgBorderEndColor
+ = new Color(UtilActivator.getResources().getColor(
+ "service.gui.SEARCH_BORDER_GRADIENT"));
+
+ /**
* Creates a <tt>SIPCommTextFieldUI</tt>.
*/
public SIPCommTextFieldUI()
@@ -130,7 +158,14 @@ public class SIPCommTextFieldUI
AntialiasingManager.activateAntialiasing(g2);
JTextComponent c = this.getComponent();
- g2.setColor(Color.WHITE);
+
+ GradientPaint bgGradientColor =
+ new GradientPaint( c.getWidth() / 2, 0,
+ bgStartColor,
+ c.getWidth() / 2, c.getHeight(),
+ bgEndColor);
+
+ g2.setPaint(bgGradientColor);
if(isRounded)
{
@@ -162,16 +197,22 @@ public class SIPCommTextFieldUI
isDeleteIconVisible = false;
g2.setStroke(new BasicStroke(1f));
- g2.setColor(Color.GRAY);
+ GradientPaint bgBorderGradientColor
+ = new GradientPaint( c.getWidth() / 2, 0,
+ bgBorderStartColor,
+ c.getWidth() / 2, c.getHeight(),
+ bgBorderEndColor);
+
+ g2.setPaint(bgBorderGradientColor);
if(isRounded)
{
- g2.drawRoundRect(0, 0, c.getWidth() - 1, c.getHeight() - 1,
+ g2.drawRoundRect(0, 0, c.getWidth() - 2, c.getHeight() - 2,
20, 20);
}
else
{
- g2.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1);
+ g2.drawRect(0, 0, c.getWidth() - 2, c.getHeight() - 2);
}
}
finally
@@ -367,4 +408,4 @@ public class SIPCommTextFieldUI
Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
}
}
-}
+} \ No newline at end of file