Пример #1
0
/*
---------------------------------------
    绘制填充 (坐标)
---------------------------------------
*/
static bool_t
qst_crh_fill_xy (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sFILL   fill;
    sRECT   rect;
    sIMAGE* draw;
    sint_t  sx, sy;
    sint_t  dx, dy;

    /* 参数解析 <X1> <Y1> <X2> <Y2> */
    if (argc < 5)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    sx = (sint_t)str2intxA(argv[1]);
    sy = (sint_t)str2intxA(argv[2]);
    dx = (sint_t)str2intxA(argv[3]);
    dy = (sint_t)str2intxA(argv[4]);
    rect_set_xy(&rect, sx, sy, dx, dy);
    fill.dx = rect.x1;
    fill.dy = rect.y1;
    fill.dw = rect.ww;
    fill.dh = rect.hh;
    s_flldraw(draw, &fill, s_color, NULL);
    return (TRUE);
}
Пример #2
0
/*
---------------------------------------
    绘制椭圆 (坐标)
---------------------------------------
*/
static bool_t
qst_crh_ellps_xy (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sRECT   rect;
    sIMAGE* draw;
    sint_t  sx, sy;
    sint_t  dx, dy;

    /* 参数解析 <X1> <Y1> <X2> <Y2> */
    if (argc < 5)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    sx = (sint_t)str2intxA(argv[1]);
    sy = (sint_t)str2intxA(argv[2]);
    dx = (sint_t)str2intxA(argv[3]);
    dy = (sint_t)str2intxA(argv[4]);
    rect_set_xy(&rect, sx, sy, dx, dy);
    draw_ellipse(draw, &rect, s_color, s_pixdraw);
    return (TRUE);
}
Пример #3
0
/*
---------------------------------------
    绘制椭圆 (宽高)
---------------------------------------
*/
static bool_t
qst_crh_ellps_wh (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sRECT   rect;
    sIMAGE* draw;
    sint_t  sx, sy;
    uint_t  ww, hh;

    /* 参数解析 <X> <Y> <Width> <Height> */
    if (argc < 5)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    sx = (sint_t)str2intxA(argv[1]);
    sy = (sint_t)str2intxA(argv[2]);
    ww = (uint_t)str2intxA(argv[3]);
    hh = (uint_t)str2intxA(argv[4]);
    rect_set_wh(&rect, sx, sy, ww, hh);
    draw_ellipse(draw, &rect, s_color, s_pixdraw);
    return (TRUE);
}
Пример #4
0
/*
---------------------------------------
    移动坐标 (绘制)
---------------------------------------
*/
static bool_t
qst_crh_lineto (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sLINE   line;
    sint_t  newx;
    sint_t  newy;
    sIMAGE* draw;

    /* 参数解析 <X> <Y> */
    if (argc < 3)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    newx = (sint_t)str2intxA(argv[1]);
    newy = (sint_t)str2intxA(argv[2]);
    line_set_xy(&line, s_posx, s_posy, newx, newy);
    draw_line(draw, &line, s_color, s_pixdraw);
    s_posx = newx;
    s_posy = newy;
    return (TRUE);
}
Пример #5
0
/*
---------------------------------------
    创建文字绘制对象 (GDI 字体)
---------------------------------------
*/
static bool_t
qst_crh_winfont (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    leng_t      len;
    LOGFONTA    font;

    CR_NOUSE(parm);

    /* 参数解析 <Height> <FaceName> [Weight] [Width]
                [CharSet] [Quality] [Italic] [Underline]
                [StrikeOut] [Escapement] [Orientation] */
    if (argc < 3)
        return (FALSE);
    if (s_gdi_calls == NULL)
        return (FALSE);

    /* 填充字体生成结构 */
    struct_zero(&font, LOGFONTA);
    font.lfCharSet = DEFAULT_CHARSET;
    font.lfQuality = ANTIALIASED_QUALITY;
    font.lfHeight = (LONG)str2intxA(argv[1]);
    if ((len = str_lenA(argv[2])) >= LF_FACESIZE)
        len = LF_FACESIZE - 1;
    chr_cpyA(font.lfFaceName, argv[2], len);
    if (argc > 3)
        font.lfWeight = (LONG)str2intxA(argv[3]);
    if (argc > 4)
        font.lfWidth = (LONG)str2intxA(argv[4]);
    if (argc > 5)
        font.lfCharSet = (BYTE)str2intxA(argv[5]);
    if (argc > 6)
        font.lfQuality = (BYTE)str2intxA(argv[6]);
    if (argc > 7)
        font.lfItalic = (BYTE)str2intxA(argv[7]);
    if (argc > 8)
        font.lfUnderline = (BYTE)str2intxA(argv[8]);
    if (argc > 9)
        font.lfStrikeOut = (BYTE)str2intxA(argv[9]);
    if (argc > 10)
        font.lfEscapement = (LONG)str2intxA(argv[10]);
    if (argc > 11)
        font.lfOrientation = (LONG)str2intxA(argv[11]);

    /* 生成文字输出对象 */
    if (s_font != NULL)
        CR_VCALL(s_font)->release(s_font);
    s_font = s_gdi_calls->create_fontA(&font);
    if (s_font == NULL)
        return (FALSE);
    return (TRUE);
}
Пример #6
0
/*
---------------------------------------
    绘制文字 (实体/透明)
---------------------------------------
*/
static bool_t
qst_crh_text (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sRECT   rect;
    bool_t  rett;
    bool_t  tran;
    ansi_t* temp;
    ansi_t* text;
    sIMAGE* draw;
    uint_t  ww,hh;
    uint_t  align;

    /* 参数解析 <X> <Y> <EscText> [Width Height Align] */
    if (argc < 4)
        return (FALSE);
    if (s_font == NULL)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);

    /* 必须使用转义字符串 */
    temp = str_fmtA("\"%s\"", argv[3]);
    if (temp == NULL)
        return (FALSE);
    text = str_esc_dupU(temp);
    mem_free(temp);
    if (text == NULL)
        return (FALSE);

    /* 区分实体和透明, 两个命令合并起来了 */
    if (str_cmpA(argv[0], "crh:texts") == 0)
        tran = FALSE;
    else
        tran = TRUE;
    rect.x1 = (sint_t)str2intxA(argv[1]);
    rect.y1 = (sint_t)str2intxA(argv[2]);
    if (argc > 6) {
        ww = str2intxA(argv[4]);
        hh = str2intxA(argv[5]);
        align = str2intxA(argv[6]);
        rect_set_wh(&rect, rect.x1, rect.y1, ww, hh);
    }
    else {
        align = 0;
    }
    rett = qst_crh_text_int(draw, tran, &rect, text, align);
    mem_free(text);
    return (rett);
}
Пример #7
0
/*
---------------------------------------
    创建文字绘制对象 (UCDOS 点阵)
---------------------------------------
*/
static bool_t
qst_crh_ucfont (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    iDATIN* asc;
    iDATIN* hzk;
    iDATIN* chr;
    ansi_t  name[MAX_PATHA];
    uint_t  size, xspc, yspc;

    CR_NOUSE(parm);

    /* 参数解析 <Size> <XSpace> <YSpace> [Suffix] */
    if (argc < 4)
        return (FALSE);

    /* 加载点阵字库文件 */
    size = str2intxA(argv[1]);
    if (argc == 4) {
        sprintf(name, QST_PATH_SOURCE "ucfont\\HZK%u", size);
    }
    else {
        sprintf(name, QST_PATH_SOURCE "ucfont\\HZK%u%c", size,
                      (argv[4])[0]);
    }
    hzk = create_disk_inA(name);
    if (hzk == NULL)
        return (FALSE);
    sprintf(name, QST_PATH_SOURCE "ucfont\\ASC%u", size);
    asc = create_disk_inA(name);
    sprintf(name, QST_PATH_SOURCE "ucfont\\HZK%uT", size);
    chr = create_disk_inA(name);

    /* 创建 UCDOS 点阵汉字绘制对象 */
    xspc = str2intxA(argv[2]);
    yspc = str2intxA(argv[3]);
    if (s_font != NULL)
        CR_VCALL(s_font)->release(s_font);
    s_font = create_ucdos_font(asc, hzk, chr, size, xspc, yspc);
    if (s_font == NULL) {
        CR_VCALL(hzk)->release(hzk);
        if (asc != NULL)
            CR_VCALL(asc)->release(asc);
        if (chr != NULL)
            CR_VCALL(chr)->release(chr);
        return (FALSE);
    }
    return (TRUE);
}
Пример #8
0
/*
---------------------------------------
    绘制图块 (支持对齐)
---------------------------------------
*/
static bool_t
qst_crh_blit2 (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sBLIT   blit;
    sRECT   rect;
    sRECT   dest;
    sRECT*  wins;
    int32u  idxs;
    uint_t  algn;
    sIMAGE* draw;
    sIMAGE* srce;

    /* 参数解析 <SpriteName> <RectName> <Align> [Index] */
    if (argc < 4)
        return (FALSE);
    if (s_resx == NULL)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);

    /* 查找目标矩形对象 */
    wins = egui_res_get_rct(s_resx, argv[2]);
    if (wins == NULL)
        return (FALSE);

    /* 查找目标图片对象 */
    if (argc > 4)
        idxs = str2intxA(argv[4]);
    else
        idxs = 0;
    srce = egui_res_get_img(s_resx, argv[1], idxs, &rect);
    if (srce == NULL)
        return (FALSE);

    /* 计算对齐输出图块 */
    algn = str2intxA(argv[3]);
    rect_set_wh(&dest, wins->x1, wins->y1, rect.ww, rect.hh);
    egui_rect_align(&dest, wins, algn);
    blit.dx = dest.x1;
    blit.dy = dest.y1;
    blit.sx = rect.x1;
    blit.sy = rect.y1;
    blit.sw = dest.ww;
    blit.sh = dest.hh;
    qst_crh_blit_int(draw, srce, &blit);
    return (TRUE);
}
Пример #9
0
/*
---------------------------------------
    移动坐标
---------------------------------------
*/
static bool_t
qst_crh_moveto (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    CR_NOUSE(parm);

    /* 参数解析 <X> <Y> */
    if (argc < 3)
        return (FALSE);
    s_posx = (sint_t)str2intxA(argv[1]);
    s_posy = (sint_t)str2intxA(argv[2]);
    return (TRUE);
}
Пример #10
0
/*
---------------------------------------
    创建文字绘制对象 (自定义点阵)
---------------------------------------
*/
static bool_t
qst_crh_btfont (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    iDATIN* asc;
    iDATIN* hzk;
    ansi_t  name[MAX_PATHA];
    uint_t  size, xspc, yspc;

    CR_NOUSE(parm);

    /* 参数解析 <Size> <XSpace> <YSpace> <Type> */
    if (argc < 5)
        return (FALSE);

    /* 加载点阵字库文件 */
    size = str2intxA(argv[1]);
    sprintf(name, QST_PATH_SOURCE "btfont\\%s_%u.full", argv[4], size);
    hzk = create_disk_inA(name);
    if (hzk == NULL)
        return (FALSE);
    sprintf(name, QST_PATH_SOURCE "btfont\\%s_%u.half", argv[4], size);
    asc = create_disk_inA(name);
    if (asc == NULL) {
        CR_VCALL(hzk)->release(hzk);
        return (FALSE);
    }

    /* 创建自定义点阵文字绘制对象 */
    xspc = str2intxA(argv[2]);
    yspc = str2intxA(argv[3]);
    if (s_font != NULL)
        CR_VCALL(s_font)->release(s_font);
    s_font = create_bit_font(asc, hzk, size, xspc, yspc, argv[4]);
    if (s_font == NULL) {
        CR_VCALL(hzk)->release(hzk);
        CR_VCALL(asc)->release(asc);
        return (FALSE);
    }
    return (TRUE);
}
Пример #11
0
/*
---------------------------------------
    设置透明颜色
---------------------------------------
*/
static bool_t
qst_crh_trans (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    CR_NOUSE(parm);

    /* 参数解析 <Red> <Green> <Blue> [Alpha] */
    if (argc < 4)
        return (FALSE);
    s_trans.c32.rrr = (byte_t)str2intxA(argv[1]);
    s_trans.c32.ggg = (byte_t)str2intxA(argv[2]);
    s_trans.c32.bbb = (byte_t)str2intxA(argv[3]);
    if (argc > 4)
        s_trans.c32.lrp = (byte_t)str2intxA(argv[4]);
    else
        s_trans.c32.lrp = 255;
    return (TRUE);
}
Пример #12
0
/*
---------------------------------------
    绘制正圆
---------------------------------------
*/
static bool_t
qst_crh_circle (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sIMAGE* draw;
    sint_t  cx, cy, rr;

    /* 参数解析 <X> <Y> <Radius> */
    if (argc < 4)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    cx = (sint_t)str2intxA(argv[1]);
    cy = (sint_t)str2intxA(argv[2]);
    rr = (sint_t)str2intxA(argv[3]);
    draw_circle(draw, cx, cy, rr, s_color, s_pixdraw);
    return (TRUE);
}
Пример #13
0
/*
---------------------------------------
    设置颜色
---------------------------------------
*/
static bool_t
qst_crh_color (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    CR_NOUSE(parm);

    /* 参数解析 <Red> <Green> <Blue> [Alpha] */
    if (argc < 4)
        return (FALSE);
    s_color.c32.rrr = (byte_t)str2intxA(argv[1]);
    s_color.c32.ggg = (byte_t)str2intxA(argv[2]);
    s_color.c32.bbb = (byte_t)str2intxA(argv[3]);
    if (argc > 4)
        s_color.c32.lrp = (byte_t)str2intxA(argv[4]);
    else
        s_color.c32.lrp = 255;
    if (s_font == NULL)
        return (TRUE);
    return (CR_VCALL(s_font)->setColor(s_font, s_color.val));
}
Пример #14
0
/*
---------------------------------------
    绘制填充 (宽高)
---------------------------------------
*/
static bool_t
qst_crh_fill_wh (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sFILL   fill;
    sIMAGE* draw;

    /* 参数解析 <X> <Y> <Width> <Height> */
    if (argc < 5)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    fill.dx = (sint_t)str2intxA(argv[1]);
    fill.dy = (sint_t)str2intxA(argv[2]);
    fill.dw = (uint_t)str2intxA(argv[3]);
    fill.dh = (uint_t)str2intxA(argv[4]);
    s_flldraw(draw, &fill, s_color, NULL);
    return (TRUE);
}
Пример #15
0
/*
---------------------------------------
    延时一段时间 (ms)
---------------------------------------
*/
static bool_t
qst_crh_sleep (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    CR_NOUSE(parm);

    /* 参数解析 <TimeMS> */
    if (argc < 2)
        return (FALSE);
    thread_sleep(str2intxA(argv[1]));
    return (TRUE);
}
Пример #16
0
/*
---------------------------------------
    绘制像素
---------------------------------------
*/
static bool_t
qst_crh_pixel (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sint_t  posx;
    sint_t  posy;
    sIMAGE* draw;

    /* 参数解析 <X> <Y> */
    if (argc < 3)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);
    posx = (sint_t)str2intxA(argv[1]);
    posy = (sint_t)str2intxA(argv[2]);
    if (!clip_pixel(posx, posy, &draw->clip_win))
        return (TRUE);
    s_pixdraw(draw, posx, posy, s_color);
    return (TRUE);
}
Пример #17
0
/*
---------------------------------------
    绘制图块 (支持对齐)
---------------------------------------
*/
static bool_t
qst_crh_blit (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sBLIT   blit;
    sRECT   rect;
    sRECT   dest;
    sRECT   wins;
    int32u  idxs;
    sIMAGE* draw;
    sIMAGE* srce;
    uint_t  ww,hh;
    uint_t  align;

    /* 参数解析 <X> <Y> <SpriteName> [Index] [Width Height Align] */
    if (argc < 4)
        return (FALSE);
    if (s_resx == NULL)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);

    /* 查找目标图片对象 */
    if (argc > 4)
        idxs = str2intxA(argv[4]);
    else
        idxs = 0;
    srce = egui_res_get_img(s_resx, argv[3], idxs, &rect);
    if (srce == NULL)
        return (FALSE);

    /* 计算对齐输出图块 */
    dest.x1 = (sint_t)str2intxA(argv[1]);
    dest.y1 = (sint_t)str2intxA(argv[2]);
    rect_set_wh(&dest, dest.x1, dest.y1, rect.ww, rect.hh);
    if (argc > 7) {
        ww = str2intxA(argv[5]);
        hh = str2intxA(argv[6]);
        align = str2intxA(argv[7]);
        rect_set_wh(&wins, dest.x1, dest.y1, ww, hh);
        egui_rect_align(&dest, &wins, align);
    }
    blit.dx = dest.x1;
    blit.dy = dest.y1;
    blit.sx = rect.x1;
    blit.sy = rect.y1;
    blit.sw = dest.ww;
    blit.sh = dest.hh;
    qst_crh_blit_int(draw, srce, &blit);
    return (TRUE);
}
Пример #18
0
/*
---------------------------------------
    打开 UDPv4 通讯接口
---------------------------------------
*/
static bool_t
qst_com_udpv4 (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    uint_t      port;
    socket_t    netw;

    /* 参数解析 <目标地址> <端口号> */
    if (argc < 3)
        return (FALSE);
    port = str2intxA(argv[2]);
    if (port > 65535)
        return (FALSE);

    sQstComm*   ctx = (sQstComm*)parm;

    /* 关闭当前接口并打开 UDPv4 连接 */
    netw = client_udp_open(argv[1], (int16u)port);
    if (netw == NULL)
        return (FALSE);
    socket_set_timeout(netw, QCOM_SNDTOUT, QCOM_CUTDOWN);

    /* 设置工作参数 */
    qst_com_close(parm, argc, argv);
    ctx->comm.obj.netw = netw;
    ctx->comm.send = qst_udpv4_send;

    /* 启动接收线程 */
    ctx->comm.thrd = thread_new(0, qst_udpv4_main, parm, FALSE);
    if (ctx->comm.thrd == NULL) {
        socket_close(netw);
        return (FALSE);
    }
    TRY_FREE(ctx->comm.title);
    ctx->comm.title = str_fmtA(" - UDPv4 \"%s\", %u", argv[1], port);
    qst_update_title(ctx);
    return (TRUE);
}
Пример #19
0
/*
---------------------------------------
    设置显示文本编码
---------------------------------------
*/
static bool_t
qst_com_cpage (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    uint_t  page;

    /* 参数解析 <编码> */
    if (argc < 2)
        return (FALSE);
    page = str2intxA(argv[1]);
    if (page == CR_LOCAL)
        page = get_sys_codepage();
    else
    if (is_cr_widechar(page))
        page = CR_UTF8;
    ((sQstComm*)parm)->page = page;
    return (TRUE);
}
Пример #20
0
/*
---------------------------------------
    打开 RS232 通讯接口
---------------------------------------
*/
static bool_t
qst_com_rs232 (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    int32u  baud;
    uint_t  port, bits;
    uint_t  stop, parity;
    /* --------------- */
    const ansi_t*   sstop;
    const ansi_t*   sparity;

    /* 参数解析 <串口号> [波特率] [数据位] [校验位] [停止位] */
    if (argc < 2)
        return (FALSE);
    bits = 8;
    baud = 115200UL;
    stop = CR_SIO_STOP10;
    parity = CR_SIO_NOP;
    sstop = "1";
    sparity = "no";
    port = str2intxA(argv[1]);
    if (argc > 2) {
        baud = str2intx32A(argv[2]);
        if (argc > 3) {
            bits = str2intxA(argv[3]);
            if (argc > 4) {
                sparity = argv[4];
                if (str_cmpA(argv[4], "no") == 0)
                    parity = CR_SIO_NOP;
                else
                if (str_cmpA(argv[4], "odd") == 0)
                    parity = CR_SIO_ODD;
                else
                if (str_cmpA(argv[4], "even") == 0)
                    parity = CR_SIO_EVEN;
                else
                if (str_cmpA(argv[4], "mark") == 0)
                    parity = CR_SIO_MARK;
                else
                if (str_cmpA(argv[4], "space") == 0)
                    parity = CR_SIO_SPCE;
                else
                    sparity = "no";
                if (argc > 5) {
                    sstop = argv[5];
                    if (str_cmpA(argv[5], "1") == 0)
                        stop = CR_SIO_STOP10;
                    else
                    if (str_cmpA(argv[5], "1.5") == 0)
                        stop = CR_SIO_STOP15;
                    else
                    if (str_cmpA(argv[5], "2") == 0)
                        stop = CR_SIO_STOP20;
                    else
                        sstop = "1";
                }
            }
        }
    }

    sQstComm*   ctx = (sQstComm*)parm;

    /* 关闭当前接口并打开串口 */
    if (!sio_open(port))
        return (FALSE);
    sio_setup(port, baud, bits, parity, stop);
    sio_set_buffer(port, 1024, 1024);
    sio_set_rd_timeout(port, 0, 0, QCOM_CUTDOWN);
    sio_set_wr_timeout(port, 0, QCOM_SNDTOUT);
    sio_clear_error(port);
    sio_flush(port, CR_SIO_FLU_RT);

    /* 设置工作参数 */
    qst_com_close(parm, argc, argv);
    ctx->comm.obj.port = port;
    ctx->comm.send = qst_rs232_send;

    /* 启动接收线程 */
    ctx->comm.thrd = thread_new(0, qst_rs232_main, parm, FALSE);
    if (ctx->comm.thrd == NULL) {
        sio_close(port);
        return (FALSE);
    }
    TRY_FREE(ctx->comm.title);
    ctx->comm.title = str_fmtA(" - COM%u, %u, %u, %s, %s",
                            port, baud, bits, sparity, sstop);
    qst_update_title(ctx);
    return (TRUE);
}
Пример #21
0
/*
---------------------------------------
    绘制文字 (使用外部定义)
---------------------------------------
*/
static bool_t
qst_crh_text_ex (
  __CR_IN__ void_t*     parm,
  __CR_IN__ uint_t      argc,
  __CR_IN__ ansi_t**    argv
    )
{
    sRECT*  rect;
    bool_t  free;
    bool_t  rett;
    bool_t  tran;
    uint_t  algn;
    ansi_t* temp;
    ansi_t* text;
    sIMAGE* draw;

    /* 参数解析 <EscText/TextName> <RectName> <Align> [IsTextName] */
    if (argc < 4)
        return (FALSE);
    if (s_font == NULL)
        return (FALSE);
    if (s_resx == NULL)
        return (FALSE);
    draw = ((sQstView2D*)parm)->paint;
    if (draw == NULL)
        return (FALSE);

    /* 查找目标矩形对象 */
    rect = egui_res_get_rct(s_resx, argv[2]);
    if (rect == NULL)
        return (FALSE);

    /* 找不到或不使用文本名称的时候使用转义字符串 */
    if (argc > 4)
        text = egui_res_get_txt(s_resx, argv[1]);
    else
        text = NULL;
    if (text == NULL) {
        temp = str_fmtA("\"%s\"", argv[1]);
        if (temp == NULL)
            return (FALSE);
        text = str_esc_dupU(temp);
        mem_free(temp);
        if (text == NULL)
            return (FALSE);
        free = TRUE;
    }
    else {
        free = FALSE;
    }

    /* 区分实体和透明, 两个命令合并起来了 */
    if (str_cmpA(argv[0], "crh:texts_ex") == 0)
        tran = FALSE;
    else
        tran = TRUE;
    algn = str2intxA(argv[3]);
    rett = qst_crh_text_int(draw, tran, rect, text, algn);
    if (free)
        mem_free(text);
    return (rett);
}