home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Borland Programmer's Resource
/
Borland_Programmers_Resource_CD_1995.iso
/
code
/
stdg44
/
cursors.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-18
|
7KB
|
248 lines
#include "stdc.h"
#include "stdg.h"
/* Click to show some cursors and demonstrate the timer mechanism */
cursor confirmcursor={
{ 0, 0},
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
},
{0x00, 0x0E, 0x07, 0x1F, 0x03, 0x17, 0x73, 0x6F,
0xFB, 0xCE, 0xDB, 0x8C, 0xDB, 0xC0, 0xFB, 0x6C,
0x77, 0xFC, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03,
0x94, 0xA6, 0x63, 0x3C, 0x63, 0x18, 0x94, 0x90,
},
0
};
cursor watch={
{ -9, -8},
{0x3F, 0xC0, 0x3F, 0xC0, 0x3F, 0xC0, 0x3F, 0xC0,
0x7F, 0xE0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8,
0xFF, 0xF8, 0xFF, 0xF0, 0xFF, 0xF0, 0x7F, 0xE0,
0x3F, 0xC0, 0x3F, 0xC0, 0x3F, 0xC0, 0x3F, 0xC0,
},
{0x1F, 0x80, 0x1F, 0x80, 0x1F, 0x80, 0x1F, 0x80,
0x20, 0x40, 0x42, 0x20, 0x42, 0x20, 0x42, 0x30,
0x4E, 0x30, 0x40, 0x20, 0x40, 0x20, 0x20, 0x40,
0x1F, 0x80, 0x1F, 0x80, 0x1F, 0x80, 0x1F, 0x80,
},
0
};
cursor insertbar={
{ -7, -4},
{0x0C, 0x60, 0x0E, 0xE0, 0x03, 0x80, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
0x03, 0x80, 0x03, 0x80, 0x0E, 0xE0, 0x0C, 0x60,
},
{0x0C, 0x60, 0x02, 0x80, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x0C, 0x60,
},
0
};
cursor hand={
{ -7, 0},
{0x03, 0x80, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0,
0x07, 0xC0, 0x07, 0xC0, 0x77, 0xF8, 0xFF, 0xFE,
0x7F, 0xFF, 0x3F, 0xFF, 0x3F, 0xFF, 0x1F, 0xFF,
0x0F, 0xFF, 0x0F, 0xFE, 0x07, 0xFE, 0x07, 0xFE,
},
{0x03, 0x80, 0x04, 0xC0, 0x04, 0xC0, 0x04, 0xC0,
0x04, 0xC0, 0x04, 0xC0, 0x74, 0xF8, 0x9C, 0xAE,
0x4C, 0xAB, 0x24, 0x0B, 0x24, 0x03, 0x10, 0x03,
0x08, 0x03, 0x08, 0x06, 0x04, 0x06, 0x04, 0x06,
},
0
};
cursor checkpoint={
{ -7, -8},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x00, 0x1C, 0x00, 0x3C, 0x0C, 0x78, 0x1E, 0xF0,
0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x08, 0x00, 0x18, 0x00, 0x30, 0x0C, 0x60,
0x06, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
0
};
cursor blank={
{ 0, 0},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
0
};
cursor pencil={
{-4, -15},
{0x00, 0xF0, 0x01, 0xF8, 0x01, 0xF8, 0x03, 0xF8,
0x03, 0xF0, 0x07, 0xF0, 0x07, 0xE0, 0x0F, 0xE0,
0x0F, 0xC0, 0x1F, 0xC0, 0x1F, 0x80, 0x1F, 0x80,
0x1F, 0x00, 0x1E, 0x00, 0x1C, 0x00, 0x18, 0x00,
},
{0x00, 0x60, 0x00, 0x90, 0x00, 0x90, 0x01, 0x70,
0x01, 0x20, 0x02, 0x20, 0x02, 0x40, 0x04, 0x40,
0x04, 0x80, 0x08, 0x80, 0x09, 0x00, 0x0F, 0x00,
0x0E, 0x00, 0x0C, 0x00, 0x08, 0x00, 0x00, 0x00,
},
0
};
cursor eraser={
{0, -13},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFE,
0x03, 0xFE, 0x07, 0xFF, 0x0F, 0xFF, 0x1F, 0xFE,
0x3F, 0xFC, 0x7F, 0xF8, 0xFF, 0xF0, 0xFF, 0xE0,
0xFF, 0xC0, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00,
},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFE,
0x02, 0x06, 0x04, 0x0B, 0x08, 0x17, 0x10, 0x2E,
0x20, 0x5C, 0x40, 0xB8, 0xFF, 0x70, 0x81, 0xE0,
0x81, 0xC0, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00,
},
0
};
cursor eraserbox={
{0, 0},
{0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x00, 0x00,
},
{0xFF, 0xFE, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02,
0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02,
0x80, 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x02,
0x80, 0x02, 0x80, 0x02, 0xFF, 0xFE, 0x00, 0x00,
},
0
};
cursor paintbrush={
{-2, -15},
{0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE0, 0x03, 0xE0,
0x03, 0xE0, 0x03, 0xE0, 0x1F, 0xFC, 0x1F, 0xFC,
0x1F, 0xFC, 0x1F, 0xFC, 0x1F, 0xFC, 0x1F, 0xFC,
0x1F, 0xFC, 0x1F, 0xFC, 0x3F, 0xFC, 0x7F, 0xF8,
},
{0x00, 0x00, 0x01, 0xC0, 0x01, 0x40, 0x01, 0xC0,
0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x0F, 0xF8,
0x08, 0x08, 0x0F, 0xF8, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x0A, 0xA8, 0x15, 0x58, 0x3F, 0xF0,
},
0
};
cursor spraypaint={
{0, -2},
{0x1F, 0x00, 0xFF, 0xF8, 0xFF, 0xFC, 0xFF, 0xFE,
0x3F, 0x8F, 0x7F, 0xF7, 0x7F, 0xF0, 0x7F, 0xF0,
0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0,
0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0, 0x7F, 0xF0,
},
{0x02, 0x00, 0x1F, 0x00, 0x7F, 0xF8, 0x1F, 0x0C,
0x07, 0x06, 0x07, 0x00, 0x3F, 0xE0, 0x20, 0x20,
0x3F, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x3F, 0xE0, 0x00, 0x00,
},
0
};
cursor macarrow={
{-1, -1},
{0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x00,
0xFC, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x80,
0xFF, 0xC0, 0xFF, 0xE0, 0xFE, 0x00, 0xEF, 0x00,
0xCF, 0x00, 0x87, 0x80, 0x07, 0x80, 0x03, 0x80,
},
{0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00,
0x78, 0x00, 0x7C, 0x00, 0x7E, 0x00, 0x7F, 0x00,
0x7F, 0x80, 0x7C, 0x00, 0x6C, 0x00, 0x46, 0x00,
0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
},
0
};
cursor *cursorlist[] = {
&confirmcursor,
&watch, &insertbar,
&hand, &checkpoint,
&blank, &pencil,
&eraser, &eraserbox,
&paintbrush, &spraypaint,
&macarrow
};
char *cursorname[] = {
"confirm cursor",
"watch cursor", "insertbar cursor",
"hand cursor", "checkpoint cursor",
"blank cursor", "pencil",
"eraser", "eraser box",
"paintbrush", "spraypaint",
"macarrow cursor"
};
#define NCURS (sizeof(cursorlist)/sizeof(cursor *))
void redraw(window *w)
{
fill_rect(w->b, w->b->r, BLUE);
gflush();
}
int main(int argc, char **argv)
{
int i;
mouse m;
ulong key;
window *w;
ginit("Tester", NULL, NULL);
w = new_window("Cursor & Timer Test", rect(0,0,0,0),
Titlebar+Maximize+Resize);
set_winfns(w, NULL, NULL, &redraw);
show_window(w);
do m=get_mouse(w); while (!(m.kind & MouseUp)); /* wait for click */
start_timer(2000); /* start 2 second timer */
for (i=0; i<NCURS; i++) {
while(!can_timer())
continue;
get_timer();
draw_string(w->b, pt(18*(i+1),18*(i+1)), fixed_font,
cursorname[i], WHITE);
set_cursor(cursorlist[i]);
gflush();
}
do m=get_mouse(w); while (!(m.kind & MouseUp)); /* wait for click */
return 0;
}