コード例 #1
0
ファイル: handle_ops.c プロジェクト: UIKit0/dia
void
handle_draw(Handle *handle, DDisplay *ddisp)
{
  gboolean some_selected;
  int x,y;
  DiaRenderer *renderer = ddisp->renderer;
  DiaInteractiveRendererInterface *irenderer =
    DIA_GET_INTERACTIVE_RENDERER_INTERFACE (ddisp->renderer);
  const Color *color;

  ddisplay_transform_coords(ddisp, handle->pos.x, handle->pos.y, &x, &y);
  /* change handle color to reflect different behaviour for multiple selected */
  /* this code relies on the fact that only selected objects get their handles drawn */
  some_selected = g_list_length (ddisp->diagram->data->selected) > 1;

  if  (handle->connected_to != NULL) {
    color = &handle_color_connected[handle->type + (some_selected ? NUM_HANDLE_TYPES : 0)];
  } else {
    color = &handle_color[handle->type + (some_selected ? NUM_HANDLE_TYPES : 0)];
  }

  DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, 0.0);
  DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID);
  DIA_RENDERER_GET_CLASS(renderer)->set_linejoin(renderer, LINEJOIN_MITER);
  DIA_RENDERER_GET_CLASS(renderer)->set_fillstyle(renderer, FILLSTYLE_SOLID);
  

  irenderer->fill_pixel_rect(renderer,
			     x - HANDLE_SIZE/2 + 1,
			     y - HANDLE_SIZE/2 + 1,
			     HANDLE_SIZE-2, HANDLE_SIZE-2,
			     /* it does not change the color, but does not reflect taht in the signature */
			     (Color *)color);
  
  irenderer->draw_pixel_rect(renderer,
			     x - HANDLE_SIZE/2,
			     y - HANDLE_SIZE/2,
			     HANDLE_SIZE-1, HANDLE_SIZE-1,
			     &color_black);

    
  
  if (handle->connect_type != HANDLE_NONCONNECTABLE) {
    irenderer->draw_pixel_line
                         (renderer,
			  x - HANDLE_SIZE/2, y - HANDLE_SIZE/2,
			  x + HANDLE_SIZE/2, y + HANDLE_SIZE/2,
			  &color_black);
    irenderer->draw_pixel_line
                         (renderer,
			  x - HANDLE_SIZE/2, y + HANDLE_SIZE/2,
			  x + HANDLE_SIZE/2, y - HANDLE_SIZE/2,
			  &color_black);
  }
}
コード例 #2
0
ファイル: display.c プロジェクト: chebizarro/dia
void
ddisplay_render_pixmap(DDisplay *ddisp, Rectangle *update)
{
  GList *list;
  DiaObject *obj;
  int i;
  DiaInteractiveRendererInterface *renderer;
#ifdef TRACES
  GTimer *timer;
#endif
  
  if (ddisp->renderer==NULL) {
    printf("ERROR! Renderer was NULL!!\n");
    return;
  }

  renderer = DIA_GET_INTERACTIVE_RENDERER_INTERFACE (ddisp->renderer);

  /* Erase background */
  g_return_if_fail (renderer->fill_pixel_rect != NULL);
  DIA_RENDERER_GET_CLASS(ddisp->renderer)->begin_render(ddisp->renderer, update);
  if (update) {
    int x0, y0, x1, y1;

    ddisplay_transform_coords (ddisp, update->left, update->top, &x0, &y0);
    ddisplay_transform_coords (ddisp, update->right, update->bottom, &x1, &y1);
    renderer->fill_pixel_rect (ddisp->renderer,
			       x0, y0, x1-x0, y1-y0,
			       &ddisp->diagram->data->bg_color);
  } else
    renderer->fill_pixel_rect (ddisp->renderer,
			       0, 0,
		               dia_renderer_get_width_pixels (ddisp->renderer),
			       dia_renderer_get_height_pixels (ddisp->renderer),
			       &ddisp->diagram->data->bg_color);

  /* Draw grid */
  grid_draw(ddisp, update);
  pagebreak_draw(ddisp, update);

#ifdef TRACES
  timer = g_timer_new();
#endif
  data_render(ddisp->diagram->data, ddisp->renderer, update,
	      ddisplay_obj_render, (gpointer) ddisp);
#ifdef TRACES
  g_print ("data_render(%g%%) took %g seconds\n", ddisp->zoom_factor * 5.0, g_timer_elapsed (timer, NULL));
  g_timer_destroy (timer);
#endif
  /* Draw handles for all selected objects */
  list = ddisp->diagram->data->selected;
  while (list!=NULL) {
    obj = (DiaObject *) list->data;

    for (i=0;i<obj->num_handles;i++) {
       handle_draw(obj->handles[i], ddisp);
     }
    list = g_list_next(list);
  }
  DIA_RENDERER_GET_CLASS(ddisp->renderer)->end_render(ddisp->renderer);
}