From: luke@tfs.com (Luke Matam)
Newsgroups: fj.mail-lists.x-window
Subject: Re: Scrolling Bitmaps & All that jazz
Date: 26 Sep 92 11:49:07 GMT
Distribution: fj
Organization: TRW Financial Systems

Date: 25 Sep 92 21:13:58 GMT
Message-Id: <1992Sep25.211358.27834@tfs.com>
Newsgroups: comp.windows.x,comp.windows.x.motif

In article <1992Sep24.012247.10227@mprgate.mpr.ca> vli@mpr.ca (Vincent Li) writes:
>Hi there,
>  I got a couple questions which I think could be added to the FAQ if there's
>some good answers:
>1) I got this bitmap of the world and wants to plop in on a scrolling window.
>   I want to have the vertical & horizontal scroll bars so that if the user
>   resizes the window, my map size is not to change, but he can scroll to
>   see various parts of the world (or I might want to large enough map
>   for the user to see enough details, but is too large to fit on the
>   screen/window). Is it possible? I would think so. Seems like a straight
>   forward enough implementation. Has anyone done this before & how?
>

A XmScrolledWindow is the answer to the above. You can use drawing area widget
as the work window and the scrolled widget will do all the managing and scrolling


>2) OK, I could probably figure out 1) by myself. Now, to make thing more
>   interesting, I want the display the major cities of the world on my map.
>   Associated with each city displayed, I'd like the user to be able to click
>   on (possibly a button) the city and get more information about the city,
>   for example. How do I associate the cities with the user actions? button?
>   How do I scroll the buttons then? Or it is done by X? (I don't think that
>   would be the case, but I could be wrong.) If not buttons, how? X Y coord?
>   How do I know? (Not the X Y coord, but that a particular X Y coord means
>   a particular city at a particular time.) Remember, I want this whole thing
>   to be scrollable/panable. I suppose if I can scroll the city with the map,
>   knowing about the X/Y doesn't seem to be a big problem, but that's not
>   very appealing at all. Off the top of my head, buttons seems nice but
>   I'm not sure about the management of it all. (Seems like I might have
>   to change the display of the buttons & their position dynamically, as
>   the user scrolls & resize, etc)
>

Okay. So don't use a drawing area widget but instead use a form widget in
which you can place all these buttons, text and the world. When a user inputs
a data point your action routine will be called ... oh! I forgot to mention
that you need to use translations with the form. The coordinates given to your
action routine will be compensated for scrolling so you don't have to worry.

>3) What if now I want to add some "connections" between the cities, such as
>   plane routes between the cities, say, and possibly display of some critical
>   data along side these routes, like flight number, eta, etc. Again, how
>   do I handle the scrolling? Will it be done for me once I've drawn it on
>   the window? And what if I want to dynamically change the colour, line
>   type, etc. of the connections --- individually.
>

When you get expose events, then events are in world coordinates (in the
coordinates of the form, which is good). You will  need the ability to update
any part of your world when the expose arrives.


That's about it.

Confession: I did not use the XmScrolledWindow; However I implemented a widget
which does something like the above, based on the Viewport widget of the
Athena Widget set.

-- 
+-----------------------------------------------------------------------------+
| These are my opinions and that too only at this instant in time.            |
+-----------------------------------------------------------------------------+
| Luke S Matam                                            luke@tfs.com        |