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

Page 121

Advertising
background image

KTD-S0057-I

Page 117 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


#define BTN_CANCEL

1

#define BTN_FONT1

"9x15bold"

#define BTN_TEXT1

"Cancel"

#define BTN_PICTURE

2

#define BTN_FONT2

"lucidasans-bold-12"

#define BTN_TEXT2

"Picture"

#define PICT_X

4

#define PICT_BG

"peru"

#define PICT_FG

"gainsboro"

typedef struct {
Display

*disp;

Window

win;

GC

gc;

int

screen;

Colormap cmap;

/* only for freeing */

XFontStruct *font1;

/* only for freeing */

XFontStruct *font2;

/* only for freeing */

Pixmap pict;

/* only for freeing */

} XSystem;

typedef struct {
XRectangle

rc;

unsigned

long

backcol;

unsigned long linecol1;

unsigned long linecol2;

unsigned long textcol;

XFontStruct

*font;

char

text[16];

} XButton;

static XRectangle btn1 = {

.x = WIDTH - BTN_WIDTH - 20,

.y = HEIGHT - BTN_HEIGHT - 20,

.width

=

BTN_WIDTH,

.height

=

BTN_HEIGHT

};

static XRectangle btn2 = {

.x = WIDTH / 2 - BTN_WIDTH / 2,

.y = HEIGHT / 2 - BTN_HEIGHT,

.width

=

BTN_WIDTH,

.height = BTN_HEIGHT * 2

};

static void draw_button (XSystem sys, XButton btn)
{

int tmp, xp, yp;

XCharStruct

tsize;

XSetForeground (sys.disp, sys.gc, btn.backcol);

XFillRectangle (sys.disp, sys.win, sys.gc, btn.rc.x+1, btn.rc.y+1, btn.rc.width-2, btn.rc.height-2);

XSetForeground (sys.disp, sys.gc, BlackPixel (sys.disp, sys.screen));

XDrawRectangle (sys.disp, sys.win, sys.gc, btn.rc.x, btn.rc.y, btn.rc.width, btn.rc.height);

Advertising
This manual is related to the following products: