home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / video / security / pref.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.6 KB  |  106 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include <stdlib.h>
  18. #include <limits.h>
  19. #include <stdio.h>
  20. #include "pref.h"
  21.  
  22. Pref::Pref(const char *name) : VkPrefDialog (name)
  23. {
  24.   prefAccuracy = new VkPrefText("accuracy");
  25.   prefAccuracy->setValue("20");
  26.   setAccuracy(20);
  27.  
  28.   prefDelay = new VkPrefText("delay");
  29.   prefDelay->setValue("1");
  30.   setDelay(1);
  31.  
  32.   prefFrames = new VkPrefText("frames");
  33.   prefFrames->setValue("300");
  34.   setFrames(300);
  35.  
  36.   prefCount = new VkPrefText("count");
  37.   prefCount->setValue("10");
  38.   setTripCount(10);
  39.  
  40.   prefType = new VkPrefToggle("motion");
  41.   prefType->setValue(TRUE);
  42.   setTripType(MOTION);
  43.  
  44.   _group = new VkPrefGroup("group",FALSE,FALSE);
  45.   _group->addItem(prefAccuracy);
  46.   _group->addItem(prefDelay);
  47.   _group->addItem(prefFrames);
  48.   _group->addItem(prefType);
  49.   _group->addItem(prefCount);
  50.   setItem(_group);
  51.   
  52. }
  53.  
  54. Pref::~Pref()
  55. {
  56.   delete prefAccuracy;
  57.   delete prefDelay;
  58.   delete prefFrames;
  59.   delete prefCount;
  60.   delete prefType;
  61.   delete _group;
  62. }
  63.  
  64. void Pref::update()
  65. {
  66.   if(prefAccuracy->changed()){
  67.     int acc = atoi(prefAccuracy->getValue());
  68.     if(acc == LONG_MAX || acc <= 0){
  69.       acc = 20;
  70.       prefAccuracy->setValue("20");
  71.     }
  72.     setAccuracy(acc);
  73.   }
  74.   if(prefDelay->changed()){
  75.     int delay = atoi(prefDelay->getValue());
  76.     if(delay == LONG_MAX || delay <= 0){
  77.       delay = 1;
  78.       prefDelay->setValue("1");
  79.     }
  80.     setDelay(delay);
  81.   }
  82.   if(prefFrames->changed()){
  83.     int frames = atoi(prefFrames->getValue());
  84.     if((frames == LONG_MAX || frames <= 0) && (frames != -1)){
  85.       frames = 300;
  86.       prefFrames->setValue("300");
  87.     }
  88.     setFrames(frames);
  89.   }
  90.   if(prefCount->changed()){
  91.     int count = atoi(prefCount->getValue());
  92.     if(count == LONG_MAX || count <= 0){
  93.       count = 10;
  94.       prefCount->setValue("10");
  95.     }
  96.     setTripCount(count);
  97.   }
  98.   if(prefType->changed()){
  99.     if(prefType->getValue()){
  100.       setTripType(MOTION);
  101.     }else{
  102.       setTripType(STATIC);
  103.     }
  104.   }
  105.