gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
JackPortMonitorGui.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #ifndef JACKPORTMANAGERGUI_H_
18 #define JACKPORTMANAGERGUI_H_
19 
20 #include "JackPortMonitor.H"
21 #include "Box.H"
22 #include "Buttons.H"
23 #include "Frame.H"
24 #include "Surface.H"
25 #include "CairoArrow.H"
26 #include "EventBox.H"
27 
33 class ClientIOGui : public HBox {
37  map<GtkWidget*, vector<GtkWidget*> > inputWidgetConnections;
38 
41  void init();
42 
48  virtual void dragDataGet(GtkWidget *w, GtkSelectionData *selectionData, guint info);
49 
50 public:
54  ClientIOGui();
55 
59  ClientIOGui(string clientName_);
60 
61  virtual ~ClientIOGui() {}
62 
63  void renameClient(string clientName_);
64 
68  void setPorts(vector<string> &portNames);
69 
73  void setPorts(map<string, map<string, vector<string> > > &portNames);
74 
75  void reverseHBoxStacking();
76 
80  string getClientName(void){
81  return clientNameButton.getLabel();
82  }
83 
88  string getFullPortName(GtkWidget *wid);
89 
92  void clearAllWidgetConnections(void);
93 
98  void addWidgetConnections(GtkWidget *wid, GtkWidget*cWid);
99 
104  GtkWidget* getPortWidget(string portName);
105 
110  string getWidgetsPortName(GtkWidget *wid);
111 
115  map<GtkWidget*, vector<GtkWidget*> > &getInputWidgetConn(){return inputWidgetConnections;}
116 
120  void setupDrag(DragNDrop &dnd);
121 
125  void setupDrop(DragNDrop &dnd);
126 
130  GtkWidget *getClientWidget(){return clientNameButton.current();}
131 };
132 
145  virtual int chooseTheTargetToUse(GtkWidget *w, GtkWidget *sourceWidget, DragNDrop &dnd);
146 
147 public:
150 
152 
155  void reSyncPortGui(void);
156 
165  virtual bool dragDataReceived(GtkWidget *w, GtkWidget *sourceWidget, int info, const unsigned char *selectionStoredData, int length);
166 };
167 
170 class ConnectionSurface : public Surface {
171 
172 public:
176  void drawConnections(const map<GtkWidget*, vector<GtkWidget*> > &connections);
177 };
178 
184 class JackPortMonitorGui : public JackPortMonitor, public HBox {
185 
188 
190 
191  static bool exposeEventStatic(GtkWidget *widget, GdkEvent *event, gpointer data){
192  static_cast<JackPortMonitorGui*>(data)->reSyncConnections();
193  return true;
194  }
195 
198  void init();
199 
205  virtual void jackPortConnected(jack_port_id_t a, jack_port_id_t b, int connect);
206 
211  virtual void jackPortRegistered(jack_port_id_t port, int reg);
212 
218  virtual void jackPortRenamed(jack_port_id_t port, const char *oldName, const char *newName);
219 
226  static gboolean reDrawConnectionsStatic(GtkWidget *widget, GdkEventConfigure *event, gpointer data) {
227  //cout<<"JackPortMonitorGui::reDrawConnectionsStatic"<<endl;
228  static_cast<JackPortMonitorGui*>(data)->reDrawConnections();
229  return false;
230  }
231 
236  static void connect1To1Static(GtkWidget *widget, gpointer data) {
237  static_cast<JackPortMonitorGui*>(data)->connect1To1=Buttons::getActive(widget);
238  static_cast<JackPortMonitorGui*>(data)->reSyncPorts(); // resyncronise all of the clients with the original client.
239  static_cast<JackPortMonitorGui*>(data)->reSyncConnections();
240  }
241 
246  static void autoConnectNetClientsPortsStatic(GtkWidget *widget, gpointer data) {
247  if (static_cast<JackPortMonitorGui*>(data)->autoConnectNetClients=Buttons::getActive(widget))
248  static_cast<JackPortMonitorGui*>(data)->autoConnectNetClientsPorts();
249  }
250 public:
251  enum {CONNECT_PORTS, DISCONNECT_PORTS};
252 
255  virtual void reSyncPorts(void);
256 
259  virtual void reSyncConnections(void);
260 
263  void reDrawConnections();
264 
269 
273  JackPortMonitorGui(bool monitorPorts);
274 
279  JackPortMonitorGui(bool monitorPorts, bool autoConnectNetClientsIn);
280 
285  JackPortMonitorGui(string clientName_);
286 
291  JackPortMonitorGui(string clientName_, bool monitorPorts);
292 
298  JackPortMonitorGui(string clientName_, bool monitorPorts, bool autoConnectNetClientsIn);
299 
305  JackPortMonitorGui(string clientName_, string serverName);
306 
312  JackPortMonitorGui(string clientName_, string serverName, bool monitorPorts);
313 
320  JackPortMonitorGui(string clientName_, string serverName, bool monitorPorts, bool autoConnectNetClientsIn);
321 
322  virtual ~JackPortMonitorGui(){}
323 };
324 #endif // JACKPORTMANAGERGUI_H_
bool getActive(void)
Definition: Buttons.H:512
GtkWidget * getPortWidget(string portName)
ClientIOGui outputPortGui
The output port gui.
const gchar * getLabel()
Definition: Buttons.H:453
void setupDrop(DragNDrop &dnd)
void renameClient(string clientName_)
void setPorts(vector< string > &portNames)
Definition: Box.H:351
VBox outputPortBox
A box with all of the output half duplex GUIs stacked.
Buttons clientNameButton
Button representing all of the half duplex client ports.
virtual ~ClientIOGui()
Destructor.
void clearAllWidgetConnections(void)
static void autoConnectNetClientsPortsStatic(GtkWidget *widget, gpointer data)
static bool exposeEventStatic(GtkWidget *widget, GdkEvent *event, gpointer data)
void addWidgetConnections(GtkWidget *wid, GtkWidget *cWid)
string getClientName(void)
Definition: Box.H:366
void reverseHBoxStacking()
VBox inputPortBox
A box with all of the input half duplex GUIs stacked.
GtkWidget * getClientWidget()
ClientIOGui inputPortGui
The input port gui.
void setupDrag(DragNDrop &dnd)
Buttons portButtons
The clients half duplex ports. either input or output.
virtual bool dragDataReceived(GtkWidget *w, GtkWidget *sourceWidget, int info, const unsigned char *selectionStoredData, int length)
Definition: Widget.H:542
virtual ~JackBaseWithPortNamesGui()
Destructor.
virtual void dragDataGet(GtkWidget *w, GtkSelectionData *selectionData, guint info)
map< GtkWidget *, vector< GtkWidget * > > inputWidgetConnections
Each of the port buttons map to connected port buttons.
string getWidgetsPortName(GtkWidget *wid)
static void connect1To1Static(GtkWidget *widget, gpointer data)
GtkWidget * widget
The container based widget.
Definition: Widget.H:33
VBox portVBox
A holder for the port buttons.
string getFullPortName(GtkWidget *wid)
static gboolean reDrawConnectionsStatic(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
virtual ~JackPortMonitorGui()
Destructor.
ConnectionSurface connectionSurface
Draws client port connections.
Class to setup buttons whic are either text, image or toggle types. Buttons are defined in terms of t...
Definition: Buttons.H:184
map< GtkWidget *, vector< GtkWidget * > > & getInputWidgetConn()
virtual int chooseTheTargetToUse(GtkWidget *w, GtkWidget *sourceWidget, DragNDrop &dnd)
Definition: Widget.H:582
void connect(const char *event, GCallback callback, gpointer data)
Definition: Widget.H:224
gtkIOStream: /tmp/gtkiostream/include/JackPortMonitorGui.H Source File
GTK+ IOStream  Beta