Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)

Paste

Pasted as C++ by registered user adam ( 15 years ago )
#include <gtkmm.h>

// GTKmm 2.4

using namespace Gtk;

class window : public Window
{
public:

    window()
    {
        set_title("Example");
        show_all_children();

        add_events(Gdk::BUTTON_PRESS_MASK);
        add_events(Gdk::POINTER_MOTION_MASK);
    }

private:
    int mouse_beg_x, mouse_beg_y;
    int win_pos_beg_x, win_pos_beg_y;

    bool on_button_press_event(GdkEventButton* event)
    {
        mouse_beg_x = event->x_root;
        mouse_beg_y = event->y_root;

        get_position(win_pos_beg_x, win_pos_beg_y);

        return true;
    }

    bool on_motion_notify_event(GdkEventMotion* event)
    {
        if (event->state & GDK_BUTTON1_MASK)
        {
            int x = win_pos_beg_x + (event->x_root - mouse_beg_x);
            int y = win_pos_beg_y + (event->y_root - mouse_beg_y);

            move(x, y);
        }
        return true;
    }
};

int main(int argc, char **argv)
{
    Gtk::Main kit(argc, argv);

    window win;
    Gtk::Main::run(win);

    return 0;
}

 

Revise this Paste

Your Name: Code Language: