home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / pieces.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  7.9 KB  |  373 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.02
  4. // Copyright (C) 1990, 1991
  5. // Software Dimensions
  6. //
  7. // Dialog Development System
  8. //
  9.  
  10. #include "fliwin.h"
  11. #include "colors.h"
  12. #include "dds.h"
  13.  
  14. #include <stdio.h>
  15. #include <alloc.h>
  16. #include <mem.h>
  17.  
  18. //-------------------------------------------------------------------------
  19. //
  20. // Displays prompter for elements
  21. //
  22. //-------------------------------------------------------------------------
  23.  
  24. #define Prompt \
  25.   if (Prompter && *Prompter) \
  26.   { \
  27.     Blaze->QuickDisplay(PromptX,PromptY, \
  28.       Colors.DiaQuickKey,Colors.DiaLocator,Prompter); \
  29.   } \
  30.  
  31. //-------------------------------------------------------------------------
  32. //
  33. // Draws a box
  34. //
  35. //-------------------------------------------------------------------------
  36.  
  37. void Box::DrawFigure()
  38. {
  39.   Blaze->Box(X,Y,Width,Height,Color);
  40. }
  41.  
  42. void Box::Size(int X,int Y)
  43. {
  44.   Width+=X;
  45.   Height+=Y;
  46.   if (Width<2)
  47.     Width=2;
  48.   if (Height<2)
  49.     Height=2;
  50. }
  51.  
  52. //-------------------------------------------------------------------------
  53. //
  54. // Draws a filled box
  55. //
  56. //-------------------------------------------------------------------------
  57.  
  58. void FilledBox::DrawFigure()
  59. {
  60.   Blaze->BoxFilled(X,Y,Width,Height,Color);
  61. }
  62.  
  63. void FilledBox::Size(int X,int Y)
  64. {
  65.   Width+=X;
  66.   Height+=Y;
  67.   if (Width<2)
  68.     Width=2;
  69.   if (Height<2)
  70.     Height=2;
  71. }
  72.  
  73. //-------------------------------------------------------------------------
  74. //
  75. // Draws a horizontal line
  76. //
  77. //-------------------------------------------------------------------------
  78.  
  79. void HorizontalLine::DrawFigure()
  80. {
  81.   Blaze->CharacterRepeater(X,Y,Width,Color,'\xc4');
  82. }
  83.  
  84. void HorizontalLine::Size(int X,int Y)
  85. {
  86.   Width+=X;
  87.   if (Width<1)
  88.     Width=1;
  89. }
  90.  
  91. //-------------------------------------------------------------------------
  92. //
  93. // Draws a vertical line
  94. //
  95. //-------------------------------------------------------------------------
  96.  
  97. void VerticalLine::DrawFigure()
  98. {
  99.   Blaze->CharacterRepeaterDown(X,Y,Height,Color,'\xb3');
  100. }
  101.  
  102. void VerticalLine::Size(int X,int Y)
  103. {
  104.   Height+=Y;
  105.   if (Height<1)
  106.     Height=1;
  107. }
  108.  
  109. //-------------------------------------------------------------------------
  110. //
  111. // Draws a shadow
  112. //
  113. //-------------------------------------------------------------------------
  114.  
  115. void Shadow::DrawFigure()
  116. {
  117.   Blaze->Shadow(X,Y,Width,Height);
  118. }
  119.  
  120. void Shadow::Size(int X,int Y)
  121. {
  122.   Width+=X;
  123.   Height+=Y;
  124.   if (Width<1)
  125.     Width=1;
  126.   if (Height<1)
  127.     Height=1;
  128. }
  129.  
  130. //-------------------------------------------------------------------------
  131. //
  132. // Draws an erased area
  133. //
  134. //-------------------------------------------------------------------------
  135.  
  136. void EraseArea::DrawFigure()
  137. {
  138.   Blaze->EraseArea(X,Y,Width,Height,Color);
  139. }
  140.  
  141. void EraseArea::Size(int X,int Y)
  142. {
  143.   Width+=X;
  144.   Height+=Y;
  145.   if (Width<1)
  146.     Width=1;
  147.   if (Height<1)
  148.     Height=1;
  149. }
  150.  
  151. //-------------------------------------------------------------------------
  152. //
  153. // Draws a colorized area
  154. //
  155. //-------------------------------------------------------------------------
  156.  
  157. void ColorizeArea::DrawFigure()
  158. {
  159.   Blaze->BoxAttribute(X,Y,Width,Height,Color);
  160. }
  161.  
  162. void ColorizeArea::Size(int X,int Y)
  163. {
  164.   Width+=X;
  165.   Height+=Y;
  166.   if (Width<1)
  167.     Width=1;
  168.   if (Height<1)
  169.     Height=1;
  170. }
  171.  
  172. //-------------------------------------------------------------------------
  173. //
  174. // Displays a character element
  175. //
  176. //-------------------------------------------------------------------------
  177.  
  178. void Character::DrawFigure()
  179. {
  180.   if (!ScrollWidth && !MaskWidth)
  181.     (*Blaze) (X,Y) << Color << Mask;
  182.   else
  183.   {
  184.     Blaze->CharacterRepeater(X,Y,Width,Color,' ');
  185.     (*Blaze) << Color;
  186.     if (ScrollWidth)
  187.     {
  188.       (*Blaze) (X,Y) << '\x11';
  189.       (*Blaze) (X+Width-1,Y) << '\x10';
  190.     }
  191.     if (MaskWidth)
  192.     {
  193.       Blaze->CharacterRepeater(X+((ScrollWidth)?1:0),Y,
  194.         (ScrollWidth)?(Width-2):MaskWidth,Color,MaskCharacter);
  195.     }
  196.     else
  197.     {
  198.       (*Blaze) (X+1,Y);
  199.       for (int i=0;i<Width-2;i++)
  200.         (*Blaze) << (char)Mask[i];
  201.     }
  202.   }
  203.   Prompt;
  204. }
  205.  
  206. //-------------------------------------------------------------------------
  207. //
  208. // Displays an integer element
  209. //
  210. //-------------------------------------------------------------------------
  211.  
  212. void Integer::DrawFigure()
  213. {
  214.   (*Blaze) (X,Y) << Color << Mask;
  215.   Prompt;
  216. }
  217.  
  218. //-------------------------------------------------------------------------
  219. //
  220. // Displays a long element
  221. //
  222. //-------------------------------------------------------------------------
  223.  
  224. void Long::DrawFigure()
  225. {
  226.   (*Blaze) (X,Y) << Color << Mask;
  227.   Prompt;
  228. }
  229.  
  230. //-------------------------------------------------------------------------
  231. //
  232. // Displays a float element
  233. //
  234. //-------------------------------------------------------------------------
  235.  
  236. void Float::DrawFigure()
  237. {
  238.   (*Blaze) (X,Y) << Color << Mask;
  239.   Prompt;
  240. }
  241.  
  242. //-------------------------------------------------------------------------
  243. //
  244. // Displays a double element
  245. //
  246. //-------------------------------------------------------------------------
  247.  
  248. void Double::DrawFigure()
  249. {
  250.   (*Blaze) (X,Y) << Color << Mask;
  251.   Prompt;
  252. }
  253.  
  254. //-------------------------------------------------------------------------
  255. //
  256. // Displays a bcd element
  257. //
  258. //-------------------------------------------------------------------------
  259.  
  260. void Bcd::DrawFigure()
  261. {
  262.   (*Blaze) (X,Y) << Color << Mask;
  263.   Prompt;
  264. }
  265.  
  266. //-------------------------------------------------------------------------
  267. //
  268. // Displays a check box element
  269. //
  270. //-------------------------------------------------------------------------
  271.  
  272. void Check::DrawFigure()
  273. {
  274.   (*Blaze) (X,Y) << Color << " [ ] ";
  275.   Blaze->QuickDisplay(X+5,Y,Colors.CheckQuickKey,Colors.CheckText,Text);
  276.   (*Blaze) << ' ';
  277. }
  278.  
  279. //-------------------------------------------------------------------------
  280. //
  281. // Displays a push button element
  282. //
  283. //-------------------------------------------------------------------------
  284.  
  285. void Push::DrawFigure()
  286. {
  287.   (*Blaze) (X,Y)
  288.     << Colors.ButtonNormal
  289.     << ' ';
  290.  
  291.   Blaze->QuickDisplay(X+1,Y,Colors.ButtonBold,Colors.ButtonNormal,Text);
  292.  
  293.   (*Blaze)
  294.     << Colors.ButtonNormal
  295.     << ' '
  296.     << Colors.DiaInterior
  297.     << '\xdc';
  298.  
  299.   Blaze->CharacterRepeater(X+1,Y+1,Width,Colors.DiaInterior,223);
  300. }
  301.  
  302. //-------------------------------------------------------------------------
  303. //
  304. // Displays a group heading (not an element)
  305. //
  306. //-------------------------------------------------------------------------
  307.  
  308. void GroupHeading::DrawFigure()
  309. {
  310.   Blaze->QuickDisplay(X,Y,
  311.     Colors.DiaHeadingQuickKey,Colors.DiaHeading,Text);
  312. }
  313.  
  314. //-------------------------------------------------------------------------
  315. //
  316. // Displays a horizontal radio element
  317. //
  318. //-------------------------------------------------------------------------
  319.  
  320. void HRadio::DrawFigure()
  321. {
  322.   (*Blaze) (X,Y) << Color << ' ';
  323.  
  324.   for (int i=0;i<10;i++)
  325.   {
  326.     if (!*(Elements[i]+0))
  327.       break;
  328.  
  329.     (*Blaze) << "( ) " << Elements[i] << ' ';
  330.   }
  331.  
  332.   Prompt;
  333. }
  334.  
  335. //-------------------------------------------------------------------------
  336. //
  337. // Displays a vertical radio element
  338. //
  339. //-------------------------------------------------------------------------
  340.  
  341. void VRadio::DrawFigure()
  342. {
  343.   Blaze->EraseArea(X,Y,Width,Height,Color);
  344.   (*Blaze) << Color;
  345.  
  346.  
  347.   for (int i=0;i<10;i++)
  348.   {
  349.     if (!*(Elements[i]+0))
  350.       break;
  351.  
  352.     (*Blaze) (X+1,Y+i) << "( ) " << Elements[i];
  353.   }
  354.  
  355.   Prompt;
  356. }
  357.  
  358. //-------------------------------------------------------------------------
  359. //
  360. // Displays a pick list element
  361. //
  362. //-------------------------------------------------------------------------
  363.  
  364. void PickGeneric::DrawFigure()
  365. {
  366.   Blaze->EraseArea(X,Y,Width,Height,Color);
  367.   Blaze->CharacterRepeaterDown(X+Width-1,Y,Height,Colors.PickButton,177);
  368.   (*Blaze) (X+Width-1,Y) << Colors.PickButton << '\x1e';
  369.   (*Blaze) (X+Width-1,Y+Height-1) << '\x1f';
  370.   Prompt;
  371. }
  372.  
  373.