Permalink
Browse files

Get basic Core Text drawing working

  • Loading branch information...
1 parent 6d97aa8 commit 8c493c8d17d315e4c1f94b768d0ed646c75c64ab @jjgod committed Jul 31, 2009
Showing with 197 additions and 90 deletions.
  1. +1 −1 AppController.h
  2. +12 −3 AppController.m
  3. +8 −8 English.lproj/MainMenu.xib
  4. +7 −7 English.lproj/TextDocument.xib
  5. +1 −1 Info.plist
  6. +5 −9 JJTextView.h
  7. +150 −57 JJTextView.m
  8. +13 −0 README.markdown
  9. +0 −4 TextDocument.m
View
@@ -8,7 +8,7 @@
#import <Cocoa/Cocoa.h>
-@interface AppController : NSObject {
+@interface AppController : NSResponder {
}
View
@@ -104,15 +104,24 @@ - (BOOL) applicationShouldOpenUntitledFile: (NSApplication *) sender
return NO;
}
+- (BOOL) acceptsFirstResponder
+{
+ return YES;
+}
+
- (void) changeFont: (id) sender
{
NSFont *oldFont = [self font];
NSFont *newFont = [sender convertFont: oldFont];
-
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+
NSLog(@"changeFont = %@", newFont);
- [[NSUserDefaults standardUserDefaults] setValue: [newFont fontName] forKey: @"fontName"];
- [[NSUserDefaults standardUserDefaults] setValue: [NSNumber numberWithDouble: [newFont pointSize]] forKey: @"fontSize"];
+ if ([oldFont fontName] != [newFont fontName])
+ [defaults setValue: [newFont fontName] forKey: @"fontName"];
+
+ if ([oldFont pointSize] != [newFont pointSize])
+ [defaults setValue: [NSNumber numberWithDouble: [newFont pointSize]] forKey: @"fontSize"];
}
@end
@@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9G55</string>
+ <string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
- <string key="IBDocument.AppKitVersion">949.43</string>
+ <string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -826,7 +826,7 @@
<object class="NSTextFieldCell" key="NSCell" id="986725230">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">71304192</int>
- <string key="NSContents">Line Spacing:</string>
+ <string key="NSContents">Line Spread:</string>
<reference key="NSSupport" ref="901208874"/>
<reference key="NSControlView" ref="995010602"/>
<reference key="NSBackgroundColor" ref="248392606"/>
@@ -873,8 +873,8 @@
<int key="NSCellFlags">917024</int>
<int key="NSCellFlags2">0</int>
<reference key="NSControlView" ref="228139828"/>
- <double key="NSMaxValue">1.000000e+02</double>
- <double key="NSIncrement">1.000000e+00</double>
+ <double key="NSMaxValue">1.000000e+01</double>
+ <double key="NSIncrement">1.000000e-01</double>
<bool key="NSAutorepeat">YES</bool>
</object>
</object>
@@ -2237,8 +2237,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{321, 407}, {200, 170}}</string>
- <string>{{321, 407}, {200, 170}}</string>
+ <string>{{337, 443}, {200, 170}}</string>
+ <string>{{337, 443}, {200, 170}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -2320,7 +2320,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">AppController</string>
- <string key="superclassName">NSObject</string>
+ <string key="superclassName">NSResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">AppController.h</string>
@@ -34,7 +34,7 @@
<object class="NSWindowTemplate" id="275939982">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{103, -42}, {939, 787}}</string>
+ <string key="NSWindowRect">{{103, -31}, {939, 776}}</string>
<int key="NSWTFlags">1886912512</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
@@ -59,12 +59,12 @@
<object class="NSCustomView" id="793227834">
<reference key="NSNextResponder" ref="479699895"/>
<int key="NSvFlags">274</int>
- <string key="NSFrameSize">{939, 766}</string>
+ <string key="NSFrameSize">{939, 755}</string>
<reference key="NSSuperview" ref="479699895"/>
<string key="NSClassName">JJTextView</string>
</object>
</object>
- <string key="NSFrame">{{1, 1}, {939, 766}}</string>
+ <string key="NSFrame">{{1, 1}, {939, 755}}</string>
<reference key="NSSuperview" ref="707828383"/>
<reference key="NSNextKeyView" ref="793227834"/>
<reference key="NSDocView" ref="793227834"/>
@@ -100,7 +100,7 @@
<double key="NSPercent">5.060241e-01</double>
</object>
</object>
- <string key="NSFrame">{{-1, 20}, {941, 768}}</string>
+ <string key="NSFrame">{{-1, 20}, {941, 757}}</string>
<reference key="NSSuperview" ref="568628114"/>
<reference key="NSNextKeyView" ref="479699895"/>
<int key="NSsFlags">562</int>
@@ -109,7 +109,7 @@
<reference key="NSContentView" ref="479699895"/>
</object>
</object>
- <string key="NSFrameSize">{939, 787}</string>
+ <string key="NSFrameSize">{939, 776}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
@@ -263,8 +263,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{389, 266}, {939, 787}}</string>
- <string>{{389, 266}, {939, 787}}</string>
+ <string>{{389, 80}, {939, 776}}</string>
+ <string>{{389, 80}, {939, 776}}</string>
<integer value="1" id="9"/>
<string>{{201, 387}, {507, 413}}</string>
<reference ref="9"/>
View
@@ -42,7 +42,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>1.0</string>
+ <string>2.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
View
@@ -9,20 +9,16 @@
#import <Cocoa/Cocoa.h>
@interface JJTextView : NSView {
- NSSize textContainerInset;
- CGFloat lineGap;
+ NSSize textInset;
NSColor *backgroundColor;
- NSFont *font;
NSString *string;
- CTFrameRef frame;
+ NSMutableArray *textFrames;
}
-@property (assign) NSSize textContainerInset;
-@property (assign) CGFloat lineGap;
+@property (assign) NSSize textInset;
@property (retain) NSColor *backgroundColor;
-@property (retain) NSFont *font;
-@property (copy) NSString *string;
-- (void) relayout;
+- (void) setString: (NSString *) string;
+- (void) invalidateLayout;
@end
Oops, something went wrong.

0 comments on commit 8c493c8

Please sign in to comment.