mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Rewrite NSPrintPanel and NSPageLayout, prepare for printing improvements
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11155 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e5c1ccc763
commit
22741391dc
21 changed files with 1016 additions and 735 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2001-10-15 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Headers/gnustep/gui/DPSOperators.h: New functions DPSPrintf,
|
||||
DPSWriteData
|
||||
* Headers/gnustep/gui/GSMethodTable.h: Likewise.
|
||||
* Headers/gnustep/gui/NSGraphicsContext.h: Likewise.
|
||||
* Source/NSGraphicsContext.m: Implement.
|
||||
|
||||
* Headers/gnustep/gui/NSPageLayout.h: Change some ivars.
|
||||
* Headers/gnustep/gui/NSPrintOperation.h: Add an ivar.
|
||||
* Headers/gnustep/gui/NSPrintPanel.h: Remove outlets, use tags instead.
|
||||
* Panels/GNUmakefile: Add GSPageLayout gorm files.
|
||||
* Source/NSPageLayout.m: Rewrite (set NSPrintInfo, use gorm files).
|
||||
* Source/NSPrintOperation.m (_print): Start of implementation. Use
|
||||
NSView to add PS headers, etc.
|
||||
* Source/NSPrintPanel.m: Rewrite using tags not outlets. Document.
|
||||
* Documentation/gsdoc/NSPrintPanel.gsdoc: Regenerate
|
||||
* Documentation/gsdoc/NSPageLayout.gsdoc: Likewise.
|
||||
|
||||
* Model/GNUmakefile: Add OBJC_LIB to DEPENDS_UPON line.
|
||||
|
||||
* Source/NSFontPanel.m (init): setBecomesKeyOnlyIfNeeded to YES.
|
||||
|
||||
2001-10-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSPopUpButtonCell.m
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.5//EN" "http://www.gnustep.org/gsdoc-0_6_5.xml">
|
||||
<gsdoc base="NSPageLayout" prev="NSPICTImageRep.html" next="NSPanel.html" up="Gui.html">
|
||||
<!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.6//EN" "http://www.gnustep.org/gsdoc-0_6_6.xml">
|
||||
<gsdoc>
|
||||
<head>
|
||||
<title>NSPageLayout</title>
|
||||
<author name="Richard Frith-Macdonald">
|
||||
<email address="rfm@gnu.org"/>
|
||||
<url url="http://www.gnustep.org/developers/whoiswho.html"/>
|
||||
<author name="Adam Fedor">
|
||||
<email>fedor@gnu.org</email>
|
||||
</author>
|
||||
<version>$Revision$</version>
|
||||
<date>$Date$</date>
|
||||
<abstract>
|
||||
Standard panel for querying user about page layout.
|
||||
</abstract>
|
||||
<copy>(C) 2001 Free Software Foundation, Inc.</copy>
|
||||
</head>
|
||||
<body>
|
||||
<chapter>
|
||||
<heading>NSPageLayout</heading>
|
||||
<class name="NSPageLayout" super="NSObject">
|
||||
<declared>Gui/NSPageLayout.h</declared>
|
||||
<conform>NSObject</conform>
|
||||
<desc>
|
||||
</desc>
|
||||
<heading>
|
||||
Software documentation for the NSPageLayout class
|
||||
</heading>
|
||||
<class name="NSPageLayout" super="NSPanel">
|
||||
<declared>NSPageLayout.h</declared>
|
||||
<desc>
|
||||
</desc>
|
||||
<method type="NSPageLayout*" factory="yes">
|
||||
<sel>pageLayout</sel>
|
||||
<desc>
|
||||
|
@ -28,6 +30,20 @@
|
|||
<desc>
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>beginSheetWithPrintInfo:</sel>
|
||||
<arg type="NSPrintInfo*">printInfo</arg>
|
||||
<sel>modalForWindow:</sel>
|
||||
<arg type="NSWindow*">docWindow</arg>
|
||||
<sel>delegate:</sel>
|
||||
<arg type="id">delegate</arg>
|
||||
<sel>didEndSelector:</sel>
|
||||
<arg type="SEL">didEndSelector</arg>
|
||||
<sel>contextInfo:</sel>
|
||||
<arg type="void*">contextInfo</arg>
|
||||
<desc>
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>convertOldFactor:</sel>
|
||||
<arg type="float*">old</arg>
|
||||
|
@ -77,7 +93,7 @@
|
|||
</method>
|
||||
<method type="int">
|
||||
<sel>runModalWithPrintInfo:</sel>
|
||||
<arg type="NSPrintInfo*">printInfo</arg>
|
||||
<arg type="NSPrintInfo*">pInfo</arg>
|
||||
<desc>
|
||||
</desc>
|
||||
</method>
|
||||
|
|
|
@ -2,44 +2,44 @@
|
|||
<title>NSPageLayout</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href ="NSPICTImageRep.html">[Previous]</a>
|
||||
<a href ="Gui.html">[Up]</a>
|
||||
<a href ="NSPanel.html">[Next]</a>
|
||||
<h1>NSPageLayout</h1>
|
||||
<h3>Authors </h3>
|
||||
<dl>
|
||||
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
|
||||
<dt>Adam Fedor
|
||||
<dd>
|
||||
</dl>
|
||||
<p>Version: $Revision$</p>
|
||||
<p>Date: $Date$</p>
|
||||
<h2><a name ="cont-0">NSPageLayout</a></h2>
|
||||
<blockquote>
|
||||
Standard panel for querying user about page layout.
|
||||
</blockquote>
|
||||
<p>Copyright: (C) 2001 Free Software Foundation, Inc.</p>
|
||||
<h2><a name ="cont-0">
|
||||
Software documentation for the NSPageLayout class
|
||||
</a></h2>
|
||||
<h2><a name ="NSPageLayout">NSPageLayout</a></h2>
|
||||
<p><b>Declared in: </b> Gui/NSPageLayout.h</p>
|
||||
<p><b>Inherits from: </b> NSObject</p>
|
||||
<p><b>Conforms to: </b> NSObject
|
||||
</p>
|
||||
<p><b>Declared in: </b> NSPageLayout.h</p>
|
||||
<p><b>Inherits from: </b> NSPanel</p>
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
<h2>Instance Variables </h2>
|
||||
<ul>
|
||||
</ul>
|
||||
<h2>Methods </h2>
|
||||
<ul>
|
||||
<li><a href ="NSPageLayout.html#method-0">+pageLayout</a>
|
||||
<li><a href ="NSPageLayout.html#method-1">-accessoryView</a>
|
||||
<li><a href ="NSPageLayout.html#method-2">-convertOldFactor:newFactor:</a>
|
||||
<li><a href ="NSPageLayout.html#method-3">-pickedButton:</a>
|
||||
<li><a href ="NSPageLayout.html#method-4">-pickedOrientation:</a>
|
||||
<li><a href ="NSPageLayout.html#method-5">-pickedPaperSize:</a>
|
||||
<li><a href ="NSPageLayout.html#method-6">-pickedUnits:</a>
|
||||
<li><a href ="NSPageLayout.html#method-7">-printInfo</a>
|
||||
<li><a href ="NSPageLayout.html#method-8">-readPrintInfo</a>
|
||||
<li><a href ="NSPageLayout.html#method-9">-runModal</a>
|
||||
<li><a href ="NSPageLayout.html#method-10">-runModalWithPrintInfo:</a>
|
||||
<li><a href ="NSPageLayout.html#method-11">-setAccessoryView:</a>
|
||||
<li><a href ="NSPageLayout.html#method-12">-writePrintInfo</a>
|
||||
<li ><a href ="NSPageLayout.html#method-0">+pageLayout</a>
|
||||
<li ><a href ="NSPageLayout.html#method-1">-accessoryView</a>
|
||||
<li ><a href ="NSPageLayout.html#method-2">-beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-3">-convertOldFactor:newFactor:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-4">-pickedButton:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-5">-pickedOrientation:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-6">-pickedPaperSize:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-7">-pickedUnits:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-8">-printInfo</a>
|
||||
<li ><a href ="NSPageLayout.html#method-9">-readPrintInfo</a>
|
||||
<li ><a href ="NSPageLayout.html#method-10">-runModal</a>
|
||||
<li ><a href ="NSPageLayout.html#method-11">-runModalWithPrintInfo:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-12">-setAccessoryView:</a>
|
||||
<li ><a href ="NSPageLayout.html#method-13">-writePrintInfo</a>
|
||||
</ul>
|
||||
<hr><h2>Class Methods </h2>
|
||||
<h3><a name ="method-0">pageLayout</a></h3>
|
||||
|
@ -53,57 +53,62 @@
|
|||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-2">convertOldFactor:newFactor:</a></h3>
|
||||
<h3><a name ="method-2">beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:</a></h3>
|
||||
- (void) <b>beginSheetWithPrintInfo:</b> (NSPrintInfo*)printInfo <b>modalForWindow:</b> (NSWindow*)docWindow <b>delegate:</b> (id)delegate <b>didEndSelector:</b> (SEL)didEndSelector <b>contextInfo:</b> (void*)contextInfo;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-3">convertOldFactor:newFactor:</a></h3>
|
||||
- (void) <b>convertOldFactor:</b> (float*)old <b>newFactor:</b> (float*)new;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-3">pickedButton:</a></h3>
|
||||
<h3><a name ="method-4">pickedButton:</a></h3>
|
||||
- (void) <b>pickedButton:</b> (id)sender;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-4">pickedOrientation:</a></h3>
|
||||
<h3><a name ="method-5">pickedOrientation:</a></h3>
|
||||
- (void) <b>pickedOrientation:</b> (id)sender;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-5">pickedPaperSize:</a></h3>
|
||||
<h3><a name ="method-6">pickedPaperSize:</a></h3>
|
||||
- (void) <b>pickedPaperSize:</b> (id)sender;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-6">pickedUnits:</a></h3>
|
||||
<h3><a name ="method-7">pickedUnits:</a></h3>
|
||||
- (void) <b>pickedUnits:</b> (id)sender;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-7">printInfo</a></h3>
|
||||
<h3><a name ="method-8">printInfo</a></h3>
|
||||
- (NSPrintInfo*) <b>printInfo</b>;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-8">readPrintInfo</a></h3>
|
||||
<h3><a name ="method-9">readPrintInfo</a></h3>
|
||||
- (void) <b>readPrintInfo</b>;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-9">runModal</a></h3>
|
||||
<h3><a name ="method-10">runModal</a></h3>
|
||||
- (int) <b>runModal</b>;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-10">runModalWithPrintInfo:</a></h3>
|
||||
- (int) <b>runModalWithPrintInfo:</b> (NSPrintInfo*)printInfo;<br>
|
||||
<h3><a name ="method-11">runModalWithPrintInfo:</a></h3>
|
||||
- (int) <b>runModalWithPrintInfo:</b> (NSPrintInfo*)pInfo;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-11">setAccessoryView:</a></h3>
|
||||
<h3><a name ="method-12">setAccessoryView:</a></h3>
|
||||
- (void) <b>setAccessoryView:</b> (NSView*)aView;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-12">writePrintInfo</a></h3>
|
||||
<h3><a name ="method-13">writePrintInfo</a></h3>
|
||||
- (void) <b>writePrintInfo</b>;<br>
|
||||
|
||||
|
||||
|
|
|
@ -1,70 +1,119 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.5//EN" "http://www.gnustep.org/gsdoc-0_6_5.xml">
|
||||
<gsdoc base="NSPrintPanel" prev="NSPrintOperation.html" next="NSPrinter.html" up="Gui.html">
|
||||
<!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 0.6.6//EN" "http://www.gnustep.org/gsdoc-0_6_6.xml">
|
||||
<gsdoc>
|
||||
<head>
|
||||
<title>NSPrintPanel</title>
|
||||
<author name="Richard Frith-Macdonald">
|
||||
<email address="rfm@gnu.org"/>
|
||||
<url url="http://www.gnustep.org/developers/whoiswho.html"/>
|
||||
<author name="Adam Fedor">
|
||||
<email>fedor@gnu.org</email>
|
||||
</author>
|
||||
<version>$Revision$</version>
|
||||
<date>$Date$</date>
|
||||
<abstract>
|
||||
Standard panel for querying user about printing.
|
||||
</abstract>
|
||||
<copy>(C) 2001 Free Software Foundation, Inc.</copy>
|
||||
</head>
|
||||
<body>
|
||||
<chapter>
|
||||
<heading>NSPrintPanel</heading>
|
||||
<heading>Class Description</heading>
|
||||
<p>
|
||||
NSPrintPanel provides a standard print panel
|
||||
allowing the user to specify information about how a
|
||||
document is to be printed, including the page range,
|
||||
number of copies and scale of the document. It also
|
||||
allows the user to save the document to a file or
|
||||
preview it. When a print: message is sent to an NSView
|
||||
or NSWindow, an NSPrintOpertation is created which manages
|
||||
printing of a view. The NSPrintOperation object would
|
||||
by default show a print panel in a modal loop for the user.
|
||||
You can avoid showing the print panel by sending the
|
||||
setShowsPanels: message in the print operation
|
||||
with a <code>NO</code> argument.
|
||||
</p>
|
||||
<class name="NSPrintPanel" super="NSPanel">
|
||||
<declared>Gui/NSPrintPanel.h</declared>
|
||||
<conform>NSObject</conform>
|
||||
<desc>
|
||||
</desc>
|
||||
<declared>NSPrintPanel.h</declared>
|
||||
<desc>
|
||||
</desc>
|
||||
<method type="NSPrintPanel*" factory="yes">
|
||||
<sel>printPanel</sel>
|
||||
<desc>
|
||||
Creates and returns a shared instance of the
|
||||
NSPrintPanel panel.
|
||||
</desc>
|
||||
</method>
|
||||
<method type="NSView*">
|
||||
<sel>accessoryView</sel>
|
||||
<desc>
|
||||
Returns the accessory view for the print panel
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>beginSheetWithPrintInfo:</sel>
|
||||
<arg type="NSPrintInfo*">printInfo</arg>
|
||||
<sel>modalForWindow:</sel>
|
||||
<arg type="NSWindow*">docWindow</arg>
|
||||
<sel>delegate:</sel>
|
||||
<arg type="id">delegate</arg>
|
||||
<sel>didEndSelector:</sel>
|
||||
<arg type="SEL">didEndSelector</arg>
|
||||
<sel>contextInfo:</sel>
|
||||
<arg type="void*">contextInfo</arg>
|
||||
<desc>
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>finalWritePrintInfo</sel>
|
||||
<desc>
|
||||
Saves information set by the user in the receiver's
|
||||
panel in the NSPrintInfo object from the current
|
||||
NSPrintOperation.
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>pickedAllPages:</sel>
|
||||
<arg type="id">sender</arg>
|
||||
<desc>
|
||||
This method has been depreciated. It doesn't do
|
||||
anything useful.
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>pickedButton:</sel>
|
||||
<arg type="id">sender</arg>
|
||||
<desc>
|
||||
This method has been depreciated. It doesn't do
|
||||
anything useful.
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>pickedLayoutList:</sel>
|
||||
<arg type="id">sender</arg>
|
||||
<desc>
|
||||
This method has been depreciated. It doesn't do
|
||||
anything useful.
|
||||
</desc>
|
||||
</method>
|
||||
<method type="int">
|
||||
<sel>runModal</sel>
|
||||
<desc>
|
||||
Display the Print panel in a modal loop. Saves any
|
||||
aquired information in the NSPrintInfo object for
|
||||
the current NSPrintOperation. Returns NSCancelButton if
|
||||
the user clicks the Cancel button or NSOKButton
|
||||
otherwise.
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>setAccessoryView:</sel>
|
||||
<arg type="NSView*">aView</arg>
|
||||
<desc>
|
||||
Set the accessory view for the print panel
|
||||
</desc>
|
||||
</method>
|
||||
<method type="void">
|
||||
<sel>updateFromPrintInfo</sel>
|
||||
<desc>
|
||||
Setup the display in the receiver's panel based on
|
||||
the values stored in the NSPrintInfo object from the
|
||||
current NSPrintOperation.
|
||||
</desc>
|
||||
</method>
|
||||
</class>
|
||||
|
|
|
@ -2,86 +2,125 @@
|
|||
<title>NSPrintPanel</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href ="NSPrintOperation.html">[Previous]</a>
|
||||
<a href ="Gui.html">[Up]</a>
|
||||
<a href ="NSPrinter.html">[Next]</a>
|
||||
<h1>NSPrintPanel</h1>
|
||||
<h3>Authors </h3>
|
||||
<dl>
|
||||
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
|
||||
<dt>Adam Fedor
|
||||
<dd>
|
||||
</dl>
|
||||
<p>Version: $Revision$</p>
|
||||
<p>Date: $Date$</p>
|
||||
<h2><a name ="cont-0">NSPrintPanel</a></h2>
|
||||
<blockquote>
|
||||
Standard panel for querying user about printing.
|
||||
</blockquote>
|
||||
<p>Copyright: (C) 2001 Free Software Foundation, Inc.</p>
|
||||
<h2><a name ="cont-0">Class Description</a></h2>
|
||||
<p>
|
||||
|
||||
NSPrintPanel provides a standard print panel
|
||||
allowing the user to specify information about how a
|
||||
document is to be printed, including the page range,
|
||||
number of copies and scale of the document. It also
|
||||
allows the user to save the document to a file or
|
||||
preview it. When a print: message is sent to an NSView
|
||||
or NSWindow, an NSPrintOpertation is created which manages
|
||||
printing of a view. The NSPrintOperation object would
|
||||
by default show a print panel in a modal loop for the user.
|
||||
You can avoid showing the print panel by sending the
|
||||
setShowsPanels: message in the print operation
|
||||
with a <code>NO</code> argument.
|
||||
</p>
|
||||
<h2><a name ="NSPrintPanel">NSPrintPanel</a></h2>
|
||||
<p><b>Declared in: </b> Gui/NSPrintPanel.h</p>
|
||||
<p><b>Declared in: </b> NSPrintPanel.h</p>
|
||||
<p><b>Inherits from: </b> NSPanel</p>
|
||||
<p><b>Conforms to: </b> NSObject
|
||||
</p>
|
||||
<hr>
|
||||
|
||||
|
||||
|
||||
<h2>Instance Variables </h2>
|
||||
<ul>
|
||||
</ul>
|
||||
<h2>Methods </h2>
|
||||
<ul>
|
||||
<li><a href ="NSPrintPanel.html#method-0">+printPanel</a>
|
||||
<li><a href ="NSPrintPanel.html#method-1">-accessoryView</a>
|
||||
<li><a href ="NSPrintPanel.html#method-2">-finalWritePrintInfo</a>
|
||||
<li><a href ="NSPrintPanel.html#method-3">-pickedAllPages:</a>
|
||||
<li><a href ="NSPrintPanel.html#method-4">-pickedButton:</a>
|
||||
<li><a href ="NSPrintPanel.html#method-5">-pickedLayoutList:</a>
|
||||
<li><a href ="NSPrintPanel.html#method-6">-runModal</a>
|
||||
<li><a href ="NSPrintPanel.html#method-7">-setAccessoryView:</a>
|
||||
<li><a href ="NSPrintPanel.html#method-8">-updateFromPrintInfo</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-0">+printPanel</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-1">-accessoryView</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-2">-beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-3">-finalWritePrintInfo</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-4">-pickedAllPages:</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-5">-pickedButton:</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-6">-pickedLayoutList:</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-7">-runModal</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-8">-setAccessoryView:</a>
|
||||
<li ><a href ="NSPrintPanel.html#method-9">-updateFromPrintInfo</a>
|
||||
</ul>
|
||||
<hr><h2>Class Methods </h2>
|
||||
<h3><a name ="method-0">printPanel</a></h3>
|
||||
+ (NSPrintPanel*) <b>printPanel</b>;<br>
|
||||
|
||||
Creates and returns a shared instance of the
|
||||
NSPrintPanel panel.
|
||||
|
||||
<hr>
|
||||
<hr><h2>Instances Methods </h2>
|
||||
<h3><a name ="method-1">accessoryView</a></h3>
|
||||
- (NSView*) <b>accessoryView</b>;<br>
|
||||
|
||||
Returns the accessory view for the print panel
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-2">finalWritePrintInfo</a></h3>
|
||||
<h3><a name ="method-2">beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:</a></h3>
|
||||
- (void) <b>beginSheetWithPrintInfo:</b> (NSPrintInfo*)printInfo <b>modalForWindow:</b> (NSWindow*)docWindow <b>delegate:</b> (id)delegate <b>didEndSelector:</b> (SEL)didEndSelector <b>contextInfo:</b> (void*)contextInfo;<br>
|
||||
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-3">finalWritePrintInfo</a></h3>
|
||||
- (void) <b>finalWritePrintInfo</b>;<br>
|
||||
|
||||
Saves information set by the user in the receiver's
|
||||
panel in the NSPrintInfo object from the current
|
||||
NSPrintOperation.
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-3">pickedAllPages:</a></h3>
|
||||
<h3><a name ="method-4">pickedAllPages:</a></h3>
|
||||
- (void) <b>pickedAllPages:</b> (id)sender;<br>
|
||||
|
||||
This method has been depreciated. It doesn't do
|
||||
anything useful.
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-4">pickedButton:</a></h3>
|
||||
<h3><a name ="method-5">pickedButton:</a></h3>
|
||||
- (void) <b>pickedButton:</b> (id)sender;<br>
|
||||
|
||||
This method has been depreciated. It doesn't do
|
||||
anything useful.
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-5">pickedLayoutList:</a></h3>
|
||||
<h3><a name ="method-6">pickedLayoutList:</a></h3>
|
||||
- (void) <b>pickedLayoutList:</b> (id)sender;<br>
|
||||
|
||||
This method has been depreciated. It doesn't do
|
||||
anything useful.
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-6">runModal</a></h3>
|
||||
<h3><a name ="method-7">runModal</a></h3>
|
||||
- (int) <b>runModal</b>;<br>
|
||||
|
||||
Display the Print panel in a modal loop. Saves any
|
||||
aquired information in the NSPrintInfo object for
|
||||
the current NSPrintOperation. Returns NSCancelButton if
|
||||
the user clicks the Cancel button or NSOKButton
|
||||
otherwise.
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-7">setAccessoryView:</a></h3>
|
||||
<h3><a name ="method-8">setAccessoryView:</a></h3>
|
||||
- (void) <b>setAccessoryView:</b> (NSView*)aView;<br>
|
||||
|
||||
Set the accessory view for the print panel
|
||||
|
||||
<hr>
|
||||
<h3><a name ="method-8">updateFromPrintInfo</a></h3>
|
||||
<h3><a name ="method-9">updateFromPrintInfo</a></h3>
|
||||
- (void) <b>updateFromPrintInfo</b>;<br>
|
||||
|
||||
Setup the display in the receiver's panel based on
|
||||
the values stored in the NSPrintInfo object from the
|
||||
current NSPrintOperation.
|
||||
|
||||
<hr>
|
||||
</body>
|
||||
|
|
|
@ -974,6 +974,21 @@ static inline void
|
|||
DPScurrentwindowdevice(GSCTXT *ctxt, int win, void **windowptr)
|
||||
__attribute__((unused));
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Client functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static inline void
|
||||
DPSPrintf(GSCTXT *ctxt, char *fmt, ...)
|
||||
__attribute__((unused));
|
||||
|
||||
static inline void
|
||||
DPSWriteData(GSCTXT *ctxt, char *buf, unsigned int count)
|
||||
__attribute__((unused));
|
||||
|
||||
/***************************************************************************/
|
||||
/* Definitions */
|
||||
/***************************************************************************/
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Color operations */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
@ -2600,4 +2615,26 @@ DPScurrentwindowdevice(GSCTXT *ctxt, int win, void **windowptr)
|
|||
(ctxt, @selector(DPScurrentwindowdevice::), win, windowptr);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Client functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static inline void
|
||||
DPSPrintf(GSCTXT *ctxt, char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
(ctxt->methods->DPSPrintf__)
|
||||
(ctxt, @selector(DPSPrintf::), fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static inline void
|
||||
DPSWriteData(GSCTXT *ctxt, char *buf, unsigned int count)
|
||||
{
|
||||
(ctxt->methods->DPSWriteData__)
|
||||
(ctxt, @selector(DPSWriteData::), buf, count);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -532,6 +532,17 @@ typedef struct {
|
|||
void (*DPScurrentwindowdevice__)
|
||||
(NSGraphicsContext*, SEL, int, void **);
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Client functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
void (*DPSPrintf__)
|
||||
(NSGraphicsContext*, SEL, char *, va_list);
|
||||
|
||||
void (*DPSWriteData__)
|
||||
(NSGraphicsContext*, SEL, char *, unsigned int);
|
||||
|
||||
|
||||
/*
|
||||
* Rectangle Drawing Functions
|
||||
*/
|
||||
|
|
|
@ -465,6 +465,12 @@ NSGraphicsContext *GSCurrentContext();
|
|||
- (void) DPScurrentserverdevice: (void **)serverptr;
|
||||
- (void) DPScurrentwindowdevice: (int)win : (void **)windowptr;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Client functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
- (void) DPSPrintf: (char *)fmt : (va_list)args;
|
||||
- (void) DPSWriteData: (char *)buf : (unsigned int)count;
|
||||
|
||||
@end
|
||||
|
||||
/* Common graphics functions */
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/*
|
||||
NSPageLayout.h
|
||||
/** <title>NSPageLayout</title>
|
||||
|
||||
Standard panel for querying user about page layout info
|
||||
<abstract>Standard panel for querying user about page layout.</abstract>
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright <copy>(C) 2001 Free Software Foundation, Inc.</copy>
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Written By: <author name="Adam Fedor"><email>fedor@gnu.org</email></author>
|
||||
Date: Oct 2001
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -46,13 +45,13 @@ enum {
|
|||
NSPLOKButton
|
||||
};
|
||||
|
||||
@interface NSPageLayout : NSPanel <NSCoding>
|
||||
@interface NSPageLayout : NSPanel
|
||||
{
|
||||
// Attributes
|
||||
float _old;
|
||||
NSSize _size;
|
||||
NSPrintInfo *_printInfo;
|
||||
|
||||
NSView *_accessoryView;
|
||||
id _panel;
|
||||
int _picked;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef enum _NSPrintingPageOrder {
|
|||
NSPrintingPageOrder _pageOrder;
|
||||
BOOL _showPanels;
|
||||
BOOL _pathSet;
|
||||
int _currentPage;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
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.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_NSPrintPanel
|
||||
|
@ -35,43 +36,31 @@
|
|||
@class NSPrintInfo;
|
||||
|
||||
enum {
|
||||
NSPPSaveButton = 4,
|
||||
NSPPPreviewButton,
|
||||
NSFaxButton,
|
||||
NSPPTitleField,
|
||||
NSPPImageButton,
|
||||
NSPPNameTitle,
|
||||
NSPPNameField,
|
||||
NSPPNoteTitle,
|
||||
NSPPNoteField,
|
||||
NSPPStatusTitle,
|
||||
NSPPStatusField,
|
||||
NSPPCopiesField,
|
||||
NSPPPageChoiceMatrix,
|
||||
NSPPPageRangeFrom,
|
||||
NSPPPageRangeTo,
|
||||
NSPPScaleField,
|
||||
NSPPOptionsButton,
|
||||
NSPPPaperFeedButton,
|
||||
NSPPLayoutButton
|
||||
NSPPSaveButton = 3,
|
||||
NSPPPreviewButton = 4,
|
||||
NSFaxButton = 5,
|
||||
NSPPTitleField = 20,
|
||||
NSPPImageButton = 21,
|
||||
NSPPNameTitle = 22,
|
||||
NSPPNameField = 23,
|
||||
NSPPNoteTitle = 24,
|
||||
NSPPNoteField = 25,
|
||||
NSPPStatusTitle = 26,
|
||||
NSPPStatusField = 27,
|
||||
NSPPCopiesField = 28,
|
||||
NSPPPageChoiceMatrix = 29,
|
||||
NSPPPageRangeFrom = 30,
|
||||
NSPPPageRangeTo = 31,
|
||||
NSPPScaleField = 32,
|
||||
NSPPOptionsButton = 33,
|
||||
NSPPPaperFeedButton = 34,
|
||||
NSPPLayoutButton = 35,
|
||||
NSPPResolutionButton = 36
|
||||
};
|
||||
|
||||
@interface NSPrintPanel : NSPanel
|
||||
{
|
||||
id _cancelButton;
|
||||
id _copiesField;
|
||||
id _faxButton;
|
||||
id _fromRangeForm;
|
||||
id _pageMatrix;
|
||||
id _paperButton;
|
||||
id _previewButton;
|
||||
id _printButton;
|
||||
id _printForm;
|
||||
id _resButton;
|
||||
id _saveButton;
|
||||
id _toRangeForm;
|
||||
id _panelWindow;
|
||||
|
||||
id _panel;
|
||||
id _accessoryView;
|
||||
id _savePath;
|
||||
int _picked;
|
||||
|
|
|
@ -78,7 +78,7 @@ ADDITIONAL_INCLUDE_DIRS = -I../Headers -I../Headers/gnustep
|
|||
# systems where building a shared library requires to pass to the linker
|
||||
# all the libraries the target library depends upon.
|
||||
ifneq ($(GUI_LIB), nx)
|
||||
libgmodel_LIBRARIES_DEPEND_UPON = -lgnustep-gui $(FND_LIBS)
|
||||
libgmodel_LIBRARIES_DEPEND_UPON = -lgnustep-gui $(FND_LIBS) $(OBJC_LIBS)
|
||||
else
|
||||
libgmodel_LIBRARIES_DEPEND_UPON = $(FND_LIBS)
|
||||
endif
|
||||
|
|
67
Panels/English.lproj/GSPageLayout.classes
Normal file
67
Panels/English.lproj/GSPageLayout.classes
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
NSApplication = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSButton = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSControl = {
|
||||
Actions = (
|
||||
"takeDoubleValueFrom:",
|
||||
"takeFloatValueFrom:",
|
||||
"takeIntValueFrom:",
|
||||
"takeObjectValueFrom:",
|
||||
"takeStringValueFrom:"
|
||||
);
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSView;
|
||||
};
|
||||
NSMenu = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSMenuItem = {
|
||||
Outlets = (
|
||||
target
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
NSPageLayout = {
|
||||
Actions = (
|
||||
"_pickedButton:",
|
||||
"_pickedPaper:"
|
||||
);
|
||||
Outlets = (
|
||||
_panel
|
||||
);
|
||||
Super = NSPanel;
|
||||
};
|
||||
NSPanel = {
|
||||
Super = NSWindow;
|
||||
};
|
||||
NSResponder = {
|
||||
Super = NSObject;
|
||||
};
|
||||
NSSlider = {
|
||||
Super = NSControl;
|
||||
};
|
||||
NSTextField = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSControl;
|
||||
};
|
||||
NSView = {
|
||||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
Super = NSResponder;
|
||||
};
|
||||
}
|
|
@ -31,8 +31,6 @@
|
|||
Super = NSObject;
|
||||
};
|
||||
NSPanel = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
);
|
||||
Super = NSWindow;
|
||||
|
@ -44,19 +42,7 @@
|
|||
"_pickedPrintOp:"
|
||||
);
|
||||
Outlets = (
|
||||
_cancelButton,
|
||||
_copiesField,
|
||||
_faxButton,
|
||||
_fromRangeForm,
|
||||
_pageMatrix,
|
||||
_panelWindow,
|
||||
_paperButton,
|
||||
_previewButton,
|
||||
_printButton,
|
||||
_printForm,
|
||||
_resButton,
|
||||
_saveButton,
|
||||
_toRangeForm
|
||||
_panel
|
||||
);
|
||||
Super = NSPanel;
|
||||
};
|
||||
|
@ -76,6 +62,10 @@
|
|||
Super = NSResponder;
|
||||
};
|
||||
NSWindow = {
|
||||
Actions = (
|
||||
"orderFront:",
|
||||
"orderOut:"
|
||||
);
|
||||
Outlets = (
|
||||
delegate
|
||||
);
|
||||
|
|
|
@ -37,7 +37,7 @@ include ../Version
|
|||
|
||||
LANGUAGES = English
|
||||
|
||||
LOCALIZED_RESOURCE_FILES = GSPrintPanel.gorm
|
||||
LOCALIZED_RESOURCE_FILES = GSPrintPanel.gorm GSPageLayout.gorm
|
||||
|
||||
PANELS = ColorPanel.gmodel SavePanel.gmodel SpellPanel.gmodel
|
||||
|
||||
|
|
|
@ -598,6 +598,7 @@ float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
|||
[self setMinSize: [self frame].size];
|
||||
|
||||
[self setInitialFirstResponder: setButton];
|
||||
[self setBecomesKeyOnlyIfNeeded: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -891,6 +891,14 @@ NSGraphicsContext *GSCurrentContext()
|
|||
methodTable.DPScurrentwindowdevice__ =
|
||||
GET_IMP(@selector(DPScurrentwindowdevice::));
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Client functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
methodTable.DPSPrintf__ =
|
||||
GET_IMP(@selector(DPSPrintf::));
|
||||
methodTable.DPSWriteData__ =
|
||||
GET_IMP(@selector(DPSWriteData::));
|
||||
|
||||
/*
|
||||
* Rectangle Drawing Functions
|
||||
*/
|
||||
|
@ -2489,6 +2497,19 @@ NSGraphicsContext *GSCurrentContext()
|
|||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Client functions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
- (void) DPSPrintf: (char *)fmt : (va_list)args
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) DPSWriteData: (char *)buf : (unsigned int)count
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSGraphicsContext (NSGraphics)
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
/*
|
||||
NSPageLayout.m
|
||||
/** <title>NSPageLayout</title>
|
||||
|
||||
Page setup panel
|
||||
<abstract>Standard panel for querying user about page layout.</abstract>
|
||||
|
||||
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
Copyright <copy>(C) 2001 Free Software Foundation, Inc.</copy>
|
||||
|
||||
Author: Scott Christley <scottc@net-community.com>
|
||||
Date: 1996
|
||||
Author: Fred Kiefer <fredkiefer@gmx.de>
|
||||
Date: November 2000
|
||||
Written By: <author name="Adam Fedor"><email>fedor@gnu.org</email></author>
|
||||
Date: Oct 2001
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -26,6 +23,7 @@
|
|||
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.
|
||||
|
||||
*/
|
||||
|
||||
#include <AppKit/NSApplication.h>
|
||||
|
@ -38,90 +36,163 @@
|
|||
#include <AppKit/NSComboBox.h>
|
||||
#include <AppKit/NSPopUpButton.h>
|
||||
#include <AppKit/NSMatrix.h>
|
||||
#include <AppKit/NSNibLoading.h>
|
||||
#include <AppKit/NSForm.h>
|
||||
#include <AppKit/NSFormCell.h>
|
||||
#include <AppKit/NSPrintInfo.h>
|
||||
#include <AppKit/NSPageLayout.h>
|
||||
#include <AppKit/NSPrinter.h>
|
||||
|
||||
NSPageLayout *shared_instance;
|
||||
|
||||
@interface NSPageLayout (Private)
|
||||
- (id) _initWithoutGModel;
|
||||
- (NSArray*) _units;
|
||||
- (float) factorForIndex: (int)sel;
|
||||
- (NSArray*) _paperSizes;
|
||||
- (NSArray*) _layouts;
|
||||
@end
|
||||
#define GSPANELNAME @"GSPageLayout"
|
||||
|
||||
#define CONTROL(panel, name) [[panel contentView] viewWithTag: name]
|
||||
|
||||
<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>
|
||||
@implementation NSPageLayout
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [NSPageLayout class])
|
||||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Creating an NSPageLayout Instance
|
||||
//
|
||||
/** Creates and returns a shared instance of the NSPageLayout panel.
|
||||
*/
|
||||
+ (NSPageLayout *)pageLayout
|
||||
{
|
||||
if (shared_instance == nil)
|
||||
{
|
||||
shared_instance = [[NSPageLayout alloc] init];
|
||||
}
|
||||
else
|
||||
{
|
||||
[shared_instance _initDefaults];
|
||||
}
|
||||
return shared_instance;
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (id) init
|
||||
- (NSArray*) _units
|
||||
{
|
||||
self = [self _initWithoutGModel];
|
||||
[self _initDefaults];
|
||||
|
||||
return self;
|
||||
return [NSArray arrayWithObjects: @"pts", @"mm", @"cm", @"in", nil];
|
||||
}
|
||||
|
||||
- (void) _initDefaults
|
||||
- (id) init
|
||||
{
|
||||
// use points as the default
|
||||
_old = 1.0;
|
||||
[super _initDefaults];
|
||||
int style = NSTitledWindowMask;
|
||||
NSRect frame = NSMakeRect(300, 300, 350, 320);
|
||||
return [self initWithContentRect: frame
|
||||
styleMask: style
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: YES];
|
||||
}
|
||||
|
||||
- (id) initWithContentRect: (NSRect)contentRect
|
||||
styleMask: (unsigned int)aStyle
|
||||
backing: (NSBackingStoreType)bufferingType
|
||||
defer: (BOOL)flag
|
||||
screen: (NSScreen*)aScreen
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// Running the Panel
|
||||
//
|
||||
/** 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.
|
||||
*/
|
||||
- (int)runModal
|
||||
{
|
||||
return [self runModalWithPrintInfo: [NSPrintInfo sharedPrintInfo]];
|
||||
}
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
- (int)runModalWithPrintInfo:(NSPrintInfo *)pInfo
|
||||
{
|
||||
int result;
|
||||
|
||||
// store the print Info
|
||||
_printInfo = pInfo;
|
||||
|
||||
// read the values of the print info
|
||||
[self readPrintInfo];
|
||||
|
||||
result = [NSApp runModalForWindow: self];
|
||||
[self orderOut: self];
|
||||
|
||||
NSLog(@"Model Page Layout ended with code %d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -131,10 +202,8 @@ NSPageLayout *shared_instance;
|
|||
didEndSelector:(SEL)didEndSelector
|
||||
contextInfo:(void *)contextInfo
|
||||
{
|
||||
// store the print Info
|
||||
_picked = NSOKButton;
|
||||
_printInfo = printInfo;
|
||||
|
||||
// read the values of the print info
|
||||
[self readPrintInfo];
|
||||
|
||||
[NSApp beginSheet: self
|
||||
|
@ -149,412 +218,23 @@ NSPageLayout *shared_instance;
|
|||
//
|
||||
// Customizing the Panel
|
||||
//
|
||||
/** Returns the accessory view for the page layout panel
|
||||
*/
|
||||
- (NSView *)accessoryView
|
||||
{
|
||||
return nil;
|
||||
return _accessoryView;
|
||||
}
|
||||
|
||||
/** Set the accessory view for the page layout panel
|
||||
*/
|
||||
- (void)setAccessoryView:(NSView *)aView
|
||||
{
|
||||
ASSIGN(_accessoryView, aView);
|
||||
}
|
||||
|
||||
//
|
||||
// Updating the Panel's Display
|
||||
//
|
||||
- (void)convertOldFactor:(float *)old
|
||||
newFactor:(float *)new
|
||||
{
|
||||
NSPopUpButton *pop;
|
||||
int sel;
|
||||
|
||||
if (old)
|
||||
*old = _old;
|
||||
|
||||
pop = [[self contentView] viewWithTag: NSPLUnitsButton];
|
||||
if (pop != nil)
|
||||
{
|
||||
sel = [pop indexOfSelectedItem];
|
||||
|
||||
if (new)
|
||||
*new = [self factorForIndex: sel];
|
||||
}
|
||||
else if (new)
|
||||
*new = _old;
|
||||
}
|
||||
|
||||
- (void)pickedButton:(id)sender
|
||||
{
|
||||
if ([sender tag] == NSPLOKButton)
|
||||
{
|
||||
// check the items if the values are positive,
|
||||
// if not select that item and keep on running.
|
||||
NSTextField *field;
|
||||
|
||||
field = [[self contentView] viewWithTag: NSPLWidthForm];
|
||||
if ((field != nil) && ([field floatValue] <= 0.0))
|
||||
{
|
||||
[field selectText: sender];
|
||||
return;
|
||||
}
|
||||
field = [[self contentView] viewWithTag: NSPLHeightForm];
|
||||
if ((field != nil) && ([field floatValue] <= 0.0))
|
||||
{
|
||||
[field selectText: sender];
|
||||
return;
|
||||
}
|
||||
|
||||
// store the values in the print info
|
||||
[self writePrintInfo];
|
||||
|
||||
[NSApp stopModalWithCode: NSOKButton];
|
||||
}
|
||||
if ([sender tag] == NSPLCancelButton)
|
||||
{
|
||||
[NSApp stopModalWithCode: NSCancelButton];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pickedOrientation:(id)sender
|
||||
{
|
||||
NSLog(@"pickedOrientation %@", sender);
|
||||
}
|
||||
|
||||
- (void)pickedPaperSize:(id)sender
|
||||
{
|
||||
NSLog(@"pickedPaperSize %@", sender);
|
||||
}
|
||||
|
||||
- (void)pickedLayout:(id)sender
|
||||
{
|
||||
NSLog(@"pickedLayout %@", sender);
|
||||
}
|
||||
|
||||
- (void)pickedUnits:(id)sender
|
||||
{
|
||||
NSTextField *field;
|
||||
float new, old;
|
||||
|
||||
// At this point the units have been selected but not set.
|
||||
[self convertOldFactor: &old newFactor: &new];
|
||||
|
||||
field = [[self contentView] viewWithTag: NSPLWidthForm];
|
||||
if (field != nil)
|
||||
{
|
||||
// Update field based on the conversion factors.
|
||||
[field setFloatValue:([field floatValue]*new/old)];
|
||||
}
|
||||
|
||||
field = [[self contentView] viewWithTag: NSPLHeightForm];
|
||||
if (field != nil)
|
||||
{
|
||||
// Update field based on the conversion factors.
|
||||
[field setFloatValue:([field floatValue]*new/old)];
|
||||
}
|
||||
|
||||
// Set the selected units.
|
||||
_old = new;
|
||||
}
|
||||
|
||||
//
|
||||
// Communicating with the NSPrintInfo Object
|
||||
//
|
||||
- (NSPrintInfo *)printInfo
|
||||
{
|
||||
return _printInfo;
|
||||
}
|
||||
|
||||
- (void)readPrintInfo
|
||||
{
|
||||
NSTextField *field;
|
||||
NSSize size = [_printInfo paperSize];
|
||||
float new, old;
|
||||
|
||||
// Both values should be the same
|
||||
[self convertOldFactor: &old newFactor: &new];
|
||||
|
||||
field = [[self contentView] viewWithTag: NSPLWidthForm];
|
||||
if (field != nil)
|
||||
{
|
||||
// Update field based on the conversion factors.
|
||||
[field setFloatValue:(size.width/old)];
|
||||
}
|
||||
|
||||
field = [[self contentView] viewWithTag: NSPLHeightForm];
|
||||
if (field != nil)
|
||||
{
|
||||
// Update field based on the conversion factors.
|
||||
[field setFloatValue:(size.height/old)];
|
||||
}
|
||||
|
||||
//[_printInfo paperName];
|
||||
//[_printInfo orientation];
|
||||
}
|
||||
|
||||
- (void)writePrintInfo
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// NSCoding protocol
|
||||
//
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSPageLayout (Private)
|
||||
|
||||
- (id) _initWithoutGModel
|
||||
{
|
||||
NSRect rect = {{100,100}, {300,300}};
|
||||
unsigned int style = NSTitledWindowMask | NSClosableWindowMask;
|
||||
|
||||
self = [super initWithContentRect: rect
|
||||
styleMask: style
|
||||
backing: NSBackingStoreRetained
|
||||
defer: NO
|
||||
screen: nil];
|
||||
if (self != nil)
|
||||
{
|
||||
NSImageView *imageView;
|
||||
NSImage *paper;
|
||||
NSBox *box;
|
||||
NSForm *f;
|
||||
NSFormCell *fc;
|
||||
NSMatrix *o;
|
||||
NSButtonCell *oc;
|
||||
NSButton *okButton;
|
||||
NSButton *cancelButton;
|
||||
NSRect uv = {{0,50}, {300,250}};
|
||||
NSRect lv = {{0,0}, {300,50}};
|
||||
NSRect ulv = {{0,0}, {190,250}};
|
||||
NSRect urv = {{190,0}, {110,250}};
|
||||
NSRect pi = {{60,120}, {100,100}};
|
||||
NSRect wf = {{5,70}, {75,30}};
|
||||
NSRect hf = {{90,70}, {75,30}};
|
||||
NSRect pb = {{0,190}, {95,30}};
|
||||
NSRect pc = {{5,5}, {85,20}};
|
||||
NSRect lb = {{0,130}, {95,30}};
|
||||
NSRect lc = {{5,5}, {85,20}};
|
||||
NSRect ub = {{0,70}, {95,30}};
|
||||
NSRect uc = {{5,5}, {85,20}};
|
||||
NSRect sb = {{0,10}, {95,35}};
|
||||
NSRect tf = {{5,5}, {75,20}};
|
||||
NSRect mo = {{60,10}, {90,40}};
|
||||
NSRect rb = {{126,8}, {72,24}};
|
||||
NSRect db = {{217,8}, {72,24}};
|
||||
NSView *content;
|
||||
NSView *upper;
|
||||
NSView *lower;
|
||||
NSView *left;
|
||||
NSView *right;
|
||||
NSPopUpButton *pop;
|
||||
NSTextField *text;
|
||||
|
||||
[self setTitle: @"Page Layout"];
|
||||
|
||||
content = [self contentView];
|
||||
// Spilt up in upper and lower
|
||||
upper = [[NSView alloc] initWithFrame: uv];
|
||||
[content addSubview: upper];
|
||||
RELEASE(upper);
|
||||
lower = [[NSView alloc] initWithFrame: lv];
|
||||
[content addSubview: lower];
|
||||
RELEASE(lower);
|
||||
// Solit upper in left and right
|
||||
left = [[NSView alloc] initWithFrame: ulv];
|
||||
[upper addSubview: left];
|
||||
RELEASE(left);
|
||||
right = [[NSView alloc] initWithFrame: urv];
|
||||
[upper addSubview: right];
|
||||
RELEASE(right);
|
||||
|
||||
// FIXME: image of the paper size
|
||||
paper = nil;
|
||||
imageView = [[NSImageView alloc] initWithFrame: pi];
|
||||
[imageView setImage: paper];
|
||||
[imageView setImageScaling: NSScaleNone];
|
||||
[imageView setEditable: NO];
|
||||
[imageView setTag: NSPLImageButton];
|
||||
[left addSubview: imageView];
|
||||
RELEASE(imageView);
|
||||
|
||||
// Width
|
||||
f = [[NSForm alloc] initWithFrame: wf];
|
||||
fc = [f addEntry: @"Width:"];
|
||||
[fc setEditable: YES];
|
||||
[fc setSelectable: YES];
|
||||
[f setBordered: NO];
|
||||
[f setBezeled: YES];
|
||||
[f setTitleAlignment: NSRightTextAlignment];
|
||||
[f setTextAlignment: NSLeftTextAlignment];
|
||||
[f setAutosizesCells: YES];
|
||||
[f sizeToFit];
|
||||
[f setEntryWidth: 80.0];
|
||||
[f setTag: NSPLWidthForm];
|
||||
[left addSubview: f];
|
||||
RELEASE(f);
|
||||
|
||||
// Height
|
||||
f = [[NSForm alloc] initWithFrame: hf];
|
||||
fc = [f addEntry: @"Height:"];
|
||||
[fc setEditable: YES];
|
||||
[fc setSelectable: YES];
|
||||
[f setBordered: NO];
|
||||
[f setBezeled: YES];
|
||||
[f setTitleAlignment: NSRightTextAlignment];
|
||||
[f setTextAlignment: NSLeftTextAlignment];
|
||||
[f setAutosizesCells: YES];
|
||||
[f sizeToFit];
|
||||
[f setEntryWidth: 80.0];
|
||||
[f setTag: NSPLHeightForm];
|
||||
[left addSubview: f];
|
||||
RELEASE(f);
|
||||
|
||||
// Paper Size
|
||||
box = [[NSBox alloc] initWithFrame: pb];
|
||||
[box setTitle: @"Paper Size"];
|
||||
[box setTitlePosition: NSAtTop];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[box setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
|
||||
pop = [[NSPopUpButton alloc] initWithFrame: pc pullsDown: NO];
|
||||
[pop setAction: @selector(pickedPaperSize:)];
|
||||
[pop setTarget: self];
|
||||
[pop addItemsWithTitles: [self _paperSizes]];
|
||||
[pop selectItemAtIndex: 0];
|
||||
[pop setTag: NSPLPaperNameButton];
|
||||
[box addSubview: pop];
|
||||
RELEASE(pop);
|
||||
[box sizeToFit];
|
||||
|
||||
[right addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
// Layout
|
||||
box = [[NSBox alloc] initWithFrame: lb];
|
||||
[box setTitle: @"Layout"];
|
||||
[box setTitlePosition: NSAtTop];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[box setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
|
||||
pop = [[NSPopUpButton alloc] initWithFrame: lc pullsDown: NO];
|
||||
[pop setAction: @selector(pickedLayout:)];
|
||||
[pop setTarget: self];
|
||||
[pop addItemsWithTitles: [self _layouts]];
|
||||
[pop selectItemAtIndex: 0];
|
||||
//[pop setTag: NSPLPaperNameButton];
|
||||
[box addSubview: pop];
|
||||
RELEASE(pop);
|
||||
[box sizeToFit];
|
||||
|
||||
[right addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
// Units
|
||||
box = [[NSBox alloc] initWithFrame: ub];
|
||||
[box setTitle: @"Units"];
|
||||
[box setTitlePosition: NSAtTop];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[box setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
|
||||
pop = [[NSPopUpButton alloc] initWithFrame: uc pullsDown: NO];
|
||||
[pop setAction: @selector(pickedUnits:)];
|
||||
[pop setTarget: self];
|
||||
[pop addItemsWithTitles: [self _units]];
|
||||
[pop selectItemAtIndex: 0];
|
||||
[pop setTag: NSPLUnitsButton];
|
||||
[box addSubview: pop];
|
||||
RELEASE(pop);
|
||||
|
||||
[box sizeToFit];
|
||||
|
||||
[right addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
// Scale
|
||||
box = [[NSBox alloc] initWithFrame: sb];
|
||||
[box setTitle: @"Scale"];
|
||||
[box setTitlePosition: NSAtTop];
|
||||
[box setBorderType: NSGrooveBorder];
|
||||
[box setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
|
||||
text = [[NSTextField alloc] initWithFrame: tf];
|
||||
[box addSubview: text];
|
||||
RELEASE(text);
|
||||
|
||||
[box sizeToFit];
|
||||
|
||||
[right addSubview: box];
|
||||
RELEASE(box);
|
||||
|
||||
// orientation
|
||||
o = [[NSMatrix alloc] initWithFrame: mo
|
||||
mode: NSRadioModeMatrix
|
||||
cellClass: [NSButtonCell class]
|
||||
numberOfRows: 1
|
||||
numberOfColumns: 2];
|
||||
[o setCellSize: NSMakeSize(60, 50)];
|
||||
[o setIntercellSpacing: NSMakeSize(5, 5)];
|
||||
oc = (NSButtonCell*)[o cellAtRow: 0 column: 0];
|
||||
[oc setFont: [NSFont systemFontOfSize: 10]];
|
||||
[oc setButtonType: NSOnOffButton];
|
||||
[oc setBordered: YES];
|
||||
[oc setTitle: @"Portrait"];
|
||||
[oc setImagePosition: NSImageAbove];
|
||||
oc = (NSButtonCell*)[o cellAtRow: 0 column: 1];
|
||||
[oc setFont: [NSFont systemFontOfSize: 10]];
|
||||
[oc setButtonType: NSOnOffButton];
|
||||
[oc setBordered: YES];
|
||||
[oc setTitle: @"Landscape"];
|
||||
[oc setImagePosition: NSImageAbove];
|
||||
[o selectCellAtRow: 0 column: 0];
|
||||
[o setAllowsEmptySelection: NO];
|
||||
[o setTag: NSPLOrientationMatrix];
|
||||
[o setAction: @selector(pickedOrientation:)];
|
||||
[o setTarget: self];
|
||||
[left addSubview: o];
|
||||
RELEASE(o);
|
||||
|
||||
// cancle button
|
||||
cancelButton = [[NSButton alloc] initWithFrame: rb];
|
||||
[cancelButton setStringValue: @"Cancel"];
|
||||
[cancelButton setAction: @selector(pickedButton:)];
|
||||
[cancelButton setTarget: self];
|
||||
[cancelButton setTag: NSPLCancelButton];
|
||||
[lower addSubview: cancelButton];
|
||||
RELEASE(cancelButton);
|
||||
|
||||
// OK button
|
||||
okButton = [[NSButton alloc] initWithFrame: db];
|
||||
[okButton setStringValue: @"OK"];
|
||||
[okButton setAction: @selector(pickedButton:)];
|
||||
[okButton setTarget: self];
|
||||
[okButton setTag: NSPLOKButton];
|
||||
[lower addSubview: okButton];
|
||||
// make it the default button
|
||||
[self setDefaultButtonCell: [okButton cell]];
|
||||
RELEASE(okButton);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray*) _units
|
||||
{
|
||||
return [NSArray arrayWithObjects: @"Points", @"Millimeter",
|
||||
@"Centimeter", @"Inches", nil];
|
||||
}
|
||||
|
||||
- (float) factorForIndex: (int)sel
|
||||
{
|
||||
switch (sel)
|
||||
|
@ -567,15 +247,246 @@ NSPageLayout *shared_instance;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSArray*) _paperSizes
|
||||
/** Convert the old value to a new one based on the current units. This
|
||||
method has been depreciated. It doesn't do anything useful
|
||||
*/
|
||||
- (void)convertOldFactor:(float *)old
|
||||
newFactor:(float *)new
|
||||
{
|
||||
return [NSArray arrayWithObjects: @"A2", @"A3", @"A4",
|
||||
@"A5", @"A6", nil];
|
||||
NSPopUpButton *pop;
|
||||
int sel;
|
||||
|
||||
if (old == NULL)
|
||||
return;
|
||||
pop = [[self contentView] viewWithTag: NSPLUnitsButton];
|
||||
if (pop == nil)
|
||||
return;
|
||||
|
||||
sel = [pop indexOfSelectedItem];
|
||||
if (new)
|
||||
*new = [self factorForIndex: sel];
|
||||
}
|
||||
|
||||
- (NSArray*) _layouts
|
||||
/* Private communication with our panel objects */
|
||||
- (void) _pickedButton: (id)sender
|
||||
{
|
||||
return [NSArray arrayWithObjects: @"1 Up", nil];
|
||||
int tag = [sender tag];
|
||||
if (tag == NSPLOKButton)
|
||||
{
|
||||
_picked = NSOKButton;
|
||||
[self writePrintInfo];
|
||||
}
|
||||
else if (tag == NSPLCancelButton)
|
||||
{
|
||||
_picked = NSCancelButton;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"NSPageLayout button press from unknown sender %@ tag %d",
|
||||
sender, tag);
|
||||
_picked = NSOKButton;
|
||||
}
|
||||
[NSApp stopModalWithCode: _picked];
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
NSPrinter *printer;
|
||||
int tag = [sender tag];
|
||||
|
||||
printer = [_printInfo printer];
|
||||
|
||||
if (tag == NSPLPaperNameButton)
|
||||
{
|
||||
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;
|
||||
}
|
||||
[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;
|
||||
}
|
||||
else
|
||||
{
|
||||
double temp = MAX(_size.width, _size.height);
|
||||
_size.width = MIN(_size.width, _size.height);
|
||||
_size.height = temp;
|
||||
}
|
||||
[self _setNewPageSize];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"NSPageLayout action from unknown sender %@ tag %d",
|
||||
sender, tag);
|
||||
}
|
||||
}
|
||||
|
||||
/** 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.
|
||||
*/
|
||||
- (void)pickedOrientation:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPageLayout -pickedOrientation:] method depreciated");
|
||||
}
|
||||
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
*/
|
||||
- (void)pickedPaperSize:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPageLayout -pickedPaperSize:] method depreciated");
|
||||
}
|
||||
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
*/
|
||||
- (void)pickedLayout:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPageLayout -pickedLayout:] method depreciated");
|
||||
}
|
||||
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
*/
|
||||
- (void)pickedUnits:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPageLayout -pickedUnits:] method depreciated");
|
||||
}
|
||||
|
||||
//
|
||||
// Communicating with the NSPrintInfo Object
|
||||
//
|
||||
/** Return the NSPrintInfo object that the receiver stores layout information
|
||||
into.
|
||||
*/
|
||||
- (NSPrintInfo *)printInfo
|
||||
{
|
||||
return _printInfo;
|
||||
}
|
||||
|
||||
/** Updates the receiver panel with information from its NSPrintInfo object
|
||||
*/
|
||||
- (void)readPrintInfo
|
||||
{
|
||||
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)
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
else
|
||||
[control addItemWithTitle: @"Unknown"];
|
||||
|
||||
/* Set up units */
|
||||
control = [[self contentView] viewWithTag: NSPLUnitsButton];
|
||||
if ([control numberOfItems] < 2)
|
||||
{
|
||||
int i;
|
||||
NSArray *list = [self _units];
|
||||
[control removeAllItems];
|
||||
for (i = 0; i < [list count]; i++)
|
||||
{
|
||||
[control addItemWithTitle: [list objectAtIndex: i]];
|
||||
}
|
||||
[control selectItemAtIndex: 0];
|
||||
}
|
||||
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)];
|
||||
}
|
||||
}
|
||||
|
||||
/** Writes any layout information set by the user to the receiver's
|
||||
NSPrintInfo object
|
||||
*/
|
||||
- (void)writePrintInfo
|
||||
{
|
||||
id control;
|
||||
NSString *str;
|
||||
NSPrinter *printer;
|
||||
|
||||
printer = [_printInfo printer];
|
||||
|
||||
/* Write Paper Name */
|
||||
control = [[self contentView] viewWithTag: NSPLPaperNameButton];
|
||||
str = [control titleOfSelectedItem];
|
||||
[_printInfo setPaperName: str];
|
||||
|
||||
/* Write Orientation */
|
||||
control = [[self contentView] viewWithTag: NSPLOrientationMatrix];
|
||||
[_printInfo setOrientation: [control selectedColumn]+NSPortraitOrientation];
|
||||
|
||||
/* Write Size */
|
||||
/* FIXME: Currently don't allow writing size. What does that mean
|
||||
anyway? Shouldn't we set margins instead? */
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -250,6 +250,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
TEST_RELEASE(_context);
|
||||
TEST_RELEASE(_printPanel);
|
||||
TEST_RELEASE(_accessoryView);
|
||||
TEST_RELEASE(_path);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -328,8 +329,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
//
|
||||
- (int)currentPage
|
||||
{
|
||||
// FIXME
|
||||
return 0;
|
||||
return _currentPage;
|
||||
}
|
||||
|
||||
- (NSPrintingPageOrder)pageOrder
|
||||
|
@ -347,6 +347,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
//
|
||||
- (void)cleanUpOperation
|
||||
{
|
||||
_currentPage = 0;
|
||||
[NSPrintOperation setCurrentOperation: nil];
|
||||
}
|
||||
|
||||
|
@ -513,6 +514,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
|
||||
ASSIGN(_path, @"/tmp/NSTempPrintFile");
|
||||
_pathSet = NO;
|
||||
_currentPage = 0;
|
||||
|
||||
[NSPrintOperation setCurrentOperation: self];
|
||||
return self;
|
||||
|
@ -520,6 +522,8 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
|
||||
- (void) _print
|
||||
{
|
||||
BOOL knowsPageRange;
|
||||
NSRange viewPageRange;
|
||||
NSString *clocale;
|
||||
/* Reset the current locale to a generic C locale so numbers
|
||||
get printed correctly for PostScript (maybe we should only
|
||||
|
@ -527,7 +531,15 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
clocale = GSSetLocale(nil);
|
||||
GSSetLocale(@"C");
|
||||
|
||||
/* Print the header information */
|
||||
[_view beginDocument];
|
||||
|
||||
/* Setup pagination */
|
||||
knowsPageRange = [_view knowsPageRange: &viewPageRange];
|
||||
|
||||
[_view beginPageInRect: _rect atPlacement: NSMakePoint(0,0)];
|
||||
[_view displayRectIgnoringOpacity: _rect];
|
||||
[_view endDocument];
|
||||
|
||||
GSSetLocale(clocale);
|
||||
}
|
||||
|
@ -590,13 +602,6 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
|
||||
@implementation GSEPSPrintOperation
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
TEST_RELEASE(_path);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)initEPSOperationWithView:(NSView *)aView
|
||||
insideRect:(NSRect)rect
|
||||
toData:(NSMutableData *)data
|
||||
|
@ -606,7 +611,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
insideRect: rect
|
||||
toData: data
|
||||
printInfo: aPrintInfo];
|
||||
|
||||
_pathSet = YES; /* Use the default temp path */
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -628,15 +633,21 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
return self;
|
||||
}
|
||||
|
||||
- (NSGraphicsContext*)createContext
|
||||
- (void) _print
|
||||
{
|
||||
NSMutableDictionary *info = [_printInfo dictionary];
|
||||
NSGraphicsContext *psContext;
|
||||
NSString *clocale;
|
||||
/* Reset the current locale to a generic C locale so numbers
|
||||
get printed correctly for PostScript (maybe we should only
|
||||
set the numeric locale?). Save the current locale for later. */
|
||||
clocale = GSSetLocale(nil);
|
||||
GSSetLocale(@"C");
|
||||
|
||||
[_view beginDocument];
|
||||
[_view beginPageInRect: _rect atPlacement: NSMakePoint(0,0)];
|
||||
[_view displayRectIgnoringOpacity: _rect];
|
||||
[_view endDocument];
|
||||
|
||||
[info setObject: _path forKey: @"NSOutputFile"];
|
||||
psContext = [NSGraphicsContext postscriptContextWithInfo: info];
|
||||
|
||||
return psContext;
|
||||
GSSetLocale(clocale);
|
||||
}
|
||||
|
||||
- (BOOL)deliverResult
|
||||
|
@ -656,13 +667,6 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
|
||||
@implementation GSPDFPrintOperation
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
TEST_RELEASE(_path);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) initPDFOperationWithView:(NSView *)aView
|
||||
insideRect:(NSRect)rect
|
||||
toData:(NSMutableData *)data
|
||||
|
@ -672,7 +676,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
insideRect: rect
|
||||
toData: data
|
||||
printInfo: aPrintInfo];
|
||||
|
||||
_pathSet = YES; /* Use the default temp path */
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -700,6 +704,20 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void) _print
|
||||
{
|
||||
NSString *clocale;
|
||||
/* Reset the current locale to a generic C locale so numbers
|
||||
get printed correctly for PostScript (maybe we should only
|
||||
set the numeric locale?). Save the current locale for later. */
|
||||
clocale = GSSetLocale(nil);
|
||||
GSSetLocale(@"C");
|
||||
|
||||
[_view displayRectIgnoringOpacity: _rect];
|
||||
|
||||
GSSetLocale(clocale);
|
||||
}
|
||||
|
||||
- (BOOL)deliverResult
|
||||
{
|
||||
if (_data != nil && _path != nil && [_data length])
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/*
|
||||
NSPrintPanel.m
|
||||
/** <title>NSPrintPanel</title>
|
||||
|
||||
Creates a Print panel for the user to select various print options.
|
||||
<abstract>Standard panel for querying user about printing.</abstract>
|
||||
|
||||
Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
Copyright <copy>(C) 2001 Free Software Foundation, Inc.</copy>
|
||||
|
||||
Author: Adam Fedor <fedor@gnu.org>
|
||||
Date: 2001
|
||||
Written By: <author name="Adam Fedor"><email>fedor@gnu.org</email></author>
|
||||
Date: Oct 2001
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -24,7 +23,8 @@
|
|||
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.
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
#include <gnustep/gui/config.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
|
@ -42,41 +42,58 @@
|
|||
#include <AppKit/NSSavePanel.h>
|
||||
#include <AppKit/NSView.h>
|
||||
|
||||
NSPrintPanel *shared_instance;
|
||||
|
||||
#define GSPANELNAME @"GSPrintPanel"
|
||||
|
||||
#define CONTROL(panel, name) [[panel contentView] viewWithTag: name]
|
||||
|
||||
/**
|
||||
<unit>
|
||||
<heading>Class Description</heading>
|
||||
<p>
|
||||
NSPrintPanel provides a standard print panel allowing the user to
|
||||
specify information about how a document is to be printed, including
|
||||
the page range, number of copies and scale of the document. It also
|
||||
allows the user to save the document to a file or preview it.
|
||||
|
||||
When a print: message is sent to an NSView or NSWindow, an
|
||||
NSPrintOpertation is created which manages printing of a view. The
|
||||
NSPrintOperation object would by default show a print panel in a modal
|
||||
loop for the user. You can avoid showing the print panel by sending
|
||||
the setShowsPanels: message in the print operation with a NO argument.
|
||||
</p>
|
||||
</unit>
|
||||
*/
|
||||
@implementation NSPrintPanel
|
||||
|
||||
//
|
||||
// Class methods
|
||||
// Class Methods
|
||||
//
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [NSPrintPanel class])
|
||||
{
|
||||
// Initial version
|
||||
[self setVersion:1];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Creating an NSPrintPanel
|
||||
//
|
||||
/* It seems like this should be a singleton, but the docs say this
|
||||
returns a newly created panel object
|
||||
*/
|
||||
/** Creates and returns a shared instance of the NSPrintPanel panel.
|
||||
*/
|
||||
+ (NSPrintPanel *)printPanel
|
||||
{
|
||||
int style = NSTitledWindowMask | NSClosableWindowMask;
|
||||
NSRect frame = NSMakeRect(300, 300, 420, 350);
|
||||
return [[NSPrintPanel alloc] initWithContentRect: frame
|
||||
styleMask: style
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: YES];
|
||||
if (shared_instance == nil)
|
||||
{
|
||||
shared_instance = [[NSPrintPanel alloc] init];
|
||||
}
|
||||
return shared_instance;
|
||||
}
|
||||
|
||||
//
|
||||
// Instance methods
|
||||
//
|
||||
- (id) init
|
||||
{
|
||||
int style = NSTitledWindowMask;
|
||||
NSRect frame = NSMakeRect(300, 300, 420, 350);
|
||||
return [self initWithContentRect: frame
|
||||
styleMask: style
|
||||
backing: NSBackingStoreBuffered
|
||||
defer: YES];
|
||||
}
|
||||
|
||||
/* Designated initializer */
|
||||
- (id) initWithContentRect: (NSRect)contentRect
|
||||
styleMask: (unsigned int)aStyle
|
||||
|
@ -117,32 +134,29 @@
|
|||
|
||||
/* Transfer the objects to us. FIXME: There must be a way to
|
||||
instantiate the panel directly */
|
||||
subviews = [[_panelWindow contentView] subviews];
|
||||
subviews = [[_panel contentView] subviews];
|
||||
for (i = 0; i < [subviews count]; i++)
|
||||
{
|
||||
[_contentView addSubview: [subviews objectAtIndex: i]];
|
||||
}
|
||||
DESTROY(_panelWindow);
|
||||
/* FIXME: Can't do this in Gorm yet: */
|
||||
[_printForm setBezeled: NO];
|
||||
[_printForm setBordered: NO];
|
||||
[[_printForm cellAtIndex: 0] setEditable: NO];
|
||||
[[_printForm cellAtIndex: 1] setEditable: NO];
|
||||
[[_printForm cellAtIndex: 2] setEditable: NO];
|
||||
[[_printForm cellAtIndex: 0] setSelectable: NO];
|
||||
[[_printForm cellAtIndex: 1] setSelectable: NO];
|
||||
[[_printForm cellAtIndex: 2] setSelectable: NO];
|
||||
DESTROY(_panel);
|
||||
/* Now set _panel to point to our options panel */
|
||||
_panel = RETAIN([CONTROL(self, NSPPOptionsButton) target]);
|
||||
return self;
|
||||
}
|
||||
|
||||
//
|
||||
// Customizing the Panel
|
||||
//
|
||||
/** Set the accessory view for the print panel
|
||||
*/
|
||||
- (void)setAccessoryView:(NSView *)aView
|
||||
{
|
||||
ASSIGN(_accessoryView, aView);
|
||||
}
|
||||
|
||||
/** Returns the accessory view for the print panel
|
||||
*/
|
||||
- (NSView *)accessoryView
|
||||
{
|
||||
return _accessoryView;
|
||||
|
@ -151,10 +165,16 @@
|
|||
//
|
||||
// Running the Panel
|
||||
//
|
||||
/** Display the Print panel in a modal loop. Saves any aquired
|
||||
information in the NSPrintInfo object for the current NSPrintOperation.
|
||||
Returns NSCancelButton if the user clicks the Cancel button or
|
||||
NSOKButton otherwise.
|
||||
*/
|
||||
- (int)runModal
|
||||
{
|
||||
_picked = NSCancelButton;
|
||||
_picked = NSOKButton;
|
||||
[NSApp runModalForWindow: self];
|
||||
[_panel orderOut: self];
|
||||
[self orderOut: self];
|
||||
return (_picked == NSCancelButton) ? NSCancelButton : NSOKButton;
|
||||
}
|
||||
|
@ -165,13 +185,13 @@
|
|||
didEndSelector: (SEL)didEndSelector
|
||||
contextInfo: (void *)contextInfo
|
||||
{
|
||||
_picked = NSCancelButton;
|
||||
// FIXME: We should probably arrange to call endSheet instead of stopModal
|
||||
_picked = NSOKButton;
|
||||
[NSApp beginSheet: self
|
||||
modalForWindow: docWindow
|
||||
modalDelegate: delegate
|
||||
didEndSelector: didEndSelector
|
||||
contextInfo: contextInfo];
|
||||
[_panel orderOut: self];
|
||||
[self orderOut: self];
|
||||
}
|
||||
|
||||
|
@ -206,7 +226,9 @@
|
|||
/* Private communication with our panel objects */
|
||||
- (void) _pickedButton: (id)sender
|
||||
{
|
||||
if (sender == _saveButton)
|
||||
int tag = [sender tag];
|
||||
|
||||
if (tag == NSPPSaveButton)
|
||||
{
|
||||
_picked = NSPPSaveButton;
|
||||
if ([self _getSavePath] == NO)
|
||||
|
@ -216,11 +238,11 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (sender == _previewButton)
|
||||
else if (tag == NSPPPreviewButton)
|
||||
{
|
||||
_picked = NSPPPreviewButton;
|
||||
}
|
||||
else if (sender == _faxButton)
|
||||
else if (tag ==NSFaxButton )
|
||||
{
|
||||
_picked = NSFaxButton;
|
||||
NSRunAlertPanel(@"Warning", @"Fax of print file not implemented",
|
||||
|
@ -228,11 +250,11 @@
|
|||
/* Don't stop the modal session */
|
||||
return;
|
||||
}
|
||||
else if (sender == _cancelButton)
|
||||
else if (tag == NSCancelButton)
|
||||
{
|
||||
_picked = NSCancelButton;
|
||||
}
|
||||
else if (sender == _printButton)
|
||||
else if (tag == NSOKButton)
|
||||
{
|
||||
_picked = NSOKButton;
|
||||
}
|
||||
|
@ -246,39 +268,44 @@
|
|||
|
||||
- (void) _pickedPage: (id)sender
|
||||
{
|
||||
if ([_pageMatrix selectedColumn] == 0)
|
||||
id pageMatrix = CONTROL(self, NSPPPageChoiceMatrix);
|
||||
id fromRangeForm = CONTROL(self, NSPPPageRangeFrom);
|
||||
id toRangeForm = CONTROL(self, NSPPPageRangeTo);
|
||||
|
||||
if ([pageMatrix selectedColumn] == 0)
|
||||
{
|
||||
[[_fromRangeForm cellAtIndex: 0] setStringValue: @"" ];
|
||||
[[_toRangeForm cellAtIndex: 0] setStringValue: @"" ];
|
||||
[[fromRangeForm cellAtIndex: 0] setStringValue: @"" ];
|
||||
[[toRangeForm cellAtIndex: 0] setStringValue: @"" ];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *str;
|
||||
str = [NSString stringWithFormat: @"%d", _pages.location];
|
||||
[[_fromRangeForm cellAtIndex: 0] setStringValue: str];
|
||||
[[fromRangeForm cellAtIndex: 0] setStringValue: str];
|
||||
str = [NSString stringWithFormat: @"%d", NSMaxRange(_pages)];
|
||||
[[_toRangeForm cellAtIndex: 0] setStringValue: str];
|
||||
[[toRangeForm cellAtIndex: 0] setStringValue: str];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _pickedPrintOp: (id)sender
|
||||
{
|
||||
NSLog(@"pick print op from sender %@, title %@", sender, [sender title]);
|
||||
}
|
||||
|
||||
/* Depreciated communication methods */
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
*/
|
||||
- (void)pickedButton:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPrintPanel -pickedButton:] method depreciated");
|
||||
[self pickedButton: sender];
|
||||
}
|
||||
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
*/
|
||||
- (void)pickedAllPages:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPrintPanel -pickedAllPages:] method depreciated");
|
||||
[self _pickedPage: sender];
|
||||
}
|
||||
|
||||
/** This method has been depreciated. It doesn't do anything useful.
|
||||
*/
|
||||
- (void)pickedLayoutList:(id)sender
|
||||
{
|
||||
NSLog(@"[NSPrintPanel -pickedLayoutList:] method depreciated");
|
||||
|
@ -287,22 +314,35 @@
|
|||
//
|
||||
// Communicating with the NSPrintInfo Object
|
||||
//
|
||||
/** Setup the display in the receiver's panel based on the values stored
|
||||
in the NSPrintInfo object from the current NSPrintOperation.
|
||||
*/
|
||||
- (void)updateFromPrintInfo
|
||||
{
|
||||
id control;
|
||||
int layout;
|
||||
double scale;
|
||||
NSString *str;
|
||||
NSPrinter *printer;
|
||||
NSDictionary *dict;
|
||||
NSPrintInfo* info = [[NSPrintOperation currentOperation] printInfo];
|
||||
|
||||
printer = [info printer];
|
||||
[[_printForm cellAtIndex: 0] setStringValue: [printer name] ];
|
||||
[[_printForm cellAtIndex: 1] setStringValue: [printer note] ];
|
||||
[[_printForm cellAtIndex: 2] setStringValue: @"" ];
|
||||
/* Setup printer information */
|
||||
[CONTROL(self, NSPPNameField) setStringValue: [printer name] ];
|
||||
[CONTROL(self, NSPPNoteField) setStringValue: [printer note] ];
|
||||
[CONTROL(self, NSPPStatusField) setStringValue: @"Idle" ];
|
||||
|
||||
/* Setup copies, page range, scale */
|
||||
[CONTROL(self, NSPPCopiesField) setIntValue: 1];
|
||||
[[CONTROL(self, NSPPPageRangeFrom) cellAtIndex: 0] setStringValue: @"" ];
|
||||
[[CONTROL(self, NSPPPageRangeTo) cellAtIndex: 0] setStringValue: @"" ];
|
||||
[CONTROL(self, NSPPPageChoiceMatrix) selectCellAtRow: 0 column: 0];
|
||||
scale = [[dict objectForKey: NSPrintScalingFactor] doubleValue];
|
||||
if (scale == 0)
|
||||
scale = 1;
|
||||
[CONTROL(self, NSPPScaleField) setIntValue: (int)(scale*100)];
|
||||
|
||||
[_copiesField setIntValue: 1];
|
||||
[[_fromRangeForm cellAtIndex: 0] setStringValue: @"" ];
|
||||
[[_toRangeForm cellAtIndex: 0] setStringValue: @"" ];
|
||||
[_pageMatrix selectCellAtRow: 0 column: 0];
|
||||
|
||||
dict = [info dictionary];
|
||||
NSDebugLLog(@"NSPrintPanel",
|
||||
|
@ -312,93 +352,127 @@
|
|||
if (NSMaxRange(_pages) == 0)
|
||||
_pages = NSMakeRange(1, 0);
|
||||
|
||||
/* Setup the layout popup */
|
||||
layout = [[dict objectForKey: NSPrintPagesPerSheet] intValue];
|
||||
if (layout == 0)
|
||||
layout = 1;
|
||||
if (layout > 4)
|
||||
layout = 4;
|
||||
control = CONTROL(self, NSPPLayoutButton);
|
||||
if ([control numberOfItems] < 2)
|
||||
{
|
||||
int i;
|
||||
NSArray *list = [NSArray arrayWithObjects: @"1up", @"2up", @"3up",
|
||||
@"4up", nil];
|
||||
[control removeAllItems];
|
||||
for (i = 0; i < [list count]; i++)
|
||||
{
|
||||
[control addItemWithTitle: [list objectAtIndex: i]];
|
||||
}
|
||||
[control selectItemAtIndex: layout-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We've already been setup */
|
||||
[control selectItemAtIndex: layout-1];
|
||||
}
|
||||
|
||||
/* Setup the resolution popup */
|
||||
[_resButton removeAllItems];
|
||||
control = CONTROL(_panel, NSPPResolutionButton);
|
||||
[control removeAllItems];
|
||||
/* FIXME: Get default from printInfo? */
|
||||
str = [printer stringForKey:@"DefaultResolution" inTable: @"PPD"];
|
||||
if (str)
|
||||
{
|
||||
NSArray *resList;
|
||||
resList = [printer stringListForKey:@"Resolution" inTable: @"PPD"];
|
||||
if ([resList count])
|
||||
NSArray *list;
|
||||
list = [printer stringListForKey:@"Resolution" inTable: @"PPD"];
|
||||
if ([list count])
|
||||
{
|
||||
int i;
|
||||
NSString *displayRes, *listRes;
|
||||
for (i = 0; i < [resList count]; i++)
|
||||
NSString *display, *option;
|
||||
for (i = 0; i < [list count]; i++)
|
||||
{
|
||||
NSString *res = [resList objectAtIndex: i];
|
||||
listRes = [@"Resolution/" stringByAppendingString: res];
|
||||
displayRes = [printer stringForKey: listRes
|
||||
NSString *key = [list objectAtIndex: i];
|
||||
option = [@"Resolution/" stringByAppendingString: key];
|
||||
display = [printer stringForKey: option
|
||||
inTable: @"PPDOptionTranslation"];
|
||||
|
||||
if (displayRes == nil)
|
||||
displayRes = res;
|
||||
[_resButton addItemWithTitle: displayRes];
|
||||
if (display == nil)
|
||||
display = key;
|
||||
[control addItemWithTitle: display];
|
||||
}
|
||||
listRes = [@"Resolution/" stringByAppendingString: str];
|
||||
displayRes = [printer stringForKey: listRes
|
||||
option = [@"Resolution/" stringByAppendingString: str];
|
||||
display = [printer stringForKey: option
|
||||
inTable: @"PPDOptionTranslation"];
|
||||
|
||||
if (displayRes == nil)
|
||||
displayRes = str;
|
||||
[_resButton selectItemWithTitle: displayRes];
|
||||
if (display == nil)
|
||||
display = str;
|
||||
[control selectItemWithTitle: display];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_resButton addItemWithTitle: str];
|
||||
[control addItemWithTitle: str];
|
||||
}
|
||||
}
|
||||
else
|
||||
[_resButton addItemWithTitle: @"Unknown"];
|
||||
[control addItemWithTitle: @"Unknown"];
|
||||
|
||||
/* Setup the paper feed popup */
|
||||
[_paperButton removeAllItems];
|
||||
control = CONTROL(_panel, NSPPPaperFeedButton);
|
||||
[control removeAllItems];
|
||||
str = [printer stringForKey:@"DefaultInputSlot" inTable: @"PPD"];
|
||||
if (str)
|
||||
{
|
||||
NSString *manual;
|
||||
NSArray *inputList;
|
||||
NSArray *list;
|
||||
manual = [printer stringForKey:@"DefaultManualFeed" inTable: @"PPD"];
|
||||
if (manual)
|
||||
[_paperButton addItemWithTitle: @"Manual"];
|
||||
inputList = [printer stringListForKey:@"InputSlot" inTable: @"PPD"];
|
||||
if ([inputList count])
|
||||
[control addItemWithTitle: @"Manual"];
|
||||
list = [printer stringListForKey:@"InputSlot" inTable: @"PPD"];
|
||||
if ([list count])
|
||||
{
|
||||
int i;
|
||||
NSString *displayPaper, *listPaper;
|
||||
for (i = 0; i < [inputList count]; i++)
|
||||
NSString *display, *option;
|
||||
for (i = 0; i < [list count]; i++)
|
||||
{
|
||||
NSString *paper = [inputList objectAtIndex: i];
|
||||
listPaper = [@"InputSlot/" stringByAppendingString: paper];
|
||||
displayPaper = [printer stringForKey: listPaper
|
||||
NSString *paper = [list objectAtIndex: i];
|
||||
option = [@"InputSlot/" stringByAppendingString: paper];
|
||||
display = [printer stringForKey: option
|
||||
inTable: @"PPDOptionTranslation"];
|
||||
|
||||
if (displayPaper == nil)
|
||||
displayPaper = paper;
|
||||
[_paperButton addItemWithTitle: displayPaper];
|
||||
if (display == nil)
|
||||
display = paper;
|
||||
[control addItemWithTitle: display];
|
||||
}
|
||||
/* FIXME: What if manual is default ? */
|
||||
listPaper = [@"InputSlot/" stringByAppendingString: str];
|
||||
displayPaper = [printer stringForKey: listPaper
|
||||
option = [@"InputSlot/" stringByAppendingString: str];
|
||||
display = [printer stringForKey: option
|
||||
inTable: @"PPDOptionTranslation"];
|
||||
|
||||
if (displayPaper == nil)
|
||||
displayPaper = str;
|
||||
[_paperButton selectItemWithTitle: displayPaper];
|
||||
if (display == nil)
|
||||
display = str;
|
||||
[control selectItemWithTitle: display];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_paperButton addItemWithTitle: str];
|
||||
[control addItemWithTitle: str];
|
||||
}
|
||||
}
|
||||
else
|
||||
[_paperButton addItemWithTitle: @"Unknown"];
|
||||
[control addItemWithTitle: @"Unknown"];
|
||||
|
||||
}
|
||||
|
||||
#define NSNUMBER(a) [NSNumber numberWithInt: (a)]
|
||||
|
||||
/** Saves information set by the user in the receiver's panel
|
||||
in the NSPrintInfo object from the current NSPrintOperation.
|
||||
*/
|
||||
- (void)finalWritePrintInfo
|
||||
{
|
||||
id control;
|
||||
double scale;
|
||||
int layout;
|
||||
NSString *sel;
|
||||
NSArray *list;
|
||||
NSPrinter *printer;
|
||||
|
@ -410,35 +484,56 @@
|
|||
features = [dict objectForKey: NSPrintJobFeatures];
|
||||
|
||||
/* Copies */
|
||||
if ([_copiesField intValue] > 1)
|
||||
control = CONTROL(self, NSPPCopiesField);
|
||||
if ([control intValue] > 1)
|
||||
{
|
||||
[dict setObject: NSNUMBER([_copiesField intValue])
|
||||
[dict setObject: NSNUMBER([control intValue])
|
||||
forKey: NSPrintCopies];
|
||||
}
|
||||
|
||||
/* Pages */
|
||||
if ([_pageMatrix selectedColumn] != 0)
|
||||
control = CONTROL(self, NSPPPageChoiceMatrix);
|
||||
if ([control selectedColumn] != 0)
|
||||
{
|
||||
[dict setObject: NSNUMBER([[_fromRangeForm cellAtIndex: 0] intValue])
|
||||
id fromRangeForm = CONTROL(self, NSPPPageRangeFrom);
|
||||
id toRangeForm = CONTROL(self, NSPPPageRangeTo);
|
||||
[dict setObject: NSNUMBER([[fromRangeForm cellAtIndex: 0] intValue])
|
||||
forKey: NSPrintFirstPage];
|
||||
[dict setObject: NSNUMBER([[_toRangeForm cellAtIndex: 0] intValue])
|
||||
[dict setObject: NSNUMBER([[toRangeForm cellAtIndex: 0] intValue])
|
||||
forKey: NSPrintLastPage];
|
||||
[dict setObject: NSNUMBER(NO) forKey: NSPrintAllPages];
|
||||
}
|
||||
else
|
||||
[dict setObject: NSNUMBER(YES) forKey: NSPrintAllPages];
|
||||
|
||||
/* Scale */
|
||||
control = CONTROL(self, NSPPScaleField);
|
||||
scale = [control intValue]/100;
|
||||
if (scale <= 0)
|
||||
scale = .1;
|
||||
if (scale >= 10)
|
||||
scale = 10;
|
||||
[control setIntValue: (int)(scale*100)];
|
||||
[dict setObject: [NSNumber numberWithDouble: scale]
|
||||
forKey: NSPrintScalingFactor];
|
||||
|
||||
/* Layout */
|
||||
layout = [CONTROL(self, NSPPLayoutButton) indexOfSelectedItem] + 1;
|
||||
[dict setObject: NSNUMBER(layout) forKey: NSPrintPagesPerSheet];
|
||||
|
||||
/* Resolution */
|
||||
/* Here we take advantage of the fact the names in the popup list
|
||||
are in the same order as the PPD file, so we don't actually compare
|
||||
the values */
|
||||
control = CONTROL(_panel, NSPPResolutionButton);
|
||||
list = [printer stringListForKey: @"Resolution" inTable: @"PPD"];
|
||||
if (list)
|
||||
{
|
||||
NSString *def;
|
||||
sel = [list objectAtIndex: [_resButton indexOfSelectedItem]];
|
||||
sel = [list objectAtIndex: [control indexOfSelectedItem]];
|
||||
def = [printer stringForKey:@"DefaultResolution" inTable: @"PPD"];
|
||||
if ([sel isEqual: def] == NO)
|
||||
if ([sel isEqual: def] == NO
|
||||
|| [features objectForKey: @"Resolution"])
|
||||
{
|
||||
if (features == nil)
|
||||
{
|
||||
|
@ -451,13 +546,14 @@
|
|||
}
|
||||
|
||||
/* Input Slot */
|
||||
control = CONTROL(_panel, NSPPPaperFeedButton);
|
||||
list = [printer stringListForKey:@"InputSlot" inTable: @"PPD"];
|
||||
if (list)
|
||||
{
|
||||
int selected;
|
||||
NSString *def, *manual;
|
||||
sel = nil;
|
||||
selected = [_paperButton indexOfSelectedItem];
|
||||
selected = [control indexOfSelectedItem];
|
||||
manual = [printer stringForKey:@"DefaultManualFeed" inTable: @"PPD"];
|
||||
|
||||
if (manual)
|
||||
|
@ -479,7 +575,8 @@
|
|||
[dict setObject: @"ManualFeed/True" forKey: NSPrintManualFeed];
|
||||
[features setObject: @"ManualFeed/True" forKey: NSPrintPaperFeed];
|
||||
}
|
||||
else if ([sel isEqual: def] == NO)
|
||||
else if ([sel isEqual: def] == NO
|
||||
|| [dict objectForKey: NSPrintPaperFeed])
|
||||
{
|
||||
if (features == nil)
|
||||
{
|
||||
|
|
|
@ -1849,6 +1849,7 @@ resetCursorRectsForView(NSView *theView)
|
|||
{
|
||||
NSWarnMLog(@"closing window (%@) that's already closed.", self);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Private Method. Many X Window managers will just deminiaturize us without
|
||||
|
|
Loading…
Reference in a new issue