Fl_OpDesk
Fl_OpButton Class Reference

The Fl_OpButton widget, an FLTK widget derived from Fl_Button that manages just the buttons of an Fl_OpBox. More...

#include <Fl_OpButton.H>

List of all members.

Public Member Functions

virtual int Connecting (Fl_OpButton *, std::string &errmsg)
 This virtual method can be defined by the app to detect when a connection to button is being made.
int ConnectTo (Fl_OpButton *but, std::string &errmsg)
 Connect this button to another one.
void Disconnect (Fl_OpButton *but)
 Disconnect a connection to a specified button The correct way to cleanly disconnect two buttons.
void DisconnectAll ()
 Disconnect all buttons connected to this one.
virtual void Disconnecting (Fl_OpButton *)
 This virtual method can be defined by the app to detect when connections are being deleted.
void draw ()
 Fltk draw() handler.
 Fl_OpButton (const char *L, Fl_OpButtonType io)
 Constructor for the Fl_OpButton.
 Fl_OpButton (const Fl_OpButton &)
 Fl_OpButton copy constructor. Makes a "copy" of Fl_OpButton o.
Fl_OpButtonType GetButtonType () const
 Return the type of button; input or output.
Fl_OpButtonGetConnectedButton (size_t index=0)
 Return one of the buttons we're connected to, given index.
const Fl_OpButtonGetConnectedButton (size_t index=0) const
 Const version of GetConnectedButton().
Fl_OpConnectGetConnection (size_t index)
 Return the Fl_OpConnect connection for the given connected button index.
std::string GetFullName () const
 Return the 'full instance name' for this button.
int GetMinimumHeight () const
 Get the button's 'minimum height', given its label size, and adjusting for margins.
int GetMinimumWidth () const
 Get the button's 'minimum width', given its current font size and label contents.
const Fl_OpBoxGetOpBox () const
 Return a constant pointer this button's parent Fl_OpBox.
Fl_OpBoxGetOpBox ()
 Return the pointer this button's parent Fl_OpBox.
const Fl_OpDeskGetOpDesk () const
 Return a constnat pointer to the parent OpDesk.
Fl_OpDeskGetOpDesk ()
 Return a pointer to the parent OpDesk.
void GetOutputBoxes (std::vector< Fl_OpBox * > &outboxes)
 Returns array of outboxes connected to this button.
size_t GetTotalConnectedButtons () const
 Return the total number of other buttons we're connected to.
int handle (int e)
 Fltk event handler.
int IsConnected () const
 See if this button has any connections.
int IsConnected (const Fl_OpButton *but) const
 See if the specified button but is in our connection list.
 ~Fl_OpButton ()
 Destructor for the Fl_OpButton.

Friends

class Fl_OpDesk

Detailed Description

The Fl_OpButton widget, an FLTK widget derived from Fl_Button that manages just the buttons of an Fl_OpBox.

These become children of the Fl_OpBox in the usual FLTK fashion, where opbox->begin() and opbox->end() are used to bracket the creation of buttons, a simple example being:

         // Create box
         Fl_OpBox *box = new Fl_OpBox(X,Y,150,80);
         box->copy_label("add");
         box->begin();
             // Create two input buttons ("A", "B") and one output button ("OUT")
             Fl_OpButton *a   = new Fl_OpButton("A", FL_OP_INPUT_BUTTON);
             Fl_OpButton *b   = new Fl_OpButton("B", FL_OP_INPUT_BUTTON);
             Fl_OpButton *out = new Fl_OpButton("OUT", FL_OP_OUTPUT_BUTTON);
         box->end();

Constructor & Destructor Documentation

Fl_OpButton::Fl_OpButton ( const char *  name,
Fl_OpButtonType  io 
)

Constructor for the Fl_OpButton.

Creates a button whose label is name , and who's type is io. 'name' can be null, and set later with label() or copy_label(). Placement of the button is handled entirely by the parent Fl_OpBox.

Fl_OpButton::~Fl_OpButton ( )

Destructor for the Fl_OpButton.

Handles disconnecting all connections.


Member Function Documentation

virtual int Fl_OpButton::Connecting ( Fl_OpButton ,
std::string &  errmsg 
) [inline, virtual]

This virtual method can be defined by the app to detect when a connection to button is being made.

The app can 'OK' the connection by returning 0, or 'FAIL' the connection by returning -1, and setting errmsg to the reason why.

Example:

 class MyButton : public Fl_OpButton {
     // Handle checking connections
     int Connecting(Fl_OpButton *to, std::string &errmsg) {
         if ( to->OKToConnect(this) ) {
             return(0);      // OK
         } else {
             errmsg = "It's not OK to connect";
             return(-1);     // FAIL
         }
     }
 [..]
int Fl_OpButton::ConnectTo ( Fl_OpButton but,
std::string &  errmsg 
)

Connect this button to another one.

Handles a) telling other button about the connection, and b) avoids illegal "output-to-output" or "input-to-input" connections.

If we're an input button, any previous connection is dropped first. If we're an output button, drops any existing connections *to dstbut*, then recreates.

Returns:
0 if OK. Otherwise, -1 on error, errmsg has reason.
void Fl_OpButton::DisconnectAll ( )

Disconnect all buttons connected to this one.

Handles telling the other buttons and the desk about the disconnect.

Fl_OpButton * Fl_OpButton::GetConnectedButton ( size_t  index = 0)

Return one of the buttons we're connected to, given index.

index is NOT range checked; use either IsConnected() to see if there's at least one connection, or use GetTotalConnectedButtons() to determine the max value for index.

To loop through all the connected buttons, you can use:

    for ( int t=0; t<GetTotalConnectedButtons(); t++ ) {
        Fl_OpButton *otherbut = GetConnectedButton(t);
        // ..your code here..
    }
Fl_OpConnect * Fl_OpButton::GetConnection ( size_t  index)

Return the Fl_OpConnect connection for the given connected button index.

index is NOT range checked; use either IsConnected() to see if there's at least one connection, or use GetTotalConnectedButtons() to determine the max value for index.

std::string Fl_OpButton::GetFullName ( ) const

Return the 'full instance name' for this button.

This name uniquely identifies this button from all the other buttons on the Fl_OpDesk, the form being "BOX(BUT)", where "BOX" is the parent Fl_OpBox's unique name, and "BUT" is this button's unique label.

size_t Fl_OpButton::GetTotalConnectedButtons ( ) const

Return the total number of other buttons we're connected to.

To loop through all the buttons we're connected to, use:

    for ( int t=0; t<GetTotalConnectedButtons(); t++ ) {
        Fl_OpButton *otherbut = GetConnectedButton(t);
        // ..your code here..
    }
Returns:
The total number of buttons we're connected to. Input buttons can only be connected to one other button. Output buttons can be connected to several.
int Fl_OpButton::IsConnected ( const Fl_OpButton but) const

See if the specified button but is in our connection list.

Returns:
1 if button is in connection list
0 if not.

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