|
1 /***************************************************************************
2 * Filename :
hello.c
3 * Begin
: 2008-05-09 16:24:44
4 * Project
: Hello Nano-X World
5 * Version
: 1.1
6 * Copyright
: GPL v2.0
7 * Author :
Wu Yin (吴垠)
8 * Description
:
9 * Email
: lazy.fox.wu#gmail.com
10 **************************************************************************/
11 #include
<stdio.h>
12 #include
"nano-X.h"
13 #include
"nxcolors.h"
14
15 int main()
16 {
17 GR_WINDOW_ID root_wid,
wid;
18 GR_GC_ID gc;
19 GR_COORD x,
y;
20 GR_SIZE width,
height;
21 GR_EVENT event;
22 GR_FONT_ID fid;
23
24 x = 0;
25 y = 0;
26 width = 640;
27 height = 480;
28
29 if (GrOpen() < 0)
30 {
31 printf("Can't open graphics\n");
32 return 0;
33 }
34
35 gc = GrNewGC();
36 fid = GrCreateFont("HZKFONT",
16, NULL);
37 // 创建父窗口(根窗口)
38 root_wid = GrNewWindow(GR_ROOT_WINDOW_ID,
x, y, width, height,
39 1,
GR_COLOR_ROYALBLUE, GR_COLOR_BLACK);
40 // 创建一个子窗口
41 wid=GrNewWindow(root_wid,60,60,200,60,1,GR_COLOR_BLACK,GR_COLOR_WHITE);
42 GrMapWindow(root_wid); // 绘制父窗口
43 GrMapWindow(wid);
// 绘制子窗口
44
45 // 显示在父窗口中的文字
46 GrSetGCForeground(gc,
GR_COLOR_RED); // 前景色(字体颜色)
47 GrSetGCBackground(gc,
GR_COLOR_GREEN); // 背景色(字体背景颜色)
48 GrSetGCFont(gc,
fid);
49 GrText(root_wid, gc,
10, 20,
"你好 in root_wid", -1, GR_TFBOTTOM);
50
51 // 显示在子窗口中的文字
52 GrSetGCForeground(gc,
GR_COLOR_RED); // 前景色(字体颜色)
53 GrSetGCBackground(gc,
GR_COLOR_GREEN); // 背景色(字体背景颜色)
54 GrText(wid, gc, 10, 20, "你好 in wid", -1, GR_TFBOTTOM);
55
56 for (;;)
57 {
58 GrGetNextEvent(&event);
59 }
60 GrClose();
61
62 return 1;
63 }
64
|