home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CHECKERS.ZIP / INFO.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  5.0 KB  |  162 lines

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