File: widcontain.h

package info (click to toggle)
vdk2 2.4.0-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,524 kB
  • ctags: 4,975
  • sloc: cpp: 26,944; sh: 10,580; ansic: 9,220; makefile: 602; perl: 113
file content (109 lines) | stat: -rw-r--r-- 3,384 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * ===========================
 * VDK Visual Develeopment Kit
 * Version 0.4
 * Revision 0.4.1
 * October 1998
 * ===========================
 *
 * Copyright (C) 1998, Mario Motta
 * Developed by Mario Motta <mmotta@guest.net>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#ifndef WIDCONTAIN_H
#define WIDCONTAIN_H
#include <vdk/vdkobj.h>
/*! \class VDKObjectContainer
 *  \brief Containers base class
 *
 *  This class provides a container widget, common class for
 *  specialized containers such as VDKBox, VDKTable etc.
 *  User should not construct explicitely this kind of object.
 *  
 */
class VDKObjectContainer: public VDKObject
{
public:
  VDKObjectContainer(VDKForm* owner);
  virtual ~VDKObjectContainer() {}
  /*!
    Sets container border width
    \param w returns border width if is < 0
   */
  int BorderWidth(int w = -1)
    {
      if(w>=0)
	gtk_container_set_border_width (GTK_CONTAINER (widget),w); 
      return GTK_CONTAINER (widget)->border_width;
    }
  /*!
    Add an object.
  */
  virtual void Add(VDKObject* obj, int justify = l_justify,
		   int expand = TRUE, int fill = TRUE , int padding = 0);
  /*!
    Remove an object from container, object will be destroyed
    \param obj object to be removed
   */
  void RemoveObject(VDKObject* obj) { obj->Destroy(); }
  /*!
    This function will remove an object from a container
    without destroying it.
    \param obj object to be removed
    Tip: should be used to reparent an widget, or it will leak.
    Example:
    \code
    // remove from source container
    // referencing it otherwise will be destroyed by gtk+
    source->RemoveObjectFromContainer(widget);
    // add to target container
    target->Add(widget);
    // set target as parent to redirect signal flow
    widget->Parent(target);	
    // unref widget again (or it will leak)
    gtk_widget_unref(widget->Widget());
    \endcode
   */
  virtual void RemoveObjectFromContainer(VDKObject* obj);
  /*!
    Remove all objects from container destroying them
   */
  void RemoveObjects();
  /*!
    Find an object with Tag==tag, NULL if fails
    \param tag value to be searched
   */
  VDKObject* FindTag(int tag);
  /*!
    Apply user defined functions to each contained object
   */
  void ForEachDo(void (*action)(VDKObject*));
  /* !
    Select those contained objects that satisfy to user defined
    condition.
    \param list an ItemList filled with all object addresses
    that satisfy condition-
    \condition an user defined function invoked with each object
    as param, function must return either true (satisfy) or false
    value.
   */
  void Select(ItemList* list, bool (*condition)(VDKObject*));
  
};
#endif