当前位置: 首页>>代码示例>>C++>>正文


C++ DefaultColormap函数代码示例

本文整理汇总了C++中DefaultColormap函数的典型用法代码示例。如果您正苦于以下问题:C++ DefaultColormap函数的具体用法?C++ DefaultColormap怎么用?C++ DefaultColormap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DefaultColormap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int
main(int argc, char *argv[])
{
	XEvent e;
	Atom type;
	XClassHint *h;
	XSetWindowAttributes wa;
	unsigned int desktop;
	struct pollfd pfd[1];
	int nfds;
	char *fontstr = FONT;
	int running = 1;

	d = XOpenDisplay(NULL);
	if (d == NULL) {
		fprintf(stderr, "Cannot open display\n");
		exit(1);
	}

	s = DefaultScreen(d);

	wa.override_redirect = 1;
	wa.background_pixmap = ParentRelative;
	wa.event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask;

	w = XCreateWindow(d, RootWindow(d, s), 0, BARPOS, BARWIDTH, BARHEIGHT, 0,
	    DefaultDepth(d, s), CopyFromParent, DefaultVisual(d, s),
	    CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);

	h = XAllocClassHint();
	h->res_name  = "status";
	h->res_class = "status";
	XSetClassHint(d, w, h);
	XFree(h);

	XStoreName(d, w, "status");

	type = XInternAtom(d, "_NET_WM_WINDOW_TYPE_DOCK", False);
	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_WINDOW_TYPE", False),
	    XInternAtom(d, "ATOM", False), 32, PropModeReplace, (unsigned char *)&type, 1);

	type = XInternAtom(d, "_NET_WM_STATE_ABOVE", False);
	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_STATE", False),
	    XInternAtom(d, "ATOM", False), 32, PropModeReplace, (unsigned char *)&type, 1);

	type = XInternAtom(d, "_NET_WM_STATE_STICKY", False);
	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_STATE", False),
	    XInternAtom(d, "ATOM", False), 32, PropModeAppend, (unsigned char *)&type, 1); 

	desktop = 0xffffffff;
	XChangeProperty(d, w, XInternAtom(d, "_NET_WM_DESKTOP", False),
	    XInternAtom(d, "CARDINAL", False), 32, PropModeReplace, (unsigned char *)&desktop, 1);

	xftd = XftDrawCreate(d, w, DefaultVisual(d, s), DefaultColormap(d, s));

	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "white",  &white);
	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "black",  &black);
	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "red",  &red);
	XftColorAllocName(d, DefaultVisual(d, s), DefaultColormap(d, s),  "green",  &green);

	xftfont = XftFontOpenXlfd(d, s, fontstr);
	if (!xftfont)
		xftfont = XftFontOpenName(d, s, fontstr);
	if (!xftfont)
		exit(1);

	XSelectInput(d, w, ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask);
	XSelectInput(d, RootWindow(d, s), PropertyChangeMask);

	XMapWindow(d, w);
	XFlush(d);

	pfd[0].fd = ConnectionNumber(d);
	pfd[0].events = POLLIN;

	while (running) {
		nfds = poll(pfd, 1, 1000);
		if (nfds == -1 || (pfd[0].revents & (POLLERR|POLLHUP|POLLNVAL)))
			break;
		if (nfds == 0) {
			redraw();
			XFlush(d);
			continue;
		}

		while (XPending(d)) {
			XNextEvent(d, &e);
			if (e.type == PropertyNotify &&
			    e.xproperty.window == RootWindow(d, s) &&
			    e.xproperty.atom == XInternAtom(d, "_NET_CURRENT_DESKTOP", True)) {
				redraw();
			}
			if (e.type == Expose) {
				XftDrawRect(xftd, &black, 0, 0, BARWIDTH, BARHEIGHT);
				redraw();
			}
			if (e.type == ButtonPress) {
				/*running = 0;
				break;*/
				redraw();
//.........这里部分代码省略.........
开发者ID:awaw,项目名称:status,代码行数:101,代码来源:status.c

示例2: XMenuCreate


//.........这里部分代码省略.........
  /*
   * Get default values from X.
   */
  def_val = x_get_resource_string ("menuFreeze", "MenuFreeze");
  if (def_val != NULL) {
    if (strcmp(def_val, "on") == 0) freeze = 1;
    else if (strcmp(def_val, "off") == 0) freeze = 0;
  }

  def_val = x_get_resource_string ("menuReverseVideo", "MenuReverseVideo");
  if (def_val != NULL) {
    if (strcmp(def_val, "on") == 0) reverse = 1;
    else if (strcmp(def_val, "off") == 0) reverse = 0;
  }

  def_val = x_get_resource_string ("menuStyle", "MenuStyle");
  if (def_val != NULL) {
    if (strcmp(def_val, "right_hand") == 0) menu_style = RIGHT;
    else if (strcmp(def_val, "left_hand") == 0) menu_style = LEFT;
    else if (strcmp(def_val, "center") == 0) menu_style = CENTER;
  }

  def_val = x_get_resource_string ("menuMode", "MenuMode");
  if (def_val != NULL) {
    if (strcmp(def_val, "box") == 0) menu_mode = BOX;
    else if (strcmp(def_val, "invert") == 0) menu_mode = INVERT;
  }

  def_val = x_get_resource_string ("menuMouse", "MenuMouse");
  if (
      def_val != NULL &&
      DisplayCells(display, DefaultScreen(display)) > 2 &&
      XAllocDisplayColor(display,
			 DefaultColormap(display, DefaultScreen(display)),
			 def_val,
			 &mouse_color, &color_def)
      );
  else if (reverse &&
	   XAllocDisplayColor(display,
			      DefaultColormap(display, DefaultScreen(display)),
			      "white",
			      &mouse_color, &color_def)
	   );

  else if (XAllocDisplayColor(display,
			      DefaultColormap(display, DefaultScreen(display)),
			      "black",
			      &mouse_color, &color_def)
	   );

  else {}

  def_val = x_get_resource_string ("menuBackground", "MenuBackground");
  if (
      def_val != NULL &&
      DisplayCells(display, DefaultScreen(display)) > 2 &&
      XAllocDisplayColor(display,
			 DefaultColormap(display, DefaultScreen(display)),
			 def_val,
			 &bkgnd_color, &color_def)
      );
  else if (reverse &&
	   XAllocDisplayColor(display,
			      DefaultColormap(display, DefaultScreen(display)),
			      "black",
			      &bkgnd_color, &color_def)
开发者ID:7696122,项目名称:emacs,代码行数:67,代码来源:Create.c

示例3: _find_color

static void _find_color(Widget w, XColor *target, char *dontuse)
{
Colormap		cm;
XColor			cell_def[256];
double 			cur_dist;
int 			cur_red_dist_index=0;
int 			cur_green_dist_index=0;
int 			cur_blue_dist_index=0;
double 			cur_red_dist;
double 			cur_green_dist;
double 			cur_blue_dist;
double 			dist;
double 			red_dist;
double 			green_dist;
double 			blue_dist;
int    			i;
XColor 			tmp = {0,0,0,0,0,0};
int    			screen;
int    			ncells;
Display 		*d = XtDisplay(w);
XWindowAttributes 	win_att;
int			depth;
Pixel			pix;
unsigned long		red_mask=0;
unsigned long		green_mask=0;
unsigned long		blue_mask=0;
unsigned long		red_mult=0;
unsigned long		green_mult=0;
unsigned long		blue_mult=0;

    screen = XScreenNumberOfScreen(XtScreen(w));
    XtVaGetValues(w, XmNdepth, &depth, NULL);
    if(depth == 8) 
	    ncells = 255;
    else if(depth == 12) 
	    ncells = 16; 
    else
	    ncells = 256;
    if(XtIsRealized(w))
    {
	    XGetWindowAttributes(d, XtWindow(w), &win_att);
	    if(win_att.colormap != 
	        DefaultColormap(XtDisplay(w), screen))
	    {
	        cm = win_att.colormap;
	        red_mask = win_att.visual->red_mask;
	        green_mask = win_att.visual->green_mask;
	        blue_mask = win_att.visual->blue_mask;

	        red_mult = red_mask & (~red_mask+1);
	        green_mult = green_mask & (~green_mask+1);
	        blue_mult = blue_mask & (~blue_mask+1);
	    }
	    else
	    {
	        cm = DefaultColormap(XtDisplay(w), screen);
	    }
    }
    else
    {
	    cm = DefaultColormap(XtDisplay(w), screen);
    }

    for (i = 0; i < ncells; i++)
	{
	    switch(depth)
	        {
	        case 8:
		    cell_def[i].pixel = i;
		    break;
	        case 12:
		    pix = i;
		    cell_def[i].pixel = 
		        (pix * red_mult) + 
		        (pix * green_mult) + 
		        (pix * blue_mult);
		    break;
	        default:
		    pix = i;
		    cell_def[i].pixel = 
		        (pix * red_mult) | 
		        (pix * green_mult) | 
		        (pix * blue_mult);
		    break;
	        }
	    cell_def[i].flags = DoRed | DoGreen | DoBlue;
	}

    XQueryColors(d, cm, cell_def, ncells);

    cur_dist = sqrt((double)((double)65535*(double)65535*(double)65535));
    cur_red_dist = cur_green_dist = cur_blue_dist = 65535.0*65535.0;
    for (i = 0; i < ncells; i++)
	{
	red_dist = (double)(target->red - cell_def[i].red) * 
	      	   (double)(target->red - cell_def[i].red);
	green_dist = (double)(target->green - cell_def[i].green) * 
	      	     (double)(target->green - cell_def[i].green);
	blue_dist = (double)(target->blue - cell_def[i].blue) * 
	      	    (double)(target->blue - cell_def[i].blue);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:opendx2,代码行数:101,代码来源:findcolor.c

示例4: lookup


//.........这里部分代码省略.........

    if (property != XA_RGB_DEFAULT_MAP) {
	if (replace) {
	    XmuDeleteStandardColormap(dpy, screen, property);
	    if (cnew)
		XSetRGBColormaps(dpy, win, cnew, 1, property);
	}
	XFree((char *)stdcmaps);
	return 1;
    }

    /* The property exists and is RGB_DEFAULT_MAP */

    for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++)
	;

    /* No RGB_DEFAULT_MAP property matches the given visualid */

    if (i == count) {
	if (cnew) {
	    XStandardColormap	*m, *maps;

	    s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
					      (XStandardColormap)));

	    for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
		m->colormap   = maps->colormap;
		m->red_max    = maps->red_max;
		m->red_mult   = maps->red_mult;
		m->green_max  = maps->green_max;
		m->green_mult = maps->green_mult;
		m->blue_max   = maps->blue_max;
		m->blue_mult  = maps->blue_mult;
		m->base_pixel = maps->base_pixel;
		m->visualid   = maps->visualid;
		m->killid     = maps->killid;
	    }
	    m->colormap   = cnew->colormap;
	    m->red_max    = cnew->red_max;
	    m->red_mult   = cnew->red_mult;
	    m->green_max  = cnew->green_max;
	    m->green_mult = cnew->green_mult;
	    m->blue_max   = cnew->blue_max;
	    m->blue_mult  = cnew->blue_mult;
	    m->base_pixel = cnew->base_pixel;
	    m->visualid   = cnew->visualid;
	    m->killid     = cnew->killid;

	    XSetRGBColormaps(dpy, win, s, ++count, property);
	    free((char *) s);
	}
	XFree((char *) stdcmaps);
	return 0;
    }

    /* Found an RGB_DEFAULT_MAP property with a matching visualid */

    if (replace) {
	/* Free old resources first - we may need them, particularly in
	 * the default colormap of the screen.  However, because of this,
	 * it is possible that we will destroy the old resource and fail
	 * to create a new one if XmuStandardColormap() fails.
	 */

	if (count == 1) {
	    XmuDeleteStandardColormap(dpy, screen, property);
	    if (cnew)
		XSetRGBColormaps(dpy, win, cnew, 1, property);
	}
	else {
	    XStandardColormap	*map;

	    /* s still points to the matching standard colormap */

	    if (s->killid == ReleaseByFreeingColormap) {
		if ((s->colormap != None) &&
		    (s->colormap != DefaultColormap(dpy, screen)))
		    XFreeColormap(dpy, s->colormap);
	    }
	    else if (s->killid != None)
		XKillClient(dpy, s->killid);

	    map = (cnew) ? cnew : stdcmaps + --count;

	    s->colormap   = map->colormap;
	    s->red_max    = map->red_max;
	    s->red_mult   = map->red_mult;
	    s->green_max  = map->green_max;
	    s->green_mult = map->green_mult;
	    s->blue_max   = map->blue_max;
	    s->blue_mult  = map->blue_mult;
	    s->visualid   = map->visualid;
	    s->killid     = map->killid;

	    XSetRGBColormaps(dpy, win, stdcmaps, count, property);
	}
    }
    XFree((char *) stdcmaps);
    return 1;
}
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:101,代码来源:LookupCmap.c

示例5: DefaultScreen

int XAbstractGui::SetColors(Display *dpy)
{
    int screen;
    XcmsColor xcolor;
    XcmsColor exact;
    int i, scale;
    int rw_color;   /* is it a read/write color ?*/
    int visualClass;
    unsigned long pixels[1 << COLOR_PLANES];

    screen = DefaultScreen(dpy);
    visual = GetBestVisual(dpy, &visualClass, &depth);

    if (!visual)
    {
        fprintf(stderr, "Unable to find an appropriate visual\n");
        return 0;
    }

    rw_color = (visualClass == DirectColor || visualClass == PseudoColor ||
                visualClass == GrayScale);
    cmap = DefaultColormap(dpy, screen);

    if (rw_color)
    {
        /* on visuals with read/write color cells
           first allocate them */
        if (!XAllocColorCells(dpy, cmap, False, nullptr, 0, pixels,
                              1 << COLOR_PLANES))
        {
            /* try again with a own colormap */
            cmap = XCreateColormap(dpy,
                                   RootWindow(dpy, screen),
                                   visual, AllocNone);
            own_cmap = 1;

            if (!XAllocColorCells(dpy, cmap, False, nullptr, 0,
                                  pixels, 1 << COLOR_PLANES))
            {
                fprintf(stderr, "Unable to allocate %d colors\n",
                        1 << COLOR_PLANES);
                return 0; /* failed even with own colormap */
            }
        }
    }

    if (!XcmsLookupColor(dpy, cmap, color.c_str(), &xcolor, &exact,
                         XcmsRGBiFormat))
    {
        exact.spec.RGBi.blue  = 1.0;
        exact.spec.RGBi.red   = 1.0;
        exact.spec.RGBi.green = 1.0;
    }

    xcolor.format = XcmsRGBiFormat;

    for (i = 0; i < (1 << COLOR_PLANES); i++)
    {
        if (withColorScale)
        {
            // DEPENDANCIES:
            // the color plane masks used here depend on
            // the same masks used in CopyToZPixmap
            scale  = i & 0x20 ? 2 : 0;
            scale |= i & 0x04 ? 1 : 0;
            xcolor.spec.RGBi.green = 1.0 * scale / 3;
            scale  = i & 0x10 ? 2 : 0;
            scale |= i & 0x02 ? 1 : 0;
            xcolor.spec.RGBi.red   = 1.0 * scale / 3;
            scale  = i & 0x08 ? 2 : 0;
            scale |= i & 0x01 ? 1 : 0;
            xcolor.spec.RGBi.blue  = 1.0 * scale / 3;
        }
        else
        {
            xcolor.spec.RGBi.blue  =
                exact.spec.RGBi.blue  * i / (1 << COLOR_PLANES);
            xcolor.spec.RGBi.red   =
                exact.spec.RGBi.red   * i / (1 << COLOR_PLANES);
            xcolor.spec.RGBi.green =
                exact.spec.RGBi.green * i / (1 << COLOR_PLANES);
        }

        if (rw_color)
        {
            xcolor.pixel = pixels[i];

            if (XcmsStoreColor(dpy, cmap,
                               &xcolor) == XcmsFailure)
            {
                fprintf(stderr, "Error storing a color\n");
                return 0;
            }
        }
        else
        {
            if (XcmsAllocColor(dpy, cmap,
                               &xcolor, XcmsRGBiFormat) == XcmsFailure)
            {
                fprintf(stderr, "Error allocating a color\n");
//.........这里部分代码省略.........
开发者ID:aladur,项目名称:flexemu,代码行数:101,代码来源:xabsgui.cpp

示例6: initializeWindowSystem

void
initializeWindowSystem(void)
{
    char *display_name = NULL;
    XColor fg, bg;
#if 0
    XColor rgbdef;
#endif
    Colormap cmap;
    Pixmap  mousebits, mousemask;
/*    fprintf(stderr,"initx:initializeWindowSystem:entered\n");*/
    /* Try to open the display */
/*    fprintf(stderr,"initx:initializeWindowSystem:XOpenDisplay\n");*/
    if ((gXDisplay = XOpenDisplay(display_name)) == NULL) {
        fprintf(stderr, "(HyperDoc) Cannot connect to the X11 server!\n");
        exit(-1);
    }

    /* Get the screen */
/*    fprintf(stderr,"initx:initializeWindowSystem:DefaultScreen\n");*/
    gXScreenNumber = scrn = DefaultScreen(gXDisplay);
/*    fprintf(stderr,"initx:initializeWindowSystem:XGContextFromGC\n");*/
    server_font =XGContextFromGC(DefaultGC(gXDisplay, gXScreenNumber));

    /* Get the cursors we need. */

/*    fprintf(stderr,"initx:initializeWindowSystem:DefaultColormap\n");*/
    cmap = DefaultColormap(gXDisplay, gXScreenNumber);
/*    fprintf(stderr,"initx:initializeWindowSystem:WhitePixel\n");*/
    fg.pixel = WhitePixel(gXDisplay,gXScreenNumber);
/*    fprintf(stderr,"initx:initializeWindowSystem:XQueryColor\n");*/
    XQueryColor(gXDisplay, cmap, &fg );
/*    fprintf(stderr,"initx:initializeWindowSystem:BlackPixel\n");*/
    bg.pixel = BlackPixel(gXDisplay,gXScreenNumber);
/*    fprintf(stderr,"initx:initializeWindowSystem:XQueryColor2\n");*/
    XQueryColor(gXDisplay, cmap, &bg );
#if 0
    XAllocNamedColor(gXDisplay, cmap, "Black", &fg, &rgbdef);
    XAllocNamedColor(gXDisplay, cmap, "White", &bg, &rgbdef);
#endif

#ifdef USE_BORING_OLD_CURSORS
    gActiveCursor = XCreateFontCursor(gXDisplay, XC_circle);
    gNormalCursor = XCreateFontCursor(gXDisplay, XC_dot);
#else
/*  fprintf(stderr,"initx:initializeWindowSystem:XCreateBitmapFromData 1\n");*/
    mousebits = XCreateBitmapFromData(gXDisplay,
        RootWindow(gXDisplay, gXScreenNumber),
        mouseBitmap_bits, mouseBitmap_width,mouseBitmap_height);
/* fprintf(stderr,"initx:initializeWindowSystem:XCreateBitmapFromData 2\n");*/
    mousemask = XCreateBitmapFromData(gXDisplay,
        RootWindow(gXDisplay, gXScreenNumber),
        mouseMask_bits, mouseMask_width,mouseMask_height);
/* fprintf(stderr,"initx:initializeWindowSystem:XCreateBitmapFromData 2\n");*/
    gActiveCursor = XCreatePixmapCursor(gXDisplay,
        mousebits, mousemask, &fg, &bg,
        mouseBitmap_x_hot,mouseBitmap_y_hot);

/*    fprintf(stderr,"initx:initializeWindowSystem:XCreateFontCursor\n");*/
    gNormalCursor = XCreateFontCursor(gXDisplay, XC_left_ptr);
#endif

/*    fprintf(stderr,"initx:initializeWindowSystem:XCreateFontCursor 2\n");*/
    gBusyCursor = XCreateFontCursor(gXDisplay, XC_watch);

    /* Now initialize all the colors and fonts */

/*    fprintf(stderr,"initx:initializeWindowSystem:ingItColors_and_fonts\n");*/
    ingItColors_and_fonts();
/*    fprintf(stderr,"initx:initializeWindowSystem:init_text\n");*/
    init_text();
/*    fprintf(stderr,"initx:initializeWindowSystem:exited\n");*/

}
开发者ID:bfauser,项目名称:fricas,代码行数:74,代码来源:initx.c

示例7: main

int main()
{
#ifdef TEST_FOR_X
	Display		*display;
	Window		window;
	GC		gc;
	XGCValues	gcValues;
	Colormap	colormap;
	Pixmap		src_pixmap;
	unsigned long	fgColor, bgColor;
	int		screenNum;
	XPoint		points[NUM_POINTS];
#else
	GR_WINDOW_ID 	window;
	GR_WINDOW_ID	src_pixmap;
	unsigned char*	src_pixmap_buf[320*240*2];
	GR_GC_ID        gc;
	GR_POINT	points[NUM_POINTS];
#endif
	
	int		c, c1,  count=4500;
	int		x, y, x1, y1, x2, y2;

#ifdef TEST_FOR_X
	if(!(display=XOpenDisplay(""))) {
		printf("Cannot connect to X.\n");
	}
	screenNum = DefaultScreen(display);
	colormap = DefaultColormap(display, screenNum);

	bgColor = BlackPixel(display, screenNum);
	fgColor = WhitePixel(display, screenNum);
	window = XCreateSimpleWindow(display, RootWindow(display, screenNum),
		0, 0 , 639, 479, 0,
		fgColor, bgColor);
	src_pixmap = XCreatePixmap(display, window, 320, 240, 16);
	XMapRaised(display, window);
	gcValues.background = bgColor;
	gcValues.foreground = fgColor;
	gcValues.line_width = 1;
	gcValues.line_style = LineSolid;
	gcValues.fill_style = FillSolid;
	gcValues.fill_rule = WindingRule;
	gcValues.arc_mode = ArcPieSlice;
	gc = XCreateGC(display, window,
		GCForeground  | GCBackground | GCLineWidth | GCLineStyle |
		GCFillStyle,
		&gcValues);

#else	
	GrOpen();
	window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 639, 479, 0, BLACK, BLUE);
	src_pixmap = GrNewPixmap(640, 480, src_pixmap_buf);
	GrMapWindow(window);
	gc = GrNewGC();
        GrSetGCForeground(gc, WHITE);
	GrSetGCBackground(gc, BLACK);
	GrSetGCMode(gc, GR_MODE_COPY);
#endif




	
	// Horizontal Line
	////////////////////////////////////////////////
	printf("Horizontal Line(XDrawLine)\n");
	start_timer();
	for(c=0; c<count*20; c++)
	{
		y1=random()%480;
#ifdef TEST_FOR_X
		XDrawLine(display, window, gc, 0, y1, 639, y1);
		XFlush(display);
#else
		GrLine(window, gc, 0, y1, 639, y1);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif
	
	// Vertical Line
	/////////////////////////////////////////////////
	printf("Vertical Line(XDrawLine)\n");
	start_timer();
	for(c=0; c<count*19; c++)
	{
		x1=random()%640;
#ifdef TEST_FOR_X
		XDrawLine(display, window, gc, x1, 0, x1, 479);
		XFlush(display);
#else
		GrLine(window, gc, x1, 0, x1, 479);
		GrFlush();
#endif
//.........这里部分代码省略.........
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,代码来源:speed.c

示例8: calibrator

GuiCalibratorX11::GuiCalibratorX11(Calibrator* calibrator0)
  : calibrator(calibrator0), time_elapsed(0)
{
    display = XOpenDisplay(NULL);
    if (display == NULL) {
        throw std::runtime_error("Unable to connect to X server");
    }
    screen_num = DefaultScreen(display);
    // Load font and get font information structure
    font_info = XLoadQueryFont(display, "9x15");
    if (font_info == NULL) {
        // fall back to native font
        font_info = XLoadQueryFont(display, "fixed");
        if (font_info == NULL) {
            XCloseDisplay(display);
            throw std::runtime_error("Unable to open neither '9x15' nor 'fixed' font");
        }
    }

#ifdef HAVE_X11_XRANDR
    // get screensize from xrandr
    int nsizes;
    XRRScreenSize* randrsize = XRRSizes(display, screen_num, &nsizes);
    if (nsizes != 0) {
        set_display_size(randrsize->width, randrsize->height);
    } else {
        set_display_size(DisplayWidth(display, screen_num),
                         DisplayHeight(display, screen_num));
    }
# else
    set_display_size(DisplayWidth(display, screen_num),
                     DisplayHeight(display, screen_num));
#endif

    // Register events on the window
    XSetWindowAttributes attributes;
    attributes.override_redirect = True;
    attributes.event_mask = ExposureMask | KeyPressMask | ButtonPressMask;

    win = XCreateWindow(display, RootWindow(display, screen_num),
                0, 0, display_width, display_height, 0,
                CopyFromParent, InputOutput, CopyFromParent,
                CWOverrideRedirect | CWEventMask,
                &attributes);
    XMapWindow(display, win);

    // Listen to events
    XGrabKeyboard(display, win, False, GrabModeAsync, GrabModeAsync,
                CurrentTime);
    calib_input = calibrator->register_events();
    if (!calib_input) {
            XGrabPointer(display, win, False, ButtonPressMask, GrabModeAsync,
                GrabModeAsync, None, None, CurrentTime);
    }

    Colormap colormap = DefaultColormap(display, screen_num);
    XColor color;
    for (int i = 0; i != nr_colors; i++) {
        XParseColor(display, colormap, colors[i], &color);
        XAllocColor(display, colormap, &color);
        pixel[i] = color.pixel;
    }
    XSetWindowBackground(display, win, pixel[GRAY]);
    XClearWindow(display, win);

    gc = XCreateGC(display, win, 0, NULL);
    XSetFont(display, gc, font_info->fid);

    // Setup timer for animation
    signal(SIGALRM, sigalarm_handler);
    struct itimerval timer;
    timer.it_value.tv_sec = time_step/1000;
    timer.it_value.tv_usec = (time_step % 1000) * 1000;
    timer.it_interval = timer.it_value;
    setitimer(ITIMER_REAL, &timer, NULL);
}
开发者ID:axet,项目名称:xinput_calibrator,代码行数:76,代码来源:gui_x11.cpp

示例9: main

int main (int argc, char **argv) {
	Cursor cursor;
	Display *display;
	Window root, blub, *blubs = NULL;
	unsigned clients;
	unsigned long pixel;
	char *cname;
	XColor color;
	int cnt;
	Atom prop;
	Pixmap save_pixmap = (Pixmap)None;

	display = XOpenDisplay(NULL);
	if(!display) return 1;

	cname = argc == 2 ? argv[1] : "black";

	screen = DefaultScreen(display);
	root = RootWindow(display, screen);
	pixel = BlackPixel(display, screen);

	if(XParseColor(display, DefaultColormap(display, screen), cname, &color)) {
	if(XAllocColor(display, DefaultColormap(display, screen), &color)) {
		pixel = color.pixel;
	}
	}

	XSetWindowBackground(display, root, pixel);
	XClearWindow(display, root);
	cursor = CreateCursorFromName(display,"watch");
	if (cursor) {
		XDefineCursor (display, root, cursor);
		XFreeCursor (display, cursor);
	}
	
	if (fork() == 0) {
		Window win;
		XEvent xev;

		close(0); close(1); close(2);
		chdir("/");

		display = XOpenDisplay(NULL);

		// open a client...
		if (display) {
			win = XCreateSimpleWindow (
				display, root, 0, 0, 1, 1, 0, 0, pixel
			);
			XSync(display, False);
		}
		// wait within event loop...
		for(;;) XNextEvent(display, &xev);
	}

	// wait until the child has opened a client
	cnt = 100;
	do {
	if (!XQueryTree (display, root, &blub, &blub, &blubs, &clients)) {
		XCloseDisplay(display);
		return 0;
	}
	usleep(50000);
	} while(clients < 1 && cnt--);

	save_pixmap = XCreatePixmap (display, root, 1, 1, 1);
	prop = XInternAtom (display, "_XSETROOT_ID", False);
	XChangeProperty (
		display, root, prop, XA_PIXMAP, 32, 
		PropModeReplace, (unsigned char *) &save_pixmap, 1
	);
	XSetCloseDownMode (display, RetainPermanent);

	// enable accessX
	// XAccess (display,NULL);
	XCloseDisplay(display);

	RunWindowManager();
	return 0;
}
开发者ID:BackupTheBerlios,项目名称:sax-svn,代码行数:80,代码来源:xtest.c

示例10: Init_X

int Init_X (int swidth, int sheight)
{
    XGCValues vals;
    Colormap TheColormap;
    XColor TheColor;
    int i;

    TheWidth = swidth ;
    TheHeight = sheight ;


    TheDisplay = XOpenDisplay("\0");
    TheRootWindow = DefaultRootWindow(TheDisplay);
    TheScreenNumber = DefaultScreen(TheDisplay); 
    TheDepth = DefaultDepth(TheDisplay, TheScreenNumber);
    if (TheDepth != 24) {
      printf("24 bit color not supported.\n") ;
      printf("Color function not likely to work.\n") ;
    }
    TheWindow = XCreateSimpleWindow(TheDisplay, TheRootWindow,
                        0, 0, TheWidth, TheHeight, 0, 0, 0);

    if (!TheWindow) return 0 ;

    ThePixmap = XCreatePixmap(TheDisplay, TheRootWindow, TheWidth, TheHeight, 
				TheDepth);

    if (!ThePixmap) return 0 ;

    TheDrawable = ThePixmap;

    
    XMapWindow(TheDisplay, TheWindow);
    XSelectInput(TheDisplay, TheWindow, ExposureMask |
					StructureNotifyMask |
					PointerMotionMask | 
					ButtonPressMask |
					KeyPressMask );




    /*
    TheWindowContext = XCreateGC(TheDisplay, TheWindow, 0, 0);
    // this is a bad idea ... see test t02.c for an example
    // of what can happen to the behavior of the event handler,
    //       int Handle_Events_X(int *px, int *py)
    // if you do this, you'll get runaway calls to Handle_Events
    // with the default condition being met and this produces
    // a great deal of tearing in the animation of t02.c
    */




    /* also a bad idea...same behavior as above
    vals.graphics_exposures = 1; // True
    */

    // so this is what you want :
    vals.graphics_exposures = 0; // False
    TheWindowContext = XCreateGC(TheDisplay, TheWindow,
                                 GCGraphicsExposures, &vals);
    if (!TheWindowContext) return 0;


    ThePixmapContext = XCreateGC(TheDisplay, ThePixmap, 0, 0);
    if (!ThePixmapContext) return 0;


    TheColormap = DefaultColormap(TheDisplay, TheScreenNumber);
    for(i = 0; i < 256; i++) {
	TheColor.green = TheColor.blue = TheColor.red = (i << 8) | i;
	TheColor.flags = DoRed | DoGreen | DoBlue;
	XAllocColor(TheDisplay, TheColormap, &TheColor);
	Grays[i] = TheColor.pixel;
    }
 

    TheFontInfo = XLoadQueryFont(TheDisplay, TheFont) ;
    XSetFont(TheDisplay, TheWindowContext, TheFontInfo->fid) ;




    //   XClearWindow(TheDisplay, TheWindow);
    //   XClearArea(TheDisplay, TheWindow, 0,0,0,0,False); // same as above
    XClearArea(TheDisplay, TheWindow, 0,0,0,0,True); 
                  // Does the boolean matter here?


    // most people expect a white piece of paper
    // with a black pencil
    Set_Color_Rgb_X (255,255,255) ; // white
    Clear_Buffer_X() ; // otherwise you can inherit garbage
    // from the parent window

    //    Set_Color_Rgb_X (255,0,255) ; // purple
    //    Fill_Rectangle_X(10,10,50,80) ;
    // above was just a test
//.........这里部分代码省略.........
开发者ID:javins,项目名称:fpt,代码行数:101,代码来源:X_graphics.c

示例11: read_ppm_file

XImage *
read_ppm_file(Display *disp, Colormap cmap, int depth, IOSTREAM *fd)
{ XImage *img;
  long here = Stell(fd);
  int c;
  int fmt, encoding;
  int width, height, bytes_per_line, scale=0;
  char *data;
  int allocdepth;
  int pad = XBitmapPad(disp);
  Visual *v = DefaultVisual(disp, DefaultScreen(disp));

  ncolours = nmapped = nfailed = 0;	/* statistics */
  assert(pad%8 == 0);

  if ( (c=Sgetc(fd)) != 'P' )
  { Sungetc(c, fd);
    return NULL;
  }

  if ( !cmap )
    cmap = DefaultColormap(disp, DefaultScreen(disp));

  c = Sgetc(fd);
  if ( c < '1' || c > '9' )
    goto errout;
  c -= '0';
  fmt      = ((c - 1) % 3) + 1;
  encoding = c - fmt;

  width = getNum(fd);
  height = getNum(fd);

  if ( fmt == PNM_PBM )
  { depth = 1;
  } else
  { scale = getNum(fd);
    if ( !depth )
      depth = DefaultDepth(disp, DefaultScreen(disp));
  }

  if ( width < 0 || height < 0 || scale < 0 )
    goto errout;

  allocdepth = (depth >= 24 ? 32 : depth);
  bytes_per_line = roundup((width*allocdepth+7)/8, pad/8);
  data = (char *)pceMalloc(height * bytes_per_line);

  img = XCreateImage(disp,
		     v,
		     depth,
		     fmt == PNM_PBM ? XYBitmap : ZPixmap,
		     0,
		     data,
		     width, height,
		     pad, bytes_per_line);
  if ( !img )
  { perror("XCreateImage");
    pceFree(data);
    goto errout;
  }
  img->bits_per_pixel = depth;

  switch(encoding)
  { int x, y;

    case PNM_ASCII:
    { switch(fmt)
      { case PNM_PBM:
	  for(y=0; y<height; y++)
	  { for(x=0; x<width; x++)
	    { int value = getNum(fd);

	      if ( value < 0 || value > 1 )
		goto errout;

	      XPutPixel(img, x, y, value);
	    }
	  }
	  break;
	case PNM_PGM:
	{ Table t = newTable(64);

	  for(y=0; y<height; y++)
	  { for(x=0; x<width; x++)
	    { int g = getNum(fd);
	      unsigned long pixel;

	      if ( g < 0 || g > scale )
		goto errout;
	      if ( scale != 255 )
		g = rescale(g, scale, 255);

	      pixel = colourPixel(disp, depth, cmap, t, g, g, g);
	      XPutPixel(img, x, y, pixel);
	    }
	  }
	  freeTable(t);

	  break;
//.........这里部分代码省略.........
开发者ID:brayc0,项目名称:nlfetdb,代码行数:101,代码来源:xppm.c

示例12: malloc

stk_widget *stk_progress_bar_new(stk_widget *parent_win, int x, int y, uint w, uint h, char *label)
{
    stk_widget *new_pb  = (stk_widget*) malloc(sizeof(stk_widget));
    stk_progress_bar *pb  = (stk_progress_bar*) malloc(sizeof(stk_progress_bar));
    int screen;

    XGCValues gcval;
    long fg, bg;
    
    memset(new_pb, 0, sizeof(stk_widget));
    
    new_pb->dsp = display;
    new_pb->fontname = "7x13";

    screen = DefaultScreen(new_pb->dsp);
    fg = BlackPixel(new_pb->dsp, screen);
    bg = WhitePixel(new_pb->dsp, screen);
    
    gcval.foreground = fg;
    gcval.background = bg;

    new_pb->gc2 = XCreateGC(new_pb->dsp, parent_win->win, GCForeground |
                                                  GCBackground, &gcval);

    if(new_pb->dsp)
    {
        new_pb->win = XCreateSimpleWindow(new_pb->dsp, parent_win->win, x, y, w,
                                                                  h, 1, fg, bg);
        new_pb->gc = XCreateGC(new_pb->dsp, new_pb->win, 0, 0);
        new_pb->font_info = XLoadQueryFont(new_pb->dsp, new_pb->fontname);

        if(new_pb->fontname != NULL)
            XSetFont(display, new_pb->gc2, new_pb->font_info->fid);
        else
            perror("XLoadQueryFont");

        new_pb->mask =  ExposureMask | EnterWindowMask | LeaveWindowMask | ButtonPressMask | ButtonReleaseMask;

        XSelectInput(new_pb->dsp, new_pb->win, new_pb->mask);
        


        if(DisplayPlanes(new_pb->dsp, screen) != 1)
        {
            pb->cmap = DefaultColormap(new_pb->dsp, screen);
            if(XAllocNamedColor(new_pb->dsp, pb->cmap, "red", &pb->color, &pb->colorrgb))
                    XSetForeground(new_pb->dsp, new_pb->gc, pb->color.pixel);
        }

        XMapWindow(new_pb->dsp, new_pb->win);

        memset(pb, 0, sizeof(stk_progress_bar));

        new_pb->x = x;
        new_pb->y = y;
        new_pb->w = w;
        new_pb->h = h;

        new_pb->handler = &stk_progress_bar_handle;
        pb->pct = 0;
        new_pb->ext_struct = (void*)pb;


        if(label)
            strcpy(pb->label, label);
        else
            new_pb->label = NULL;

        stk_widget_insert((void*)new_pb); 

        return new_pb;
    }
    else
        return NULL;
}
开发者ID:gabrield,项目名称:stk,代码行数:75,代码来源:stk_progress_bar.c

示例13: main


//.........这里部分代码省略.........
            my_current_person_id <= our_number_of_people - 1;
            my_current_person_id++)
    {
        our_num_days_infected[my_current_person_id] = 0;
    }

    /* ALG XIII: Rank 0 initializes the graphics display */
#ifdef X_DISPLAY
    if(our_rank == 0)
    {
        /* Initialize the X Windows Environment
         * This all comes from 
         *   http://en.wikibooks.org/wiki/X_Window_Programming/XLib
         *   http://tronche.com/gui/x/xlib-tutorial
         *   http://user.xmission.com/~georgeps/documentation/tutorials/
         *      Xlib_Beginner.html
         */

        /* Open a connection to the X server */
        display = XOpenDisplay(NULL);
        if(display == NULL)
        {
            fprintf(stderr, "Error: could not open X display\n");
        }
        screen = DefaultScreen(display);
        window = XCreateSimpleWindow(display, RootWindow(display, screen),
                0, 0, environment_width * PIXEL_WIDTH_PER_PERSON, 
                environment_height * PIXEL_HEIGHT_PER_PERSON, 1,
                BlackPixel(display, screen), WhitePixel(display, screen));
        delete_window = XInternAtom(display, "WM_DELETE_WINDOW", 0);
        XSetWMProtocols(display, window, &delete_window, 1);
        XSelectInput(display, window, ExposureMask | KeyPressMask);
        XMapWindow(display, window);
        colormap = DefaultColormap(display, 0);
        gc = XCreateGC(display, window, 0, 0);
        XParseColor(display, colormap, red, &infected_color);
        XParseColor(display, colormap, green, &immune_color);
        XParseColor(display, colormap, white, &dead_color);
        XParseColor(display, colormap, black, &susceptible_color);
        XAllocColor(display, colormap, &infected_color);
        XAllocColor(display, colormap, &immune_color);
        XAllocColor(display, colormap, &susceptible_color);
        XAllocColor(display, colormap, &dead_color);
    }
#endif

    /* ALG XIV: Each process starts a loop to run the simulation for the
     *  specified number of days */
    for(our_current_day = 0; our_current_day <= total_number_of_days - 1; 
            our_current_day++)
    {
        /* ALG XIV.A: Each process determines its infected x locations and 
         *  infected y locations */
        our_current_infected_person = 0;
        for(our_person1 = 0; our_person1 <= our_number_of_people - 1;
                our_person1++)
        {
            if(our_states[our_person1] == INFECTED)
            {
                our_infected_x_locations[our_current_infected_person] =
                    our_x_locations[our_person1];
                our_infected_y_locations[our_current_infected_person] =
                    our_y_locations[our_person1];
                our_current_infected_person++;
            }
        }
开发者ID:Jgarcia08,项目名称:PetascaleInstitute,代码行数:67,代码来源:pandemic-openmp.c

示例14: MakeColors

/*
 ***********************************************************************
 * Allocates colors and fill a pixel value array. Color values are
 * truncated with RED_MASK, GREEN_MASK and BLUE_MASK
 *
 * from,to are the primary colors to use
 * maxcols is the number of colors
 * colors is the array of pixel values
 * light,dark are the colors for the relief
 * dr,dg,db are the increment values for the colors
 * alloc_relief if colors for relief should be allocated
 * incr - 0 if gradient is light to dark, 1 if dark to light
 ***********************************************************************
 */
int MakeColors(Display *dpy, Drawable d, int from[3], int to[3], int maxcols,
	       unsigned long *colors, unsigned long *dark,
	       unsigned long *light, int dr, int dg, int db,
	       int alloc_relief, int incr)
{
    float rv, gv, bv;
    float sr,sg,sb;
    int red, green, blue;
    XColor color;
    int i;

    sr = (float)dr / (float)maxcols;
    sg = (float)dg / (float)maxcols;
    sb = (float)db / (float)maxcols;
    rv = (float)from[0];
    gv = (float)from[1];
    bv = (float)from[2];
    /* kludge to frce color allocation in the first iteration on any case */
    color.red = (from[0] == 0) ? 0xffff : 0;
    color.green = 0;
    color.blue = 0;
    for(i = 0; i < maxcols; i++) {
	/* color allocation saver */
	red = ((short)rv) & RED_MASK;
	green = ((short)gv) & GREEN_MASK;
	blue = ((short)bv) & BLUE_MASK;
	if (color.red != red || color.green != green || color.blue != blue) {
	    color.red = red;
	    color.green = green;
	    color.blue = blue;
	    if (XAllocColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
			&color)==0) {
	        return 0;
	    }
	}
	colors[i] = color.pixel;
	rv += sr;
	gv += sg;
	bv += sb;
	if ((rv > 65535.0) || (rv < 0.0)) rv -= sr;
	if ((gv > 65535.0) || (gv < 0.0)) gv -= sg;
	if ((bv > 65535.0) || (bv < 0.0)) bv -= sb;
    }
    /* allocate 2 colors for the bevel */
    if (alloc_relief) {
	if (incr) {
	    rv = (float)from[0] * 0.8;
	    gv = (float)from[1] * 0.8;
	    bv = (float)from[2] * 0.8;
	} else {
	    rv = (float)to[0] * 0.8;
	    gv = (float)to[1] * 0.8;
	    bv = (float)to[2] * 0.8;
	}
	color.red = (unsigned short)(rv<0?0:rv);
    color.green = (unsigned short)(gv<0?0:gv);
	color.blue = (unsigned short)(bv<0?0:bv);
	if (XAllocColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),&color))
	  *dark = color.pixel;
	else
	  *dark = colors[incr ? 0 : maxcols-1];

	if (incr) {
	    float avg;
	    avg = (float)(to[0]+to[1]+to[2])/3;
	    rv = avg + (float)(to[0]/2);
	    gv = avg + (float)(to[1]/2);
	    bv = avg + (float)(to[2]/2);
	} else {
            float avg;
	    avg = (float)(from[0]+from[1]+from[2])/3;
	    rv = avg + (float)(from[0]/2);
	    gv = avg + (float)(from[1]/2);
	    bv = avg + (float)(from[2]/2);
	}
	color.red = (unsigned short)(rv>65535.0 ? 65535.0:rv);
    color.green = (unsigned short)(gv>65535.0 ? 65535.0:gv);
	color.blue = (unsigned short)(bv>65535.0 ? 65535.0:bv);
	if (XAllocColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
			&color))
	  *light = color.pixel;
	else
	  *light = colors[incr ? maxcols-1 : 0];
    } else {
	*light = colors[incr ? maxcols-1 : 0];
	*dark = colors[incr ? 0 : maxcols-1];
//.........这里部分代码省略.........
开发者ID:att,项目名称:uwin,代码行数:101,代码来源:stepgfx.c

示例15: Tk_GetPixmap

Pixmap
Tk_GetPixmap(
    Display *display,
    Drawable d,
    int width,
    int height,
    int depth)
{
    TkWinDrawable *newTwdPtr, *twdPtr;
    int planes;
    Screen *screen;

    display->request++;

    newTwdPtr = ckalloc(sizeof(TkWinDrawable));
    newTwdPtr->type = TWD_BITMAP;
    newTwdPtr->bitmap.depth = depth;
    twdPtr = (TkWinDrawable *) d;
    if (twdPtr->type != TWD_BITMAP) {
	if (twdPtr->window.winPtr == NULL) {
	    newTwdPtr->bitmap.colormap = DefaultColormap(display,
		    DefaultScreen(display));
	} else {
	    newTwdPtr->bitmap.colormap = twdPtr->window.winPtr->atts.colormap;
	}
    } else {
	newTwdPtr->bitmap.colormap = twdPtr->bitmap.colormap;
    }
    screen = &display->screens[0];
    planes = 1;
    if (depth == screen->root_depth) {
	planes = PTR2INT(screen->ext_data);
	depth /= planes;
    }
    newTwdPtr->bitmap.handle =
	    CreateBitmap(width, height, (DWORD) planes, (DWORD) depth, NULL);

    /*
     * CreateBitmap tries to use memory on the graphics card. If it fails,
     * call CreateDIBSection which uses real memory; slower, but at least
     * still works. [Bug 2080533]
     */

    if (newTwdPtr->bitmap.handle == NULL) {
	static int repeatError = 0;
	void *bits = NULL;
	BITMAPINFO bitmapInfo;
	HDC dc;

	memset(&bitmapInfo, 0, sizeof(bitmapInfo));
	bitmapInfo.bmiHeader.biSize = sizeof(bitmapInfo.bmiHeader);
	bitmapInfo.bmiHeader.biWidth = width;
	bitmapInfo.bmiHeader.biHeight = height;
	bitmapInfo.bmiHeader.biPlanes = planes;
	bitmapInfo.bmiHeader.biBitCount = depth;
	bitmapInfo.bmiHeader.biCompression = BI_RGB;
	bitmapInfo.bmiHeader.biSizeImage = 0;
	dc = GetDC(NULL);
	newTwdPtr->bitmap.handle = CreateDIBSection(dc, &bitmapInfo,
		DIB_RGB_COLORS, &bits, 0, 0);
	ReleaseDC(NULL, dc);

	/*
	 * Oh no! Things are still going wrong. Pop up a warning message here
	 * (because things will probably crash soon) which will encourage
	 * people to report this as a bug...
	 */

	if (newTwdPtr->bitmap.handle == NULL && !repeatError) {
	    LPVOID lpMsgBuf;

	    repeatError = 1;
	    if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
		    FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
		    NULL, GetLastError(),
		    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
		    (LPSTR) &lpMsgBuf, 0, NULL)) {
		MessageBoxA(NULL, (LPCSTR) lpMsgBuf,
			"Tk_GetPixmap: Error from CreateDIBSection",
			MB_OK | MB_ICONINFORMATION);
		LocalFree(lpMsgBuf);
	    }
	}
    }

    if (newTwdPtr->bitmap.handle == NULL) {
	ckfree(newTwdPtr);
	return None;
    }

    return (Pixmap) newTwdPtr;
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:92,代码来源:tkWinPixmap.c


注:本文中的DefaultColormap函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。