• 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
Text not drawing where I think it should
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Text not drawing where I think it should


  • Subject: Text not drawing where I think it should
  • From: Graham J Lee <email@hidden>
  • Date: Wed, 3 Nov 2004 12:25:19 +0000

Hi,

I'm creating an app to graph some data (and eventually do some simple stats on them), displaying the graph in a custom view. The graphing is all fine, but labeling the axes is causing me some trouble. I want to draw the Y label going 'up' the axis, so I'm drawing the labels like this:

	p1=NSMakePoint(width*0.50,height*0.02);
	[xLabel drawAtPoint:p1];
	/* Rotate the context, draw the Y label, rotate back */
	[NSGraphicsContext saveGraphicsState];
	aTrans=[NSAffineTransform transform];
	[aTrans translateXBy:width yBy:0];
	[aTrans rotateByDegrees:90];
	[aTrans concat];
	/*p1=NSMakePoint(width*0.50,height*0.90);*/
	p1=NSMakePoint(height*0.50,width*0.90);
	[yLabel drawAtPoint:p1];
	[NSGraphicsContext restoreGraphicsState];

With p1 defined the second time by "p1=NSMakePoint(width*0.50,height*0.90);" then the label draws in "kindof" the right place, but it's clear that because width and height differ it's not *quite* the right place. I think that this is because the width of the rotated context is equal to height and vice versa. BTW, the variables width and height were found by e.g. [self bounds].size.width earlier in the method, i.e. back when the context was the "right" way around.

So, I try to put the label in the correct place by "p1=NSMakePoint(height*0.50,width*0.90);" only it doesn't appear at all. I found that for some value of the [rotated] y ordinate that happens to be around (width*0.86), the label starts to get chopped off [see http://www-teaching.physics.ox.ac.uk/~leeg/ppcgview.pdf] suggesting that it's popping off the top of the drawable area. I guess my questions are twofold: firstly how can I engineer things so that I *can* draw right up to the edge of the visible view, and secondly what is the reason that I currently can't? I.e. what is it about drawing on views that I don't understand, leading me to try something that doesn't work as I think it might?

Thanks,

Graham.
--
Graham Lee
UNIX Systems Manager,
Oxford Physics Practical Course
http://nextstep.sdf-eu.org

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Text not drawing where I think it should
      • From: "R. Scott Thompson" <email@hidden>
  • Prev by Date: Re: How to check for afp connections?
  • Next by Date: Recalculating an NSScrollView
  • Previous by thread: Re: Internationalization: How to bring the locale in line with the language?
  • Next by thread: Re: Text not drawing where I think it should
  • Index(es):
    • Date
    • Thread