home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / elemmove.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  7.1 KB  |  276 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. #include <string.h>
  18.  
  19. //-------------------------------------------------------------------------
  20. //
  21. // Slide an element to the end of the dialog
  22. //
  23. //-------------------------------------------------------------------------
  24.  
  25. void DialogWindow::ManipToEnd()
  26. {
  27.   if (NumberPieces>1)
  28.   {
  29.     for (int i=NumberPieces-1;i>=0;i--)
  30.     {
  31.       PieceHandler &Piece=*Pieces[i];
  32.  
  33.       int PromptWidth=0;
  34.  
  35.       if (Piece.Prompter && *Piece.Prompter)
  36.       {
  37.         PromptWidth=strlen(Piece.Prompter)-(strchr(Piece.Prompter,'~')?1:0);
  38.       }
  39.  
  40.       if ((CursorX>=Piece.X && CursorY>=Piece.Y &&
  41.           CursorX<Piece.X+Piece.Width && CursorY<Piece.Y+Piece.Height &&
  42.           Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__) ||
  43.           (PromptWidth && CursorX>=Piece.PromptX &&
  44.            CursorY>=Piece.PromptY &&
  45.            CursorX<Piece.PromptX+PromptWidth &&
  46.            CursorY==Piece.PromptY &&
  47.            Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__))
  48.       {
  49.         RemoveTheMenus();
  50.  
  51.         if (i==NumberPieces-1)
  52.            return;
  53.  
  54.         PieceHandler *Hold=Pieces[i];
  55.  
  56.         movmem(&Pieces[i+1],&Pieces[i],(NumberPieces-i-1)*sizeof(PieceHandler *));
  57.  
  58.         Pieces[NumberPieces-1]=Hold;
  59.  
  60.         VirtualizedInterior();
  61.  
  62.         return;
  63.       }
  64.     }
  65.   }
  66.  
  67.   InfoBox NothingFound;
  68.  
  69.   NothingFound
  70.     + "Sorry, there isn\'t an"
  71.     + "element below the cursor that"
  72.     + "can be moved to the end.";
  73.  
  74.   NothingFound.Title("Nothing to End");
  75.   NothingFound.UseInfoBox();
  76. }
  77.  
  78. //-------------------------------------------------------------------------
  79. //
  80. // Slide an element to the start of the dialog
  81. //
  82. //-------------------------------------------------------------------------
  83.  
  84. void DialogWindow::ManipToStart()
  85. {
  86.   if (NumberPieces>1)
  87.   {
  88.     for (int i=NumberPieces-1;i>=0;i--)
  89.     {
  90.       PieceHandler &Piece=*Pieces[i];
  91.  
  92.       int PromptWidth=0;
  93.  
  94.       if (Piece.Prompter && *Piece.Prompter)
  95.       {
  96.         PromptWidth=strlen(Piece.Prompter)-(strchr(Piece.Prompter,'~')?1:0);
  97.       }
  98.  
  99.       if ((CursorX>=Piece.X && CursorY>=Piece.Y &&
  100.           CursorX<Piece.X+Piece.Width && CursorY<Piece.Y+Piece.Height &&
  101.           Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__) ||
  102.           (PromptWidth && CursorX>=Piece.PromptX &&
  103.            CursorY>=Piece.PromptY &&
  104.            CursorX<Piece.PromptX+PromptWidth &&
  105.            CursorY==Piece.PromptY &&
  106.            Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__))
  107.       {
  108.         RemoveTheMenus();
  109.  
  110.         if (!i)
  111.           return;
  112.  
  113.         PieceHandler *Hold=Pieces[i];
  114.  
  115.         movmem(&Pieces[0],&Pieces[1],i*sizeof(PieceHandler *));
  116.  
  117.         Pieces[0]=Hold;
  118.  
  119.         VirtualizedInterior();
  120.  
  121.         return;
  122.       }
  123.     }
  124.   }
  125.  
  126.   InfoBox NothingFound;
  127.  
  128.   NothingFound
  129.     + "Sorry, there isn\'t an"
  130.     + "element below the cursor that"
  131.     + "can be moved to the start.";
  132.  
  133.   NothingFound.Title("Nothing to Start");
  134.   NothingFound.UseInfoBox();
  135. }
  136.  
  137. //-------------------------------------------------------------------------
  138. //
  139. // Slide an element one step closer to the start of the dialog
  140. //
  141. //-------------------------------------------------------------------------
  142.  
  143. void DialogWindow::ManipEarlier()
  144. {
  145.   if (NumberPieces>1)
  146.   {
  147.     for (int i=NumberPieces-1;i>=0;i--)
  148.     {
  149.       PieceHandler &Piece=*Pieces[i];
  150.  
  151.       int PromptWidth=0;
  152.  
  153.       if (Piece.Prompter && *Piece.Prompter)
  154.       {
  155.         PromptWidth=strlen(Piece.Prompter)-(strchr(Piece.Prompter,'~')?1:0);
  156.       }
  157.  
  158.       if ((CursorX>=Piece.X && CursorY>=Piece.Y &&
  159.           CursorX<Piece.X+Piece.Width && CursorY<Piece.Y+Piece.Height &&
  160.           Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__) ||
  161.           (PromptWidth && CursorX>=Piece.PromptX &&
  162.            CursorY>=Piece.PromptY &&
  163.            CursorX<Piece.PromptX+PromptWidth &&
  164.            CursorY==Piece.PromptY &&
  165.            Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__))
  166.       {
  167.         RemoveTheMenus();
  168.  
  169.         if (!i)
  170.           return;
  171.  
  172.         for (int j=i-1;j>=0;j--)
  173.         {
  174.           if (Pieces[j]->LayOut>PieceHandler::__DUMMY__ && Pieces[j]->LayOut<PieceHandler::__DUMMY2__)
  175.           {
  176.             PieceHandler *Hold=Pieces[i];
  177.  
  178.             movmem(&Pieces[i+1],&Pieces[i],(NumberPieces-i-1)*sizeof(PieceHandler *));
  179.  
  180.             movmem(&Pieces[j],&Pieces[j+1],(NumberPieces-j-1)*sizeof(PieceHandler *));
  181.  
  182.             Pieces[j]=Hold;
  183.  
  184.             VirtualizedInterior();
  185.  
  186.             return;
  187.           }
  188.         }
  189.  
  190.         return;
  191.       }
  192.     }
  193.   }
  194.  
  195.   InfoBox NothingFound;
  196.  
  197.   NothingFound
  198.     + "Sorry, there isn\'t an"
  199.     + "element below the cursor that"
  200.     + "can be moved closer to the"
  201.     + "start of the dialog.";
  202.  
  203.   NothingFound.Title("Nothing to Early");
  204.   NothingFound.UseInfoBox();
  205. }
  206.  
  207. //-------------------------------------------------------------------------
  208. //
  209. // Slide an element one step closer to the end of the dialog
  210. //
  211. //-------------------------------------------------------------------------
  212.  
  213. void DialogWindow::ManipLater()
  214. {
  215.   if (NumberPieces>1)
  216.   {
  217.     for (int i=NumberPieces-1;i>=0;i--)
  218.     {
  219.       PieceHandler &Piece=*Pieces[i];
  220.  
  221.       int PromptWidth=0;
  222.  
  223.       if (Piece.Prompter && *Piece.Prompter)
  224.       {
  225.         PromptWidth=strlen(Piece.Prompter)-(strchr(Piece.Prompter,'~')?1:0);
  226.       }
  227.  
  228.       if ((CursorX>=Piece.X && CursorY>=Piece.Y &&
  229.           CursorX<Piece.X+Piece.Width && CursorY<Piece.Y+Piece.Height &&
  230.           Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__) ||
  231.           (PromptWidth && CursorX>=Piece.PromptX &&
  232.            CursorY>=Piece.PromptY &&
  233.            CursorX<Piece.PromptX+PromptWidth &&
  234.            CursorY==Piece.PromptY &&
  235.            Piece.LayOut>PieceHandler::__DUMMY__ && Piece.LayOut<PieceHandler::__DUMMY2__))
  236.       {
  237.         RemoveTheMenus();
  238.  
  239.         if (i==NumberPieces-1)
  240.            return;
  241.  
  242.         for (int j=i+1;j<NumberPieces;j++)
  243.         {
  244.           if (Pieces[j]->LayOut>PieceHandler::__DUMMY__ && Pieces[j]->LayOut<PieceHandler::__DUMMY2__)
  245.           {
  246.             PieceHandler *Hold=Pieces[i];
  247.  
  248.             movmem(&Pieces[i+1],&Pieces[i],(NumberPieces-i-1)*sizeof(PieceHandler *));
  249.  
  250.             movmem(&Pieces[j],&Pieces[j+1],(NumberPieces-j-1)*sizeof(PieceHandler *));
  251.  
  252.             Pieces[j]=Hold;
  253.  
  254.             VirtualizedInterior();
  255.  
  256.             return;
  257.           }
  258.         }
  259.  
  260.         return;
  261.       }
  262.     }
  263.   }
  264.  
  265.   InfoBox NothingFound;
  266.  
  267.   NothingFound
  268.     + "Sorry, there isn\'t an"
  269.     + "element below the cursor that"
  270.     + "can be moved closer to the"
  271.     + "end of the dialog.";
  272.  
  273.   NothingFound.Title("Nothing to Later");
  274.   NothingFound.UseInfoBox();
  275. }
  276.