void MyWidget::on_realize() { //Do not call base class Gtk::Widget::on_realize(). //It's intended only for widgets that set_has_window(false). set_realized(); //Get the themed style from the CSS file: get_style_property("example_scale", m_scale); std::cout << "m_scale (example_scale from the theme/css-file) is: " << m_scale << std::endl; if(!m_refGdkWindow) { //Create the GdkWindow: GdkWindowAttr attributes; memset(&attributes, 0, sizeof(attributes)); Gtk::Allocation allocation = get_allocation(); //Set initial position and size of the Gdk::Window: attributes.x = allocation.get_x(); attributes.y = allocation.get_y(); attributes.width = allocation.get_width(); attributes.height = allocation.get_height(); attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; m_refGdkWindow = Gdk::Window::create(get_parent_window(), &attributes, GDK_WA_X | GDK_WA_Y); set_window(m_refGdkWindow); //set colors override_background_color(Gdk::RGBA("red")); override_color(Gdk::RGBA("blue")); //make the widget receive expose events m_refGdkWindow->set_user_data(gobj()); } }
/** * Does something when the block bar is realized. */ void GtkBlockBar::on_realize() { //Do not call base class Gtk::Widget::on_realize(). //It's intended only for widgets that set_has_window(false). set_realized(); if(!m_refGdkWindow) { //Create the GdkWindow: GdkWindowAttr attributes; memset(&attributes, 0, sizeof(attributes)); Gtk::Allocation allocation = get_allocation(); //Set initial position and size of the Gdk::Window: attributes.x = allocation.get_x(); attributes.y = allocation.get_y(); attributes.width = allocation.get_width(); attributes.height = allocation.get_height(); attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; m_refGdkWindow = Gdk::Window::create(get_parent_window(), &attributes, GDK_WA_X | GDK_WA_Y); set_window(m_refGdkWindow); //set colors TODO //override_background_color(Gdk::RGBA("red")); //override_color(Gdk::RGBA("green")); //make the widget receive expose events m_refGdkWindow->set_user_data(gobj()); } }