Next: 2.3 Setting the title Up: 2 Adding a Window Previous: 2.1 Window Attributes

2.2 Creating a Window

We are now ready to show an example of creating a window:
NSWindow *myWindow;
NSRect rect = NSMakeRect (100, 100, 200, 200);
unsigned int styleMask = NSTitledWindowMask 
                         | NSMiniaturizableWindowMask;

myWindow = [NSWindow alloc];
myWindow = [myWindow initWithContentRect: rect
                     styleMask: styleMask
                     backing: NSBackingStoreBuffered
                     defer: NO];
(Please ignore the backing: and defer: arguments for now. The values given in the example are appropriate in most cases). This window has an initial content rect which has its origin (its lower left corner) positioned in the point of coordinates (100, 100) in the screen coordinates. In GNUstep, all coordinates system are by default Cartesian and the origin is always in the lower left corner (this is only the default, because inside a GNUstep window you can then flip, rotate and (more generally) transform coordinates at your wish). The window has a title bar, and can be miniaturized by the user, but not resized or closed.



2008-01-16