- 积分
- 10
- 注册时间
- 2007-10-5
- 仿真币
-
- 最后登录
- 1970-1-1
|
本帖最后由 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);
} |
|