• Uncategorized

About c++ : Detecting-when-a-window-is-resized-using-gtkmm

Question Detail

I am working with gtkmm 2.4 in Linux RHEL 6.

I have a class MyWindow that inherits from Gtk::Window.

I need to detect when MyWindow resizes.
The call back for this event resize the pixbufs and move the pixbuf/evenbox combination.
The pixbuf is the child of the eventbox. The call back is onresize_cb();

I am trying to use the signal_configure_event().

The code below will complie and run. When I try to resize the window, onresize_cb() is not excuting.
It does not display ” onresize_cb “.

What do I need to do to get onresize_cb() to excute?

MyClass.h

#include <gtkmm.h>

class MyClass : public Gtk::Window
{
public:
    
    MyClass();
    ~MyClass();

    static bool onresize_cb();

};

MyClass.cc

#include <iostream>

MyClass::MyClass()
{
    // Set up window
    set_position(Gtk::WIN_POS_CENTER); // positions the Gtk::Window to the WIN_POS_CENTER position

   add_events(Gtk::STRUCTURE_MASK);
   signal_configure_event().connect(sigc::ptr_fun(&onresize_cb));
}

MyClass::~MyClass()
{

}

bool MyClass::onresize_cb()
{
    std::cout << " onresize_cb " << std::endl;
    return true;
}

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.