gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
Container.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 CONTAINER_H_
18 #define CONTAINER_H_
19 #include <gtk/gtk.h>
20 #include "mffm/LinkList.H"
21 #include "Widget.H"
22 
28 class Container : public Widget {
29 protected:
30 
33  virtual void pack(GtkWidget *obj){
34  gtk_container_add(GTK_CONTAINER(widget),obj);
35  }
36 
37 public:
41  void setBorder(unsigned int size){
42  gtk_container_set_border_width(GTK_CONTAINER(widget), size);
43  }
44 
48  unsigned int getBorder(void){
49  return gtk_container_get_border_width(GTK_CONTAINER(widget));
50  }
51 
57  return operator<<(c.getWidget());
58  }
59 
65  return operator<<(c->getWidget());
66  }
67 
73  return operator<<(w.getWidget());
74  }
75 
81  return operator<<(w->getWidget());
82  }
83 
88  virtual Container& operator <<(GtkWidget * w) {
89  pack(w);
90  return *this;
91  }
92 
97  Container& operator <<(LinkList<GtkWidget *> &ll) {
98  ll.grab(1);// load using next from the first
99  for (int i=1;i<=ll.getCount();i++,ll.next())
100  operator<<(ll.current());
101  return *this;
102  }
103 
109  Container& operator >>(GtkWidget * w) {
110  gtk_container_remove(GTK_CONTAINER(widget), w);
111  return *this;
112  }
113 
120  gtk_container_remove(GTK_CONTAINER(widget), c->getWidget());
121  return *this;
122  }
123 
130  gtk_container_remove(GTK_CONTAINER(widget), c.getWidget());
131  return *this;
132  }
133 
139  for (int i=1; i<=ll.getCount(); i++)
140  (*this)>>ll.next();
141  return *this;
142  }
143 
144 // Container& operator=(const Container b){
145 // widget=b.getWidget();
146 // }
147 
151  void setChildrensSensitivity(bool sens) {
152  GList *widgetList=g_list_first(gtk_container_get_children(GTK_CONTAINER(widget)));
153  GtkWidget *widget;
154  for (int i=0; i<=(int)g_list_length(widgetList); i++) {
155  widget=static_cast<GtkWidget*>(g_list_nth_data(widgetList,i));
156  gtk_widget_set_sensitive(widget,sens);
157  }
158  }
159 
160 
165  GList *widgetList=g_list_first(gtk_container_get_children(GTK_CONTAINER(widget)));
166  GtkWidget *widget;
167  for (int i=0; i<=(int)g_list_length(widgetList); i++) {
168  widget=static_cast<GtkWidget*>(g_list_nth_data(widgetList,i));
169  if (gtk_widget_get_sensitive(widget))
170  return true;
171  }
172  return false;
173  }
174 
178  unsigned int size(){
179  return g_list_length(gtk_container_get_children(GTK_CONTAINER(widget)));
180  }
181 };
182 #endif // CONTAINER_H_
Container & operator>>(GtkWidget *w)
Definition: Container.H:109
void setChildrensSensitivity(bool sens)
Definition: Container.H:151
void setBorder(unsigned int size)
Definition: Container.H:41
unsigned int size()
Definition: Container.H:178
bool areAnyChildrensSensitive(void)
Definition: Container.H:164
Container & operator<<(Container &c)
Definition: Container.H:56
virtual void pack(GtkWidget *obj)
Definition: Container.H:33
GtkWidget * widget
The container based widget.
Definition: Widget.H:33
GtkWidget * getWidget(void)
Definition: Widget.H:91
Definition: Widget.H:31
unsigned int getBorder(void)
Definition: Container.H:48
gtkIOStream: /tmp/gtkiostream/include/Container.H Source File
GTK+ IOStream  Beta