Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Attributes
LaxInterfaces::anInterface Class Reference

A class for key and mouse interfaces acting on particular windows. More...

Inheritance diagram for LaxInterfaces::anInterface:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 anInterface ()
 This constructor assigns id=getUniqueNumber().
 anInterface (int nid)
 Constructor to assign just the id, set other stuff to 0.
 anInterface (int nid, Laxkit::Displayer *ndp)
 anInterface (anInterface *nowner, int nid)
 Constructor to assign owner and id.
 anInterface (anInterface *nowner, int nid, Laxkit::Displayer *ndp)
virtual anInterfaceduplicate (anInterface *dup)
 Return or modify to almost duplicate instance.
virtual Laxkit::ShortcutHandlerGetShortcuts ()
 Return a ShortcutHandler that contains stacks of bound shortcuts and possible actions.
virtual int PerformAction (int actionnumber)
virtual const charIconId ()
virtual const charName ()
virtual const charwhattype ()
virtual const charwhatdatatype ()=0
virtual int draws (const char *atype)
 Returns !strcmp(whatdatatype(),atype).
virtual void Clear ()
 Default just calls Clear(NULL).
virtual int InterfaceOn ()
 Called when, for instance data is selected, and the interface must now show control points, and expect input.
virtual int InterfaceOff ()
 Called when the interface is no longer required to handle display of data.
virtual int RemoveChild ()
 If there is a child, do something to remove it.
virtual int AddChild (LaxInterfaces::anInterface *ch, int absorbcount, int addbefore)
virtual int Needtodraw ()
 Must return nonzero if the data needs to be drawn, that is to say Refresh must be called.
virtual int Needtodraw (int n)
virtual int LBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int MBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int RBDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int LBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int MBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int RBUp (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int WheelUp (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int WheelDown (int x, int y, unsigned int state, int count, const Laxkit::LaxMouse *d)
virtual int MouseMove (int x, int y, unsigned int state, const Laxkit::LaxMouse *d)
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const Laxkit::LaxKeyboard *d)
virtual int KeyUp (unsigned int ch, unsigned int state, const Laxkit::LaxKeyboard *d)
virtual int DeviceChange (const Laxkit::DeviceEventData *e)
virtual int Event (const Laxkit::EventData *e, const char *mes)
 Respond to events, particularly menu events from a menu created from ContextMenu().
virtual void ExposeChange (Laxkit::ScreenEventData *e)
virtual void ViewportResized ()
 Called after the parent viewport gets resized.
virtual void Mapped ()
 Called after the parent viewport gets mapped (made visible).
virtual void Unmapped ()
 Called after the parent viewport gets mapped (made invisible, such as offscreen, not merely obscured).
virtual int Refresh ()
virtual void PostMessage (const char *message)
 If viewport, use that, else app->postmessage().
virtual Laxkit::MenuInfoContextMenu (int x, int y, int deviceid)
 Return a context sensitive menu for screen position (x,y).
virtual int UseThis (int id, int ndata)
 Return 1 if the id/ndata is used, otherwise zero.
virtual int UseThis (Laxkit::anObject *ndata, unsigned int mask=0)
 Return 1 if interface can use that data, otherwise, the calling code must appropriately dispose of ndata.
virtual int UseThisObject (ObjectContext *oc)
virtual int DrawData (Laxkit::anObject *ndata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=0)
 Redefine this for interfaces that can draw data not owned, without loosing current data.
virtual Laxkit::anXWindowCurrentWindow (Laxkit::anXWindow *ncur)
 Set the window the interface works on to ncur. Returns ncur. If ncur==NULL, then just return current viewport.
virtual void Clear (SomeData *d)=0
 Clear the data from the interface only if d is the interface's current data.
virtual ObjectContextContext ()
virtual void Dp (Laxkit::Displayer *ndp)
 Set the dp to ndp, and update curwindow/viewport.
virtual int DrawDataDp (Laxkit::Displayer *tdp, SomeData *tdata, Laxkit::anObject *a1=NULL, Laxkit::anObject *a2=NULL, int info=1)
 Use a different dp to draw data with.
virtual flatpoint realtoscreen (flatpoint r)
 Do a little extra checking to find what point r should correspond to.
virtual flatpoint screentoreal (int x, int y)
 Do a little extra checking to find what point (x,y) should correspond to.
virtual double Getmag (int c=0)
 Do a little extra checking to find what the magnification is.
virtual double GetVMag (int x, int y)
 Do a little extra checking to find what the magnification is.
virtual void dump_out (FILE *f, int indent, int what, Laxkit::anObject *savecontext)
 Default settings saving is to output nothing.
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, Laxkit::anObject *loadcontext)
 Placeholder for dumping in settings.
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual Attributedump_out_atts (Attribute *att, int what, Laxkit::anObject *savecontext)
 Default is return NULL. what==0 means write out normal Attribute formatted things.
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.

