home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 5.6 KB | 182 lines |
- /*---------------------------------------------------------------------------
-
- Written by the Personal Journal developers of Dow Jones & Company, Inc.
-
- Dow Jones makes no representations or warranties about
- the suitability of this software, either express or
- implied, including but not limited to the implied warranties
- of merchantability, fitness for a particular purpose,
- or non-infringement. Dow Jones will not be liable for
- any damages suffered by a user as a result of using,
- modifying or distributing this software or its derivatives.
-
-
- @(#)DogEar.java
-
- The page turner control used to step through the pages of PJ
- one by one. It has a picture of a dog-eared page, hence the name.
- Maybe, I should have called it PageTurner, se la guerre.
-
-
- Authors:
-
- Ted S. Ted Skolnick
- jlee James Lee
-
- Version Ident:
-
- $Header$
-
-
- History:
-
- 0.00 2-feb-1996 Ted S. Initial Creation
- 0.01 23-Feb-96 Ted S. Made use of nextView method to turn pages.
- 4-Mar-96 jlee Replace CheckboxNb with TabNotebook.
-
- ---------------------------------------------------------------------------*/
-
- package pj.awt;
-
-
- import pj.awt.PjImages;
- import pj.awt.TabNotebook;
- import pj.net.RemoteImage;
- import pj.net.RemoteString;
- import pj.net.RemoteURL;
-
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.awt.Panel;
- import java.awt.*;
-
- /**
- * Fill me in with description
- *
- * @see
- * @see
- * @version 0.00 03-Jan-96
- * @author Ted Skolnick
- */
- public class DogEar extends Canvas
- {
-
- // --- Class variables
-
- private static final short IDB_PAGE_BOTH = 0; //both, up
- private static final short IDB_PAGE_RIGHT_DOWN = 1; // both, right down
- private static final short IDB_PAGE_LEFT_DOWN = 2; // both, left down
-
- private static Image ImageList[];
-
- private static final int iMinWidth = 34;
- private static final int iMinHeight = 34;
-
- // --- Instance variables
-
- private short miCurrentImage;
- private boolean mbClickPrev;
- private TabNotebook notebook;
-
-
-
- // --- Public constructors
- /**
- * @param ImagesIn - PJ's repository for all images, DogEar takes the ones it needs.
- * @param Notebook - The notebook to step through when a page turner is pressed.
- */
- public DogEar( PjImages ImagesIn, TabNotebook Nb )
- {
- notebook = Nb;
-
- // Load up DogEar with images.
- ImageList = new Image[3];
- ImageList[IDB_PAGE_BOTH]=
- ImagesIn.imagespecs()[ PjImages.idxDogEarBothUp ].getImage();
- ImageList[IDB_PAGE_RIGHT_DOWN]=
- ImagesIn.imagespecs()[ PjImages.idxDogEarRightDown ].getImage();
- ImageList[IDB_PAGE_LEFT_DOWN]=
- ImagesIn.imagespecs()[ PjImages.idxDogEarLeftDown ].getImage();
-
- // Init to show both pages in the up position.
- SetImage(IDB_PAGE_BOTH);
-
- System.out.println("Debug-DogEar:constructed");
- }
-
- // --- Public operations
-
- // Draw the control in its current state.
- public void paint( Graphics g )
- {
- g.drawImage( ImageList[ miCurrentImage ], 0, 0, iMinWidth, iMinHeight, this );
- }
-
-
- // Make it look like the user pressed down on the page turner,
- // and remember which side ( prev or next ) was pressed.
- public boolean mouseDown( Event e, int x, int y )
- {
- mbClickPrev = IsOverPrev( x );
- if ( mbClickPrev )
- {
- SetImage(IDB_PAGE_LEFT_DOWN);
- }
- else
- {
- SetImage(IDB_PAGE_RIGHT_DOWN);
- }
-
- return true;
- }
-
- // When the user releases the mouse, then tell the notebook to change pages.
- public boolean mouseUp( Event e, int x, int y )
- {
-
- SetImage(IDB_PAGE_BOTH);
- if (mbClickPrev)
- notebook.previousView();
- else
- notebook.nextView();
-
- return true;
- }
-
-
- // Tell java how much space this control requires.
- public Dimension preferredSize()
- {
- //System.out.println("Debug pS ");
- return minimumSize();
- }
-
- // Tell java how much space this control requires.
- public Dimension minimumSize()
- {
- //System.out.println("Debug Dimension ");
- return new Dimension(iMinWidth,iMinHeight);
- }
-
- // --- Private operations
-
- private void SetImage( short nNewImage )
- {
- // Set the current image, and redraw the control.
- miCurrentImage = nNewImage;
-
- repaint();
- }
-
- // Is the mouse over the previous button?, if not it is over next.
- private boolean IsOverPrev( int x )
- {
- // The previous button is the left half of the control.
- return ( x < ( iMinWidth/2 ) );
- }
-
-
- } // DogEar
-
-
-