void MyWidget::on_size_allocate(Gtk::Allocation& allocation) { //Do something with the space that we have actually been given: //(We will not be given heights or widths less than we have requested, though //we might get more) //Use the offered allocation for this container: set_allocation(allocation); if(m_refGdkWindow) { m_refGdkWindow->move_resize( allocation.get_x(), allocation.get_y(), allocation.get_width(), allocation.get_height() ); } }
/** * Does something with the space that we have actually been given. */ void GtkBlockBar::on_size_allocate(Gtk::Allocation& allocation) { // //(We will not be given heights or widths less than we have requested, though //we might get more) //Use the offered allocation for this container: set_allocation(allocation); if(m_refGdkWindow) { m_refGdkWindow->move_resize( allocation.get_x(), allocation.get_y(), allocation.get_width(), allocation.get_height() ); } }
void OSGDrawingArea::on_size_allocate (Gtk::Allocation& pAllocation) { #ifdef DEBUG //??std::cout <<"void OSGDrawingArea::on_size_allocate (Gtk::Allocation& pAllocation)<<"<< std::endl; #endif set_allocation (pAllocation); if (is_realized ()) { get_window ()->move_resize (pAllocation.get_x (), pAllocation.get_y (), pAllocation.get_width (), pAllocation.get_height ()); }//if #ifdef DEBUG //??std::cout <<"void OSGDrawingArea::on_size_allocate (Gtk::Allocation& pAllocation)>>"<< std::endl; #endif }
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()); } }
bool Liveplay::window_expose_event(GdkEventExpose *event) { Cairo::RefPtr<Cairo::Context> cr = Glib::wrap(event->window, true)->create_cairo_context(); Gtk::Allocation a = liveplay_canvas->get_allocation(); Gdk::Region region(a); region.intersect(Glib::wrap(event->region, true)); Gdk::Cairo::add_region_to_path(cr, region); cr->clip(); cr->set_operator(Cairo::OPERATOR_SOURCE); cr->set_source_rgb(0,0,0); cr->paint(); //gdk_cairo_set_source_window(cr->cobj(), liveplay_canvas->get_window()->gobj(), a.get_x(), a.get_y()); gtk 2.24 gdk_cairo_set_source_pixmap(cr->cobj(), liveplay_canvas->get_window()->gobj(), a.get_x(), a.get_y()); cr->paint_with_alpha(pow(brightness_adj->get_value(),2.2)); return false; }