nsview

Core Animation - Sheet-like Window Sliding

How difficult would it be to use core animation to make an NSView slide in an out of view like a sheet? Generally speaking, what would be involved in accomplishing this? I've been reading through the CA documentation, but it's been hard for me to pinpoint which parts are relevant to what I want to do since I have no experience with the f...

Binding a custom NSView: Does it demand creating an IBPlugin ?

I have created a subclass of NSView to draw an image as a pattern: @interface CePatternView : NSView { NSImage* image; id observableObjectForImage; NSString* keyPathForImage; } @end I implemented the following to expose bindings: + (void)initialize { // Expose the "image" binding to IB. [self exposeBinding:@"i...

NSView with variable number of items inside

I'm trying to figure out how to create a view that, depending on the circumstances, has a variable number of items being displayed in it. Something like the grid view in Finder or iTunes, an image with a sort of caption text underneath it. I've heard that you can use an NSCollectionView for this sort of thing, but I don't really know. I'...

Change cursor in GL fullscreen on OSX using cocoa?

Can anyone provide a sample / link to a sample Cocoa app that changes the 'hardware' cursor in a fullscreen OpenGL Cocoa app? I have been able to create a full screen GL app and an app that changes the cursor by overriding NSView::resetCursorRects but I have not been able to get both to work simultaneously. I've also refitted some of t...

iPhone Memory Management and Releasing

Here's a common practice I see often (including from a very popular iPhone developer book) In the .h file: @interface SomeViewController : UIViewController { UIImageView *imgView; } Somewhere in the .m file: imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; [imgView setImage:[UIImage imageName...

[NSView setFrame:] not working?

Greetings all, I have a puzzling problem. I have a pointer to a vanilla NSView that was initialized in a nib. I message the nsview with [myNSView setFrame:NSMakeRect(0,0,816,1056)]; but when I step through the debugger, myNSView has a frame of {{0,0}, {801, 1041}}. The dimensions of the rectangle are 15 less than I've specified! Thi...

How do you put a normal control into an NSView?

What I'm actually trying to do is put a WebKitView into a ScreenSaver (which inherits NSView). I'm totally new to MacOS X and Cocoa (but I'm very familiar with Objective-C and used some parts of GNUStep). Do I need some laying out? I want to show only one control in the whole NSView. ...

How to display unarchived custom NSView objects

I’m learning Cocoa programming, and I’m unable to figure out how to archive and unarchive a custom NSView subclass I’ve made a toy application that presents a window. This window contains an instance of my custom BackgroundView class (archived in the xib file). Clicking anywhere in this BackgroundView creates and displays a blue square ...

NSView's autoresizing behavior

Greetings all, I hope you all can shed some light on how NSView autoresizes it's views. I've set everything up in IB and my subviews resize nicely (when I resize my window around with a mouse). However, if I do [myMainView setFrame:] with my new frame rect, nothing happens. All of my sub-views are still the original size (even though t...

Determining Which Instance Self Is

I have a gameboard with 25 tiles of NSView subclass myGameTile. In mouseDown: I want to figure out what tile I clicked on and set an ivar to that value. i.e. If I clicked on tile 12, set myTile to 12. My problem is figuring out in mouseDown: whether it belongs to instance 12 or instance 25. What ways are there to do this? ...

Why are subviews of an NSView not sent a release message when a Cocoa application terminates?

The short version: Why are the subviews of NSView objects not sent a release message when a Cocoa application terminates? Is there a way to override this behaviour? An example: The MyView class shown below is nothing more than an NSView subclass that reports to the console when it is created and destroyed. I have tested it out and ...

Dynamically loading a part of a Window in Cocoa

I have an area of a Window (in my MainMenu.xib) which I'd like to populate dynamically with unrelated "views" such as an NSTable, IKImageBrowserView etc. at different points of time depending on some user-selected criteria. How do I define this area of the window such that it can be "replaced" with different views? How do I attach a ta...

NSAffineTransforms not being used?

I have a subclass of NSView, and in that I'm drawing an NSImage. I'm unsing NSAffineTransforms to rotate, translate and scale the image. Most of it works fine. However, sometimes, the transforms just don't seem to get activated. For example, when I resize the window, the rotate transform doesn't happen. When I zoom in on the image, ...

Why does an NSView's frame method return the wrong results?

I occasionally want to change an NSView's dimensions programmaticaly. To do this, it is helpful to get the dimensions of various views, adjust them relative to each other, and then use setFrame: to reposition. The problem is that the frame method usually returns NSRects that are clearly wrong, from my perspective. I have a program wit...

Obtain a CGContextRef of NSView outside of drawRect ?

I need to get CGContextRef of NSView object. It won't be so bad if I knew how. In Carbon this thing was done like this: CGContextRef cgref = (libvlc_drawable_t)GetWindowPort(HIViewGetWindow((OpaqueControlRef*)hiViewRef)); Obviously it can be done by subclassing NSView (or it's subclass) and catching it in it's drawRect, but that's to...

In Cocoa, what is the best way to change the cursor when hovering over a circular view?

What I want to do I have a circular custom NSView subclass, and I want to change the appearance of the cursor when the mouse is hovering over the circular portions of the view, but not when over the portions of the view's rectangle that fall outside the circle. Here's an illustration. I would have inlined it with an image tag, but I'm ...

What's the RIGHT way to draw an image in the upper left corner on a mac?

I have an NSView in a ScrollView and I'm trying to draw an image in it. The problem is that I want the upper left corner of the image locked to the upper left corner of the frame, instead of the lower left corner, which is what the View wants me to do. I will need to be able to zoom in and out, and rotate. currently, I have a kludge of ...

Better way to move NSView bounds with player?

Currently writing a roguelike to learn more about Objective-C/Cocoa. I'm really enjoying it so far and I've learned tons. This code moves the origin of the view's bounds, so that it follows the player as he moves. The code works perfect, I was just asking if there was a better way than using four for's. I've also seen in some cases th...

How to implement very large scrolled view in Cocoa

Is it wise to create views in Cocoa that have dimensions around 15000 pixels? (of course only small part of this view will be visible at a time in a NSScrollView) Interface Builder has limit of 10000 pixels in size. Is this an artificial limitation or is there a good reason behind it? Should I just create huge view and let NSScrollView...

Why shouldn't I use a cursor rect on a rotated NSView subclass?

I am writing a custom NSView subclass. I have several instances of this class in my window, most of which are rotated by calling NSView's setFrameRotation method. I also need to change the cursor when over a rectangular region of this view. The documentation for NSView's addCursorRect method contains the following oblique warning: C...