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
Converted scripting support to Nu, added README.
timburks (author)
Sat Dec 01 23:51:03 -0800 2007
commit  2e7474b5d93c471bee5ea14db509b52e24b8664b
tree    9ecc165970f4796502796fe95d4af4198258620d
parent  b056c97ca901999e31ab5df0373003e259321bdc
...
24
25
26
27
 
28
29
30
...
24
25
26
 
27
28
29
30
0
@@ -24,7 +24,7 @@
0
            "CFBundleIconFile" "PPApp"
0
            "CFBundleIdentifier" "nu.programming.NuPagePacker"
0
            "CFBundleInfoDictionaryVersion" "6.0"
0
- "CFBundleName" "PagePacker"
0
+ "CFBundleName" "NuPagePacker"
0
            "CFBundlePackageType" "APPL"
0
            "CFBundleSignature" "????"
0
            "CFBundleVersion" "1.2"
...
8
9
10
11
 
12
13
14
...
21
22
23
 
 
24
25
26
...
8
9
10
 
11
12
13
14
...
21
22
23
24
25
26
27
28
0
@@ -8,7 +8,7 @@
0
 (load "console")  ;; interactive console
0
 (load "packer")    ;; application code
0
 
0
-;; unfortunately, these aren't called automatically
0
+;; unfortunately, these initialize methods aren't called automatically, so we call them here.
0
 (PackerView initialize)
0
 (PreferenceController initialize)
0
 (DraggingSourcePDFView initialize)
0
@@ -21,6 +21,8 @@
0
           (if SHOW_CONSOLE_AT_STARTUP ($console toggleConsole:self))
0
           ((CatalogController sharedCatalogController) showWindow:nil)))
0
 
0
+(load "scripting") ;; scripting support, must be loaded after AppControler is defined
0
+
0
 (set NSApp (NSApplication sharedApplication))
0
 
0
 ;; this makes the application window take focus when we've started it from the terminal
...
3
4
5
 
6
7
8
...
126
127
128
129
130
131
132
...
339
340
341
342
 
343
344
345
346
347
 
348
349
350
351
352
 
353
354
355
356
357
 
358
359
360
...
378
379
380
381
382
383
384
...
449
450
451
452
453
454
455
 
 
 
 
456
457
458
...
536
537
538
539
 
540
541
542
...
545
546
547
548
 
549
550
551
...
667
668
669
670
671
 
 
672
673
674
...
781
782
783
784
785
786
787
...
3
4
5
6
7
8
9
...
127
128
129
 
130
131
132
...
339
340
341
 
342
343
344
345
346
 
347
348
349
350
351
 
352
353
354
355
356
 
357
358
359
360
...
378
379
380
 
381
382
383
...
448
449
450
 
 
 
 
451
452
453
454
455
456
457
...
535
536
537
 
538
539
540
541
...
544
545
546
 
547
548
549
550
...
666
667
668
 
 
669
670
671
672
673
...
780
781
782
 
783
784
785
0
@@ -3,6 +3,7 @@
0
 ;;
0
 ;; @copyright Copyright (c) 2007 Tim Burks, Neon Design Technology, Inc.
0
 
0
+;; these declarations would be unnecessary if Nu is enhanced to read the Apple BridgeSupport files.
0
 (global kPDFDisplaySinglePage 0)
0
 (global NSDragOperationCopy 1)
0
 (global NSPDFPboardType "Apple PDF pasteboard type")
0
@@ -126,7 +127,6 @@
0
      (ivar (id) mouseDownEvent)
0
      
0
      (+ (void) initialize is
0
- (NSLog "(DraggingSourcePDFView +initialize)")
0
         (set $dragImage (NSImage imageNamed:"Generic")))
0
      
