示例#1
0
RubberbandInfo *
rubberband_info_new (Sheet *sheet)
{
	RubberbandInfo *rubberband_info;
	cairo_pattern_t *pattern;
	cairo_matrix_t matrix;

	NG_DEBUG ("0x%x A", COLOR_A);
	NG_DEBUG ("0x%x B", COLOR_B);
	NG_DEBUG ("0x%x A PRE", COLOR_A_PRE);
	NG_DEBUG ("0x%x B PRE", COLOR_B_PRE);
	static guint32 stipple_data[8*8] = {
	    COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE,COLOR_B_PRE,COLOR_A_PRE,
	    COLOR_A_PRE, COLOR_A_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE,COLOR_A_PRE,COLOR_A_PRE,
	    COLOR_A_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_A_PRE,COLOR_A_PRE,COLOR_A_PRE,
	    COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_A_PRE, COLOR_A_PRE,COLOR_A_PRE,COLOR_A_PRE,
	    
	    COLOR_B_PRE, COLOR_B_PRE, COLOR_B_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE,COLOR_A_PRE,COLOR_B_PRE,
	    COLOR_B_PRE, COLOR_B_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE,COLOR_B_PRE,COLOR_B_PRE,
	    COLOR_B_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_B_PRE,COLOR_B_PRE,COLOR_B_PRE,
	    COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_A_PRE, COLOR_B_PRE, COLOR_B_PRE,COLOR_B_PRE,COLOR_B_PRE};

/* the stipple patten should look like that
 *	    1 1 1 0  0 0 0 1
 *	    1 1 0 0  0 0 1 1
 *	    1 0 0 0  0 1 1 1
 *	    0 0 0 0  1 1 1 1
 *	    
 *	    0 0 0 1  1 1 1 0
 *	    0 0 1 1  1 1 0 0
 *	    0 1 1 1  1 0 0 0
 *	    1 1 1 1  0 0 0 0
 */
	rubberband_info = g_new (RubberbandInfo, 1);
	rubberband_info->state = RUBBERBAND_START;
	
	pattern = create_stipple ("lightgrey", (guchar*)stipple_data);
	
	//scale 5x, see http://cairographics.org/manual/cairo-cairo-pattern-t.html#cairo-pattern-t
	cairo_matrix_init_scale (&matrix, 1.0, 1.0);
	cairo_pattern_set_matrix (pattern, &matrix);
	
	rubberband_info->rectangle = GOO_CANVAS_RECT (goo_canvas_rect_new (
	    GOO_CANVAS_ITEM (sheet->object_group),
	    10.0, 10.0,
	    10.0, 10.0, 
	    "stroke-color", "black",
	    "line-width", 0.2,
	    "fill-pattern", pattern,
	    "visibility", GOO_CANVAS_ITEM_INVISIBLE,
	    NULL));
	cairo_pattern_destroy (pattern);
	return rubberband_info;
}
示例#2
0
void MCScreenDC::initatoms()
{
	XSetErrorHandler(xerror);
	XSync( dpy, false ) ;
	
	int ev1, ev2;
	int major, minor;
	Bool pix;
	MCshmpix = False ;
	if (!MCshmoff )
		if ( XQueryExtension(dpy, "MIT-SHM", &shmopcode, &ev1, &ev2))
	        if ( XShmQueryVersion(dpy, &major, &minor, &pix))
	{
		MCshm = True;
		MCshmpix = pix; // For shared memory pixmap's we need this to be true as well...
	}

	create_stipple();

	selectionatom = XInternAtom(dpy, SELECTIONNAME, False);
	
	MCprotocolatom = XInternAtom(dpy, "WM_PROTOCOLS", False);
	MCtakefocusatom = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
	MCdeletewindowatom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
	MCstateatom = XInternAtom(dpy, "WM_STATE", False);
	MCmwmmessageatom = XInternAtom(dpy, "_MOTIF_WM_MESSAGES", True);
	MCmwmhintsatom = XInternAtom(dpy, "_MOTIF_WM_HINTS", True);
	
#ifdef OLWM
	MColwinatom = XInternAtom(dpy, "_OL_WIN_ATTR" , True);
	MColwtotheratom = XInternAtom(dpy, "_OL_WT_OTHER", True);
	MColwtpropatom = XInternAtom(dpy, "_OL_WT_PROP", True);
	MColadecoratom = XInternAtom(dpy, "_OL_DECOR_ADD", True);
	MColddecoratom = XInternAtom(dpy, "_OL_DECOR_DEL", True);
	MColresizeatom = XInternAtom(dpy, "_OL_DECOR_RESIZE", True);
	MColheaderatom = XInternAtom(dpy, "_OL_DECOR_HEADER", True);
	MColcloseatom = XInternAtom(dpy, "_OL_DECOR_CLOSE", True);
#endif
	
	MClayeratom = XInternAtom(dpy, "_WIN_LAYER", False);
	MCclipboardatom = XInternAtom(dpy, "CLIPBOARD", False);
	
	MCclientlistatom = XInternAtom(dpy, "_NET_CLIENT_LIST", True);
	MCstrutpartialatom = XInternAtom(dpy, "_NET_WM_STRUT_PARTIAL", True);
	MCworkareaatom = XInternAtom(dpy, "_NET_WORKAREA", True);
}
示例#3
0
void 
sheet_setup_rubberband (Sheet *sheet, GdkEventButton *event)
{
	double x, y;
	cairo_pattern_t *pattern;
	static guchar stipple_data[16] = 
	{0, 0, 0, 255,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 255 };

	x = event->x; //the x coordinate of the pointer relative to the window.
	y = event->y; //the y coordinate of the pointer relative to the window.
	goo_canvas_convert_from_pixels (GOO_CANVAS (sheet), &x, &y);

	sheet->priv->rubberband->start_x = x;
	sheet->priv->rubberband->start_y = y;

	sheet->priv->rubberband->state = RUBBER_YES;
	sheet->priv->rubberband->click_start_state = event->state;

	pattern = create_stipple ("lightgrey", stipple_data);

	sheet->priv->rubberband->rectangle = goo_canvas_rect_new (
		GOO_CANVAS_ITEM (sheet->object_group), 
	    x, y, 0.0, 0.0, 
	    "stroke-color", "black",
	    "line-width", 0.2,
	    "fill-pattern", pattern,
	    NULL);

	goo_canvas_pointer_grab (GOO_CANVAS (sheet), GOO_CANVAS_ITEM (sheet->grid), 
		(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK),
	    NULL, event->time);
	
	// Mark all the selected objects to preserve their selected state
	// if SHIFT is pressed while rubberbanding.
	if (event->state & GDK_SHIFT_MASK) {
		sheet->priv->preserve_selection_items = 
			g_list_copy (sheet_preserve_selection (sheet));
	}

}