home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 16 / 16.iso / w / w055 / 4.ddi / SOURCES.LIF / DISPLAY.PEL < prev    next >
Encoding:
Text File  |  1990-09-27  |  3.9 KB  |  168 lines

  1. # $Header:   P:/source/ppee/macros/display.pev   1.21   10 Aug 1990 10:07:40   ericj  $
  2.  
  3. ##############################################################################
  4. #
  5. #           Sage Software - POLYTRON Division
  6. #             1700 NW 167th Place
  7. #               Beaverton, OR 97006
  8. #
  9. #   Copyright 1990, Sage Software, Inc.
  10. #
  11. #   Permission is hereby granted for licensed users of Sage Professional
  12. #   Editor and PolyAwk to copy and modify this source code for their own
  13. #   personal use.  These derivative works may be distributed only to other
  14. #   licensed Sage Professional Editor and PolyAwk users.  All other usage
  15. #   is prohibited without express written permission from Sage Software.
  16. #
  17. ##############################################################################
  18.  
  19. #### $Workfile:   display.pel  $: Initialization and command line processing
  20.  
  21.  
  22.  
  23. #
  24. # a couple of constants representing the current local height and width
  25. #
  26. local    currentHeight = 25;
  27. local    currentWidth  = 80;
  28.  
  29. #
  30. # toggle the current display mode from 25 to 50 or from 50 to 25.
  31. # if mode == 0, set to 25 line mode, otherwise set to 50 lines.
  32. #
  33. global function toggle_display( mode ) {
  34.  
  35.     if( argcount() < 1 ) {
  36.         mode = !(display_height > 25);
  37.     } else {
  38.         mode = !!(0+mode)
  39.     }
  40.  
  41.     currentHeight = display_height;
  42.     currentWidth  = display_width;
  43.  
  44.     if ( !xor( currentHeight == 25, mode) )
  45.         if (mode) {
  46.             display_mode( 50 );
  47.             if (display_height == 25)
  48.                 display_mode( 43 );
  49.             resize_all_windows( currentHeight,\
  50.                 currentWidth,        \
  51.                 display_height,     \
  52.                 display_width);
  53.         } else {
  54.             resize_all_windows( currentHeight,\
  55.                 currentWidth,        \
  56.                 25,             \
  57.                 80);
  58.             display_mode( 25 );
  59.         }
  60.     else
  61.         return;
  62.  
  63.  
  64.     if (help_resident) {
  65.         help_install( 0 );
  66.         help_install( 1 );
  67.     }
  68.  
  69.     if (clock_on) {
  70.         toggle_clock( 0 );
  71.         toggle_clock( 1 );
  72.     }
  73.  
  74. }
  75.  
  76.  
  77. #
  78. # Resize all of the windows to fit on the new screen size.
  79. #
  80. # We will only handle the situation where the screen size is 
  81. # becoming larger.
  82. #
  83. # Only non-system windows are resized
  84. #
  85. global function resize_all_windows(currentHeight,currentWidth,newHeight,newWidth) {
  86.     local    cw = current_window;
  87.     local    sw
  88.     local    lr_x
  89.     local    lr_y
  90.     local    top_y;
  91.     local    top_x;
  92.     local    new_xext
  93.     local    new_yext
  94.     local    vpcnt
  95.     local    hpcnt
  96.  
  97.     sw = next_window("",1);
  98.  
  99.     do {
  100.         #
  101.         # resize it only if it's not the dialog window and
  102.         # not a system window
  103.         #
  104.         if ( (!and( window_flags, WINDOW_SYSTEM) && and(window_flags, WINDOW_ZOOM)) \
  105.             || (current_window == dialog_window)){
  106.  
  107.             top_x = window_x0;
  108.             top_y = window_y0;
  109.             new_xext = window_width;
  110.             new_yext = window_height;
  111.  
  112.             if (currentHeight != newHeight) {
  113.                 if (window_y0 == currentHeight - 1)
  114.                     top_y = newHeight - 1;
  115.                 else if (window_y0 > 1) {
  116.                     vpcnt = (window_y0 * 100) / currentHeight;
  117.                     top_y = (vpcnt * newHeight) / 100;
  118.                 }
  119.  
  120.                 lr_y = window_y0 + window_height;
  121.  
  122.                 if (lr_y == currentHeight) {
  123.                     new_yext = newHeight - top_y;
  124.                 } else if (lr_y == currentHeight - 1) {
  125.                     new_yext = newHeight - 1 - top_y;
  126.                 } else {
  127.                     #
  128.                     # resize the y extent proportionally
  129.                     #
  130.                     vpcnt = (lr_y * 100) / currentHeight;
  131.                     new_yext =  ((vpcnt * newHeight) / 100) - top_y;
  132.                 }
  133.             }
  134.  
  135.             if (currentWidth != newWidth) {
  136.                 if (window_x0 != 0) {
  137.                     hpcnt = (window_x0 * 100) / currentWidth;
  138.                     top_x = (hpcnt * newWidth) / 100;
  139.                 }
  140.  
  141.                 lr_x = window_x0 + window_width;
  142.  
  143.                 if (lr_x == currentWidth) {
  144.                     new_xext = newWidth;
  145.                 } else {
  146.                     #
  147.                     # resize the x extent proportionally
  148.                     #
  149.                     hpcnt = (lr_x * 100) / currentWidth;
  150.                     new_xext =  ((hpcnt * newWidth) / 100) - top_x;
  151.                 }
  152.             }
  153.  
  154.  
  155.             frame_window( top_x, top_y, new_xext, new_yext );
  156.         }
  157.  
  158.         next_window("",1);    # next window, include system ones
  159.  
  160.     } while (sw != current_window);
  161.  
  162.     #
  163.     # restore original window
  164.     #
  165.     if ( cw )
  166.         current_window = cw
  167. }
  168.