Public Attributes

charname
 An instance name.. ***don't think this is used anywhere at the moment.
int id
 Must be positive, other values are reserved for internal use.
unsigned long style
 Style flags for the interface. Meaning depends on the interface.
int interface_type
 What sort of interface this is. Default is INTERFACE_Tool.
Laxkit::anXAppapp
 The application this interface works with.
Laxkit::anXWindowcurwindow
 The window the interface currently works on.
anInterfaceowner
 The interface that owns this one.
anInterfacechild
 The child of this interface. See anInterface::owner. This is dec_counted in destructor.
int primary
 Whether this is supposed to be a 'main' interface, or merely a helper.
int needtodraw
 Whether the interface thinks it has to refresh.

Protected Attributes

Laxkit::ButtonDownInfo buttondown
ViewportWindowviewport
 curwindow dynamically cast to ViewportWindow. Thus, it will be NULL if it is not a ViewportWindow.
Laxkit::Displayerdp
 The Displayer used by the controlling window.

Detailed Description

A class for key and mouse interfaces acting on particular windows.

anInterfaces are for use with, for instance, a ViewportWindow, which maintains a stack of interfaces, down through which input is sent. The convention used in ViewportWindow is that the input related member functions like LBDown() and WheelDown() must return 0 if they absorb the event, and nonzero if they do not. When it is a button, if the absorb an LBDown(), they MUST also absorb a corresponding LBUp().

For any derived classes, if you ever use the duplicate function please always remember to actually define your own duplicate function! Otherwise, your duplicate will just return NULL.

Interfaces designed for use in a ViewportWindow store their own data internally. Any time they create new data, they must call viewport->NewData(newdata). This allows the viewport to place the data properly. Interfaces generally are all able to search for objects of types they may or may not be able to use. After a search, they call viewport->NewData(data,context_returned_by_search_function).


Constructor & Destructor Documentation

LaxInterfaces::anInterface::anInterface ( anInterface nowner,
int  nid 
)

Constructor to assign owner and id.

Todo:
*** this isn't so hot, maybe do some check to ensure that owner->child points here?

References Laxkit::anXApp::app, and curwindow.


Member Function Documentation

int LaxInterfaces::anInterface::AddChild ( LaxInterfaces::anInterface ch,
int  absorbcount,
int  addbefore 
)
virtual

Will not add ch if child!=NULL. If addbefore!=0, then add at index-1 in viewport->interfaces. Else after *this.

Return 0 success, or nonzero for not added.

References Laxkit::anObject::inc_count(), and owner.

void LaxInterfaces::anInterface::Clear ( SomeData d)
pure virtual

Clear the data from the interface only if d is the interface's current data.

If d==NULL, then the interface should clear any data it has. Otherwise, clear only if the interface is using d.

Implemented in LaxInterfaces::PathInterface, LaxInterfaces::PatchInterface, LaxInterfaces::PointWarpInterface, and LaxInterfaces::ObjectInterface.

ObjectContext * LaxInterfaces::anInterface::Context ( )
virtual

Interfaces can choose to automate drawing of whatever data they have hold of. If Context() returns something, then the anInterface::dp will have that context applied before the Refresh() is called.

Default here is to return NULL. If subclasses do not return something here, they must apply any extra transform to their Displayer before refreshing. Generally, this means keeping track if Refresh() is called directly from the viewport, or if it is called from DrawDataDp().

Laxkit::MenuInfo * LaxInterfaces::anInterface::ContextMenu ( int  x,
int  y,
int  deviceid 
)
inlinevirtual

Return a context sensitive menu for screen position (x,y).

This should be a menu instance that gets deleted by the popped up menu. The interface should not refer to it again.

Default implementation here is to simply return NULL.

int LaxInterfaces::anInterface::DrawData ( Laxkit::anObject ndata,
Laxkit::anObject a1 = NULL,
Laxkit::anObject a2 = NULL,
int  info = 0 
)
inlinevirtual

Redefine this for interfaces that can draw data not owned, without loosing current data.

Return 1 for nothing drawn, 0 for something drawn.

Reimplemented in LaxInterfaces::GradientInterface, LaxInterfaces::ImageInterface, and LaxInterfaces::CaptionInterface.

Referenced by LaxInterfaces::ViewportWithStack::Refresh().

int LaxInterfaces::anInterface::DrawDataDp ( Laxkit::Displayer tdp,
SomeData data,
Laxkit::anObject a1 = NULL,
Laxkit::anObject a2 = NULL,
int  info = 1 
)
virtual

Use a different dp to draw data with.

