Drawing in a window-less widget



Hello all,
I have a custom container widget (derived from Gtk::Container) which is somewhat similar to a toolbar. I am declaring the widget as windowless in the class constructor by set_flags(Gtk::NO_WINDOW). Later in ::on_realize of my class I do the following.
void CInlineMenu::on_realize()
{
    GdkWindowAttr stWndAttrib;
    Gtk::Allocation obAlloc;

    //Call base class
    Gtk::Container::on_realize();

    if(!m_refWnd)
    {
        //Get size allocation
        obAlloc = get_allocation();

        //Set window attributes
        stWndAttrib.x = obAlloc.get_x();
        stWndAttrib.y = obAlloc.get_y();
        stWndAttrib.width = obAlloc.get_width();
        stWndAttrib.height = obAlloc.get_height();

        stWndAttrib.event_mask = Gdk::EXPOSURE_MASK;
        stWndAttrib.window_type = GDK_WINDOW_CHILD;
        stWndAttrib.wclass = GDK_INPUT_OUTPUT;
        stWndAttrib.type_hint = GDK_WINDOW_TYPE_HINT_DOCK;

        //Create a window
        m_refWnd = Gdk::Window::create(get_window(), &stWndAttrib, GDK_WA_X | GDK_WA_Y);
        //unset_flags(Gtk::NO_WINDOW);
        //set_window(m_refWnd);
        m_refWnd->set_user_data(gobj());
    }
}

Within this container I will be having multiple windowed widgets like buttons. Now when I run  my application the child widgets are visible but the drawing what I do within the on_expose_event override of my class is not appearing on screen, which I believe is because I created my widget window-less.

Now the million dollar question is how to draw something from this class. Is it even possible or do I need to reconsider I realize my widget?


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