Hallo flyer,
anbei zwei Beispiele von PLMSolutions, die hoffentlich deine
Frage beantwoten.
Gruß Michael
Date: 18-SEP-2002
Subject: Sample API program to set uistyler dialogs default action
/*HEAD SET_UISTYLER_DIALOGS_DEFAULT_ACTION CCC UFUN */
/* To create a dialog to use with this program:
- Select Application->User Interface Styler
- Change the dialog's Prefix Name to "GTAC"
- Specify the Constructor Callback as GTAC_"const_cb"
- Add a Push Button object
- Specify its Activate callback ask GTAC_"push_cb"
- Save Dialog As "gtac"
*/
#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)))
#define GTAC_ACTION_0 ("ACTION_0")
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];
UF_get_fail_message(irc, err);
sprintf(msg, "error %d at line %d in %s", irc, line, file);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n\n");
}
else
{
#ifdef _USRDLL
uc1601(err, TRUE);
uc1601(msg, TRUE);
#else
fprintf(stderr, "%s\n", err);
fprintf(stderr, "%s\n", msg);
fprintf(stderr, "%s;\n\n", call);
#endif
}
}
return(irc);
}
#define WRITE(X) UF_UI_open_listing_window(); UF_UI_write_listing_window(X)
#define WRITE_D(X) (write_integer_to_listing_window(#X, X))
static void write_integer_to_listing_window(char *title, int n)
{
char
msg[MAX_LINE_SIZE+1];
UF_CALL(UF_UI_open_listing_window());
sprintf(msg, "%s = %d\n", title, n);
UF_CALL(UF_UI_write_listing_window(msg));
}
/*ARGSUSED*/
static int GTAC_const_cb(int dialog_id, void *client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
UF_STYLER_item_value_type_t
set_value;
WRITE("Setting default to action button...\n");
set_value.item_attr = UF_STYLER_DEFAULT_ACTION;
set_value.item_id = GTAC_ACTION_0;
UF_CALL(UF_STYLER_set_value(dialog_id, &set_value));
return (UF_UI_CB_CONTINUE_DIALOG);
}
/*ARGSUSED*/
static int GTAC_push_cb(int dialog_id, void *client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
UF_STYLER_item_value_type_t
set_value;
WRITE("Setting default to OK button...\n");
set_value.item_attr = UF_STYLER_SENSITIVITY;
set_value.item_id = UF_STYLER_NAV_INDEX;
set_value.subitem_index = UF_STYLER_OK_INDEX;
set_value.value.integer = TRUE;
UF_CALL(UF_STYLER_set_value(dialog_id, &set_value));
set_value.item_attr = UF_STYLER_DEFAULT_ACTION;
set_value.item_id = UF_STYLER_NAV_INDEX;
set_value.subitem_index = UF_STYLER_OK_INDEX;
UF_CALL(UF_STYLER_set_value(dialog_id, &set_value));
return (UF_UI_CB_CONTINUE_DIALOG);
}
static void do_it(void)
{
int
resp;
UF_STYLER_callback_info_t GTAC_cbs[3] = {
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB , 0, GTAC_const_cb},
{GTAC_ACTION_0 , UF_STYLER_ACTIVATE_CB , 0, GTAC_push_cb},
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }};
UF_CALL(UF_STYLER_create_dialog("gtac.dlg", GTAC_cbs, 3, NULL, &resp));
WRITE_D(resp);
}
/*ARGSUSED*/
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);
}
Date: 18-SEP-2002
Subject: Sample API program to remove uistyler default action
/*HEAD REMOVE_UISTYLER_DEFAULT_ACTION CCC UFUN */
/*
This program demonstrates a method enabling you to post a UIStyler dialog
where there is no default action, so that nothing happens when the user
presses the middle mouse button (MB2). This is done by setting the default
action to a dummy push button on the dialog, and then making this push
button invisible.
To create a dialog to use with this program:
- Select Application->User Interface Styler
- Change the dialog's Prefix Name to "GTAC"
- Specify the Constructor Callback as GTAC_"const_cb"
- Add a Push Button object
- Add another Push Button object
- Save Dialog As "gtac"
*/
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_styler.h>
#define GTAC_ACTION_0 ("ACTION_0")
#define GTAC_ACTION_1 ("ACTION_1")
#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);
/* NOTE: UF_print_syslog is new in V18 */
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);
}
#define WRITE(X) UF_UI_open_listing_window(); UF_UI_write_listing_window(X)
#define WRITE_D(X) (write_integer_to_listing_window(#X, X))
static void write_integer_to_listing_window(char *title, int n)
{
char
msg[MAX_LINE_SIZE+1];
UF_CALL(UF_UI_open_listing_window());
sprintf(msg, "%s = %d\n", title, n);
UF_CALL(UF_UI_write_listing_window(msg));
}
/*ARGSUSED*/
static int GTAC_const_cb(int dialog_id, void *client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
UF_STYLER_item_value_type_t
set_value;
WRITE("Removing default action...\n");
/* Set the default to the second button */
set_value.item_attr = UF_STYLER_DEFAULT_ACTION;
set_value.item_id = GTAC_ACTION_1;
UF_CALL(UF_STYLER_set_value(dialog_id, &set_value));
/* Make the second button invisible */
set_value.item_attr = UF_STYLER_VISIBILITY;
set_value.item_id = GTAC_ACTION_1;
set_value.value.integer = FALSE;
UF_CALL(UF_STYLER_set_value(dialog_id, &set_value));
/* Work around for PR 4007701 - OK gets greyed out automatically */
set_value.item_attr = UF_STYLER_SENSITIVITY;
set_value.item_id = UF_STYLER_NAV_INDEX;
set_value.subitem_index = UF_STYLER_OK_INDEX;
set_value.value.integer = TRUE;
UF_CALL(UF_STYLER_set_value(dialog_id, &set_value));
/* End - Work around for PR 4007701 */
return (UF_UI_CB_CONTINUE_DIALOG);
}
/*ARGSUSED*/
static int GTAC_action_0_act_cb(int dialog_id, void *client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
WRITE("Pushed button...\n");
return (UF_UI_CB_CONTINUE_DIALOG);
}
static void do_it(void)
{
int
resp;
UF_STYLER_callback_info_t GTAC_cbs[3] = {
{UF_STYLER_DIALOG_INDEX, UF_STYLER_CONSTRUCTOR_CB , 0, GTAC_const_cb},
{GTAC_ACTION_0, UF_STYLER_ACTIVATE_CB, 0, GTAC_action_0_act_cb},
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }};
UF_CALL(UF_STYLER_create_dialog("gtac.dlg", GTAC_cbs, 3, NULL, &resp));
WRITE_D(resp);
}
/*ARGSUSED*/
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);
}
------------------
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP