15dfecf96Smrg/* 25dfecf96Smrg * Copyright (c) 2001 by The XFree86 Project, Inc. 35dfecf96Smrg * 45dfecf96Smrg * Permission is hereby granted, free of charge, to any person obtaining a 55dfecf96Smrg * copy of this software and associated documentation files (the "Software"), 65dfecf96Smrg * to deal in the Software without restriction, including without limitation 75dfecf96Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 85dfecf96Smrg * and/or sell copies of the Software, and to permit persons to whom the 95dfecf96Smrg * Software is furnished to do so, subject to the following conditions: 105dfecf96Smrg * 115dfecf96Smrg * The above copyright notice and this permission notice shall be included in 125dfecf96Smrg * all copies or substantial portions of the Software. 135dfecf96Smrg * 145dfecf96Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 155dfecf96Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 165dfecf96Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 175dfecf96Smrg * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 185dfecf96Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 195dfecf96Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 205dfecf96Smrg * SOFTWARE. 215dfecf96Smrg * 225dfecf96Smrg * Except as contained in this notice, the name of the XFree86 Project shall 235dfecf96Smrg * not be used in advertising or otherwise to promote the sale, use or other 245dfecf96Smrg * dealings in this Software without prior written authorization from the 255dfecf96Smrg * XFree86 Project. 265dfecf96Smrg * 275dfecf96Smrg * Author: Paulo César Pereira de Andrade 285dfecf96Smrg */ 295dfecf96Smrg 305dfecf96Smrg/* $XFree86: xc/programs/xedit/lisp/modules/xaw.c,v 1.15tsi Exp $ */ 315dfecf96Smrg 325dfecf96Smrg#include <stdlib.h> 335dfecf96Smrg#include <X11/Intrinsic.h> 345dfecf96Smrg#include <X11/StringDefs.h> 355dfecf96Smrg#include <X11/Xaw/AsciiSink.h> 365dfecf96Smrg#include <X11/Xaw/AsciiSrc.h> 375dfecf96Smrg#include <X11/Xaw/AsciiText.h> 385dfecf96Smrg#include <X11/Xaw/Box.h> 395dfecf96Smrg#include <X11/Xaw/Command.h> 405dfecf96Smrg#include <X11/Xaw/Dialog.h> 415dfecf96Smrg#include <X11/Xaw/Form.h> 425dfecf96Smrg#include <X11/Xaw/Grip.h> 435dfecf96Smrg#include <X11/Xaw/Label.h> 445dfecf96Smrg#include <X11/Xaw/List.h> 455dfecf96Smrg#include <X11/Xaw/MenuButton.h> 465dfecf96Smrg#include <X11/Xaw/MultiSink.h> 475dfecf96Smrg#include <X11/Xaw/MultiSrc.h> 485dfecf96Smrg#include <X11/Xaw/Paned.h> 495dfecf96Smrg#include <X11/Xaw/Panner.h> 505dfecf96Smrg#include <X11/Xaw/Porthole.h> 515dfecf96Smrg#include <X11/Xaw/Repeater.h> 525dfecf96Smrg#include <X11/Xaw/Scrollbar.h> 535dfecf96Smrg#include <X11/Xaw/Simple.h> 545dfecf96Smrg#include <X11/Xaw/SimpleMenu.h> 555dfecf96Smrg#include <X11/Xaw/SmeBSB.h> 565dfecf96Smrg#include <X11/Xaw/Sme.h> 575dfecf96Smrg#include <X11/Xaw/SmeLine.h> 585dfecf96Smrg#include <X11/Xaw/StripChart.h> 595dfecf96Smrg#include <X11/Xaw/Text.h> 605dfecf96Smrg#include <X11/Xaw/TextSink.h> 615dfecf96Smrg#include <X11/Xaw/TextSrc.h> 625dfecf96Smrg#include <X11/Xaw/Tip.h> 635dfecf96Smrg#include <X11/Xaw/Toggle.h> 645dfecf96Smrg#include <X11/Xaw/Tree.h> 655dfecf96Smrg#include <X11/Xaw/Viewport.h> 665dfecf96Smrg#include <X11/Vendor.h> 675dfecf96Smrg#include "lisp/internal.h" 685dfecf96Smrg#include "lisp/private.h" 695dfecf96Smrg 705dfecf96Smrg/* 715dfecf96Smrg * Types 725dfecf96Smrg */ 735dfecf96Smrgtypedef struct { 745dfecf96Smrg LispObj *object; 755dfecf96Smrg void *data; 765dfecf96Smrg} WidgetData; 775dfecf96Smrg 785dfecf96Smrg/* 795dfecf96Smrg * Prototypes 805dfecf96Smrg */ 815dfecf96Smrgint xawLoadModule(void); 825dfecf96Smrgvoid LispXawCleanupCallback(Widget, XtPointer, XtPointer); 835dfecf96Smrg 845dfecf96Smrg/* until a better/smarter interface be written... */ 855dfecf96SmrgLispObj *Lisp_XawCoerceToListReturnStruct(LispBuiltin*); 865dfecf96SmrgLispObj *Lisp_XawScrollbarCoerceToReal(LispBuiltin*); 875dfecf96Smrg 885dfecf96SmrgLispObj *Lisp_XawFormDoLayout(LispBuiltin*); 895dfecf96SmrgLispObj *Lisp_XawListChange(LispBuiltin*); 905dfecf96SmrgLispObj *Lisp_XawListHighlight(LispBuiltin*); 915dfecf96SmrgLispObj *Lisp_XawListUnhighlight(LispBuiltin*); 925dfecf96SmrgLispObj *Lisp_XawTextGetSource(LispBuiltin*); 935dfecf96SmrgLispObj *Lisp_XawTextLastPosition(LispBuiltin*); 945dfecf96SmrgLispObj *Lisp_XawTextReplace(LispBuiltin*); 955dfecf96SmrgLispObj *Lisp_XawTextSearch(LispBuiltin*); 965dfecf96SmrgLispObj *Lisp_XawTextGetInsertionPoint(LispBuiltin*); 975dfecf96SmrgLispObj *Lisp_XawTextSetInsertionPoint(LispBuiltin*); 985dfecf96SmrgLispObj *Lisp_XawScrollbarSetThumb(LispBuiltin*); 995dfecf96Smrg 1005dfecf96Smrg/* 1015dfecf96Smrg * Initialization 1025dfecf96Smrg */ 1035dfecf96Smrg 1045dfecf96Smrgstatic LispBuiltin lispbuiltins[] = { 1055dfecf96Smrg {LispFunction, Lisp_XawCoerceToListReturnStruct, "xaw-coerce-to-list-return-struct opaque"}, 1065dfecf96Smrg {LispFunction, Lisp_XawScrollbarCoerceToReal, "xaw-scrollbar-coerce-to-real opaque"}, 1075dfecf96Smrg 1085dfecf96Smrg {LispFunction, Lisp_XawScrollbarSetThumb, "xaw-scrollbar-set-thumb widget top &optional shown"}, 1095dfecf96Smrg {LispFunction, Lisp_XawFormDoLayout, "xaw-form-do-layout widget force"}, 1105dfecf96Smrg {LispFunction, Lisp_XawListChange, "xaw-list-change widget list &optional longest resize"}, 1115dfecf96Smrg {LispFunction, Lisp_XawListHighlight, "xaw-list-highlight widget index"}, 1125dfecf96Smrg {LispFunction, Lisp_XawListUnhighlight, "xaw-list-unhighlight widget"}, 1135dfecf96Smrg {LispFunction, Lisp_XawTextGetSource, "xaw-text-get-source widget"}, 1145dfecf96Smrg {LispFunction, Lisp_XawTextLastPosition, "xaw-text-last-position widget"}, 1155dfecf96Smrg {LispFunction, Lisp_XawTextReplace, "xaw-text-replace widget left right text"}, 1165dfecf96Smrg {LispFunction, Lisp_XawTextSearch, "xaw-text-search widget direction text"}, 1175dfecf96Smrg {LispFunction, Lisp_XawTextGetInsertionPoint, "xaw-text-get-insertion-point widget"}, 1185dfecf96Smrg {LispFunction, Lisp_XawTextSetInsertionPoint, "xaw-text-set-insertion-point widget position"}, 1195dfecf96Smrg}; 1205dfecf96Smrg 1215dfecf96SmrgLispModuleData xawLispModuleData = { 1225dfecf96Smrg LISP_MODULE_VERSION, 1235dfecf96Smrg xawLoadModule 1245dfecf96Smrg}; 1255dfecf96Smrg 1265dfecf96Smrgstatic int xawWidget_t, xawWidgetClass_t, xawListReturnStruct_t, xawFloatp_t; 1275dfecf96Smrgstatic WidgetData **list_data; 1285dfecf96Smrgstatic int num_list_data; 1295dfecf96Smrg 1305dfecf96Smrg/* 1315dfecf96Smrg * Implementation 1325dfecf96Smrg */ 1335dfecf96Smrgint 1345dfecf96SmrgxawLoadModule(void) 1355dfecf96Smrg{ 1365dfecf96Smrg int i; 1375dfecf96Smrg char *fname = "XAW-LOAD-MODULE"; 1385dfecf96Smrg 1395dfecf96Smrg xawWidget_t = LispRegisterOpaqueType("Widget"); 1405dfecf96Smrg xawWidgetClass_t = LispRegisterOpaqueType("WidgetClass"); 1415dfecf96Smrg xawListReturnStruct_t = LispRegisterOpaqueType("XawListReturnStruct"); 1425dfecf96Smrg xawFloatp_t = LispRegisterOpaqueType("float*"); 1435dfecf96Smrg 1445dfecf96Smrg LispExecute("(DEFSTRUCT XAW-LIST-RETURN-STRUCT STRING INDEX)\n"); 1455dfecf96Smrg 1465dfecf96Smrg GCDisable(); 1475dfecf96Smrg (void)LispSetVariable(ATOM2("ASCII-SINK-OBJECT-CLASS"), 1485dfecf96Smrg OPAQUE(asciiSinkObjectClass, xawWidgetClass_t), 1495dfecf96Smrg fname, 0); 1505dfecf96Smrg (void)LispSetVariable(ATOM2("ASCII-SRC-OBJECT-CLASS"), 1515dfecf96Smrg OPAQUE(asciiSinkObjectClass, xawWidgetClass_t), 1525dfecf96Smrg fname, 0); 1535dfecf96Smrg (void)LispSetVariable(ATOM2("ASCII-TEXT-WIDGET-CLASS"), 1545dfecf96Smrg OPAQUE(asciiTextWidgetClass, xawWidgetClass_t), 1555dfecf96Smrg fname, 0); 1565dfecf96Smrg (void)LispSetVariable(ATOM2("BOX-WIDGET-CLASS"), 1575dfecf96Smrg OPAQUE(boxWidgetClass, xawWidgetClass_t), 1585dfecf96Smrg fname, 0); 1595dfecf96Smrg (void)LispSetVariable(ATOM2("COMMAND-WIDGET-CLASS"), 1605dfecf96Smrg OPAQUE(commandWidgetClass, xawWidgetClass_t), 1615dfecf96Smrg fname, 0); 1625dfecf96Smrg (void)LispSetVariable(ATOM2("DIALOG-WIDGET-CLASS"), 1635dfecf96Smrg OPAQUE(dialogWidgetClass, xawWidgetClass_t), 1645dfecf96Smrg fname, 0); 1655dfecf96Smrg (void)LispSetVariable(ATOM2("FORM-WIDGET-CLASS"), 1665dfecf96Smrg OPAQUE(formWidgetClass, xawWidgetClass_t), 1675dfecf96Smrg fname, 0); 1685dfecf96Smrg (void)LispSetVariable(ATOM2("GRIP-WIDGET-CLASS"), 1695dfecf96Smrg OPAQUE(gripWidgetClass, xawWidgetClass_t), 1705dfecf96Smrg fname, 0); 1715dfecf96Smrg (void)LispSetVariable(ATOM2("LABEL-WIDGET-CLASS"), 1725dfecf96Smrg OPAQUE(labelWidgetClass, xawWidgetClass_t), 1735dfecf96Smrg fname, 0); 1745dfecf96Smrg (void)LispSetVariable(ATOM2("LIST-WIDGET-CLASS"), 1755dfecf96Smrg OPAQUE(listWidgetClass, xawWidgetClass_t), 1765dfecf96Smrg fname, 0); 1775dfecf96Smrg (void)LispSetVariable(ATOM2("MENU-BUTTON-WIDGET-CLASS"), 1785dfecf96Smrg OPAQUE(menuButtonWidgetClass, xawWidgetClass_t), 1795dfecf96Smrg fname, 0); 1805dfecf96Smrg (void)LispSetVariable(ATOM2("MULTI-SINK-OBJEC-TCLASS"), 1815dfecf96Smrg OPAQUE(multiSinkObjectClass, xawWidgetClass_t), 1825dfecf96Smrg fname, 0); 1835dfecf96Smrg (void)LispSetVariable(ATOM2("MULTI-SRC-OBJECT-CLASS"), 1845dfecf96Smrg OPAQUE(multiSrcObjectClass, xawWidgetClass_t), 1855dfecf96Smrg fname, 0); 1865dfecf96Smrg (void)LispSetVariable(ATOM2("PANED-WIDGET-CLASS"), 1875dfecf96Smrg OPAQUE(panedWidgetClass, xawWidgetClass_t), 1885dfecf96Smrg fname, 0); 1895dfecf96Smrg (void)LispSetVariable(ATOM2("PANNER-WIDGET-CLASS"), 1905dfecf96Smrg OPAQUE(pannerWidgetClass, xawWidgetClass_t), 1915dfecf96Smrg fname, 0); 1925dfecf96Smrg (void)LispSetVariable(ATOM2("PORTHOLE-WIDGET-CLASS"), 1935dfecf96Smrg OPAQUE(portholeWidgetClass, xawWidgetClass_t), 1945dfecf96Smrg fname, 0); 1955dfecf96Smrg (void)LispSetVariable(ATOM2("REPEATER-WIDGET-CLASS"), 1965dfecf96Smrg OPAQUE(repeaterWidgetClass, xawWidgetClass_t), 1975dfecf96Smrg fname, 0); 1985dfecf96Smrg (void)LispSetVariable(ATOM2("SCROLLBAR-WIDGET-CLASS"), 1995dfecf96Smrg OPAQUE(scrollbarWidgetClass, xawWidgetClass_t), 2005dfecf96Smrg fname, 0); 2015dfecf96Smrg (void)LispSetVariable(ATOM2("SIMPLE-MENU-WIDGET-CLASS"), 2025dfecf96Smrg OPAQUE(simpleMenuWidgetClass, xawWidgetClass_t), 2035dfecf96Smrg fname, 0); 2045dfecf96Smrg (void)LispSetVariable(ATOM2("SIMPLE-WIDGET-CLASS"), 2055dfecf96Smrg OPAQUE(simpleWidgetClass, xawWidgetClass_t), 2065dfecf96Smrg fname, 0); 2075dfecf96Smrg (void)LispSetVariable(ATOM2("SME-BSB-OBJECT-CLASS"), 2085dfecf96Smrg OPAQUE(smeBSBObjectClass, xawWidgetClass_t), 2095dfecf96Smrg fname, 0); 2105dfecf96Smrg (void)LispSetVariable(ATOM2("SME-LINE-OBJECT-CLASS"), 2115dfecf96Smrg OPAQUE(smeLineObjectClass, xawWidgetClass_t), 2125dfecf96Smrg fname, 0); 2135dfecf96Smrg (void)LispSetVariable(ATOM2("SME-OBJECT-CLASS"), 2145dfecf96Smrg OPAQUE(smeObjectClass, xawWidgetClass_t), 2155dfecf96Smrg fname, 0); 2165dfecf96Smrg (void)LispSetVariable(ATOM2("STRIP-CHART-WIDGET-CLASS"), 2175dfecf96Smrg OPAQUE(stripChartWidgetClass, xawWidgetClass_t), 2185dfecf96Smrg fname, 0); 2195dfecf96Smrg (void)LispSetVariable(ATOM2("TEXT-WIDGET-CLASS"), 2205dfecf96Smrg OPAQUE(textWidgetClass, xawWidgetClass_t), 2215dfecf96Smrg fname, 0); 2225dfecf96Smrg (void)LispSetVariable(ATOM2("TEXT-SINKOBJECT-CLASS"), 2235dfecf96Smrg OPAQUE(textSinkObjectClass, xawWidgetClass_t), 2245dfecf96Smrg fname, 0); 2255dfecf96Smrg (void)LispSetVariable(ATOM2("TEXT-SRC-OBJECT-CLASS"), 2265dfecf96Smrg OPAQUE(textSrcObjectClass, xawWidgetClass_t), 2275dfecf96Smrg fname, 0); 2285dfecf96Smrg (void)LispSetVariable(ATOM2("TIP-WIDGET-CLASS"), 2295dfecf96Smrg OPAQUE(tipWidgetClass, xawWidgetClass_t), 2305dfecf96Smrg fname, 0); 2315dfecf96Smrg (void)LispSetVariable(ATOM2("TOGGLE-WIDGET-CLASS"), 2325dfecf96Smrg OPAQUE(toggleWidgetClass, xawWidgetClass_t), 2335dfecf96Smrg fname, 0); 2345dfecf96Smrg (void)LispSetVariable(ATOM2("TREE-WIDGET-CLASS"), 2355dfecf96Smrg OPAQUE(treeWidgetClass, xawWidgetClass_t), 2365dfecf96Smrg fname, 0); 2375dfecf96Smrg (void)LispSetVariable(ATOM2("VIEWPORT-WIDGET-CLASS"), 2385dfecf96Smrg OPAQUE(viewportWidgetClass, xawWidgetClass_t), 2395dfecf96Smrg fname, 0); 2405dfecf96Smrg (void)LispSetVariable(ATOM2("VENDOR-SHELL-WIDGET-CLASS"), 2415dfecf96Smrg OPAQUE(vendorShellWidgetClass, xawWidgetClass_t), 2425dfecf96Smrg fname, 0); 2435dfecf96Smrg 2445dfecf96Smrg /* return codes of XawTextReplace */ 2455dfecf96Smrg (void)LispSetVariable(ATOM2("XAW-REPLACE-ERROR"), 2465dfecf96Smrg INTEGER(XawReplaceError), fname, 0); 2475dfecf96Smrg (void)LispSetVariable(ATOM2("XAW-EDIT-DONE"), 2485dfecf96Smrg INTEGER(XawEditDone), fname, 0); 2495dfecf96Smrg (void)LispSetVariable(ATOM2("XAW-EDIT-ERROR"), 2505dfecf96Smrg INTEGER(XawEditError), fname, 0); 2515dfecf96Smrg (void)LispSetVariable(ATOM2("XAW-POSITION-ERROR"), 2525dfecf96Smrg INTEGER(XawPositionError), fname, 0); 2535dfecf96Smrg 2545dfecf96Smrg /* return code of XawTextSearch */ 2555dfecf96Smrg (void)LispSetVariable(ATOM2("XAW-TEXT-SEARCH-ERROR"), 2565dfecf96Smrg INTEGER(XawTextSearchError), fname, 0); 2575dfecf96Smrg 2585dfecf96Smrg /* enum XawTextScanDirection */ 2595dfecf96Smrg (void)LispSetVariable(ATOM2("XAWSD-LEFT"), 2605dfecf96Smrg INTEGER(XawsdLeft), fname, 0); 2615dfecf96Smrg (void)LispSetVariable(ATOM2("XAWSD-RIGHT"), 2625dfecf96Smrg INTEGER(XawsdRight), fname, 0); 2635dfecf96Smrg GCEnable(); 2645dfecf96Smrg 2655dfecf96Smrg for (i = 0; i < sizeof(lispbuiltins) / sizeof(lispbuiltins[0]); i++) 2665dfecf96Smrg LispAddBuiltinFunction(&lispbuiltins[i]); 2675dfecf96Smrg 2685dfecf96Smrg return (1); 2695dfecf96Smrg} 2705dfecf96Smrg 2715dfecf96Smrgvoid 2725dfecf96SmrgLispXawCleanupCallback(Widget w, XtPointer user_data, XtPointer call_data) 2735dfecf96Smrg{ 2745dfecf96Smrg WidgetData *data = (WidgetData*)user_data; 2755dfecf96Smrg 2765dfecf96Smrg UPROTECT(CAR(data->object), data->object); 2775dfecf96Smrg XtFree((XtPointer)data->data); 2785dfecf96Smrg XtFree((XtPointer)data); 2795dfecf96Smrg} 2805dfecf96Smrg 2815dfecf96SmrgLispObj * 2825dfecf96SmrgLisp_XawCoerceToListReturnStruct(LispBuiltin *builtin) 2835dfecf96Smrg/* 2845dfecf96Smrg xaw-coerce-to-list-return-struct opaque 2855dfecf96Smrg */ 2865dfecf96Smrg{ 2875dfecf96Smrg LispObj *result, *code, *ocod = COD; 2885dfecf96Smrg XawListReturnStruct *retlist; 2895dfecf96Smrg 2905dfecf96Smrg LispObj *opaque; 2915dfecf96Smrg 2925dfecf96Smrg opaque = ARGUMENT(0); 2935dfecf96Smrg 2945dfecf96Smrg if (!CHECKO(opaque, xawListReturnStruct_t)) 2955dfecf96Smrg LispDestroy("%s: cannot convert %s to XawListReturnStruct", 2965dfecf96Smrg STRFUN(builtin), STROBJ(opaque)); 2975dfecf96Smrg 2985dfecf96Smrg retlist = (XawListReturnStruct*)(opaque->data.opaque.data); 2995dfecf96Smrg 3005dfecf96Smrg GCDisable(); 3015dfecf96Smrg code = CONS(ATOM("MAKE-XAW-LIST-RETURN-STRUCT"), 3025dfecf96Smrg CONS(KEYWORD("STRING"), 3035dfecf96Smrg CONS(STRING(retlist->string), 3045dfecf96Smrg CONS(KEYWORD("INDEX"), 3055dfecf96Smrg CONS(INTEGER(retlist->list_index), NIL))))); 3065dfecf96Smrg COD = CONS(code, COD); 3075dfecf96Smrg GCEnable(); 3085dfecf96Smrg 3095dfecf96Smrg result = EVAL(code); 3105dfecf96Smrg COD = ocod; 3115dfecf96Smrg 3125dfecf96Smrg return (result); 3135dfecf96Smrg} 3145dfecf96Smrg 3155dfecf96SmrgLispObj * 3165dfecf96SmrgLisp_XawScrollbarCoerceToReal(LispBuiltin *builtin) 3175dfecf96Smrg/* 3185dfecf96Smrg xaw-scrollbar-coerce-to-real opaque 3195dfecf96Smrg */ 3205dfecf96Smrg{ 3215dfecf96Smrg float *floatp; 3225dfecf96Smrg double real; 3235dfecf96Smrg 3245dfecf96Smrg LispObj *opaque; 3255dfecf96Smrg 3265dfecf96Smrg opaque = ARGUMENT(0); 3275dfecf96Smrg 3285dfecf96Smrg if (!CHECKO(opaque, xawFloatp_t)) 3295dfecf96Smrg LispDestroy("%s: cannot convert %s to float*", 3305dfecf96Smrg STRFUN(builtin), STROBJ(opaque)); 3315dfecf96Smrg 3325dfecf96Smrg floatp = (float*)(opaque->data.opaque.data); 3335dfecf96Smrg real = *floatp; 3345dfecf96Smrg 3355dfecf96Smrg return (DFLOAT(real)); 3365dfecf96Smrg} 3375dfecf96Smrg 3385dfecf96SmrgLispObj * 3395dfecf96SmrgLisp_XawFormDoLayout(LispBuiltin *builtin) 3405dfecf96Smrg/* 3415dfecf96Smrg xaw-form-do-layout widget force 3425dfecf96Smrg */ 3435dfecf96Smrg{ 3445dfecf96Smrg int force; 3455dfecf96Smrg 3465dfecf96Smrg LispObj *owidget, *oforce; 3475dfecf96Smrg 3485dfecf96Smrg oforce = ARGUMENT(1); 3495dfecf96Smrg owidget = ARGUMENT(0); 3505dfecf96Smrg 3515dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 3525dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 3535dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 3545dfecf96Smrg 3555dfecf96Smrg force = oforce != NIL; 3565dfecf96Smrg XawFormDoLayout((Widget)(owidget->data.opaque.data), force); 3575dfecf96Smrg 3585dfecf96Smrg return (oforce); 3595dfecf96Smrg} 3605dfecf96Smrg 3615dfecf96SmrgLispObj * 3625dfecf96SmrgLisp_XawTextGetSource(LispBuiltin *builtin) 3635dfecf96Smrg/* 3645dfecf96Smrg xaw-text-get-source widget 3655dfecf96Smrg */ 3665dfecf96Smrg{ 3675dfecf96Smrg LispObj *owidget; 3685dfecf96Smrg 3695dfecf96Smrg owidget = ARGUMENT(0); 3705dfecf96Smrg 3715dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 3725dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 3735dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 3745dfecf96Smrg 3755dfecf96Smrg return (OPAQUE(XawTextGetSource((Widget)(owidget->data.opaque.data)), 3765dfecf96Smrg xawWidget_t)); 3775dfecf96Smrg} 3785dfecf96Smrg 3795dfecf96SmrgLispObj * 3805dfecf96SmrgLisp_XawTextLastPosition(LispBuiltin *builtin) 3815dfecf96Smrg/* 3825dfecf96Smrg xaw-text-last-position widget 3835dfecf96Smrg */ 3845dfecf96Smrg{ 3855dfecf96Smrg LispObj *owidget; 3865dfecf96Smrg 3875dfecf96Smrg owidget = ARGUMENT(0); 3885dfecf96Smrg 3895dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 3905dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 3915dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 3925dfecf96Smrg 3935dfecf96Smrg return (FIXNUM(XawTextLastPosition((Widget)(owidget->data.opaque.data)))); 3945dfecf96Smrg} 3955dfecf96Smrg 3965dfecf96SmrgLispObj * 3975dfecf96SmrgLisp_XawTextGetInsertionPoint(LispBuiltin *builtin) 3985dfecf96Smrg/* 3995dfecf96Smrg xaw-text-get-insertion-point widget 4005dfecf96Smrg */ 4015dfecf96Smrg{ 4025dfecf96Smrg LispObj *owidget; 4035dfecf96Smrg 4045dfecf96Smrg owidget = ARGUMENT(0); 4055dfecf96Smrg 4065dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 4075dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 4085dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 4095dfecf96Smrg 4105dfecf96Smrg return (FIXNUM(XawTextGetInsertionPoint((Widget)(owidget->data.opaque.data)))); 4115dfecf96Smrg} 4125dfecf96Smrg 4135dfecf96SmrgLispObj * 4145dfecf96SmrgLisp_XawTextSetInsertionPoint(LispBuiltin *builtin) 4155dfecf96Smrg/* 4165dfecf96Smrg xaw-text-set-insertion-point widget position 4175dfecf96Smrg */ 4185dfecf96Smrg{ 4195dfecf96Smrg Widget widget; 4205dfecf96Smrg XawTextPosition position; 4215dfecf96Smrg 4225dfecf96Smrg LispObj *owidget, *oposition; 4235dfecf96Smrg 4245dfecf96Smrg oposition = ARGUMENT(1); 4255dfecf96Smrg owidget = ARGUMENT(0); 4265dfecf96Smrg 4275dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 4285dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 4295dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 4305dfecf96Smrg widget = (Widget)(owidget->data.opaque.data); 4315dfecf96Smrg 4325dfecf96Smrg CHECK_INDEX(oposition); 4335dfecf96Smrg position = (XawTextPosition)FIXNUM_VALUE(oposition); 4345dfecf96Smrg 4355dfecf96Smrg XawTextSetInsertionPoint(widget, position); 4365dfecf96Smrg 4375dfecf96Smrg return (oposition); 4385dfecf96Smrg} 4395dfecf96Smrg 4405dfecf96SmrgLispObj * 4415dfecf96SmrgLisp_XawTextReplace(LispBuiltin *builtin) 4425dfecf96Smrg/* 4435dfecf96Smrg xaw-text-replace widget left right text 4445dfecf96Smrg */ 4455dfecf96Smrg{ 4465dfecf96Smrg Widget widget; 4475dfecf96Smrg XawTextPosition left, right; 4485dfecf96Smrg XawTextBlock block; 4495dfecf96Smrg 4505dfecf96Smrg LispObj *owidget, *oleft, *oright, *otext; 4515dfecf96Smrg 4525dfecf96Smrg otext = ARGUMENT(3); 4535dfecf96Smrg oright = ARGUMENT(2); 4545dfecf96Smrg oleft = ARGUMENT(1); 4555dfecf96Smrg owidget = ARGUMENT(0); 4565dfecf96Smrg 4575dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 4585dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 4595dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 4605dfecf96Smrg widget = (Widget)(owidget->data.opaque.data); 4615dfecf96Smrg 4625dfecf96Smrg CHECK_INDEX(oleft); 4635dfecf96Smrg left = (XawTextPosition)FIXNUM_VALUE(oleft); 4645dfecf96Smrg 4655dfecf96Smrg CHECK_INDEX(oright); 4665dfecf96Smrg right = (XawTextPosition)FIXNUM_VALUE(oright); 4675dfecf96Smrg 4685dfecf96Smrg CHECK_STRING(otext); 4695dfecf96Smrg block.firstPos = 0; 4705dfecf96Smrg block.ptr = THESTR(otext); 4715dfecf96Smrg block.length = strlen(block.ptr); 4725dfecf96Smrg block.format = FMT8BIT; 4735dfecf96Smrg 4745dfecf96Smrg return (FIXNUM(XawTextReplace(widget, left, right, &block))); 4755dfecf96Smrg} 4765dfecf96Smrg 4775dfecf96SmrgLispObj * 4785dfecf96SmrgLisp_XawTextSearch(LispBuiltin *builtin) 4795dfecf96Smrg/* 4805dfecf96Smrg xaw-text-search widget direction text 4815dfecf96Smrg */ 4825dfecf96Smrg{ 4835dfecf96Smrg Widget widget; 4845dfecf96Smrg XawTextScanDirection direction; 4855dfecf96Smrg XawTextBlock block; 4865dfecf96Smrg 4875dfecf96Smrg LispObj *owidget, *odirection, *otext; 4885dfecf96Smrg 4895dfecf96Smrg otext = ARGUMENT(2); 4905dfecf96Smrg odirection = ARGUMENT(1); 4915dfecf96Smrg owidget = ARGUMENT(0); 4925dfecf96Smrg 4935dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 4945dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 4955dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 4965dfecf96Smrg widget = (Widget)(owidget->data.opaque.data); 4975dfecf96Smrg 4985dfecf96Smrg CHECK_INDEX(odirection); 4995dfecf96Smrg direction = (XawTextPosition)FIXNUM_VALUE(odirection); 5005dfecf96Smrg if (direction != XawsdLeft && direction != XawsdRight) 5015dfecf96Smrg LispDestroy("%s: %d does not fit in XawTextScanDirection", 5025dfecf96Smrg STRFUN(builtin), direction); 5035dfecf96Smrg 5045dfecf96Smrg CHECK_STRING(otext); 5055dfecf96Smrg block.firstPos = 0; 5065dfecf96Smrg block.ptr = THESTR(otext); 5075dfecf96Smrg block.length = strlen(block.ptr); 5085dfecf96Smrg block.format = FMT8BIT; 5095dfecf96Smrg 5105dfecf96Smrg return (FIXNUM(XawTextSearch(widget, direction, &block))); 5115dfecf96Smrg} 5125dfecf96Smrg 5135dfecf96SmrgLispObj * 5145dfecf96SmrgLisp_XawListChange(LispBuiltin *builtin) 5155dfecf96Smrg/* 5165dfecf96Smrg xaw-list-change widget list &optional longest resize 5175dfecf96Smrg */ 5185dfecf96Smrg{ 5195dfecf96Smrg Widget widget; 5205dfecf96Smrg String *list; 5215dfecf96Smrg int i, nitems; 5225dfecf96Smrg int longest; 5235dfecf96Smrg Boolean resize; 5245dfecf96Smrg LispObj *object; 5255dfecf96Smrg WidgetData *data; 5265dfecf96Smrg 5275dfecf96Smrg LispObj *owidget, *olist, *olongest, *oresize; 5285dfecf96Smrg 5295dfecf96Smrg oresize = ARGUMENT(3); 5305dfecf96Smrg olongest = ARGUMENT(2); 5315dfecf96Smrg olist = ARGUMENT(1); 5325dfecf96Smrg owidget = ARGUMENT(0); 5335dfecf96Smrg 5345dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 5355dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 5365dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 5375dfecf96Smrg widget = (Widget)(owidget->data.opaque.data); 5385dfecf96Smrg 5395dfecf96Smrg CHECK_LIST(olist); 5405dfecf96Smrg for (nitems = 0, object = olist; CONSP(object); 5415dfecf96Smrg ++nitems, object = CDR(object)) 5425dfecf96Smrg CHECK_STRING(CAR(object)); 5435dfecf96Smrg 5445dfecf96Smrg if (olongest != UNSPEC) { 5455dfecf96Smrg CHECK_INDEX(olongest); 5465dfecf96Smrg longest = FIXNUM_VALUE(olongest); 5475dfecf96Smrg } 5485dfecf96Smrg else 5495dfecf96Smrg XtVaGetValues(widget, XtNlongest, &longest, NULL, 0); 5505dfecf96Smrg resize = oresize != UNSPEC && oresize != NIL; 5515dfecf96Smrg 5525dfecf96Smrg /* No errors in arguments, build string list */ 5535dfecf96Smrg list = (String*)XtMalloc(sizeof(String) * nitems); 5545dfecf96Smrg for (i = 0, object = olist; CONSP(object); i++, object = CDR(object)) 5555dfecf96Smrg list[i] = THESTR(CAR(object)); 5565dfecf96Smrg 5575dfecf96Smrg /* Check if xaw-list-change was already called 5585dfecf96Smrg * for this widget and free previous data */ 5595dfecf96Smrg for (i = 0; i < num_list_data; i++) 5605dfecf96Smrg if ((Widget)CAR(list_data[i]->object)->data.opaque.data == widget) { 5615dfecf96Smrg XtRemoveCallback(widget, XtNdestroyCallback, 5625dfecf96Smrg LispXawCleanupCallback, list_data[i]); 5635dfecf96Smrg LispXawCleanupCallback(widget, list_data[i], NULL); 5645dfecf96Smrg break; 5655dfecf96Smrg } 5665dfecf96Smrg 5675dfecf96Smrg if (i >= num_list_data) { 5685dfecf96Smrg ++num_list_data; 5695dfecf96Smrg list_data = (WidgetData**)XtRealloc((XtPointer)list_data, 5705dfecf96Smrg sizeof(WidgetData*) * num_list_data); 5715dfecf96Smrg } 5725dfecf96Smrg 5735dfecf96Smrg data = (WidgetData*)XtMalloc(sizeof(WidgetData)); 5745dfecf96Smrg data->data = list; 5755dfecf96Smrg list_data[i] = data; 5765dfecf96Smrg data->object = CONS(owidget, olist); 5775dfecf96Smrg PROTECT(owidget, data->object); 5785dfecf96Smrg XtAddCallback(widget, XtNdestroyCallback, LispXawCleanupCallback, data); 5795dfecf96Smrg 5805dfecf96Smrg XawListChange(widget, list, nitems, longest, resize); 5815dfecf96Smrg 5825dfecf96Smrg return (olist); 5835dfecf96Smrg} 5845dfecf96Smrg 5855dfecf96SmrgLispObj * 5865dfecf96SmrgLisp_XawListHighlight(LispBuiltin *builtin) 5875dfecf96Smrg/* 5885dfecf96Smrg xaw-list-highlight widget index 5895dfecf96Smrg */ 5905dfecf96Smrg{ 5915dfecf96Smrg Widget widget; 5925dfecf96Smrg int position; 5935dfecf96Smrg 5945dfecf96Smrg LispObj *owidget, *oindex; 5955dfecf96Smrg 5965dfecf96Smrg oindex = ARGUMENT(1); 5975dfecf96Smrg owidget = ARGUMENT(0); 5985dfecf96Smrg 5995dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 6005dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 6015dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 6025dfecf96Smrg widget = (Widget)(owidget->data.opaque.data); 6035dfecf96Smrg 6045dfecf96Smrg CHECK_INDEX(oindex); 6055dfecf96Smrg position = FIXNUM_VALUE(oindex); 6065dfecf96Smrg 6075dfecf96Smrg XawListHighlight(widget, position); 6085dfecf96Smrg 6095dfecf96Smrg return (oindex); 6105dfecf96Smrg} 6115dfecf96Smrg 6125dfecf96SmrgLispObj * 6135dfecf96SmrgLisp_XawListUnhighlight(LispBuiltin *builtin) 6145dfecf96Smrg/* 6155dfecf96Smrg xaw-list-unhighlight widget 6165dfecf96Smrg */ 6175dfecf96Smrg{ 6185dfecf96Smrg LispObj *owidget; 6195dfecf96Smrg 6205dfecf96Smrg owidget = ARGUMENT(0); 6215dfecf96Smrg 6225dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 6235dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 6245dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 6255dfecf96Smrg 6265dfecf96Smrg XawListUnhighlight((Widget)(owidget->data.opaque.data)); 6275dfecf96Smrg 6285dfecf96Smrg return (NIL); 6295dfecf96Smrg} 6305dfecf96Smrg 6315dfecf96SmrgLispObj * 6325dfecf96SmrgLisp_XawScrollbarSetThumb(LispBuiltin *builtin) 6335dfecf96Smrg/* 6345dfecf96Smrg xaw-scrollbar-set-thumb widget top &optional shown 6355dfecf96Smrg */ 6365dfecf96Smrg{ 6375dfecf96Smrg Widget widget; 6385dfecf96Smrg double top, shown; 6395dfecf96Smrg 6405dfecf96Smrg LispObj *owidget, *otop, *oshown; 6415dfecf96Smrg 6425dfecf96Smrg oshown = ARGUMENT(2); 6435dfecf96Smrg otop = ARGUMENT(1); 6445dfecf96Smrg owidget = ARGUMENT(0); 6455dfecf96Smrg 6465dfecf96Smrg if (!CHECKO(owidget, xawWidget_t)) 6475dfecf96Smrg LispDestroy("%s: cannot convert %s to Widget", 6485dfecf96Smrg STRFUN(builtin), STROBJ(owidget)); 6495dfecf96Smrg widget = (Widget)(owidget->data.opaque.data); 6505dfecf96Smrg 6515dfecf96Smrg CHECK_DFLOAT(otop); 6525dfecf96Smrg top = DFLOAT_VALUE(otop); 6535dfecf96Smrg 6545dfecf96Smrg if (oshown == UNSPEC) 6555dfecf96Smrg shown = 1.0; 6565dfecf96Smrg else { 6575dfecf96Smrg CHECK_DFLOAT(oshown); 6585dfecf96Smrg shown = DFLOAT_VALUE(oshown); 6595dfecf96Smrg } 6605dfecf96Smrg 6615dfecf96Smrg XawScrollbarSetThumb(widget, top, shown); 6625dfecf96Smrg 6635dfecf96Smrg return (oshown == UNSPEC ? DFLOAT(shown) : oshown); 6645dfecf96Smrg} 665