00001
00002
00003
00004
00005
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
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 );
00068 ClientD->Add (c[1], 5, 20);
00069 ClientD->Add (c[2], 5, 40);
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
00092 for (int i = 0; i < MaxPlayers; i++) {
00093 c[i] -> ChangeStatus (On);
00094 c[i] -> SetPseudo (Off);
00095 }
00096 }
00097 }
00098