gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
Box.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 BOX_H_
18 #define BOX_H_
19 
20 #include <iostream>
21 using namespace std;
22 #include <gtk/gtk.h>
23 
24 #include <mffm/LinkList.H>
25 #include "Container.H"
26 
27 #ifndef uint
28 typedef unsigned int uint;
29 #endif
30 
33 class BoxIS {
34  //bool defaultVal=false;
35  //#define defaultVal false ///< The default value
42 
45  void setDefaults(void){
46  expandDefault=fillDefault=false; //defaultVal; // setup the default behaviour
47  startDefault=true;
48 
49  expand = expandDefault;
50  fill = fillDefault;
51  start = startDefault;
52  }
53 public:
55  bool expand;
57  bool fill;
59  bool start;
60 
63  BoxIS(void) {
64  setDefaults(); // load up the default values
65  }
66 
71  BoxIS(bool expandIn, bool fillIn) {
72  setDefaults(); // load up the default values
73  expand=expandIn;
74  fill=fillIn;
75  }
76 
82  BoxIS(bool expandIn, bool fillIn, bool startIn) {
83  setDefaults(); // load up the default values
84  expand=expandIn;
85  fill=fillIn;
86  start=startIn;
87  }
88 
91  void reset(void) {
92  expand=expandDefault;
93  fill=fillDefault;
94  start=startDefault;
95  }
96 
100  void setDefaultStart(bool startIn){
101  startDefault=startIn;
102  start=startDefault;
103  }
104 
108  void setDefaultExpand(bool expandIn){
109  expandDefault=expandIn;
110  expand=expandDefault;
111  }
112 
116  void setDefaultFill(bool fillIn){
117  fillDefault=fillIn;
118  fill=fillDefault;
119  }
120 
124  expand=bis.expand;
125  fill=bis.fill;
126  start=bis.start;
127  return *this;
128  }
129 
132  BoxIS& operator=(const BoxIS bis) {
133  expand=bis.expand;
134  fill=bis.fill;
135  start=bis.start;
136  return *this;
137  }
138 
141  void dump(void){
142  cout<<"BoxIS::expand="<<expand<<", fill="<<fill<<", start="<<start<<endl;
143  }
144 };
145 
146 /*/// The default values of expand and fill
147 bool BoxIS::defaultVal=false;
148 */
149 
153 class Box : public BoxIS, public Container {
154 protected:
155 
162  virtual void pack(GtkWidget *obj) {
163  if (start)
164  gtk_box_pack_start (GTK_BOX (widget), obj, expand, fill, 0);
165  else
166  gtk_box_pack_end (GTK_BOX (widget), obj, expand, fill, 0);
167  //BoxIS::reset(); // reset the starting values
168  }
169 public:
170 
171  enum {EXPAND=1, FILL=2, START=4, RESET=8, END=16, NOFILL=32, NOEXPAND=64};
172 
175  Box(void) : BoxIS() {
176  }
177 
178 // /** \brief destructor destroys the widget to neatly cleanup.
179 // */
180 // virtual ~Box(void){
181 // }
182 
189  this->BoxIS::operator=((const BoxIS)bis);
190  return *this;
191  }
192 
193 // /* Align the box : this is a bad idea, as it requires
194 // \param a The alignment class
195 // \return Returns a Box reference for further processing.
196 // */
197 // Box& operator<<(Alignment &a) {
198 // Box *b=static_cast<Box*>(&a);
199 // return *this<<BoxIS(true,true,true)<<b->getWidget();
200 // }
201 
207  return Box::operator<<(b.getWidget());
208  }
209 
218  Box& operator <<(int val) {
219  if (val&RESET)
220  BoxIS::reset();
221  else {
222  if (val&FILL)
223  fill=true;
224  if (val&EXPAND)
225  expand=true;
226  if (val&START)
227  start=true;
228  if (val&NOFILL)
229  fill=false;
230  if (val&NOEXPAND)
231  expand=false;
232  if (val&END)
233  start=false;
234  }
235  return *this;
236  }
237 
243  return Box::operator<<(b->getWidget());
244  }
245 
251  return Box::operator<<(b.getWidget());
252  }
253 
259  return Box::operator<<(b->getWidget());
260  }
261 
266  Box& operator <<(GtkWidget * b) {
268  return *this;
269  }
270 
277  return *this;
278  }
279 
286  return *this;
287  }
288 
293  Box& operator <<(LinkList<GtkWidget *> &ll) {
295  return *this;
296  }
297 
303  Box& operator >>(GtkWidget * b) {
305  return *this;
306  }
307 
313  Box& operator >>(Container * b) {
315  return *this;
316  }
317 
323  Box& operator >>(Container &b) {
325  return *this;
326  }
327 
328 // /*! Unpack an unknown widget from the box.
329 // Note that removal of the widget can destroy it if the only reference is the box.
330 // \return Returns the widget removed from the box
331 // */
332 // GtkWidget* removeUnknownWidget() {
333 // GtkWidget* wdgt=gtk_container_get_focus_child((GtkContainer *)this->getWidget());
334 // *this>>wdgt;
335 // return wdgt;
336 // }
337 
340  Box& operator=(const Box b){
341  //widget=b.getWidget();
342  Container::operator=(b);
343  BoxIS::operator=(b);
344  return *this;
345  }
346 
347 };
348 
351 class VBox : public Box {
352 public:
355  VBox() {
356 #if GTK_MAJOR_VERSION==2
357  widget = gtk_vbox_new (FALSE, 0);
358 #else
359  widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
360 #endif
361  }
362 };
363 
366 class HBox : public Box {
367 public:
370  HBox() {
371 #if GTK_MAJOR_VERSION==2
372  widget = gtk_hbox_new (FALSE, 0);
373 #else
374  widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
375 #endif
376  }
377 };
378 
381 class HBBox : public HBox {
382 public:
385  HBBox() {
386 #if GTK_MAJOR_VERSION==2
387  widget = gtk_hbutton_box_new ();
388 #else
389  widget = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
390 #endif
391  }
392 };
393 
396 class VBBox : public VBox {
397 public:
400  VBBox() {
401 #if GTK_MAJOR_VERSION==2
402  widget = gtk_vbutton_box_new ();
403 #else
404  widget = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
405 #endif
406  }
407 };
408 #endif //BOX_H_
VBBox()
Definition: Box.H:400
void setDefaults(void)
Definition: Box.H:45
BoxIS(bool expandIn, bool fillIn)
Definition: Box.H:71
Container & operator>>(GtkWidget *w)
Definition: Container.H:109
Definition: Box.H:351
bool start
Set to pack the start.
Definition: Box.H:59
STL namespace.
void setDefaultExpand(bool expandIn)
Definition: Box.H:108
Definition: Box.H:381
HBox()
Definition: Box.H:370
Box(void)
constructor
Definition: Box.H:175
Definition: Box.H:366
unsigned int uint
Definition: Box.H:28
Definition: Box.H:396
Container & operator<<(Container &c)
Definition: Container.H:56
bool expand
Set to expand the box contents.
Definition: Box.H:55
HBBox()
Definition: Box.H:385
void setDefaultFill(bool fillIn)
Definition: Box.H:116
VBox()
Definition: Box.H:355
std::ostream & operator<<(std::ostream &stream, const BitStream &bitStream)
Definition: BitStream.C:204
void dump(void)
Definition: Box.H:141
Box & operator<<(BoxIS bis)
destructor destroys the widget to neatly cleanup.
Definition: Box.H:188
Definition: Box.H:153
GtkWidget * getWidget(void)
Definition: Widget.H:91
void reset(void)
Definition: Box.H:91
bool startDefault
The default state of the start value = ! BoxIS::defaultVal.
Definition: Box.H:41
Definition: Widget.H:31
bool fill
Set to fill the box.
Definition: Box.H:57
virtual void pack(GtkWidget *obj)
Definition: Box.H:162
void setDefaultStart(bool startIn)
Definition: Box.H:100
BoxIS(void)
Definition: Box.H:63
Box & operator=(const Box b)
Definition: Box.H:340
bool fillDefault
The default state of the fill value = BoxIS::defaultVal.
Definition: Box.H:39
BoxIS & operator=(const BoxIS bis)
Definition: Box.H:132
BoxIS(bool expandIn, bool fillIn, bool startIn)
Definition: Box.H:82
BoxIS & operator=(BoxIS &bis)
Definition: Box.H:123
bool expandDefault
The default state of the expand value = BoxIS::defaultVal.
Definition: Box.H:37
Definition: Box.H:33
gtkIOStream: /tmp/gtkiostream/include/Box.H Source File
GTK+ IOStream  Beta