paragui-users
[Top][All Lists]
Advanced

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

[paragui-users] Can't load child buttons in running time


From: Alejandro Garcia
Subject: [paragui-users] Can't load child buttons in running time
Date: Tue, 23 Apr 2002 01:02:58 +0200

Hi all.
I'm new at paragui and trying to use it. I'm in a doubt.
How could I make appear a widget loaded into another one 
who is currently being showed?

I got a PG_ThemeWidget object in my screen and would like 
to arrange some buttons in it but don't know how.

My code compiles with no error but I get no button.

This is what I did:

#include "pgapplication.h"
#include "pgthemewidget.h"
#include "pgbutton.h"
#include "pgeventobject.h"

class MyObject: public PG_EventObject, public PG_Widget{
public:
        MyObject(PG_Widget* parent,int id, PG_Rect r, char* 
caption);
        ~MyObject();

        PG_Button* btnMObj;
private:
        int x;
        int y;
};

MyObject :: MyObject(PG_Widget* parent, int id, PG_Rect r, 
char* caption) : PG_Widget(parent, r){
        x= r.w;
        y= r.h;
        PG_Button* tempButton= new PG_Button(parent, id, r, 
caption);
        btnMObj= tempButton;
}

MyObject :: ~MyObject(){
}

class Panel : public PG_ThemeWidget{
        public:
                Panel(PG_Widget *parent,int id, PG_Rect rect);
                void addObject(MyObject *anObject);
};

Panel::Panel(PG_Widget *parent, int id, PG_Rect rect) : 
PG_ThemeWidget(parent, rect, true){
}

void Panel:: addObject(MyObject *anObject){
        AddChild(anObject);
        Redraw();
}


int main(int argc, char* argv[]) {

        PG_Application *app;
        Panel *aPanel;
        MyObject *thisObject;

        app= new PG_Application();
        app->SetEmergencyQuit(true);
        app->LoadTheme("default");
        app->InitScreen(800, 600, 16, SDL_SWSURFACE);

        aPanel = new Panel(NULL, 1001, PG_Rect(400,100,350,250));
        aPanel-> Show();

        thisObject = new MyObject(aPanel, 777, PG_Rect(10, 25, 
140, 20), "In main");
        aPanel->addObject(thisObject);

        app->Run();
        return 0;
}




reply via email to

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