Skip to content
Browse files

initial import of luamotif

  • Loading branch information...
0 parents commit 137ddc6f0d16df37c87422266a946107bd8dc528 @mbalmer mbalmer committed Apr 5, 2012
Showing with 2,569 additions and 0 deletions.
  1. +17 −0 GNUmakefile
  2. +27 −0 Makefile
  3. +7 −0 README
  4. +89 −0 buttons.lua
  5. +1,108 −0 constants.c
  6. +14 −0 hello.lua
  7. +39 −0 hello_dialog.lua
  8. +1,054 −0 luamotif.c
  9. +52 −0 luamotif.h
  10. +2 −0 shlib_version
  11. +160 −0 widgets.c
17 GNUmakefile
@@ -0,0 +1,17 @@
+SRCS= luamotif.c widgets.c constants.c
+LIB= motif
+
+CFLAGS+= -fPIC -I/usr/include -I${PKGDIR}/include -I/usr/include/lua5.1
+LDADD+= -L${XDIR}/lib -L${PKGDIR}/lib -lXm -lXt -lX11 -lm -lbsd
+
+LIBDIR= ${PKGDIR}/lib/lua/5.1
+
+${LIB}.so: ${SRCS:.c=.o}
+ cc -shared -o ${LIB}.so ${CFLAGS} ${SRCS:.c=.o} ${LDADD}
+ ln -s ${LIB}.so lib${LIB}.so
+
+clean:
+ rm -f *.o *.so
+install:
+ cp motif.so libmotif.so /usr/lib/
+
27 Makefile
@@ -0,0 +1,27 @@
+SRCS= luamotif.c widgets.c constants.c
+LIB= motif
+
+OS!= uname
+
+.if ${OS} == "NetBSD"
+XDIR= ${X11ROOTDIR}
+LOCALBASE= /usr/pkg
+LDADD+= -R/usr/lib -R${XDIR}/lib -R${LOCALBASE}/lib
+.else
+XDIR= /usr/X11R6
+LOCALBASE= /usr/local
+.endif
+
+NOLINT= 1
+CFLAGS+= -I${XDIR}/include -I${LOCALBASE}/include
+LDADD+= -L${XDIR}/lib -L${LOCALBASE}/lib -lXm -lXext -lXt -lX11
+
+LIBDIR= ${LOCALBASE}/lib/lua/5.1
+
+libinstall:
+
+install:
+ ${INSTALL} -d ${DESTDIR}${LIBDIR}
+ ${INSTALL} lib${LIB}.so ${DESTDIR}${LIBDIR}/${LIB}.so
+
+.include <bsd.lib.mk>
7 README
@@ -0,0 +1,7 @@
+A Lua Binding for OpenMotif
+
+Copyright (C) Micro Systems Marc Balmer.
+You can reach the author at marc@msys.ch
+
+Makefile is for BSD systems
+GNUmakefile is for Linux systems
89 buttons.lua
@@ -0,0 +1,89 @@
+require "motif"
+
+gui = Form {
+ fractionBase = 3,
+ Frame {
+ topAttachment = ATTACH_FORM,
+ rightAttachment = ATTACH_FORM,
+ bottomAttachment = ATTACH_POSITION,
+ leftAttachment = ATTACH_FORM,
+
+ bottomPosition = 1,
+
+ LabelGadget {
+ labelString = "Motif Buttons in Lua",
+ childType = FRAME_TITLE_CHILD
+ },
+ RowColumn {
+ PushButton {
+ labelString = "Button one",
+ activateCallback = function()
+ print("Button one was pressed")
+ end
+ },
+ PushButton {
+ labelString = "Button two",
+ activateCallback = function()
+ print("Button two was pressed")
+ end
+ },
+ }
+ },
+ TabStack {
+ topAttachment = ATTACH_POSITION,
+ rightAttachment = ATTACH_FORM,
+ bottomAttachment = ATTACH_FORM,
+ leftAttachment = ATTACH_FORM,
+
+ topPosition = 2,
+
+ tabSide = TABS_ON_BOTTOM,
+ tabStyle = TABS_ROUNDED,
+
+ tabCornerPercent = 100,
+ tabMarginHeight = 64,
+ tabMarginWidth = 64,
+
+ products = LabelGadget {
+ labelString = "frame title",
+ },
+ groups = Frame {
+ LabelGadget {
+ labelString = "frame title",
+ childType = FRAME_TITLE_CHILD,
+ },
+ rc = RowColumn {
+ PushButton {
+ labelString = "pushme",
+ activateCallback = function (w)
+ print(tf:GetString())
+ tfield = w:Parent().t
+ print(tfield:GetString())
+ end
+ },
+ t = TextField {
+ activateCallback = function (w)
+ print(w:GetString())
+ end,
+ valueChangedCallback = function (w)
+ print(w:GetString())
+ end,
+ focusCallback = function (w)
+ print("Button down " ..
+ w:GetString())
+ end
+ }
+ }
+ },
+ }
+
+}
+
+tf = gui[2].groups.rc.t
+
+SetLanguageProc(nil, nil, nil)
+toplevel, app = Initialize("XPoS")
+
+Realize(toplevel, gui)
+
+MainLoop(app)
1,108 constants.c
@@ -0,0 +1,1108 @@
+/*
+ * Copyright (c) 2009 - 2012, Micro Systems Marc Balmer, CH-5073 Gipf-Oberfrick
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Micro Systems Marc Balmer nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Motif constants */
+
+#include <X11/Xdefs.h>
+#include <Xm/XmAll.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "luamotif.h"
+
+struct str_constant motif_strings[] = {
+ { "XmNactivateCallback", XmNactivateCallback, LUA_TFUNCTION },
+ { "XmNalignment", XmNalignment, LUA_TNUMBER },
+ { "XmNarmCallback", XmNarmCallback, LUA_TFUNCTION },
+ { "XmNarmColor", XmNarmColor, LUA_TSTRING },
+ { "XmNarmPixmap", XmNarmPixmap, LUA_TSTRING },
+ { "XmNautoShowCursorPosition", XmNautoShowCursorPosition,
+ LUA_TBOOLEAN },
+ { "XmNbackground", XmNbackground, LUA_TSTRING },
+ { "XmNbottomAttachment", XmNbottomAttachment, LUA_TNUMBER },
+ { "XmNbottomPosition", XmNbottomPosition, LUA_TNUMBER },
+ { "XmNcancelCallback", XmNcancelCallback, LUA_TFUNCTION },
+ { "XmNchildHorizontalAlignment", XmNchildHorizontalAlignment,
+ LUA_TNUMBER },
+ { "XmNchildHorizontalSpacing", XmNchildHorizontalSpacing, LUA_TNUMBER },
+ { "XmNchildType", XmNchildType, LUA_TNUMBER },
+ { "XmNchildVerticalAlignment", XmNchildVerticalAlignment,
+ LUA_TNUMBER },
+ { "XmNcolumns", XmNcolumns, LUA_TNUMBER },
+ { "XmNcursorPositionVisible", XmNcursorPositionVisible,
+ LUA_TBOOLEAN },
+ { "XmNdefaultButton", XmNdefaultButton, LUA_TNUMBER },
+ { "XmNdefaultButtonShadowThickness", XmNdefaultButtonShadowThickness,
+ LUA_TNUMBER},
+ { "XmNdeleteResponse", XmNdeleteResponse, LUA_TNUMBER },
+ { "XmNdialogStyle", XmNdialogStyle, LUA_TNUMBER },
+ { "XmNdisarmCallback", XmNdisarmCallback, LUA_TFUNCTION },
+ { "XmNeditable", XmNeditable, LUA_TBOOLEAN },
+ { "XmNeditMode", XmNeditMode, LUA_TNUMBER },
+ { "XmNfillOnArm", XmNfillOnArm, LUA_TBOOLEAN },
+ { "XmNfocusCallback", XmNfocusCallback, LUA_TFUNCTION },
+ { "XmNfractionBase", XmNfractionBase, LUA_TNUMBER },
+ { "XmNframeChildType", XmNframeChildType, LUA_TNUMBER },
+ { "XmNheight", XmNheight, LUA_TNUMBER },
+ { "XmNlabelString", XmNlabelString, LUA_TSTRING },
+ { "XmNleftAttachment", XmNleftAttachment, LUA_TNUMBER },
+ { "XmNleftPosition", XmNleftPosition, LUA_TNUMBER },
+ { "XmNmarginBottom", XmNmarginBottom, LUA_TNUMBER },
+ { "XmNmarginLeft", XmNmarginLeft, LUA_TNUMBER },
+ { "XmNmarginRight", XmNmarginRight, LUA_TNUMBER },
+ { "XmNmarginTop", XmNmarginTop, LUA_TNUMBER },
+ { "XmNmessageString", XmNmessageString, LUA_TSTRING },
+ { "XmNmultiClick", XmNmultiClick, LUA_TBOOLEAN },
+ { "XmNmwmDecorations", XmNmwmDecorations, LUA_TNUMBER },
+ { "XmNmwmFunctions", XmNmwmFunctions, LUA_TNUMBER },
+ { "XmNnumColumns", XmNnumColumns, LUA_TNUMBER },
+ { "XmNokCallback", XmNokCallback, LUA_TFUNCTION },
+ { "XmNpaneMaximum", XmNpaneMaximum, LUA_TNUMBER },
+ { "XmNpaneMinimum", XmNpaneMinimum, LUA_TNUMBER },
+ { "XmNrightAttachment", XmNrightAttachment, LUA_TNUMBER },
+ { "XmNrightPosition", XmNrightPosition, LUA_TNUMBER },
+ { "XmNrows", XmNrows, LUA_TNUMBER },
+ { "XmNsashHeight", XmNsashHeight, LUA_TNUMBER },
+ { "XmNsashWidth", XmNsashWidth, LUA_TNUMBER },
+ { "XmNscrollingPolicy", XmNscrollingPolicy, LUA_TNUMBER },
+ { "XmNscrollVertical", XmNscrollVertical, LUA_TBOOLEAN },
+ { "XmNshadowType", XmNshadowType, LUA_TNUMBER },
+ { "XmNshowAsDefault", XmNshowAsDefault, LUA_TBOOLEAN },
+ { "XmNtitle", XmNtitle, LUA_TSTRING },
+ { "XmNtopAttachment", XmNtopAttachment, LUA_TNUMBER },
+ { "XmNtopPosition", XmNtopPosition, LUA_TNUMBER },
+ { "XmNtotalLines", XmNtotalLines, LUA_TNUMBER },
+ { XmNuserData, XmNuserData, LUA_TNUMBER },
+ { "XmNvalueChangedCallback", XmNvalueChangedCallback,
+ LUA_TFUNCTION },
+ { "XmNwidth", XmNwidth, LUA_TNUMBER },
+ { "XmNworkWindow", XmNworkWindow, LUA_TLIGHTUSERDATA },
+};
+
+size_t
+num_motif_strings(void)
+{
+ return sizeof(motif_strings)/sizeof(motif_strings[0]);
+}
+
+struct int_constant motif_ints[] = {
+ /* XmDirection */
+ { "DIRECTION_IGNORED", XmDIRECTION_IGNORED },
+
+ { "RIGHT_TO_LEFT_MASK", XmRIGHT_TO_LEFT_MASK },
+ { "LEFT_TO_RIGHT_MASK", XmLEFT_TO_RIGHT_MASK },
+ { "HORIZONTAL_MASK", XmHORIZONTAL_MASK },
+ { "TOP_TO_BOTTOM_MASK", XmTOP_TO_BOTTOM_MASK },
+ { "BOTTOM_TO_TOP_MASK", XmBOTTOM_TO_TOP_MASK },
+ { "VERTICAL_MASK", XmVERTICAL_MASK },
+ { "PRECEDENCE_HORIZ_MASK", XmPRECEDENCE_HORIZ_MASK },
+ { "PRECEDENCE_VERT_MASK", XmPRECEDENCE_VERT_MASK },
+ { "PRECEDENCE_MASK", XmPRECEDENCE_MASK },
+
+ { "RIGHT_TO_LEFT_TOP_TO_BOTTOM", XmRIGHT_TO_LEFT_TOP_TO_BOTTOM },
+ { "LEFT_TO_RIGHT_TOP_TO_BOTTOM", XmLEFT_TO_RIGHT_TOP_TO_BOTTOM },
+ { "RIGHT_TO_LEFT_BOTTOM_TO_TOP", XmRIGHT_TO_LEFT_BOTTOM_TO_TOP },
+ { "LEFT_TO_RIGHT_BOTTOM_TO_TOP", XmLEFT_TO_RIGHT_BOTTOM_TO_TOP },
+ { "TOP_TO_BOTTOM_RIGHT_TO_LEFT", XmTOP_TO_BOTTOM_RIGHT_TO_LEFT },
+ { "TOP_TO_BOTTOM_LEFT_TO_RIGHT", XmTOP_TO_BOTTOM_LEFT_TO_RIGHT },
+ { "BOTTOM_TO_TOP_RIGHT_TO_LEFT", XmBOTTOM_TO_TOP_RIGHT_TO_LEFT },
+ { "BOTTOM_TO_TOP_LEFT_TO_RIGHT", XmBOTTOM_TO_TOP_LEFT_TO_RIGHT },
+ { "TOP_TO_BOTTOM", XmTOP_TO_BOTTOM },
+ { "BOTTOM_TO_TOP", XmBOTTOM_TO_TOP },
+ { "RIGHT_TO_LEFT", XmRIGHT_TO_LEFT },
+ { "LEFT_TO_RIGHT", XmLEFT_TO_RIGHT },
+ { "DEFAULT_DIRECTION", XmDEFAULT_DIRECTION },
+
+ /* XmFontType */
+ { "FONT_IS_FONT", XmFONT_IS_FONT },
+ { "FONT_IS_FONTSET", XmFONT_IS_FONTSET },
+ { "ONT_IS_XFT", XmFONT_IS_XFT },
+
+ /* XmStringDirection */
+ { "STRING_DIRECTION_L_TO_R", XmSTRING_DIRECTION_L_TO_R },
+ { "STRING_DIRECTION_R_TO_L", XmSTRING_DIRECTION_R_TO_L },
+ { "STRING_DIRECTION_UNSET", XmSTRING_DIRECTION_UNSET },
+ { "STRING_DIRECTION_DEFAULT", XmSTRING_DIRECTION_DEFAULT },
+
+ /* XmStringComponent */
+ { "STRING_COMPONENT_UNKNOWN", XmSTRING_COMPONENT_UNKNOWN },
+ { "STRING_COMPONENT_CHARSET", XmSTRING_COMPONENT_CHARSET },
+ { "STRING_COMPONENT_TEXT", XmSTRING_COMPONENT_TEXT },
+ { "STRING_COMPONENT_DIRECTION", XmSTRING_COMPONENT_DIRECTION },
+ { "STRING_COMPONENT_SEPARATOR", XmSTRING_COMPONENT_SEPARATOR },
+ { "STRING_COMPONENT_LOCALE_TEXT",
+ XmSTRING_COMPONENT_LOCALE_TEXT },
+ { "STRING_COMPONENT_LOCALE", XmSTRING_COMPONENT_LOCALE },
+ { "STRING_COMPONENT_WIDECHAR_TEXT",
+ XmSTRING_COMPONENT_WIDECHAR_TEXT },
+ { "STRING_COMPONENT_LAYOUT_PUSH",
+ XmSTRING_COMPONENT_LAYOUT_PUSH },
+ { "STRING_COMPONENT_LAYOUT_POP", XmSTRING_COMPONENT_LAYOUT_POP },
+ { "STRING_COMPONENT_RENDITION_BEGIN",
+ XmSTRING_COMPONENT_RENDITION_BEGIN },
+ { "STRING_COMPONENT_RENDITION_END",
+ XmSTRING_COMPONENT_RENDITION_END },
+ { "STRING_COMPONENT_TAB", XmSTRING_COMPONENT_TAB },
+ { "STRING_COMPONENT_FONTLIST_ELEMENT_TAG",
+ XmSTRING_COMPONENT_FONTLIST_ELEMENT_TAG },
+ { "STRING_COMPONENT_TAG", XmSTRING_COMPONENT_TAG },
+ { "STRING_COMPONENT_END", XmSTRING_COMPONENT_END },
+ { "STRING_COMPONENT_USER_BEGIN", XmSTRING_COMPONENT_USER_BEGIN },
+ { "STRING_COMPONENT_USER_END", XmSTRING_COMPONENT_USER_END },
+
+ /* XmTextType */
+ { "CHARSET_TEXT", XmCHARSET_TEXT },
+ { "MULTIBYTE_TEXT", XmMULTIBYTE_TEXT },
+ { "WIDECHAR_TEXT", XmWIDECHAR_TEXT },
+ { "NO_TEXT", XmNO_TEXT },
+
+ /* XmParseModel */
+ { "OUTPUT_ALL", XmOUTPUT_ALL },
+ { "OUTPUT_BETWEEN", XmOUTPUT_BETWEEN },
+ { "OUTPUT_BEGINNING", XmOUTPUT_BEGINNING },
+ { "OUTPUT_END", XmOUTPUT_END },
+ { "OUTPUT_BOTH", XmOUTPUT_BOTH },
+
+ /* XmIncludeStatus */
+ { "INSERT", XmINSERT },
+ { "TERMINATE", XmTERMINATE },
+ { "INVOKE", XmINVOKE },
+
+ /* XmICCEncodingStyle */
+ { "STYLE_STRING", XmSTYLE_STRING },
+ { "STYLE_COMPOUND_TEXT", XmSTYLE_COMPOUND_TEXT },
+ { "STYLE_TEXT", XmSTYLE_TEXT },
+ { "STYLE_STANDARD_ICC_TEXT", XmSTYLE_STANDARD_ICC_TEXT },
+ { "STYLE_LOCALE", XmSTYLE_LOCALE },
+ { "STYLE_COMPOUND_STRING", XmSTYLE_COMPOUND_STRING },
+
+ /* XmOffsetModel */
+ { "ABSOLUTE", XmABSOLUTE },
+ { "RELATIVE", XmRELATIVE },
+
+ /* XmMergeMode */
+ { "SKIP", XmSKIP },
+ { "MERGE_REPLACE", XmMERGE_REPLACE },
+ { "MERGE_OLD", XmMERGE_OLD },
+ { "MERGE_NEW", XmMERGE_NEW },
+ { "DUPLICATE", XmDUPLICATE },
+
+ { "AS_IS", XmAS_IS },
+ { "FORCE_COLOR", XmFORCE_COLOR },
+
+ { "UNSPECIFIED_PIXEL", XmUNSPECIFIED_PIXEL },
+ { "DEFAULT_SELECT_COLOR", XmDEFAULT_SELECT_COLOR },
+ { "REVERSED_GROUND_COLORS", XmREVERSED_GROUND_COLORS },
+ { "HIGHLIGHT_COLOR", XmHIGHLIGHT_COLOR },
+
+ { "UNSPECIFIED_LOAD_MODEL", XmUNSPECIFIED_LOAD_MODEL },
+ { "LOAD_DEFERRED", XmLOAD_DEFERRED },
+ { "LOAD_IMMEDIATE", XmLOAD_IMMEDIATE },
+
+/************************************************************************
+ * Primitive Resources and define values
+ ************************************************************************/
+
+ /* size policy values */
+ { "CHANGE_ALL", XmCHANGE_ALL },
+ { "CHANGE_NONE", XmCHANGE_NONE },
+ { "CHANGE_WIDTH", XmCHANGE_WIDTH },
+ { "CHANGE_HEIGHT", XmCHANGE_HEIGHT },
+
+ /* unit type values */
+ { "PIXELS", XmPIXELS },
+ { "100TH_MILLIMETERS", Xm100TH_MILLIMETERS },
+ { "1000TH_INCHES", Xm1000TH_INCHES },
+ { "100TH_POINTS", Xm100TH_POINTS },
+ { "100TH_FONT_UNITS", Xm100TH_FONT_UNITS },
+ { "INCHES", XmINCHES },
+ { "CENTIMETERS", XmCENTIMETERS },
+ { "MILLIMETERS", XmMILLIMETERS },
+ { "POINTS", XmPOINTS },
+ { "FONT_UNITS", XmFONT_UNITS },
+
+ /* DeleteResponse values */
+ { "DESTROY", XmDESTROY },
+ { "UNMAP", XmUNMAP },
+ { "DO_NOTHING", XmDO_NOTHING },
+
+ { "EXPLICIT", XmEXPLICIT },
+ { "POINTER", XmPOINTER },
+
+/************************************************************************
+ * Navigation defines
+ ************************************************************************/
+
+ { "NONE", XmNONE },
+ { "TAB_GROUP", XmTAB_GROUP },
+ { "STICKY_TAB_GROUP", XmSTICKY_TAB_GROUP },
+ { "EXCLUSIVE_TAB_GROUP", XmEXCLUSIVE_TAB_GROUP },
+
+ { "DYNAMIC_DEFAULT_TAB_GROUP", XmDYNAMIC_DEFAULT_TAB_GROUP },
+
+/************************************************************************
+ * Audible warning
+ ************************************************************************/
+
+ { "BELL", XmBELL },
+
+/************************************************************************
+ * Input Manager defines
+ ************************************************************************/
+
+ { "PER_SHELL", XmPER_SHELL },
+ { "PER_WIDGET", XmPER_WIDGET },
+ { "INHERIT_POLICY", XmINHERIT_POLICY },
+
+/************************************************************************
+ * Menu defines
+ ************************************************************************/
+
+ { "NO_ORIENTATION", XmNO_ORIENTATION },
+ { "VERTICAL", XmVERTICAL },
+ { "HORIZONTAL", XmHORIZONTAL },
+
+ { "WORK_AREA", XmWORK_AREA },
+ { "MENU_BAR", XmMENU_BAR },
+ { "MENU_PULLDOWN", XmMENU_PULLDOWN },
+ { "MENU_POPUP", XmMENU_POPUP },
+ { "MENU_OPTION", XmMENU_OPTION },
+
+ { "NO_PACKING", XmNO_PACKING },
+ { "PACK_TIGHT", XmPACK_TIGHT },
+ { "PACK_COLUMN", XmPACK_COLUMN },
+ { "PACK_NONE", XmPACK_NONE },
+
+ { "ALIGNMENT_CONTENTS_TOP", XmALIGNMENT_CONTENTS_TOP },
+ { "ALIGNMENT_CONTENTS_BOTTOM", XmALIGNMENT_CONTENTS_BOTTOM },
+
+ { "TEAR_OFF_ENABLED", XmTEAR_OFF_ENABLED },
+ { "TEAR_OFF_DISABLED", XmTEAR_OFF_DISABLED },
+
+ { "UNPOST", XmUNPOST },
+ { "UNPOST_AND_REPLAY", XmUNPOST_AND_REPLAY },
+
+ { "LAST_POSITION", XmLAST_POSITION },
+ { "FIRST_POSITION", XmFIRST_POSITION },
+ { "POPUP_DISABLED", XmPOPUP_DISABLED },
+ { "POPUP_KEYBOARD", XmPOPUP_KEYBOARD },
+ { "POPUP_AUTOMATIC", XmPOPUP_AUTOMATIC },
+ { "POPUP_AUTOMATIC_RECURSIVE", XmPOPUP_AUTOMATIC_RECURSIVE },
+
+/************************************************************************
+ * Color Selector defines
+ ************************************************************************/
+
+ { "ListMode", XmListMode },
+ { "ScaleMode", XmScaleMode },
+
+/************************************************************************
+ * Column defines
+ ************************************************************************/
+
+ { "FILL_UNSPECIFIED", XmFILL_UNSPECIFIED },
+ { "FILL_FLUSH", XmFILL_FLUSH },
+ { "FILL_RAGGED", XmFILL_RAGGED },
+
+ { "DISTRIBUTE_TIGHT", XmDISTRIBUTE_TIGHT },
+ { "DISTRIBUTE_SPREAD", XmDISTRIBUTE_SPREAD },
+
+/************************************************************************
+ * ComboBox defines
+ ************************************************************************/
+
+ { "COMBO_BOX", XmCOMBO_BOX },
+ { "DROP_DOWN_COMBO_BOX", XmDROP_DOWN_COMBO_BOX },
+ { "DROP_DOWN_LIST", XmDROP_DOWN_LIST },
+
+ { "QUICK_NAVIGATE", XmQUICK_NAVIGATE },
+ { "INVALID_MATCH_BEHAVIOR", XmINVALID_MATCH_BEHAVIOR },
+
+ { "ZERO_BASED", XmZERO_BASED },
+ { "ONE_BASED", XmONE_BASED },
+
+ { "INVALID_POSITION", XmINVALID_POSITION },
+
+/************************************************************************
+ * Icon & Button Box defines
+ ************************************************************************/
+ { "IconTop", XmIconTop },
+ { "IconLeft", XmIconLeft },
+ { "IconRight", XmIconRight },
+ { "IconBottom", XmIconBottom },
+ { "IconOnly", XmIconOnly },
+ { "IconNone", XmIconNone },
+
+ { "FillNone", XmFillNone },
+ { "FillMajor", XmFillMajor },
+ { "FillMinor", XmFillMinor },
+ { "FillAll", XmFillAll },
+
+/************************************************************************
+ * Hierarchy/Tree/Outline defines
+ ************************************************************************/
+
+ { "AlwaysOpen", XmAlwaysOpen },
+ { "Open", XmOpen },
+ { "Closed", XmClosed },
+ { "Hidden", XmHidden },
+ { "NotInHierarchy", XmNotInHierarchy },
+
+ { "TreeLadder", XmTreeLadder },
+ { "TreeDirect", XmTreeDirect },
+
+ { "TreeCompressNone", XmTreeCompressNone },
+ { "TreeCompressLeaves", XmTreeCompressLeaves },
+ { "TreeCompressAll", XmTreeCompressAll },
+
+/************************************************************************
+ * Label/Frame defines
+ ************************************************************************/
+
+ { "ALIGNMENT_BEGINNING", XmALIGNMENT_BEGINNING },
+ { "ALIGNMENT_CENTER", XmALIGNMENT_CENTER },
+ { "ALIGNMENT_END", XmALIGNMENT_END },
+ { "ALIGNMENT_UNSPECIFIED", XmALIGNMENT_UNSPECIFIED },
+
+ { "ALIGNMENT_BASELINE_TOP", XmALIGNMENT_BASELINE_TOP },
+ { "ALIGNMENT_BASELINE_BOTTOM", XmALIGNMENT_BASELINE_BOTTOM },
+ { "ALIGNMENT_WIDGET_TOP", XmALIGNMENT_WIDGET_TOP },
+ { "ALIGNMENT_WIDGET_BOTTOM", XmALIGNMENT_WIDGET_BOTTOM },
+
+
+/* new enum introduced in 2.0 to clear up the confusion in
+ widget top/bottom attachment */
+
+ { "ALIGNMENT_CHILD_TOP", XmALIGNMENT_CHILD_TOP },
+ { "ALIGNMENT_CHILD_BOTTOM", XmALIGNMENT_CHILD_BOTTOM },
+
+/************************************************************************
+ * Frame defines
+ ************************************************************************/
+
+ { "FRAME_GENERIC_CHILD", XmFRAME_GENERIC_CHILD },
+ { "FRAME_WORKAREA_CHILD", XmFRAME_WORKAREA_CHILD },
+ { "FRAME_TITLE_CHILD", XmFRAME_TITLE_CHILD },
+
+/************************************************************************
+ * ToggleButton defines
+ ************************************************************************/
+
+ { "N_OF_MANY", XmN_OF_MANY },
+ { "ONE_OF_MANY", XmONE_OF_MANY },
+ { "ONE_OF_MANY_ROUND", XmONE_OF_MANY_ROUND },
+ { "ONE_OF_MANY_DIAMOND", XmONE_OF_MANY_DIAMOND },
+
+/************************************************************************
+ * Form defines
+ ************************************************************************/
+
+ { "ATTACH_NONE", XmATTACH_NONE },
+ { "ATTACH_FORM", XmATTACH_FORM },
+ { "ATTACH_OPPOSITE_FORM", XmATTACH_OPPOSITE_FORM },
+ { "ATTACH_WIDGET", XmATTACH_WIDGET },
+ { "ATTACH_OPPOSITE_WIDGET", XmATTACH_OPPOSITE_WIDGET },
+ { "ATTACH_POSITION", XmATTACH_POSITION },
+ { "ATTACH_SELF", XmATTACH_SELF },
+
+ { "RESIZE_NONE", XmRESIZE_NONE },
+ { "RESIZE_GROW", XmRESIZE_GROW },
+ { "RESIZE_ANY", XmRESIZE_ANY },
+
+ /* TabStack */
+ /* XmTabStyle */
+ { "TABS_SQUARED", XmTABS_SQUARED },
+ { "TABS_ROUNDED", XmTABS_ROUNDED },
+ { "TABS_BEVELED", XmTABS_BEVELED },
+
+ /* XmTabMode */
+ { "TABS_BASIC", XmTABS_BASIC },
+ { "TABS_STACKED", XmTABS_STACKED },
+ { "TABS_STACKED_STATIC", XmTABS_STACKED_STATIC },
+ { "TABS_SCROLLED", XmTABS_SCROLLED },
+ { "TABS_OVERLAYED", XmTABS_OVERLAYED },
+
+ /* XmTabOrientation */
+ { "TAB_ORIENTATION_DYNAMIC", XmTAB_ORIENTATION_DYNAMIC },
+ { "TABS_RIGHT_TO_LEFT", XmTABS_RIGHT_TO_LEFT },
+ { "TABS_LEFT_TO_RIGHT", XmTABS_LEFT_TO_RIGHT },
+ { "TABS_TOP_TO_BOTTOM", XmTABS_TOP_TO_BOTTOM },
+ { "TABS_BOTTOM_TO_TOP", XmTABS_BOTTOM_TO_TOP },
+
+ /* XmTabEdge */
+ { "TAB_EDGE_TOP_LEFT", XmTAB_EDGE_TOP_LEFT },
+ { "TAB_EDGE_BOTTOM_RIGHT", XmTAB_EDGE_BOTTOM_RIGHT },
+
+ /* XmTabArrowPlacement */
+ { "TAB_ARROWS_ON_RIGHT", XmTAB_ARROWS_ON_RIGHT },
+ { "TAB_ARROWS_ON_LEFT", XmTAB_ARROWS_ON_LEFT },
+ { "TAB_ARROWS_SPLIT", XmTAB_ARROWS_SPLIT },
+
+ { "CR_TAB_SELECTED", XmCR_TAB_SELECTED },
+ { "CR_TAB_UNSELECTED", XmCR_TAB_UNSELECTED },
+
+ { "TABS_ON_BOTTOM", XmTABS_ON_BOTTOM },
+ { "TABS_ON_LEFT", XmTABS_ON_LEFT },
+ { "TABS_ON_RIGHT", XmTABS_ON_RIGHT },
+ { "TABS_ON_TOP", XmTABS_ON_TOP },
+
+ { "PIXMAP_TOP", XmPIXMAP_TOP },
+ { "PIXMAP_BOTTOM", XmPIXMAP_BOTTOM },
+ { "PIXMAP_RIGHT", XmPIXMAP_RIGHT },
+ { "PIXMAP_LEFT", XmPIXMAP_LEFT },
+ { "PIXMAP_NONE", XmPIXMAP_NONE },
+ { "PIXMAP_ONLY", XmPIXMAP_ONLY },
+
+ { "TAB_VALUE_COPY", XmTAB_VALUE_COPY },
+ { "TAB_VALUE_SHARE", XmTAB_VALUE_SHARE },
+
+ { "TAB_CMP_VISUAL", XmTAB_CMP_VISUAL },
+ { "TAB_CMP_SIZE", XmTAB_CMP_SIZE },
+ { "TAB_CMP_EQUAL", XmTAB_CMP_EQUAL },
+
+/****************************************************************************
+ * Callback reasons
+ ****************************************************************************/
+
+ { "CR_NONE", XmCR_NONE },
+ { "CR_HELP", XmCR_HELP },
+ { "CR_VALUE_CHANGED", XmCR_VALUE_CHANGED },
+ { "CR_INCREMENT", XmCR_INCREMENT },
+ { "CR_DECREMENT", XmCR_DECREMENT },
+ { "CR_PAGE_INCREMENT", XmCR_PAGE_INCREMENT },
+ { "CR_PAGE_DECREMENT", XmCR_PAGE_DECREMENT },
+ { "CR_TO_TOP", XmCR_TO_TOP },
+ { "CR_TO_BOTTOM", XmCR_TO_BOTTOM },
+ { "CR_DRAG", XmCR_DRAG },
+ { "CR_ACTIVATE", XmCR_ACTIVATE },
+ { "CR_ARM", XmCR_ARM },
+ { "CR_DISARM", XmCR_DISARM },
+ { "CR_MAP", XmCR_MAP },
+ { "CR_UNMAP", XmCR_UNMAP },
+ { "CR_FOCUS", XmCR_FOCUS },
+ { "CR_LOSING_FOCUS", XmCR_LOSING_FOCUS },
+ { "CR_MODIFYING_TEXT_VALUE", XmCR_MODIFYING_TEXT_VALUE },
+ { "CR_MOVING_INSERT_CURSOR", XmCR_MOVING_INSERT_CURSOR },
+ { "CR_EXECUTE", XmCR_EXECUTE },
+ { "CR_SINGLE_SELECT", XmCR_SINGLE_SELECT },
+ { "CR_MULTIPLE_SELECT", XmCR_MULTIPLE_SELECT },
+ { "CR_EXTENDED_SELECT", XmCR_EXTENDED_SELECT },
+ { "CR_BROWSE_SELECT", XmCR_BROWSE_SELECT },
+ { "CR_DEFAULT_ACTION", XmCR_DEFAULT_ACTION },
+ { "CR_CLIPBOARD_DATA_REQUEST", XmCR_CLIPBOARD_DATA_REQUEST },
+ { "CR_CLIPBOARD_DATA_DELETE", XmCR_CLIPBOARD_DATA_DELETE },
+ { "CR_CASCADING", XmCR_CASCADING },
+ { "CR_OK", XmCR_OK },
+ { "CR_CANCEL", XmCR_CANCEL },
+ { "CR_APPLY", XmCR_APPLY },
+ { "CR_NO_MATCH", XmCR_NO_MATCH },
+ { "CR_COMMAND_ENTERED", XmCR_COMMAND_ENTERED },
+ { "CR_COMMAND_CHANGED", XmCR_COMMAND_CHANGED },
+ { "CR_EXPOSE", XmCR_EXPOSE },
+ { "CR_RESIZE", XmCR_RESIZE },
+ { "CR_INPUT", XmCR_INPUT },
+ { "CR_GAIN_PRIMARY", XmCR_GAIN_PRIMARY },
+ { "CR_LOSE_PRIMARY", XmCR_LOSE_PRIMARY },
+ { "CR_CREATE", XmCR_CREATE },
+ { "CR_TEAR_OFF_ACTIVATE", XmCR_TEAR_OFF_ACTIVATE },
+ { "CR_TEAR_OFF_DEACTIVATE", XmCR_TEAR_OFF_DEACTIVATE },
+ { "CR_OBSCURED_TRAVERSAL", XmCR_OBSCURED_TRAVERSAL },
+ { "CR_FOCUS_MOVED", XmCR_FOCUS_MOVED },
+ { "CR_REPOST", XmCR_REPOST },
+ { "CR_COLLAPSED", XmCR_COLLAPSED },
+ { "CR_EXPANDED", XmCR_EXPANDED },
+ { "CR_SELECT", XmCR_SELECT },
+ { "CR_DRAG_START", XmCR_DRAG_START },
+ { "CR_NO_FONT", XmCR_NO_FONT },
+ { "CR_NO_RENDITION", XmCR_NO_RENDITION },
+ { "CR_POST", XmCR_POST },
+ { "CR_SPIN_NEXT", XmCR_SPIN_NEXT },
+ { "CR_SPIN_PRIOR", XmCR_SPIN_PRIOR },
+ { "CR_SPIN_FIRST", XmCR_SPIN_FIRST },
+ { "CR_SPIN_LAST", XmCR_SPIN_LAST },
+ { "CR_PAGE_SCROLLER_INCREMENT", XmCR_PAGE_SCROLLER_INCREMENT },
+ { "CR_PAGE_SCROLLER_DECREMENT", XmCR_PAGE_SCROLLER_DECREMENT },
+ { "CR_MAJOR_TAB", XmCR_MAJOR_TAB },
+ { "CR_MINOR_TAB", XmCR_MINOR_TAB },
+ { "CR_START_JOB", XmCR_START_JOB },
+ { "CR_END_JOB", XmCR_END_JOB },
+ { "CR_PAGE_SETUP", XmCR_PAGE_SETUP },
+ { "CR_PDM_NONE", XmCR_PDM_NONE },
+ { "CR_PDM_UP", XmCR_PDM_UP },
+ { "CR_PDM_START_ERROR", XmCR_PDM_START_ERROR },
+ { "CR_PDM_START_VXAUTH", XmCR_PDM_START_VXAUTH },
+ { "CR_PDM_START_PXAUTH", XmCR_PDM_START_PXAUTH },
+ { "CR_PDM_OK", XmCR_PDM_OK },
+ { "CR_PDM_CANCEL", XmCR_PDM_CANCEL },
+ { "CR_PDM_EXIT_ERROR", XmCR_PDM_EXIT_ERROR },
+ { "CR_UPDATE_SHELL", XmCR_UPDATE_SHELL },
+ { "CR_UPDATE_TEXT", XmCR_UPDATE_TEXT },
+ { "CR_VERIFY_TEXT", XmCR_VERIFY_TEXT },
+ { "CR_VERIFY_TEXT_FAILED", XmCR_VERIFY_TEXT_FAILED },
+ { "CR_ENTER_CHILD", XmCR_ENTER_CHILD },
+ { "CR_LEAVE_CHILD", XmCR_LEAVE_CHILD },
+ { "CR_PROTOCOLS", XmCR_PROTOCOLS },
+
+/************************************************************************
+ * new ScrollBar showArrows define
+ ************************************************************************/
+
+ { "EACH_SIDE", XmEACH_SIDE },
+ { "MAX_SIDE", XmMAX_SIDE },
+ { "MIN_SIDE", XmMIN_SIDE },
+
+/************************************************************************
+ * Sliding mode
+ ************************************************************************/
+
+ { "SLIDER", XmSLIDER },
+ { "THERMOMETER", XmTHERMOMETER },
+
+/************************************************************************
+ * Slider Visual
+ ************************************************************************/
+
+ { "BACKGROUND_COLOR", XmBACKGROUND_COLOR },
+ { "FOREGROUND_COLOR", XmFOREGROUND_COLOR },
+ { "TROUGH_COLOR", XmTROUGH_COLOR },
+ { "SHADOWED_BACKGROUND", XmSHADOWED_BACKGROUND },
+
+/************************************************************************
+ * Slider Mark
+ ************************************************************************/
+
+ { "ETCHED_LINE", XmETCHED_LINE },
+ { "THUMB_MARK", XmTHUMB_MARK },
+ { "ROUND_MARK", XmROUND_MARK },
+
+/************************************************************************
+ * new Scale showValue
+ ************************************************************************/
+
+ { "NEAR_SLIDER", XmNEAR_SLIDER },
+ { "NEAR_BORDER", XmNEAR_BORDER },
+
+/************************************************************************
+ * new ScrolledWindow/MainWindow chidType
+ ************************************************************************/
+
+ { "HOR_SCROLLBAR", XmHOR_SCROLLBAR },
+ { "VERT_SCROLLBAR", XmVERT_SCROLLBAR },
+ { "COMMAND_WINDOW", XmCOMMAND_WINDOW },
+ { "MESSAGE_WINDOW", XmMESSAGE_WINDOW },
+ { "SCROLL_HOR", XmSCROLL_HOR },
+ { "SCROLL_VERT", XmSCROLL_VERT },
+ { "NO_SCROLL", XmNO_SCROLL },
+ { "CLIP_WINDOW", XmCLIP_WINDOW },
+ { "GENERIC_CHILD", XmGENERIC_CHILD },
+
+/************************************************************************
+ * new ScrolledWindow auto drag enum
+ ************************************************************************/
+
+ { "AUTO_DRAG_ENABLED", XmAUTO_DRAG_ENABLED },
+ { "AUTO_DRAG_DISABLED", XmAUTO_DRAG_DISABLED },
+
+/************************************************************************
+ * new Display enable warp enum
+ ************************************************************************/
+
+ { "ENABLE_WARP_ON", XmENABLE_WARP_ON },
+ { "ENABLE_WARP_OFF", XmENABLE_WARP_OFF },
+
+/************************************************************************
+ * new Display enable btn1 transfer enum
+ ************************************************************************/
+
+ { "OFF", XmOFF },
+ { "BUTTON2_ADJUST", XmBUTTON2_ADJUST },
+ { "BUTTON2_TRANSFER", XmBUTTON2_TRANSFER },
+
+/************************************************************************
+ * auto_selection_type
+ ************************************************************************/
+
+ { "AUTO_UNSET", XmAUTO_UNSET },
+ { "AUTO_BEGIN", XmAUTO_BEGIN },
+ { "AUTO_MOTION", XmAUTO_MOTION },
+ { "AUTO_CANCEL", XmAUTO_CANCEL },
+ { "AUTO_NO_CHANGE", XmAUTO_NO_CHANGE },
+ { "AUTO_CHANGE", XmAUTO_CHANGE },
+
+/************************************************************************
+ * PushButton defines
+ ************************************************************************/
+
+ { "MULTICLICK_DISCARD", XmMULTICLICK_DISCARD },
+ { "MULTICLICK_KEEP", XmMULTICLICK_KEEP },
+
+/************************************************************************
+ * DrawnButton defines
+ ************************************************************************/
+
+ { "SHADOW_IN", XmSHADOW_IN },
+ { "SHADOW_OUT", XmSHADOW_OUT },
+
+/************************************************************************
+ * Arrow defines
+ ************************************************************************/
+
+ { "ARROW_UP", XmARROW_UP },
+ { "ARROW_DOWN", XmARROW_DOWN },
+ { "ARROW_LEFT", XmARROW_LEFT },
+ { "ARROW_RIGHT", XmARROW_RIGHT },
+
+/************************************************************************
+ * Separator defines
+ * Note: XmINVALID_SEPARATOR_TYPE marks the last+1 separator type
+ ************************************************************************/
+
+ { "NO_LINE", XmNO_LINE },
+ { "SINGLE_LINE", XmSINGLE_LINE },
+ { "DOUBLE_LINE", XmDOUBLE_LINE },
+ { "SINGLE_DASHED_LINE", XmSINGLE_DASHED_LINE },
+ { "DOUBLE_DASHED_LINE", XmDOUBLE_DASHED_LINE },
+ { "SHADOW_ETCHED_IN", XmSHADOW_ETCHED_IN },
+ { "SHADOW_ETCHED_OUT", XmSHADOW_ETCHED_OUT },
+ { "SHADOW_ETCHED_IN_DASH", XmSHADOW_ETCHED_IN_DASH },
+ { "SHADOW_ETCHED_OUT_DASH", XmSHADOW_ETCHED_OUT_DASH },
+ { "INVALID_SEPARATOR_TYPE", XmINVALID_SEPARATOR_TYPE },
+
+ { "PIXMAP", XmPIXMAP },
+ { "STRING", XmSTRING },
+ { "PIXMAP_AND_STRING", XmPIXMAP_AND_STRING },
+
+/************************************************************************
+ * Drag and Drop defines
+ ************************************************************************/
+
+ { "WINDOW", XmWINDOW },
+ { "CURSOR", XmCURSOR },
+ { "DRAG_WINDOW", XmDRAG_WINDOW },
+
+/************************************************************************
+ * ScrollBar defines
+ ************************************************************************/
+
+ { "MAX_ON_TOP", XmMAX_ON_TOP },
+ { "MAX_ON_BOTTOM", XmMAX_ON_BOTTOM },
+ { "MAX_ON_LEFT", XmMAX_ON_LEFT },
+ { "MAX_ON_RIGHT", XmMAX_ON_RIGHT },
+
+/************************************************************************
+ * *
+ * List Widget defines *
+ * *
+ ************************************************************************/
+
+ { "SINGLE_SELECT", XmSINGLE_SELECT },
+ { "MULTIPLE_SELECT", XmMULTIPLE_SELECT },
+ { "XTENDED_SELECT", XmEXTENDED_SELECT },
+ { "BROWSE_SELECT", XmBROWSE_SELECT },
+
+ { "STATIC", XmSTATIC },
+ { "DYNAMIC", XmDYNAMIC },
+ { "NORMAL_MODE", XmNORMAL_MODE },
+ { "ADD_MODE", XmADD_MODE },
+
+/************************************************************************
+ * *
+ * Container Widget defines *
+ * *
+ ************************************************************************/
+
+ /* XmRAutomaticSelection */
+ { "NO_AUTO_SELECT", XmNO_AUTO_SELECT },
+ { "AUTO_SELECT", XmAUTO_SELECT },
+
+ /* XmRLineStyle */
+ { "SINGLE", XmSINGLE },
+
+ /* XmREntryViewType */
+ { "ANY_ICON", XmANY_ICON },
+
+ /* XmRSpatialIncludeModel */
+ { "APPEND", XmAPPEND },
+ { "CLOSEST", XmCLOSEST },
+ { "FIRST_FIT", XmFIRST_FIT },
+
+ /* XmRLayoutType */
+ { "OUTLINE", XmOUTLINE },
+ { "SPATIAL", XmSPATIAL },
+ { "DETAIL", XmDETAIL },
+
+ /* XmNoutlineButtonPolicy */
+ { "OUTLINE_BUTTON_PRESENT", XmOUTLINE_BUTTON_PRESENT },
+ { "OUTLINE_BUTTON_ABSENT", XmOUTLINE_BUTTON_ABSENT },
+
+ /* XmRSpatialPlaceStyle */
+ { "GRID", XmGRID },
+ { "CELLS", XmCELLS },
+
+ /* XmRPrimaryOwnership */
+ { "OWN_NEVER", XmOWN_NEVER },
+ { "OWN_ALWAYS", XmOWN_ALWAYS },
+ { "OWN_MULTIPLE", XmOWN_MULTIPLE },
+ { "OWN_POSSIBLE_MULTIPLE", XmOWN_POSSIBLE_MULTIPLE },
+
+ /* XmRSpatialResizeModel */
+ { "GROW_MINOR", XmGROW_MINOR },
+ { "GROW_MAJOR", XmGROW_MAJOR },
+ { "GROW_BALANCED", XmGROW_BALANCED },
+
+ /* XmRSelectionTechnique */
+ { "MARQUEE", XmMARQUEE },
+ { "MARQUEE_EXTEND_START", XmMARQUEE_EXTEND_START },
+ { "MARQUEE_EXTEND_BOTH", XmMARQUEE_EXTEND_BOTH },
+ { "TOUCH_ONLY", XmTOUCH_ONLY },
+ { "TOUCH_OVER", XmTOUCH_OVER },
+
+ /* XmRSpatialSnapModel */
+ { "SNAP_TO_GRID", XmSNAP_TO_GRID },
+ { "CENTER", XmCENTER },
+
+ /* XmROutlineState */
+ { "COLLAPSED", XmCOLLAPSED },
+ { "XPANDED", XmEXPANDED },
+
+/************************************************************************
+ * *
+ * IconGadget defines *
+ * *
+ ************************************************************************/
+
+ /* XmRViewType */
+ { "LARGE_ICON", XmLARGE_ICON },
+ { "SMALL_ICON", XmSMALL_ICON },
+
+ /* XmRVisualEmphasis */
+ { "SELECTED", XmSELECTED },
+ { "NOT_SELECTED", XmNOT_SELECTED },
+
+/************************************************************************
+ * *
+ * Notebook Widget defines *
+ * *
+ ************************************************************************/
+
+ { "UNSPECIFIED_PAGE_NUMBER", XmUNSPECIFIED_PAGE_NUMBER },
+
+ /* XmRBindingType */
+ { "SOLID", XmSOLID },
+ { "SPIRAL", XmSPIRAL },
+ { "PIXMAP_OVERLAP_ONLY", XmPIXMAP_OVERLAP_ONLY },
+
+ /* XmRNBChildType */
+ { "PAGE", XmPAGE },
+ { "MAJOR_TAB", XmMAJOR_TAB },
+ { "MINOR_TAB", XmMINOR_TAB },
+ { "STATUS_AREA", XmSTATUS_AREA },
+ { "PAGE_SCROLLER", XmPAGE_SCROLLER },
+
+/************************************************************************
+ * *
+ * Spin button defines. *
+ * *
+ ************************************************************************/
+
+ /* XmNarrowOrientation */
+ { "ARROWS_VERTICAL", XmARROWS_VERTICAL },
+ { "ARROWS_HORIZONTAL", XmARROWS_HORIZONTAL },
+
+ /* XmNarrowLayout */
+ { "ARROWS_END", XmARROWS_END },
+ { "ARROWS_BEGINNING", XmARROWS_BEGINNING },
+ { "RROWS_SPLIT", XmARROWS_SPLIT },
+ { "ARROWS_FLAT_END", XmARROWS_FLAT_END },
+ { "ARROWS_FLAT_BEGINNING", XmARROWS_FLAT_BEGINNING },
+
+ /* XmNarrowSensitivity and XmNdefaultArrowSensitivity */
+ /* Please note that these arrows form the proper values
+ for a bit mask. */
+ { "RROWS_INSENSITIVE", XmARROWS_INSENSITIVE },
+ { "ARROWS_INCREMENT_SENSITIVE", XmARROWS_INCREMENT_SENSITIVE },
+ { "ARROWS_DECREMENT_SENSITIVE", XmARROWS_DECREMENT_SENSITIVE },
+ { "ARROWS_SENSITIVE", XmARROWS_SENSITIVE },
+ { "ARROWS_DEFAULT_SENSITIVITY", XmARROWS_DEFAULT_SENSITIVITY },
+
+ /* XmNpositionType */
+ { "POSITION_INDEX", XmPOSITION_INDEX },
+ { "POSITION_VALUE", XmPOSITION_VALUE },
+
+ /* XmNspinButtonChildType */
+ { "NUMERIC", XmNUMERIC },
+
+ /* Return values for Xm[Simple]SpinBoxValidatePosition */
+ { "VALID_VALUE", XmVALID_VALUE },
+ { "CURRENT_VALUE", XmCURRENT_VALUE },
+ { "MAXIMUM_VALUE", XmMAXIMUM_VALUE },
+ { "MINIMUM_VALUE", XmMINIMUM_VALUE },
+ { "INCREMENT_VALUE", XmINCREMENT_VALUE },
+
+/************************************************************************
+ * *
+ * Scrolled Window defines. *
+ * *
+ ************************************************************************/
+
+ { "VARIABLE", XmVARIABLE },
+ { "CONSTANT", XmCONSTANT },
+ { "RESIZE_IF_POSSIBLE", XmRESIZE_IF_POSSIBLE },
+
+ { "AUTOMATIC", XmAUTOMATIC },
+ { "APPLICATION_DEFINED", XmAPPLICATION_DEFINED },
+
+ { "AS_NEEDED", XmAS_NEEDED },
+
+ { "TOP_LEFT", XmTOP_LEFT },
+ { "BOTTOM_LEFT", XmBOTTOM_LEFT },
+ { "TOP_RIGHT", XmTOP_RIGHT },
+ { "BOTTOM_RIGHT", XmBOTTOM_RIGHT },
+
+/************************************************************************
+ * *
+ * MainWindow Resources *
+ * *
+ ************************************************************************/
+
+ { "COMMAND_ABOVE_WORKSPACE" ,XmCOMMAND_ABOVE_WORKSPACE },
+ { "COMMAND_BELOW_WORKSPACE", XmCOMMAND_BELOW_WORKSPACE },
+
+/************************************************************************
+ * *
+ * Text Widget defines *
+ * *
+ ************************************************************************/
+
+ { "MULTI_LINE_EDIT", XmMULTI_LINE_EDIT },
+ { "SINGLE_LINE_EDIT", XmSINGLE_LINE_EDIT },
+
+ /* XmTextDirection */
+ { "TEXT_FORWARD", XmTEXT_FORWARD },
+ { "TEXT_BACKWARD", XmTEXT_BACKWARD },
+
+ { "FMT_8_BIT", XmFMT_8_BIT },
+ { "FMT_16_BIT", XmFMT_16_BIT },
+
+ /* XmTextScanType */
+ { "SELECT_POSITION", XmSELECT_POSITION },
+ { "SELECT_WHITESPACE", XmSELECT_WHITESPACE },
+ { "SELECT_WORD", XmSELECT_WORD },
+ { "SELECT_LINE", XmSELECT_LINE },
+ { "SELECT_ALL", XmSELECT_ALL },
+ { "SELECT_PARAGRAPH", XmSELECT_PARAGRAPH },
+ { "SELECT_OUT_LINE", XmSELECT_OUT_LINE },
+
+ /* XmHighlightMode */
+ { "HIGHLIGHT_NORMAL", XmHIGHLIGHT_NORMAL },
+ { "HIGHLIGHT_SELECTED", XmHIGHLIGHT_SELECTED },
+ { "HIGHLIGHT_SECONDARY_SELECTED",
+ XmHIGHLIGHT_SECONDARY_SELECTED },
+ { "SEE_DETAIL", XmSEE_DETAIL },
+
+ { "COPY_FAILED", XmCOPY_FAILED },
+ { "COPY_SUCCEEDED", XmCOPY_SUCCEEDED },
+ { "COPY_TRUNCATED", XmCOPY_TRUNCATED },
+
+/************************************************************************
+ * *
+ * DIALOG defines.. BulletinBoard and things common to its subclasses *
+ * CommandBox MessageBox Selection FileSelection *
+ * *
+ ************************************************************************/
+
+ /* child type defines for Xm...GetChild() */
+ { "DIALOG_NONE", XmDIALOG_NONE },
+ { "DIALOG_APPLY_BUTTON", XmDIALOG_APPLY_BUTTON },
+ { "DIALOG_CANCEL_BUTTON", XmDIALOG_CANCEL_BUTTON },
+ { "DIALOG_DEFAULT_BUTTON", XmDIALOG_DEFAULT_BUTTON },
+ { "DIALOG_OK_BUTTON", XmDIALOG_OK_BUTTON },
+ { "DIALOG_FILTER_LABEL", XmDIALOG_FILTER_LABEL },
+ { "DIALOG_FILTER_TEXT", XmDIALOG_FILTER_TEXT },
+ { "DIALOG_HELP_BUTTON", XmDIALOG_HELP_BUTTON },
+ { "DIALOG_LIST", XmDIALOG_LIST },
+ { "DIALOG_LIST_LABEL", XmDIALOG_LIST_LABEL },
+ { "DIALOG_MESSAGE_LABEL", XmDIALOG_MESSAGE_LABEL },
+ { "DIALOG_SELECTION_LABEL", XmDIALOG_SELECTION_LABEL },
+ { "DIALOG_SYMBOL_LABEL", XmDIALOG_SYMBOL_LABEL },
+ { "DIALOG_TEXT", XmDIALOG_TEXT },
+ { "DIALOG_SEPARATOR", XmDIALOG_SEPARATOR },
+ { "DIALOG_DIR_LIST", XmDIALOG_DIR_LIST },
+ { "DIALOG_DIR_LIST_LABEL", XmDIALOG_DIR_LIST_LABEL },
+
+ { "DIALOG_HISTORY_LIST", XmDIALOG_HISTORY_LIST },
+ { "DIALOG_PROMPT_LABEL", XmDIALOG_PROMPT_LABEL },
+ { "DIALOG_VALUE_TEXT", XmDIALOG_VALUE_TEXT },
+ { "DIALOG_COMMAND_TEXT", XmDIALOG_COMMAND_TEXT },
+ { "DIALOG_FILE_LIST", XmDIALOG_FILE_LIST },
+ { "DIALOG_FILE_LIST_LABEL", XmDIALOG_FILE_LIST_LABEL },
+
+ /* dialog style defines */
+ { "DIALOG_MODELESS", XmDIALOG_MODELESS },
+ { "DIALOG_PRIMARY_APPLICATION_MODAL",
+ XmDIALOG_PRIMARY_APPLICATION_MODAL },
+ { "DIALOG_FULL_APPLICATION_MODAL",
+ XmDIALOG_FULL_APPLICATION_MODAL },
+ { "DIALOG_SYSTEM_MODAL", XmDIALOG_SYSTEM_MODAL },
+
+/************************************************************************
+ * XmSelectionBox, XmFileSelectionBox and XmCommand - misc. stuff *
+ ***********************************************************************/
+
+ /* Defines for Selection child placement */
+ { "PLACE_TOP", XmPLACE_TOP },
+ { "PLACE_ABOVE_SELECTION", XmPLACE_ABOVE_SELECTION },
+ { "PLACE_BELOW_SELECTION", XmPLACE_BELOW_SELECTION },
+
+ /* Defines for file type mask:
+ */
+ { "FILE_DIRECTORY", XmFILE_DIRECTORY },
+ { "FILE_REGULAR", XmFILE_REGULAR },
+ { "FILE_ANY_TYPE", XmFILE_ANY_TYPE },
+
+ /* Defines for selection dialog type:
+ */
+ { "DIALOG_WORK_AREA", XmDIALOG_WORK_AREA },
+ { "DIALOG_PROMPT", XmDIALOG_PROMPT },
+ { "DIALOG_SELECTION", XmDIALOG_SELECTION },
+ { "DIALOG_COMMAND", XmDIALOG_COMMAND },
+ { "DIALOG_FILE_SELECTION", XmDIALOG_FILE_SELECTION },
+
+/************************************************************************
+ * XmMessageBox stuff not common to other dialogs *
+ ***********************************************************************/
+
+ /* defines for dialog type */
+ { "DIALOG_TEMPLATE", XmDIALOG_TEMPLATE },
+ { "DIALOG_ERROR", XmDIALOG_ERROR },
+ { "DIALOG_INFORMATION", XmDIALOG_INFORMATION },
+ { "DIALOG_MESSAGE", XmDIALOG_MESSAGE },
+ { "DIALOG_QUESTION", XmDIALOG_QUESTION },
+ { "DIALOG_WARNING", XmDIALOG_WARNING },
+ { "DIALOG_WORKING", XmDIALOG_WORKING },
+
+ /* Traversal types */
+ /* XmVisibility */
+ { "VISIBILITY_UNOBSCURED", XmVISIBILITY_UNOBSCURED },
+ { "VISIBILITY_PARTIALLY_OBSCURED",
+ XmVISIBILITY_PARTIALLY_OBSCURED },
+ { "VISIBILITY_FULLY_OBSCURED", XmVISIBILITY_FULLY_OBSCURED },
+
+ /* XmTraverseDirection */
+ { "TRAVERSE_CURRENT", XmTRAVERSE_CURRENT },
+ { "TRAVERSE_NEXT", XmTRAVERSE_NEXT },
+ { "TRAVERSE_PREV", XmTRAVERSE_PREV },
+ { "TRAVERSE_HOME", XmTRAVERSE_HOME },
+ { "TRAVERSE_NEXT_TAB_GROUP", XmTRAVERSE_NEXT_TAB_GROUP },
+ { "TRAVERSE_PREV_TAB_GROUP", XmTRAVERSE_PREV_TAB_GROUP },
+ { "TRAVERSE_UP", XmTRAVERSE_UP },
+ { "TRAVERSE_DOWN", XmTRAVERSE_DOWN },
+ { "TRAVERSE_LEFT", XmTRAVERSE_LEFT },
+ { "TRAVERSE_RIGHT", XmTRAVERSE_RIGHT },
+ { "TRAVERSE_GLOBALLY_FORWARD", XmTRAVERSE_GLOBALLY_FORWARD },
+ { "TRAVERSE_GLOBALLY_BACKWARD", XmTRAVERSE_GLOBALLY_BACKWARD },
+
+/***********************************************************************
+ *
+ * SimpleMenu declarations and definitions.
+ *
+ ***********************************************************************/
+
+ { "PUSHBUTTON", XmPUSHBUTTON },
+ { "TOGGLEBUTTON", XmTOGGLEBUTTON },
+ { "RADIOBUTTON", XmRADIOBUTTON },
+ { "CASCADEBUTTON", XmCASCADEBUTTON },
+ { "SEPARATOR", XmSEPARATOR },
+ { "DOUBLE_SEPARATOR", XmDOUBLE_SEPARATOR },
+ { "TITLE", XmTITLE },
+ { "CHECKBUTTON", XmCHECKBUTTON },
+
+/***********************************************************************
+ *
+ * BitmapConversionModel
+ *
+ ***********************************************************************/
+
+ { "MATCH_DEPTH", XmMATCH_DEPTH },
+ { "DYNAMIC_DEPTH", XmDYNAMIC_DEPTH },
+
+/************************************************************************
+ * PrintShell defines
+ ************************************************************************/
+
+ { "PDM_NOTIFY_FAIL", XmPDM_NOTIFY_FAIL },
+ { "PDM_NOTIFY_SUCCESS", XmPDM_NOTIFY_SUCCESS },
+
+/************************************************************************
+ * MultiList defines
+ ************************************************************************/
+
+ { "MULTILIST_FOUND", XmMULTILIST_FOUND },
+ { "MULTILIST_NOT_FOUND", XmMULTILIST_NOT_FOUND },
+
+/************************************************************************
+ * DropDown defines
+ ************************************************************************/
+
+ { "DROPDOWN_LABEL", XmDROPDOWN_LABEL },
+ { "DROPDOWN_TEXT", XmDROPDOWN_TEXT },
+ { "DROPDOWN_ARROW_BUTTON", XmDROPDOWN_ARROW_BUTTON },
+ { "DROPDOWN_LIST", XmDROPDOWN_LIST },
+
+ /* XmNmwmDecorations */
+ { "MWM_DECOR_ALL", MWM_DECOR_ALL },
+ { "MWM_DECOR_BORDER", MWM_DECOR_BORDER },
+ { "MWM_DECOR_MAXIMIZE", MWM_DECOR_MAXIMIZE },
+ { "MWM_DECOR_MENU", MWM_DECOR_MENU },
+ { "MWM_DECOR_MINIMIZE", MWM_DECOR_MINIMIZE },
+ { "MWM_DECOR_RESIZEH", MWM_DECOR_RESIZEH },
+ { "MWM_DECOR_TITLE", MWM_DECOR_TITLE },
+
+ /* XmNmwmFunctions */
+ { "MWM_FUNC_ALL", MWM_FUNC_ALL },
+ { "MWM_FUNC_CLOSE", MWM_FUNC_CLOSE },
+ { "MWM_FUNC_MAXIMIZE", MWM_FUNC_MAXIMIZE },
+ { "MWM_FUNC_MINIMIZE", MWM_FUNC_MINIMIZE },
+ { "MWM_FUNC_MOVE", MWM_FUNC_MOVE },
+ { "MWM_FUNC_RESIZE", MWM_FUNC_RESIZE },
+
+ { "True", True },
+ { "False", False },
+
+ { "EXTERNAL_HIGHLIGHT", XmEXTERNAL_HIGHLIGHT },
+ { "INTERNAL_HIGHLIGHT", XmINTERNAL_HIGHLIGHT },
+
+ { "GrabExclusive", XtGrabExclusive },
+ { "GrabNone", XtGrabNone },
+};
+
+size_t
+num_motif_ints(void)
+{
+ return sizeof(motif_ints)/sizeof(motif_ints[0]);
+}
14 hello.lua
@@ -0,0 +1,14 @@
+require "motif"
+
+button = PushButton {
+ labelString = "Push here to say hello",
+ activateCallback = function ()
+ print("Hello yourself!")
+ end
+}
+
+SetLanguageProc(nil, nil, nil)
+toplevel, app = Initialize("XLua")
+
+Realize(toplevel, button)
+MainLoop(app)
39 hello_dialog.lua
@@ -0,0 +1,39 @@
+require "motif"
+
+function exit(w)
+ print("exiting")
+ SetExitFlag(app)
+end
+
+function activate(dialog)
+ print("OK was pressed.")
+end
+
+function popup(button)
+ local dialog = button:CreateInformationDialog("info")
+
+ dialog.messageString = "Hello, world!"
+ dialog.okCallback = activate
+
+ Realize(button:XtParent(), dialog)
+
+ dialog:XtParent():Popup(GrabNone)
+end
+
+SetLanguageProc(nil, nil, nil)
+
+toplevel, app = Initialize("Demos")
+
+rc = RowColumn {
+ pb = PushButton {
+ labelString = "Hello",
+ activateCallback = popup
+ },
+ PushButton {
+ labelString = "Goodbye",
+ activateCallback = exit
+ }
+}
+
+Realize(toplevel, rc)
+MainLoop(app)
1,054 luamotif.c
@@ -0,0 +1,1054 @@
+/*
+ * Copyright (c) 2009 - 2012, Micro Systems Marc Balmer, CH-5073 Gipf-Oberfrick
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Micro Systems Marc Balmer nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Lua binding for Motif */
+
+#include <stdlib.h>
+
+#include <X11/Xdefs.h>
+#include <Xm/XmAll.h>
+
+#include <iconv.h>
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "luamotif.h"
+
+static int lm_getArgs(lua_State *L, int start, Arg **args);
+static int get_type(const char *);
+
+extern struct luaL_reg lm_gadgetConstructors[];
+extern struct luaL_reg lm_widgetConstructors[];
+
+extern struct str_constant motif_strings[];
+extern struct int_constant motif_ints[];
+extern size_t num_motif_strings(void);
+extern size_t num_motif_ints(void);
+
+static struct str_constant *typestr;
+
+static Widget
+lm_GetWidget(lua_State *L, int t)
+{
+ Widget w;
+
+ if (!lua_istable(L, t))
+ luaL_argerror(L, t, "table expected");
+
+ lua_pushstring(L, "__widget");
+ lua_rawget(L, t);
+ w = (Widget)lua_topointer(L, -1);
+ lua_pop(L, 1);
+
+ if (w == NULL)
+ luaL_argerror(L, t, "widget expected");
+ return w;
+}
+
+static int
+lm_CreateFileSelectionDialog(lua_State *L)
+{
+ Widget parent, dialog;
+ const char *name;
+
+ parent = lm_GetWidget(L, 1);
+
+ name = luaL_checkstring(L, 2);
+ dialog = XmCreateFileSelectionDialog(parent, (char *)name, NULL, 0);
+ XtManageChild(dialog);
+ lua_newtable(L);
+ lua_pushlightuserdata(L, dialog);
+ lua_setfield(L, -2, "__widget");
+ luaL_getmetatable(L, WIDGET_METATABLE);
+ lua_setmetatable(L, -2);
+
+ return 1;
+}
+
+static int
+lm_CreateInformationDialog(lua_State *L)
+{
+ Widget parent, dialog;
+ const char *name;
+
+ parent = lm_GetWidget(L, 1);
+
+ name = luaL_checkstring(L, 2);
+ dialog = XmCreateInformationDialog(parent, (char *)name, NULL, 0);
+ XtManageChild(dialog);
+ lua_newtable(L);
+ lua_pushlightuserdata(L, dialog);
+ lua_setfield(L, -2, "__widget");
+ luaL_getmetatable(L, WIDGET_METATABLE);
+ lua_setmetatable(L, -2);
+
+ return 1;
+}
+
+static int
+lm_XmFileSelectionBoxGetChild(lua_State *L)
+{
+ Widget child, parent;
+ int which;
+
+ if (!lua_islightuserdata(L, 1))
+ luaL_argerror(L, 1, "udata expected");
+
+ parent = lua_touserdata(L, 1);
+ which = luaL_checkinteger(L, 2);
+ child = XmFileSelectionBoxGetChild(parent, which);
+ lua_pushlightuserdata(L, child);
+ return 1;
+}
+
+static int
+lm_XmFileSelectionDoSearch(lua_State *L)
+{
+ Widget widget;
+ XmString str;
+
+ if (!lua_islightuserdata(L, 1))
+ luaL_argerror(L, 1, "udata expected");
+ if (!lua_islightuserdata(L, 2))
+ luaL_argerror(L, 2, "udata expected");
+
+ widget = lua_touserdata(L, 1);
+ str = lua_touserdata(L, 2);
+ XmFileSelectionDoSearch(widget, str);
+ return 0;
+}
+
+static int
+lm_XmMessageBoxGetChild(lua_State *L)
+{
+ Widget child, parent;
+ int which;
+
+ if (!lua_islightuserdata(L, 1))
+ luaL_argerror(L, 1, "udata expected");
+
+ parent = lua_touserdata(L, 1);
+ which = luaL_checkint(L, 2);
+ child = XmMessageBoxGetChild(parent, which);
+ lua_pushlightuserdata(L, child);
+ return 1;
+}
+
+static int
+lm_ProcessTraversal(lua_State *L)
+{
+ Widget widget;
+ int direction;
+
+ widget = lm_GetWidget(L, 1);
+ direction = luaL_checkint(L, 2);
+ XmProcessTraversal(widget, (XmTraversalDirection)direction);
+ return 0;
+}
+
+static int
+lm_GetString(lua_State *L)
+{
+ Widget widget;
+ char *txt;
+
+ widget = lm_GetWidget(L, 1);
+
+ txt = XmTextGetString(widget);
+ if (txt == NULL)
+ lua_pushnil(L);
+ else
+ lua_pushstring(L, txt);
+ return 1;
+}
+
+static int
+lm_Remove(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XmTextRemove(widget);
+ return 0;
+}
+
+static int
+lm_SetInsertionPosition(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XmTextSetInsertionPosition(widget, luaL_checkint(L, 2));
+ return 0;
+}
+
+static int
+lm_SetMaxLength(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XmTextSetMaxLength(widget, luaL_checkint(L, 2));
+ return 0;
+}
+
+static int
+lm_SetString(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XmTextSetString(widget, (char *)luaL_checkstring(L, 2));
+ return 0;
+}
+
+static int
+lm_UpdateDisplay(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XmUpdateDisplay(widget);
+ return 0;
+}
+
+static void
+lm_Callback(Widget widget, XtPointer client_data, XtPointer call_data)
+{
+ struct cb_data *cbd = (struct cb_data *)client_data;
+
+ lua_rawgeti(cbd->L, LUA_REGISTRYINDEX, cbd->ref);
+ lua_rawgeti(cbd->L, LUA_REGISTRYINDEX, cbd->obj);
+ lua_pcall(cbd->L, 1, 0, 0);
+}
+
+static void
+lm_DestroyCallback(Widget widget, XtPointer client_data, XtPointer call_data)
+{
+ struct cb_data *cbd = (struct cb_data *)client_data;
+
+ luaL_unref(cbd->L, LUA_REGISTRYINDEX, cbd->ref);
+ luaL_unref(cbd->L, LUA_REGISTRYINDEX, cbd->obj);
+ free(cbd);
+}
+
+static int
+lm_AddCallback(lua_State *L)
+{
+ Widget w;
+ const char *cb;
+ const char *func;
+ struct cb_data *cbd;
+
+ w = lm_GetWidget(L, 1);
+ if (!lua_isstring(L, 2))
+ luaL_argerror(L, 2, "string expected");
+ if (!lua_isfunction(L, 3))
+ luaL_argerror(L, 3, "function expected");
+
+ /* XXX maybe leaks memory (e.g. when the widget is destroyed */
+ cbd = malloc(sizeof(struct cb_data));
+ if (cbd == NULL)
+ luaL_error(L, "memory error");
+
+ cbd->L = L;
+ cbd->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ cb = lua_tostring(L, -1);
+ XtAddCallback(w, (char *)cb, lm_Callback, cbd);
+ XtAddCallback(w, XmNdestroyCallback, lm_DestroyCallback, cbd);
+ return 0;
+}
+
+static int
+lm_getArgs(lua_State *L, int start, Arg **args)
+{
+ XmString string;
+ int narg, n;
+ const char *arg;
+
+ *args = calloc(sizeof(Arg), lua_gettop(L));
+ if (*args == NULL)
+ luaL_error(L, "memory error");
+
+ for (narg = 0, n = start; n <= lua_gettop(L); n++) {
+ if (lua_type(L, n) != LUA_TSTRING)
+ continue;
+ arg = lua_tostring(L, n);
+ n++;
+ switch (lua_type(L, n)) {
+ case LUA_TNUMBER:
+ XtSetArg((*args)[narg], (String)arg, (XtArgVal)
+ (int)lua_tonumber(L, n));
+ narg++;
+ break;
+ case LUA_TSTRING:
+ /* XXX leaks memory */
+ string = XmStringCreateLocalized(
+ (char *)lua_tostring(L, n));
+ XtSetArg((*args)[narg], (String)arg, (XtArgVal)string);
+ narg++;
+ break;
+ case LUA_TFUNCTION:
+ break;
+ case LUA_TNIL:
+ break;
+ case LUA_TBOOLEAN:
+ break;
+ case LUA_TTABLE:
+ break;
+ case LUA_TUSERDATA:
+ XtSetArg((*args)[narg], (String)arg,
+ (XtArgVal)lua_topointer(L, n));
+ narg++;
+ break;
+ case LUA_TTHREAD:
+ break;
+ case LUA_TLIGHTUSERDATA:
+ XtSetArg((*args)[narg], (String)arg,
+ (XtArgVal)lua_topointer(L, n));
+ narg++;
+ break;
+ default:
+ break;
+ }
+ }
+ return narg;
+}
+
+static int
+lm_GetValues(lua_State *L)
+{
+ Arg args[1];
+ Widget widget;
+ int narg, n, type, number;
+ const char *arg;
+ char *string, *value;
+ Cardinal card;
+ XmString text;
+
+ widget = lm_GetWidget(L, 1);
+
+ for (narg = 0, n = 2; n < lua_gettop(L); n++) {
+ if (lua_type(L, n) != LUA_TSTRING)
+ continue;
+
+ arg = lua_tostring(L, n);
+ type = get_type(arg);
+ switch (type) {
+ case LUA_TNUMBER:
+ XtSetArg(args[0], (String)arg, &card);
+ XtGetValues(widget, args, 1);
+ lua_pushnumber(L, card);
+ narg++;
+ break;
+ case LUA_TSTRING:
+ XtSetArg(args[0], (String)arg, &text);
+ XtGetValues(widget, args, 1);
+ XmStringGetLtoR(text, XmFONTLIST_DEFAULT_TAG, &value);
+ lua_pushstring(L, value);
+ XmStringFree(text);
+ narg++;
+ break;
+ case LUA_TFUNCTION:
+ break;
+ case LUA_TNIL:
+ break;
+ case LUA_TBOOLEAN:
+ break;
+ case LUA_TTABLE:
+ break;
+ case LUA_TUSERDATA:
+ break;
+ case LUA_TTHREAD:
+ break;
+ case LUA_TLIGHTUSERDATA:
+ break;
+ default:
+ break;
+ }
+ }
+ return narg;
+}
+
+static int
+lm_SetValues(lua_State *L)
+{
+ Arg *args;
+ Widget widget;
+ int narg;
+
+ widget = lm_GetWidget(L, 1);
+ narg = lm_getArgs(L, 2, &args);
+ XtSetValues(widget, args, narg);
+ free(args);
+ return 0;
+}
+
+static int
+lm_SetWorkWindow(lua_State *L)
+{
+ Widget widget, work_window;
+ int narg;
+
+ widget = lm_GetWidget(L, 1);
+ work_window = lm_GetWidget(L, 2);
+ XtVaSetValues(widget, XmNworkWindow, work_window, NULL);
+ return 0;
+}
+
+static int
+lm_ScrollVisible(lua_State *L)
+{
+ Widget w, scroll_to;
+
+ w = lm_GetWidget(L, 1);
+ scroll_to = lm_GetWidget(L, 2);
+
+ XmScrollVisible(w, scroll_to, 0, 0);
+ return 0;
+}
+
+/* Return the true widget */
+static int
+lm_Widget(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+
+ lua_pushlightuserdata(L, widget);
+
+ return 1;
+}
+
+/* Return the true XtParent as a widget */
+static int
+lm_XtParent(lua_State *L)
+{
+ Widget parent, widget;
+
+ widget = lm_GetWidget(L, 1);
+
+ parent = XtParent(widget);
+ lua_newtable(L);
+ lua_pushlightuserdata(L, parent);
+ lua_setfield(L, -2, "__widget");
+ luaL_getmetatable(L, WIDGET_METATABLE);
+ lua_setmetatable(L, -2);
+
+ return 1;
+}
+
+/* Return the Parent in the Lua object hierarchy */
+static int
+lm_Parent(lua_State *L)
+{
+ if (!lua_istable(L, -1))
+ luaL_argerror(L, -1, "table expected");
+
+ lua_pushstring(L, "__parent");
+ lua_rawget(L, -2);
+ return 1;
+}
+
+static int
+lm_Popdown(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XtPopdown(widget);
+ return 0;
+}
+
+static int
+lm_Popup(lua_State *L)
+{
+ Widget widget;
+ int grab;
+
+ widget = lm_GetWidget(L, 1);
+ grab = luaL_checkint(L, 2);
+ XtPopup(widget, grab);
+ return 0;
+}
+
+static int
+lm_Screen(lua_State *L)
+{
+ Widget widget;
+ Screen *screen;
+
+ widget = lm_GetWidget(L, 1);
+ screen = XtScreen(widget);
+ lua_pushinteger(L, screen->width);
+ lua_pushinteger(L, screen->height);
+ return 2;
+};
+
+static int
+lm_XtSetLanguageProc(lua_State *L)
+{
+ XtAppContext app_context;
+ XtLanguageProc proc;
+ XtPointer client_data;
+
+ if (lua_isnil(L, 1))
+ app_context = NULL;
+ else
+ app_context = lua_touserdata(L, 1);
+ if (lua_isnil(L, 2))
+ proc = NULL;
+ else
+ proc = lua_touserdata(L, 2);
+ if (lua_isnil(L, 3))
+ client_data = NULL;
+ else
+ client_data = lua_touserdata(L, 3);
+ XtSetLanguageProc(app_context, proc, client_data);
+ return 0;
+}
+
+static int
+lm_SetSensitive(lua_State *L)
+{
+ Widget widget;
+ int value;
+
+ widget = lm_GetWidget(L, 1);
+ value = luaL_checkint(L, 2);
+ XtSetSensitive(widget, value);
+ return 0;
+}
+
+static int
+lm_UnmanageChild(lua_State *L)
+{
+ Widget widget;
+
+ widget = lm_GetWidget(L, 1);
+ XtUnmanageChild(widget);
+ return 0;
+}
+
+static int
+lm_Initialize(lua_State *L)
+{
+ Widget toplevel;
+ XtAppContext *app;
+ const char *application_class;
+ int argc = 0;
+ String argv[1];
+
+ app = malloc(sizeof(XtAppContext));
+ application_class = luaL_checkstring(L, 1);
+ toplevel = XtAppInitialize(app, (char *)application_class, NULL, 0,
+ &argc, argv, NULL, NULL, 0);
+ lua_newtable(L);
+ lua_pushlightuserdata(L, toplevel);
+ lua_setfield(L, -2, "__widget");
+ luaL_getmetatable(L, WIDGET_METATABLE);
+ lua_setmetatable(L, -2);
+
+ lua_pushlightuserdata(L, app);
+ return 2;
+}
+
+static int
+lm_MainLoop(lua_State *L)
+{
+ XtAppContext *app;
+
+ if (!lua_islightuserdata(L, 1))
+ luaL_argerror(L, 1, "udata expected");
+
+ app = lua_touserdata(L, 1);
+ XtAppMainLoop(*app);
+ return 0;
+}
+
+static int
+lm_SetExitFlag(lua_State *L)
+{
+ XtAppContext *app;
+
+ if (!lua_islightuserdata(L, 1))
+ luaL_argerror(L, 1, "udata expected");
+
+ app = lua_touserdata(L, 1);
+ XtAppSetExitFlag(*app);
+ return 0;
+}
+
+static int
+type_compare(const void *r1, const void *r2)
+{
+ struct str_constant *s1, *s2;
+
+ s1 = (struct str_constant *)r1;
+ s2 = (struct str_constant *)r2;
+
+ return strcmp(s1->value, s2->value);
+}
+
+static int
+get_type(const char *string)
+{
+ struct str_constant *constant, key;
+ int type = LUA_TNIL;
+
+ if (typestr == NULL) {
+ typestr = motif_strings;
+ qsort(&motif_strings[0],
+ num_motif_strings(),
+ sizeof(motif_strings[0]), type_compare);
+ }
+ key.value = string;
+ constant = bsearch(&key, &motif_strings[0],
+ num_motif_strings(),
+ sizeof(motif_strings[0]), type_compare);
+ if (constant)
+ type = constant->type;
+ return type;
+}
+
+static void
+lm_set_info(lua_State *L) {
+ lua_pushliteral(L, "_COPYRIGHT");
+ lua_pushliteral(L, "Copyright (C) 2009, 2010, 2011 micro systems "
+ "marc balmer");
+ lua_settable(L, -3);
+ lua_pushliteral(L, "_DESCRIPTION");
+ lua_pushliteral(L, "Motif binding for Lua");
+ lua_settable(L, -3);
+ lua_pushliteral(L, "_VERSION");
+ lua_pushliteral(L, "Motif 1.1.2");
+ lua_settable(L, -3);
+}
+
+static void
+register_global(lua_State *L, struct luaL_reg *reg)
+{
+ while (reg->name != NULL) {
+ lua_pushcfunction(L, reg->func);
+ lua_setfield(L, LUA_GLOBALSINDEX, reg->name);
+ reg++;
+ }
+}
+
+static int
+lm_index(lua_State *L)
+{
+ const char *nam;
+
+ nam = lua_tostring(L, -1);
+ lua_rawget(L, -2);
+ if (lua_type(L, -1) == LUA_TNIL) {
+ if (lua_getmetatable(L, -2)) {
+ lua_pushstring(L, nam);
+ lua_rawget(L, -2);
+ /* XXX if no function found, try attributes */
+ }
+ }
+ return 1;
+}
+
+static int
+lm_newindex(lua_State *L)
+{
+ Arg args[1];
+ Widget widget;
+ lm_callbackdata *cbd;
+ XmString s;
+ int narg, n;
+ const char *nam;
+ char *nm;
+
+ nam = lua_tostring(L, -2);
+
+ lua_pushstring(L, "__widget");
+ lua_rawget(L, 1);
+ widget = (Widget)lua_topointer(L, -1);
+ lua_pop(L, 1);
+
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ lua_pushvalue(L, -1);
+ lua_pushstring(L, nam);
+ lua_rawset(L, 1);
+ }
+
+ if (widget != NULL) {
+ narg = 0;
+ switch (lua_type(L, -1)) {
+ case LUA_TSTRING:
+ nm = strdup(nam);
+ s = XmStringCreateLocalized(
+ (String)lua_tostring(L, -1));
+ XtSetArg(args[narg], nm, (XtArgVal)s);
+ narg++;
+ break;
+ case LUA_TNUMBER:
+ nm = strdup(nam);
+ XtSetArg(args[narg], nm, (XtArgVal)
+ (int)lua_tonumber(L, -1));
+ narg++;
+ break;
+ case LUA_TBOOLEAN:
+ nm = strdup(nam);
+ XtSetArg(args[narg], nm, (XtArgVal)
+ (int)lua_toboolean(L, -1));
+ narg++;
+ break;
+ case LUA_TFUNCTION:
+ /* XXX maybe leaks memory */
+ cbd = malloc(sizeof(struct cb_data));
+ if (cbd == NULL)
+ luaL_error(L, "memory error");
+ cbd->L = L;
+ lua_pushvalue(L, -1);
+ cbd->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ lua_pushvalue(L, -3);
+ cbd->obj = luaL_ref(L, LUA_REGISTRYINDEX);
+ XtAddCallback(widget, nam, lm_Callback, cbd);
+ XtAddCallback(widget, XmNdestroyCallback,
+ lm_DestroyCallback, cbd);
+ break;
+ }
+ if (narg > 0) {
+ XtSetValues(widget, args, narg);
+ for (n = 0; n < narg; n++)
+ free(args[n].name);
+ }
+ }
+ return 0;
+}
+
+#define MAXARGS 64
+
+static Widget
+lm_CreateWidgetHierarchy(lua_State *L, int parentObj, Widget parent,
+ const char *name)
+{
+ Arg args[MAXARGS];
+ WidgetClass class;
+ Widget widget;
+ XmString s;
+#if 0
+ iconv_t cd;
+#endif
+ struct cb_data *cbd;
+ size_t len, inbytesleft, outbytesleft;
+ char nam[64], *nm;
+ int n, narg, t;
+ const char *cb;
+ const char *func;
+ char *utf8_s;
+#if 0
+ char *utf8_s, *iso_s;
+ char *inbuf, *outbuf;
+#endif
+ widget = NULL;
+ narg = 0;
+
+ lua_pushstring(L, "__widgetClass");
+ lua_rawget(L, -2);
+ class = (WidgetClass)lua_topointer(L, -1);
+ lua_pop(L, 1);
+
+ if (class != NULL) {
+ t = lua_gettop(L);
+ lua_pushnil(L);
+ while (lua_next(L, t) != 0) {
+ switch (lua_type(L, -2)) {
+ case LUA_TSTRING:
+ strlcpy(nam, lua_tostring(L, -2), sizeof nam);
+ break;
+ case LUA_TNUMBER:
+ snprintf(nam, sizeof nam, "%.f", lua_tonumber(L, -2));
+ break;
+ default:
+ strlcpy(nam, name, sizeof nam);
+ }
+
+ switch (lua_type(L, -1)) {
+ case LUA_TSTRING:
+ utf8_s = (char *)lua_tostring(L, -1);
+#if 0
+ len = strlen(iso_s) * 2 + 1;
+ utf8_s = malloc(len);
+
+ cd = iconv_open("UTF-8", "ISO-8859-1");
+ inbytesleft = strlen(iso_s);
+ outbytesleft = len;
+ inbuf = iso_s;
+ outbuf = utf8_s;
+ bzero(utf8_s, len);
+ iconv(cd, (const char**)&inbuf, &inbytesleft,
+ &outbuf, &outbytesleft);
+ iconv_close(cd);
+#endif
+ nm = strdup(nam);
+ /* XXX ugly, ugliest... */
+ if (strcmp(nam, "value")) {
+ s = XmStringCreateLocalized(utf8_s);
+ XtSetArg(args[narg], nm, (XtArgVal)s);
+ } else
+ XtSetArg(args[narg], nm, utf8_s);
+ narg++;
+ break;
+ case LUA_TNUMBER:
+ nm = strdup(nam);
+ XtSetArg(args[narg], nm, (XtArgVal)
+ (int)lua_tonumber(L, -1));
+ narg++;
+ break;
+ case LUA_TBOOLEAN:
+ nm = strdup(nam);
+ XtSetArg(args[narg], nm, (XtArgVal)
+ (int)lua_toboolean(L, -1));
+ narg++;
+ break;
+ }
+ lua_pop(L, 1);
+ }
+ }
+
+ if (class == xmDialogShellWidgetClass)
+ widget = XtCreatePopupShell(name, class, parent, args, narg);
+ else if (class != NULL)
+ widget = XtCreateManagedWidget(name, class, parent, args, narg);
+ if (widget != NULL) {
+ lua_pushlightuserdata(L, widget);
+ lua_setfield(L, -2, "__widget");
+ luaL_getmetatable(L, WIDGET_METATABLE);
+ lua_setmetatable(L, -2);
+ }
+
+ t = lua_gettop(L);
+ lua_pushnil(L);
+ while (lua_next(L, t) != 0) {
+ switch (lua_type(L, -2)) {
+ case LUA_TSTRING:
+ strlcpy(nam, lua_tostring(L, -2), sizeof nam);
+ break;
+ case LUA_TNUMBER:
+ snprintf(nam, sizeof n, "%.f", lua_tonumber(L, -2));
+ break;
+ default:
+ strlcpy(nam, name, sizeof nam);
+ }
+
+ switch (lua_type(L, -1)) {
+ case LUA_TTABLE:
+ if (widget == NULL)
+ lm_CreateWidgetHierarchy(L, t, parent, nam);
+ else
+ lm_CreateWidgetHierarchy(L, t, widget, nam);
+ break;
+ case LUA_TFUNCTION:
+ if (widget == NULL)
+ break;
+
+ /* XXX maybe leaks memory */
+ cbd = malloc(sizeof(struct cb_data));
+ if (cbd == NULL)
+ luaL_error(L, "memory error");
+ cbd->L = L;
+ lua_pushvalue(L, -1);
+ cbd->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ lua_pushvalue(L, t);
+ cbd->obj = luaL_ref(L, LUA_REGISTRYINDEX);
+ XtAddCallback(widget, nam, lm_Callback, cbd);
+ XtAddCallback(widget, XmNdestroyCallback,
+ lm_DestroyCallback, cbd);
+ break;
+ }
+ lua_pop(L, 1);
+ }
+ for (n = 0; n < narg; n++)
+ free(args[n].name);
+ if (parentObj > 0) {
+ lua_pushvalue(L, parentObj);
+ lua_setfield(L, -2, "__parent");
+ }
+ return widget;
+}
+
+static int
+lm_DestroyWidgetHierarchy(lua_State *L)
+{
+ Widget widget;
+ int t;
+
+ widget = NULL;
+
+ lua_getfield(L, -1, "__widget");
+ widget = (Widget)lua_topointer(L, -1);
+ lua_pop(L, 1);
+
+
+ if (lua_type(L, -1) == LUA_TTABLE) {
+ lua_pushnil(L);
+ lua_setfield(L, -2, "__parent");
+
+ t = lua_gettop(L);
+ lua_pushnil(L);
+ while (lua_next(L, t) != 0) {
+ if (lua_type(L, -1) == LUA_TTABLE)
+ lm_DestroyWidgetHierarchy(L);
+ lua_pop(L, 1);
+ }
+ }
+ if (widget != NULL) {
+ XtDestroyWidget(widget);
+ lua_pushnil(L);
+ lua_setfield(L, -2, "__widget");
+
+ }
+ return 0;
+}
+
+static int
+lm_Realize(lua_State *L)
+{
+ Widget toplevel, w;
+ char nam[64];
+ void *table;
+
+ toplevel = lm_GetWidget(L, 1);
+ if (!lua_istable(L, 2))
+ luaL_argerror(L, 2, "table expected");
+
+ if (lua_gettop(L) == 3) {
+ if (!lua_isstring(L, 3))
+ luaL_argerror(L, 3, "string expected");
+ strlcpy(nam, lua_tostring(L, 3), sizeof nam);
+ lua_pop(L, 1);
+ } else {
+ table = (void *)lua_topointer(L, 2);
+ strlcpy(nam, "toplevel", sizeof nam);
+
+ lua_pushnil(L);
+ while (lua_next(L, LUA_GLOBALSINDEX) != 0) {
+ if (lua_topointer(L, -1) == table) {
+ switch (lua_type(L, -2)) {
+ case LUA_TSTRING:
+ strlcpy(nam, lua_tostring(L, -2),
+ sizeof nam);
+ break;
+ case LUA_TNUMBER:
+ snprintf(nam, sizeof nam, "%.f",
+ lua_tonumber(L, -2));
+ break;
+ }
+ }
+ lua_pop(L, 1);
+ }
+ }
+ w = lm_CreateWidgetHierarchy(L, 0, toplevel, nam);
+ XtRealizeWidget(toplevel);
+
+ return 0;
+}
+
+int
+luaopen_motif(lua_State *L)
+{
+ int n;
+
+ struct luaL_reg luamotif[] = {
+ { NULL, NULL }
+ };
+ struct luaL_reg luaapp[] = {
+ { "__index", lm_index },
+ { "__newindex", lm_newindex },
+
+ { "CreateInformationDialog", lm_CreateInformationDialog },
+ { "CreateFileSelectionDialog", lm_CreateFileSelectionDialog },
+
+ /* Managing, Xt */
+ { "SetSensitive", lm_SetSensitive },
+ { "UnmanageChild", lm_UnmanageChild },
+ { "Screen", lm_Screen },
+ { "Parent", lm_Parent },
+ { "XtParent", lm_XtParent },
+ { "Widget", lm_Widget },
+ { "Popup", lm_Popup },
+ { "Popdown", lm_Popdown },
+ { "UpdateDisplay", lm_UpdateDisplay },
+ { "ProcessTraversal", lm_ProcessTraversal },
+ { "AddCallback", lm_AddCallback },
+ { "Destroy", lm_DestroyWidgetHierarchy },
+ { "GetValues", lm_GetValues },
+ { "SetValues", lm_SetValues },
+ { "SetWorkWindow", lm_SetWorkWindow },
+ { "ScrollVisible", lm_ScrollVisible },
+
+ /* XmText */
+ { "GetString", lm_GetString },
+ { "SetString", lm_SetString },
+ { "Remove", lm_Remove },
+ { "SetInsertionPosition", lm_SetInsertionPosition },
+ { "SetMaxLenght", lm_SetMaxLength },
+ { NULL, NULL }
+ };
+ struct luaL_reg luaXt[] = {
+ { "Realize", lm_Realize },
+ { "Initialize", lm_Initialize },
+ { "MainLoop", lm_MainLoop },
+ { "SetExitFlag", lm_SetExitFlag },
+ { "SetLanguageProc", lm_XtSetLanguageProc },
+ { NULL, NULL }
+ };
+
+ luaL_register(L, "motif", luamotif);
+ lm_set_info(L);
+ register_global(L, luaXt);
+ register_global(L, lm_widgetConstructors);
+ register_global(L, lm_gadgetConstructors);
+
+ for (n = 0; n < num_motif_strings(); n++) {
+ lua_pushstring(L, motif_strings[n].value);
+ lua_setfield(L, LUA_GLOBALSINDEX, motif_strings[n].name);
+ };
+ for (n = 0; n < num_motif_ints(); n++) {
+ lua_pushinteger(L, motif_ints[n].value);
+ lua_setfield(L, LUA_GLOBALSINDEX, motif_ints[n].name);
+ };
+
+ /* The Widget metatable */
+ if (luaL_newmetatable(L, WIDGET_METATABLE)) {
+ luaL_register(L, NULL, luaapp);
+
+ lua_pushliteral(L, "__metatable");
+ lua_pushliteral(L, "must not access this metatable");
+ lua_settable(L, -3);
+ }
+ lua_pop(L, 1);
+
+ return 1;
+}
52 luamotif.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2009 - 2012, Micro Systems Marc Balmer, CH-5073 Gipf-Oberfrick
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Micro Systems Marc Balmer nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Lua binding for Motif */
+
+#ifndef __LUAMOTIF_H__
+#define __LUAMOTIF_H__
+
+#define WIDGET_METATABLE "Motif widget functions"
+
+typedef struct cb_data {
+ lua_State *L;
+ int ref; /* The function to be called */
+ int obj; /* The Lua object to pass */
+} lm_callbackdata;
+
+struct str_constant {
+ const char *name;
+ const char *value;
+ int type;
+};
+
+struct int_constant {
+ char *name;
+ long value;
+};
+
+#endif /* __LUAMOTIF_H__ */
2 shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
160 widgets.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2009 - 2012, Micro Systems Marc Balmer, CH-5073 Gipf-Oberfrick
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Micro Systems Marc Balmer nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Lua binding for Motif */
+
+#include <stdlib.h>
+
+#include <X11/Xdefs.h>
+#include <Xm/XmAll.h>
+#include <Xm/ButtonBox.h>
+#include <Xm/FontS.h>
+#include <Xm/Tree.h>
+#include <Xm/Outline.h>
+#include <Xm/IconBox.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "luamotif.h"
+
+#define GadgetConstructor(W) \
+static int \
+lm_##W##Gadget(lua_State *L) \
+{ \
+ lua_pushlightuserdata(L, xm##W##GadgetClass); \
+ lua_setfield(L, -2, "__widgetClass"); \
+ return 1; \
+}
+
+#define WidgetConstructor(W) \
+static int \
+lm_##W(lua_State *L) \
+{ \
+ lua_pushlightuserdata(L, xm##W##WidgetClass); \
+ lua_setfield(L, -2, "__widgetClass"); \
+ return 1; \
+}
+
+GadgetConstructor(ArrowButton)
+GadgetConstructor(Label)
+GadgetConstructor(PushButton)
+GadgetConstructor(Separator)
+GadgetConstructor(ToggleButton)
+
+WidgetConstructor(ArrowButton)
+WidgetConstructor(BulletinBoard)
+WidgetConstructor(ButtonBox)
+WidgetConstructor(CascadeButton)
+WidgetConstructor(Column)
+WidgetConstructor(ComboBox)
+WidgetConstructor(Command)
+WidgetConstructor(Container)
+WidgetConstructor(DataField)
+WidgetConstructor(DialogShell)
+WidgetConstructor(DrawingArea)
+WidgetConstructor(DrawnButton)
+WidgetConstructor(FileSelectionBox)
+WidgetConstructor(FontSelector)
+WidgetConstructor(Form)
+WidgetConstructor(Frame)