コード例 #1
0
ファイル: resize.c プロジェクト: dkogan/notion
static void moveres_draw_rubberband(WMoveresMode *mode)
{
    WRectangle rgeom=mode->geom;
    WRootWin *rootwin=(mode->reg==NULL
                       ? NULL
                       : region_rootwin_of(mode->reg));

    if(rootwin==NULL)
        return;

    rgeom.x+=mode->parent_rx;
    rgeom.y+=mode->parent_ry;

    if(mode->rubfn==NULL)
        draw_rubberbox(rootwin, &rgeom);
    else
        mode->rubfn(rootwin, &rgeom);
}
コード例 #2
0
ファイル: rubberbox.c プロジェクト: debrouxl/tiemu
gboolean
mouse_motion(GtkWidget *drawingarea, GdkEventMotion *event, gpointer action)
{
  int x, y; /* pointer coords */
  GdkModifierType state; 

  if (event->is_hint) 
    {
      gdk_window_get_pointer(event->window, &x, &y, &state); 
    }
  else 
    { 
      x = (int)event->x; 
      y = (int)event->y; 
      state = event->state; 
    } 

  if ((state & GDK_BUTTON1_MASK) == 0) /* button 1 is not pressed */
    return FALSE;

  /* be careful with GDK ... */

  if (x < 0)
    x = 0;
  
  if (y < 0)
    y = 0;
  
  if (x > skin_infos.width - 1)
    x = skin_infos.width - 1;

  if (y > skin_infos.height - 1)
    y = skin_infos.height - 1;
  
  if (x >= ox)
    {
      tmp_rect.x = ox;
      tmp_rect.w = (x - ox);

      if (y >= oy)
	{
	  tmp_rect.y = oy;
	  tmp_rect.h = (y - oy);
	}
      else
	{
	  /* remap Y orig */
	  tmp_rect.y = y;
	  tmp_rect.h = oy - y;
	}
    }
  else
    {
      /* remap X orig */
      tmp_rect.x = x;
      tmp_rect.w = ox - x;

      if (y >= oy)
	{
	  tmp_rect.y = oy;
	  tmp_rect.h = (y - oy);
	}
      else
	{
	  /* remap Y orig */
	  tmp_rect.y = y;
	  tmp_rect.h = oy - y;
	}
    }

  draw_rubberbox(drawingarea1, tmp_rect);

  if (GPOINTER_TO_UINT(action) == ACTION_LCD_COORDS)
    {
      sbar_print(_("LCD size : %d x %d at (%d;%d)"), tmp_rect.w, tmp_rect.h,
		 tmp_rect.x, tmp_rect.y);
    }

  return FALSE;
}