home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 13
/
boot-disc-1997-09.iso
/
HyprWire
/
DATA.Z
/
ScrollbarPlugIn.java
< prev
next >
Wrap
Text File
|
1997-01-21
|
8KB
|
298 lines
package kinetix.hyperc1.userPlugIns;
/********************************************************************************\
** **
** (C) Copyright 1997 by Autodesk, Inc. **
** **
** This program is copyrighted by Autodesk, Inc. and is licensed to you under **
** the following conditions. You may not distribute or publish the source **
** code of this program in any form. You may incorporate this code in object **
** form in derivative works provided such derivative works are (i.) are de- **
** signed and intended to work solely with Autodesk, Inc. products, and (ii.) **
** contain Autodesk's copyright notice "(C) Copyright 1997 by Autodesk, Inc." **
** **
** AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. AUTODESK SPE- **
** CIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR **
** A PARTICULAR USE. AUTODESK, INC. DOES NOT WARRANT THAT THE OPERATION OF **
** THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE. **
** **
\********************************************************************************/
/**************************************************************************
ScrollBarPlugIn: Scrollbar AWT Widget implemented in Hyperwire
Author: Hyperwire demonstration file
Version: 1.0
Note: This PlugIn is used for both Horizontal and Vertical Scrollbars
**************************************************************************/
import kinetix.hyperc1.runtime.*;
import java.awt.*;
import java.applet.Applet;
/*** Class Declaration ***/
public class ScrollbarPlugIn extends HwVisualUserPlugIn
{
/*** Custom Object ***/
AWTScrollbar AWTObject;
public boolean mCreatingAWTObject = false;
/*** Persistent Properties ***/
int value, visible, minimum, maximum, type;
/*** Class Methods ***/
private void createAWTObject()
{
if (mCreatingAWTObject) return;
mCreatingAWTObject = true;
VisualRunService runService = piGetVisualRunService();
Applet theApplet = runService.siGetApplet();
Rectangle textRect = runService.siGetAbsRect();
// Create the AWT Object
if ( type == 1 )
{
AWTObject = new AWTScrollbar(this, Scrollbar.HORIZONTAL);
}
else
{
AWTObject = new AWTScrollbar(this, Scrollbar.VERTICAL);
}
// Add it to the Applet and set the size to the PlugIn's size
theApplet.add(AWTObject, 0);
AWTObject.reshape(textRect.x, textRect.y, textRect.width, textRect.height);
// Set and object-specific values
AWTObject.setLineIncrement(1);
AWTObject.setPageIncrement(10);
AWTObject.setValues(value,visible,minimum,maximum);
// And away we go!
AWTObject.show();
mCreatingAWTObject = false;
}
/*** VisualRunPlugIn Implementation ***/
/*
/* The following 7 methods allow a
/* PlugIn to draw an AWT Object (or a
/* sub-class thereof) to the Hyperwire
/* runtime.
/* */
public void piEventAppletStart(Applet theApplet) throws HwException
{
if (AWTObject == null) createAWTObject();
}
public void piEventAboutToHide(int why) throws HwException
{
if (AWTObject != null)
{
if ( why == BasicRunPlugIn.E_THIS ) AWTObject.nextFocus();
AWTObject.hide();
}
}
public void piEventAboutToShow(int why) throws HwException
{
if (AWTObject != null) AWTObject.show();
}
public void piEventParentMovedBy(VisualRunPlugIn aParent, int xOffset, int yOffset) throws HwException
{
if (AWTObject != null)
{
Rectangle absRect = piGetVisualRunService().siGetAbsRect();
VisualRunRepresentation vRep = (VisualRunRepresentation) piGetVisualRunService();
AWTObject.reshape(absRect.x + xOffset, absRect.y + yOffset, absRect.width, absRect.height);
}
}
public void piRestoreInitialRunState() throws HwException
{
piSetAbsRect(piGetVisualRunService().siGetAbsRect());
}
public void piSetAbsRect(Rectangle aRect) throws HwException
{
if (AWTObject != null) AWTObject.reshape(aRect.x, aRect.y, aRect.width, aRect.height);
}
/*** End VisualRunPlugIn Implementation ***/
/*** Event Handler -- events from sub-class of AWT Object ***/
public boolean handleEvent( Event e ) throws HwException
{
switch (e.id)
{
case Event.SCROLL_ABSOLUTE:
piGetVisualRunService().siPerformOutput("Absolute",
HwInt.from(AWTObject.getValue()));
piGetVisualRunService().siPerformOutput("Changed",
HwInt.from(AWTObject.getValue()));
return true;
case Event.SCROLL_LINE_UP:
piGetVisualRunService().siPerformOutput("LineUp",
HwInt.from(AWTObject.getValue()));
piGetVisualRunService().siPerformOutput("Changed",
HwInt.from(AWTObject.getValue()));
return true;
case Event.SCROLL_LINE_DOWN:
piGetVisualRunService().siPerformOutput("LineDown",
HwInt.from(AWTObject.getValue()));
piGetVisualRunService().siPerformOutput("Changed",
HwInt.from(AWTObject.getValue()));
return true;
case Event.SCROLL_PAGE_UP:
piGetVisualRunService().siPerformOutput("PageUp",
HwInt.from(AWTObject.getValue()));
piGetVisualRunService().siPerformOutput("Changed",
HwInt.from(AWTObject.getValue()));
return true;
case Event.SCROLL_PAGE_DOWN:
piGetVisualRunService().siPerformOutput("PageDown",
HwInt.from(AWTObject.getValue()));
piGetVisualRunService().siPerformOutput("Changed",
HwInt.from(AWTObject.getValue()));
return true;
}
return false;
}
/*** Properties Interface ***/
public void fiSetValue( int i) { value = i; }
public void fiSetVisible( int i) { visible = i; }
public void fiSetMinimum( int i) { minimum = i; }
public void fiSetMaximum( int i) { maximum = i; }
public void fiSetType( int i ) { type = i; }
/*** Wire Interface ***/
/* These are all calls to methods in the AWT Object */
public int wiSetValue( int i)
{
AWTObject.setValue(i);
return i;
}
public int wiGetValue()
{
return AWTObject.getValue();
}
public int wiSetVisible( int i)
{
AWTObject.setValues(AWTObject.getValue(), i, minimum, maximum);
return i;
}
public int wiGetVisible()
{
return AWTObject.getVisible();
}
public int wiSetMinimum( int i)
{
AWTObject.setValues(AWTObject.getValue(), visible, i, maximum);
return i;
}
public int wiGetMinimum()
{
return AWTObject.getMinimum();
}
public int wiSetMaximum( int i)
{
AWTObject.setValues(AWTObject.getValue(), visible, minimum, i);
return i;
}
public int wiGetMaximum()
{
return AWTObject.getMaximum();
}
public int wiSetPageIncrement( int i)
{
AWTObject.setPageIncrement(i);
return i;
}
public int wiGetPageIncrement()
{
return AWTObject.getPageIncrement();
}
public int wiSetLineIncrement( int i)
{
AWTObject.setLineIncrement(i);
return i;
}
public int wiGetLineIncrement()
{
return AWTObject.getLineIncrement();
}
}
/*** End ScrollbarPlugIn ***/
/***********************************************************************
AWTScrollBar: Sub-class of AWT Scrollbar widget, with event handler
Author: Amalgamated YoYoDyne PlugIns, Inc.(Hyperwire demonstraton file)
Version: 1.0
***********************************************************************/
class AWTScrollbar extends Scrollbar
{
ScrollbarPlugIn mPlugIn;
/*** Constructor ***/
public AWTScrollbar(ScrollbarPlugIn aPlugIn, int type)
{
super(type);
mPlugIn = aPlugIn;
}
/*** Pass Events back to the PlugIn ***/
public boolean handleEvent ( Event evt )
{
try
{
return mPlugIn.handleEvent( evt );
}
catch(Exception e)
{
HwException oe = mPlugIn.piGetRunService().siProcessException(e, "Scrollbar Widget Error");
mPlugIn.piGetRunService().siLogException(oe);
}
return false;
}
}
/*** End AWTScrollbar ***/