#include <Fl_OpDesk.H>
Public Member Functions | |
void | BringToFront (Fl_OpBox *box) |
Bring the specified box 'to the front', above the other boxes. | |
void | Clear () |
Clear the entire desk; delete all boxes/connections. | |
int | Connect (const std::string &src_name, const std::string &dst_name, std::string &errmsg) |
Connect two buttons given their full names ("box(butt)") for src_name and dst_name . | |
int | Connect (Fl_OpBox *srcbox, const std::string &srcbut_lname, Fl_OpBox *dstbox, const std::string &dstbut_lname, std::string &errmsg) |
Connect two buttons given box pointers srcbox and dstbox , and button label names srcbut_lname and dstbut_lname . | |
int | Connect (Fl_OpButton *srcbut, Fl_OpButton *dstbut, std::string &errmsg) |
Connect two buttons: given two button pointers srcbut , dstbut . | |
virtual void | ConnectionError (Fl_OpButton *, Fl_OpButton *, std::string &errmsg) |
This virtual method can be defined by the app to define what to do when a connection error is detected. | |
virtual int | CopySelected () |
Copy the selected boxes to the paste buffer. | |
virtual int | CutSelected () |
Cut the selected boxes to the paste buffer. | |
void | DeleteBox (Fl_OpBox *box) |
Delete the box from the desk. | |
virtual int | DeleteSelected () |
Delete all the selected boxes. | |
int | DeselectAll () |
Deselect all boxes. | |
int | Disconnect (Fl_OpBox *box) |
Disconnect all connections to/from box . | |
int | Disconnect (Fl_OpButton *a, Fl_OpButton *b) |
Disconnect two buttons a and b . | |
void | DisconnectAll () |
Disconnect all connections. | |
void | draw () |
FLTK draw() method for the Fl_OpDesk. | |
Fl_OpBox * | FindBoxByLabel (std::string &lname, std::string &errmsg) |
Find a box given its label name, lname . | |
Fl_OpBox * | FindBoxForFullName (const std::string &fullname, std::string &errmsg) |
Return the box pointer for the given fullname . | |
Fl_OpButton * | FindButtonForFullName (const std::string &fullname, std::string &errmsg) |
Return the button pointer for the given fullname . | |
Fl_OpButton * | FindButtonUnderMouse () |
INTERNAL: Find a button that is under the mouse. | |
Fl_OpDesk (int X, int Y, int W, int H, const char *L=0) | |
Constructor for Fl_OpDesk Creates an instance of an empty desk with scrollbars. | |
Fl_OpConnect * | GetConnection (Fl_OpButton *srcbut, Fl_OpButton *dstbut) |
Return the Fl_OpConnect* connection between srcbut and dstbut . | |
Fl_OpConnect * | GetConnection (int index) |
Return a particular button connection specified by index . | |
int | GetConnectionsTotal () const |
Return total number of button connections. | |
Fl_OpConnect * | GetLastOpConnect () |
Return lass button connection. | |
const Fl_OpBox * | GetOpBox (int t) const |
Returns a const box specified by index . | |
Fl_OpBox * | GetOpBox (int index) |
Return a particular box specified by index . | |
int | GetOpBoxIndex (const Fl_OpBox *) const |
Return the index for the given Fl_OpBox box . | |
int | GetOpBoxTotal () const |
Return the total number of boxes. | |
Fl_Color | GetOpConnectColor () const |
Get default color of connection lines. | |
int | GetOpConnectSpacing () const |
Get spacing between connection lines (in pixels). | |
int | GetOpConnectWidth () const |
Get default width of connection lines (in pixels). | |
int | handle (int e) |
FLTK event handler for the Fl_OpDesk. | |
int | ParseFullButtonName (const std::string &fullname, std::string &boxname, std::string &butname, std::string &errmsg) |
Parse separate box and button names from a 'full button name', eg. | |
virtual int | PasteSelected () |
Virtual method for handling 'paste' operations. | |
int | SelectAll () |
Select all boxes. | |
void | SetOpConnectColor (Fl_Color val) |
Set default color of connection lines to val . | |
void | SetOpConnectSpacing (int val) |
Set spacing between connection lines to val (in pixels). | |
void | SetOpConnectWidth (int val) |
Set default width of connection lines to val (in pixels). | |
~Fl_OpDesk () | |
Fl_OpDesk's destructor. | |
Protected Member Functions | |
void | _AddBox (Fl_OpBox *b) |
INTERNAL: Add a box to the boxes array. (Used by Fl_OpBox ctor/dtors). | |
int | _ConnectOnly (Fl_OpButton *srcbut, Fl_OpButton *dstbut, std::string &errmsg) |
INTERNAL: Add connect of two buttons srcbut and dstbut to our internal array. | |
int | _DisconnectOnly (Fl_OpButton *a, Fl_OpButton *b) |
INTERNAL: Disconnect buttons a and b from our internal list. | |
void | _RemoveBox (Fl_OpBox *b) |
INTERNAL: Remove a box from internal boxes and clipboard arrays. (Used by Fl_OpBox ctor/dtors). | |
void | CopyConnections (std::vector< Fl_OpBox * > origboxes, std::vector< Fl_OpBox * > copyboxes) |
Copy connections in origboxes array to copyboxes array. | |
void | DraggingBoxes (int xdiff, int ydiff) |
INTERNAL: Handles a user interactively dragging selected boxes around. | |
void | DraggingConnection (Fl_OpButton *b) |
INTERNAL: Handles a user interactively dragging out a connection. | |
void | DrawConnect (Fl_OpConnect *con) const |
Draw the connect specified by con . | |
void | DrawLine (float x1, float y1, float x2, float y2) const |
INTERNAL: Draws a line between two floating point x/y points. | |
Friends | |
class | Fl_OpBox |
class | Fl_OpButton |
Fl_OpDesk // Desk -- top level widget that contains all boxes |___ Fl_OpBox // Boxes -- the operation boxes |___ Fl_OpButton // Buttons -- the buttons in the boxes
Fl_OpDesk::~Fl_OpDesk | ( | ) |
Fl_OpDesk's destructor.
Handles disconnecting everything.
int Fl_OpDesk::_ConnectOnly | ( | Fl_OpButton * | srcbut, | |
Fl_OpButton * | dstbut, | |||
std::string & | errmsg | |||
) | [protected] |
INTERNAL: Add connect of two buttons srcbut
and dstbut
to our internal array.
Doesn't recurse to telling other buttons, local only. FOR INTERNAL USE ONLY.
errmsg
has reason. int Fl_OpDesk::_DisconnectOnly | ( | Fl_OpButton * | a, | |
Fl_OpButton * | b | |||
) | [protected] |
INTERNAL: Disconnect buttons a
and b
from our internal list.
Doesn't tell other buttons. FOR INTERNAL USE ONLY.
void Fl_OpDesk::BringToFront | ( | Fl_OpBox * | box | ) |
Bring the specified box 'to the front', above the other boxes.
This changes the widget order in fltk so that the box is drawn last.
int Fl_OpDesk::Connect | ( | const std::string & | src_name, | |
const std::string & | dst_name, | |||
std::string & | errmsg | |||
) |
Connect two buttons given their full names ("box(butt)") for src_name
and dst_name
.
Handles adding the connection to the connects[] array, and telling the buttons about each other.
errmsg
has reason. int Fl_OpDesk::Connect | ( | Fl_OpBox * | srcbox, | |
const std::string & | srcbut_lname, | |||
Fl_OpBox * | dstbox, | |||
const std::string & | dstbut_lname, | |||
std::string & | errmsg | |||
) |
Connect two buttons given box pointers srcbox
and dstbox
, and button label names srcbut_lname
and dstbut_lname
.
Handles adding the connection to the connects[] array, and telling the buttons about each other.
errmsg
has reason. int Fl_OpDesk::Connect | ( | Fl_OpButton * | srcbut, | |
Fl_OpButton * | dstbut, | |||
std::string & | errmsg | |||
) |
Connect two buttons: given two button pointers srcbut
, dstbut
.
Handles adding the connection to the connects[] array, and telling the buttons about each other.
errmsg
has reason. virtual void Fl_OpDesk::ConnectionError | ( | Fl_OpButton * | , | |
Fl_OpButton * | , | |||
std::string & | errmsg | |||
) | [inline, virtual] |
This virtual method can be defined by the app to define what to do when a connection error is detected.
Default behavior is to print the errmsg
to stderr, but app may want to post a dialog instead. The srcbut
and dstbut
are the buttons whose connection attempt had failed.
Example:
class MyDesk : public Fl_OpDesk { // Handle displaying connection errors void ConnectionError(Fl_OpButton *src, Fl_OpButton *dst, std::string &errmsg) { std::string msg; msg = std::string(" INPUT: ") + src->GetFullName() + std::string("\n") + std::string( "OUTPUT: ") + dst->GetFullName() + std::string("\n") + errmsg; fl_alert(msg.c_str()); // post a dialog } [..]
void Fl_OpDesk::CopyConnections | ( | std::vector< Fl_OpBox * > | origboxes, | |
std::vector< Fl_OpBox * > | copyboxes | |||
) | [protected] |
Copy connections in origboxes
array to copyboxes
array.
The arrays must be equal in size; the 'copyboxes' array should contain mirror copies of the 'origboxes' array.
Look at the connections in the original boxes, and make similar connections (connect same buttons) in the copies.
Only make copies of connections that are between boxes we're copying. (Don't copy connections to boxes that aren't part of the copy)
int Fl_OpDesk::CopySelected | ( | ) | [virtual] |
Copy the selected boxes to the paste buffer.
Returns how many boxes were copied.
int Fl_OpDesk::CutSelected | ( | ) | [virtual] |
Cut the selected boxes to the paste buffer.
Returns how many boxes were cut.
TBD: Paste buffer not yet implemented.
void Fl_OpDesk::DeleteBox | ( | Fl_OpBox * | box | ) |
Delete the box
from the desk.
Cuts all connections, and FLTK's event loop handles scheduling the actual destruction of the widget.
int Fl_OpDesk::DeleteSelected | ( | ) | [virtual] |
Delete all the selected boxes.
Returns how many boxes were deleted.
int Fl_OpDesk::DeselectAll | ( | ) |
Deselect all boxes.
Marks desk for redraw if any changed.
int Fl_OpDesk::Disconnect | ( | Fl_OpBox * | box | ) |
Disconnect all connections to/from box
.
int Fl_OpDesk::Disconnect | ( | Fl_OpButton * | a, | |
Fl_OpButton * | b | |||
) |
Disconnect two buttons a
and b
.
The correct way to cleanly disconnect two buttons.
void Fl_OpDesk::DraggingConnection | ( | Fl_OpButton * | srcbut | ) | [protected] |
INTERNAL: Handles a user interactively dragging out a connection.
Assumes Fl::event_x() and Fl::event_y() have current mouse position. If b
is NULL, stop any existing dragging operations.
Fl_OpBox * Fl_OpDesk::FindBoxByLabel | ( | std::string & | lname, | |
std::string & | errmsg | |||
) |
Find a box given its label name, lname
.
Fl_OpBox * Fl_OpDesk::FindBoxForFullName | ( | const std::string & | fullname, | |
std::string & | errmsg | |||
) |
Return the box pointer for the given fullname
.
Fl_OpButton * Fl_OpDesk::FindButtonForFullName | ( | const std::string & | fullname, | |
std::string & | errmsg | |||
) |
Return the button pointer for the given fullname
.
Fl_OpConnect * Fl_OpDesk::GetConnection | ( | Fl_OpButton * | srcbut, | |
Fl_OpButton * | dstbut | |||
) |
Return the Fl_OpConnect* connection between srcbut
and dstbut
.
Fl_OpConnect * Fl_OpDesk::GetLastOpConnect | ( | ) |
Return lass button connection.
Returns 0 if empty list.
int Fl_OpDesk::GetOpBoxIndex | ( | const Fl_OpBox * | box | ) | const |
Return the index for the given Fl_OpBox box
.
Returns -1 if not found.
int Fl_OpDesk::GetOpConnectWidth | ( | ) | const |
Get default width of connection lines (in pixels).
This is the default width used for all new connections created with Fl_OpDesk::Connect().
int Fl_OpDesk::ParseFullButtonName | ( | const std::string & | fullname, | |
std::string & | boxname, | |||
std::string & | butname, | |||
std::string & | errmsg | |||
) |
Parse separate box and button names from a 'full button name', eg.
"boxname(butname)". Returns: 0: if OK, with boxname
and butname
set to the parsed names. -1: if fullname
could not be parsed.
int Fl_OpDesk::PasteSelected | ( | ) | [virtual] |
Virtual method for handling 'paste' operations.
Pastes the boxes/connections from the clipboard. Returns how many new boxes were pasted.
int Fl_OpDesk::SelectAll | ( | ) |
Select all boxes.
void Fl_OpDesk::SetOpConnectWidth | ( | int | val | ) |
Set default width of connection lines to val
(in pixels).
This is the default width used for all new connections created with Fl_OpDesk::Connect().