• 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
Help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help


  • Subject: Help
  • From: "Anoop Thomas varghese" <email@hidden>
  • Date: Mon, 27 Feb 2006 20:29:54 +0530

  Hai,
I have made some changes in sketch example. I am  a beginner in cocoa. Our
    desired out put is to display the width of text at the mid point of a
line.
    I gave these in the Line.m of sketch
     - (NSBezierPath *)bezierPath {
       NSBezierPath *path=[NSBezierPath bezierPath];
        NSRect bounds = [self bounds];

        if ([self startsAtLowerLeft])
        {
            [path moveToPoint:NSMakePoint(NSMinX (bounds), NSMaxY(bounds))];
            x1=NSMinX(bounds);
            y1=NSMaxY(bounds);
            [path lineToPoint:NSMakePoint(NSMaxX(bounds), NSMinY(bounds))];
            x2=NSMaxX(bounds);
            y2=NSMinY(bounds);
        }
        else{
            [path moveToPoint:NSMakePoint(NSMinX(bounds), NSMinY(bounds))];
            x1=NSMinX(bounds);


            y1=NSMinY(bounds);
            [path lineToPoint:NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))];
            x2=NSMaxX(bounds);
            y2=NSMaxY(bounds);

        }

           NSPoint midPoint;//,locationText;
            width=sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
            midx = (x1+x2)/2;
            midy = (y1+y2)/2;
            midPoint.x=midx;
            midPoint.y=midx;
         NSLog(@"width is:%i \t x1,y1==%i,%i \t x2,y2==%i,%i
    ",width,x1,y1,x2,y2);
         NSLog(@"Middle point is:%i ,%i",midx,midy);
          [self drawRect:bounds];


        NSPoint midPoint,locationText;
                width=sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
                midx = (x1+x2)/2;
                midy = (y1+y2)/2;
                midPoint.x=midx;
                midPoint.y=midx;
                NSLog(@"width is:%i \t x1,y1==%i,%i \t x2,y2==%i,%i
    ",width,x1,y1,x2,y2);
                NSLog(@"Middle point is:%i ,%i",midx,midy);

        */
        return path;
    }
    -(void)drawRect:(NSRect)rect
    {
        NSString *message= [NSString stringWithString:@"Hai"];
        NSMutableDictionary *attributes = [ NSMutableDictionary dictonary];
        NSRect textBounds=NSZeroRect;
        NSRect bds = [self bounds];
        textBounds.size=[message sizeWithAttributes:attributes];

    textBounds.origin=NSMakePoint((bds.size.width-textBounds.size.width
)/2.0,(bd
    s.size.height - textBounds.size.height) /2.0);
        [message drawAtPoint:textBounds.origin withAttributes:attributes];

    }


--
Regards,
Anoop T Varghese
Ph:919818134789
 _______________________________________________
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: Help
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Why is NSFontManager lying to me ?
  • Next by Date: Problem with copiesOnScroll of NSClipView
  • Previous by thread: iCal syncing bug?
  • Next by thread: Re: Help
  • Index(es):
    • Date
    • Thread