/************************************************************************* ** ** ** Function Definitions ** ** ** **************************************************************************/ static int scale_initialize( ABObj obj ) { if (obj_get_read_only(obj) == False) { obj_set_unique_name(obj, "scale"); obj_set_label(obj, catgets(Dtb_project_catd, 100, 260, "Scale:")); } else /* Gauge */ { obj_set_unique_name(obj, "gauge"); obj_set_label(obj, catgets(Dtb_project_catd, 100, 261, "Gauge:")); } obj_set_label_position(obj, AB_CP_NORTH); obj_set_orientation(obj, AB_ORIENT_HORIZONTAL); obj_set_direction(obj, AB_DIR_LEFT_TO_RIGHT); obj_set_min_value(obj, 0); obj_set_max_value(obj, 100); obj_set_initial_value_int(obj, 50); obj_set_increment(obj, 1); obj_set_is_initially_visible(obj, True); obj_set_is_initially_active(obj, True); /* REMIND: Hack to get around Motif XmNtitleString bug (when set to NULL) */ obj_set_width(obj, 90); obj_set_height(obj, 18); obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y); obj_set_attachment(obj, AB_CP_WEST, AB_ATTACH_POINT, NULL, obj->x); return OK; }
/* * ui_get_obj_pixmap * based on an object's type and subtype, return a pixmap, and * it's width/height. This pixmap typically can be used to represent * the object in viewers/browsers. */ void ui_get_obj_pixmap ( AB_OBJ *obj, Pixmap *pixmap, /* RETURN */ unsigned int *width, /* RETURN */ unsigned int *height /* RETURN */ ) { int i; AB_OBJECT_TYPE type; int subtype; Pixmap p = NULL; BOOL found = FALSE; if (!obj || !pixmap || !width || !height) return; /* * Initialize pixmaps */ init_obj_pixmaps(); /* * Get object type/subtype */ type = obj_get_type(obj); subtype = obj_get_subtype(obj); /* * Special case for scale/gauge * The subtype field is not used. Instead it's read-only * state is used to determine if it is a scale/gauge. */ if (type == AB_TYPE_SCALE) { if (obj_get_read_only(obj) == False) subtype = AB_SCALE_SCALE; else /* Gauge */ subtype = AB_SCALE_GAUGE; } /* * Search for object type/subtype match */ for (i=0; (object_pixmaps[i].type != AB_TYPE_UNKNOWN); ++i) { if ((type == object_pixmaps[i].type) && (subtype == object_pixmaps[i].subtype)) { *pixmap = object_pixmaps[i].pixmap; *width = object_pixmaps[i].width; *height = object_pixmaps[i].height; if (*pixmap) found = TRUE; break; } } /* * If no match, return the default pixmap */ if (!found) { *pixmap = default_pixmap; *width = default_pixmap_width; *height = default_pixmap_height; } }
static int scale_prop_load( ABObjPtr obj, AB_PROP_TYPE type, unsigned long loadkey ) { PropScaleSettingsRec *pss = &(prop_scale_settings_rec[type]); AB_ORIENTATION orient; BOOL load_all = (loadkey & LoadAll); if (obj == NULL) { if (pss->current_obj != NULL) obj = pss->current_obj; else return ERROR; } else if (!obj_is_scale(obj)) return ERROR; else pss->current_obj = obj; /* Load Name */ if (load_all || loadkey & LoadName) prop_field_set_value(&(pss->name), obj_get_name(obj), False); if (load_all) { /* Load Label Type/Position */ prop_options_set_value(&(pss->label_type), (XtPointer)obj->label_type, False); prop_options_set_value(&(pss->label_pos), (XtPointer)obj_get_label_position(obj), False); /* Load Label */ prop_setup_label_field(&(pss->label), NULL, obj->label_type, obj_get_label(obj), AB_LINE_UNDEF); /* Load Scale Type */ prop_radiobox_set_value(&(pss->scale_type), (XtPointer)obj_get_read_only(obj), False); /* Load Orientation */ orient = obj_get_orientation(obj); prop_radiobox_set_value(&(pss->orient), (XtPointer)orient, False); setup_direction_setting(type, orient); /* Load Direction */ prop_options_set_value(&(pss->dir), (XtPointer)obj_get_direction(obj), False); /* Load Value Range */ prop_field_set_numeric_value(&(pss->min), obj_get_min_value(obj), False); prop_field_set_numeric_value(&(pss->max), obj_get_max_value(obj), False); prop_field_set_numeric_value(&(pss->incr), obj_get_increment(obj), False); /* Load Decimal Points */ prop_field_set_numeric_value(&(pss->decimal), obj_get_decimal_points(obj), False); /* Load Initial Value/Show Value */ prop_field_set_numeric_value(&(pss->ivalue), obj_get_initial_value_int(obj), False); prop_checkbox_set_value(&(pss->show_value), SHOW_VALUE_KEY, obj_get_show_value(obj), False); /* Load Initial State */ prop_checkbox_set_value(&(pss->init_state), AB_STATE_VISIBLE, obj_is_initially_visible(obj), False); prop_checkbox_set_value(&(pss->init_state), AB_STATE_ACTIVE, obj_is_initially_active(obj), False); /* Load Color */ prop_colorfield_set_value(&(pss->bg_color), obj_get_bg_color(obj), False); prop_colorfield_set_value(&(pss->fg_color), obj_get_fg_color(obj), False); turnoff_changebars(type); } /* Load Geometry */ if (load_all || loadkey & LoadPosition) prop_load_obj_position(obj, &(pss->geometry)); if (load_all || loadkey & LoadSize) prop_load_obj_size(obj, &(pss->geometry)); return OK; }