找回密码
 注册
Simdroid-非首页
查看: 109|回复: 3

[二次开发] demo uistyler position selection

[复制链接]
发表于 2009-9-19 23:16:24 | 显示全部楼层 |阅读模式 来自 湖北武汉
本帖最后由 lirui0726 于 2009-9-19 23:18 编辑

To test this example - you must create a simple dialog:
    1.  Change CHANGE to test
    2.  Assign the constructor "const_cb" on the Callbacks tab
    3.  Enable selection on the Selection tab
    4.  Enable both Single Postion and Rectangle Position
    5.  Save the dialog to your application directory as test.dlg


#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_styler.h>

#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))

static int report_error( char *file, int line, char *call, int irc)
{
    if (irc)
    {
        char err[133],
             msg[133];

        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
            irc, line, file);
        UF_get_fail_message(irc, err);

        UF_print_syslog(msg, FALSE);
        UF_print_syslog(err, FALSE);
        UF_print_syslog("\n", FALSE);
        UF_print_syslog(call, FALSE);
        UF_print_syslog(";\n", FALSE);

        if (!UF_UI_open_listing_window())
        {
            UF_UI_write_listing_window(msg);
            UF_UI_write_listing_window(err);
            UF_UI_write_listing_window("\n");
            UF_UI_write_listing_window(call);
            UF_UI_write_listing_window(";\n");
        }
    }

    return(irc);
}


static int select_cb(int n_sel, tag_t *sel_objects, int n_des,
    tag_t *des_objects, void *user_data, UF_UI_selection_p_t select)
{
    int
        descriptor;
    tag_t
        view;
    double
        pos[3],
        pos1[3],
        pos2[3],
        pos3[3],
        pos4[3];
    UF_OBJ_disp_props_t
        attrib = { 1, UF_OBJ_WHITE, UF_OBJ_NOT_BLANKED, UF_OBJ_WIDTH_NORMAL,
            UF_OBJ_FONT_SOLID, FALSE};

    UF_CALL(UF_UI_ask_sel_descriptor(select, &descriptor));

    if (descriptor & UF_UI_SEL_DESC_SINGLE_POSITION)
    {
        UF_CALL(UF_UI_ask_sel_cursor_pos(select, &view, pos));

        UF_CALL(UF_DISP_display_temporary_point(view, UF_DISP_USE_VIEW_TAG,
            pos, &attrib, UF_DISP_POINT));
    }

    if (descriptor & UF_UI_SEL_DESC_RECTANGLE_POSITION)
    {
        UF_CALL(UF_UI_ask_sel_rectangle_pos(select, &view, pos1, pos2, pos3,
            pos4));
        UF_CALL(UF_DISP_display_temporary_line(view, UF_DISP_USE_VIEW_TAG,
            pos1, pos3, &attrib));
        UF_CALL(UF_DISP_display_temporary_line(view, UF_DISP_USE_VIEW_TAG,
            pos3, pos2, &attrib));
        UF_CALL(UF_DISP_display_temporary_line(view, UF_DISP_USE_VIEW_TAG,
            pos2, pos4, &attrib));
        UF_CALL(UF_DISP_display_temporary_line(view, UF_DISP_USE_VIEW_TAG,
            pos4, pos1, &attrib));

    }

    return( UF_UI_CB_CONTINUE_DIALOG);

}

static int TEST_const_cb(int dialog_id, void *client_data,
    UF_STYLER_item_value_type_p_t callback_data)
{
    UF_STYLER_item_value_type_t
        value;

    value.item_id = UF_STYLER_DIALOG_INDEX;
    value.item_attr  = UF_STYLER_SELECTION;
    UF_CALL(UF_STYLER_ask_value(dialog_id, &value));

    UF_CALL(UF_UI_set_sel_procs(value.value.selection, NULL, select_cb, NULL));

    UF_CALL(UF_STYLER_free_value(&value ));

    return (UF_UI_CB_CONTINUE_DIALOG);
}

static void do_it(void)
{
    int
        resp;
    UF_STYLER_callback_info_t
        TEST_cbs[2] = {
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB, 0, TEST_const_cb},
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 } };

    UF_CALL(UF_STYLER_create_dialog("test", TEST_cbs, 2, NULL, &resp));
}


void ufusr(char *param, int *retcode, int paramLen)
{
    if (UF_CALL(UF_initialize())) return;
    do_it();
    UF_terminate();
}

int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}
发表于 2009-9-21 10:31:45 | 显示全部楼层 来自 黑龙江哈尔滨
Simdroid开发平台
程序实验过了,谢谢版主,今天看了版主推荐的书,突然感觉自己的思路有点儿错误,如果想实现交互功能,完全可以应用UG提供的标准对话框函数,准备试一下uc1609(),应该能满足要求!
回复 不支持

使用道具 举报

 楼主| 发表于 2009-9-21 18:16:56 | 显示全部楼层 来自 河北廊坊
何不试试uc1613,功能更全
回复 不支持

使用道具 举报

发表于 2009-9-21 19:02:23 | 显示全部楼层 来自 黑龙江哈尔滨
恩,对,可以输入多种数据!

评分

1

查看全部评分

回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-9-23 00:27 , Processed in 0.044796 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表