Inherits From:
NSObject
NSObject (NSObject)
Declared In:
AppKit/NSPageLayout.h
runPageLayout:
message is sent to the NSApplication object. By default, this message is sent up the responder chain when the user chooses the Page Setup menu item (on Mach platforms the menu item is called Page Layout).
Typically, you access an NSPageLayout panel by invoking the pageLayout
method. When the class receives a pageLayout
message, it returns an existing panel rather than create a new one. If a panel is reused, its attributes are reset to the default values so that the effect is the same as receiving a new panel. Because the NSPageLayout object returned by pageLayout
may be reused, you should only modify it using methods explicitly declared by NSPageLayout. If you must modify an NSPageLayout object in other ways, don't modify the object returned by pageLayout
; instead, create and manage your own instance using the alloc...
and init...
methods.
In most cases it is unnecessary to subclass NSPageLayout-you can customize an NSPageLayout by specifying your own accessory view. You can add your own controls to an NSPageLayout through the setAccessoryView:
method. The panel is automatically resized to accommodate the NSView that you've added. Note that NSPageLayout does not have accessor methods to obtain the state of its controls. If controls you add through an accessory view need to know the values of existing controls (or vice versa) use the viewWithTag:
method. You obtain a specific control object by sending viewWithTag:
to the NSPageLayout object passing one of the following tags (enumerated in AppKit/NSPageLayout.h):
NSPLImageButton
NSPLTitleField
NSPLPaperNameButton
NSPLUnitsButton
NSPLWidthForm
NSPLHeightForm
NSPLOrientationMatrix
NSPLCancelButton
NSPLOKButton
The value can then be obtained by sending an appropriate accessor message to the returned control object.
pageLayout
Returns a shared NSPageLayout object or a newly created one if it doesn't already exist.
accessoryView
Returns the receiver's accessory view (used to customize the receiver).
See also:
- setAccessoryView:
convertOldFactor:
(float *)old newFactor:
(float *)new
This method is for Mach platforms only-it is not defined for other platforms. The standard unit used to measure a paper's dimensions is a point (for example, NSPrintInfo defines a paper's size in points). However, the user can select a different unit of measurement from the NSPageLayout panel. Use this method to get the ratio between a point and the currently selected unit of measurement. Unless this method is invoked by pickedUnits:
both old and new will be set to the same ratio value.
The pickedUnits:
method is invoked when the user selects a new unit of measurement from the NSPageLayout panel. Subclasses should override the pickedUnits:
method to update any controls, located on the accessory view, that display dimensional values. Use this method to get the old and new ratios. See pickedUnits:
for details.
pickedButton:
(id)sender
This method is for Mach platforms only-it is not defined for other platforms. Invoked when either the OK or Cancel buttons are clicked, and stops the receiver's modal loop. If the OK button was clicked, this method verifies that the height, width and scale entries are acceptable (they must hold positive numbers). If not, the unacceptable entry is selected and the panel isn't stopped. Subclasses should override this method to verify that the controls on the accessory view contain acceptable values.
See also:
- pickedOrientation:
, - pickedPaperSize:
, - pickedUnits:
pickedOrientation:
(id)sender
This method is for Mach platforms only-it is not defined for other platforms. Invoked when the user selects a page orientation (i.e., portrait or landscape). This method updates the height and width fields, and redraws the paper view.
See also:
- pickedButton:
, - pickedPaperSize:
, - pickedUnits:
pickedPaperSize:
(id)sender
This method is for Mach platforms only-it is not defined for other platforms. Invoked when the user selects a paper size from the paper size list. Updates the height and width fields, redraws the paper view, and may switch the portrait/landscape orientation.
See also:
- pickedButton:
, - pickedOrientation:
, - pickedUnits:
pickedUnits:
(id)sender
This method is for Mach platforms only-it is not defined for other platforms. Invoked when the user selects a new unit of measurement from the Units list. The height and width fields are updated.
Subclasses should override this method to update controls in the accessory view that contain unit values. The ratios returned by the convertOldFactor:newFactor:
method should be used to calculate the new values as shown below, where myField
is an NSTextField located on the accessory view that needs to be updated:
- pickedUnitsLsender
{
float old, new;
/* At this point the units have been selected but not set. */
[self convertOldFactor:&old newFactor:&new];
/* Update myField based on the conversion factors. */
[myField setFloatValue:([myField floatValue]*new/old)];
/* Set the selected units. */
return [super pickedUnits:sender];
}
See also:
- pickedButton:
, - pickedOrientation:
, - pickedPaperSize:
printInfo
Returns the NSPrintInfo object that is used when the receiver is run (set using the runModal
or runModalWithPrintInfo:
methods).
See also:
- readPrintInfo
, - writePrintInfo
readPrintInfo
Sets the receiver's values to those stored in the NSPrintInfo object used when the receiver is run.
See also:
- printInfo
, - writePrintInfo
, - runModal
, - runModalWithPrintInfo:
runModal
Displays the receiver and begins the modal loop. The receiver's values are recorded in the shared NSPrintInfo object. Returns NSCancelButton if the user clicks the Cancel button, otherwise returns NSOKButton.
See also:
- pickedButton:
, - runModalWithPrintInfo:
runModalWithPrintInfo:
(NSPrintInfo *)printInfo
Displays the receiver and begins the modal loop. The receiver's values are recorded in printInfo. Returns NSCancelButton if the user clicks the Cancel button, otherwise returns NSOKButton.
See also:
- pickedButton:
, - runModal
setAccessoryView:
(NSView *)aView
Adds an NSView to the receiver. Invoke this method to add a custom view containing your controls. The receiver is automatically resized to accommodate aView. This method can be invoked repeatedly to change the accessory view depending on the situation. If aView is nil
, then the receiver's current accessory view, if any, is removed.
See also:
- accessoryView
writePrintInfo
Writes the receiver's values to the NSPrintInfo object used when the receiver is run.
See also:
- printInfo
, - readPrintInfo
, - runModal
, - runModalWithPrintInfo: