home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / utility / QAP_AssistPP.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  24.2 KB  |  808 lines

  1. //    ============================================================================
  2. //    ÑÑÑ    QAP_AssistPP.cp
  3. //    ============================================================================
  4. //        QA Partner/Macintosh Driver Assistance Hook for 
  5. //        PowerPlant Class Library applications
  6. //        
  7. //        Copyright ⌐ 1993-1997 Segue Software, Inc.
  8. //        All Rights Reserved.
  9. //        
  10. //        QA PARTNER RELEASE VERSION 4.0 BETA 1
  11. //        THIS IS A BETA RELEASE.  THIS SOFTWARE MAY HAVE BUGS.  THIS SOFTWARE MAY CHANGE BEFORE FINAL RELEASE.
  12.  
  13. /*
  14.  
  15. To use this assistance hook with your PowerPlant application, do the following:
  16.  
  17. 1.     #include "QAP_Assist.h" in the source file(s) in which you do steps 2 and 3 below.
  18.  
  19. 2.     In your main () function, add calls to the QAP_AssistHook before and after your
  20.        application's "Run" method, as follows
  21.  
  22.     ...
  23.     QAP_AssistHook (kQAPAppToForeground, 0, NULL, 0, 0);
  24.     YourApplication->Run();
  25.     QAP_AssistHook (kQAPAppToBackground, 0, NULL, 0, 0);
  26.     ...
  27.     
  28. 3.     Sub-class LCommander::PutOnDuty and LCommander::TakeOffDuty (if you havn't already),
  29.        and add the following to them:
  30.  
  31.     void CYourApplication::PutOnDuty ()
  32.     {
  33.         QAP_AssistHook (kQAPAppToForeground, 0, NULL, 0, 0);
  34.         LCommander::PutOnDuty ();
  35.     }
  36.     
  37.     void CYourApplication::TakeOffDuty ()
  38.     {
  39.         LCommander::TakeOffDuty ();
  40.         QAP_AssistHook (kQAPAppToBackground, 0, NULL, 0, 0);
  41.     }
  42.    
  43. 4.     The assist hook now uses RTTI to resolve class id at runtime.  Make sure RTTI 
  44.     is enabled in your compiler preferences.  Also, ensure that the LView static 
  45.     class variable LView::sInFocusView and the instance variable LView::mSubPanes 
  46.     are visible by tweaking 'LView.h' to declare them public.
  47.     
  48. 5.     Add QAP_AssistPP.cp to your project and rebuild.
  49.  
  50. */
  51.  
  52. #include "QAP_Assist.h"
  53. #include <string.h>
  54.  
  55. #include <LButton.h>
  56. #include <LCaption.h>
  57. #include <LCicnButton.h>
  58. #include <LControl.h>
  59. #include <LEditField.h>
  60. #include <LGroupBox.h>
  61. #include <LIconPane.h>
  62. #include <LListBox.h>
  63. #include <LArrayIterator.h>        //ÑNETSCAPE: was LListIterator.h
  64. #include <LPicture.h>
  65. #include <LPlaceHolder.h>
  66. #include <LStdControl.h>
  67. #include <LTextButton.h>
  68. #include <LTextEdit.h>
  69. #include <LToggleButton.h>
  70. #include <LView.h>
  71. #include <LWindow.h>
  72.  
  73. #ifndef PARTNER // Segue internal use
  74. #  include <LGACheckBox.h>
  75. #  include <LGADisclosureTriangle.h>
  76. #  include <LGAPopup.h>
  77. #  include <LGAIconButtonPopup.h>
  78. #  include <LGAIconButton.h>
  79. #  include <LGAPushButton.h>
  80. #  include <LGATextButton.h>
  81. #  include <LGARadioButton.h>
  82. #endif
  83.  
  84. #ifdef PARTNER // Segue internal use
  85. #  include "ZButton.h"
  86. #endif
  87.  
  88. #include "CButton.h"        //ÑNETSCAPE: custom classes
  89. #include "CPatternButtonPopup.h"
  90.  
  91. #ifndef FALSE                //ÑNETSCAPE: duh?
  92. #define FALSE 0
  93. #endif
  94.  
  95.                             //ÑNETSCAPE:
  96.                             // When the driver calls back QAP_AssistHook with the
  97.                             // 'kQAPGetListContents' selector, it sets a wrong
  98.                             // LPane* in 'l_handle'. This enables a workaround:
  99. #define QAP_V4_DRIVER_WORKAROUND
  100.  
  101. #pragma segment main
  102.  
  103. static short SetAssistHook (QAPAssistHookUPP assistHookUPP);
  104. static void AddViewItem (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_type, short s_cls, Handle h);
  105. static short GetWindowContents (WindowPtr winp, PWCINFO wcp, short s_max);
  106. static short GetListInfo (LPane * lpanep, PQAPLISTINFO p_buffer);                //ÑNETSCAPE: added
  107. static short GetListContents (LPane * lpanep, Ptr p_buffer, short s_val);        //ÑNETSCAPE: added
  108. static short LPaneGetContents (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_max);
  109. static short LPaneGetTextInfo (LPane * lpanep, PTEXTINFO textInfop);
  110. static short LPaneGetCustomItemName (LPane * lpanep, char * cp_buf);
  111. static short LPaneGetCustomItemValue (LPane * lpanep, long * l_value);
  112.  
  113. #ifdef QAP_BUILD
  114.  
  115. // NOTE: assumes that <MacHeaders> is automatically included
  116.  
  117. //    ----------------------------------------------------------------------------
  118. //    Ñ    QAP_AssistHook
  119. //    ----------------------------------------------------------------------------
  120. //        QAP_AssistHook is the actual assistance hook callback.
  121.  
  122. pascal short QAP_AssistHook (short s_selector, long l_handle, void * p_buffer, short s_val, long l_inAppA5)
  123. {
  124.     short s_result;
  125.     long l_saveA5;
  126.  
  127.     /* Dispatch to the appropiate function and return the result. */
  128.     
  129.     switch (s_selector)
  130.     {
  131.     case kQAPAppToForeground:
  132.         s_result = SetAssistHook (NewQAPAssistHook (QAP_AssistHook));
  133.         break;
  134.  
  135.     case kQAPAppToBackground:
  136.         s_result = SetAssistHook (NULL);
  137.         break;
  138.  
  139.     case kQAPGetWindowContents:
  140.         l_saveA5 = SetA5 (l_inAppA5);
  141.         s_result = GetWindowContents ((WindowPtr) l_handle, (PWCINFO) p_buffer, s_val);
  142.         l_saveA5 = SetA5 (l_saveA5);
  143.         break;
  144.  
  145. /*
  146.     case kQAPGetCustomItemName:
  147.         l_saveA5 = SetA5 (l_inAppA5);
  148.         LPaneGetCustomItemName ((LPane *) l_handle, (char *) p_buffer);
  149.         l_saveA5 = SetA5 (l_saveA5);
  150.         break;
  151. */    
  152.     case kQAPGetCustomItemValue:
  153.         l_saveA5 = SetA5 (l_inAppA5);
  154.         LPaneGetCustomItemValue ((LPane *) l_handle, (long *) p_buffer);
  155.         l_saveA5 = SetA5 (l_saveA5);
  156.         break;
  157.         
  158.     case kQAPGetTextInfo:
  159.         l_saveA5 = SetA5 (l_inAppA5);
  160.         s_result = LPaneGetTextInfo ((LPane *) l_handle, (PTEXTINFO) p_buffer);
  161.         l_saveA5 = SetA5 (l_saveA5);
  162.         break;
  163.  
  164.     case kQAPGetListInfo:
  165.         //    PowerPlant LListBox uses the Mac Toolbox ListManager, so QAP gets
  166.         //    the information it needs from the ListHandle.  If you use custom 
  167.         //    ListBoxes, this selector would be called to retrieve information about the ListBox.
  168. //ÑNETSCAPE: the following lines were out-commented
  169.         l_saveA5 = SetA5 (l_inAppA5);
  170.         s_result = GetListInfo ((LPane *) l_handle, (PQAPLISTINFO) p_buffer);
  171.         l_saveA5 = SetA5 (l_saveA5);
  172.         break;
  173.  
  174.     case kQAPGetListContents:
  175.         //    PowerPlant LListBox uses the Mac Toolbox ListManager, so QAP gets
  176.         //    the information it needs from the ListHandle.  If you use custom 
  177.         //    ListBoxes, this selector would be called to retrieve the contents the ListBox.
  178. //ÑNETSCAPE: the following lines were out-commented
  179.         l_saveA5 = SetA5 (l_inAppA5);
  180.         s_result = GetListContents ((LPane *) l_handle, (Ptr) p_buffer, s_val);
  181.         l_saveA5 = SetA5 (l_saveA5);
  182.         break;
  183.  
  184.     default:
  185.         s_result = 0;
  186.         break;
  187.     }
  188.     return s_result;
  189. }
  190.  
  191. //    ----------------------------------------------------------------------------
  192. //    Ñ    SetAssistHook
  193. //    ----------------------------------------------------------------------------
  194. //        SetAssistHook makes the appropriate PBControl call to the QA Partner driver to install
  195. //          the assistance hook callback
  196.  
  197. static short SetAssistHook (QAPAssistHookUPP assistHookUPP)
  198. {
  199.     CntrlParam cp;
  200.     OSErr osErr;
  201.     
  202.     if ((osErr = OpenDriver (QAP_DRIVER_NAME, &cp.ioCRefNum)) != 0)
  203.         return osErr;
  204.  
  205.     cp.ioNamePtr = NULL;
  206.     cp.ioVRefNum = 0;
  207.     cp.csCode = QAP_SET_ASSIST_HOOK;
  208.     * (QAPAssistHookUPP *) & cp.csParam[0] = assistHookUPP;
  209.     * (long *) & cp.csParam[2] = (long) SetCurrentA5 ();
  210.  
  211.     if ((osErr = PBControlSync ((ParmBlkPtr) & cp)) != 0)
  212.         return osErr;
  213.  
  214.     return 0;
  215. }
  216.  
  217. //    ----------------------------------------------------------------------------
  218. //    Ñ    AddViewItem
  219. //    ----------------------------------------------------------------------------
  220. //        AddViewItem adds a given item to the window contents list.
  221.  
  222. static void AddViewItem (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_type, short s_cls, char * cp_name, Handle h)
  223. {
  224.     wcp += * sp_count;
  225.     ++ * sp_count;
  226.     wcp->type = s_type;
  227.     wcp->cls = s_cls;
  228.     wcp->handle = h;
  229.     
  230.     if (cp_name)
  231.         strncpy (wcp->str, cp_name, MAC_NAME_SIZE-1);
  232.         
  233.     if (lpanep)
  234.     {
  235.         lpanep->FocusDraw ();
  236.         lpanep->CalcPortFrameRect (wcp->rect);
  237.         wcp->flags = (lpanep->IsEnabled () ? 0 : WCF_DISABLED);
  238.     }
  239. }
  240.  
  241. //    ----------------------------------------------------------------------------
  242. //    Ñ    GetWindowContents
  243. //    ----------------------------------------------------------------------------
  244. //        GetWindowContents is called by the assistance hook to fill in the 
  245. //        window contents structures for all the relevant views in a given window.
  246.  
  247. static short GetWindowContents (WindowPtr winp, PWCINFO wcp, short s_max)
  248. {
  249.     LWindow * lwindowp;
  250.     short s_count = 0;
  251.     LView * lviewp_saveFocus;
  252.     
  253.     lviewp_saveFocus = LView::GetInFocusView();        //ÑNETSCAPE: was LView::sInFocusView;
  254.     
  255.     lwindowp = LWindow::FetchWindowObject (winp);
  256.  
  257.     if (lwindowp != nil)
  258.         LPaneGetContents (lwindowp, wcp, & s_count, s_max);
  259.     
  260.     //    The following call tells the QAP Agent that the list provided is incomplete.
  261.     //    The Agent will go ahead and perform its usual traversal of toolbox data structures.    
  262.     //    If you do not want to perform this search, comment this line out.
  263.     
  264.     AddViewItem (0, wcp, & s_count, WT_INCOMPLETE, 0, NULL, 0);        
  265.                                                                                                                                 
  266.     if (lviewp_saveFocus)
  267.         lviewp_saveFocus->FocusDraw ();
  268.     
  269.     return s_count;
  270. }
  271.  
  272. //    ----------------------------------------------------------------------------
  273. //    Ñ    GetListInfo            //ÑNETSCAPE: added
  274. //    ----------------------------------------------------------------------------
  275. static short GetListInfo (LPane * lpanep, PQAPLISTINFO p_buffer)
  276. {
  277.     CQAPartnerTableMixin* qaTable = dynamic_cast <CQAPartnerTableMixin*> (lpanep);
  278.     if (qaTable != NULL)
  279.         qaTable->QapGetListInfo(p_buffer);
  280.     return 0;    
  281. }
  282.  
  283. //    ----------------------------------------------------------------------------
  284. //    Ñ    GetListContents        //ÑNETSCAPE: added
  285. //    ----------------------------------------------------------------------------
  286. static short GetListContents (LPane * lpanep, Ptr p_buffer, short s_val)
  287. {
  288. #ifdef QAP_V4_DRIVER_WORKAROUND
  289.     lpanep = (LPane *)(((long*)lpanep)[4]);
  290. #endif //QAP_V4_DRIVER_WORKAROUND
  291.     CQAPartnerTableMixin* qaTable = dynamic_cast <CQAPartnerTableMixin*> (lpanep);
  292.     if (qaTable != NULL)
  293.         return (qaTable->QapGetListContents(p_buffer, s_val));
  294.     return 0;    
  295. }
  296.  
  297.  
  298. //    ----------------------------------------------------------------------------
  299. //    Ñ    LPaneGetContents
  300. //    ----------------------------------------------------------------------------
  301. //        LPaneGetContents is called by GetWindowContents 
  302. //        and recursively by itself to fill in some window contents structures 
  303. //        for a given LPane.
  304.  
  305. static short LPaneGetContents (LPane * lpanep, PWCINFO wcp, short * sp_count, short s_max)
  306. {
  307.     LView * lviewp;
  308.     LEditField * leditFieldp;
  309.     LListBox * llistBoxp;
  310.     LStdControl * lstdControlp;
  311.     LTextEdit * ltextEditp;
  312.     PaneIDT id;
  313.     Str255 str;
  314.     char str_name[MAC_NAME_SIZE];
  315.  
  316.     if (* sp_count == s_max)
  317.         return 0;
  318.         
  319.     if ((llistBoxp = dynamic_cast <LListBox*> (lpanep)) != NULL)
  320.     {
  321.         AddViewItem (lpanep, wcp, sp_count, WT_LIST_BOX, 0, NULL, (Handle) llistBoxp->GetMacListH ());
  322.         // Adjust bounding rect to exclude the scrollbars.
  323.         Rect r_adjusted = wcp [*sp_count-1].rect;
  324.         if ((** llistBoxp->GetMacListH ()).vScroll != NULL)
  325.             r_adjusted.right -= 15;
  326.         if ((** llistBoxp->GetMacListH ()).hScroll != NULL)
  327.             r_adjusted.bottom -= 15;            
  328.         wcp [*sp_count-1].rect = r_adjusted;    
  329.         goto Done;
  330.     }
  331.     
  332.     if ((lstdControlp = dynamic_cast <LStdControl*> (lpanep)) != NULL)
  333.     {
  334.         ((LCaption *) lpanep)->GetDescriptor (str);
  335.         p2cstr (str);
  336.         AddViewItem (lpanep, wcp, sp_count, WT_CONTROL, 0, (char *) str, (Handle) lstdControlp->GetMacControl ());
  337.         goto Done;
  338.     }
  339.         
  340.     if ((leditFieldp = dynamic_cast <LEditField*> (lpanep)) != NULL)
  341.     {
  342.         AddViewItem (lpanep, wcp, sp_count, WT_TEXT_FIELD, 0, NULL, (Handle) leditFieldp->GetMacTEH ());
  343.         goto Done;
  344.     }
  345.         
  346.     if ((ltextEditp = dynamic_cast <LTextEdit*> (lpanep)) != NULL)
  347.     {
  348.         AddViewItem (lpanep, wcp, sp_count, WT_TEXT_FIELD, 0, NULL, (Handle) ltextEditp->GetMacTEH ());
  349.         goto Done;
  350.     }
  351.         
  352.     if (dynamic_cast <LGroupBox*> (lpanep) != NULL)
  353.     {
  354.         ((LGroupBox *) lpanep)->GetDescriptor (str);
  355.         p2cstr (str);
  356.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_STATIC_TEXT, (char *) str, (Handle) lpanep);
  357.         // Change bounding rect to textbox frame.  To do this, you need to change the access modifier of
  358.         // LGroupBox::CalcTextBoxFrame() from protected to public. 
  359.         ((LGroupBox *) lpanep)->CalcTextBoxFrame (wcp [*sp_count-1].rect);    
  360.  
  361.         goto Done;
  362.     }
  363.     
  364.     if (dynamic_cast <LCaption*> (lpanep) != NULL)
  365.     {
  366.         ((LCaption *) lpanep)->GetDescriptor (str);
  367.         p2cstr (str);
  368.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_STATIC_TEXT, (char *) str, (Handle) lpanep);
  369.         goto Done;
  370.     }
  371.  
  372. #ifdef PARTNER
  373.     if (dynamic_cast <ZButton*> (lpanep) != NULL)
  374.     {
  375.         //    For in-house use, call the ZButton method
  376.         ((ZButton *) lpanep)->GetCDescriptor (str_name);
  377.         if (strcmp (str_name, "") == 0)
  378.         {
  379.             id = lpanep->GetPaneID ();
  380.             * (long *) str_name = id;
  381.             str_name[4] = 0;
  382.         }
  383.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, str_name, (Handle) lpanep);
  384.         goto Done;
  385.     }
  386. #endif    
  387.     if ((dynamic_cast <LButton*> (lpanep) != NULL) ||
  388.         (dynamic_cast <LCicnButton*> (lpanep) != NULL))
  389.     {
  390.         //    Return the pane id as control name
  391.         
  392.         id = lpanep->GetPaneID ();
  393.         * (long *) str_name = id;
  394.         str_name[4] = 0;
  395.         //    Modify or override this to return window class WC_PUSH_BUTTON, 
  396.         //    WC_CHECK_BOX or WC_RADIO_BUTTON as appropriate for your use of LButton.
  397.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, str_name, (Handle) lpanep);
  398.         goto Done;
  399.     }
  400.  
  401.     if (dynamic_cast <LTextButton*> (lpanep) != NULL)
  402.     {
  403.         ((LCaption *) lpanep)->GetDescriptor (str);
  404.         p2cstr (str);
  405.         //    According to doc, LTextButton's default behaviour is that of a radio button.
  406.         //    If this is not your case, change window class below as appropriate.
  407.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_RADIO_BUTTON, (char *) str, (Handle) lpanep);
  408.         goto Done;
  409.     }
  410.  
  411.     if (dynamic_cast <LToggleButton*> (lpanep) != NULL)
  412.     {
  413.         //    Return the pane id as control name
  414.         id = lpanep->GetPaneID ();
  415.         * (long *) str_name = id;
  416.         str_name[4] = 0;
  417.         //    LToggleButton is essentially a fancy check box.
  418.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, str_name, (Handle) lpanep);
  419.         goto Done;
  420.     }
  421.  
  422.     if (dynamic_cast <LIconPane*> (lpanep) != NULL)
  423.     {
  424.         //    Return the pane id as control name
  425.         id = lpanep->GetPaneID ();
  426.         * (long *) str_name = id;
  427.         str_name[4] = 0;
  428.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_ICON, str_name, (Handle) lpanep);
  429.         goto Done;
  430.     }
  431.  
  432.     if (dynamic_cast <LPlaceHolder*> (lpanep) != NULL)
  433.     {
  434.         //    Return the pane id as control name
  435.         id = lpanep->GetPaneID ();
  436.         * (long *) str_name = id;
  437.         str_name[4] = 0;
  438.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CUSTOM, str_name, (Handle) lpanep);
  439.         goto Done;
  440.     }
  441.  
  442. #ifndef PARTNER
  443.     if (dynamic_cast <LGACheckbox *> (lpanep) != NULL)
  444.     {
  445.         ((LGACheckbox *) lpanep)->GetDescriptor (str);
  446.         p2cstr (str);
  447.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, (char *) str, (Handle) lpanep);
  448.         goto Done;
  449.     }
  450.  
  451.     if (dynamic_cast <LGADisclosureTriangle *> (lpanep) != NULL)
  452.     {
  453.         //    Return the pane id as control name
  454.         id = lpanep->GetPaneID ();
  455.         * (long *) str_name = id;
  456.         str_name[4] = 0;
  457.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, str_name /*ÑNETSCAPE: was NULL*/, (Handle) lpanep);
  458.         goto Done;
  459.     }
  460.  
  461.     if (dynamic_cast <LGAPopup *> (lpanep) != NULL)
  462.     {
  463.         ((LGAPopup *) lpanep)->GetDescriptor (str);
  464.         p2cstr (str);
  465.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_POPUP_LIST, (char *) str, (Handle) lpanep);
  466.         goto Done;
  467.     }
  468.  
  469.     if (dynamic_cast <LGAIconButtonPopup *> (lpanep) != NULL)
  470.     {
  471.         //    Return the pane id as control name
  472.         id = lpanep->GetPaneID ();
  473.         * (long *) str_name = id;
  474.         str_name[4] = 0;
  475.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_POPUP_LIST, str_name /*ÑNETSCAPE: was NULL*/, (Handle) lpanep);
  476.         goto Done;
  477.     }
  478.  
  479.     if (dynamic_cast <LGAIconButton *> (lpanep) != NULL)
  480.     {
  481.         //    Return the pane id as control name
  482.         id = lpanep->GetPaneID ();
  483.         * (long *) str_name = id;
  484.         str_name[4] = 0;
  485.  
  486.         switch (((LGAIconButton *) lpanep)->GetControlMode ())
  487.         {
  488.             case controlMode_Button:
  489.                 AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, (char *) str_name /*ÑNETSCAPE: was str*/, (Handle) lpanep);
  490.                 break;
  491.             case controlMode_RadioButton:
  492.                 AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_RADIO_BUTTON, (char *) str_name /*ÑNETSCAPE: was str*/, (Handle) lpanep);
  493.                 break;
  494.             case controlMode_Switch:
  495.                 AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CHECK_BOX, (char *) str_name /*ÑNETSCAPE: was str*/, (Handle) lpanep);
  496.                 break;
  497.         }
  498.         goto Done;
  499.     }
  500.     
  501.     if ((dynamic_cast <LGAPushButton *> (lpanep) != NULL) ||
  502.         (dynamic_cast <LGATextButton *> (lpanep) != NULL))
  503.     {
  504.         ((LGAPopup *) lpanep)->GetDescriptor (str);
  505.         p2cstr (str);
  506.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, (char *) str, (Handle) lpanep);
  507.         goto Done;
  508.     }
  509.  
  510.     if (dynamic_cast <LGARadioButton *> (lpanep) != NULL)
  511.     {
  512.         ((LGAPopup *) lpanep)->GetDescriptor (str);
  513.         p2cstr (str);
  514.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_RADIO_BUTTON, (char *) str, (Handle) lpanep);
  515.         goto Done;
  516.     }
  517. #endif
  518.  
  519.     if (dynamic_cast <LPicture*> (lpanep) != NULL)
  520.     {
  521.         //    Return the pane id as control name
  522.         id = lpanep->GetPaneID ();
  523.         * (long *) str_name = id;
  524.         str_name[4] = 0;
  525.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PICTURE, str_name, (Handle) lpanep);
  526.         // LPicture is subclassed from LView, and can have subViews.  Don't exit.
  527.     }
  528.  
  529.     //Ñ NETSCAPE --- begin
  530.     if (dynamic_cast <CPatternButtonPopup *> (lpanep) != NULL)
  531.     {
  532.         //    Return the pane id as control name
  533.         id = lpanep->GetPaneID ();
  534.         * (long *) str_name = id;
  535.         str_name[4] = 0;
  536.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_POPUP_LIST, str_name, (Handle) lpanep);
  537.         goto Done;
  538.     }
  539.  
  540.     if (dynamic_cast <CButton*> (lpanep) != NULL)
  541.     {
  542.         ((CButton *)lpanep)->GetDescriptor(str);
  543.         p2cstr(str);
  544.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_PUSH_BUTTON, (char *) str, (Handle) lpanep);
  545.         goto Done;
  546.  
  547.         short s_type = WC_PUSH_BUTTON;    
  548.         if (((CButton *)lpanep)->IsBehaviourRadio())
  549.             s_type = WC_RADIO_BUTTON;
  550.         else
  551.         if (((CButton *)lpanep)->IsBehaviourToggle())
  552.             s_type = WC_CHECK_BOX;
  553.  
  554.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, s_type, (char *) str, (Handle) lpanep);
  555.         goto Done;
  556.     }
  557.  
  558.     if (dynamic_cast <CQAPartnerTableMixin*> (lpanep) != NULL)
  559.     {
  560.         id = lpanep->GetPaneID ();
  561.         * (long *) str_name = id;
  562.         str_name[4] = 0;
  563.         AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_LIST_BOX, (char *) str_name, (Handle) lpanep);
  564.         goto Done;
  565.     }    
  566.     //Ñ NETSCAPE --- end
  567.  
  568.  
  569.     //Ñ NETSCAPE: below is the generic LView handler - put your custom types above
  570.     if ((lviewp = dynamic_cast <LView*> (lpanep)) != NULL)
  571.     {
  572.         LArrayIterator     iterator (lviewp->GetSubPanes (), LArrayIterator::from_Start);
  573.         LPane             * lpanep_sub;
  574.  
  575.         while (iterator.Next (& lpanep_sub)) 
  576.         {
  577.             if (lpanep_sub->IsVisible ())
  578.                 LPaneGetContents (lpanep_sub, wcp, sp_count, s_max);
  579.             if (* sp_count == s_max)
  580.                 break;
  581.         }
  582.         goto Done;
  583.     }
  584.  
  585. /*
  586.     The following is a catch-all which will return any other LPane as a CustomWin, including 
  587.     "cosmetic" LPanes with no functionality.  If you don't want this to happen,
  588.     comment the next four lines out.
  589. */
  590. /*
  591.     id = lpanep->GetPaneID ();
  592.     * (long *) str_name = id;
  593.     str_name[4] = 0;
  594.     AddViewItem (lpanep, wcp, sp_count, WT_ASSIST_ITEM, WC_CUSTOM, str_name, (Handle) lpanep);
  595. */
  596. Done:
  597.     return * sp_count;
  598. }
  599.  
  600. //    ----------------------------------------------------------------------------
  601. //    Ñ    LPaneGetTextInfo
  602. //    ----------------------------------------------------------------------------
  603.  
  604. static short LPaneGetTextInfo (LPane * lpanep, PTEXTINFO textInfop)
  605. {
  606.     LCaption * lcaptionp;
  607.     LGroupBox * lgroupBoxp;
  608.     
  609.     memset (textInfop, 0, sizeof (TEXTINFO));
  610.     
  611.     if ((lcaptionp = dynamic_cast <LCaption*> (lpanep)) != NULL)
  612.     {
  613.         lcaptionp->GetDescriptor ((unsigned char *) textInfop->buf);
  614.         textInfop->hTE = NULL;
  615.         textInfop->hasFocus = FALSE;
  616.         textInfop->len = textInfop->buf[0];
  617.         textInfop->handle = NULL;
  618.         textInfop->state = FALSE;
  619.         textInfop->ptr = (char *) & textInfop->buf[1];
  620.     }
  621.  
  622.     if ((lgroupBoxp = dynamic_cast <LGroupBox*> (lpanep)) != NULL)
  623.     {
  624.         lgroupBoxp->GetDescriptor ((unsigned char *) textInfop->buf);
  625.         textInfop->hTE = NULL;
  626.         textInfop->hasFocus = FALSE;
  627.         textInfop->len = textInfop->buf[0];
  628.         textInfop->handle = NULL;
  629.         textInfop->state = FALSE;
  630.         textInfop->ptr = (char *) & textInfop->buf[1];
  631.     }
  632.  
  633.     return 0;
  634. }
  635.  
  636. //    ----------------------------------------------------------------------------
  637. //    Ñ    LPaneGetCustomItemName
  638. //    ----------------------------------------------------------------------------
  639. //        If you want the assist hook to return the name of a GUI object, to
  640. //        be used as the tag, make sure this function returns what you need.xxx
  641. //        Name must be a NULL terminated c-string, shorter than 256 characters.
  642. /*
  643. static short LPaneGetCustomItemName (LPane * lpanep, char * cp_buf)
  644. {
  645.     
  646.     * cp_buf = 0;
  647.     
  648.     //    For classes without obvious descriptor, by default we use the 4 character PaneID for tag.
  649.     //    Change this if you want to return a different descriptor.
  650.     LButton * lbuttonp;
  651.     LCicnButton * lcicnButtonp;
  652.     LTextButton * ltextButtonp;
  653.     LToggleButton * ltoggleButtonp;
  654.     LPicture * lpicturep;
  655.     LIconPane * liconPanep;
  656.             
  657.     PaneIDT id;
  658.     
  659.     if ((lbuttonp = dynamic_cast <LButton *> (lpanep)) != NULL)
  660.     {
  661.         id = lbuttonp->GetPaneID ();
  662.         * (long *) cp_buf = id;
  663.         cp_buf[4] = 0;
  664.         goto Done;
  665.     }
  666.  
  667.     if ((lcicnButtonp = dynamic_cast <LCicnButton *> (lpanep)) != NULL)
  668.     {
  669.         id = lbuttonp->GetPaneID ();
  670.         * (long *) cp_buf = id;
  671.         cp_buf[4] = 0;
  672.         goto Done;
  673.     }
  674.  
  675.     if ((ltextButtonp = dynamic_cast <LTextButton *> (lpanep)) != NULL)
  676.     {
  677.         ltextButtonp->GetDescriptor ((unsigned char *) cp_buf);
  678.         p2cstr ((StringPtr) cp_buf);
  679.         goto Done;
  680.     }
  681.  
  682.     if ((ltoggleButtonp = dynamic_cast <LToggleButton *> (lpanep)) != NULL)
  683.     {
  684.         id = ltoggleButtonp->GetPaneID ();
  685.         * (long *) cp_buf = id;
  686.         cp_buf[4] = 0;
  687.         goto Done;
  688.     }
  689.  
  690.     if ((lpicturep = dynamic_cast <LPicture *> (lpanep)) != NULL)
  691.     {
  692.         id = lpicturep->GetPaneID ();
  693.         * (long *) cp_buf = id;
  694.         cp_buf[4] = 0;
  695.         goto Done;
  696.     }
  697.  
  698.     if ((liconPanep = dynamic_cast <LIconPane *> (lpanep)) != NULL)
  699.     {
  700.         id = liconPanep->GetPaneID ();
  701.         * (long *) cp_buf = id;
  702.         cp_buf[4] = 0;
  703.         goto Done;
  704.     }
  705.  
  706.  
  707. Done:
  708.     return 0;
  709. }
  710. */
  711. //    ----------------------------------------------------------------------------
  712. //    Ñ    LPaneGetCustomItemValue
  713. //    ----------------------------------------------------------------------------
  714. static short LPaneGetCustomItemValue (LPane * lpanep, long * l_value)
  715. {
  716.     
  717.     * l_value = 0;
  718.     
  719.     LControl * lcontrolp;
  720.             
  721.     if ((lcontrolp = dynamic_cast <LControl *> (lpanep)) != NULL)
  722.     {
  723.         * l_value = lcontrolp->GetValue ();
  724.         goto Done;
  725.     }
  726.  
  727. Done:
  728.     return 0;
  729. }
  730.  
  731. //    ----------------------------------------------------------------------------
  732. //    Ñ    CQAPartnerTableMixin            //ÑNETSCAPE: added
  733. //    ----------------------------------------------------------------------------
  734. CQAPartnerTableMixin::CQAPartnerTableMixin(LTableView * inTable)
  735.     : mTableView(inTable)
  736. {
  737. }
  738.  
  739. CQAPartnerTableMixin::~CQAPartnerTableMixin()
  740. {
  741. }
  742.  
  743. short    CQAPartnerTableMixin::QapGetListContents(Ptr pBuf, short index)
  744. {
  745.     STableCell    sTblCell;
  746.     short        count = 0;
  747.     Ptr            pLimit;
  748.  
  749.     if (pBuf == NULL || mTableView == NULL)
  750.         return 0;
  751.  
  752.     pLimit = pBuf + *(long *)pBuf;
  753.  
  754.     TableIndexT outRows, outCols;
  755.     mTableView->GetTableSize(outRows, outCols);
  756.  
  757.     switch (index)
  758.     {
  759.         case QAP_INDEX_ALL:
  760.             mTableView->IndexToCell(1, sTblCell);
  761.             if (mTableView->IsValidCell(sTblCell))
  762.             {
  763.                 do
  764.                 {
  765.                     if ((pBuf = QapAddCellToBuf(pBuf, pLimit, sTblCell)) != NULL)
  766.                     {
  767.                         count ++;
  768.                         sTblCell.SetCell(sTblCell.row, outCols);
  769.                     }
  770.                     else
  771.                         break;
  772.                 }
  773.                 while (mTableView->GetNextCell(sTblCell));
  774.             }
  775.             break;
  776.             
  777.         case QAP_INDEX_SELECTED:
  778.             sTblCell = mTableView->GetFirstSelectedCell();
  779.             if (mTableView->IsValidCell(sTblCell))
  780.             {
  781.                 do
  782.                 {
  783.                     if ((pBuf = QapAddCellToBuf(pBuf, pLimit, sTblCell)) != NULL)
  784.                     {
  785.                         count ++;
  786.                         sTblCell.SetCell(sTblCell.row, outCols);
  787.                     }
  788.                     else
  789.                         break;
  790.                 }
  791.                 while (mTableView->GetNextSelectedCell(sTblCell));
  792.             }
  793.             break;
  794.             
  795.         default:
  796.             sTblCell.row = index + 1;
  797.             sTblCell.col = 1;
  798.             if (mTableView->IsValidCell(sTblCell))
  799.             {
  800.                 if ((pBuf = QapAddCellToBuf(pBuf, pLimit, sTblCell)) != NULL)
  801.                     count ++;
  802.             }
  803.             break;
  804.     }
  805.     return count;
  806. }
  807.  
  808. #endif /* QAP_BUILD */