2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
25 * $XConsortium: brws_edit.c /main/3 1995/11/06 17:20:54 rswiston $
27 * @(#)brws_edit.c 1.2 28 Jan 1994
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special
32 * restrictions in a confidential disclosure agreement between
33 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 * document outside HP, IBM, Sun, USL, SCO, or Univel without
35 * Sun's specific written approval. This document and all copies
36 * and derivative works thereof must be returned or destroyed at
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
45 #include <sys/param.h>
46 #include <sys/types.h>
53 #include <ab_private/obj.h>
54 #include <ab_private/trav.h>
55 #include <ab_private/istr.h>
56 #include <ab/util_types.h>
57 #include <ab_private/abobj.h>
58 #include <ab_private/abobj_set.h>
59 #include <ab_private/proj.h>
60 #include <ab_private/brwsP.h>
61 #include <ab_private/objxm.h>
63 static void browser_textf_activate(
65 XtPointer client_data,
70 browser_textf_activate(
72 XtPointer client_data,
76 ABObj textf_obj = NULL;
77 VNode textf_node = NULL;
80 XtVaGetValues(widget, XmNuserData, &textf_node, NULL);
85 textf_obj = (AB_OBJ *)textf_node->obj_data;
87 newName = XmTextFieldGetString(widget);
92 XtUnmanageChild(widget);
93 XtVaSetValues(widget, XmNuserData, NULL, NULL);
95 if (!util_streq(obj_get_name(textf_obj), newName))
97 abobj_set_name(textf_obj, newName);
98 proj_update_node(textf_obj);
99 brws_update_node(textf_obj);
110 BrowserUiObjects *ui;
115 ui = aob_ui_from_browser(v);
122 XmFontListEntry font_list_entry;
123 XmFontList font_list;
126 draw_area = brws_draw_area(v);
131 font_list_entry = XmFontListEntryCreate(
132 XmFONTLIST_DEFAULT_TAG,
136 font_list = XmFontListAppendEntry(NULL, font_list_entry);
138 ui->textf = XtVaCreateWidget("change_name",
139 xmTextFieldWidgetClass,
141 XmNfontList, font_list,
142 XmNshadowThickness, 0,
143 XmNhighlightThickness, 0,
144 XmNmarginWidth, BRWS_ELM_BBOX_MARGIN,
145 XmNmarginHeight, BRWS_ELM_BBOX_MARGIN,
148 BlackPixelOfScreen(XtScreen(ui->shell)),
150 WhitePixelOfScreen(XtScreen(ui->shell)),
153 XtAddCallback(ui->textf, XmNactivateCallback,
154 (XtCallbackProc)browser_textf_activate,
164 BrowserUiObjects *ui;
169 ui = aob_ui_from_browser(v);
176 XtDestroyWidget(ui->textf);
186 BrowserUiObjects *ui;
191 ui = aob_ui_from_browser(v);
196 if (ui->textf && XtIsManaged(ui->textf))
197 XtUnmanageChild(ui->textf);
202 * Show the edit in place textfield on the node element specified
204 * Also, store the vnode as XmNuserData on the textfield.
215 if (!vnode || (elm_pos < 0) ||
216 !vnode->num_elements ||
217 (elm_pos >= vnode->num_elements))
220 if (!(v = vnode->browser))
223 if (!(ui = aob_ui_from_browser(v)))
228 VNodeElm elm = vnode->elements;
233 XtVaSetValues(ui->textf,
234 XmNvalue, (char *)elm[elm_pos].data,
236 BRWS_ELM_BORDER_WIDTH,
237 XmNy, elm[elm_pos].y -
238 BRWS_ELM_BBOX_MARGIN,
239 XmNwidth, vnode->width -
240 (2 * BRWS_ELM_BORDER_WIDTH),
241 XmNheight, elm[elm_pos].height +
242 (2 * BRWS_ELM_BBOX_MARGIN),
246 XtManageChild(ui->textf);