|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
NSTableView, rows in reverse orderHi all,
I've come across something where I'm not sure if it's a bug or a feature. The following code fragment draws an existing tableview into a bitmap, for later export as TIFF and conversion to PostScript. NSRect box = [table bounds], hbox = [[table headerView] bounds]; NSRect winrect = box; winrect.size.height += hbox.size.height; NSWindow *win = [[NSWindow alloc] initWithContentRect:winrect styleMask:0 backing:NSBackingStoreRetained defer:NO]; [[win contentView] lockFocus]; [table drawRect:box]; [NSGraphicsContext saveGraphicsState]; PStranslate(0, box.size.height); [[table headerView] drawRect:hbox]; [NSGraphicsContext restoreGraphicsState]; NSBitmapImageRep *boxRep = [NSBitmapImageRep alloc]; [boxRep initWithFocusedViewRect:[[win contentView] bounds]]; AUTORELEASE(boxRep); [[win contentView] unlockFocus]; I guess I could replace the last "[[win contentView] bounds]" with "winrect" but that's not relevant here. The phenomenon I'm observing is that the tableview draws the rows in reverse order, from bottom to top instead of from top to bottom. So the output does not match what the user sees on screen. The row that comes first on screen is drawn last in the bitmap. Curious, to say the least. Best regards, Marko +-------------------------------------------------------------+ | Marko Riedel, EDV Neue Arbeit gGmbH, markoriedelde@... | | http://www.geocities.com/markoriedelde/index.html | +-------------------------------------------------------------+ __________________________________________________________ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
|
|
Re: NSTableView, rows in reverse orderI think what you are seeing is the correct behaviour. It should even be the same on MacOSX, but I am unable to test at the moment.
What happens is that you draw into a view you just created and this view isn't flipped, whereas an NSTableView is flipped. That way the rows show up in the wrong order. You should be able to correct this by using a flipped view instead. My main question to you code is different, why are you doing it that way after all? Why don't you just ask the NSTableView for a PS representation? I am not saying this will be working completely correct, but it surely is better to go in that direction and fix any problems you encounter. Fred -------- Original-Nachricht -------- > Datum: Wed, 23 Jul 2008 22:48:41 +0000 (GMT) > Von: Marko Riedel <markoriedelde@...> > An: DISCUSS GNUstep <discuss-gnustep@...> > Betreff: NSTableView, rows in reverse order > Hi all, > > I've come across something where I'm not sure if it's a bug or a feature. > > The following code fragment draws an existing tableview into a bitmap, for > later export as TIFF and conversion to PostScript. > > NSRect box = [table bounds], > hbox = [[table headerView] bounds]; > > NSRect winrect = box; > winrect.size.height += hbox.size.height; > > NSWindow *win = > [[NSWindow alloc] > initWithContentRect:winrect > styleMask:0 > backing:NSBackingStoreRetained > defer:NO]; > > [[win contentView] lockFocus]; > > [table drawRect:box]; > > [NSGraphicsContext saveGraphicsState]; > > PStranslate(0, box.size.height); > [[table headerView] drawRect:hbox]; > > [NSGraphicsContext restoreGraphicsState]; > > NSBitmapImageRep > *boxRep = [NSBitmapImageRep alloc]; > [boxRep > initWithFocusedViewRect:[[win contentView] bounds]]; > AUTORELEASE(boxRep); > > [[win contentView] unlockFocus]; > > I guess I could replace the last "[[win contentView] bounds]" with > "winrect" but that's not relevant here. > > The phenomenon I'm observing is that the tableview draws the rows in > reverse order, from bottom to top instead of from top to bottom. So the output > does not match what the user sees on screen. The row that comes first on > screen is drawn last in the bitmap. > > Curious, to say the least. > > Best regards, > > Marko > > > +-------------------------------------------------------------+ > | Marko Riedel, EDV Neue Arbeit gGmbH, markoriedelde@... | > | http://www.geocities.com/markoriedelde/index.html | > +-------------------------------------------------------------+ > > > __________________________________________________________ > Gesendet von Yahoo! Mail. > Dem pfiffigeren Posteingang. > http://de.overview.mail.yahoo.com > > > _______________________________________________ > Discuss-gnustep mailing list > Discuss-gnustep@... > http://lists.gnu.org/mailman/listinfo/discuss-gnustep -- GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion! http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196 _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
|
|
Re: NSTableView, rows in reverse orderHello there, thanks for your reply. I tried your suggestion and ran into a problem: the table does not include the table header in the data for dataWithEPSInsideRect: So I had to get those data separately, but I don't know how to merge them properly. If I just concatenate them, then the bounding box for the whole is wrong and the header obscures part of the first row. The previous version (the one you commented on) uses ImageMagick to create a PS file for printing. It looks like I won't be able to avoid using it after all. I could assemble the two EPS files (header + table) using Magick, but then I may as well stay with the old approach. So I guess I will try to find out how to flip views properly so that the rows do not show up in reverse when I draw into a bitmap. What's your take on this? Of course if I could get header + table in one EPS file, that would be very nice. Best regards, +-------------------------------------------------------------+ | Marko Riedel, EDV Neue Arbeit gGmbH, markoriedelde@... | | http://www.geocities.com/markoriedelde/index.html | +-------------------------------------------------------------+ __________________________________________________________ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
|
|
Re: NSTableView, rows in reverse orderMarko Riedel wrote:
> thanks for your reply. I tried your suggestion and ran into a > problem: the table does not include the table header in the data for > dataWithEPSInsideRect: So I had to get those data separately, but I > don't know how to merge them properly. If I just concatenate them, > then the bounding box for the whole is wrong and the header obscures > part of the first row. > Not sure why this should happen, are you certain to pass in the correct rectangle? As far as I remember there is no special handling for printing in NSTableView that would switch off the header. What you could always try is to print a super view of the table, that definitly should include everything. > The previous version (the one you commented on) uses ImageMagick to > create a PS file for printing. It looks like I won't be able to avoid > using it after all. I could assemble the two EPS files (header + > table) using Magick, but then I may as well stay with the old > approach. > > So I guess I will try to find out how to flip views properly so that > the rows do not show up in reverse when I draw into a bitmap. > That is easy, just create a subclass of NSView and let the isFlipped method return true. > What's your take on this? Of course if I could get header + table in > one EPS file, that would be very nice. > I would prefer this solution, as it helps to improve GNUstep printing. Fred _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
|
|
Re: NSTableView, rows in reverse orderHi there,
just a quick reply -- I'm in a hurry. Thanks for all your help so far. I am definitely certain that I have the right rectangle. (I am using [table bounds].) Your suggestion re. the superview is tricky. It's a clip view inside a scroll view. It does include the header in its EPS, but it only prints the visible portion (which depends on how the user has sized tbe window). Best regards, +-------------------------------------------------------------+ | Marko Riedel, EDV Neue Arbeit gGmbH, markoriedelde@... | | http://www.geocities.com/markoriedelde/index.html | +-------------------------------------------------------------+ --- Fred Kiefer <fredkiefer@...> schrieb am Do, 24.7.2008: > Von: Fred Kiefer <fredkiefer@...> > Betreff: Re: NSTableView, rows in reverse order > An: markoriedelde@... > CC: discuss-gnustep@... > Datum: Donnerstag, 24. Juli 2008, 19:41 > Marko Riedel wrote: > > thanks for your reply. I tried your suggestion and ran > into a > > problem: the table does not include the table header > in the data for > > dataWithEPSInsideRect: So I had to get those data > separately, but I > > don't know how to merge them properly. If I just > concatenate them, > > then the bounding box for the whole is wrong and the > header obscures > > part of the first row. > > > > Not sure why this should happen, are you certain to pass in > the correct > rectangle? As far as I remember there is no special > handling for > printing in NSTableView that would switch off the header. > What you could always try is to print a super view of the > table, that > definitly should include everything. > > > > The previous version (the one you commented on) uses > ImageMagick to > > create a PS file for printing. It looks like I > won't be able to avoid > > using it after all. I could assemble the two EPS files > (header + > > table) using Magick, but then I may as well stay with > the old > > approach. > > > > So I guess I will try to find out how to flip views > properly so that > > the rows do not show up in reverse when I draw into a > bitmap. > > > > That is easy, just create a subclass of NSView and let the > isFlipped > method return true. > > > What's your take on this? Of course if I could get > header + table in > > one EPS file, that would be very nice. > > > > I would prefer this solution, as it helps to improve > GNUstep printing. > > Fred __________________________________________________________ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
|
|
Re: NSTableView, rows in reverse orderHello again,
you write "As far as I remember there is no special handling for printing in NSTableView that would switch off the header." Are your sure? I have not looked at the source code, but there must be special code to handle tables in scroll views. The header view needs to always stay in place instead of scrolling out of sight. If you look carefully you see that that is no ordinary table view inside the scroll view. It is separated from the header, which is above the scrolling area. Have I got this right? Marko +-------------------------------------------------------------+ | Marko Riedel, EDV Neue Arbeit gGmbH, markoriedelde@... | | http://www.geocities.com/markoriedelde/index.html | +-------------------------------------------------------------+ --- Fred Kiefer <fredkiefer@...> schrieb am Do, 24.7.2008: > Von: Fred Kiefer <fredkiefer@...> > Betreff: Re: NSTableView, rows in reverse order > An: markoriedelde@... > CC: discuss-gnustep@... > Datum: Donnerstag, 24. Juli 2008, 19:41 > Marko Riedel wrote: > > thanks for your reply. I tried your suggestion and ran > into a > > problem: the table does not include the table header > in the data for > > dataWithEPSInsideRect: So I had to get those data > separately, but I > > don't know how to merge them properly. If I just > concatenate them, > > then the bounding box for the whole is wrong and the > header obscures > > part of the first row. > > > > Not sure why this should happen, are you certain to pass in > the correct > rectangle? As far as I remember there is no special > handling for > printing in NSTableView that would switch off the header. > What you could always try is to print a super view of the > table, that > definitly should include everything. > > > > The previous version (the one you commented on) uses > ImageMagick to > > create a PS file for printing. It looks like I > won't be able to avoid > > using it after all. I could assemble the two EPS files > (header + > > table) using Magick, but then I may as well stay with > the old > > approach. > > > > So I guess I will try to find out how to flip views > properly so that > > the rows do not show up in reverse when I draw into a > bitmap. > > > > That is easy, just create a subclass of NSView and let the > isFlipped > method return true. > > > What's your take on this? Of course if I could get > header + table in > > one EPS file, that would be very nice. > > > > I would prefer this solution, as it helps to improve > GNUstep printing. > > Fred > > > _______________________________________________ > Discuss-gnustep mailing list > Discuss-gnustep@... > http://lists.gnu.org/mailman/listinfo/discuss-gnustep __________________________________________________________ Unglücklich mit Ihrer Mail-Adresse? Millionen neuer Mail-Adressen - jetzt bei Yahoo! http://de.docs.yahoo.com/mail/wunschmailadresse/index.html _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
|
|
Re: NSTableView, rows in reverse orderMarko Riedel wrote:
> I am definitely certain that I have the right rectangle. (I am > using [table bounds].) Your suggestion re. the superview is > tricky. It's a clip view inside a scroll view. It does include the > header in its EPS, but it only prints the visible portion (which > depends on how the user has sized tbe window). You might try creating an off-screen window containing only a table view that is large enough to show all data of the table, copy the original table's data into the new window, and then print the off- screen window's content. Wolfgang _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@... http://lists.gnu.org/mailman/listinfo/discuss-gnustep |
| Free Forum Powered by Nabble | Forum Help |