home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / infoserv / www / cern / dev / scott.Z / scott / WWW / NextStep / Implementation / WWWPageLayout.m < prev   
Encoding:
Text File  |  1991-03-19  |  3.2 KB  |  133 lines

  1. /*        Page layout subclass
  2. **        --------------------
  3. **
  4. ** History
  5. **    14 Mar 91    Based on the DrawPageLayout class in the NeXTStep "Draw"
  6. **            example application
  7. **
  8. */
  9. #import "WWWPageLayout.h"
  10. #import <appkit/Application.h>
  11. #import <appkit/Matrix.h>
  12. #import <appkit/PrintInfo.h>
  13.  
  14. @implementation WWWPageLayout
  15. /*
  16.  * PageLayout is overridden so that the user can set the margins of
  17.  * the page.  This is important in a Draw program where the user
  18.  * typically wants to maximize the drawable area on the page.
  19.  *
  20.  * The accessory view is used to add the additional fields, and
  21.  * pickedUnits: is overridden so that the margin is displayed in the
  22.  * currently selected units.  Note that the accessoryView is set
  23.  * in InterfaceBuilder using the outlet mechanism!
  24.  *
  25.  * This can be used as an example of how to override Application Kit panels.
  26.  */
  27.  
  28. - pickedUnits:sender
  29. /*
  30.  * Called when the user selects different units (e.g. cm or inches).
  31.  * Must update the margin fields.
  32.  */
  33. {
  34.     float old, new;
  35.  
  36.     [self convertOldFactor:&old newFactor:&new];
  37.     [leftMargin setFloatValue:new * [leftMargin floatValue] / old];
  38.     [rightMargin setFloatValue:new * [rightMargin floatValue] / old];
  39.     [topMargin setFloatValue:new * [topMargin floatValue] / old];
  40.     [bottomMargin setFloatValue:new * [bottomMargin floatValue] / old];
  41.  
  42.     return [super pickedUnits:sender];
  43. }
  44.  
  45. - readPrintInfo
  46. /*
  47.  * Sets the margin fields from the Application-wide PrintInfo.
  48.  */
  49. {
  50.     id pi;
  51.     float conversion, dummy;
  52.     NXCoord left, right, top, bottom;
  53.  
  54.     [super readPrintInfo];
  55.     pi = [NXApp printInfo];
  56.     [self convertOldFactor:&conversion newFactor:&dummy];
  57.     [pi getMarginLeft:&left right:&right top:&top bottom:&bottom];
  58.     [leftMargin setFloatValue:left * conversion];
  59.     [rightMargin setFloatValue:right * conversion];
  60.     [topMargin setFloatValue:top * conversion];
  61.     [bottomMargin setFloatValue:bottom * conversion];
  62.  
  63.     return self;
  64. }
  65.  
  66. - writePrintInfo
  67. /*
  68.  * Sets the margin values in the Application-wide PrintInfo from
  69.  * the margin fields in the panel.
  70.  */
  71. {
  72.     id pi;
  73.     float conversion, dummy;
  74.  
  75.     [super writePrintInfo];
  76.     pi = [NXApp printInfo];
  77.     [self convertOldFactor:&conversion newFactor:&dummy];
  78.     if (conversion) {
  79.     [pi setMarginLeft:[leftMargin floatValue] / conversion
  80.             right:[rightMargin floatValue] / conversion
  81.               top:[topMargin floatValue] / conversion
  82.            bottom:[bottomMargin floatValue] / conversion];
  83.     }
  84.     if (*[pi paperType])
  85.         NXWriteDefault("WorldWideWeb", "PaperType", [pi paperType]);    /* Save it */
  86.     return self;
  87. }
  88.  
  89. /* NIB outlet setting methods */
  90.  
  91. - setTopBotForm:anObject
  92. {
  93.     [anObject setTarget:ok];
  94.     [anObject setAction:@selector(performClick:)];
  95.     [anObject setNextText:width];
  96.     return self;
  97. }
  98.  
  99. - setSideForm:anObject
  100. {
  101.     [scale setNextText:anObject];
  102.     [anObject setTarget:ok];
  103.     [anObject setAction:@selector(performClick:)];
  104.     return self;
  105. }
  106.  
  107. - setLeftMargin:anObject
  108. {
  109.     leftMargin = anObject;
  110.     return self;
  111. }
  112.  
  113. - setRightMargin:anObject
  114. {
  115.     rightMargin = anObject;
  116.     return self;
  117. }
  118.  
  119. - setTopMargin:anObject
  120. {
  121.     topMargin = anObject;
  122.     return self;
  123. }
  124.  
  125. - setBottomMargin:anObject
  126. {
  127.     bottomMargin = anObject;
  128.     return self;
  129. }
  130.  
  131. @end
  132.  
  133.