[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [paragui-users] questions about paragui
From: |
Ulf Lorenz |
Subject: |
Re: [paragui-users] questions about paragui |
Date: |
Wed, 16 Feb 2005 14:48:36 +0100 |
User-agent: |
Mutt/1.5.6+20040907i |
On Mon, Feb 14, 2005 at 09:30:16AM -0800, bogdan wrote:
> I'm thinking to use paragui for an embedded
> application and I'm not sure if paragui can be used
> for this.
>
> The main requirements would be: threadsafe, control
> the GUI only with few keys and to have an option to
> display the user interface rotated with 90 degrees
> (infact the device can stand vertical or horizontal
> while the user has a "vertical" GUI).
>
> For the first issue I've found the answer reading the
> highlights of the library.
>
> The second requirement will suffice if I'll be able to
> send messages/signals/etc to widgets. I.e. I could
> focus, push, select buttons, lists, windows only by
> sending messages; is it possible?
I think, yes. I don't know exactly how this would be done, but in
principle I think there are two ways:
1. Either there is some way to translate the keys into "normal" kernel
events, i.e. you press key a and the kernel outputs a "Z" keyboard
pressing event. This one is cleaner, but I don't know much about
embedded applications, so maybe this is not available.
2. paragui uses the event mechanism of SDL; the basic loop just gets the
next event in the queue and handles it. SDL itself provides a means
to add events to the queue. The function is called SDL_PushEvent and
defined in SDL_events.h. This is a bit messy, because you have to
create the events yourself and such, but using this, you can emulate
everything you want. The paragui classes then allow to react on e.g.
keypresses, mouse clicks etc.
> For the rotated display maybe the answer lies in SDL,
> but any suggestion would be appreciated.
I suppose you don't have an X running, that happens to support
rotation...
Then the answer is: Yes, but this is really messy. I haven't done
something like this yet, so this is just a guess. What you need to do
is:
0. In pgdraw.h, a function RotoScaleSurface is defined. This function
takes a surface, rotates it by an angel, and returns the rotated
surface. So in principle, rotation is possible.
IF your application does not allow mouse motion, but just has some keys
where you select e.g. "push this button" or "select the next button",
so that you DON'T have to translate mouse coordinates to handle click
events, THEN you can do the following:
1. Drawing in paragui works like this: The parent widget (e.g. a dialog)
has a surface and demands of all child widgets (e.g. edit fields or
buttons) to draw themselves at their position on its surface.
2. On the other hand, it is possible to overwrite the drawing code
(PG_Widget::eventDraw) using an own surface (i.e. create a widget
with an internal surface, see PG_Widget constructor).
3. Now in combination with the RotoScaleSurface function, you could
derive an own RotoWidget from PG_Widget and write in the eventDraw
function basically something like this:
RotoWidget::eventDraw(SDL_Surface* s, PG_Rect& r)
{
// should draw all child widgets on the surface (I hope :))
PG_Widget::eventDraw(s, r);
// Rotate the appearance by 90 degrees, zoom factor 1
SDL_Surface* temp = RotoScaleSurface(s, 90, 1);
// Copy the temporary surface and dispose of it
SDL_BlitSurface(temp, 0, s, 0);
SDL_FreeSurface(temp);
}
Uses a lot of ressources, is slow, and I am not really sure if it
works (something in this way _should_ work, however). The ressource
use could be decreased by tweaking the paragui draw code, but I
suppose this is out of scope here.
I hope this helps a bit.
Ulf
--
recursive:
see recursive