home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 13
/
boot-disc-1997-09.iso
/
HyprWire
/
DATA.Z
/
ListPlugIn.java
< prev
next >
Wrap
Text File
|
1997-01-21
|
8KB
|
287 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. **
** **
\********************************************************************************/
/**************************************************************************
ListPlugIn: List AWT Widget implemented in Hyperwire
Author: Amalgamated YoYoDyne PlugIns, Inc.(Hyperwire demonstration file)
Version: 1.0
**************************************************************************/
import kinetix.hyperc1.runtime.*;
import java.awt.*;
import java.applet.Applet;
/*** Class Declaration ***/
public class ListPlugIn extends HwVisualUserPlugIn
{
AWTList mObject;
boolean mCreatingAWTObject = false;
String s [] = new String [20];
/*** Instance methods ***/
public void createAWTObject()
{
if (mCreatingAWTObject) return;
mCreatingAWTObject = true;
VisualRunService runService = piGetVisualRunService();
Applet theApplet = runService.siGetApplet();
Rectangle textRect = runService.siGetAbsRect();
mObject = new AWTList(this);
for ( int i=0; i < 20; i++ )
{
if ( !s[i].equals("") )
mObject.addItem( s[i] );
}
theApplet.add(mObject, 0);
mObject.reshape(textRect.x, textRect.y, textRect.width, textRect.height);
mObject.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 (mObject == null)
createAWTObject();
}
public void piEventAboutToHide(int why) throws HwException
{
if (mObject != null)
{
if ( why == BasicRunPlugIn.E_THIS )
mObject.nextFocus();
mObject.hide();
}
}
public void piEventAboutToShow(int why) throws HwException
{
if (mObject != null)
{
mObject.show();
}
}
public void piEventParentMovedBy(VisualRunPlugIn aParent, int xOffset, int yOffset)
throws HwException
{
if (mObject != null)
{
Rectangle absRect = piGetVisualRunService().siGetAbsRect();
VisualRunRepresentation vRep = (VisualRunRepresentation) piGetVisualRunService();
mObject.reshape(absRect.x + xOffset, absRect.y + yOffset,
absRect.width, absRect.height);
}
}
public void piRestoreInitialRunState() throws HwException
{
System.out.println("Restore");
piSetAbsRect(piGetVisualRunService().siGetAbsRect());
}
public void piSetAbsRect(Rectangle aRect) throws HwException
{
if (mObject != null)
{
mObject.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.LIST_SELECT:
piGetVisualRunService().siPerformOutput("ListSelect",
HwString.from(mObject.getSelectedItem()) );
return true;
}
return false;
}
/*** Properties Interface ***/
public void fiSetListItem1 ( String item ) { s[0] = item; }
public void fiSetListItem2 ( String item ) { s[1] = item; }
public void fiSetListItem3 ( String item ) { s[2] = item; }
public void fiSetListItem4 ( String item ) { s[3] = item; }
public void fiSetListItem5 ( String item ) { s[4] = item; }
public void fiSetListItem6 ( String item ) { s[5] = item; }
public void fiSetListItem7 ( String item ) { s[6] = item; }
public void fiSetListItem8 ( String item ) { s[7] = item; }
public void fiSetListItem9 ( String item ) { s[8] = item; }
public void fiSetListItem10 ( String item ) { s[9] = item; }
public void fiSetListItem11 ( String item ) { s[10] = item; }
public void fiSetListItem12 ( String item ) { s[11] = item; }
public void fiSetListItem13 ( String item ) { s[12] = item; }
public void fiSetListItem14 ( String item ) { s[13] = item; }
public void fiSetListItem15 ( String item ) { s[14] = item; }
public void fiSetListItem16 ( String item ) { s[15] = item; }
public void fiSetListItem17 ( String item ) { s[16] = item; }
public void fiSetListItem18 ( String item ) { s[17] = item; }
public void fiSetListItem19 ( String item ) { s[18] = item; }
public void fiSetListItem20 ( String item ) { s[19] = item; }
/*** Wire Interface ***/
/* These are all calls to methods in the AWT Object */
public int wiCountItems()
{
return mObject.countItems();
}
public String wiGetItem( int i )
{
return mObject.getItem( i );
}
public void wiAddItem( String item )
{
mObject.addItem( item );
}
public void wiAddItemAtIndex( String item, int i )
{
mObject.addItem( item, i );
}
public void wiClear()
{
mObject.clear();
}
public void wiDelItem( int i )
{
mObject.delItem( i );
}
public void wiDelItems( int i, int j )
{
mObject.delItems( i, j );
}
public void wiReplaceItem( String item, int i)
{
mObject.replaceItem( item, i );
}
public int wiGetSelectedIndex()
{
return mObject.getSelectedIndex();
}
public void wiSelect( int i )
{
mObject.select( i );
}
public void wiDeselect( int i )
{
mObject.deselect( i );
}
public boolean wiIsSelected( int i )
{
return mObject.isSelected( i );
}
public int wiGetRows()
{
return mObject.getRows();
}
public void wiMakeVisible( int i )
{
mObject.makeVisible( i );
}
}
/*** End ListPlugIn ***/
/***********************************************************************
AWTScrollBar: Sub-class of AWT Scrollbar widget, with event handler
Author: Amalgamated YoYoDyne PlugIns, Inc.(Hyperwire demonstraton file)
Version: 1.0
***********************************************************************/
class AWTList extends List
{
ListPlugIn mPlugIn;
/*** Constructor ***/
public AWTList(ListPlugIn aPlugIn)
{
super();
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, "List Widget Error");
mPlugIn.piGetRunService().siLogException(oe);
}
return false;
}
}
/*** End AWTList ***/