home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / BCPPOWL1.ZIP / CHECKERS.ZIP / INFO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-28  |  4.4 KB  |  146 lines

  1. // ObjectWindows - (C) Copyright 1991 by Borland International
  2.  
  3. #include <owl.h>
  4. #include <static.h>
  5. #include "checkers.h"
  6. #include "info.h"
  7. #include "board.h"
  8.  
  9. const LEFTMARGIN = 6;
  10. const SEPERATOR = 4;
  11. const LINESIZE = 16;
  12. const CHARSIZE = 7;
  13. const MAXLINE = INFOXSIZE - LEFTMARGIN;
  14.  
  15. const COLORX = LEFTMARGIN + CHARSIZE * 6;
  16. const COLORY = SEPERATOR + 2;
  17. const COLORW = CHARSIZE * 6;
  18. const REDINFOX = LEFTMARGIN + CHARSIZE * 7;
  19. const REDINFOY = COLORY + LINESIZE + SEPERATOR * 2;
  20. const REDINFOW = MAXLINE - REDINFOX;
  21. const BLACKINFOX = REDINFOX;
  22. const BLACKINFOY = REDINFOY + LINESIZE + SEPERATOR;
  23. const BLACKINFOW = REDINFOW;                 
  24. const SEARCHX = LEFTMARGIN + CHARSIZE * 14;
  25. const SEARCHY = BLACKINFOY + LINESIZE + SEPERATOR * 2;
  26. const SEARCHW = MAXLINE - SEARCHX;
  27. const ITERX = LEFTMARGIN + CHARSIZE * 12;
  28. const ITERY = SEARCHY + LINESIZE + SEPERATOR;
  29. const ITERW = MAXLINE - ITERX;
  30. const VALUEX = LEFTMARGIN + CHARSIZE * 7;
  31. const VALUEY = ITERY + LINESIZE + SEPERATOR;
  32. const VALUEW = MAXLINE - VALUEX;
  33. const NODEX = LEFTMARGIN + CHARSIZE * 9;
  34. const NODEY = VALUEY + LINESIZE + SEPERATOR;
  35. const NODEW = MAXLINE - NODEX;
  36. const SECX =  LEFTMARGIN + CHARSIZE * 11;
  37. const SECY = NODEY + LINESIZE + SEPERATOR;
  38. const SECW = MAXLINE - SECX;
  39. const STATBESTY = SECY + LINESIZE + SEPERATOR * 2;
  40. const BESTX = LEFTMARGIN;
  41. const BESTY = STATBESTY + LINESIZE + SEPERATOR;
  42. const BESTW = MAXLINE - LEFTMARGIN;
  43. const BESTH = LINESIZE * 3 + SEPERATOR * 3 - 9;
  44. const MESSX = LEFTMARGIN;
  45. const MESSY = BESTY + BESTH + SEPERATOR * 2;
  46. const MESSW = MAXLINE - MESSX;
  47.  
  48.  
  49. #define EmptyStr  ""
  50.  
  51.  
  52. TInfoWindow::TInfoWindow(PTWindowsObject AParent, LPSTR ATitle) :
  53.     TWindow(AParent, ATitle)
  54. {
  55.     Attr.Style |= WS_CHILD | WS_VISIBLE;
  56.     Attr.X = BORDERSIZE + (MAXBDSIZE * SQUARE_SIZE) + 3;
  57.     Attr.Y = BORDERSIZE - 3;
  58.     InfoRect.right = Attr.W = INFOXSIZE;
  59.     InfoRect.bottom = Attr.H = MAXBDSIZE * SQUARE_SIZE + 6;
  60.     InfoRect.left = InfoRect.top =  0;
  61.     new TStatic(this, -1, "Turn:", LEFTMARGIN, COLORY,
  62.         CHARSIZE * 6, LINESIZE, 5);
  63.     new TStatic(this, -1, "Red:", LEFTMARGIN, REDINFOY,
  64.         CHARSIZE * 5, LINESIZE, 4);
  65.     new TStatic(this, -1, "Black:", LEFTMARGIN, BLACKINFOY,
  66.         CHARSIZE * 7, LINESIZE, 6);
  67.     new TStatic(this, -1, "Searchdepth:", LEFTMARGIN, SEARCHY,
  68.         CHARSIZE * 13, LINESIZE, 12);
  69.     new TStatic(this, -1, "Iteration:", LEFTMARGIN, ITERY,
  70.         CHARSIZE * 11, LINESIZE, 10);
  71.     new TStatic(this, -1, "Value:", LEFTMARGIN, VALUEY,
  72.         CHARSIZE * 7, LINESIZE, 6);
  73.     new TStatic(this, -1, "Nodes:", LEFTMARGIN, NODEY,
  74.         CHARSIZE * 7, LINESIZE, 7);
  75.     new TStatic(this, -1, "Seconds:", LEFTMARGIN, SECY,
  76.         CHARSIZE * 9, LINESIZE, 9);
  77.     new TStatic(this, -1, "Bestline:", LEFTMARGIN, STATBESTY,
  78.         CHARSIZE * 9, LINESIZE, 9);
  79.     Color = new TStatic(this, -1, EmptyStr, COLORX, COLORY,
  80.         COLORW, LINESIZE, 6);
  81.     RedInfo = new TStatic(this, -1, EmptyStr, REDINFOX, REDINFOY,
  82.         REDINFOW, LINESIZE, REDINFOW/CHARSIZE);
  83.     BlackInfo = new TStatic(this, -1, EmptyStr, BLACKINFOX, BLACKINFOY,
  84.         BLACKINFOW, LINESIZE, BLACKINFOW / CHARSIZE);
  85.     SearchDepth = new TStatic(this, -1, EmptyStr, SEARCHX, SEARCHY,
  86.         SEARCHW, LINESIZE, SEARCHW / CHARSIZE);
  87.     Iteration = new TStatic(this, -1, EmptyStr, ITERX, ITERY,
  88.         ITERW, LINESIZE, ITERW/CHARSIZE);
  89.     Value = new TStatic(this, -1, EmptyStr, VALUEX, VALUEY,
  90.         VALUEW, LINESIZE, VALUEW / CHARSIZE);
  91.     Nodes = new TStatic(this, -1, EmptyStr, NODEX, NODEY,
  92.         NODEW, LINESIZE, NODEW / CHARSIZE);
  93.     Seconds = new TStatic(this, -1, EmptyStr, SECX, SECY,
  94.         SECW, LINESIZE, SECW / CHARSIZE);
  95.     BestLine = new TStatic(this, -1, EmptyStr, BESTX, BESTY,
  96.         BESTW, BESTH, ((BESTW / CHARSIZE) * 3));
  97.     Message = new TStatic(this, -1, EmptyStr, MESSX, MESSY,
  98.         MESSW, LINESIZE, MESSW / CHARSIZE);
  99. }
  100.  
  101.  
  102. void TInfoWindow::Paint( HDC PaintDC, PAINTSTRUCT& )
  103. {
  104.     DrawInfoFrame(PaintDC);
  105. }
  106.  
  107. void TInfoWindow::DrawInfoFrame(HDC hDC)
  108. {
  109.  
  110.    DrawFrame(hDC, InfoRect);
  111. }
  112.  
  113. void TInfoWindow::WMControlColor(TMessage& Msg)
  114. {
  115.     SetBkColor(Msg.WParam, RGB(192, 192, 192));
  116.     Msg.Result = GetStockObject(LTGRAY_BRUSH);
  117. }
  118.  
  119. void TInfoWindow::Reset()
  120. {
  121.    Color->SetText("Red");
  122.    RedInfo->Clear();
  123.    BlackInfo->Clear();
  124.    SearchDepth->Clear();
  125.    Iteration->Clear();
  126.    Value->Clear();
  127.    Nodes->Clear();
  128.    Seconds->Clear();
  129.    BestLine->Clear();
  130.    Message->Clear();
  131. }
  132.  
  133. void TInfoWindow::IterReset()
  134. {
  135.    Color->SetText("Red");
  136.    Iteration->Clear();
  137.    Value->Clear();
  138.    Nodes->Clear();
  139.    Seconds->Clear();
  140.    BestLine->Clear();
  141. }
  142.  
  143.  
  144.  
  145.  
  146.