Fl_OpDesk
Fl_OpButton.H
Go to the documentation of this file.
00001 #ifndef _FL_OPBUTTON_H_
00002 #define _FL_OPBUTTON_H_
00003 
00004 //INSERT-LGPL-HEADER-HERE//
00005 
00010 
00011 #include <vector>
00012 #include <string>
00013 
00014 #include <FL/Fl.H>
00015 #include <FL/Fl_Button.H>
00016 #include <FL/fl_draw.H>
00017 
00018 #include "Fl_OpBox.H"
00019 
00020 class Fl_OpDesk;
00021 class Fl_OpBox;
00022 class Fl_OpConnect;
00023 
00027 enum Fl_OpButtonType {
00028     FL_OP_INPUT_BUTTON,         
00029     FL_OP_OUTPUT_BUTTON,        
00030 };
00031 
00051 
00088 class Fl_OpButton;
00089 
00090 // Operation Buttons
00091 //    Manages all the input buttons for Fl_OpBoxes
00092 //
00093 class Fl_OpButton : public Fl_Button {
00094     Fl_OpButtonType           button_type;      // type of this button (input|output)
00095     std::vector<Fl_OpButton*> connected_to;     // array of button(s) we're connected to
00096     int                       dragging;         // used for connection dragging
00097 
00098     // PRIVATE METHODS
00099     friend class Fl_OpDesk;
00100     void _RemoveConnect(Fl_OpButton *but);
00101     int  _ConnectToOnly(Fl_OpButton *but, std::string &errmsg);
00102     void _DisconnectOnly(Fl_OpButton *but);
00103 
00104 public:
00105     // CTORS
00106     Fl_OpButton(const char *L, Fl_OpButtonType io);
00107     ~Fl_OpButton();
00108     Fl_OpButton(const Fl_OpButton&);
00109 
00110     // FLTK
00111     void draw();
00112     int handle(int e);
00113 
00114     // MISC
00115     Fl_OpButtonType GetButtonType() const;
00116     int GetMinimumHeight() const;
00117     int GetMinimumWidth() const;
00118     std::string GetFullName() const;
00119 
00120     // PARENT ACCESS
00121     Fl_OpBox *GetOpBox();
00122     const Fl_OpBox* GetOpBox() const;
00123     Fl_OpDesk *GetOpDesk();
00124     const Fl_OpDesk* GetOpDesk() const;
00125 
00126     // CONNECTIONS
00127     int IsConnected() const;
00128     int IsConnected(const Fl_OpButton *but) const;
00129     int ConnectTo(Fl_OpButton *but, std::string &errmsg);
00130     void Disconnect(Fl_OpButton *but);
00131     void DisconnectAll();
00132 
00133     Fl_OpButton* GetConnectedButton(size_t index=0);
00134     const Fl_OpButton* GetConnectedButton(size_t index=0) const;
00135     size_t GetTotalConnectedButtons() const;
00136     void GetOutputBoxes(std::vector<Fl_OpBox*> &outboxes);
00137     Fl_OpConnect* GetConnection(size_t index);
00138 
00139     // VIRTUALS
00140 
00162     virtual int Connecting(Fl_OpButton*, std::string& errmsg) {
00163         return(0);
00164     }
00165 
00167     virtual void Disconnecting(Fl_OpButton*) {
00168         return;
00169     }
00170 
00171 };
00172 #endif /* _FL_OPBUTTON_H_ */