Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSRect implemented in C?

NSRect implemented in C?
Thread Tools
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Mar 18, 2001, 11:11 PM
 
I am trying to get some information surrounding the dimensions of a subclass of NSOpenGLView and I am running into some difficulties.

I am trying to call:
[[self bounds] width];
or
[[self bounds] maxX];

Neither of these seem to work at all. It seems to be having trouble finding the width and maxX methods within NSRect (the return type for [self bounds]). It finds the bounds NSRect of the view, the implicitly declares width or maxX as return type id when it can't find them. I couldn't find a class header file for NSRect in Foundation or Appkit (it should be in Foundation, I think) so I had to look online to get the method prototypes. They all appear to be in C while almost the entire rest of the API is obj-C. I was wondering if this might be causing this problem but using C syntax to call these methods didn't work either. If anyone could help me out that would be much appreciated.
Or, if you can think of a better way to get the coordinates of a mouseUp event in an OpenGLView's coordinate system (without Z, I guess), that would also be helpful (but I am trying not to use GLUT, just GLU and cocoa API).

Hope to hear form someone soon,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Mar 18, 2001, 11:46 PM
 
NSRect, NSPoint, and NSSize are are regular C structures, not Objective-C classes. The structures and the functions to manipulate them are declared in <Foundation/NSGeometry.h>.

So, you really want:

NSWidth([self bounds])

NSMaxX([self bounds])

I guess these constructs were considered too simple to bother with making them classes -- they really are just data storage, after all, and it's probably easier to manipulate them as structures. Java doesn't have structures, so they're implemented as real classes there, but not in ObjC. NSRange (in ObjC) is also a C structure if you come across that, defined in <Foundation/NSRange.h>.


[This message has been edited by lindberg (edited 03-19-2001).]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:43 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2