home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e002 / 1.ddi / PAGE.CN_ / PAGE.CN
Encoding:
Text File  |  1993-12-09  |  4.1 KB  |  200 lines

  1. menu -plot /* make sure plot window menu */
  2.  
  3. menu 4    
  4. /* Assume Origin's default
  5.  * menu, which has page at the 4th
  6.  * position
  7.  */
  8.  
  9. menu -i 5 (Full Screen) {
  10.     type -b "Double-click to restore the screen.";
  11.     plot -screen;
  12. }
  13. menu -i 5 /* add a space */
  14.  
  15. def CheckMargins {
  16.     CheckVar Top 10;
  17.     CheckVar Left 15;
  18.     CheckVar Right 10;
  19.     CheckVar Bottom 15;
  20.     CheckVar xGap 5;
  21.     CheckVar yGap 5;
  22. }
  23.  
  24. /* ArrangeLayers nRow nCol
  25.  * Assume xGap, yGap, top, left,right,bottm
  26.  */
  27. def ArrangeLayers {
  28. /* use x and y as temperary variables width and height
  29.  * %1 = nRow
  30.  * %2 = nCol
  31.  */
  32.     x = 100 - Left - Right - (%2-1)*xGap;
  33.     x/=%2;
  34.     y = 100 - Top - Bottom - (%1-1)*yGap;
  35.     y/=%1;
  36.     
  37.     if(x < 5 || y < 5) {
  38.         ty -b "Resulting layers are too small, operation aborted!";
  39.         break 1;
  40.     };
  41.     for(i = 1; i <= %1; i+=1) {
  42.         for(j = 1; j <= %2; j+=1) {
  43.             layer -s ((i-1)*%2 + j);
  44.  
  45.             layer -u 1;/* make sure unit is 1 which is % of page */
  46.             if(%2==1) { /* one column, put layer 1 at bottom */
  47.                 layer x y [Left+(j-1)*(x + xGap)] [Top+(%1 - i)*(y + yGap)];
  48.             }
  49.             else {
  50.                 layer x y [Left+(j-1)*(x + xGap)] [Top+(i-1)*(y + yGap)];
  51.             };
  52.         }
  53.     };
  54. }
  55.  
  56. menu "Arrange All Layers.." {
  57.     CheckVar nRow 2;
  58.     CheckVar nColumn 1;
  59.     GetNum 
  60. [Number of Rows] nRow
  61. [Number of Columns] nColumn
  62. [Total number of layers];
  63.     doc -CL;
  64.         /* count the number of layers already on the page
  65.          * result is put into count
  66.          */
  67.     n = nRow * nColumn - count;
  68.     if(n > 0) {
  69.         ty -N "Need to create $(n) more layers. Go ahead?";
  70.         
  71.         repeat n {
  72.             layer -n;/* create a new layer */
  73.             plot -L;
  74.             /* plot the layer, this force the layer
  75.              * to finish making itself before
  76.              * the next one is created.
  77.              */
  78.         }
  79.     };
  80.     
  81.     CheckMargins;/* see def above */
  82.     
  83.     GetNum
  84. [Horizontal Gap] xGap
  85. [Vertical Gap] yGap
  86. [Left Margin] Left
  87. [Right Margin] Right
  88. [Top Margin] Top
  89. [Bottom Margin] Bottom
  90. [Spacings in % of Page Dimension];
  91.  
  92.     ArrangeLayers nRow nColumn;
  93.     
  94. }
  95.  
  96.  
  97. menu "&Fit Layer to Page.." {
  98.     type -N Are you sure you want to fit the layer to the whole page?;
  99.     layer 0;
  100. #Maximize the active layer to fit to the page.
  101. }
  102.  
  103.  
  104. menu /* add a separator */
  105.  
  106.  
  107. menu "&Rotate Page" {
  108.     page -O Rotate;/* P = portrait, L = landscape, R = rotate */
  109. #Exchange between landscape and portrait.
  110. }
  111.  
  112. menu "Page &Control.." {
  113.     page;
  114. #Open the page control dialog box
  115. }
  116.  
  117. menu /* add a separator */
  118.  
  119. menu "&Merge All Pages" {
  120.     Window -M;
  121. #Put all layers from other plot windows into %H. Close other windows.
  122. }
  123.  
  124.  
  125. /* we also need to add the file import and export commands to the
  126.  * File menu
  127.  */
  128. menu 1/* the File menu is the 1st one */
  129.  
  130. menu -i 11/* insert separation line */
  131.  
  132. menu -L -i 12 (&Import ASCII)
  133. /* new drop down menu at position 12 */
  134. menu (Single File...) {
  135. ImportAscii;
  136. }
  137.  
  138. menu "Multiple Files.." {
  139.     getfile -m *.dat;
  140.     for(i = 1; i <= count; i+=1) {
  141.         getfile -g i;
  142.         open -w %A;
  143.     }
  144. #Import multiple ACSII files into the active plot %H
  145. }
  146. menu -L
  147. /* end the drop down menu */
  148.  
  149. menu -L -i 13 (&Export Page)
  150. /* new drop down menu at position 13 */
  151.  
  152.  
  153. menu EPS.. {
  154. ty -N 
  155. "Click Yes if you have already selected an EPS 
  156. file on a PostScript printer. If not, choose 
  157. a PostScript printer within Printer Setup. 
  158. Click on Options and set printing to EPS file.
  159. Leave the filename blank and Origin will
  160. prompt for filename.";
  161. print -e;
  162. #Print %H window into an Encapsulated PostScript file.
  163. }
  164.  
  165. menu (Windows Metafile..)    {
  166.     GetSaveName %H *.WMF;
  167.     clipb -C (%H) %A;
  168. }
  169.  
  170. menu (Bitmap (BMP) ...) {
  171.     GetSaveName %H *.BMP;
  172.  
  173.     page -pg width x;
  174.     page -pg height y;
  175.     BMP.Width=nint(prec(0.5+x/5,2));
  176.     BMP.Height=nint(prec(0.5+y/5,2));
  177.         /* we suggest 1/5 of page resolution
  178.          * to conserve space
  179.          */
  180.     CheckVar BMP.BW     0;/* black and white is equal to one */
  181.     
  182.     GetNumber
  183.     [Width (pixels)] BMP.width
  184.     [Height (pixels)] BMP.height
  185.     (Black and White) BMP.BW:2
  186.     (Image Attributes);
  187.     
  188.     if(BMP.BW) {
  189.         save -BS %H %A BMP.width BMP.height Black;
  190.     }
  191.     else {
  192.         save -BS %H %A BMP.width BMP.height;
  193.     };
  194. #Export the %H window into a device independent bitmap file
  195. }
  196.  
  197. menu -L
  198. /* end the drop down menu */
  199.  
  200.