Temporarily replaces dp with tdp while it passes data on to anInterface::DrawData(data,a1,a2,info). When the Laxkit interfaces use a1 or a2, the convention is that a1 is a LineStyle, and a2 is a FillStyle.

Returns this->DrawData(data,a1,a2,info). Derived classes need only redefine DrawData(anObject *,anObject *,anObject *,int).

Reimplemented in LaxInterfaces::PathInterface.

References Laxkit::dp.

int LaxInterfaces::anInterface::draws ( const char atype)
inlinevirtual

Returns !strcmp(whatdatatype(),atype).

Return 1 if the interface can draw data of the given type.

Derived classes that can draw more than one kind of object would redefine this appropriately. Just return nonzero if the interface can draw the type, or 0 if it cannot.

Referenced by LaxInterfaces::ViewportWithStack::Refresh().

anInterface * LaxInterfaces::anInterface::duplicate ( anInterface dup)
virtual

Return or modify to almost duplicate instance.

If dup==NULL, then return NULL. Otherwise modify the existing dup.

Copies app, name, style, id. The rest are initialized to NULL.

Normally, subclassed anInterface objects will return a new anInterface if dup=NULL, or apply changes to the given dup object, assuming it is of the correct class. This is especially important when setting up a ViewportWindow/ViewerWindow system. In that scenario, the dp and the data if present should not be copied, as they will be assigned new stuff by the window, thus those things are not transferred to the duplicate. Typically, the specific interface will create their own blank instance of themselves, and in doing so, the dp and and data will be set to NULL there.

Typical duplicate function in an interface looks like this:

{
dup=new TheInterface();
// add any other TheInterface specific initialization
dup->somefield = somefield;
}

Reimplemented in LaxInterfaces::PathInterface, LaxInterfaces::PatchInterface, LaxInterfaces::PointWarpInterface, LaxInterfaces::GradientInterface, LaxInterfaces::ImageInterface, LaxInterfaces::CaptionInterface, LaxInterfaces::FreehandInterface, LaxInterfaces::EllipseInterface, and LaxInterfaces::MeasureInterface.

References id, makestr(), name, and style.

double LaxInterfaces::anInterface::Getmag ( int  c = 0)
virtual

Do a little extra checking to find what the magnification is.

If curwindow is a ViewportWindow, then return same function from ViewportWindow. Otherwise return the usual function from dp.

If a viewport defines pages or groups, for instance, then this allows derived interfaces to use coords on those pages and groups, rather than the plain view transform in dp.

References Laxkit::dp, and Laxkit::Displayer::Getmag().

Referenced by LaxInterfaces::CaptionInterface::LBDown(), LaxInterfaces::ImageInterface::LBDown(), LaxInterfaces::PatchInterface::MouseMove(), LaxInterfaces::ImagePatchInterface::newPatchData(), LaxInterfaces::MeasureInterface::scan(), and LaxInterfaces::GradientInterface::scan().

ShortcutHandler * LaxInterfaces::anInterface::GetShortcuts ( )
virtual

Return a ShortcutHandler that contains stacks of bound shortcuts and possible actions.

NULL means there are none defined for this interface.

Interfaces that do use shortcuts, and want them stored in an easy manner should use the ShortcutManager system, accessed with GetDefaultShortcutManager(). They can then install a single list of shortcuts and actions bound to the type name of the interface, and any future window instances can borrow those.

double LaxInterfaces::anInterface::GetVMag ( int  x,
int  y 
)
virtual

Do a little extra checking to find what the magnification is.

If curwindow is a ViewportWindow, then return same function from ViewportWindow. Otherwise return the usual function from dp.

If a viewport defines pages or groups, for instance, then this allows derived interfaces to use coords on those pages and groups, rather than the plain view transform in dp.

References Laxkit::dp, and Laxkit::Displayer::GetVMag().

int LaxInterfaces::anInterface::PerformAction ( int  actionnumber)
virtual

This method exists to aid standardizing access to shortcut actions from potential scripting. Return 1 for not found or otherwise not done, or 0 for success. Default is return 1.

Reimplemented in LaxInterfaces::ObjectInterface.

flatpoint LaxInterfaces::anInterface::realtoscreen ( flatpoint  r)
virtual

Do a little extra checking to find what point r should correspond to.

If curwindow is a ViewportWindow, then return same function from ViewportWindow. Otherwise return the usual function from dp.

If a viewport defines pages or groups, for instance, then this allows derived interfaces to use coords on those pages and groups, rather than the plain view transform in dp.

Reimplemented in LaxInterfaces::PathInterface.

References Laxkit::dp, and Laxkit::Displayer::realtoscreen().

Referenced by LaxInterfaces::EllipseInterface::CharInput().

int LaxInterfaces::anInterface::RemoveChild ( )
virtual

If there is a child, do something to remove it.

If this interface is in a ViewportWindow, then the child will be popped off that port's stack.

