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

Help in Sketch Example


  • Subject: Help in Sketch Example
  • From: Anoop <email@hidden>
  • Date: Mon, 27 Feb 2006 20:13:37 +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(keyDown)
        //{
        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);

- Ignored:
            y1=NSMinY(bounds);
            [path lineToPoint:NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))];
            x2=NSMaxX(bounds);
            y2=NSMaxY(bounds);
        //    [self TextDisplay];
        }
        //}
           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];

    }

--
With Regards,
             Anoop


 _______________________________________________
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

  • Prev by Date: [CORE DATA] multithreading
  • Next by Date: iCal syncing bug?
  • Previous by thread: Re: [CORE DATA] multithreading
  • Next by thread: iCal syncing bug?
  • Index(es):
    • Date
    • Thread