home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / ADDON.PAK / OPTION.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  4.5 KB  |  156 lines

  1. /*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2.  
  3.   option.cpp
  4.   Created: 10/24/95
  5.   Copyright (c) 1995, Borland International
  6.   $Revision:   1.18  $
  7.   
  8.   Test the OptionSet server.
  9.   See tests.h for a description of the TestObject class, which OptionSetTestA
  10.   derives from.
  11.    
  12. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/  
  13. #ifndef __AOEXPCH_H
  14.   #include "aoexpch.h"
  15. #endif
  16.  
  17. #pragma hdrstop
  18.  
  19. #include <ideaddon\ioption.h>
  20. #include <ideaddon\iproj.h>
  21. #include "option.h"
  22.  
  23. //.............................................................................
  24. OptionSetTestA::OptionSetTestA() { 
  25.   _optionSetServer = NULL; 
  26.   _projectServer = NULL;
  27. }
  28. //.............................................................................
  29. OptionSetTestA::~OptionSetTestA() {
  30.   UnInit();
  31. }
  32.  
  33. //.............................................................................
  34. BOOL OptionSetTestA::Init() {
  35.   //
  36.   // The user has clicked the Init button while positioned on the OptionSet
  37.   // Test A test.
  38.   //
  39.   OutStr( "OptionSetTestA::Init()" );
  40.   if ( !_optionSetServer ) {
  41.     _optionSetServer = GET_INTERFACE( IOptionSetServer );
  42.   }
  43.   if ( !_projectServer ) {
  44.     _projectServer = GET_INTERFACE( IProjectServer );
  45.   }   
  46.   return ( _optionSetServer && _projectServer );
  47. }
  48. //.............................................................................
  49. void OptionSetTestA::UnInit() {
  50.   //
  51.   // The user has clicked the UnInit button or our destructor has been 
  52.   // called.
  53.   //
  54.   OutStr( "OptionSetTestA::UnInit()" );
  55.   if ( _optionSetServer ) {
  56.     _optionSetServer->Release();
  57.     _optionSetServer = NULL;
  58.   }
  59.   if ( _projectServer ) {
  60.     _projectServer->Release();
  61.     _projectServer = NULL;
  62.   }
  63. }  
  64. //.............................................................................
  65. const char * OptionSetTestA::GetName() {
  66.   //
  67.   // Return a name to display in the list of tests.
  68.   //
  69.   return "OptionSet Test A";
  70. }
  71. //.............................................................................
  72. const char * OptionSetTestA::GetTestDescription( int testNum ) {
  73.   //
  74.   // Return a description of each sub-test to display when the user presses
  75.   // the '?' button next to a sub-test button.
  76.   //
  77.   switch ( testNum ) {
  78.     case 1: 
  79.       return "Sets the include path of the selected node(s) to something useless.";
  80.     case 2:
  81.       return "Show include path of the selected node(s)";
  82.     case 3:
  83.       return "Set a #define for the selected node(s)";
  84.     case 4:
  85.       return "removes *all* local overrides for the selected node(s)";
  86.   }
  87.   return "This test not implemented.";
  88. }  
  89. //.............................................................................
  90. void OptionSetTestA::DoTest( int testNum ) {
  91.   //
  92.   // The user has clicked one of the test buttons.
  93.   //
  94.   int numNodes;
  95.   ProjectNode * nodeArray;
  96.   
  97.   if ( !_optionSetServer || !_projectServer ) {
  98.     //
  99.     // We shouldn't ever get here.
  100.     //
  101.     OutStr( "OptionSet Server not initialized!" );
  102.     return;
  103.   }
  104.   
  105.   //
  106.   // Get the currently selected project nodes, these tests will manipulate
  107.   // options on the selected nodes.
  108.   //
  109.   nodeArray = _projectServer->QuerySelectedNodes( &numNodes );
  110.   
  111.   if ( !numNodes ) {
  112.     OutStr( "No selected node(s) to work with" );
  113.   }
  114.   
  115.   for ( int i = 0; i < numNodes; ++i ) {
  116.     switch ( testNum ) {
  117.       case 1: {
  118.         //
  119.         // We'll set the include path to something really funky, just to
  120.         // show that it worked. 
  121.         //
  122.         OutStr( "Setting include path for node" );
  123.         _optionSetServer->OptionApply(  nodeArray[i], 
  124.                               OID_Include,
  125.                               ::MakePolyString( "OptionSet Test A-1" )
  126.                             );
  127.         break;
  128.       }       
  129.       case 2: {
  130.         OutStr( "Include path of node:" );
  131.         IPolyString* pps = _optionSetServer->OptionGet( nodeArray[i], OID_Include );
  132.         ShowPolyStr ( "", pps, TRUE );
  133.         break;
  134.       }
  135.       case 3: { 
  136.         OutStr( "Add Define \"HelloDefine\" to node" );
  137.         IPolyString * name = ::MakePolyString( "HelloDefine" );
  138.         _optionSetServer->OptionApply( nodeArray[i], OID_Defines, name );
  139.         break;
  140.       }
  141.       case 4: {
  142.         OutStr( "Remove local options from node" );
  143.         _optionSetServer->OptionRemove( nodeArray[i], OID_RemoveAll );
  144.         break;
  145.       }
  146.       default: {
  147.         OutStr( FormatStr( "Test #%d Not Implemented!", testNum ) );
  148.       }
  149.     }
  150.   }
  151. }
  152.  
  153.  
  154.  
  155. 
  156.