discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Geometry problem


From: Kazunobu Kuriyama
Subject: Re: Geometry problem
Date: Wed, 25 Jun 2003 12:21:04 +0900
User-agent: Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.0.0) Gecko/20020614

Hi, Jeff.

I greatly appreciate your educational e-mail. In particular,
I believe the first half of the mail should be on a GNUstep tutorial
(especially for those who are familiar with Xlib and other GUI toolkits
which use freefall coordinates system.).

I have a few points to make sure. I would be deadly happy if you
could find time to reply to them.


Jeff Teunissen wrote:

 >>If Object A is a parent or ancestor of Object B (in a sense of
 >>window hierarchy), the answer may be easy.  I have no idea,
 >>however, if Object A is an instance of NSApplication.
 >>
 >
 >It's not, it's probably an instance of NSView (or one of its subclasses).
 >

Then, doesn't the top of the NSView tree play a special role like the
so-called shell widgets of Xt?

 >Every view has its own coordinate system. Every window has a "content
 >view", which takes up its entire displayable area (the window's border,
>etc. are owned by the window system/window manager and are, of course, not
 >part of this displayable area).

Does a 'window' simply mean a rectangular entity on a display's screen,
or an instance different from a view instance?

 >Note: coordinates are floating-point, and a coordinate system may be
 >modified, scaled, rotated, repositioned, etc. arbitrarily.

As such, we often need to round a floating-point to an integer.  Is there
a standard macro/inline function in the GNUstep libraries for this purpose?
Or is it left to programmer's preference?

 >You could create an unflipped view such that the origin is at the top
 >right (by translating the origin and rotating the coordinate system 180
>degrees, which will cause the contents to be upside-down and backwards; or >just by setting the bounds origin and using negative coordinates), or even
 >at the center of the view (by setting the bounds origin). In this case,
>negative coordinates are valid (they're already valid anyway, just clipped
 >to the view's visible bounds). This can make things interesting, as you
 >can probably imagine. :)

Then, I'm wondering if the region of a window that should be retained when
the window is resized (the so-called gravity in Xlib), changes depending
on a coordinates system I choose

 >
 >--->8---cut-here---8<---
 >
 >float i = 50; // down
 >float j = 50; // right
 >NSRect superFrame = [view frame]; // get the view's frame
 >NSSize mySize = NSMakeSize(100, 100); // size of my new view
 >NSRect myFrame;
 >
 >// make a rectangle describing where you want the view to be
 >// note: this is wrong if "view" is flipped
 >myFrame = NSMakeRect(superFrame.origin.x + j,
 >
            (superFrame.origin.y + superFrame.size.height)
 >
             - (i + mySize.height),
 >
             mySize.width,
 >
             mySize.height);
 >
 >myView = [[NSView alloc] initWithFrame: myFrame];
 >[view addSubview: myView];
 >
 >--->8---cut-here---8<---
 >
 >[snip]
 >
 >I hope I've gone some way in helping you to understand what you want. :)
 >

I fully understand.  Almost all ordinary people fail to understand
the code and absolutely get mad when they find out the meaning of it.

Thank you very much for sharing your precious time with me.

Kazunobu Kuriyama







reply via email to

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