0
      (- (id) hitTest:(NSPoint) aPoint is
0
@@ -339,22 +339,22 @@
0
 
0
 (function isLeftSide (pageNum) (or (eq pageNum 0) (> pageNum 4)))
0
 
0
-(function minX (rect)
0
+(function NSMinX (rect)
0
      (set x1 (rect first))
0
      (set x2 (+ (rect first) (rect third)))
0
      (if (< x1 x2) (then x1) (else x2)))
0
 
0
-(function maxX (rect)
0
+(function NSMaxX (rect)
0
      (set x1 (rect first))
0
      (set x2 (+ (rect first) (rect third)))
0
      (if (> x1 x2) (then x1) (else x2)))
0
 
0
-(function minY (rect)
0
+(function NSMinY (rect)
0
      (set y1 (rect second))
0
      (set y2 (+ (rect second) (rect fourth)))
0
      (if (< y1 y2) (then y1) (else y2)))
0
 
0
-(function maxY (rect)
0
+(function NSMaxY (rect)
0
      (set y1 (rect second))
0
      (set y2 (+ (rect second) (rect fourth)))
0
      (if (> y1 y2) (then y1) (else y2)))
0
@@ -378,7 +378,6 @@
0
      (set numberAttributes nil) ;; pseudo-class variable
0
      
0
      (+ (void) initialize is
0
- (NSLog "(Packerview +initialize)")
0
         (set numberAttributes ((NSMutableDictionary alloc) init))
0
         (numberAttributes setObject:(NSFont fontWithName:"Helvetica" size:40.0) forKey:NSFontAttributeName)
0
         (numberAttributes setObject:(NSColor blueColor) forKey:NSForegroundColorAttributeName))
0
@@ -449,10 +448,10 @@
0
      
0
      (- (void) prepareBezierPaths is
0
         (set bounds (self bounds))
0
- (set left (minX bounds))
0
- (set right (maxX bounds))
0
- (set top (maxY bounds))
0
- (set bottom (minY bounds))
0
+ (set left (NSMinX bounds))
0
+ (set right (NSMaxX bounds))
0
+ (set top (NSMaxY bounds))
0
+ (set bottom (NSMinY bounds))
0
         (set lowerH (QuarterY bounds))
0
         (set midH (HalfY bounds))
0
         (set upperH (ThreeQuarterY bounds))
0
@@ -536,7 +535,7 @@
0
      (- (NSRect) fullRectForPage:(int) pageNum is
0
         (set bounds (self bounds))
0
         (if (isLeftSide pageNum)
0
- (then (set x (minX bounds)))
0
+ (then (set x (NSMinX bounds)))
0
             (else (set x (HalfX bounds))))
0
         (case pageNum
0
               (0 (set y (ThreeQuarterY bounds)))
0
@@ -545,7 +544,7 @@
0
               (2 (set y (HalfY bounds)))
0
               (6 (set y (QuarterY bounds)))
0
               (3 (set y (QuarterY bounds)))
0
- (else (set y (minY bounds))))
0
+ (else (set y (NSMinY bounds))))
0
         (list x y (* 0.5 (bounds third)) (* 0.25 (bounds fourth))))
0
      
0
      (- (NSRect) imageableRectForPage:(int) pageNum is
0
@@ -667,8 +666,8 @@
0
                  (if (@packModel pageIsFilled:i)
0
                      (set fullRect (self fullRectForPage:i))
0
                      (set buttonRect (list
0
- (- (maxX fullRect) (+ 30 BUTTON_MARGIN))
0
- (+ (minY fullRect) BUTTON_MARGIN)
0
+ (- (NSMaxX fullRect) (+ 30 BUTTON_MARGIN))
0
+ (+ (NSMinY fullRect) BUTTON_MARGIN)
0
                                           30 25))
0
                      (set button ((NSButton alloc) initWithFrame:buttonRect))
0
                      (button setCell:((RoundCloseButtonCell alloc) init))
0
@@ -781,7 +780,6 @@
0
         self)
0
      
0
      (+ (void)initialize is
0
- (NSLog "(PreferencesController +initialize)")
0
         (set factoryDefaults ((NSMutableDictionary alloc) init))
0
         (factoryDefaults setObject:(NSNumber numberWithInt:0)
0
              forKey:PaperSizeKey)

Comments

    No one has commented yet.