home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkNode.h.z / VkNode.h
Encoding:
C/C++ Source or Header  |  1996-09-20  |  3.8 KB  |  127 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. ///////   Copyright 1992, Silicon Graphics, Inc.  All Rights Reserved.   ///////
  3. //                                                                            //
  4. // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;     //
  5. // the contents of this file may not be disclosed to third parties, copied    //
  6. // or duplicated in any form, in whole or in part, without the prior written  //
  7. // permission of Silicon Graphics, Inc.                                       //
  8. //                                                                            //
  9. // RESTRICTED RIGHTS LEGEND:                                                  //
  10. // Use,duplication or disclosure by the Government is subject to restrictions //
  11. // as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data     //
  12. // and Computer Software clause at DFARS 252.227-7013, and/or in similar or   //
  13. // successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -    //
  14. // rights reserved under the Copyright Laws of the United States.             //
  15. //                                                                            //
  16. ////////////////////////////////////////////////////////////////////////////////
  17. #ifndef VKNODE_H
  18. #define VKNODE_H
  19.  
  20. #include <Vk/VkComponent.h>
  21.  
  22. class VkNode;
  23.  
  24. typedef int (*VkNodeSortFunction)(VkNode *, VkNode *);
  25.  
  26. class VkNode : public VkComponent {
  27.  
  28.     friend class VkGraph;
  29.  
  30.  public:
  31.  
  32.     // Constructors
  33.  
  34.     VkNode();
  35.     VkNode(const char *name, const char *label = NULL);
  36.     VkNode(const char *name, VkNode *parent, const char *label = NULL);
  37.  
  38.     static void setSortFunction(VkNodeSortFunction f) { VkNode::_sortFunction = f; }
  39.  
  40.     // Destructor
  41.  
  42.     virtual ~VkNode();
  43.  
  44.     // The only public info that should be needed is
  45.     // is the name, the widgets,  and access to the 
  46.     // children and parents of a node.
  47.     
  48.     char *name() const {return _name;}
  49.     virtual char *label();
  50.  
  51.     int nChildren() const { return _nChildren;}
  52.     int nParents() const { return _nParents;}
  53.  
  54.     VkNode *findChild(char * name);
  55.     VkNode *findParent(char * name);
  56.  
  57.     VkNode *child(int index) const { return _children[index];}
  58.     VkNode *parent(int index) const { return _parents[index];}
  59.  
  60.     void sortChildren();   
  61.  
  62.     // "private" functions for internal use. Do not use.
  63.  
  64.     void markAsConnected(int index) { _buildList[index] = TRUE;}
  65.     void markAsDisconnected(int index) { _buildList[index] = FALSE;}
  66.     Boolean connected(int index) ;
  67.     Atom attribute(int index) ;
  68.     String attributeName(int index) ;
  69.  
  70.   protected:
  71.  
  72.     int   _index;
  73.  
  74.  
  75.     char          *_label;
  76.     void clear();
  77.     class VkNode **_children;
  78.     int            _nChildren;
  79.     int            _maxChildren;
  80.  
  81.     Boolean        *_buildList;
  82.     Atom           *_attributeList;
  83.     VkNode         **_parents;
  84.     int            _nParents;
  85.     int            _maxParents;
  86.     Boolean        _hasChildren;
  87.     Boolean        _hasVisibleChildren;
  88.     Boolean        _hasVisibleParents;
  89.     Boolean        _hasParents;
  90.  
  91.     Boolean hasChildren() { return _hasChildren; };
  92.     Boolean hasVisibleChildren() { return _hasVisibleChildren; };
  93.     Boolean hasParents() { return _hasParents; };
  94.     Boolean hasVisibleParents() { return _hasVisibleParents; };
  95.     
  96.     void display(Widget parent);
  97.     void undisplay();
  98.  
  99.     void addParent(VkNode *, char *attribute = NULL);
  100.  
  101.     void addChild(VkNode *);
  102.  
  103.     void removeChild(char *name);
  104.     void removeChild(VkNode *child);
  105.  
  106.     void removeParent(char *name);
  107.     void removeParent(VkNode *child);
  108.  
  109.     virtual void updateVisualState();
  110.  
  111.     virtual void build(Widget);
  112.  
  113.     void widgetDestroyed();
  114.     
  115.     
  116.   private:
  117.  
  118.     static VkNodeSortFunction _sortFunction;
  119.     static int sortStub(const void *, const void *);
  120.  
  121.     
  122. };
  123.  
  124. #endif
  125.  
  126.  
  127.