home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cubbon.zip / SCRNMTHD.TXT < prev    next >
Text File  |  1995-02-10  |  1KB  |  46 lines

  1. sizeAWindow: aWindow
  2.     "Size the argument window proportional to the current
  3.      screen size based on the development screen size.  
  4.  
  5.      This should be executed when #aboutToOpenWidget."
  6.  
  7.     | windowWidth windowHeight ratio |
  8.  
  9. "Ensure argument is a VisualAge window"
  10.  
  11.     (aWindow class inheritsFrom: AbtBasicView)
  12.         ifFalse: [self error: '#sizeAWindow argument is not a visual part.'].
  13.  
  14. "Intialize the class variables if necessary"
  15.     (CurrentScreenWidth isNil)
  16.         ifTrue: [self initialize].
  17.  
  18. "Get the Width and Height of argument window"
  19.     windowWidth := (aWindow primaryWidget width) asFloat.
  20.     windowHeight := (aWindow primaryWidget height) asFloat.
  21.  
  22. "Calculate screen size ratio.  Assumes that the ratio is
  23.  the same for the width and height."
  24.  
  25.     ratio := ((CurrentScreenWidth asFloat) 
  26.             / 
  27.             (DevelopmentSystemScreenWidth asFloat)).
  28.  
  29. "Adjust ratio based on experiments of VGA to XGA 
  30.  and XGA to VGA."
  31.  
  32. "VGA to XGA"
  33.     (ratio = (1024 asFloat / 640 asFloat) )
  34.         ifTrue: [ratio := 1.3].
  35. "XGA to VGA"
  36.     (ratio = (640 asFloat / 1024 asFloat) )
  37.         ifTrue: [ratio := 0.85].
  38.  
  39. "Compute new window size based on the ratio of 
  40.  the current display to the development display"
  41.     windowWidth := (ratio * windowWidth) asInteger.
  42.     windowHeight := (ratio * windowHeight) asInteger.
  43.  
  44. "Set the new window size"
  45.     aWindow primaryWidget width: windowWidth.
  46.     aWindow primaryWidget height: windowHeight.