网上另一稿nano-x 的hello world,只有图框没hello,郁闷......

 

 /***************************************************************************
  *  Filename    : hello.c
  *  Begin       : 2010.5.25
  *  Project     : Hello Nano-X World
  *  Version     : 1.0
  *  Copyright   : GPL v2.0
  *  Author      : uunubt
  *  Description :
  ***************************************************************************/
 #include <stdio.h>
 #include "nano-X.h"
 #include "nxcolors.h"

 int main()
 {
     GR_WINDOW_ID root_wid, wid;
     GR_GC_ID gc;
     GR_COORD x, y;
     GR_SIZE width, height;
     GR_EVENT event;
 
     x = 0;
     y = 0;
     width = 640;
     height = 480;
 
     if (GrOpen() < 0)
     {
         printf("Can't open graphics/n");
         return 0;
     }
 
     gc = GrNewGC();
     // 创建父窗口(根窗口)
     root_wid = GrNewWindow(GR_ROOT_WINDOW_ID, x, y, width, height,
             1, GR_COLOR_ROYALBLUE, GR_COLOR_BLACK);
     // 创建一个子窗口
     wid = GrNewWindow(root_wid, 60, 60, 200, 60, 1, GR_COLOR_BLACK, GR_COLOR_WHITE);
     GrMapWindow(root_wid);  // 绘制父窗口
     GrMapWindow(wid);       // 绘制子窗口
 
     // 显示在父窗口中的文字
     GrSetGCForeground(gc, GR_COLOR_RED);   // 前景色(字体颜色)
     GrSetGCBackground(gc, GR_COLOR_GREEN); // 背景色(字体背景颜色)
     GrText(root_wid, gc, 10, 20, "Hello in root_wid", -1, GR_TFBOTTOM);
 
     // 显示在子窗口中的文字
     GrSetGCForeground(gc, GR_COLOR_RED);   // 前景色(字体颜色)
     GrSetGCBackground(gc, GR_COLOR_GREEN); // 背景色(字体背景颜色)
     GrText(wid, gc, 10, 20, "Hello in wid", -1, GR_TFBOTTOM);
 
     for (;;)
     {
         GrGetNextEvent(&event);
     }
     GrClose();
 
     return 1;
 }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值