00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "window.h"
00010 #include "cpanel.h"
00011 #include "button.h"
00012 #include "scrnobj.h"
00013 #include "ui.h"
00014
00015 #include <alloc.h>
00016 #include <assert.h>
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 #include <conio.h>
00020 #include <string.h>
00021
00022
00023
00024 CPanelWindow::CPanelWindow (void)
00025 {
00026 XDim = CPanelXDim; YDim = CPanelYDim;
00027 CliX1 = CliY1 = CliX2 = CliY2 = 0;
00028 TX1 = TY1 = TX2 = TY2 = 0;
00029 BorderColor = RED;
00030 BkColor = LIGHTGRAY;
00031 TitleColor = WHITE;
00032 Title = new char[20];
00033 strcpy (Title, "Control Panel");
00034 ClientD = TitleD = NULL;
00035 Drawn = False;
00036 }
00037
00038 void CPanelWindow::Init (Display *d, int x, int y)
00039 {
00040 Disp = d;
00041 X = x; Y = y;
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 PushButton *pb[Num_Buttons_In_CPanel];
00059 pb[3] = new PushButton ("Legal Stops", BLUE, ID_LEGAL);
00060 pb[1] = new PushButton ("Refresh", BLUE, ID_REFRESH, pb[3]->GetXDim(), pb[3]->GetYDim());
00061 pb[2] = new PushButton ("Quit", BLUE, ID_QUIT);
00062 pb[0] = new PushButton ("Spy", BLUE, ID_SPY, pb[2]->GetXDim(), pb[2]->GetYDim());
00063 for (int i=0; i < Num_Buttons_In_CPanel; i++)
00064 assert (pb[i] != NULL);
00065
00066 ClientD -> Add(pb[0],25, 2);
00067 ClientD -> Add(pb[1],25, pb[0]->GetYDim()+5);
00068 ClientD -> Add(pb[3],ClientD->GetMaxX()-pb[3]->GetXDim()-25, 2);
00069 ClientD -> Add(pb[2],ClientD->GetMaxX()-pb[2]->GetXDim()-25
00070 ,pb[0]->GetYDim()+5);
00071 }
00072
00073
00074 Message CPanelWindow::Dispatch (Message& msg)
00075 {
00076 if (ClientD)
00077 return ClientD->Dispatch (msg);
00078 else
00079 return NullMsg;
00080 }
00081