home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / xcontact / include / CardView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  7.1 KB  |  243 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. ////////////////////////////////////////////////////////////////
  18. // CardView.h --
  19. ////////////////////////////////////////////////////////////////
  20. #ifndef CARDVIEW_H
  21. #define CARDVIEW_H
  22.  
  23.  
  24. #include "Buttons.h"
  25. #include "ListView.h"
  26.  
  27. #include "OkImageView.h"
  28. #include "OkFileItem.h"
  29. #include "OkText.h"
  30. #include "OkScrolledText.h"
  31. #include "OkLabeledComponent.h"
  32. #include "OkToggleButton.h"
  33. #include "OkStr.h"
  34. #include <Vk/VkWindow.h>
  35. #include <Vk/VkMenu.h>
  36. #include <Vk/VkInfoDialog.h>
  37.  
  38.  
  39. // Control classes.
  40.  
  41. class CardInfo;
  42. class CardView;
  43.  
  44. class ActiveToggle : public OkToggleButton {
  45.  
  46.  private:
  47.   int _viewerNo;
  48.   void valueChanged(Boolean newValue);
  49.  
  50.  public:
  51.   ActiveToggle( int viewerNo, Widget parent );
  52.   ~ActiveToggle() {}
  53.   const char* className() { return "ActiveToggle"; }
  54.  
  55.   int viewerNo() const { return _viewerNo; }
  56. };
  57.  
  58.  
  59. class FieldText : public OkText {
  60.  
  61.  private:
  62.   CardView*    _parentView;
  63.  
  64.  public:
  65.   FieldText( const char* name, Widget parent ) : OkText( name, parent ) {}
  66.   ~FieldText() {}
  67.  
  68.   void setParentView( CardView* parentView ) { _parentView = parentView; }
  69.   void valueChanged();
  70. };
  71.  
  72. class Notes : public OkScrolledText {
  73.  
  74.  private:
  75.   CardView*    _parentView;
  76.  
  77.  public:
  78.   Notes( const char* name, Widget parent ) : OkScrolledText( name, parent ) {}
  79.   ~Notes() {}
  80.  
  81.   void setParentView( CardView* parentView ) { _parentView = parentView; }
  82.   void valueChanged();
  83. };
  84.  
  85.  
  86. class Attributes;
  87.  
  88. class CardView : public VkWindow, public OkFileItem {
  89.  
  90.  
  91.  public:
  92.   CardView( int viewerNo );
  93.   ~CardView();
  94.   const char* className() { return "CardView"; }
  95.  
  96.   Boolean okToQuit();
  97.  
  98.   void setCardInfo( CardInfo* );
  99.   const CardInfo* cardInfo() const    { return _cardInfo; }
  100.  
  101.   // Set field values programmatically.
  102.   void setCardPos( int cPos )    { _cardPos = cPos; }
  103.  
  104.   void setName( OkStr name )     { _nameField->t()->setValue( name ); }
  105.   void setPhone1( OkStr phone1 ){ _phone1Field->t()->setValue( phone1 ); }
  106.   void setPhone2( OkStr phone2 ){ _phone2Field->t()->setValue( phone2 ); }
  107.   void setFax( OkStr fax )     { _faxField->t()->setValue( fax ); }
  108.   void setMobilePhone( OkStr mp ){ _mobilePhoneField->t()->setValue( mp ); }
  109.   void setEmail( OkStr email )     { _emailField->t()->setValue( email ); }
  110.  
  111.   void setAddressLine1( OkStr line ){ _addressLine1Field->t()->setValue(line); }
  112.   void setAddressLine2( OkStr line ){ _addressLine2Field->t()->setValue(line); }
  113.   void setCity( OkStr city )     { _cityField->t()->setValue( city ); }
  114.   void setState( OkStr state )     { _stateField->t()->setValue( state ); }
  115.   void setZip( OkStr zip )     { _zipField->t()->setValue( zip ); }
  116.   void setCountry( OkStr country )  { _countryField->t()->setValue( country ); }
  117.  
  118.   void setAttributeValue( unsigned n, Boolean value );
  119.  
  120.   void setNotes( const char* notes ) { _notes->t()->setValue( notes ); }
  121.  
  122.  
  123.   // Get field values.
  124.   int cardPos() const        { return _cardPos; }
  125.  
  126.   OkStr name() const        { return _nameField->t()->getValue(); }
  127.   OkStr phone1() const        { return _phone1Field->t()->getValue(); }
  128.   OkStr phone2() const        { return _phone2Field->t()->getValue(); }
  129.   OkStr fax() const        { return _faxField->t()->getValue(); }
  130.   OkStr mobilePhone() const    { return _mobilePhoneField->t()->getValue(); }
  131.   OkStr email() const        { return _emailField->t()->getValue(); }
  132.  
  133.   OkStr addressLine1() const    { return _addressLine1Field->t()->getValue(); }
  134.   OkStr addressLine2() const    { return _addressLine2Field->t()->getValue(); }
  135.   OkStr city() const        { return _cityField->t()->getValue(); }
  136.   OkStr state() const        { return _stateField->t()->getValue(); }
  137.   OkStr zip() const        { return _zipField->t()->getValue(); }
  138.   OkStr country() const        { return _countryField->t()->getValue(); }
  139.  
  140.   Boolean attributeValue( unsigned n ) const;
  141.  
  142.   const char* notes() const    { return _notes->t()->getValue(); }
  143.   void insertFromFile();
  144.   void saveToFile();
  145.   void clearNotes();
  146.  
  147.  
  148.   // Utility Funcs.
  149.   int viewerNo() const        { return _activeToggle->viewerNo(); }
  150.   void makeActive( Boolean );
  151.   void hide();
  152.   void save( Boolean redrawFace=FALSE );
  153.  
  154.   void saveAndDeleteCardInfo();
  155.  
  156.   void showFaceImg();
  157.   void hideFaceImg();
  158.  
  159.   Boolean dirty()         { return _dirty; }
  160.   void clearDirty()         { _dirty = FALSE; }
  161.   void setDirty()         { _dirty = TRUE; }
  162.  
  163.   Boolean deleteCard();
  164.  
  165.   Attributes* attributes()     { return _attributes->t(); }
  166.  
  167.   void setFieldLabels();
  168.  
  169.  private:
  170.  
  171.   static VkMenuDesc mainMenuPane[];
  172.   static VkMenuDesc cardMenuPane[];
  173.   static VkMenuDesc notesMenuPane[];
  174.   static VkMenuDesc cardUtilsMenuPane[];
  175.   static VkMenuDesc cardPrefsMenuPane[];
  176.  
  177.   int     _cardPos;
  178.   CardInfo* _cardInfo;
  179.  
  180.   OkImageView*                _faceImg;
  181.   
  182.   OkLabeledComponent<FieldText>*    _nameField;
  183.   OkLabeledComponent<FieldText>*    _phone1Field;
  184.   OkLabeledComponent<FieldText>*    _phone2Field;
  185.   OkLabeledComponent<FieldText>*    _faxField;
  186.   OkLabeledComponent<FieldText>*    _mobilePhoneField;
  187.   OkLabeledComponent<FieldText>*    _emailField;
  188.  
  189.   OkLabeledComponent<FieldText>*    _addressLine1Field;
  190.   OkLabeledComponent<FieldText>*    _addressLine2Field;
  191.   OkLabeledComponent<FieldText>*    _cityField;
  192.   OkLabeledComponent<FieldText>*    _stateField;
  193.   OkLabeledComponent<FieldText>*    _zipField;
  194.   OkLabeledComponent<FieldText>*    _countryField;
  195.  
  196.   OkLabeledComponent<Notes>*        _notes;
  197.  
  198.   OkLabeledComponent<Attributes>*     _attributes;
  199.  
  200.   // Controls.
  201.   ActiveToggle*        _activeToggle;
  202.  
  203.   FirstBtn*        _firstBtn;
  204.   PrevBtn*        _prevBtn;
  205.   NextBtn*        _nextBtn;
  206.   LastBtn*        _lastBtn;
  207.   CloseBtn*        _closeBtn;
  208.  
  209.   SrchBtn*        _srchBtn;
  210.  
  211.   Boolean         _dirty;
  212.  
  213.   void enableNavigationalBtns();
  214.   void disableNavigationalBtns();
  215.  
  216.   void handleWmDeleteMessage()     { hide(); }
  217.  
  218.   // Menu item callbacks.
  219.   static void searchCB( Widget, XtPointer obj, XtPointer ) 
  220.                 { ((CardView *) obj)->_srchBtn->activate(); }
  221.   static void saveCB( Widget, XtPointer obj, XtPointer ) 
  222.                 { ((CardView *) obj)->save( TRUE ); }
  223.   static void deleteCB( Widget, XtPointer obj, XtPointer ) 
  224.                 { ((CardView *) obj)->deleteCard(); }
  225.   static void newCB( Widget, XtPointer obj, XtPointer )
  226.                 { theListView->addCard((CardView *) obj); }
  227.  
  228.   static void printCB( Widget, XtPointer obj, XtPointer );
  229.  
  230.   static void closeCB( Widget, XtPointer obj, XtPointer ) 
  231.                 { ((CardView *) obj)->hide(); }
  232.  
  233.   static void insertFromFileCB( Widget, XtPointer obj, XtPointer ) 
  234.                 { ((CardView *) obj)->insertFromFile(); }
  235.   static void saveToFileCB( Widget, XtPointer obj, XtPointer ) 
  236.                 { ((CardView *) obj)->saveToFile(); }
  237.   static void clearNotesCB( Widget, XtPointer obj, XtPointer ) 
  238.                 { ((CardView *) obj)->clearNotes(); }
  239.  
  240. };
  241.  
  242. #endif
  243.