gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changes to graphic context handling


From: Mark Tracy
Subject: Re: Changes to graphic context handling
Date: Sun, 18 Mar 2007 18:33:59 -0700

Fred,
The change you made has broken one of my programs. I am printing from a windowless custom view because I want to lay out the report for paper not the screen. Maybe not a wise strategy, but certainly not an illegal one. This works fine for Cocoa and for previous editions of GNUstep.

In  svn 24892, NSView.m line 1900, there is:
- (void) lockFocusInRect: (NSRect)rect
{
    [self _lockFocusInContext: [_window graphicsContext] inRrect: rect]
}

In my program, since the view is not associated with a window, nil is passed, and I get a segfault trying to read the context.

I changed it to read:
- (void) lockFocusInRect: (NSRect)rect
{
    NSGraphicsContext *ctxt =
      (_window ? [_window graphicsContext] : GSCurrentContext() );
    [self _lockFocusInContext: ctxt inRect: rect];
}

This appears to solve my problem, but it should be reviewed by someone who has a deeper knowledge.

Cheers,
Mark Tracy

Message: 4
Date: Wed, 28 Feb 2007 12:20:45 +0100
From: Fred Kiefer <address@hidden>
Subject: Changes to graphic context handling
To: GNUstep Developer <address@hidden>
Message-ID: <address@hidden>
Content-Type: text/plain; charset=ISO-8859-15

I am planing to implement some serious changes to NSGraphicsContext and
the way this class interacts with the rest of GNUstep and wanted to
publish this plans first, so you may comment on them.

Currently GNUstep uses mostly just one graphics context, the one set up in NSApplication. Only for printing other graphics contexts get created. The idea now is to let each window have its own graphics context. There
still would be the default graphics context owned by the NSApplication
and the ones for printing. In addition, we may even have graphics
contexts to draw into memory space.

Why do this? One reason is of course to follow the change that Apple has done for OS 10.4. With our current setup we could not implement many of
the methods on the class NSGraphicsContext nor some on NSView. Another
reason is to get rid of the strange way we currently set up the gstate
of a window, but this is a rather private reason. :-)

The graphics context will be selected when ever a view does a lock
focus. When this has happened everything will be as before, the context
returned by GSCurrentContext() will be the one for the active window.
The difference will only be when no view has locked focus. Then a
default context will be returned by this function. This context will
mostly be used by events. Drawing on the default context should be
regarded as an error. This may be a difference to the current state,
where this drawing is silently ignored.

Now, what is the real benefit of this change? It will allow us to
implement drawing for PS, PDF and bitmap output more easily. Our current PS solution works to a certain degree, but it is incompatible to MacOSX.

If nobody opposes this change, I will go ahead with it.

Cheers,
Fred






reply via email to

[Prev in Thread] Current Thread [Next in Thread]