3 * also includes region clipping demo
10 #define MWINCLUDECOLORS
16 #define CLIP_POLYGON 0 /* =1 for polygonal region test*/
23 #define FONT1 "HZKFONT"
24 #define FONT2 "HZKFONT"
25 #define FONT3 "HZKFONT"
26 #define FONT4 "HZKFONT"
27 #define FONT5 "HZKFONT"
29 #define FONT1 "HZXFONT"
30 #define FONT2 "HZXFONT"
31 #define FONT3 "HZXFONT"
32 #define FONT4 "HZXFONT"
33 #define FONT5 "HZXFONT"
35 #elif HAVE_T1LIB_SUPPORT
40 #define FONT4 "dcbx10"
45 #define FONT1 "lt1-r-omega-serif"
49 #define FONT5 "timesi"
52 static char * names[5] = { FONT1, FONT2, FONT3, FONT4, FONT5 };
61 GR_REGION_ID regionid = 0;
63 GR_POINT points[]={ {100, 100},
68 GR_RECT clip_rect={100,100,300,300};
74 window = GrNewWindow(GR_ROOT_WINDOW_ID, 50,50, MAXW,MAXH, 4, BLACK,BLUE);
80 /* polygon clip region*/
81 regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points);
83 /* rectangle clip region*/
84 regionid = GrNewRegion();
85 GrUnionRectWithRegion(regionid, &clip_rect);
88 GrSetGCRegion(gc, regionid);
90 GrSelectEvents(window,GR_EVENT_MASK_ALL);
91 GrSetGCUseBackground(gc,GR_FALSE);
92 GrSetGCBackground(gc, GR_RGB(0, 0, 0));
94 GrCheckNextEvent(&event);
96 i = (int)((float)MAXFONTS * rand() / (RAND_MAX + 1.0));
97 fontid = GrCreateFont(names[i], 20, NULL);
98 GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0)));
99 GrSetFontRotation(fontid, 330); /* 33 degrees*/
100 GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
101 GrSetGCFont(gc, fontid);
102 /*GrSetGCBackground(gc, rand() & 0xffffff);*/
103 GrSetGCForeground(gc, rand() & 0xffffff);
104 x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
105 y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0));
108 { /* to test Unicode 16 chinese characters display ,use HZK font Bitmap font (Metrix font). */
132 GrText(window, gc,x,y+20, buffer,17, GR_TFUC16);
134 GrText(window, gc,x,y+20, buffer,17, GR_TFUC16);
136 unsigned short buffer[7];
144 GrText(window, gc,x,y+20, buffer,7, GR_TFUC16);
146 GrText(window, gc,x,y+20, buffer,7, GR_TFUC16);
152 /* HZK Metrix font test, includes Chinese and English*/
153 GrText(window, gc,x,y, "Microwindows,»¶ÓʹÓÃÖÐÓ¢ÎĵãÕó×ÖÌå",
156 GrText(window, gc,x,y, "Microwindows,Åwªï¨Ï¥Î¤¤^¤åÂI°}¦rÅé",
159 GrText(window, gc,x,y, "£t£u£v£w£¸£¹£º", -1, GR_TFASCII);
163 #else /* !HZK_FONT_SUPPORT*/
165 #if HAVE_BIG5_SUPPORT
166 /* ENCODING_BIG5 test*/
167 GrText(window, gc,x,y, "±d±d", -1, GR_TFASCII);
169 #if HAVE_GB2312_SUPPORT
170 /* ENCODING_GB2312 test*/
171 GrText(window, gc,x,y, "\275\241\275\241", -1, GR_TFASCII);
174 GrText(window, gc,x,y, "Microwindows", -1, GR_TFASCII);
178 #endif /* HZK_FONT_SUPPORT*/
181 GrDestroyFont(fontid);
183 if(event.type == GR_EVENT_TYPE_CLOSE_REQ) {
189 GrDestroyRegion(regionid);