home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 November
/
pcwk_11_98a.iso
/
Wtestowe
/
SOFTSRC
/
vtrial15.exe
/
DATA.1
/
Vutil.h
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-09
|
4KB
|
152 lines
/*
Vdraft plugin - vutil.h
(C) Copyright 1997 by SoftSource. All rights reserved.
Scott Sherman 1-97...
useful tools to help build Vdraft add-ons
*/
#ifndef VUTIL_H
#define VUTIL_H
#define PI 3.14159265358979
// base class for encapsulating handling Vdraft Plug-in events
class cVdraftEvent
{
public:
cVdraftEvent(IVdraft& vdraft, vtAddOnID id);
virtual ~cVdraftEvent() {}
protected:
// derived classes can access Vdraft objects from here
IVdraft& getVdraft() { return m_vdraft; }
vtAddOnID getAddOnID() { return m_id; }
private:
IVdraft m_vdraft; // Vdraft interface
vtAddOnID m_id; // id passed to Vdraft when requesting events
};
//
// to handle pick events, derive from cPickEvent and override
// the event functions you need to handle
// if you use this class, remember to add Vutil.cpp to your project
// and export vfPickEvent in your .def file
// e.g. IPickEvents pick(doc.GetPickEvents());
// pick.RequestPick(id,cVariant(new cMyEvent(vdraft,id)));
class cPickEvent : public cVdraftEvent
{
public:
cPickEvent(IVdraft& vdraft, vtAddOnID id) : cVdraftEvent(vdraft,id) {}
// events derived classes can respond to
// override & provide your own implementation
virtual void Done() {} // Done chosen from popup
virtual void Cancel() {} // pick was aborted
virtual void Pick(double* point) {} // a point has been picked
virtual void Properties() {} // Properties chosen from popup
virtual void Undo() {} // Undo chosen from popup
};
//
// to handle draw events, derive from cDrawEvent and override
// the event functions you need to handle
// if you use this class, remember to add Vutil.cpp to your project
// and export vfDrawEvent in your .def file
// e.g. IPickEvents pick(doc.GetPickEvents());
// pick.RequestDraw(id,cVariant(new cMyEvent(vdraft,id)));
class cDrawEvent : public cVdraftEvent
{
public:
cDrawEvent(IVdraft& vdraft, vtAddOnID id) : cVdraftEvent(vdraft,id) {}
// events derived classes can respond to
// override & provide your own implementation
virtual void Done() {} // drawing is completely done
virtual void Cancel() {} // drawing has been aborted
virtual void Pick(double* point, short picknumber) {} // a point has been picked
};
//
// to handle selection events, derive from cSelectEvent and override
// the event functions you need to handle
// if you use this class, remember to add Vutil.cpp to your project
// and export vfSelectEvent in your .def file
// e.g. ISelectionEvents select(doc.GetSelectionEvents());
// select.RequestSelect(id,cVariant(new cSelectEvent(vdraft,id)));
class cSelectEvent : public cVdraftEvent
{
public:
cSelectEvent(IVdraft& vdraft, vtAddOnID id) : cVdraftEvent(vdraft,id) {}
// events derived classes can respond to
// override & provide your own implementation
virtual void Done() {} // the user is done selecting objects
virtual void Cancel() {} // the user aborted the selection process
};
//
// utility class which makes passing VARIANTs easier
// e.g. IVector myvector( vdraft.NewVector(cVariant(2.97), cVariant(3.14), cVariant() );
class cVariant
{
public:
cVariant()
{
variant.vt = VT_EMPTY;
}
cVariant(BOOL val)
{
variant.vt = VT_BOOL;
variant.boolVal = val;
}
cVariant(short val)
{
variant.vt = VT_I2;
variant.iVal = val;
}
cVariant(long val)
{
variant.vt = VT_I4;
variant.lVal = val;
}
cVariant(double val)
{
variant.vt = VT_R8;
variant.dblVal = val;
}
cVariant(BSTR val)
{
variant.vt = VT_BSTR;
variant.bstrVal = val;
}
cVariant(CString& val)
{
variant.vt = VT_BSTR;
variant.bstrVal = val.AllocSysString();
}
cVariant(LPDISPATCH val)
{
variant.vt = VT_DISPATCH;
variant.pdispVal = val;
}
cVariant(cVdraftEvent* event)
{
variant.vt = VT_I4;
variant.lVal = (long)event;
}
inline operator VARIANT&() { return variant; }
protected:
VARIANT variant;
};
// creating vectors
#define VECTOR2D(vdraft,x,y) (vdraft.NewVector(cVariant(x),cVariant(y),cVariant()))
#define VECTOR3D(vdraft,x,y,z) (vdraft.NewVector(cVariant(x),cVariant(y),cVariant(z)))
#endif // VUTIL_H