home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / c / fli106c / winsize.cpp < prev    next >
C/C++ Source or Header  |  1992-03-11  |  4KB  |  166 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // FusionWindow
  8. //
  9.  
  10. #include "fliwin.h"
  11. #include "colors.h"
  12.  
  13. #ifdef __BCPLUSPLUS__
  14. #pragma hdrstop
  15. #endif
  16.  
  17. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  18. //
  19. // SizeWindow()
  20. //
  21. // Permits keyboard sizing of window
  22. //
  23. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  24.  
  25. void FusionWindow::SizeWindow()
  26. {
  27.   if (!NumberOfWindows)
  28.     return;
  29.  
  30.   BlazeClass::InvisibleCursor();
  31.  
  32.   RemoveAllMenus();
  33.  
  34.   WindowElement &Window=*Windows[0];
  35.  
  36.   if (!Window.SizeIcon)
  37.     return;
  38.  
  39.   char *EntireWindow=
  40.     new char[Blaze.ComputeNeededBytes(Blaze.WhatWidth(),Blaze.WhatHeight())];
  41.   char *ThisWindow=
  42.     new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  43.  
  44.   Blaze.UseMemory(EntireWindow);
  45.   Blaze.CharacterFill(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  46.     Colors.WorkSpace,176);
  47.  
  48.   Windows[0]->WindowZoomed=0;
  49.  
  50.   if (NumberOfWindows>1)
  51.   {
  52.     for (register int i=NumberOfWindows-1;i;i--)
  53.     {
  54.       Windows[i]->Blaze.UseMemory(EntireWindow);
  55.       Windows[i]->ShowWindow();
  56.       Windows[i]->ShowInterior();
  57.       Windows[i]->Blaze.UseVideo();
  58.     }
  59.   }
  60.  
  61.   Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  62.  
  63.   Blaze.HelpLine(0,"Use the keyboard to expand or contract the size of the window");
  64.  
  65.   Window.Blaze.UseMemory(EntireWindow);
  66.   Window.ShowWindow();
  67.   Window.ShowInterior();
  68.   Window.Blaze.UseVideo();
  69.  
  70.   MouseHide();
  71.  
  72.   Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  73.     EntireWindow);
  74.  
  75.   MouseShow();
  76.  
  77.   for (;;)
  78.   {
  79.     int Event=GetEvent();
  80.  
  81.     if (Event==MousedEvent && MouseEvent&MouseLeftButtonPress)
  82.     {
  83.       if ((Window.SizeIcon &&
  84.            MouseVertical==Window.Y+Window.Height-1 &&
  85.            MouseHorizontal==Window.X+Window.Width-1) ||
  86.           (Window.Moveable &&
  87.            MouseVertical==Window.Y &&
  88.            MouseHorizontal>=(Window.X+(Window.CloseIcon*3)+1) &&
  89.            MouseHorizontal<=(Window.X+Window.Width-(Window.ZoomIcon*3)-3)))
  90.       {
  91.         LastShift=500;
  92.         KeyLast=500;
  93.         delete ThisWindow;
  94.         delete EntireWindow;
  95.         Blaze.UseVideo();
  96.         Window.ShowWindow();
  97.         Window.ShowInterior();
  98.         CheckMoveOrSize();
  99.         return;
  100.       }
  101.     }
  102.  
  103.     if (Event==kbCr || Event==kbEsc)
  104.     {
  105.       LastShift=500;
  106.       KeyLast=500;
  107.       delete ThisWindow;
  108.       delete EntireWindow;
  109.       Blaze.UseVideo();
  110.       Window.Cursor();
  111.       Window.EventHandler(SizeEvent);
  112.       return;
  113.     }
  114.  
  115.     if (Event==kbRight || Event==kbLeft || Event==kbUp || Event==kbDown)
  116.     {
  117.       MouseHide();
  118.  
  119.       Blaze.PutArea(Window.X,Window.Y,ThisWindow);
  120.       delete ThisWindow;
  121.  
  122.       int ActionX=0, ActionY=0;
  123.  
  124.       if (Event==kbRight)
  125.         ActionX=1;
  126.       else if (Event==kbLeft)
  127.         ActionX=-1;
  128.       else if (Event==kbUp)
  129.         ActionY=-1;
  130.       else
  131.         ActionY=1;
  132.  
  133.       Window.Width+=ActionX;
  134.       Window.Height+=ActionY;
  135.  
  136.       if (Window.Width<Window.MinimumWidth || Window.Width<13)
  137.         Window.Width=Window.MinimumWidth;
  138.  
  139.       if (Window.Height<Window.MinimumHeight || Window.Height<5)
  140.         Window.Height=Window.MinimumHeight;
  141.  
  142.       if (Window.X+Window.Width>Blaze.WhatWidth())
  143.         Window.Width=Blaze.WhatWidth()-Window.X;
  144.  
  145.       if (Window.Y+Window.Height>Blaze.WhatHeight()-1)
  146.         Window.Height=Blaze.WhatHeight()-Window.Y-1;
  147.  
  148.       ThisWindow=
  149.         new char[Blaze.ComputeNeededBytes(Window.Width,Window.Height)];
  150.       Blaze.GetArea(Window.X,Window.Y,Window.Width,Window.Height,ThisWindow);
  151.       Window.Blaze.UseMemory(EntireWindow);
  152.       Window.ShowWindow();
  153.       Window.ShowInterior();
  154.       Window.Blaze.UseVideo();
  155.  
  156.       MouseHide();
  157.  
  158.       Blaze.BlockCopyVirtualToVisual(0,1,Blaze.WhatWidth(),Blaze.WhatHeight()-2,
  159.         EntireWindow);
  160.  
  161.       MouseShow();
  162.     }
  163.   }
  164. }
  165.  
  166.