home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / g / gina15.zip / demos / sleuth / ZatDialog.C < prev    next >
C/C++ Source or Header  |  1992-02-27  |  4KB  |  167 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2.  
  3. //   Module      : ZatDialog.C   Version 1.2
  4. //   LastSCCS    : 2/26/92  16:38:24
  5. //   LastEdit    : "Tue Nov  5 14:53:11 1991"
  6. //   Description : 
  7. //   Author      : 
  8. //   Copyright   : GMD Schloss Birlinghoven
  9.  
  10. #include <ctype.h>
  11.  
  12. ZatDialog::
  13. ZatDialog(SleuthDocument *p_document)
  14. : UpdatedDialog(True), document(p_document), view(p_document)
  15. {
  16. }
  17.  
  18. void ZatDialog::
  19. Update()
  20. {
  21.     if( ! document->IsRegistered(&view) )
  22.     document->AddCardView(&view);
  23.  
  24.     int i;
  25.     int value = document->GetZatParameterDialog()->GetNumQuestions();
  26.     
  27.     if( value == 0 )
  28.     for( i = 0; i < 5; i++)
  29.         questions[i].unmanage();
  30.     else {
  31.     for( i = 0; i < value; i++)
  32.         questions[i].manage();
  33.     for( i = value; i < 5; i++)
  34.         questions[i].unmanage();
  35.     }
  36.  
  37.     game_name.setR_value(document->GetGameName());
  38.     game_name.SetValues();
  39.  
  40.     strstream stream;
  41.     stream << document->GetRound() << '\0';
  42.     round.setR_value(stream.str());
  43.     round.SetValues();
  44.     player_name.setR_value(document->GetParticipant());
  45.     player_name.SetValues();    
  46. }
  47.  
  48. void ZatDialog::
  49. Mapped()
  50. {
  51.     document->GetZatParameterDialog()->Update();
  52. }
  53.  
  54. void ZatDialog::
  55. Unmapped()
  56. {
  57.     document->GetZatParameterDialog()->Update();
  58. }
  59.  
  60. void ZatDialog::
  61. NewGameName(caddr_t)
  62. {
  63.     document->SetGameName(game_name.get_string(), False);
  64. }
  65.  
  66. void ZatDialog::
  67. NewParticipant(caddr_t)
  68. {
  69.     document->SetParticipant(player_name.get_string(), False);
  70. }
  71.  
  72. void ZatDialog::
  73. NoWhiteSpaceInString(caddr_t call_data)
  74. {
  75.     XmTextVerifyCallbackStruct *cbs = (XmTextVerifyCallbackStruct *)call_data;
  76.  
  77.     for(int i = 0; i < cbs->text->length; i++)
  78.     if(isspace(cbs->text->ptr[i])) {
  79.         cbs->doit = False;
  80.         return;
  81.     }
  82.     cbs->doit = True;
  83. }
  84.  
  85. void ZatDialog::
  86. before_create(GnWidget *)
  87. {
  88.     setR_dialogTitle(DialogTitle());
  89.     setR_noResize(True);
  90.     setR_resizePolicy(XmRESIZE_ANY);
  91. }
  92.  
  93. void ZatDialog::
  94. after_create()
  95. {
  96.     UpdatedDialog::after_create();
  97.     
  98.     game_name.setR_labelString("Spiel:         ");
  99.     game_name.setR_columns(35);
  100.     game_name.setR_topAttachment(XmATTACH_FORM);
  101.     game_name.setR_leftAttachment(XmATTACH_FORM);
  102.     game_name.create(this, "gameName");
  103.     game_name.add_activateCallback(CALLBACK(ZatDialog, NewGameName, this));
  104.     game_name.add_modifyVerifyCallback(CALLBACK(ZatDialog,
  105.                         NoWhiteSpaceInString, this));
  106.     
  107.     round.setR_labelString("Runde:         ");
  108.     round.setR_columns(35);
  109.     round.setR_topAttachment(XmATTACH_WIDGET);
  110.     round.setR_topWidget(game_name);
  111.     round.setR_leftAttachment(XmATTACH_FORM);
  112.     round.create(this, "round");
  113.     
  114.     player_name.setR_labelString("Spieler:       ");
  115.     player_name.setR_columns(35);
  116.     player_name.setR_topAttachment(XmATTACH_WIDGET);
  117.     player_name.setR_topWidget(round);
  118.     player_name.setR_leftAttachment(XmATTACH_FORM);
  119.     player_name.create(this, "playerName");
  120.     player_name.add_activateCallback(CALLBACK(ZatDialog,NewParticipant, this));
  121.     
  122.     date.setR_labelString("Datum:         ");
  123.     date.setR_columns(35);
  124.     date.setR_topAttachment(XmATTACH_WIDGET);
  125.     date.setR_topWidget(player_name);
  126.     date.setR_leftAttachment(XmATTACH_FORM);
  127.     date.create(this, "date");
  128.  
  129.     GnSeparator *separator = new GnSeparator;
  130.     separator->setR_topAttachment(XmATTACH_WIDGET);
  131.     separator->setR_topWidget(date);
  132.     separator->setR_topOffset(10);
  133.     separator->setR_leftAttachment(XmATTACH_FORM);
  134.     separator->setR_rightAttachment(XmATTACH_FORM);
  135.     separator->create(this, "sepp");
  136.     
  137.     row_for_questions.setR_topAttachment(XmATTACH_WIDGET);
  138.     row_for_questions.setR_topWidget(separator);
  139.     row_for_questions.setR_topOffset(10);
  140.     row_for_questions.setR_leftAttachment(XmATTACH_FORM);
  141.     row_for_questions.setR_marginWidth(0);
  142.     row_for_questions.create(this, "rowForQuestions");
  143.  
  144.     questions[0].setR_labelString("Frage:         ");
  145.     questions[1].setR_labelString("Ersatzfrage:   ");
  146.     questions[2].setR_labelString("2. Ersatzfrage:");
  147.     questions[3].setR_labelString("3. Ersatzfrage:");
  148.     questions[4].setR_labelString("4. Ersatzfrage:");
  149.     for( int i = 0; i < 5; i++ ) {
  150.     questions[i].setR_columns(35);
  151.     questions[i].create(row_for_questions, "question");
  152.     if( i >= 2 )
  153.         questions[i].unmanage();
  154.     }
  155.  
  156.     view.setR_topAttachment(XmATTACH_WIDGET);
  157.     view.setR_topWidget(row_for_questions);
  158.     view.setR_leftAttachment(XmATTACH_FORM);
  159.     view.create(this, "view");
  160.     
  161. }
  162.  
  163.  
  164.  
  165.  
  166.  
  167.