Re: Custom widget draw
- From: "Yuriy Rusinov" <yrusinov gmail com>
- To: "Larik Ishkulov" <gentro etersoft ru>
- Cc: gtkmm-list gnome org
- Subject: Re: Custom widget draw
- Date: Sat, 1 Nov 2008 11:04:23 +0300
Hello !
>
> Hi,
>
> I didn'n clearly understand what you mean. Do you call show_all() or show() on
> added widgets? How are you doing your drawing?
>
OK, here is my expose event slot
bool MyWidget :: on_expose_event (GdkEventExpose* event)
{
if (pRefGdkWindow)
{
int width = get_allocation().get_width();
int height = get_allocation().get_height();
double scale_x = (double)width/ scale;
double scale_y = (double)height / scale;
Cairo::RefPtr<Cairo::Context> cr =
pRefGdkWindow->create_cairo_context();
if (event)
{
// clip to the area that needs to be re-exposed so we don't draw any
// more than we need to.
cr->rectangle (event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
std::cout << __FUNCTION__ << " expose_event" << std::endl;
}
//
// Paint the background
//
Gdk::Cairo::set_source_color (cr, get_style()->get_bg
(Gtk::STATE_NORMAL));
cr->paint ();
//
// Paint the foreground
//
Gdk::Cairo::set_source_color (cr, get_style()->get_fg
(Gtk::STATE_NORMAL));
//cr->move_to (get_allocation().get_width()/2,
get_allocation().get_height()/2);
cr->save ();
cr->translate (width/2.0, height/2.0);
double radius = width < height ? width-40 : height-40;
radius /= 2.0;
cr->scale (radius, radius);
cr->arc (0.0, 0.0, 1.0, 0.0, 2 * pi);
cr->arc_negative (0.0, 0.0, 1.0, 0.0, 2 * pi);
cr->fill ();
cr->restore ();
cr->stroke ();
}
//
// Base class call
//
Gtk::Frame::on_expose_event (event);
vBox0->show_all_children ();
hBoxUp->show_all_children ();
return true;
}
--
Best regards,
Sincerely yours,
Yuriy Rusinov.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]