2001-10-16 02:09:09 +00:00
|
|
|
/** <title>NSPageLayout</title>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
<abstract>Standard panel for querying user about page layout.</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
Copyright <copy>(C) 2001 Free Software Foundation, Inc.</copy>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
Written By: <author name="Adam Fedor"><email>fedor@gnu.org</email></author>
|
|
|
|
Date: Oct 2001
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2001-10-16 02:09:09 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
2000-10-16 22:52:59 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
2000-11-21 19:22:45 +00:00
|
|
|
#include <AppKit/NSFont.h>
|
2000-10-16 22:52:59 +00:00
|
|
|
#include <AppKit/NSTextField.h>
|
2000-11-21 19:22:45 +00:00
|
|
|
#include <AppKit/NSImage.h>
|
|
|
|
#include <AppKit/NSImageView.h>
|
|
|
|
#include <AppKit/NSBox.h>
|
2000-10-16 22:52:59 +00:00
|
|
|
#include <AppKit/NSButton.h>
|
2000-11-21 19:22:45 +00:00
|
|
|
#include <AppKit/NSComboBox.h>
|
2001-09-23 22:08:49 +00:00
|
|
|
#include <AppKit/NSPopUpButton.h>
|
2000-11-21 19:22:45 +00:00
|
|
|
#include <AppKit/NSMatrix.h>
|
2001-10-16 02:09:09 +00:00
|
|
|
#include <AppKit/NSNibLoading.h>
|
2000-11-21 19:22:45 +00:00
|
|
|
#include <AppKit/NSForm.h>
|
|
|
|
#include <AppKit/NSFormCell.h>
|
2000-10-16 22:52:59 +00:00
|
|
|
#include <AppKit/NSPrintInfo.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSPageLayout.h>
|
2001-10-16 02:09:09 +00:00
|
|
|
#include <AppKit/NSPrinter.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 03:20:01 +00:00
|
|
|
static NSPageLayout *shared_instance;
|
2000-10-16 22:52:59 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
#define GSPANELNAME @"GSPageLayout"
|
|
|
|
|
|
|
|
#define CONTROL(panel, name) [[panel contentView] viewWithTag: name]
|
|
|
|
|
2001-10-16 02:11:30 +00:00
|
|
|
/**
|
2001-10-16 02:09:09 +00:00
|
|
|
<unit>
|
|
|
|
<heading>NSPageLayout</heading>
|
|
|
|
<p>
|
|
|
|
NSPageLayout provides a panel that allows the user to specify certain
|
|
|
|
information about the printer and how data is formatted for printing.
|
|
|
|
This includes information about the paper size and orientation.
|
|
|
|
|
|
|
|
Typically you would create a page layout panel with the
|
|
|
|
<ref id="pageLayout">pageLayout</ref> class method. However, the best
|
|
|
|
way to use the panel is to have the application
|
|
|
|
call the runPageLayout: method in the NSApplication object
|
|
|
|
which would both create a standard NSPageLayout panel and display it
|
|
|
|
in a modal loop. This method would be sent up the responder chain if
|
|
|
|
the user clicked on a Page Layout menu item.
|
|
|
|
</p>
|
|
|
|
</unit>
|
2001-10-16 02:11:30 +00:00
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
@implementation NSPageLayout
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Creates and returns a shared instance of the NSPageLayout panel.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
+ (NSPageLayout *)pageLayout
|
|
|
|
{
|
2000-10-16 22:52:59 +00:00
|
|
|
if (shared_instance == nil)
|
|
|
|
{
|
|
|
|
shared_instance = [[NSPageLayout alloc] init];
|
|
|
|
}
|
|
|
|
return shared_instance;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
2001-10-16 02:09:09 +00:00
|
|
|
- (NSArray*) _units
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"pts", @"mm", @"cm", @"in", nil];
|
|
|
|
}
|
|
|
|
|
2000-10-16 22:52:59 +00:00
|
|
|
- (id) init
|
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
int style = NSTitledWindowMask;
|
|
|
|
NSRect frame = NSMakeRect(300, 300, 350, 320);
|
|
|
|
return [self initWithContentRect: frame
|
|
|
|
styleMask: style
|
|
|
|
backing: NSBackingStoreBuffered
|
|
|
|
defer: YES];
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
- (id) initWithContentRect: (NSRect)contentRect
|
|
|
|
styleMask: (unsigned int)aStyle
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
defer: (BOOL)flag
|
|
|
|
screen: (NSScreen*)aScreen
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
int i;
|
|
|
|
id control;
|
|
|
|
NSForm *sizeForm;
|
|
|
|
NSArray *subviews, *list;
|
|
|
|
NSString *panel;
|
|
|
|
NSDictionary *table;
|
|
|
|
|
|
|
|
self = [super initWithContentRect: contentRect
|
|
|
|
styleMask: aStyle
|
|
|
|
backing: bufferingType
|
|
|
|
defer: flag
|
|
|
|
screen: aScreen];
|
|
|
|
if (self == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
panel = [NSBundle pathForGNUstepResource: GSPANELNAME ofType: @"gorm"
|
|
|
|
inDirectory: nil];
|
|
|
|
if (panel == nil)
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(@"Error", @"Could not find page layout resource",
|
|
|
|
@"OK", NULL, NULL);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
table = [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"];
|
|
|
|
if ([NSBundle loadNibFile: panel
|
|
|
|
externalNameTable: table
|
|
|
|
withZone: [self zone]] == NO)
|
|
|
|
{
|
|
|
|
NSRunAlertPanel(@"Error", @"Could not load page layout resource",
|
|
|
|
@"OK", NULL, NULL);
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Transfer the objects to us. FIXME: There must be a way to
|
|
|
|
instantiate the panel directly */
|
|
|
|
subviews = [[_panel contentView] subviews];
|
|
|
|
for (i = 0; i < [subviews count]; i++)
|
|
|
|
{
|
|
|
|
[_contentView addSubview: [subviews objectAtIndex: i]];
|
|
|
|
}
|
|
|
|
DESTROY(_panel);
|
|
|
|
/* FIXME: Can't do this in Gorm yet: */
|
|
|
|
sizeForm = CONTROL(self, NSPLWidthForm);
|
|
|
|
[[sizeForm cellAtIndex: 0] setEditable: NO];
|
|
|
|
[[sizeForm cellAtIndex: 1] setEditable: NO];
|
|
|
|
[[sizeForm cellAtIndex: 0] setSelectable: NO];
|
|
|
|
[[sizeForm cellAtIndex: 1] setSelectable: NO];
|
|
|
|
control = CONTROL(self, NSPLOKButton);
|
|
|
|
[self setDefaultButtonCell: [control cell]];
|
|
|
|
|
|
|
|
/* Set up units popup */
|
|
|
|
control = CONTROL(self, NSPLUnitsButton);
|
|
|
|
list = [self _units];
|
|
|
|
[control removeAllItems];
|
|
|
|
for (i = 0; i < [list count]; i++)
|
|
|
|
{
|
|
|
|
[control addItemWithTitle: [list objectAtIndex: i]];
|
|
|
|
}
|
|
|
|
[control selectItemAtIndex: 0];
|
|
|
|
return self;
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Running the Panel
|
|
|
|
//
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Display the Page Layout panel in a modal loop. Saves any aquired
|
|
|
|
information in the shared NSPrintInfo object. Returns NSCancelButton
|
|
|
|
if the user clicks the Cancel button or NSOKButton otherwise.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (int)runModal
|
|
|
|
{
|
2000-10-16 22:52:59 +00:00
|
|
|
return [self runModalWithPrintInfo: [NSPrintInfo sharedPrintInfo]];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Display the Page Layout panel in a modal loop. Saves any aquired
|
|
|
|
information in the indicated NSPrintInfo object. Returns NSCancelButton
|
|
|
|
if the user clicks the Cancel button or NSOKButton otherwise.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (int)runModalWithPrintInfo:(NSPrintInfo *)pInfo
|
|
|
|
{
|
2001-09-23 22:08:49 +00:00
|
|
|
int result;
|
|
|
|
|
2000-10-16 22:52:59 +00:00
|
|
|
_printInfo = pInfo;
|
|
|
|
[self readPrintInfo];
|
|
|
|
|
2001-09-23 22:08:49 +00:00
|
|
|
result = [NSApp runModalForWindow: self];
|
2000-10-16 22:52:59 +00:00
|
|
|
[self orderOut: self];
|
2001-10-16 02:09:09 +00:00
|
|
|
NSLog(@"Model Page Layout ended with code %d", result);
|
2001-09-23 22:08:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)beginSheetWithPrintInfo:(NSPrintInfo *)printInfo
|
|
|
|
modalForWindow:(NSWindow *)docWindow
|
|
|
|
delegate:(id)delegate
|
|
|
|
didEndSelector:(SEL)didEndSelector
|
|
|
|
contextInfo:(void *)contextInfo
|
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
_picked = NSOKButton;
|
2001-09-23 22:08:49 +00:00
|
|
|
_printInfo = printInfo;
|
|
|
|
[self readPrintInfo];
|
|
|
|
|
|
|
|
[NSApp beginSheet: self
|
|
|
|
modalForWindow: docWindow
|
|
|
|
modalDelegate: delegate
|
|
|
|
didEndSelector: didEndSelector
|
|
|
|
contextInfo: contextInfo];
|
|
|
|
|
|
|
|
[self orderOut: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Customizing the Panel
|
|
|
|
//
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Returns the accessory view for the page layout panel
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (NSView *)accessoryView
|
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
return _accessoryView;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Set the accessory view for the page layout panel
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)setAccessoryView:(NSView *)aView
|
2000-11-21 19:22:45 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
ASSIGN(_accessoryView, aView);
|
2000-11-21 19:22:45 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Updating the Panel's Display
|
|
|
|
//
|
2001-10-16 02:09:09 +00:00
|
|
|
- (float) factorForIndex: (int)sel
|
|
|
|
{
|
|
|
|
switch (sel)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: return 1.0;
|
|
|
|
case 1: return 25.4/72;
|
|
|
|
case 2: return 2.54/72;
|
|
|
|
case 3: return 1.0/72;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Convert the old value to a new one based on the current units. This
|
|
|
|
method has been depreciated. It doesn't do anything useful
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)convertOldFactor:(float *)old
|
|
|
|
newFactor:(float *)new
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-09-23 22:08:49 +00:00
|
|
|
NSPopUpButton *pop;
|
|
|
|
int sel;
|
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
if (old == NULL)
|
|
|
|
return;
|
2001-09-23 22:08:49 +00:00
|
|
|
pop = [[self contentView] viewWithTag: NSPLUnitsButton];
|
2001-10-16 02:09:09 +00:00
|
|
|
if (pop == nil)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sel = [pop indexOfSelectedItem];
|
|
|
|
if (new)
|
|
|
|
*new = [self factorForIndex: sel];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Private communication with our panel objects */
|
|
|
|
- (void) _pickedButton: (id)sender
|
|
|
|
{
|
|
|
|
int tag = [sender tag];
|
|
|
|
if (tag == NSPLOKButton)
|
2001-09-23 22:08:49 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
_picked = NSOKButton;
|
|
|
|
[self writePrintInfo];
|
|
|
|
}
|
|
|
|
else if (tag == NSPLCancelButton)
|
|
|
|
{
|
|
|
|
_picked = NSCancelButton;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"NSPageLayout button press from unknown sender %@ tag %d",
|
|
|
|
sender, tag);
|
|
|
|
_picked = NSOKButton;
|
2001-09-23 22:08:49 +00:00
|
|
|
}
|
2001-10-16 02:09:09 +00:00
|
|
|
[NSApp stopModalWithCode: _picked];
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
- (void) _setNewPageSize
|
|
|
|
{
|
|
|
|
NSForm *sizeForm = [[self contentView] viewWithTag: NSPLWidthForm];
|
|
|
|
id control = [[self contentView] viewWithTag: NSPLUnitsButton];
|
|
|
|
double factor = [self factorForIndex: [control indexOfSelectedItem]];
|
|
|
|
[[sizeForm cellAtIndex: 0] setDoubleValue: _size.width * factor];
|
|
|
|
[[sizeForm cellAtIndex: 1] setDoubleValue: _size.height * factor];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _pickedPaper: (id)sender
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSPrinter *printer;
|
|
|
|
int tag = [sender tag];
|
|
|
|
|
|
|
|
printer = [_printInfo printer];
|
|
|
|
|
|
|
|
if (tag == NSPLPaperNameButton)
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
id ocontrol;
|
|
|
|
_size = [printer pageSizeForPaper: [sender titleOfSelectedItem]];
|
|
|
|
ocontrol = [[self contentView] viewWithTag: NSPLOrientationMatrix];
|
|
|
|
if ([ocontrol selectedColumn] > 0)
|
|
|
|
{
|
|
|
|
double temp = _size.width;
|
|
|
|
_size.width = _size.height;
|
|
|
|
_size.height = temp;
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
2001-10-16 02:09:09 +00:00
|
|
|
[self _setNewPageSize];
|
|
|
|
}
|
|
|
|
else if (tag == NSPLUnitsButton)
|
|
|
|
{
|
|
|
|
[self _setNewPageSize];
|
|
|
|
}
|
|
|
|
else if (tag == NSPLOrientationMatrix)
|
|
|
|
{
|
|
|
|
if ([sender selectedColumn] > 0)
|
|
|
|
{
|
|
|
|
double temp = MIN(_size.width, _size.height);
|
|
|
|
_size.width = MAX(_size.width, _size.height);
|
|
|
|
_size.height = temp;
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
2001-10-16 02:09:09 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
double temp = MAX(_size.width, _size.height);
|
|
|
|
_size.width = MIN(_size.width, _size.height);
|
|
|
|
_size.height = temp;
|
|
|
|
}
|
|
|
|
[self _setNewPageSize];
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
2001-10-16 02:09:09 +00:00
|
|
|
else
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSLog(@"NSPageLayout action from unknown sender %@ tag %d",
|
|
|
|
sender, tag);
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** This method has been depreciated. It doesn't do anything useful.
|
|
|
|
*/
|
|
|
|
- (void)pickedButton:(id)sender
|
|
|
|
{
|
|
|
|
NSLog(@"[NSPageLayout -pickedButton:] method depreciated");
|
|
|
|
[self pickedButton: sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
/** This method has been depreciated. It doesn't do anything useful.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)pickedOrientation:(id)sender
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSLog(@"[NSPageLayout -pickedOrientation:] method depreciated");
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** This method has been depreciated. It doesn't do anything useful.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)pickedPaperSize:(id)sender
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSLog(@"[NSPageLayout -pickedPaperSize:] method depreciated");
|
2001-09-23 22:08:49 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** This method has been depreciated. It doesn't do anything useful.
|
|
|
|
*/
|
2001-09-23 22:08:49 +00:00
|
|
|
- (void)pickedLayout:(id)sender
|
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSLog(@"[NSPageLayout -pickedLayout:] method depreciated");
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** This method has been depreciated. It doesn't do anything useful.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)pickedUnits:(id)sender
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSLog(@"[NSPageLayout -pickedUnits:] method depreciated");
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Communicating with the NSPrintInfo Object
|
|
|
|
//
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Return the NSPrintInfo object that the receiver stores layout information
|
|
|
|
into.
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (NSPrintInfo *)printInfo
|
|
|
|
{
|
2000-10-16 22:52:59 +00:00
|
|
|
return _printInfo;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Updates the receiver panel with information from its NSPrintInfo object
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)readPrintInfo
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
id control;
|
|
|
|
NSString *str;
|
|
|
|
NSPrinter *printer;
|
|
|
|
NSDictionary *dict;
|
|
|
|
|
|
|
|
printer = [_printInfo printer];
|
|
|
|
dict = [_printInfo dictionary];
|
|
|
|
|
|
|
|
/* Setup the paper name popup */
|
|
|
|
control = [[self contentView] viewWithTag: NSPLPaperNameButton];
|
|
|
|
[control removeAllItems];
|
|
|
|
str = [_printInfo paperName];
|
|
|
|
if (str)
|
2001-09-23 22:08:49 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
NSArray *list;
|
|
|
|
list = [printer stringListForKey:@"PageSize" inTable: @"PPD"];
|
|
|
|
if ([list count])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < [list count]; i++)
|
|
|
|
{
|
|
|
|
NSString *key = [list objectAtIndex: i];
|
|
|
|
[control addItemWithTitle: key];
|
|
|
|
}
|
|
|
|
[control selectItemWithTitle: str];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[control addItemWithTitle: str];
|
|
|
|
}
|
2001-09-23 22:08:49 +00:00
|
|
|
}
|
2001-10-16 02:09:09 +00:00
|
|
|
else
|
|
|
|
[control addItemWithTitle: @"Unknown"];
|
2001-09-23 22:08:49 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/* Set up units */
|
|
|
|
control = [[self contentView] viewWithTag: NSPLUnitsButton];
|
|
|
|
if ([control numberOfItems] < 2)
|
2001-09-23 22:08:49 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
int i;
|
|
|
|
NSArray *list = [self _units];
|
|
|
|
[control removeAllItems];
|
|
|
|
for (i = 0; i < [list count]; i++)
|
|
|
|
{
|
|
|
|
[control addItemWithTitle: [list objectAtIndex: i]];
|
|
|
|
}
|
|
|
|
[control selectItemAtIndex: 0];
|
2001-09-23 22:08:49 +00:00
|
|
|
}
|
2001-10-16 02:09:09 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We've already been setup */
|
|
|
|
[control selectItemAtIndex: 0];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up size form */
|
|
|
|
_size = [_printInfo paperSize];
|
|
|
|
control = [[self contentView] viewWithTag: NSPLWidthForm];
|
|
|
|
[[control cellAtIndex: 0] setDoubleValue: _size.width];
|
|
|
|
[[control cellAtIndex: 1] setDoubleValue: _size.height];
|
|
|
|
|
|
|
|
/* Set up the orientation */
|
|
|
|
{
|
|
|
|
NSPrintingOrientation orient = [_printInfo orientation];
|
|
|
|
control = [[self contentView] viewWithTag: NSPLOrientationMatrix];
|
|
|
|
[control selectCellAtRow: 0 column: (orient - NSPortraitOrientation)];
|
|
|
|
}
|
2000-10-16 22:52:59 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/** Writes any layout information set by the user to the receiver's
|
|
|
|
NSPrintInfo object
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)writePrintInfo
|
2000-10-16 22:52:59 +00:00
|
|
|
{
|
2001-10-16 02:09:09 +00:00
|
|
|
id control;
|
|
|
|
NSString *str;
|
|
|
|
NSPrinter *printer;
|
2000-10-16 22:52:59 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
printer = [_printInfo printer];
|
2000-10-16 22:52:59 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/* Write Paper Name */
|
|
|
|
control = [[self contentView] viewWithTag: NSPLPaperNameButton];
|
|
|
|
str = [control titleOfSelectedItem];
|
|
|
|
[_printInfo setPaperName: str];
|
2001-09-23 22:08:49 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/* Write Orientation */
|
|
|
|
control = [[self contentView] viewWithTag: NSPLOrientationMatrix];
|
|
|
|
[_printInfo setOrientation: [control selectedColumn]+NSPortraitOrientation];
|
2000-10-16 22:52:59 +00:00
|
|
|
|
2001-10-16 02:09:09 +00:00
|
|
|
/* Write Size */
|
|
|
|
/* FIXME: Currently don't allow writing size. What does that mean
|
|
|
|
anyway? Shouldn't we set margins instead? */
|
2001-09-23 22:08:49 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|