public
Description: A popular sample Cocoa application rewritten in Nu. Original code by Aaron Hillegass, ported to Nu by Tim Burks.
Homepage: http://programming.nu/posts/2007/12/12/nupagepacker
Clone URL: git://github.com/timburks/nupagepacker.git
Moved printOperationWithSettings:error: to Nu.

The error argument to this method was of a previously-unsupported
type, but recent improvements to Nu made the conversion possible.

Also, I turned off the (slow) BridgeSupport file loading
in favor of using explicitly declared symbols.  This will
always be faster, and faster is better for deployed
applications.
timburks (author)
Tue Dec 11 21:50:34 -0800 2007
commit  fe3ab7c151b88c77594f252ec81edf99724f6b62
tree    20146f0d1481550b954e970fd1e3b2cfed1352c3
parent  08ba424fa2efc43f8b56ea0bcbf8485060ddc994
...
1
2
3
4
5
6
7
8
9
 
 
 
10
11
12
...
1
2
 
 
3
4
5
 
 
6
7
8
9
10
11
0
@@ -1,12 +1,11 @@
0
 ;; @file bridged.nu
0
 ;; @discussion Declarations of bridged constants and functions.
0
-;; We can eliminate the need for them by enhancing Nu to read the Apple BridgeSupport files.
0
-;; Project idea, anyone?
0
 ;;
0
 ;; @copyright Copyright (c) 2007 Tim Burks, Neon Design Technology, Inc.
0
 
0
-;; Switch on OS release.
0
-(if (>= 9 ((((NSString stringWithShellCommand:"uname -r") componentsSeparatedByString:".") objectAtIndex:0) intValue))
0
+(if nil ;; don't load BridgeSupport files, all the constants that we need are defined below.
0
+ ;; Switch on OS release.
0
+ ;;(>= 9 ((((NSString stringWithShellCommand:"uname -r") componentsSeparatedByString:".") objectAtIndex:0) intValue))
0
     (then ;; Use Leopard BridgeSupport files
0
           (load "bridgesupport")
0
           (import AppKit)
...
81
82
83
84
 
 
85
86
87
 
88
89
90
...
106
107
108
109
 
 
 
 
110
111
112
...
736
737
738
739
740
741
742
 
 
 
 
743
744
745
...
81
82
83
 
84
85
86
87
88
89
90
91
92
...
108
109
110
 
111
112
113
114
115
116
117
...
741
742
743
 
 
 
 
744
745
746
747
748
749
750
0
@@ -81,10 +81,12 @@
0
 
0
 ;; @class MyDocument
0
 ;; @discussion This is the main PagePacker document.
0
-(class MyDocument
0
+(class MyDocument is NSDocument
0
+ (ivar (id) packModel (id) packerView)
0
      
0
      (- (id)init is
0
         (super init)
0
+
0
         (set @packModel ((PackModel alloc) init))
0
         (@packModel setUndoManager:(self undoManager))
0
         self)
0
@@ -106,7 +108,10 @@
0
         (set @packModel (NSKeyedUnarchiver unarchiveObjectWithData:data))
0
         (@packModel setUndoManager:(self undoManager))
0
         (if @packerView (self updateUI))
0
- YES))
0
+ YES)
0
+
0
+ (- (id) printOperationWithSettings:(id)printSettings error:(id *)errorReference is
0
+ (NSPrintOperation printOperationWithView:@packerView printInfo:(self printInfo))))
0
 
0
 ;; @class DragingSourcePDFView
0
 ;; @discussion This class controls the view of the source document.
0
@@ -736,10 +741,10 @@
0
         (set bounds (NSInsetRect (self bounds) 3 3))
0
         (@attString drawInRect:bounds)))
0
 
0
-;; use the above class to generate a PDF for an attribute string.
0
-(function pdfFromAttributedStringOfSize (attStr sz)
0
- (set v ((TextDisplayView alloc) initWithPageSize:sz attributedString:attStr))
0
- (v dataWithPDFInsideRect:(v bounds)))
0
+;; use the above class to generate a PDF for an attributed string.
0
+(function pdfFromAttributedStringOfSize (attributedString size)
0
+ (set view ((TextDisplayView alloc) initWithPageSize:size attributedString:attributedString))
0
+ (view dataWithPDFInsideRect:(view bounds)))
0
 
0
 ;; some internal constants
0
 (global PaperSizeChangedNotification "PaperSizeChangedNotification")
...
 
 
 
 
 
 
 
1
2
3
...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
49
50
51
52
53
54
55
56
57
58
59
 
 
60
61
62
...
66
67
68
 
69
70
71
...
83
84
85
 
86
87
88
...
1
2
3
4
5
6
7
8
9
10
...
41
42
43
 
 
 
 
 
 
 
 
 
 
 
 
44
45
 
 
 
 
 
 
 
 
 
 
46
47
48
49
50
...
54
55
56
57
58
59
60
...
72
73
74
75
76
77
78
0
@@ -1,3 +1,10 @@
0
+// PagePacker.m
0
+// All that's left of the original Objective-C source for PagePacker.
0
+//
0
+// Substantially derived from original Objective-C source code by Aaron Hillegass.
0
+// The original copyright notice is below.
0
+// Changes in this version are copyright (c) 2007 Tim Burks, Neon Design Technology, Inc.
0
+
0
 /*
0
  Copyright (c) 2007, Big Nerd Ranch, Inc.
0
 
0
@@ -34,29 +41,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
0
 #import <Cocoa/Cocoa.h>
0
 
0
 // The code below is what remains of Aaron's original Objective-C source.
0
-// All comments are mine (Tim Burks).
0
-
0
-// We leave these class and method definitions in Objective-C.
0
-// For various reasons, each is currently not representable in Nu.
0
-
0
-@interface MyDocument : NSDocument
0
-{
0
- // since we use these two ivars in Objective-C, keep their declarations here.
0
- // all other ivars are declared in Nu.
0
- id packModel;
0
- id packerView;
0
-}
0
+// Except where otherwise noted, all comments below are mine (Tim Burks).
0
 
0
-@end
0
-
0
-@implementation MyDocument
0
-// We can't declare a method in Nu with an argument that's an (NSError **)
0
-- (id) printOperationWithSettings:(id)printSettings error:(NSError **)outError
0
-{
0
- [NSPrintOperation printOperationWithView:packerView printInfo:[self printInfo]];
0
-}
0
-
0
-@end
0
+// We leave this class declaration and these three method definitions in Objective-C.
0
+// For various reasons, each method is currently not representable in Nu.
0
 
0
 @interface PackerView : NSView
0
 {
0
@@ -66,6 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
0
 @end
0
 
0
 @interface PackerView (Nu)
0
+// declare this interface here so that our Objective-C code can call our Nu method.
0
 - (void) setImageablePageRect:(NSRect) r;
0
 @end
0
 
0
@@ -83,6 +72,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
0
 // Nu can't declare methods with arguments that are pointers to NSRanges
0
 - (BOOL)knowsPageRange:(NSRange *)rptr
0
 {
0
+ // Comment from Aaron:
0
     // As a sort of odd side-effect, I'm also informing the view
0
     // of how much of the page the printer can actually draw.
0
     // I waited until now so that I could use the printer that the

Comments

    No one has commented yet.