static void custdlg_create_area( ABObj obj, AB_CONTAINER_TYPE area_type ) { ABObj pwobj; ABObj label, area; ABObj workobj; Dimension height; pwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_PW_OBJ); workobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ); area = obj_create(AB_TYPE_CONTAINER, pwobj); obj_set_subtype(area, area_type); pal_initialize_obj(area); if (area_type == AB_CONT_FOOTER) { label = obj_create(AB_TYPE_LABEL, area); obj_set_x(label, 1); obj_set_y(label, 1); pal_initialize_obj(label); obj_set_label(label, catgets(Dtb_project_catd, 100, 264, "footer message")); obj_set_label_alignment(label, AB_ALIGN_LEFT); obj_set_unique_name(label, ab_ident_from_name_and_label(obj_get_name(obj), "label")); /* * Workaround part1: MainWindow bug that causes MainWindow to shrink * when a MessageWindow area is added */ XtVaGetValues(objxm_get_widget(workobj), XmNheight, &height, NULL); } else if (area_type == AB_CONT_BUTTON_PANEL) custdlg_create_buttons(obj, area); abobj_show_tree(area, True); /* Workaround part2 */ if (area_type == AB_CONT_FOOTER) XtVaSetValues(objxm_get_widget(workobj), XmNheight, height, NULL); abobj_set_save_needed(obj_get_module(obj), True); }
/* ** Set the label glyph (ie graphic) on an object */ void ui_obj_set_label_glyph( ABObj obj, STRING fileName ) { ABObj labelObj = NULL; if (obj == NULL) return; if (util_strempty(fileName)) return; labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ); if (labelObj == NULL || objxm_get_widget(labelObj) == NULL) return; switch (obj_get_type(obj)) { case AB_TYPE_BUTTON: case AB_TYPE_CHOICE: case AB_TYPE_COMBO_BOX: case AB_TYPE_LABEL: case AB_TYPE_LIST: case AB_TYPE_SPIN_BOX: case AB_TYPE_SCALE: case AB_TYPE_TEXT_FIELD: ui_set_label_glyph(objxm_get_widget(labelObj), fileName); break; case AB_TYPE_ITEM: switch(obj_get_item_type(obj)) { case AB_ITEM_FOR_MENU: case AB_ITEM_FOR_MENUBAR: case AB_ITEM_FOR_CHOICE: ui_set_label_glyph(objxm_get_widget(labelObj), fileName); break; default: break; } break; default: break; } }
void abobj_move_selected( ABObj *sel_list, int sel_count, XRectangle *start, XRectangle *stop ) { ABObj obj; XRectangle obj_rect; int i; /* * Loop through all selected objects with the same owner. Only * move selected objects, groups without anchors, and anchored groups * if the anchor is also selected. */ /* andy, revisit to add in all the group and anchor stuff */ for (i = 0; i < sel_count; i++) { obj = sel_list[i]; x_get_widget_rect(objxm_get_widget(obj), &obj_rect); rect_passtochild(start->x, start->y, &obj_rect); rect_passtoparent(stop->x, stop->y, &obj_rect); /* undo_record_move(obj); */ abobj_set_xy(obj, (int)obj_rect.x, (int)obj_rect.y); abobj_instantiate_changes(obj); } }
void abobj_nudge_selected( ABObj *sel_list, int sel_count, short x_delta, short y_delta, BOOL reselect ) { ABObj moveobj; ABObj xyobj; XRectangle new_rect; int i; for (i=0; i < sel_count; i++) { if (obj_is_layers(obj_get_parent(sel_list[i]))) moveobj = obj_get_parent(sel_list[i]); else moveobj = sel_list[i]; xyobj = objxm_comp_get_subobj(moveobj, AB_CFG_POSITION_OBJ); x_get_widget_rect(objxm_get_widget(xyobj), &new_rect); new_rect.x += x_delta; new_rect.y += y_delta; /* Move object */ abobj_set_xy(moveobj, new_rect.x, new_rect.y); /* if (xyobj->attachments) abobj_calculate_new_layout(xyobj, new_rect.x, new_rect.y, new_rect.width, new_rect.height); */ abobj_tree_instantiate_changes(moveobj); /* * UGLY WORKAROUND for Motif bug which prevents a 1 pixel move * to the Left from working if only 1 object is being moved... */ if (sel_count == 1 && x_delta == -1) abobj_force_dang_form_resize(moveobj); if (reselect) abobj_select(sel_list[i]); } }
static void subtract_attached_label( ABObj obj, XRectangle *r_rect ) { ABObj lblObj; Widget lbl_widget; Dimension lbl_w = 0; Dimension lbl_h = 0; Dimension margin = 0; Dimension spacing = 0; Dimension width, height; if (!abobj_has_attached_label(obj)) return; lblObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ); lbl_widget = objxm_get_widget(lblObj); if (lblObj != NULL && lbl_widget != NULL) { switch(obj_get_label_position(obj)) { case AB_CP_WEST: XtVaGetValues(lbl_widget, XmNwidth, &lbl_w, NULL); XtVaGetValues(XtParent(lbl_widget), /* RowColumn */ XmNmarginWidth, &margin, XmNspacing, &spacing, NULL); width = r_rect->width - lbl_w - (2*margin) - spacing; r_rect->width = width; break; case AB_CP_NORTH: XtVaGetValues(lbl_widget, XmNheight, &lbl_h, NULL); XtVaGetValues(XtParent(lbl_widget), /* RowColumn */ XmNmarginHeight, &margin, XmNspacing, &spacing, NULL); height = r_rect->height - lbl_h - (2*margin) - spacing; r_rect->height = height; break; default: break; } } }
/* ** Set the label string on an object ** (converts it to XmString internally, if needed) */ void ui_obj_set_label_string( ABObj obj, STRING label ) { ABObj labelObj = NULL; if (obj == NULL) return; switch (obj_get_type(obj)) { case AB_TYPE_BUTTON: case AB_TYPE_CHOICE: case AB_TYPE_COMBO_BOX: case AB_TYPE_LABEL: case AB_TYPE_LIST: case AB_TYPE_SPIN_BOX: case AB_TYPE_SCALE: case AB_TYPE_TEXT_FIELD: labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ); if (labelObj == NULL || objxm_get_widget(labelObj) == NULL) return; ui_set_label_string(objxm_get_widget(labelObj), label); break; case AB_TYPE_ITEM: switch(obj_get_item_type(obj)) { case AB_ITEM_FOR_MENU: case AB_ITEM_FOR_MENUBAR: case AB_ITEM_FOR_CHOICE: labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ); if (labelObj == NULL || objxm_get_widget(labelObj) == NULL) return; ui_set_label_string(objxm_get_widget(labelObj), label); break; case AB_ITEM_FOR_COMBO_BOX: case AB_ITEM_FOR_LIST: case AB_ITEM_FOR_SPIN_BOX: { ABObj p_obj = obj_get_parent(obj); Widget parent = objxm_get_widget(p_obj); AB_ITEM_TYPE itype = (AB_ITEM_TYPE)obj_get_subtype(obj); int pos; int num_items; XmString xmitem; if (parent != NULL) { xmitem = XmStringCreateLocalized(label); pos = obj_get_child_num(obj); pos++; /* XmList starts at 1 */ if (obj_is_combo_box_item(obj)) parent = ui_combobox_get_list_widget(parent); if (obj_is_list_item(obj) || obj_is_combo_box_item(obj)) XtVaGetValues(parent, XmNitemCount, &num_items, NULL); else if (obj_is_spin_box_item(obj)) XtVaGetValues(parent, DtNnumValues, &num_items, NULL); if (pos <= num_items) { if (obj_is_list_item(obj) || obj_is_combo_box_item(obj)) { XmListReplacePositions(parent, &pos, &xmitem, 1); } else { DtSpinBoxDeletePos(parent, pos); DtSpinBoxAddItem(parent, xmitem, pos); } } XmStringFree(xmitem); } } break; default: break; } break; case AB_TYPE_BASE_WINDOW: case AB_TYPE_DIALOG: case AB_TYPE_FILE_CHOOSER: labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ); if (labelObj == NULL || objxm_get_widget(labelObj) == NULL) return; XtVaSetValues(objxm_get_widget(labelObj), XmNtitle, label, NULL); break; default: break; } }
/* * Action: Show the module when double-clicked on. */ static void show_module( Widget widget, XEvent *event, String *params, int num_params ) { Vwr v = NULL; VNode selected_node; VMethods m; ABObj obj; ABObj winobj; AB_TRAVERSAL trav; XtVaGetValues(widget, XmNuserData, &v, NULL); if (!v) return; selected_node = vwr_locate_node(v, event->xbutton.x, event->xbutton.y); if (selected_node) { VNode *selected_nodes = NULL; int num_selected = 0; if (!(m = v->methods)) return; /* USE METHODS !! */ obj = (ABObj) selected_node->obj_data; if (!obj) return; /* * Set busy cursor before this potentially * lengthy operation */ ab_set_busy_cursor(TRUE); /* If the module is already showing, then * make all of its windows come to the fore- * ground. */ if (obj_has_flag(obj, MappedFlag)) { for (trav_open(&trav, obj, AB_TRAV_WINDOWS); (winobj = trav_next(&trav)) != NULL; ) { if (obj_has_flag(winobj, MappedFlag)) ui_win_front(objxm_get_widget(winobj)); } trav_close(&trav); proj_set_cur_module(obj); } else if( abobj_show_tree(obj, TRUE) == -1 ) { if (util_get_verbosity() > 0) fprintf(stderr,"show_module: error in abobj_show_tree\n"); } else { proj_set_cur_module(obj); } vwr_get_cond(v->current_tree, &selected_nodes, &num_selected, select_fn); if (selected_nodes) free((char *)selected_nodes); update_menu_items(0, num_selected); /* * Unset busy cursor */ ab_set_busy_cursor(FALSE); } }
/* * Function for undoing RESIZE */ static void undo_resize( ABUndoRec undo_rec ) { Position x, y; int width, height, i; ABObj obj; if (!undo_rec) return; /* * Set undo to undo this resize (undo of undo) */ (void)abobj_set_undo(undo_rec->list, undo_rec->count, undo_resize, AB_UNDO_RESIZE); /* * For each object that was resized */ for (i = 0; i < undo_rec->count; ++i) { BOOL w_resizable, h_resizable; /* * If undo record is not the right type, something is WRONG !! */ if (undo_rec->info_list[i].type != AB_UNDO_RESIZE) continue; obj = undo_rec->list[i]; w_resizable = abobj_width_resizable(obj); h_resizable = abobj_height_resizable(obj); /* * Get current x,y position */ if (obj->ui_handle) { XtVaGetValues(objxm_get_widget(obj), XmNx, &x, XmNy, &y, NULL); } else { x = (Position)obj_get_x(obj); y = (Position)obj_get_y(obj); } /* * Get previous width/height */ width = undo_rec->info_list[i].info.resize.width; height = undo_rec->info_list[i].info.resize.height; /* * Resize the object ! */ resize_in_pixels(obj, (int)width, (int)height, border_w); abobj_set_xy(obj, (int)x, (int)y); if (xy_obj->attachments) abobj_calculate_new_layout(xy_obj, (int)x, (int)y, width, height); abobj_instantiate_changes(obj); /* WORKAROUND for Motif XmForm bug (it ignores child resize request * if x,y have not also changed). So, we have to force it. */ abobj_force_dang_form_resize(xy_obj); if (util_get_verbosity() > 3) objxm_dump_widget_geometry(xy_widget); } }
/* * Draw rubberbanding outline for resizing action */ int abobjP_resize_object_outline( ABObj obj, XEvent *event, RESIZE_DIR dir ) { ABObj s_obj; static Widget parent; static Window rootwin; static Display *dpy; static XRectangle orig_r, r; static int last_x, last_y; int x,y; char buf[80]; if (event->type == MotionNotify) { x = ((XMotionEvent*)event)->x_root; y = ((XMotionEvent*)event)->y_root; } else if (event->type == ButtonPress) { x = ((XButtonEvent*)event)->x_root; y = ((XButtonEvent*)event)->y_root; } else return -1; if (first_move) { Window win; int orig_x, orig_y; int trans_x, trans_y; if (obj_is_item(obj)) obj = obj_get_parent(obj); obj = obj_get_root(obj); xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ); xy_widget = (Widget)xy_obj->ui_handle; if (xy_widget == NULL) { if (util_get_verbosity() > 0) fprintf(stderr,"abobjP_resize_object_outline: %s :no SIZE widget\n", util_strsafe(obj_get_name(obj))); return ERROR; } parent = XtParent(xy_widget); dpy = XtDisplay(xy_widget); rootwin = RootWindowOfScreen(XtScreen(xy_widget)); x_get_widget_rect(xy_widget, &orig_r); if (obj_has_border_frame(obj)) /* We have a border-frame to deal with */ { XRectangle pane_r; s_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ); /* Determine width of border */ x_get_widget_rect(objxm_get_widget(s_obj), &pane_r); border_w = ((int)(orig_r.width - pane_r.width))/2; } else border_w = 0; orig_r.width--; orig_r.height--; r = orig_r; orig_x = (int)orig_r.x; orig_y = (int)orig_r.y; XTranslateCoordinates(dpy, XtWindow(parent), rootwin, orig_x , orig_y, &trans_x, &trans_y, &win); r.x = (short)trans_x; r.y = (short)trans_y; first_move = FALSE; } else /* erase previous outline */ { make_rect(&resize_rect, &r, last_x, last_y, dir); x_fullscreen_box(xy_widget, rootwin, resize_rect.x, resize_rect.y, rect_right(&resize_rect), rect_bottom(&resize_rect)); } make_rect(&resize_rect, &r, x, y, dir); x_fullscreen_box(xy_widget, rootwin, resize_rect.x, resize_rect.y, rect_right(&resize_rect), rect_bottom(&resize_rect)); sprintf(buf, "%3.3dx%3.3d", resize_rect.width, resize_rect.height); /* REMIND: aim, update status region on ab palette win */ last_x = x; last_y = y; return OK; }
/* * Return resize-direction corresponding to cursor x,y position */ RESIZE_DIR abobjP_find_resize_direction ( ABObj obj, Widget widget, XEvent *event ) { ABObj rootObj; XRectangle w_rect; XRectangle temp; int half_handle; int half_width; int half_height; int x, y; int orig_x, orig_y; int grabbox_size; if (event->type == MotionNotify) { orig_x = x = ((XMotionEvent*)event)->x; orig_y = y = ((XMotionEvent*)event)->y; } else if (event->type == ButtonPress) { orig_x = x = ((XButtonEvent*)event)->x; orig_y = y = ((XButtonEvent*)event)->y; } else return NONE; if (obj_is_item(obj)) obj = obj_get_parent(obj); rootObj = obj_get_root(obj); rect_zero_out(&w_rect); if ((obj_is_drawing_area(obj) || obj_is_text_pane(obj)) && (obj_has_hscrollbar(obj) || obj_has_vscrollbar(obj)) ) { ABObj swobj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ); Widget cwidget; XtVaGetValues((Widget)swobj->ui_handle, XmNclipWindow, &cwidget, NULL); if (cwidget) x_get_widget_rect(cwidget, &w_rect); } else if (rootObj != obj) { Window win; XTranslateCoordinates(XtDisplay(widget), XtWindow(widget), XtWindow(objxm_get_widget(rootObj)), orig_x , orig_y, &x, &y, &win); widget = objxm_get_widget(rootObj); } if (w_rect.width == 0 || w_rect.height == 0) x_get_widget_rect(widget, &w_rect); /* if (obj_is_control(obj)) grabbox_size = (AB_selected_rect_size / 2) + 1; else */ grabbox_size = AB_selected_rect_size; /* Readjust coordinates to remove offset within the parent window. */ w_rect.x = 0; w_rect.y = 0; /* Exit if we are not near the border. */ temp = w_rect; x_adjust_rect_margin(&temp, 0 - grabbox_size); if (obj_is_control_panel(rootObj) && rect_includespoint (&temp, x, y)) return (NONE); if (!abobj_is_directly_resizable(rootObj)) return (MOVE); half_handle = grabbox_size/ 2 + 1; half_width = w_rect.width / 2; half_height = w_rect.height / 2; temp.width = temp.height = grabbox_size + 2; /******************************** * SOUTH_EAST * Most common ? *********************************/ temp.x = w_rect.width - grabbox_size; temp.y = w_rect.height - grabbox_size; if (rect_includespoint (&temp, x, y)) return (SOUTH_EAST); /******************************** * SOUTH_WEST *********************************/ temp.x = 0; temp.y = w_rect.height - grabbox_size; if (rect_includespoint (&temp, x, y)) return (SOUTH_WEST); /******************************** * NORTH *********************************/ temp.x = half_width - half_handle; temp.y = 0; if (rect_includespoint (&temp, x, y)) return (NORTH); /******************************** * SOUTH *********************************/ temp.x = half_width - half_handle; temp.y = w_rect.height - grabbox_size; if (rect_includespoint (&temp, x, y)) return (SOUTH); /******************************** * EAST *********************************/ temp.x = w_rect.width - grabbox_size; temp.y = half_height - half_handle; if (rect_includespoint (&temp, x, y)) return (EAST); /******************************** * WEST *********************************/ temp.x = 0; temp.y = half_height - half_handle; if (rect_includespoint (&temp, x, y)) return (WEST); /******************************** * NORTH_EAST *********************************/ temp.x = w_rect.width - grabbox_size; temp.y = 0; if (rect_includespoint (&temp, x, y)) return (NORTH_EAST); /******************************** * NORTH_WEST *********************************/ temp.x = 0; temp.y = 0; if (rect_includespoint (&temp, x, y)) return (NORTH_WEST); /******************************** * Must be a move. *********************************/ return (MOVE); }