Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 158

Advertising
background image

KTD-S0057-I

Page 154 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


static void draw_cairo_object2 (XSystem sys, cairo_t *cr)
{
XColor

col;

cairo_save

(cr);

cairo_translate (cr, 0.0, -25.0);

cairo_move_to (cr, 50.0, 200.0);

cairo_curve_to

(cr,

50.0,

150.0, 100.0, 50.0, 150.0, 50.0);

cairo_curve_to

(cr,

200.0,

50.0, 250.0, 250.0, 200.0, 250.0);

cairo_curve_to

(cr,

150.0,

250.0, 200.0, 50.0, 50.0, 100.0);

cairo_curve_to

(cr,

-100.0,

150.0, 200.0, 150.0, 200.0, 200.0);

cairo_curve_to

(cr,

200.0,

250.0, 50.0, 250.0, 50.0, 200.0);

XAllocNamedColor (sys.disp, sys.cmap, OBJ1_COL1, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_fill_preserve

(cr);

XAllocNamedColor (sys.disp, sys.cmap, OBJ1_COL2, &col, &col);

cairo_set_source_rgb (cr, RGB_R (C(col)), RGB_G (C(col)), RGB_B (C(col)));

cairo_stroke

(cr);

cairo_restore

(cr);

}

static int create_X11_window (XSystem *sys)
{
Display

*disp;

XVisualInfo

vinfo;

Visual

*visual;

int

screen;

Colormap

cmap;

disp = XOpenDisplay (NULL);

if (disp == (Display *) NULL)

{

fprintf (stderr, "Cannot connect the X server\n");

return

EXIT_FAILURE;

}

if (!XMatchVisualInfo (disp, 0, 32, TrueColor, &vinfo))

if (!XMatchVisualInfo (disp, 0, 24, TrueColor, &vinfo))

if (!XMatchVisualInfo (disp, 0, 16, TrueColor, &vinfo))

{

fprintf (stderr, "Cannot get TrueColor Visual\n");

XCloseDisplay

(disp);

return

EXIT_FAILURE;

}

visual = vinfo.visual;

screen = vinfo.screen;

cmap = XCreateColormap (disp, RootWindow (disp, screen), visual, AllocNone);

sys->disp = disp;

sys->cmap = cmap;

return

EXIT_SUCCESS;

}

Advertising
This manual is related to the following products: