Author: bback
Date: 2006-03-14 14:06:31 +0000 (Tue, 14 Mar 2006)
New Revision: 8251
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalArrowButton.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalCalendarPanelUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalDateEntryUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalHeaderUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifCalendarPanelUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifDateEntryUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifHeaderUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsCalendarPanelUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsDateEntryUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsHeaderUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicDateEntryUI.java
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicHeaderUI.java
Modified:
trunk/apps/frost-0.7/source/frost/Frost.java
Log:
new date chooser component
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalArrowButton.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalArrowButton.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalArrowButton.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,238 @@
+package mseries.plaf.Metal;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Color;
+
+import javax.swing.*;
+import javax.swing.plaf.metal.*;
+
+/**
+ * JButton object that draws a scaled Arrow in one of the cardinal directions.
+ * <p>
+ * <strong>Warning:</strong>
+ * Serialized objects of this class will not be compatible with
+ * future Swing releases. The current serialization support is appropriate
+ * for short term storage or RMI between applications running the same
+ * version of Swing. A future release of Swing will provide support for
+ * long term persistence.
+ *
+ * @version 1.19 02/02/00
+ */
+public class MetalArrowButton extends JButton implements SwingConstants
+{
+ protected int direction;
+
+ public MetalArrowButton(int direction)
+ {
+ super();
+ setRequestFocusEnabled(false);
+ setDirection(direction);
+ setBackground(UIManager.getColor("control"));
+ }
+
+ public int getDirection() { return direction; }
+
+ public void setDirection(int dir) { direction = dir; }
+
+ protected boolean top, left, bottom, right;
+ /**
+ * Draws the border on the side which is true. Only left is implemented
+ */
+ public void drawBorder(boolean top, boolean left, boolean bottom, boolean
right)
+ {
+ this.top=top;
+ this.left=left;
+ this.bottom=bottom;
+ this.right=right;
+ }
+
+ public void paint(Graphics g)
+ {
+ Color origColor;
+ boolean isPressed, isEnabled;
+ int w, h, size;
+
+ w = getSize().width;
+ h = getSize().height;
+ origColor = g.getColor();
+ isPressed = getModel().isPressed();
+ isEnabled = isEnabled();
+
+ g.setColor(getBackground());
+ g.fillRect(0, 0, w, h);
+
+ /// Draw the proper Border
+ if (left)
+ {
+ g.setColor( MetalLookAndFeel.getControlDarkShadow() );
+ g.drawLine(0,0,0,h);
+ g.setColor( MetalLookAndFeel.getControlHighlight() );
+ g.drawLine(1,0,1,h);
+ }
+ if (top)
+ {
+ g.setColor( MetalLookAndFeel.getControlDarkShadow() );
+ g.drawLine(0,0,w-2,0);
+ g.setColor( MetalLookAndFeel.getControlHighlight() );
+ g.drawLine(1,1,w-1,1);
+ }
+ if (bottom)
+ {
+ g.setColor( MetalLookAndFeel.getControlDarkShadow() );
+ g.drawLine(1,h-2,w,h-2);
+ g.setColor( MetalLookAndFeel.getControlHighlight() );
+ g.drawLine(0,h-1,w,h-1);
+ }
+ if (right)
+ {
+ g.setColor( MetalLookAndFeel.getControlDarkShadow() );
+ g.drawLine(w-2,0,w-2,h-2);
+ g.setColor( MetalLookAndFeel.getControlHighlight() );
+ g.drawLine(w-1,1,w-1,h-1);
+ }
+ if (isPressed)
+ {
+ g.setColor(UIManager.getColor("controlShadow"));
+ g.fillRect(0, 0, w, h);
+ }
+
+ // If there's no room to draw arrow, bail
+ if(h < 5 || w < 5)
+ {
+ g.setColor(origColor);
+ return;
+ }
+
+ // Draw the arrow
+ size = Math.min((h - 4) / 3, (w - 4) / 3);
+ size = Math.max(size, 2)+2;
+ paintTriangle(g, (w - size) / 2, (h - size) / 2, size, direction,
isEnabled);
+
+ // Reset the Graphics back to it's original settings
+ g.setColor(origColor);
+
+ }
+
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(16, 16);
+ }
+
+ public Dimension getMinimumSize()
+ {
+ return new Dimension(5, 5);
+ }
+
+ public Dimension getMaximumSize()
+ {
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ }
+
+ public boolean isFocusable()
+ {
+ return false;
+ }
+
+ public void paintTriangle(Graphics g, int x, int y, int size,
+ int direction, boolean isEnabled)
+ {
+ Color oldColor = g.getColor();
+ int mid, i, j;
+
+ j = 0;
+ size = Math.max(size, 2);
+ mid = size / 2;
+
+ g.translate(x, y);
+
+ g.setColor(isEnabled() ? MetalLookAndFeel.getControlInfo() :
MetalLookAndFeel.getControlShadow() );
+ switch(direction)
+ {
+ case NORTH:
+ for(i = 0; i < size; i++)
+ {
+ g.drawLine(mid-i, i, mid+i, i);
+ }
+ if(!isEnabled)
+ {
+ g.setColor(UIManager.getColor("controlLtHighlight"));
+ g.drawLine(mid-i+2, i, mid+i, i);
+ }
+ break;
+ case SOUTH:
+ if(!isEnabled)
+ {
+ g.translate(1, 1);
+ g.setColor(UIManager.getColor("controlLtHighlight"));
+ for(i = size-1; i >= 0; i--)
+ {
+ g.drawLine(mid-i, j, mid+i, j);
+ j++;
+ }
+ g.translate(-1, -1);
+ g.setColor(UIManager.getColor("controlShadow"));
+ }
+
+ j = 0;
+ for(i = size-1; i >= 0; i--)
+ {
+ g.drawLine(mid-i, j, mid+i, j);
+ j++;
+ }
+ break;
+ case WEST:
+ for(i = 0; i < size; i++)
+ {
+ g.drawLine(i, mid-i, i, mid+i);
+ }
+ if(!isEnabled)
+ {
+ g.setColor(UIManager.getColor("controlLtHighlight"));
+ g.drawLine(i, mid-i+2, i, mid+i);
+ }
+ break;
+ case EAST:
+ if(!isEnabled)
+ {
+ g.translate(1, 1);
+ g.setColor(UIManager.getColor("controlLtHighlight"));
+ for(i = size-1; i >= 0; i--)
+ {
+ g.drawLine(j, mid-i, j, mid+i);
+ j++;
+ }
+ g.translate(-1, -1);
+ g.setColor(UIManager.getColor("controlShadow"));
+ }
+
+ j = 0;
+ for(i = size-1; i >= 0; i--)
+ {
+ g.drawLine(j, mid-i, j, mid+i);
+ j++;
+ }
+ break;
+ }
+ g.translate(-x, -y);
+ g.setColor(oldColor);
+ }
+}
+/*
+$Log: MetalArrowButton.java,v $
+Revision 1.6 2004/08/29 17:12:09 martin
+*** empty log message ***
+
+Revision 1.5 2004/03/07 17:10:27 martin
+*** empty log message ***
+
+Revision 1.4 2003/03/24 19:45:07 martin
+Latest 1.4 version
+
+Revision 1.2 2003/03/11 22:35:15 martin
+Upgraded to Java 1.4 on 11/03/03
+
+Revision 1.1.1.1.2.1 2002/02/02 15:41:59 martin
+Removed depredated method for 1.4
+/
+*/
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalCalendarPanelUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalCalendarPanelUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalCalendarPanelUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2000 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Metal;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.metal.*;
+
+/**
+* The Metal Look and Feel UIDelagate for CalendarPanel
+*
+* A Look and Feel delegate for the CalenderPanel. This version renders the
+* selected date with a raised border and dashed focus indicator. TAB moves
+* around the calendar, Shift-Tab jumps out to the next component. The arrow
+* keys move around the panel stopping (i.e. not rolling over) at the ends.
+*/
+public class MetalCalendarPanelUI extends
mseries.plaf.basic.BasicCalendarPanelUI
+{
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new MetalCalendarPanelUI();
+ }
+
+ /*
+ * This is where we would draw/remove borders, focus highlights,
+ * colours etc. Override this method in a subclass to render the
+ * selected date.
+ */
+ protected void drawSelectedEffect(Graphics g, boolean selected)
+ {
+ int strWidth=0;
+ int strHeight=0;
+ int x,y;
+ int width, height;
+
+ width = getCellSize().width;
+ height = getCellSize().height;
+
+ if(isOpaque())
+ {
+ g.setColor(background);
+ g.fillRect(0,0,width, height);
+ }
+
+ if (selected)
+ {
+
+ g.setColor( MetalLookAndFeel.getControlDarkShadow() );
+ g.drawRect( 0, 0, width-2, height-2 );
+ g.setColor( MetalLookAndFeel.getControlHighlight() );
+ g.drawRect( 1, 1, width-2, height-2 );
+ g.setColor( MetalLookAndFeel.getControl() );
+ g.drawLine( 0, height-1, 1, height-2 );
+ g.drawLine( width-1, 0, width-2, 1 );
+ }
+ }
+
+ /**
+ * Draws the dashed rectangle around the number in the cell which is
selected
+ * when the calendar panel has focus. Over ride this method in a subclass
+ * to change the appearance.
+ */
+ protected void drawFocusedEffect(Graphics g, boolean focused, boolean
selected)
+ {
+ int width, height;
+
+ width = getCellSize().width;
+ height = getCellSize().height;
+ if (focused)
+ {
+ g.setColor(UIManager.getColor("Button.focus"));
+ drawFocus(g, 3, 2, width-5, height-5);
+ }
+
+ }
+
+ public void drawFocus(Graphics g,int x,int y,int width,int height)
+ {
+ int vx,vy;
+
+ g.drawLine(x, y, width, y);
+ g.drawLine(x, y, x, height);
+ g.drawLine(x, height, width, height);
+ g.drawLine(width, height, width, y);
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalDateEntryUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalDateEntryUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalDateEntryUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2001 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Metal;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+import javax.swing.plaf.metal.*;
+
+
+public class MetalDateEntryUI extends mseries.plaf.basic.BasicDateEntryUI
+{
+
+
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new MetalDateEntryUI();
+ }
+
+ public void configureDisplay(JComponent display)
+ {
+ display.setBorder(null);
+ //display.setBackground(UIManager.getColor("control"));
+ display.setPreferredSize(new Dimension(75, 25));
+ }
+
+ protected void configureBorder(JComponent c)
+ {
+
c.setBorder(BorderFactory.createEtchedBorder(MetalLookAndFeel.getControlHighlight(),
+
MetalLookAndFeel.getControlDarkShadow() ));
+ }
+ protected JButton createArrowButton()
+ {
+ MetalArrowButton b = new MetalArrowButton(BasicArrowButton.SOUTH);
+ b.drawBorder(false, true, false, false);
+
b.setBorder(BorderFactory.createEtchedBorder(MetalLookAndFeel.getControlHighlight(),
+
MetalLookAndFeel.getControlDarkShadow() ));
+ return b;
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalHeaderUI.java
===================================================================
--- trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalHeaderUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++ trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Metal/MetalHeaderUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2000 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Metal;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+/**
+* The Metal Look and Feel UIDelagate for Header
+*
+*/
+public class MetalHeaderUI extends mseries.plaf.basic.BasicHeaderUI
+{
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new MetalHeaderUI();
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifCalendarPanelUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifCalendarPanelUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifCalendarPanelUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2001 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Motif;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+/**
+* The Motif Look and Feel UIDelagate for CalendarPanel
+*
+* A Look and Feel delegate for the CalenderPanel. This version renders the
+* selected date with a raised border and dashed focus indicator. TAB moves
+* around the calendar, Shift-Tab jumps out to the next component. The arrow
+* keys move around the panel stopping (i.e. not rolling over) at the ends.
+*/
+public class MotifCalendarPanelUI extends
mseries.plaf.basic.BasicCalendarPanelUI
+{
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new MotifCalendarPanelUI();
+ }
+
+ /*
+ * This is where we would draw/remove borders, focus highlights,
+ * colours etc. Override this method in a subclass to render the
+ * selected date.
+ */
+ protected void drawSelectedEffect(Graphics g, boolean selected)
+ {
+ int strWidth=0;
+ int strHeight=0;
+ int x,y;
+ int width, height;
+
+ width = getCellSize().width;
+ height = getCellSize().height;
+ FontMetrics fm;
+
+ // Background
+ if(isOpaque())
+ {
+ g.setColor(background);
+ g.fillRect(0,0,width, height);
+ }
+
+ // Border
+ if (selected)
+ {
+
+ g.setColor(UIManager.getColor("control"));
+ g.fillRect(1,1,width-1, height-1);
+
+ // Draw Raised Border TOP-LEFT
+ g.setColor(UIManager.getColor("controlHighlight"));
+ g.drawLine(1, 1, width-2, 1);
+ g.drawLine(1, 1, 1, height-1);
+
+ // BOTTOM-RIGHT
+ g.setColor(UIManager.getColor("controlShadow"));
+ g.drawLine(1, height-1, width-2, height-1);
+ g.drawLine(width-2, height-1, width-2, 1);
+ }
+ }
+
+ /**
+ * Draws the dashed rectangle around the number in the cell which is
selected
+ * when the calendar panel has focus. Over ride this method in a subclass
+ * to change the appearance.
+ */
+ protected void drawFocusedEffect(Graphics g, boolean focused, boolean
selected)
+ {
+ int width, height;
+
+ width = getCellSize().width;
+ height = getCellSize().height;
+ if (focused)
+ {
+ g.setColor(UIManager.getColor("activeCaptionBorder"));
+ //g.setColor(SystemColor.control);
+ drawFocus(g, 0, 0, width-1, height);
+ }
+
+ }
+
+ public void drawFocus(Graphics g,int x,int y,int width,int height)
+ {
+ int vx,vy;
+
+ g.drawLine(x, y, width, y);
+ g.drawLine(x, y, x, height);
+ g.drawLine(x, height, width, height);
+ g.drawLine(width, height, width, y);
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifDateEntryUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifDateEntryUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifDateEntryUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2002 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*
+* Created on Dec 21, 2002 at 8:14:49 PM by martin
+*/
+package mseries.plaf.Motif;
+
+import mseries.plaf.Windows.WindowsDateEntryUI;
+
+public class MotifDateEntryUI extends WindowsDateEntryUI
+{
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifHeaderUI.java
===================================================================
--- trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifHeaderUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++ trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Motif/MotifHeaderUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2000 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Motif;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+/**
+* The Metal Look and Feel UIDelagate for Header
+*
+*/
+public class MotifHeaderUI extends mseries.plaf.basic.BasicHeaderUI
+{
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new MotifHeaderUI();
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsCalendarPanelUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsCalendarPanelUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsCalendarPanelUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2000 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Windows;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+/**
+* The Windows Look and Feel UIDelagate for CalendarPanel
+*
+* A Look and Feel delegate for the CalenderPanel. This version renders the
+* selected date with a raised border and dashed focus indicator. TAB moves
+* around the calendar, Shift-Tab jumps out to the next component. The arrow
+* keys move around the panel stopping (i.e. not rolling over) at the ends.
+*/
+public class WindowsCalendarPanelUI extends
mseries.plaf.basic.BasicCalendarPanelUI
+{
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new WindowsCalendarPanelUI();
+ }
+
+ /*
+ * This is where we would draw/remove borders, focus highlights,
+ * colours etc. Override this method in a subclass to render the
+ * selected date.
+ */
+ protected void drawSelectedEffect(Graphics g, boolean selected)
+ {
+ int strWidth=0;
+ int strHeight=0;
+ int x,y;
+ int width, height;
+
+ width = getCellSize().width;
+ height = getCellSize().height;
+ FontMetrics fm;
+
+ if(isOpaque())
+ {
+ g.setColor(background);
+ g.fillRect(0,0,width, height);
+ }
+
+
+ if (selected)
+ {
+ // Draw Raised Border TOP-LEFT
+ g.setColor(SystemColor.controlLtHighlight);
+ g.drawLine(0, 0, width-1, 0);
+ g.drawLine(0, 0, 0, height-1);
+
+ // BOTTOM-RIGHT
+ g.setColor(SystemColor.controlDkShadow);
+ g.drawLine(0, height-1, width-1, height-1);
+ g.drawLine(width-1, height-1, width-1, 0);
+ }
+
+ }
+
+ /**
+ * Draws the dashed rectangle around the number in the cell which is
selected
+ * when the calendar panel has focus. Over ride this method in a subclass
+ * to change the appearance.
+ * @see #drawDashedRect
+ */
+ protected void drawFocusedEffect(Graphics g, boolean focused, boolean
selected)
+ {
+ int width, height;
+
+ width = getCellSize().width;
+ height = getCellSize().height;
+ if (focused)
+ {
+ g.setColor(foreground);
+ drawDashedRect(g, 3, 2, width-5, height-5);
+ }
+
+ }
+
+ /**
+ * Draws a dashed rectangle in the selected date.
+ */
+ public static void drawDashedRect(Graphics g,int x,int y,int width,int
height)
+ {
+ int vx,vy;
+
+ // draw upper and lower horizontal dashes
+ for (vx = x; vx < (x + width); vx+=2) {
+ g.drawLine(vx, y, vx, y);
+ g.drawLine(vx, y + height-1, vx, y + height-1);
+ }
+
+ // draw left and right vertical dashes
+ for (vy = y; vy < (y + height); vy+=2) {
+ g.drawLine(x, vy, x, vy);
+ g.drawLine(x+width-1, vy, x + width-1, vy);
+ }
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsDateEntryUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsDateEntryUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsDateEntryUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2001 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*
+* Thanks to James Shiell for supplying amendments to this for Win XP Look &
Feel in J2SE 1.4.2
+*/
+package mseries.plaf.Windows;
+
+import com.sun.java.swing.plaf.windows.WindowsComboBoxUI;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.*;
+import java.awt.*;
+
+
+public class WindowsDateEntryUI extends mseries.plaf.basic.BasicDateEntryUI
+{
+ private final ComboBoxUI comboBoxUI = new ComboBoxUI();
+
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ //System.out.println("WindowsDateEntryUI");
+ return new WindowsDateEntryUI();
+ }
+
+ public void configureDisplay(JComponent display)
+ {
+ display.setBorder(null);
+ display.setPreferredSize(new Dimension(75, 21));
+ }
+ public void uninstallUI(JComponent c)
+ {
+ super.uninstallUI(c);
+ dateEntry.setBorder(null);
+ }
+ protected void configureBorder(JComponent c)
+ {
+ c.setBorder(UIManager.getBorder("TextField.border"));
+ }
+ protected JButton createArrowButton()
+ {
+ return comboBoxUI.createArrowButton();
+ }
+
+ // hack to get createArrowButton
+ private class ComboBoxUI extends WindowsComboBoxUI
+ {
+
+ public JButton createArrowButton()
+ {
+ return super.createArrowButton();
+ }
+
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsHeaderUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsHeaderUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/Windows/WindowsHeaderUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2000 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.Windows;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+/**
+* The Windows Look and Feel UIDelagate for Header
+*
+*/
+public class WindowsHeaderUI extends mseries.plaf.basic.BasicHeaderUI
+{
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new WindowsHeaderUI();
+ }
+ public Font getFont()
+ {
+ Font f = header.getFont();
+ String name = f.getFontName();
+ int style = (f.isItalic()) ? Font.ITALIC+Font.BOLD : Font.BOLD;
+ int size = f.getSize();
+
+ return new Font(name, style, size);
+ }
+}
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicDateEntryUI.java
===================================================================
---
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicDateEntryUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicDateEntryUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,762 @@
+/*
+* Copyright (c) 2001 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.basic;
+
+import mseries.Calendar.MDateSelectorPanel;
+import mseries.Calendar.MMonthEvent;
+import mseries.Calendar.MMonthListener;
+import mseries.ui.*;
+import mseries.utils.MComboBoxLayout;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import java.util.Vector;
+
+
+public class BasicDateEntryUI extends ComponentUI implements
PropertyChangeListener
+{
+ // The arrow button that invokes the popup.
+ protected JButton arrowButton;
+ boolean isShowing = false;
+ boolean mustClose = false;
+ Action activator;
+ Action openAction = new OpenAction();
+ Action closeAction = new CloseAction();
+ Action cancelAction = new CancelAction();
+
+ MDateField display;
+ MDateSelectorPanel panel;
+ MPopup popup;
+ Border border = null;
+ MMonthListener mMonthListener;
+ AncestorListener ancListener;
+ MouseListener mouseListener;
+ protected MDateEntryField dateEntry;
+
+ private final Object classLock = new Object();
+ private static final int MAX_CACHE_SIZE = 1;
+ private final Vector lightPopupCache = new Vector(MAX_CACHE_SIZE);
+ private static final Vector heavyPopupCache = new Vector(MAX_CACHE_SIZE);
+ Dimension d;
+
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicDateEntryUI();
+ }
+
+ /*
+ * Called by the UIManager to install the UI of the component
+ */
+ public void installUI(JComponent c)
+ {
+ dateEntry = (MDateEntryField) c;
+
+ installComponents();
+
+ configureDisplay(dateEntry.getDisplay());
+ configureBorder(dateEntry);
+
+ dateEntry.setLayout(createLayoutManager());
+
+ installListeners();
+ }
+
+ public void uninstallUI(JComponent c)
+ {
+ dateEntry.setLayout(null);
+ uninstallListeners();
+ uninstallComponents();
+ }
+
+ public void update(Graphics g, JComponent c)
+ {
+ paint(g, c);
+ }
+
+ public void paint(Graphics g, JComponent c)
+ {
+
+ }
+
+ protected void installListeners()
+ {
+ if ((activator = createActionListener()) != null)
+ {
+ arrowButton.addActionListener(activator);
+ }
+ if ((ancListener = createAncestorListener()) != null)
+ {
+ dateEntry.addAncestorListener(ancListener);
+ }
+ if ((mouseListener = createMouseListener()) != null)
+ {
+ arrowButton.addMouseListener(mouseListener);
+ }
+ registerKeyboardActions();
+ mMonthListener = createMMonthListener();
+
+ dateEntry.addPropertyChangeListener(this);
+
+ }
+
+ protected void uninstallListeners()
+ {
+ arrowButton.removeActionListener(activator);
+ arrowButton.removeMouseListener(mouseListener);
+ dateEntry.addPropertyChangeListener(this);
+ unRegisterKeyboardActions();
+ dateEntry.removeAncestorListener(ancListener);
+ }
+
+ /**
+ * Creates the standard combo box layout manager that has the arrow button
to
+ * the right and the editor to the left.
+ * Returns an instance of BasicComboBoxUI$ComboBoxLayoutManager.
+ */
+ protected LayoutManager createLayoutManager()
+ {
+ return new MComboBoxLayout();
+ }
+
+ /**
+ * The editor and arrow button are added to the JComboBox here.
+ */
+ protected void installComponents()
+ {
+ display = dateEntry.getDisplay();
+ dateEntry.add(display);
+
+ arrowButton = createArrowButton();
+ dateEntry.add(arrowButton);
+ }
+
+ protected void uninstallComponents()
+ {
+ arrowButton = null;
+ dateEntry.removeAll();
+ }
+
+ /**
+ * Creates the arrow button. Subclasses can create any button they like.
+ * The default behavior of this class is to attach various listeners to the
+ * button returned by this method.
+ * Returns an instance of BasicArrowButton.
+ */
+ protected JButton createArrowButton()
+ {
+ JButton x = new ArrowButton(ArrowButton.SOUTH);
+ x.setBackground(dateEntry.getBackground());
+ x.setForeground(dateEntry.getBackground());
+ return x;
+ }
+
+ /**
+ * Gets the insets from the JComboBox.
+ */
+ protected Insets getInsets()
+ {
+ return dateEntry.getInsets();
+ }
+
+ /**
+ * This is where we add a border the component, (the display field and
the button)
+ * @param c the entire component
+ */
+ protected void configureBorder(JComponent c)
+ {
+
c.setBorder(BorderFactory.createEtchedBorder(MetalLookAndFeel.getControlHighlight(),
+ MetalLookAndFeel.getControlDarkShadow() ));
+ }
+
+ /**
+ * This is where we would configure the display field part of the
component, such as remove
+ * the dfault border and change preferred size.
+ * @param display the display part of the component
+ */
+ public void configureDisplay(JComponent display)
+ {
+ }
+
+
+ /**
+ * Class to encapsulate the open and close action, activated by the
button and
+ * keyboard keys
+ */
+ protected class OpenCloseAction extends AbstractAction
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ String command;
+ command = getActionCommand(e);
+ if (command.equals("OPEN"))
+ {
+ mustClose = false;
+ }
+ if (!isShowing)
+ {
+ if (mustClose)
+ {
+ display.requestFocus();
+ return;
+ }
+ isShowing = true;
+ showPopup();
+ }
+ else
+ {
+ isShowing = false;
+ panel.close(command);
+ }
+ }
+
+ protected String getActionCommand(ActionEvent e)
+ {
+ return e.getActionCommand();
+ }
+ }
+
+ protected class OpenAction extends OpenCloseAction
+ {
+ protected String getActionCommand(ActionEvent e)
+ {
+ return "OPEN";
+ }
+ }
+
+ protected class CloseAction extends OpenCloseAction
+ {
+ protected String getActionCommand(ActionEvent e)
+ {
+ return "CLOSE";
+ }
+ }
+
+ protected class CancelAction extends OpenCloseAction
+ {
+ protected String getActionCommand(ActionEvent e)
+ {
+ return "CANCEL";
+ }
+ }
+
+ protected Action createActionListener()
+ {
+ return new OpenCloseAction();
+ }
+
+ protected MouseListener createMouseListener()
+ {
+ /* There follows a major cludge to get the popup to close
+ * properly.
+ */
+
+ return new MouseAdapter()
+ {
+ public void mousePressed(MouseEvent e)
+ {
+ display.requestFocus();
+ }
+
+ public void mouseReleased(MouseEvent e)
+ {
+ mustClose = isShowing;
+ }
+
+ public void mouseEntered(MouseEvent e)
+ {
+ mustClose = isShowing;
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ mustClose = isShowing;
+ }
+ };
+ }
+
+ protected void registerKeyboardActions()
+ {
+
+ display.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,
InputEvent.CTRL_MASK), "OPEN");
+ display.getActionMap().put("OPEN", openAction);
+ }
+
+ protected void unRegisterKeyboardActions()
+ {
+
//display.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,
InputEvent.ALT_MASK));
+ }
+
+
+ private void showPopup()
+ {
+ if (panel == null)
+ {
+ panel = createMDateSelectorPanel();
+ }
+ if (popup == null)
+ {
+ dateEntry.notifyListeners(new FocusEvent(dateEntry,
FocusEvent.FOCUS_GAINED));
+ /*
+ * Remove the focus listener so that when the pull down receives
the focus, the
+ * focusLost event is not caught
+ */
+ dateEntry.opened();
+ Point p = dateEntry.getLocationOnScreen();
+
+ panel.setShowTodayButton(dateEntry.getShowTodayButton());
+ panel.setCloseOnToday(dateEntry.getCloseOnToday());
+ panel.setPullDownConstraints(dateEntry.getConstraints());
+ panel.setBorder(createBorder());
+ d = panel.getPreferredSize();
+
+ if (checkLightPosition(dateEntry, p))
+ {
+ popup = createLightWeightPopup();
+ }
+ else
+ {
+ checkHeavyPosition(dateEntry, p);
+ popup = createHeavyWeightPopup();
+ }
+
+ /* This is where the MCalendarPanel is configured */
+
+
+ if (display.getMinimum() != null)
+ {
+ panel.setMinimum(display.getMinimum());
+ }
+ if (display.getMaximum() != null)
+ {
+ panel.setMaximum(display.getMaximum());
+ }
+
+ panel.setDate(display.getValue(new Date()));
+ panel.addMMonthListener(mMonthListener);
+
+ popup.setShadow(dateEntry.getConstraints().hasShadow());
+ popup.addComponent(panel, BorderLayout.CENTER);
+ popup.pack();
+ popup.setLocationOnScreen(p.x, p.y);
+ popup.setParent(display);
+ popup.setVisible(true);
+
+ popup.requestFocus();
+ dateEntry.notifyListeners(MChangeEvent.PULLDOWN_OPENED);
+ }
+ }
+
+ private void destroyPopup()
+ {
+ if (popup != null)
+ {
+ panel.removeMMonthListener(mMonthListener);
+ popup.setVisible(false);
+ dateEntry.notifyListeners(MChangeEvent.PULLDOWN_CLOSED);
+ isShowing = false;
+ popup.removeComponent(panel);
+ switch (popup.getWeight())
+ {
+ case MPopup.LIGHT:
+ recycleLightPopup(popup);
+ break;
+ case MPopup.HEAVY:
+ // Don't recycle heavy weights until we sort out the focus
problems with JWindow
+ //recycleHeavyPopup(popup);
+ break;
+ default:
+ }
+ }
+ popup = null;
+ }
+
+ protected MDateSelectorPanel createMDateSelectorPanel()
+ {
+ MDateSelectorPanel panel;
+
+ panel = new MDateSelectorPanel();
+ panel.setFocusCycleRoot(true);
+
+
panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP,
InputEvent.CTRL_MASK), "CLOSE");
+
panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
0), "CLOSE");
+ panel.getActionMap().put("CLOSE", closeAction);
+
+
+
panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,
0), "CANCEL");
+ panel.getActionMap().put("CANCEL", cancelAction);
+
+ return panel;
+ }
+
+
+ private boolean checkLightPosition(Component field, Point p)
+ {
+ Container parent;
+ if (SwingUtilities.getAncestorOfClass(JFrame.class, field) == null &&
+ SwingUtilities.getAncestorOfClass(JDialog.class, field) ==
null)
+ {
+ return false;
+ }
+ parent = SwingUtilities.getAncestorOfClass(Window.class, field);
+ Point pr = parent.getLocationOnScreen();
+ // pr represents the field position relative to its parent frame
+ pr.x = p.x - pr.x;
+ pr.y = p.y - pr.y;
+
+ return getPositionRelative(d, field.getSize(), parent.getSize(), pr,
p);
+ }
+
+ private boolean getPositionRelative(Dimension popupSize, Dimension
fieldSize, Dimension parent, Point pr, Point p)
+ {
+ Point pos = new Point(p.x, p.y);
+ //Vertical
+ if (pr.y + fieldSize.height + popupSize.height <= parent.height)
+ {
+ // Draw popup below the field
+ pos.y = p.y + fieldSize.height;
+ }
+ else if (pr.y - d.height >= 0)
+ {
+ // Draw popup above the field
+ pos.y = p.y - d.height;
+ }
+ else
+ {
+ return false;
+ }
+
+ //Horizontal
+ if (pr.x + popupSize.width <= parent.width)
+ {
+ // Fits OK
+ }
+ else if (pr.x + fieldSize.width - popupSize.width >= 0)
+ {
+ pos.x = pos.x - (popupSize.width - fieldSize.width);
+ }
+ else
+ {
+ return false;
+ }
+
+ p.x = pos.x;
+ p.y = pos.y;
+ return true;
+ }
+
+ private boolean checkHeavyPosition(Component field, Point p)
+ {
+ Point pr = field.getLocation();
+ SwingUtilities.convertPointToScreen(pr, field);
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ return getPositionRelative(d, field.getSize(), screenSize, p, p);
+ }
+
+ /*
+ * @returns a light weight Popup , either a brand new one or a recycled
one
+ */
+ private MPopup createLightWeightPopup()
+ {
+ MPopup p;
+ p = getRecycledLightPopup();
+ if (p == null)
+ {
+ p = new MPopupPanel();
+ }
+ return p;
+ }
+
+ private MPopup getRecycledLightPopup()
+ {
+ synchronized (classLock)
+ {
+ if ((lightPopupCache.size()) > 0)
+ {
+ MPopup r = (MPopup) lightPopupCache.elementAt(0);
+ lightPopupCache.removeElementAt(0);
+ return r;
+ }
+ return null;
+ }
+ }
+
+ private void recycleLightPopup(MPopup aPopup)
+ {
+ synchronized (classLock)
+ {
+ if (lightPopupCache.size() < MAX_CACHE_SIZE)
+ {
+ lightPopupCache.addElement(aPopup);
+ }
+ }
+ }
+
+ private MPopup createHeavyWeightPopup()
+ {
+ MPopup p;
+ p = getRecycledHeavyPopup();
+
+ if (p == null)
+ {
+ Dialog d = ScreenUtilities.getParentDialog(display);
+ if (d != null)
+ {
+ p = new MPopupDialog(d);
+ return p;
+ }
+
+ Frame f = ScreenUtilities.getParentFrame(display);
+ if (f != null)
+ {
+ p = new MPopupDialog(f);
+ return p;
+ }
+ }
+
+ return new MPopupWindow();
+ }
+
+ private MPopup getRecycledHeavyPopup()
+ {
+ synchronized (classLock)
+ {
+ if ((heavyPopupCache.size()) > 0)
+ {
+ MPopup r = (MPopup) heavyPopupCache.elementAt(0);
+ heavyPopupCache.removeElementAt(0);
+ return r;
+ }
+ return null;
+ }
+ }
+
+ /*
+ * Manufactures a border for the popup calendar. Subclasses should return
+ * a zero width empty border if no border is required.
+ * @return a border for the popup calendar
+ */
+ private Border createBorder()
+ {
+ if (border == null)
+ {
+ Border innerBorder = BorderFactory.createEmptyBorder(2, 3, 0, 3);
+ Border outerBorder = BorderFactory.createLineBorder(Color.black);
+ return BorderFactory.createCompoundBorder(outerBorder,
innerBorder);
+ }
+ return border;
+
+ }
+
+ protected MMonthListener createMMonthListener()
+ {
+ return
+ new MMonthListener()
+ {
+ boolean echoSelection = true;
+
+ public void dataChanged(MMonthEvent e)
+ {
+ int type = e.getType();
+ if (type == MMonthEvent.EXITED)
+ {
+ destroyPopup();
+ dateEntry.closed();
+ SwingUtilities.invokeLater(testFocus);
+ }
+ if (type == MMonthEvent.SELECTED)
+ {
+ display.setValue(e.getNewDate().getTime());
+ destroyPopup();
+ display.requestFocus();
+ dateEntry.closed();
+ }
+ echoSelection =
dateEntry.getConstraints().isSelectionEventsEnabled();
+
+ if (((type == MMonthEvent.NEW_DATE)
+ || (type == MMonthEvent.NEW_MONTH)
+ || (type == MMonthEvent.SELECTED)) &&
echoSelection)
+ {
+ display.setValue(e.getNewDate().getTime());
+ dateEntry.notifyListeners(MChangeEvent.CHANGE);
+ }
+ }
+ };
+ }
+
+ /*
+ * This variable is invoked by SwingUtiities.invokeLater after the
focusEvents have
+ * been process so that we can determine where the focus end up. If it is
outside of
+ * the component then we need to fire the event otherwise the component
still has focus
+ * so no event is need yet
+ */
+ Runnable testFocus = new Runnable()
+ {
+ public void run()
+ {
+ if (!display.hasFocus())
+ {
+ dateEntry.notifyListeners(new FocusEvent(dateEntry,
FocusEvent.FOCUS_LOST));
+ }
+ }
+ };
+
+ /**
+ * Deals with the components ancestor being moved & removed, especially
for when
+ * the component is used in an Applet & the browser is closed.
+ */
+ protected AncestorListener createAncestorListener()
+ {
+ return new AncestorListener()
+ {
+ public void ancestorAdded(AncestorEvent event)
+ {
+ }
+
+ public void ancestorRemoved(AncestorEvent event)
+ {
+ if (isShowing)
+ {
+ destroyPopup();
+ }
+ }
+
+ public void ancestorMoved(AncestorEvent event)
+
+ {
+ if (isShowing)
+ {
+ destroyPopup();
+ display.requestFocus();
+ }
+ }
+ };
+ }
+
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ String event = evt.getPropertyName();
+ if (event.equals("enabled"))
+ {
+ Object o = evt.getNewValue();
+ boolean enabled = ((Boolean) o).booleanValue();
+ display.setEnabled(enabled);
+ arrowButton.setEnabled(enabled);
+ if (enabled)
+ {
+ registerKeyboardActions();
+ }
+ else
+ {
+ unRegisterKeyboardActions();
+ }
+ }
+ }
+}
+
+/* $Log: BasicDateEntryUI.java,v $
+/* Revision 1.28 2004/05/05 14:52:14 martin
+/* *** empty log message ***
+/*
+/* Revision 1.27 2004/03/07 17:10:28 martin
+/* *** empty log message ***
+/*
+/* Revision 1.26 2004/03/05 23:25:23 martin
+/* *** empty log message ***
+/*
+/* Revision 1.25 2003/10/11 09:38:47 martin
+/* *** empty log message ***
+/*
+/* Revision 1.24 2003/08/22 21:52:45 martin
+/* no message
+/*
+/* Revision 1.23 2003/03/26 23:29:49 martin
+/* Changed email address
+/*
+/* Revision 1.22 2003/03/26 23:26:32 martin
+/* no message
+/*
+/* Revision 1.21 2003/03/24 19:45:07 martin
+/* Latest 1.4 version
+/*
+/* Revision 1.19 2003/03/12 20:35:17 martin
+/* *** empty log message ***
+/*
+/* Revision 1.18 2003/03/11 22:37:36 martin
+/* *** empty log message ***
+/*
+/* Revision 1.17 2003/03/11 22:35:15 martin
+/* Upgraded to Java 1.4 on 11/03/03
+/*
+/* Revision 1.16 2003/01/18 16:40:09 martin
+/* *** empty log message ***
+/*
+/* Revision 1.15 2003/01/15 21:47:24 martin
+/* *** empty log message ***
+/*
+/* Revision 1.14 2002/12/21 22:53:16 martin
+/* *** empty log message ***
+/*
+/* Revision 1.13 2002/11/20 20:17:42 martin
+/* Fixed bug for InputVerifier and AncesterListener
+/*
+/* Revision 1.12 2002/08/29 20:56:44 martin
+/* *** empty log message ***
+/*
+/* Revision 1.11 2002/06/13 19:25:14 martin
+/* Added closeOnToday button support
+/*
+/* Revision 1.10 2002/02/27 22:03:57 martin
+/* Removed unregisterKeyboardAction
+/*
+/* Revision 1.9 2002/02/27 21:53:14 martin
+/* Replaced obsolete method JComponent.registerKeyboardAction with JDK1.3.1
versions
+/*
+/* Revision 1.8 2002/02/24 12:33:47 martin
+/* Fixed a placement bug for heavy weight popup
+/*
+/* Revision 1.7 2002/02/16 18:13:09 martin
+/* The events to update the text field are switchable and can be disabled.
This makes the escape key more effective
+/*
+/* Revision 1.6 2002/02/04 20:11:48 martin
+/* Removed re-cycle of heavy weights
+/*
+/* Revision 1.5 2002/02/03 13:06:27 martin
+/* Recycle Heavyweight popup
+/*
+/* Revision 1.4.2.2 2002/02/22 20:49:02 martin
+/* Fixed a focus problem on 1.4
+/*
+/* Revision 1.4.2.1 2002/02/02 13:31:26 martin
+/* Generate Heavy weight popup with MPopupDialog
+/*
+/* Revision 1.4 2002/01/22 21:36:07 martin
+/* Find and pass owner to heavyweight popup calendar
+/*
+/* Revision 1.3 2002/01/01 14:38:02 martin
+/* Better detectio for lightweight/heavyweight popup which makes improves use
in BeanBox
+/* */
\ No newline at end of file
Added:
trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicHeaderUI.java
===================================================================
--- trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicHeaderUI.java
2006-03-14 14:05:52 UTC (rev 8250)
+++ trunk/apps/frost-0.7/lib/datechooser/mseries/plaf/basic/BasicHeaderUI.java
2006-03-14 14:06:31 UTC (rev 8251)
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2000 Martin Newstead (mseries at brundell.fsnet.co.uk). All
Rights Reserved.
+*
+* The author makes no representations or warranties about the suitability of
the
+* software, either express or implied, including but not limited to the
+* implied warranties of merchantability, fitness for a particular
+* purpose, or non-infringement. The author shall not be liable for any
damages
+* suffered by licensee as a result of using, modifying or distributing
+* this software or its derivatives.
+*
+* The author requests that he be notified of any application, applet, or
other binary that
+* makes use of this code and that some acknowedgement is given. Comments,
questions and
+* requests for change will be welcomed.
+*/
+package mseries.plaf.basic;
+
+import java.awt.*;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+import mseries.Calendar.*;
+
+public class BasicHeaderUI extends ComponentUI
+{
+ protected Header header;
+
+ /**
+ * This method is called by the UIManager to get an instance of
+ * this class and must be overridden in subclasses.
+ */
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicHeaderUI();
+ }
+
+ /*
+ * Called by the UIManager to install the UI of the component
+ */
+ public void installUI(JComponent c)
+ {
+ header = (Header)c;
+ installDefaults();
+ }
+
+ public void uninstallUI(JComponent c)
+ {
+ uninstallDefaults();
+ }
+
+ protected void installDefaults()
+ {
+ }
+
+ protected void uninstallDefaults() {};
+
+
+ public void update(Graphics g, JComponent c)
+ {
+ paint(g, c);
+ }
+
+ public Font getFont()
+ {
+ return header.getFont();
+ }
+
+ public void paint(Graphics g, JComponent c)
+ {
+ int cellWidth = getCellSize().width;
+ int cellHeight = getCellSize().height;
+ int cols = header.getCols();
+
+ String legend;
+ Font font = getFont();
+ int strWidth=0;
+ int strHeight=0;
+ int x,y;
+
+ FontMetrics fm;
+
+ for (int w=0; w <cols ; w++)
+ {
+ if(isOpaque())
+ {
+ g.setColor(header.getBackground(w));
+ g.fillRect(0, 0, cellWidth, cellHeight);
+ }
+
+ legend = header.getColumnName(w);
+ g.translate(cellWidth*w, 0);
+ if (legend != null)
+ {
+ g.setFont(getFont());
+ fm = g.getFontMetrics();
+ strWidth = fm.stringWidth(legend);
+ strHeight = fm.getHeight();
+ x=cellWidth-strWidth-4;
+ y=((cellHeight-strHeight)/2)+strHeight-4;
+
+ g.setColor(header.getForeground(w));
+ g.drawString(legend, x, y);
+
+ }
+ g.translate(-cellWidth*w, 0);
+ }
+ }
+
+ public boolean isOpaque()
+ {
+ return header.isOpaque();
+ }
+
+ protected Dimension getCellSize()
+ {
+ return header.getCellSize();
+ }
+}
Modified: trunk/apps/frost-0.7/source/frost/Frost.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/Frost.java 2006-03-14 14:05:52 UTC
(rev 8250)
+++ trunk/apps/frost-0.7/source/frost/Frost.java 2006-03-14 14:06:31 UTC
(rev 8251)
@@ -45,8 +45,7 @@
System.out.println("redistribute it under the GPL conditions.");
System.out.println("Frost uses code from apache.org (Apache
license),");
System.out.println("bouncycastle.org (BSD license), Onion Networks
(BSD license),");
- System.out.println("and L2FProd.com (Apache license).");
-// System.out.println("and ShiftOne Java Object Cache (LGPL license)");
+ System.out.println("L2FProd.com (Apache license) and Martin Newstead
(LGPL license).");
System.out.println();
parseCommandLine(args);