Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

keywin.c

Go to the documentation of this file.
00001 // ******************************************************************
00002 // * TITLE: keywin.cpp                                              *
00003 // * AUTHOR: Steven W                                           *
00004 // * DATE: April 30, 1993                                           *
00005 // * Purpose: Create display Key Window for main screen             *
00006 // ******************************************************************
00007 
00008 #include "window.h"
00009 #include "keywin.h"
00010 #include "checkbox.h"
00011 #include "scrnobj.h"
00012 #include "ui.h"
00013 
00014 #include <alloc.h>
00015 #include <assert.h>
00016 #include <stdlib.h>
00017 #include <stdio.h>
00018 #include <conio.h>
00019 #include <string.h>
00020 
00021 KeyWindow::KeyWindow ()
00022 {
00023   XDim = KeyXDim;  YDim = KeyYDim;
00024   CliX1 = CliY1 = CliX2 = CliY2 = 0;
00025   TX1 = TY1 = TX2 = TY2 = 0;
00026   BorderColor = RED;
00027   BkColor = LIGHTGRAY;
00028   TitleColor = WHITE;
00029   Title = new char [4];
00030   assert (Title != 0);
00031   strcpy (Title, "Legend");
00032   ClientD = TitleD = NULL;
00033   Drawn = False;
00034 }
00035 
00036 void KeyWindow::Init (Display *d, int x, int y)
00037 {
00038   Disp = d;
00039   X = x;  Y = y;
00040 
00041   char buf[3];
00042 
00043   CalcBorder ();
00044   if (Title)
00045   {
00046     CalcTitle ();
00047     TitleD = new Display (Disp, TX1, TY1, TX2, TY2);
00048     assert (TitleD != 0);
00049     TitleD->SetBkColor (BorderColor);
00050     TitleD->SetTextJustify (CENTER_TEXT, TOP_TEXT);
00051     TitleD->SetTextStyle (TitleFont, HORIZ_DIR, TitleFontSize);
00052     TitleD->SetColor (TitleColor);
00053   }
00054   ClientD = new Display (Disp, CliX1, CliY1, CliX2, CliY2);
00055   assert (ClientD != 0);
00056   ClientD->SetBkColor (BkColor);
00057   // Add stuff to the window
00058 
00059   for (int i=0; i < MaxPlayers; i++) {
00060     if (i != 0)
00061       {sprintf (buf, "%d", i);}
00062     else
00063       {sprintf (buf, "X");}
00064     c[i] = new CheckBox(buf, BLACK, PColor[i], i, Circle);
00065     assert (c[i] != NULL);
00066   }
00067     ClientD->Add (c[0], 5, 0 ); // Since we know there are a max of 6 players
00068     ClientD->Add (c[1], 5, 20); // Don't bother incorporating this into the
00069     ClientD->Add (c[2], 5, 40); // above loop
00070     ClientD->Add (c[3], 35, 0);
00071     ClientD->Add (c[4], 35, 20);
00072     ClientD->Add (c[5], 35, 40);
00073 }
00074 
00075 
00076 void KeyWindow::Draw (void)
00077 {
00078   if (!Drawn)
00079   {
00080     assert (Disp != NULL);
00081     Disp->FastDraw ();
00082     PrepScreen ();
00083     DrawBorder ();
00084     if (TitleD)
00085       DrawTitle ();
00086     ClientD->Clear ();
00087     ClientD->Draw ();
00088     Disp->Done ();
00089     Drawn = True;
00090 
00091     // Turn on all of the buttons and make sure they are static
00092     for (int i = 0; i < MaxPlayers; i++) {
00093       c[i] -> ChangeStatus (On);
00094       c[i] -> SetPseudo (Off); // since there are no messages this is redundant
00095     }
00096   }
00097 }
00098 

Generated on Sun Jul 6 23:07:15 2003 for Scotland Yard by doxygen1.2.15