paragui-users
[Top][All Lists]
Advanced

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

[paragui-users] Fwd: [support #102337] auto-resize for widgets


From: Alexander Pipelka
Subject: [paragui-users] Fwd: [support #102337] auto-resize for widgets
Date: Fri, 8 Aug 2003 09:23:42 +0200
User-agent: KMail/1.5.3

-- 
Alexander Pipelka
BMS Bayer GmbH
Thimiggase 35/12
1180 Wien

Tel: +43 1 5248134
www.bms-austria.com
--- Begin Message --- Subject: [support #102337] auto-resize for widgets Date: Thu, 07 Aug 2003 20:09:43 -0400 User-agent: Mozilla/5.0 (X11; U; Linux i686) Gecko/20030714 Galeon/1.3.5 Debian/1.3.5.20030714-3

Support Request #102337, was updated on Fri 08/08/03 at 00:09
You can respond by visiting: 
http://savannah.nongnu.org/support/?func=detailsupport&support_id=102337&group_id=1830

Category: None
Status: Open
Priority: 5
Summary: auto-resize for widgets

By: mpComplete
Date: Fri 08/08/03 at 00:09
Logged In: YES 
user_id=21640
Browser: Mozilla/5.0 (X11; U; Linux i686) Gecko/20030714 Galeon/1.3.5 
Debian/1.3.5.20030714-3

I'm writing a game in ParaGUI, and I've found it very
useful to be able to resize widgets automatically.  I
have a parent widget that takes up the whole screen,
and child widgets are embedded in it.  When I resize
the screen, I call widget_zoom() on my parent widget,
and it automatically resizes every widget on the
screen.  I've posted it here in case anyone might find
it useful (maybe even to be included in ParaGUI?). 
It's not perfect - rounding errors accumulate if you
resize too much, and things look a little off.  But it
serves pretty well in normal use.

void widget_zoom(PG_Widget *widget, double zoomx,
double zoomy)
{
    int px=0, py=0;

    if (widget->GetParent()) {
        px = widget->GetParent()->x;
        py = widget->GetParent()->y;
    }

    PG_Rect r(
            px + int((widget->x-px) * zoomx + 0.5),
            py + int((widget->y-py) * zoomy + 0.5),
            int(widget->w * zoomx + 0.5),
            int(widget->h * zoomy + 0.5));

    widget->MoveRect(r.x, r.y);
    widget->SizeWidget(r.w, r.h);

    PG_RectList *children = widget->GetChildList();
    if (children) {
        PG_RectList::iterator it;
        for (it = children->begin(); it != children->end();
it++) {
            widget_zoom(*it, zoomx, zoomy);
        }
    }
}

----------------------------------------------------------------------
You can respond by visiting: 
http://savannah.nongnu.org/support/?func=detailsupport&support_id=102337&group_id=1830

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


--- End Message ---

reply via email to

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