• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextTab Troubles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextTab Troubles


  • Subject: NSTextTab Troubles
  • From: John Devor <email@hidden>
  • Date: Fri, 19 Dec 2003 23:30:02 -0500

Hello. I'm trying to print (using an NSTextView) one line separated in
the middle using NSTextTabs. One part should be aligned center while
the other should be aligned right. Here's what I've got so far (though
in this code I'm not dividing the line... just trying to get the
@"TITLE" to be aligned right):

- (NSView *)printableView
{
NSTextView *printView;
NSDictionary *titleAttr;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle
alloc] init];

[paragraphStyle setAlignment:NSCenterTextAlignment];
//By default, text is centered

// CREATE THE PRINT VIEW
// 480 pixels wide seems like a good width for printing text
printView = [[[NSTextView alloc] initWithFrame:NSMakeRect(0, 0,
480, 200)] autorelease];
[printView setVerticallyResizable:YES];
[printView setHorizontallyResizable:NO];

[[printView textStorage] beginEditing];


/* Title */
titleAttr = [NSDictionary dictionaryWithObject:[NSFont
boldSystemFontOfSize:14] forKey:NSFontAttributeName];
[[printView textStorage]
appendAttributedString:[[[NSAttributedString alloc]
initWithString:@"\tTITLE" attributes:titleAttr] autorelease]];
[[printView textStorage]
appendAttributedString:[[[NSAttributedString alloc]
initWithString:@"\nNEXTLINE" attributes:titleAttr]
autorelease]];

[paragraphStyle addTabStop:[[[NSTextTab alloc]
initWithType:NSRightTabStopType location:0] autorelease]];

// Center the title
[[printView textStorage] addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle range:NSMakeRange(0,[[printView textStorage]
length])];

[[printView textStorage] endEditing];

[printView sizeToFit];

return printView;
}

Anyone?
- John D.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • WebServices Question
      • From: Tom Ryan <email@hidden>
    • Re: NSTextTab Troubles
      • From: Douglas Davidson <email@hidden>
    • Re: NSTextTab Troubles
      • From: Jonathan Jackel <email@hidden>
  • Prev by Date: Re: can no longer build - many warnings, internal bus error
  • Next by Date: Re: CGXRemoveTrackingArea problem
  • Previous by thread: NSPureApplication
  • Next by thread: Re: NSTextTab Troubles
  • Index(es):
    • Date
    • Thread