home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / CWarningsDialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-20  |  6.3 KB  |  238 lines  |  [TEXT/KAHL]

  1. /*
  2.     Harvest C
  3.     Copyright 1992 Eric W. Sink.  All rights reserved.
  4.     
  5.     This file is part of Harvest C.
  6.     
  7.     Harvest C is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU Generic Public License as published by
  9.     the Free Software Foundation; either version 2, or (at your option)
  10.     any later version.
  11.     
  12.     Harvest C is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.     
  17.     You should have received a copy of the GNU General Public License
  18.     along with Harvest C; see the file COPYING.  If not, write to
  19.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.     
  21.     Harvest C is not in any way a product of the Free Software Foundation.
  22.     Harvest C is not GNU software.
  23.     Harvest C is not public domain.
  24.  
  25.     This file may have other copyrights which are applicable as well.
  26.  
  27. */
  28.  
  29. /******************************************************************************
  30.  CWarningsDialog.c
  31.  
  32.         
  33.     SUPERCLASS = CDLOGDirector
  34.     
  35.     Copyright © 1991 Symantec Corporation. All rights reserved.
  36.     
  37.  
  38.  ******************************************************************************/
  39.  
  40. #include "CWarningsDialog.h"
  41. #include "CWarningsPane.h"
  42. #include "CWarningsArray.h"
  43. #include "CScrollPane.h"
  44. #include "CDialogText.h"
  45. #include "CDialog.h"
  46. #include "CPaneBorder.h"
  47. #include "CApplication.h"
  48. #include "CHarvestApp.h"
  49. #include "CHarvestDoc.h"
  50. #include "CHarvestOptions.h"
  51. #include "CDataFile.h"
  52. #include "CSourceFile.h"
  53. #include "Commands.h"
  54. #include "HarvestCommands.h"
  55. #include "AppleEvents.h"
  56. #include "Aliases.h"
  57. #include "stdarg.h"
  58.  
  59. #define    kDemoDlgID            1050
  60.  
  61. enum        /* window item numbers    */
  62. {
  63.     kListScrollPaneItem = 1
  64. };
  65.  
  66. extern CHarvestApp    *gApplication;
  67. extern CHarvestDoc    *gProject;
  68. extern tSystem gSystem;
  69. extern CSourceFile *gCurSourceFile;
  70. extern CWarningsDialog *gErrs;
  71.  
  72. /******************************************************************************
  73.  IWarningsDialog
  74. ******************************************************************************/
  75.  
  76. #define maxStringLen 255
  77.  
  78. void CWarningsDialog::IWarningsDialog( CHarvestOptions *theOpts,CWarningsArray *theWarnings)
  79. {
  80.     CScrollPane    *scrollPane;
  81.     CPaneBorder *listBorder;
  82.     Rect    margin;
  83.     Cell    aCell;
  84.     
  85.  
  86.     CDLOGDirector::IDLOGDirector( kDemoDlgID, gApplication);
  87.     
  88.     itsOptions = theOpts;
  89.  
  90.     scrollPane = (CScrollPane*) itsWindow->FindViewByID( kListScrollPaneItem);
  91.     warningOn = (CCheckBox *) itsWindow->FindViewByID( 2);
  92.     allOn = (CRadioControl *) itsWindow->FindViewByID( 4);
  93.     allOff = (CRadioControl *) itsWindow->FindViewByID( 5);
  94.     indiv = (CRadioControl *) itsWindow->FindViewByID( 6);
  95.     radioPane = (CRadioGroupPane *) itsWindow->FindViewByID( 3);
  96.  
  97.     if (scrollPane)
  98.     {                
  99.         itsWarningsPane = new( CWarningsPane);
  100.         itsWarningsPane->IWarningsPane( scrollPane, itsWindow, 0, 0, 0, 0,
  101.             sizELASTIC, sizELASTIC);
  102.         itsWarningsPane->FitToEnclosure( TRUE, TRUE);
  103.         itsWarningsPane->SetDrawActiveBorder( TRUE);
  104.         itsWarningsPane->SetDblClickCmd(cmdToggleWarning);
  105.         
  106.         itsWarningsPane->SetID( 10);
  107.  
  108.         listBorder = new( CPaneBorder);
  109.         listBorder->IPaneBorder( kBorderFrame);
  110.         itsWarningsPane->SetBorder( listBorder);
  111.                 
  112.         itsWarningsPane->SetSelectionFlags( selOnlyOne);
  113.         
  114.         scrollPane->InstallPanorama( itsWarningsPane);
  115.         
  116.         itsWarnings = theWarnings;
  117.         itsWarningsPane->SetArray( itsWarnings, FALSE);
  118.         
  119.         SetCell( aCell, 0, 0);
  120.         itsWarningsPane->SelectCell( aCell, FALSE, FALSE);
  121.     }
  122.     
  123.     warningOn->SetClickCmd(cmdToggleWarning);
  124.     allOn->SetClickCmd(cmdAllWarningsOn);
  125.     allOff->SetClickCmd(cmdAllWarningsOff);
  126.     indiv->SetClickCmd(cmdIndividuallySet);
  127.  
  128.     radioPane->SetStationID(6);
  129.     
  130.     SetupItems();
  131. }    /* CWarningsDialog::IWarningsDialog */
  132.  
  133. /******************************************************************************
  134.  DoCommand
  135. ******************************************************************************/
  136.  
  137. void CWarningsDialog::DoCommand( long aCmd)
  138. {
  139.     Cell    selectedCell;
  140.     Str255    string;
  141.     Boolean haveSelection;
  142.     struct Warning w;
  143.     
  144.     SetCell( selectedCell, 0, 0);
  145.     haveSelection = itsWarningsPane->GetSelect( TRUE, &selectedCell);
  146.     
  147.     switch (aCmd)
  148.     {
  149.         case cmdToggleWarning:
  150.             itsWarnings->GetItem((Ptr) &w, selectedCell.v+1);
  151.             itsOptions->warnings[w.num] = !itsOptions->warnings[w.num];
  152.             if (itsOptions->warnings[w.num]) {
  153.                 warningOn->SetValue(BUTTON_ON);
  154.             }
  155.             else {
  156.                 warningOn->SetValue(BUTTON_OFF);
  157.             }
  158.             itsWarningsPane->RefreshCell(selectedCell);
  159.             break;
  160.         case cmdAllWarningsOn:
  161.             itsOptions->allWarnings = TRUE;
  162.             itsOptions->noWarnings = FALSE;
  163.             break;
  164.         case cmdAllWarningsOff:
  165.             itsOptions->allWarnings = FALSE;
  166.             itsOptions->noWarnings = TRUE;
  167.             break;
  168.         case cmdIndividuallySet:
  169.             itsOptions->allWarnings = FALSE;
  170.             itsOptions->noWarnings = FALSE;
  171.             break;
  172.         default: 
  173.                 inherited::DoCommand( aCmd);
  174.                 break;
  175.     }
  176.                 
  177. }    /* CWarningsDialog::DoCommand */
  178.  
  179. /******************************************************************************
  180.  SetupItems
  181. ******************************************************************************/
  182.  
  183. void CWarningsDialog::SetupItems( void)
  184. {
  185.     Cell    selectedCell;
  186.     Boolean haveSelection;
  187.     CDialog    *dialog;
  188.     struct Warning w;
  189.  
  190.     /* determine if any cells are now selected    */
  191.     
  192.     SetCell( selectedCell, 0, 0);
  193.     haveSelection = itsWarningsPane->GetSelect( TRUE, &selectedCell);
  194.     
  195.     dialog = (CDialog*) itsWindow;
  196.     
  197.     if (haveSelection) {
  198.         itsWarnings->GetItem((Ptr) &w, selectedCell.v+1);
  199.         if (itsOptions->warnings[w.num]) {
  200.             warningOn->SetValue(BUTTON_ON);
  201.         }
  202.         else {
  203.             warningOn->SetValue(BUTTON_OFF);
  204.         }
  205.     }
  206.     else {
  207.     }
  208. }    /* CWarningsDialog::SetupItems */
  209.  
  210. /******************************************************************************
  211.  ProviderChanged
  212. ******************************************************************************/
  213.  
  214. void CWarningsDialog::ProviderChanged( CCollaborator *aProvider, long reason,
  215.                                         void *info)
  216. {
  217.     Cell    selectedCell;
  218.     Boolean haveSelection;
  219.  
  220.     if ((aProvider == itsWarningsPane) && (reason == tableSelectionChanged))
  221.     {
  222.         SetupItems();
  223.     }
  224.     else
  225.         inherited::ProviderChanged( aProvider, reason, info);
  226.  
  227. }    /* CWarningsDialog::ProviderChanged */
  228.  
  229. /******************************************************************************
  230.  Dispose
  231. ******************************************************************************/
  232.  
  233. void CWarningsDialog::Dispose( void)
  234. {
  235.     inherited::Dispose();
  236. }
  237.  
  238.