home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / treecnr.zip / TreeCnr.cpp < prev    next >
C/C++ Source or Header  |  1996-03-13  |  42KB  |  1,069 lines

  1. /*******************************************************************************
  2. * FILE NAME: TreeCnr.cpp                                                       *
  3. *                                                                              *
  4. * DESCRIPTION:                                                                 *
  5. *   Class implementation of the class:                                         *
  6. *     TreeCnr- Sample tree view container application                          *
  7. * ---------------------------------------------------------------------------- *
  8. * Warning: This file was generated by the VisualAge C++ Visual Builder.        *
  9. * Modifications to this source file will be lost when the part is regenerated. *
  10. *******************************************************************************/
  11. #ifndef _IFRAME_
  12. #include <iframe.hpp>
  13. #endif
  14.  
  15. #ifndef _IMCELCV_
  16. #include <imcelcv.hpp>
  17. #endif
  18.  
  19. #ifndef _ICNRCOL_
  20. #include <icnrcol.hpp>
  21. #endif
  22.  
  23. #ifndef _IRECT_
  24. #include <irect.hpp>
  25. #endif
  26.  
  27. #ifndef _IPOINT_
  28. #include <ipoint.hpp>
  29. #endif
  30.  
  31. #ifndef _ITBAR_
  32. #include <itbar.hpp>
  33. #endif
  34.  
  35. #ifndef _ITBARBUT_
  36. #include <itbarbut.hpp>
  37. #endif
  38.  
  39. #ifndef _IENTRYFD_
  40. #include <ientryfd.hpp>
  41. #endif
  42.  
  43. #ifndef _IINFOA_
  44. #include <iinfoa.hpp>
  45. #endif
  46.  
  47. #ifndef _IVSEQ_H_
  48. #include <ivseq.h>
  49. #endif
  50.  
  51. #ifndef _PERSON_
  52. #include "Person.hpp"
  53. #endif
  54.  
  55. #ifndef _IMSGBOX_
  56. #include <imsgbox.hpp>
  57. #endif
  58.  
  59. #ifndef _INOTIFEV_
  60. #include <inotifev.hpp>
  61. #endif
  62.  
  63. #ifndef _IOBSERVR_
  64. #include <iobservr.hpp>
  65. #endif
  66.  
  67. #ifndef _ISTDNTFY_
  68. #include <istdntfy.hpp>
  69. #endif
  70.  
  71. #ifndef _TREECNR_
  72. #include "TreeCnr.hpp"
  73. #endif
  74.  
  75. #ifndef _IVBDEFS_
  76. #include <ivbdefs.h>
  77. #endif
  78.  
  79. #ifndef _ITRACE_
  80. #include <itrace.hpp>
  81. #endif
  82.  
  83.  
  84. //*****************************************************************************
  85. // Class definition for TreeCnrConn7
  86. //*****************************************************************************
  87. class TreeCnrConn7 : public IObserver, public IStandardNotifier {
  88. public:
  89.    virtual  ~TreeCnrConn7(){};
  90.  
  91.    //---------------------------------------------------------------------------
  92.    // public member functions
  93.    //---------------------------------------------------------------------------
  94.    void initialize(IToolBarButton * aSource, IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aTarget)
  95.       {source = aSource; target = aTarget; enableNotification(); };
  96.  
  97. protected:
  98.    //---------------------------------------------------------------------------
  99.    // protected member functions
  100.    //---------------------------------------------------------------------------
  101.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  102.       {
  103.       if (anEvent.notificationId() == IToolBarButton::buttonClickId)
  104.          {
  105.          IFUNCTRACE_DEVELOP();
  106.          ITRACE_DEVELOP(" firing connection : ToolBarButton1(buttonClickEvent) to TreeCnr(showTreeIconView))");
  107.          try {target->showTreeIconView();}
  108.          catch (IException& exc) {};
  109.          }
  110.       return(*this);
  111.       };
  112.  
  113. private:
  114.    //---------------------------------------------------------------------------
  115.    // private member data
  116.    //---------------------------------------------------------------------------
  117.    IToolBarButton * source;
  118.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * target;
  119.  
  120.  
  121. };   //TreeCnrConn7
  122.  
  123.  
  124. //*****************************************************************************
  125. // Class definition for TreeCnrConn9
  126. //*****************************************************************************
  127. class TreeCnrConn9 : public IObserver {
  128. public:
  129.    virtual  ~TreeCnrConn9(){};
  130.  
  131.    //---------------------------------------------------------------------------
  132.    // public member functions
  133.    //---------------------------------------------------------------------------
  134.    void initialize(IVSequence< Person * > * aSource, IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aTarget)
  135.       {source = aSource; target = aTarget; aligning = false; };
  136.    void setSource()
  137.       {      };
  138.    void setTarget()
  139.       {
  140.       if (aligning==false) {
  141.          IFUNCTRACE_DEVELOP();
  142.          ITRACE_DEVELOP(" firing connection : People(this) to TreeCnr(items))");
  143.          ITRACE_DEVELOP(" setting target from source ");
  144.          aligning = true;
  145.          try {target->setItems(source);}
  146.          catch (IException& exc) {};
  147.          aligning = false;
  148.          }
  149.       };
  150.  
  151. protected:
  152.    //---------------------------------------------------------------------------
  153.    // protected member functions
  154.    //---------------------------------------------------------------------------
  155.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  156.       {
  157.       if (anEvent.notificationId() == VBINITIALIZEID) setTarget();
  158.       if ((anEvent.notificationId() == IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj >::itemsId) && (target == &anEvent.notifier()))
  159.          setSource();  /* set source to target value */
  160.       return(*this);
  161.       };
  162.  
  163. private:
  164.    //---------------------------------------------------------------------------
  165.    // private member data
  166.    //---------------------------------------------------------------------------
  167.    IVSequence< Person * > * source;
  168.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * target;
  169.    Boolean aligning;
  170.  
  171.  
  172. };   //TreeCnrConn9
  173.  
  174.  
  175. //*****************************************************************************
  176. // Class definition for TreeCnrConn18
  177. //*****************************************************************************
  178. class TreeCnrConn18 : public IObserver, public IStandardNotifier {
  179. public:
  180.    virtual  ~TreeCnrConn18(){};
  181.  
  182.    //---------------------------------------------------------------------------
  183.    // public member functions
  184.    //---------------------------------------------------------------------------
  185.    void initialize(IVBVariablePartPointer<Person *> * aSource, IInfoArea * aTarget)
  186.       {source = aSource; target = aTarget; enableNotification(); };
  187.  
  188. protected:
  189.    //---------------------------------------------------------------------------
  190.    // protected member functions
  191.    //---------------------------------------------------------------------------
  192.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  193.       {
  194.       if (!source) return(*this);
  195.       if (anEvent.notificationId() == IVBVariablePartPointer<Person *>::targetId)
  196.          {
  197.          IFUNCTRACE_DEVELOP();
  198.          ITRACE_DEVELOP(" firing connection : SelPerson(this) to InfoArea1(customLogic))");
  199.          try {codeSnippet(&anEvent);}
  200.          catch (IException& exc) {};
  201.          }
  202.       return(*this);
  203.       };
  204.  
  205. private:
  206.    //---------------------------------------------------------------------------
  207.    // private member functions
  208.    //---------------------------------------------------------------------------
  209.    void codeSnippet(const INotificationEvent* event)
  210.       {
  211.       target->setText(
  212.                  IString("Name: ") +
  213.                  source->target()->name() +
  214.                  IString("   Boss: ") +
  215.                  source->target()->parentName() +
  216.                  IString("   Phone: ") +
  217.                  source->target()->phoneNumber()
  218.              );
  219.       };
  220.  
  221.    //---------------------------------------------------------------------------
  222.    // private member data
  223.    //---------------------------------------------------------------------------
  224.    IVBVariablePartPointer<Person *> * source;
  225.    IInfoArea * target;
  226.  
  227.  
  228. };   //TreeCnrConn18
  229.  
  230.  
  231. //*****************************************************************************
  232. // Class definition for TreeCnrConn29
  233. //*****************************************************************************
  234. class TreeCnrConn29 : public IObserver {
  235. public:
  236.    virtual  ~TreeCnrConn29(){};
  237.  
  238.    //---------------------------------------------------------------------------
  239.    // public member functions
  240.    //---------------------------------------------------------------------------
  241.    void initialize(IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aSource, IVBVariablePartPointer<Person *> * aTarget)
  242.       {source = aSource; target = aTarget; aligning = false; };
  243.    void setSource()
  244.       {      };
  245.    void setTarget()
  246.       {
  247.       if (!target) return;
  248.       if (aligning==false) {
  249.          IFUNCTRACE_DEVELOP();
  250.          ITRACE_DEVELOP(" firing connection : TreeCnr(selectedElement) to SelPerson(this))");
  251.          ITRACE_DEVELOP(" setting target from source ");
  252.          aligning = true;
  253.          try {target->setTarget(source->selectedElement());}
  254.          catch (IException& exc) {};
  255.          aligning = false;
  256.          }
  257.       };
  258.  
  259. protected:
  260.    //---------------------------------------------------------------------------
  261.    // protected member functions
  262.    //---------------------------------------------------------------------------
  263.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  264.       {
  265.       if (!target) return(*this);
  266.       if (anEvent.notificationId() == VBINITIALIZEID) setTarget();
  267.       if ((anEvent.notificationId() == IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj >::selectId) && (source == &anEvent.notifier()))
  268.          setTarget();  /* set target to source value */
  269.       else
  270.       if ((anEvent.notificationId() == IVBVariablePartPointer<Person *>::targetId) && (target == &anEvent.notifier()))
  271.          setSource();  /* set source to target value */
  272.       return(*this);
  273.       };
  274.  
  275. private:
  276.    //---------------------------------------------------------------------------
  277.    // private member data
  278.    //---------------------------------------------------------------------------
  279.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * source;
  280.    IVBVariablePartPointer<Person *> * target;
  281.    Boolean aligning;
  282.  
  283.  
  284. };   //TreeCnrConn29
  285.  
  286.  
  287. //*****************************************************************************
  288. // Class definition for TreeCnrConn14
  289. //*****************************************************************************
  290. class TreeCnrConn14 : public IObserver, public IStandardNotifier {
  291. public:
  292.    virtual  ~TreeCnrConn14(){};
  293.  
  294.    //---------------------------------------------------------------------------
  295.    // public member functions
  296.    //---------------------------------------------------------------------------
  297.    void initialize(IToolBarButton * aSource, IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aTarget)
  298.       {source = aSource; target = aTarget; enableNotification(); };
  299.  
  300. protected:
  301.    //---------------------------------------------------------------------------
  302.    // protected member functions
  303.    //---------------------------------------------------------------------------
  304.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  305.       {
  306.       if (anEvent.notificationId() == IToolBarButton::buttonClickId)
  307.          {
  308.          IFUNCTRACE_DEVELOP();
  309.          ITRACE_DEVELOP(" firing connection : ToolBarButton3(buttonClickEvent) to TreeCnr(showTreeTextView))");
  310.          try {target->showTreeTextView();}
  311.          catch (IException& exc) {};
  312.          }
  313.       return(*this);
  314.       };
  315.  
  316. private:
  317.    //---------------------------------------------------------------------------
  318.    // private member data
  319.    //---------------------------------------------------------------------------
  320.    IToolBarButton * source;
  321.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * target;
  322.  
  323.  
  324. };   //TreeCnrConn14
  325.  
  326.  
  327. //*****************************************************************************
  328. // Class definition for TreeCnrConn15
  329. //*****************************************************************************
  330. class TreeCnrConn15 : public IObserver, public IStandardNotifier {
  331. public:
  332.    virtual  ~TreeCnrConn15(){};
  333.  
  334.    //---------------------------------------------------------------------------
  335.    // public member functions
  336.    //---------------------------------------------------------------------------
  337.    void initialize(IToolBarButton * aSource, TreeCnr * aTarget)
  338.       {source = aSource; target = aTarget; enableNotification(); };
  339.  
  340.    //---------------------------------------------------------------------------
  341.    // public member data
  342.    //---------------------------------------------------------------------------
  343.    static const INotificationId exceptionId;
  344.  
  345. protected:
  346.    //---------------------------------------------------------------------------
  347.    // protected member functions
  348.    //---------------------------------------------------------------------------
  349.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  350.       {
  351.       if (anEvent.notificationId() == IToolBarButton::buttonClickId)
  352.          {
  353.          IFUNCTRACE_DEVELOP();
  354.          ITRACE_DEVELOP(" firing connection : ToolBarButton(buttonClickEvent) to (customLogic))");
  355.          try {codeSnippet(&anEvent);}
  356.          catch (IException& exc) {notifyObservers(INotificationEvent(exceptionId, *this, true, IEventData((void *)&exc)));};
  357.          }
  358.       return(*this);
  359.       };
  360.  
  361. private:
  362.    //---------------------------------------------------------------------------
  363.    // private member functions
  364.    //---------------------------------------------------------------------------
  365.    Person * codeSnippet(const INotificationEvent* event)
  366.       {
  367.       IString addName = target->iAddEf->text();
  368.       IVSequence<Person *> *col = target->iPeople;
  369.  
  370.       // ==========================================================
  371.       // Don't allow addition if the object no objects are selected
  372.       // ==========================================================
  373.       if (target->iTreeCnr->numberOfSelections() == 0)
  374.         ITHROW(IException("You must first select the parent of the object that you want to add."));
  375.  
  376.       // ==========================================================
  377.       // Don't allow addition of two people with the same name
  378.       // ==========================================================
  379.       ICursor * colCursor = col->newCursor( );
  380.       forCursor( *colCursor )
  381.         {
  382.         if (col->elementAt(*colCursor)->name() == addName)
  383.           ITHROW(IException("Name already exists.  You cannot two people with the same name"));
  384.         }
  385.  
  386.       // ==========================================================
  387.       // Create and return a new person
  388.       // ==========================================================
  389.       Person * newPerson = target->iPersonFact->create();
  390.       target->addObjectInTreeView(target->iTreeCnr, col, newPerson);
  391.  
  392.       return newPerson;
  393.  
  394.  
  395.       };
  396.  
  397.    //---------------------------------------------------------------------------
  398.    // private member data
  399.    //---------------------------------------------------------------------------
  400.    IToolBarButton * source;
  401.    TreeCnr * target;
  402.  
  403.  
  404. };   //TreeCnrConn15
  405.  
  406. const INotificationId TreeCnrConn15::exceptionId = "TreeCnrConn15::exceptionId";
  407.  
  408. //*****************************************************************************
  409. // Class definition for TreeCnrConn22
  410. //*****************************************************************************
  411. class TreeCnrConn22 : public IObserver, public IStandardNotifier {
  412. public:
  413.    virtual  ~TreeCnrConn22(){};
  414.  
  415.    //---------------------------------------------------------------------------
  416.    // public member functions
  417.    //---------------------------------------------------------------------------
  418.    void initialize(TreeCnrConn15 * aSource, IMessageBox * aTarget)
  419.       {source = aSource; target = aTarget; enableNotification(); };
  420.  
  421. protected:
  422.    //---------------------------------------------------------------------------
  423.    // protected member functions
  424.    //---------------------------------------------------------------------------
  425.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  426.       {
  427.       if (anEvent.notificationId() == TreeCnrConn15::exceptionId)
  428.          {
  429.          IFUNCTRACE_DEVELOP();
  430.          ITRACE_DEVELOP(" firing connection : Conn15(exceptionOccurred) to MessageBox(showException))");
  431.          try {target->show(*(IException *) (anEvent.eventData().asUnsignedLong()));}
  432.          catch (IException& exc) {};
  433.          }
  434.       return(*this);
  435.       };
  436.  
  437. private:
  438.    //---------------------------------------------------------------------------
  439.    // private member data
  440.    //---------------------------------------------------------------------------
  441.    TreeCnrConn15 * source;
  442.    IMessageBox * target;
  443.  
  444.  
  445. };   //TreeCnrConn22
  446.  
  447.  
  448. //*****************************************************************************
  449. // Class definition for TreeCnrConn12
  450. //*****************************************************************************
  451. class TreeCnrConn12 : public IObserver, public IStandardNotifier {
  452. public:
  453.    virtual  ~TreeCnrConn12(){};
  454.  
  455.    //---------------------------------------------------------------------------
  456.    // public member functions
  457.    //---------------------------------------------------------------------------
  458.    void initialize(IToolBarButton * aSource, TreeCnr * aTarget)
  459.       {source = aSource; target = aTarget; enableNotification(); };
  460.    TreeCnrConn12 & setACnr(IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aSelf) {iACnr = aSelf; return *this;};
  461.    TreeCnrConn12 & setACol(IVSequence< Person * > * aSelf) {iACol = aSelf; return *this;};
  462.    TreeCnrConn12 & setAPerson(IVBVariablePartPointer<Person *> * aSelf) {iAPerson = aSelf; return *this;};
  463.  
  464. protected:
  465.    //---------------------------------------------------------------------------
  466.    // protected member functions
  467.    //---------------------------------------------------------------------------
  468.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  469.       {
  470.       if (anEvent.notificationId() == IToolBarButton::buttonClickId)
  471.          {
  472.          IFUNCTRACE_DEVELOP();
  473.          ITRACE_DEVELOP(" firing connection : ToolBarButton4(buttonClickEvent) to Member function->deleteObjectInTreeView())");
  474.          try {target->deleteObjectInTreeView(iACnr, iACol, iAPerson->target());}
  475.          catch (IException& exc) {};
  476.          }
  477.       return(*this);
  478.       };
  479.  
  480. private:
  481.    //---------------------------------------------------------------------------
  482.    // private member data
  483.    //---------------------------------------------------------------------------
  484.    IToolBarButton * source;
  485.    TreeCnr * target;
  486.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * iACnr;
  487.    IVSequence< Person * > * iACol;
  488.    IVBVariablePartPointer<Person *> * iAPerson;
  489.  
  490.  
  491. };   //TreeCnrConn12
  492.  
  493.  
  494. //*****************************************************************************
  495. // Class definition for TreeCnrConn17
  496. //*****************************************************************************
  497. class TreeCnrConn17 : public IObserver, public IStandardNotifier {
  498. public:
  499.    virtual  ~TreeCnrConn17(){};
  500.  
  501.    //---------------------------------------------------------------------------
  502.    // public member functions
  503.    //---------------------------------------------------------------------------
  504.    void initialize(TreeCnr * aSource, TreeCnr * aTarget)
  505.       {source = aSource; target = aTarget; enableNotification(); };
  506.  
  507. protected:
  508.    //---------------------------------------------------------------------------
  509.    // protected member functions
  510.    //---------------------------------------------------------------------------
  511.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  512.       {
  513.       if (anEvent.notificationId() == TreeCnr::readyId)
  514.          {
  515.          IFUNCTRACE_DEVELOP();
  516.          ITRACE_DEVELOP(" firing connection : (ready) to (customLogic))");
  517.          try {codeSnippet(&anEvent);}
  518.          catch (IException& exc) {};
  519.          }
  520.       return(*this);
  521.       };
  522.  
  523. private:
  524.    //---------------------------------------------------------------------------
  525.    // private member functions
  526.    //---------------------------------------------------------------------------
  527.    void codeSnippet(const INotificationEvent* event)
  528.       {
  529.       target->addObjectInTreeView(
  530.         target->iTreeCnr, 
  531.         target->iPeople,
  532.         new Person("Greg Clark", "Root", "444-1902"));
  533.       target->addObjectInTreeView(
  534.         target->iTreeCnr,
  535.         target->iPeople,
  536.         new Person("Peter Spung", "Greg Clark", "444-1647"));
  537.       target->addObjectInTreeView(
  538.         target->iTreeCnr,
  539.         target->iPeople,
  540.         new Person("Jim Doherty", "Peter Spung", "444-1626"));
  541.       target->addObjectInTreeView(
  542.         target->iTreeCnr,
  543.         target->iPeople,
  544.         new Person("Dave Bernath", "Jim Doherty", "444-1567"));
  545.       target->addObjectInTreeView(
  546.         target->iTreeCnr,
  547.         target->iPeople,
  548.         new Person("Kathy Endres", "Jim Doherty", "444-1623"));
  549.       target->addObjectInTreeView(
  550.         target->iTreeCnr,
  551.         target->iPeople,
  552.         new Person("Paul Holmes", "Jim Doherty", "444-1650"));
  553.       target->addObjectInTreeView(
  554.         target->iTreeCnr,
  555.         target->iPeople,
  556.         new Person("Don Ingerslew", "Peter Spung", "444-1651"));
  557.       target->addObjectInTreeView(
  558.         target->iTreeCnr,
  559.         target->iPeople,
  560.         new Person("Bob Love", "Don Ingerslew", "444-1617"));
  561.       target->addObjectInTreeView(
  562.         target->iTreeCnr,
  563.         target->iPeople,
  564.         new Person("Judy Oakley", "Don Ingerslew", "444-1602"));
  565.       target->addObjectInTreeView(
  566.         target->iTreeCnr,
  567.         target->iPeople,
  568.         new Person("Martin Stich", "Don Ingerslew", "444-1630"));
  569.       target->addObjectInTreeView(
  570.         target->iTreeCnr,
  571.         target->iPeople,
  572.         new Person("Mary Streble", "Don Ingerslew", "444-1614"));
  573.       target->addObjectInTreeView(
  574.         target->iTreeCnr,
  575.         target->iPeople,
  576.         new Person("Barry Lee", "Peter Spung", "444-1187"));
  577.       target->addObjectInTreeView(
  578.         target->iTreeCnr,
  579.         target->iPeople,
  580.         new Person("Mark Anderson", "Barry Lee", "444-1656"));
  581.       target->addObjectInTreeView(
  582.         target->iTreeCnr,
  583.         target->iPeople,
  584.         new Person("George DeCandio", "Barry Lee", "444-1569"));
  585.       target->addObjectInTreeView(
  586.         target->iTreeCnr,
  587.         target->iPeople,
  588.         new Person("Venkat Iyer", "Barry Lee", "444-5532"));
  589.       target->addObjectInTreeView(
  590.         target->iTreeCnr,
  591.         target->iPeople,
  592.         new Person("Dave Lavin", "Barry Lee", "444-1619"));
  593.       };
  594.  
  595.    //---------------------------------------------------------------------------
  596.    // private member data
  597.    //---------------------------------------------------------------------------
  598.    TreeCnr * source;
  599.    TreeCnr * target;
  600.  
  601.  
  602. };   //TreeCnrConn17
  603.  
  604.  
  605. //*****************************************************************************
  606. // Class definition for TreeCnrConn44
  607. //*****************************************************************************
  608. class TreeCnrConn44 : public IObserver, public IStandardNotifier {
  609. public:
  610.    virtual  ~TreeCnrConn44(){};
  611.  
  612.    //---------------------------------------------------------------------------
  613.    // public member functions
  614.    //---------------------------------------------------------------------------
  615.    void initialize(IToolBarButton * aSource, IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aTarget)
  616.       {source = aSource; target = aTarget; enableNotification(); };
  617.  
  618. protected:
  619.    //---------------------------------------------------------------------------
  620.    // protected member functions
  621.    //---------------------------------------------------------------------------
  622.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  623.       {
  624.       if (anEvent.notificationId() == IToolBarButton::buttonClickId)
  625.          {
  626.          IFUNCTRACE_DEVELOP();
  627.          ITRACE_DEVELOP(" firing connection : ToolBarButton2(buttonClickEvent) to TreeCnr(expandTree))");
  628.          try {target->expandTree();}
  629.          catch (IException& exc) {};
  630.          }
  631.       return(*this);
  632.       };
  633.  
  634. private:
  635.    //---------------------------------------------------------------------------
  636.    // private member data
  637.    //---------------------------------------------------------------------------
  638.    IToolBarButton * source;
  639.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * target;
  640.  
  641.  
  642. };   //TreeCnrConn44
  643.  
  644.  
  645. //*****************************************************************************
  646. // Class definition for TreeCnrConn25
  647. //*****************************************************************************
  648. class TreeCnrConn25 : public IObserver, public IStandardNotifier {
  649. public:
  650.    virtual  ~TreeCnrConn25(){};
  651.  
  652.    //---------------------------------------------------------------------------
  653.    // public member functions
  654.    //---------------------------------------------------------------------------
  655.    void initialize(IToolBarButton * aSource, IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * aTarget)
  656.       {source = aSource; target = aTarget; enableNotification(); };
  657.  
  658. protected:
  659.    //---------------------------------------------------------------------------
  660.    // protected member functions
  661.    //---------------------------------------------------------------------------
  662.    virtual IObserver & dispatchNotificationEvent(const INotificationEvent & anEvent)
  663.       {
  664.       if (anEvent.notificationId() == IToolBarButton::buttonClickId)
  665.          {
  666.          IFUNCTRACE_DEVELOP();
  667.          ITRACE_DEVELOP(" firing connection : ToolBarButton5(buttonClickEvent) to TreeCnr(collapseTree))");
  668.          try {target->collapseTree();}
  669.          catch (IException& exc) {};
  670.          }
  671.       return(*this);
  672.       };
  673.  
  674. private:
  675.    //---------------------------------------------------------------------------
  676.    // private member data
  677.    //---------------------------------------------------------------------------
  678.    IToolBarButton * source;
  679.    IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj > * target;
  680.  
  681.  
  682. };   //TreeCnrConn25
  683.  
  684.  
  685. //------------------------------------------------------------------------------
  686. // TreeCnrTreeCnrCnrObj :: TreeCnrTreeCnrCnrObj
  687. //------------------------------------------------------------------------------
  688. #pragma export (TreeCnrTreeCnrCnrObj::TreeCnrTreeCnrCnrObj(Person&))
  689. TreeCnrTreeCnrCnrObj::TreeCnrTreeCnrCnrObj(Person& anObject)
  690.  :IVBContainerObject(anObject.name(), ISystemPointerHandle(ISystemPointerHandle::warning)),
  691.       phoneNumber(anObject.phoneNumber()), parentName(anObject.parentName()), pRealObject(anObject)
  692. {
  693.    enableDataUpdate();
  694.    handleNotificationsFor(pRealObject);
  695. }
  696.  
  697.  
  698. //------------------------------------------------------------------------------
  699. // TreeCnrTreeCnrCnrObj :: TreeCnrTreeCnrCnrObj
  700. //------------------------------------------------------------------------------
  701. #pragma export (TreeCnrTreeCnrCnrObj::TreeCnrTreeCnrCnrObj(TreeCnrTreeCnrCnrObj&))
  702. TreeCnrTreeCnrCnrObj::TreeCnrTreeCnrCnrObj(TreeCnrTreeCnrCnrObj& anObject)
  703.  :IVBContainerObject(anObject.iconText(), anObject.icon()),
  704.       phoneNumber(anObject.phoneNumber), parentName(anObject.parentName), pRealObject(anObject.pRealObject)
  705. {  }
  706.  
  707.  
  708. //------------------------------------------------------------------------------
  709. // TreeCnrTreeCnrCnrObj :: ~TreeCnrTreeCnrCnrObj
  710. //------------------------------------------------------------------------------
  711. #pragma export (TreeCnrTreeCnrCnrObj::~TreeCnrTreeCnrCnrObj())
  712. TreeCnrTreeCnrCnrObj::~TreeCnrTreeCnrCnrObj()
  713. {
  714.    this->stopHandlingNotificationsFor(pRealObject);
  715. }
  716.  
  717.  
  718. //------------------------------------------------------------------------------
  719. // TreeCnrTreeCnrCnrObj :: refreshFromObject
  720. //------------------------------------------------------------------------------
  721. #pragma export (TreeCnrTreeCnrCnrObj::refreshFromObject())
  722. IVBContainerObject & TreeCnrTreeCnrCnrObj::refreshFromObject()
  723. {
  724.    setIconText(pRealObject.name());
  725.    setIcon(ISystemPointerHandle(ISystemPointerHandle::warning));
  726.    phoneNumber = pRealObject.phoneNumber();
  727.    parentName = pRealObject.parentName();
  728.    return *this;
  729. }
  730.  
  731.  
  732. //------------------------------------------------------------------------------
  733. // TreeCnrTreeCnrCnrObj :: updateToObject
  734. //------------------------------------------------------------------------------
  735. IVBContainerObject & TreeCnrTreeCnrCnrObj::updateToObject()
  736. {
  737.    pRealObject.setName(iconText());
  738.    pRealObject.setPhoneNumber(phoneNumber);
  739.    pRealObject.setParentName(parentName);
  740.    return *this;
  741. }
  742.  
  743.  
  744. //------------------------------------------------------------------------------
  745. // TreeCnrTreeCnrCnrObj :: operator=
  746. //------------------------------------------------------------------------------
  747. TreeCnrTreeCnrCnrObj& TreeCnrTreeCnrCnrObj::operator=(const TreeCnrTreeCnrCnrObj& anObject)
  748. {
  749.    if (this == &anObject) {
  750.       return *this;
  751.       }
  752.    IVBContainerObject::operator=(anObject);
  753.    phoneNumber = anObject.phoneNumber;
  754.    parentName = anObject.parentName;
  755.    return *this;
  756. }
  757.  
  758.  
  759.  
  760. const INotificationId TreeCnrPersonFactFactory::newObjectCreatedId = "TreeCnrPersonFactFactory::newObjectCreatedId";
  761.  
  762. //------------------------------------------------------------------------------
  763. // TreeCnrPersonFactFactory :: TreeCnrPersonFactFactory
  764. //------------------------------------------------------------------------------
  765. #pragma export (TreeCnrPersonFactFactory::TreeCnrPersonFactFactory())
  766. TreeCnrPersonFactFactory::TreeCnrPersonFactFactory()
  767. {
  768.    enableNotification();
  769. }
  770.  
  771. //------------------------------------------------------------------------------
  772. // TreeCnrPersonFactFactory :: ~TreeCnrPersonFactFactory
  773. //------------------------------------------------------------------------------
  774. #pragma export (TreeCnrPersonFactFactory::~TreeCnrPersonFactFactory())
  775. TreeCnrPersonFactFactory::~TreeCnrPersonFactFactory()
  776. {
  777.    disableNotification();
  778. }
  779.  
  780. //------------------------------------------------------------------------------
  781. // TreeCnrPersonFactFactory :: create
  782. //------------------------------------------------------------------------------
  783. #pragma export (TreeCnrPersonFactFactory::create())
  784. Person * TreeCnrPersonFactFactory::create()
  785. {
  786.    Person *iPersonFact = new Person(iAddEf->text());
  787.    iPersonFact->setParentName(iSelPerson->target()->name());
  788.    iPersonFact->enableNotification();
  789.    notifyObservers(INotificationEvent(newObjectCreatedId, *this, true, IEventData((void *)iPersonFact)));
  790.    return(iPersonFact);
  791. }
  792.  
  793.  
  794.  
  795. #pragma export (TreeCnr::readyId)
  796. const INotificationId TreeCnr::readyId = "TreeCnr::readyId";
  797.  
  798. //------------------------------------------------------------------------------
  799. // TreeCnr :: defaultFramingSpec
  800. //------------------------------------------------------------------------------
  801. #pragma export (TreeCnr::defaultFramingSpec())
  802. const IRectangle TreeCnr::defaultFramingSpec()
  803. {
  804.    return(IRectangle(IPoint(117, IWindow::desktopWindow()->size().height() - 23 - 274),ISize(617, 274)));
  805. }
  806.  
  807.  
  808. //------------------------------------------------------------------------------
  809. // TreeCnr :: defaultTitle
  810. //------------------------------------------------------------------------------
  811. #pragma export (TreeCnr::defaultTitle())
  812. IString TreeCnr::defaultTitle()
  813. {
  814.    return("Company Org Chart");
  815. }
  816.  
  817.  
  818. //------------------------------------------------------------------------------
  819. // TreeCnr :: TreeCnr
  820. //------------------------------------------------------------------------------
  821. #pragma export (TreeCnr::TreeCnr(unsigned long, IWindow*, IWindow*, const IRectangle&, const IFrameWindow::Style&, const char*))
  822. TreeCnr::TreeCnr(
  823.       unsigned long id, 
  824.       IWindow* parent, 
  825.       IWindow* owner, 
  826.       const IRectangle& rect, 
  827.       const IFrameWindow::Style& style, 
  828.       const char* title)
  829.    : IFrameWindow(id, parent, owner, rect, style, title)
  830. {
  831.    iMultiCellCanvas1 = new IMultiCellCanvas(
  832.       IC_FRAME_CLIENT_ID, 
  833.       this, 
  834.       this, 
  835.       IRectangle());
  836.    iTreeCnr = new IVBContainerControl< Person*, IVSequence<Person*>, TreeCnrTreeCnrCnrObj >(
  837.       id+WNDOFFSET_TreeCnr_TreeCnr, 
  838.       iMultiCellCanvas1, 
  839.       iMultiCellCanvas1, 
  840.       IRectangle ( ));
  841.    iContainerColumn1 = new IContainerColumn(TreeCnrTreeCnrCnrObj::iconTextOffset(), IContainerColumn::defaultHeadingStyle ( ), (IContainerColumn::defaultDataStyle ( )) & ~IContainerColumn::icon | IContainerColumn::string);
  842.    iContainerColumn2 = new IContainerColumn(offsetof(TreeCnrTreeCnrCnrObj, parentName), IContainerColumn::defaultHeadingStyle ( ), (IContainerColumn::defaultDataStyle ( )) & ~IContainerColumn::icon | IContainerColumn::string);
  843.    iContainerColumn3 = new IContainerColumn(offsetof(TreeCnrTreeCnrCnrObj, phoneNumber), IContainerColumn::defaultHeadingStyle ( ), (IContainerColumn::defaultDataStyle ( )) & ~IContainerColumn::icon | IContainerColumn::string);
  844.    iToolBar1 = new IToolBar(
  845.       id+WNDOFFSET_TreeCnr_ToolBar1, 
  846.       this, 
  847.       IToolBar::aboveClient, 
  848.       false, 
  849.       IToolBar::defaultStyle() & ~IToolBar::buttonBitmapVisible & ~IToolBar::buttonBitmapAndTextVisible | IToolBar::buttonTextVisible);
  850.    iToolBarButton = new IToolBarButton(
  851.       id+WNDOFFSET_TreeCnr_ToolBarButton, 
  852.       iToolBar1, 
  853.       iToolBar1, 
  854.       IRectangle(), 
  855.       IToolBarButton::defaultStyle() | IControl::group);
  856.    iAddEf = new IEntryField(
  857.       id+WNDOFFSET_TreeCnr_AddEf, 
  858.       iToolBar1, 
  859.       iToolBar1, 
  860.       IRectangle(), 
  861.       IEntryField::defaultStyle() & ~IControl::group);
  862.    iToolBarButton4 = new IToolBarButton(
  863.       id+WNDOFFSET_TreeCnr_ToolBarButton4, 
  864.       iToolBar1, 
  865.       iToolBar1, 
  866.       IRectangle(), 
  867.       IToolBarButton::defaultStyle() | IControl::group);
  868.    iToolBarButton3 = new IToolBarButton(
  869.       id+WNDOFFSET_TreeCnr_ToolBarButton3, 
  870.       iToolBar1, 
  871.       iToolBar1, 
  872.       IRectangle(), 
  873.       IToolBarButton::defaultStyle() | ICustomButton::autoLatch | IControl::group);
  874.    iToolBarButton1 = new IToolBarButton(
  875.       id+WNDOFFSET_TreeCnr_ToolBarButton1, 
  876.       iToolBar1, 
  877.       iToolBar1, 
  878.       IRectangle(), 
  879.       IToolBarButton::defaultStyle() & ~IControl::group | ICustomButton::autoLatch);
  880.    iToolBarButton2 = new IToolBarButton(
  881.       id+WNDOFFSET_TreeCnr_ToolBarButton2, 
  882.       iToolBar1, 
  883.       iToolBar1, 
  884.       IRectangle(), 
  885.       IToolBarButton::defaultStyle() | IControl::group);
  886.    iToolBarButton5 = new IToolBarButton(
  887.       id+WNDOFFSET_TreeCnr_ToolBarButton5, 
  888.       iToolBar1, 
  889.       iToolBar1, 
  890.       IRectangle(), 
  891.       IToolBarButton::defaultStyle() & ~IControl::group);
  892.    iInfoArea1 = new IInfoArea(this, id+WNDOFFSET_TreeCnr_InfoArea1);
  893.    iPeople = new IVSequence< Person * >();
  894.    iPersonFact = new TreeCnrPersonFactFactory();
  895.    iSelPerson = new IVBVariablePartPointer<Person *>();
  896.    iMessageBox = new IMessageBox(this);
  897.  
  898.    conn7 = new TreeCnrConn7();
  899.    conn9 = new TreeCnrConn9();
  900.    conn18 = new TreeCnrConn18();
  901.    conn29 = new TreeCnrConn29();
  902.    conn14 = new TreeCnrConn14();
  903.    conn15 = new TreeCnrConn15();
  904.    conn22 = new TreeCnrConn22();
  905.    conn12 = new TreeCnrConn12();
  906.    conn17 = new TreeCnrConn17();
  907.    conn44 = new TreeCnrConn44();
  908.    conn25 = new TreeCnrConn25();
  909.  
  910.    iMultiCellCanvas1->addToCell(iTreeCnr, 1, 1, 1, 1);
  911.    iMultiCellCanvas1->setColumnWidth(1, IMultiCellCanvas::defaultCell().width(), true);
  912.    iMultiCellCanvas1->setRowHeight(1, IMultiCellCanvas::defaultCell().height(), true);
  913.    iTreeCnr->showTitleSeparator(true);
  914.    iTreeCnr->showTreeTextView();
  915.    iTreeCnr->addColumn(iContainerColumn1);
  916.    iTreeCnr->addColumn(iContainerColumn2);
  917.    iTreeCnr->addColumn(iContainerColumn3);
  918.    iContainerColumn1->setHeadingText("Name");
  919.    iContainerColumn2->setHeadingText("Boss's name");
  920.    iContainerColumn3->setHeadingText("Phone #");
  921.    iToolBar1->addAsLast(iToolBarButton, iToolBarButton->isGroup());
  922.    iToolBar1->addAsLast(iAddEf, iAddEf->isGroup());
  923.    iToolBar1->addAsLast(iToolBarButton4, iToolBarButton4->isGroup());
  924.    iToolBar1->addAsLast(iToolBarButton3, iToolBarButton3->isGroup());
  925.    iToolBar1->addAsLast(iToolBarButton1, iToolBarButton1->isGroup());
  926.    iToolBar1->addAsLast(iToolBarButton2, iToolBarButton2->isGroup());
  927.    iToolBar1->addAsLast(iToolBarButton5, iToolBarButton5->isGroup());
  928.    iToolBarButton->setText("Add");
  929.    iAddEf->setMinimumSize(ISize(157, 27));
  930.    iToolBarButton4->setText("Delete");
  931.    iToolBarButton3->setText("TreeTxt");
  932.    iToolBarButton3->latch(true);
  933.    iToolBarButton1->setText("Tree");
  934.    iToolBarButton1->latch(false);
  935.    iToolBarButton2->setText("Expand");
  936.    iToolBarButton5->setText("Collapse");
  937.    this->setFocus();
  938.    this->setClient(iMultiCellCanvas1);
  939.    iPeople->add(new Person("Root"));
  940.    iPersonFact->setAddEf(iAddEf);
  941.    iPersonFact->setSelPerson(iSelPerson);
  942. }     //end constructor
  943.  
  944.  
  945. //------------------------------------------------------------------------------
  946. // TreeCnr :: ~TreeCnr
  947. //------------------------------------------------------------------------------
  948. #pragma export (TreeCnr::~TreeCnr())
  949. TreeCnr::~TreeCnr()
  950. {
  951.    conn7->stopHandlingNotificationsFor(*iToolBarButton1);
  952.    conn9->stopHandlingNotificationsFor(*iPeople);
  953.    conn9->stopHandlingNotificationsFor(*iTreeCnr);
  954.    conn18->stopHandlingNotificationsFor(*iSelPerson);
  955.    conn29->stopHandlingNotificationsFor(*iTreeCnr);
  956.    conn29->stopHandlingNotificationsFor(*iSelPerson);
  957.    conn14->stopHandlingNotificationsFor(*iToolBarButton3);
  958.    conn15->stopHandlingNotificationsFor(*iToolBarButton);
  959.    conn22->stopHandlingNotificationsFor(*conn15);
  960.    conn12->stopHandlingNotificationsFor(*iToolBarButton4);
  961.    conn17->stopHandlingNotificationsFor(*this);
  962.    conn44->stopHandlingNotificationsFor(*iToolBarButton2);
  963.    conn25->stopHandlingNotificationsFor(*iToolBarButton5);
  964.  
  965.    delete conn7;
  966.    delete conn9;
  967.    delete conn18;
  968.    delete conn29;
  969.    delete conn14;
  970.    delete conn15;
  971.    delete conn22;
  972.    delete conn12;
  973.    delete conn17;
  974.    delete conn44;
  975.    delete conn25;
  976.  
  977.  
  978.    delete iMultiCellCanvas1;
  979.    delete iTreeCnr;
  980.    delete iContainerColumn1;
  981.    delete iContainerColumn2;
  982.    delete iContainerColumn3;
  983.    delete iToolBar1;
  984.    delete iToolBarButton;
  985.    delete iAddEf;
  986.    delete iToolBarButton4;
  987.    delete iToolBarButton3;
  988.    delete iToolBarButton1;
  989.    delete iToolBarButton2;
  990.    delete iToolBarButton5;
  991.    delete iInfoArea1;
  992.    delete iPeople;
  993.    delete iPersonFact;
  994.    delete iSelPerson;
  995.    delete iMessageBox;
  996. }
  997.  
  998. //------------------------------------------------------------------------------
  999. // TreeCnr :: initializePart
  1000. //------------------------------------------------------------------------------
  1001. #pragma export (TreeCnr::initializePart())
  1002. TreeCnr & TreeCnr::initializePart()
  1003. {
  1004.    makeConnections();
  1005.    notifyObservers(INotificationEvent(readyId, *this));
  1006.    return *this;
  1007. }
  1008.  
  1009.  
  1010. //------------------------------------------------------------------------------
  1011. // TreeCnr :: makeConnections
  1012. //------------------------------------------------------------------------------
  1013. #pragma export (TreeCnr::makeConnections())
  1014. Boolean TreeCnr::makeConnections()
  1015. {
  1016.    this->enableNotification();
  1017.    iMultiCellCanvas1->enableNotification();
  1018.    iTreeCnr->enableNotification();
  1019.    iToolBar1->enableNotification();
  1020.    iToolBarButton->enableNotification();
  1021.    iAddEf->enableNotification();
  1022.    iToolBarButton4->enableNotification();
  1023.    iToolBarButton3->enableNotification();
  1024.    iToolBarButton1->enableNotification();
  1025.    iToolBarButton2->enableNotification();
  1026.    iToolBarButton5->enableNotification();
  1027.    iInfoArea1->enableNotification();
  1028.    iPeople->enableNotification();
  1029.    iPersonFact->enableNotification();
  1030.    iSelPerson->enableNotification();
  1031.  
  1032.    unsigned long id = this->id();
  1033.    conn7->initialize(iToolBarButton1, iTreeCnr);
  1034.    conn7->handleNotificationsFor(*iToolBarButton1);
  1035.    conn9->initialize(iPeople, iTreeCnr);
  1036.    conn9->handleNotificationsFor(*iPeople);
  1037.    conn9->handleNotificationsFor(*iTreeCnr);
  1038.    conn18->initialize(iSelPerson, iInfoArea1);
  1039.    conn18->handleNotificationsFor(*iSelPerson);
  1040.    conn29->initialize(iTreeCnr, iSelPerson);
  1041.    conn29->handleNotificationsFor(*iTreeCnr);
  1042.    conn29->handleNotificationsFor(*iSelPerson);
  1043.    conn14->initialize(iToolBarButton3, iTreeCnr);
  1044.    conn14->handleNotificationsFor(*iToolBarButton3);
  1045.    conn15->initialize(iToolBarButton, this);
  1046.    conn15->handleNotificationsFor(*iToolBarButton);
  1047.    conn22->initialize(conn15, iMessageBox);
  1048.    conn22->handleNotificationsFor(*conn15);
  1049.    conn12->initialize(iToolBarButton4, this);
  1050.    conn12->handleNotificationsFor(*iToolBarButton4);
  1051.    conn12->setACnr(iTreeCnr);
  1052.    conn12->setACol(iPeople);
  1053.    conn12->setAPerson(iSelPerson);
  1054.    conn17->initialize(this, this);
  1055.    conn17->handleNotificationsFor(*this);
  1056.    conn44->initialize(iToolBarButton2, iTreeCnr);
  1057.    conn44->handleNotificationsFor(*iToolBarButton2);
  1058.    conn25->initialize(iToolBarButton5, iTreeCnr);
  1059.    conn25->handleNotificationsFor(*iToolBarButton5);
  1060.  
  1061.    conn9->setTarget();
  1062.    conn29->setTarget();
  1063.    return true;
  1064. }
  1065.  
  1066.  
  1067.  
  1068. #include "treecnr.cpv"
  1069.