Re: How to subclass Gtk::Bin



On 28/05/13 00:57, Maggio Mago wrote:
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.
what do you change child to ?? not many other widgets would have add1 and add2

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();
}


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


--

  .~.     In my life God comes first.... 
  /V\         but Linux is pretty high after that :-D
 /( )\    Francis (Grizzly) Smit
 ^^-^^    http://www.smit.id.au/


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