I want to draw a line on a gtkmm widget of blue color. That widget has some background color. When I draw over that widget, then the background color and blue color gets mixed to give some other color. How can I draw the line with the blue color. I'm modifying the expose event. This is a custom widget, and m_refGdkWindow represents the GdkWindow of the widget.
Code:
bool gtk_vbox::on_expose_event(GdkEventExpose* event)
{
//std::cout<<"Widget_expose_event"<<std::endl;
if(m_refGdkWindow)
{
Cairo::RefPtr<Cairo::Context> cr = m_refGdkWindow->create_cairo_context();
//std::cout<<"X"<<event->area.x<<"Y"<<event->area.y<<std::endl;
if(event)
{
cr->rectangle(event->area.x,event->area.y,event->area.width,event->area.height);
cr->clip();
}
Gdk::Cairo::set_source_color(cr,get_style()->get_bg(Gtk::STATE_NORMAL));
cr->paint();
///Here's the drawing code
Gdk::Cairo::set_source_color(cr,Gdk::Color("blue"));
for(int i = 0;i<4;i++)
{
if(lines_draw_array[i]&&lines_draw_array[i]->width!=-1)
{
cr->set_line_width(lines_draw_array[i]->width);
cr->move_to(lines_draw_array[i]->x1,lines_draw_array[i]->y1);
cr->line_to(lines_draw_array[i]->x2,lines_draw_array[i]->y2);
cr->stroke();
}
}
/////////////------------------------------
Gdk::Cairo::set_source_color(cr,Gdk::Color("white"));
cr->set_line_width(0.5);
int i=0,j=0;
int height = get_height();
int width = get_width();
for(i=10;i<height;i+=10)
{
cr->move_to(0,i);
cr->line_to(width,i);
}
for(j=10;j<width;j+=10)
{
cr->move_to(j,0);
cr->line_to(j,height);
}
cr->stroke();
cr->set_line_width(1.0);
Gdk::Cairo::set_source_color(cr,Gdk::Color("black"));
if(number_of_widgets!=slots)
{
//std::cout<<"NUMBER OF WIDGETS != SLOTS"<<std::endl;
int height_of_slot = get_height()/slots;
//std::cout<<"slots"<<slots<<"heightofslot"<<height_of_slot<<std::endl;
//std::cout<<"spacing"<<spacing<<std::endl;
for(int i=1;i<slots;i++)
{
cr->move_to(0,i*height_of_slot);
cr->line_to(get_width(),i*height_of_slot);
}
}
cr->stroke();
}
if(event)
Gtk::Container::on_expose_event(event);
return false;
}