How to subclass Gtk::Bin



Hello,

I am extending a Gtk::Bin with a Gtk::Label like child, it seem work (with the code below "-------" ). But When i try to change the type of child nothing appears.

Can you help me to fixe this.

class Timeline : public Gtk::Bin
{
public:
Timeline();
protected:
virtual void on_size_allocate(Gtk::Allocation &allocation);
};


Timeline::Timeline() :
Gtk::Bin()
{
Gtk::Paned* child = new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL);
Gtk::Frame* frame = new Gtk::Frame("Main");
Gtk::Label* label = new Gtk::Label("A long Label ...");
paned->add1(*frame);
paned->add2(*label);
add(*child);
}
void Timeline::on_size_allocate(Gtk::Allocation &allocation)
{
Gtk::Bin::on_size_allocate(allocation);
get_child()->set_allocation(allocation);
}


--------------------------------------------------------------------------------------------

class Timeline : public Gtk::Bin
{
public:
Timeline();
protected:
virtual void on_size_allocate(Gtk::Allocation &allocation);
};


Timeline::Timeline() :
Gtk::Bin()
{
Gtk::Label* child = new Gtk::Label("It Works!");
add(*child);
}
void Timeline::on_size_allocate(Gtk::Allocation &allocation)
{
Gtk::Bin::on_size_allocate(allocation);
get_child()->set_allocation(allocation);
}


ExampleWindow::ExampleWindow() : Gtk::Window()
{
Timeline* myWidget = new Timeline();
add(myWidget);

show_all();
}


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