Re: Can I stop events for a while ??
- From: Bob Caryl <bob fis-cal com>
- To: Sergio Trinidad <strinidadr gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Can I stop events for a while ??
- Date: Thu, 15 Dec 2005 09:37:52 -0600
Creating another function to modify the font and calling it from the
on_size_allocate override will prevent the endless loop, but the
practical results are not too good. The label font gets very large very
fast. This is probably a dreadful idea.
Example code follows:
// code starts
class miMaquina : public VBox
{
miMaquina(bool homogeneous,int spacing) {
Gtk::VBox::VBox(homogeneous,spacing); no_resize = FALSE; }
Gtk::Label *lbl;
protected:
bool no_resize;
resize_font(int height);
on_size_allocate(Gtk::Allocation &alloc);
}
void miMaquina::resize_font(int height)
{
no_resize = TRUE; // setting this to true before modifying
// the font will prevent the
on_size_allocate
// override from calling this
function repeatedly.
Pango::FontDescription fd;
fd.set_size((height * Pango::SCALE));
lbl->modify_font(fd);
}
void miMaquina::on_size_allocate(Gtk::Allocation &alloc)
{
int alto = alloc.get_height();
Gtk::VBox::on_size_allocate(alloc);
if(no_resize)
{
no_resize = FALSE;
return;
}
resize_font(alto);
}
// code ends
Oh yeah, be sure to set miMaquina::lbl to point to whatever label you
are packing into your miMaquina instance.
Bob
Sergio Trinidad wrote:
> I have the next code
>
> class miMaquina : public VBox
> {
> Gtk:Label *lbl;
> .....
>
> };
> ....
> ....
>
> void miMaquina::on_size_allocate(Gtk::Allocation &alloc)
> {
> int alto = alloc.get_height();
> int ancho = alloc.get_width();
> Gtk::VBox::on_size_allocate(alloc);
>
> Pango::FontDescription fd;
> fd.set_size((alto*Pango::SCALE));
> lbl->modify_font(fd);
>
> }
>
>
> The problem is that when the events ocurrs the lbl->modify_font(fd)
> activates
> a new on_size_allocate event, because the size of label changes with
> the size
> of new text, and a infinite loop is launchet until X server gets an
> error.
> Can I stop signal emiting for a while, then apply 'lbl->modify_font'
> and later
> activate again the event??
>
>------------------------------------------------------------------------
>
>_______________________________________________
>gtkmm-list mailing list
>gtkmm-list gnome org
>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]