Fl_OpDesk
|
The main Fl_OpDesk widget, parent to the following widgets: Fl_OpBox -- the boxes that can be connected together Fl_OpButton -- the buttons (input and output) that can be added to an Fl_OpBox Fl_OpConnect -- the connections between input/output buttons of different boxes. More...
#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 (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 (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_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_OpButton *a, Fl_OpButton *b) |
Disconnect two buttons a and b . | |
int | Disconnect (Fl_OpBox *box) |
Disconnect all connections to/from box . | |
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 . | |
int | FindButtonByPtr (Fl_OpButton *b) const |
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 (int index) |
Return a particular button connection specified by index . | |
Fl_OpConnect * | GetConnection (Fl_OpButton *srcbut, Fl_OpButton *dstbut) |
Return the Fl_OpConnect* connection between srcbut and dstbut . | |
int | GetConnectionsTotal () const |
Return total number of button connections. | |
Fl_OpConnectStyle | GetConnectStyle (void) const |
Get the current connection line drawing style. | |
Fl_OpConnect * | GetLastOpConnect () |
Return the "last" button connection in the connection array. | |
Fl_OpBox * | GetOpBox (int index) |
Return a particular box specified by index . | |
const Fl_OpBox * | GetOpBox (int t) const |
Returns a const box specified by index . | |
int | GetOpBoxIndex (const Fl_OpBox *) const |
Return the index for the given Fl_OpBox box . | |
int | GetOpBoxSelectedBorderSize () const |
Get the OpBox selected border size. | |
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 | SetConnectStyle (Fl_OpConnectStyle val) |
Set the current connection line drawing style to val . | |
void | SetOpBoxSelectedBorderSize (int val) |
Set the OpBox selected border size. | |
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 |
The main Fl_OpDesk widget, parent to the following widgets: Fl_OpBox -- the boxes that can be connected together Fl_OpButton -- the buttons (input and output) that can be added to an Fl_OpBox Fl_OpConnect -- the connections between input/output buttons of different boxes.
Fl_OpDesk // Desk -- top level widget that contains all boxes |___ Fl_OpBox // Boxes -- the operation boxes |___ Fl_OpButton // Buttons -- the buttons in the boxes
This widget encapsulates the graphics elements of the desk + nodes. Normally you would derive your own classes from each of the above classes (Fl_OpDesk, Fl_OpBox, and Fl_OpButton) to implement management of your data.
It's the goal of this widget to not be tied to any particular data sets; and only implements the graphic representation of the widget. You subclass these widgets to implement your data sets.
For instance, if you want the widget to be a graphic representation of a program, then you'd add your own code to manage each box's code generation. (See the 'test-app' example for how to do this, where MyDesk/MyBox/MyButton are example subclasses showing how to implement the 'perl' programming language)
Or, if you want the widget to represent a data set, then you'd derive classes so that each box represents a node in your data set. Examples of this might be showing any kind of data in a 'tree', such as a file system, a binary tree, or even hardware representations, such as an irrigation system with each Fl_OpBox representing valves, flow control meters. or an electronics component simulator where each box represents resistors,diodes,capacitors,relays,lights. Or in a sound application, where each component represents different effects generators such as oscillators and tone generators, reverb, echo, equalizers..
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 | ( | 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. 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 | ( | 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. 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_OpButton * | a, |
Fl_OpButton * | b | ||
) |
Disconnect two buttons a
and b
.
The correct way to cleanly disconnect two buttons.
int Fl_OpDesk::Disconnect | ( | Fl_OpBox * | box | ) |
Disconnect all connections to/from box
.
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 the "last" button connection in the connection array.
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::GetOpBoxSelectedBorderSize | ( | ) | const |
Get the OpBox selected border size.
This is the thickness of the border drawn around boxes when they're selected.
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)".
Example:
IN: fullname = "add(A)" OUT: boxname = "add"; butname = "A"; }
boxname
and butname
set to the parsed names. 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::SetConnectStyle | ( | Fl_OpConnectStyle | val | ) |
Set the current connection line drawing style to val
.
Handles redraw()ing the desktop.
void Fl_OpDesk::SetOpBoxSelectedBorderSize | ( | int | val | ) |
Set the OpBox selected border size.
This is the thickness of the border drawn around boxes when they're selected.
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().