References owner.

flatpoint LaxInterfaces::anInterface::screentoreal ( int  x,
int  y 
)
virtual

Do a little extra checking to find what point (x,y) should correspond to.

If curwindow is a ViewportWindow, then return same function from ViewportWindow. Otherwise return the usual function from dp.

If a viewport defines pages or groups, for instance, then this allows derived interfaces to use coords on those pages and groups, rather than the plain view transform in dp.

Reimplemented in LaxInterfaces::PathInterface.

References Laxkit::dp, and Laxkit::Displayer::screentoreal().

Referenced by LaxInterfaces::CaptionInterface::LBDown(), LaxInterfaces::ImageInterface::LBDown(), LaxInterfaces::GradientInterface::LBDown(), LaxInterfaces::RectInterface::LBDown(), LaxInterfaces::EllipseInterface::MouseMove(), LaxInterfaces::PointWarpInterface::MouseMove(), LaxInterfaces::PatchInterface::MouseMove(), LaxInterfaces::GradientInterface::newData(), LaxInterfaces::MeasureInterface::scan(), LaxInterfaces::EllipseInterface::scan(), LaxInterfaces::GradientInterface::scan(), LaxInterfaces::PointWarpInterface::scan(), and LaxInterfaces::PatchInterface::scan().


Member Data Documentation

Displayer * LaxInterfaces::anInterface::dp
protected

The Displayer used by the controlling window.

The transform in dp is interpreted as a kind of base transform to the view space. If the space has further transformations from current pages or current groups, then it is up to the ViewportWindow to keep track of that separately. To access that transform, you can call anInterface::realtoscreen() and anInterface::screentoreal(). Otherwise, the plain dp->realtoscreen and screentoreal work fine.

Referenced by LaxInterfaces::PathInterface::ChangeCurpathop(), LaxInterfaces::ColorPatchInterface::drawControlPoint(), LaxInterfaces::PatchInterface::drawControlPoint(), LaxInterfaces::PatchInterface::drawControlPoints(), LaxInterfaces::PathInterface::DrawDataDp(), LaxInterfaces::GradientInterface::drawLinear(), LaxInterfaces::PathInterface::drawNewPathIndicator(), LaxInterfaces::ColorPatchInterface::drawpatch(), LaxInterfaces::ImagePatchInterface::drawpatch(), LaxInterfaces::PatchInterface::drawpatch(), LaxInterfaces::GradientInterface::drawRadial(), LaxInterfaces::GradientInterface::drawRadialLine(), LaxInterfaces::EllipseInterface::EllipseInterface(), LaxInterfaces::RectInterface::GetOuterRect(), LaxInterfaces::EllipseInterface::getpoint(), LaxInterfaces::RectInterface::LBDown(), LaxInterfaces::RectInterface::MouseMove(), LaxInterfaces::PathInterface::MouseMove(), LaxInterfaces::EngraverFillInterface::newPatchData(), LaxInterfaces::ColorPatchInterface::patchpoint(), LaxInterfaces::ImagePatchInterface::patchpoint(), LaxInterfaces::ColorPatchInterface::patchpoint2(), LaxInterfaces::PathInterface::realtoscreen(), LaxInterfaces::CaptionInterface::Refresh(), LaxInterfaces::ImageInterface::Refresh(), LaxInterfaces::GradientInterface::Refresh(), LaxInterfaces::RectInterface::Refresh(), LaxInterfaces::PointWarpInterface::Refresh(), LaxInterfaces::PatchInterface::Refresh(), LaxInterfaces::PathInterface::Refresh(), LaxInterfaces::EllipseInterface::scan(), LaxInterfaces::RectInterface::scan(), LaxInterfaces::PointWarpInterface::scan(), LaxInterfaces::PatchInterface::scan(), LaxInterfaces::PathInterface::scan(), and LaxInterfaces::PathInterface::screentoreal().

unsigned long LaxInterfaces::anInterface::interface_type

What sort of interface this is. Default is INTERFACE_Tool.

Can be INTERFACE_Overlay, INTERFACE_Tool, or INTERFACE_Child.

anInterface * LaxInterfaces::anInterface::owner

The interface that owns this one.

Interfaces can have one parent and one child. This might be, for instance, a BezPathOperator (the child) that controls things that are really held by PathInterface (the owner). Or an EllipseInterface (owner) that uses the controls provided by the RectInterface (child).

When interfaces are pushed and popped of a ViewportWindow's stack, complete threads of interfaces are pushed on and off, not simply individual ones.

Referenced by AddChild(), LaxInterfaces::PathInterface::Modified(), LaxInterfaces::PathInterface::PathInterface(), LaxInterfaces::ViewportWindow::Pop(), and RemoveChild().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:58, Laxkit