Path: usenet.cise.ufl.edu!huron.eel.ufl.edu!usenet.eel.ufl.edu!news.ultranet.com!newsswitch.lcs.mit.edu!news-out.internetmci.com!newsfeed.internetmci.com!128.223.220.30!logbridge.uoregon.edu!nntp.teleport.com!news.teleport.com!not-for-mail
From: [email protected] (Ken Fox)
Newsgroups: comp.lang.perl.announce,comp.lang.perl.modules
Subject: ANNOUNCE: X11::Motif 1.1 beta
Followup-To: comp.lang.perl.modules
Date: 31 Jan 1998 15:21:51 GMT
Organization: None Apparent
Lines: 91
Sender: [email protected]
Approved: [email protected] (comp.lang.perl.announce)
Message-ID: <[email protected]>
Reply-To: [email protected]
NNTP-Posting-Host: gadget.cscaper.com
Keywords: X11, Motif, X Toolkit, Perl module
X-Disclaimer: The "Approved" header verifies header information for article transmission and does not imply approval of content.
Xref: usenet.cise.ufl.edu comp.lang.perl.announce:65 comp.lang.perl.modules:1517

The first beta release of the X11::Motif module has been added
to CPAN today.  (Please allow some time for it to be mirrored.)
The module is available as:

 file: $CPAN/authors/id/KENFOX/X11-Motif-1.1b1.tar.gz
 size: 111643 bytes
  md5: 5f2bc908bf14c831ece4e006070b6c30

The X11::Motif distribution includes X11::Lib and X11::Toolkit.
Taken together, these modules provide a nearly complete
interface to the standard X libraries.  The modules have both
object oriented and function call style interfaces.  The object
interface is similar to the Tk module.  The function call
interface is strongly modeled after the standard X library
documentation and will be familiar to someone with X Toolkit or
Motif experience.

I've included two versions of the classic "hello world" example
at the end of this announcement.  Even if you don't grab the module,
I'd appreciate feedback on whether the example is understandable.

To build the modules, you will need:

 * Perl version 5.004 or higher
 * X11R5 or higher (X11R4 should work but hasn't been tested)
 * Motif 1.2.4 or higher (CDE Motif works.  Motif 2.0 is reported
   to work.  LessTif is also reported to work, but with reduced
   functionality.)
 * An ANSI C compiler

I would appreciate being notified of any changes necessary to
support other environments and/or widget sets.

The modules work well in both stand-alone scripts and when embedded
in a larger C-based Motif application.

Any questions or comments?  Please send them to <[email protected]>.

- Ken

# ----------------------------------------------------------------------
# -- Example #1: The object style

use X11::Motif;

my $toplevel = X::Toolkit::initialize("Example");

my $form = give $toplevel -Form;
my $hello = give $form -Label, -text => 'Hello, world!';
my $ok = give $form -Button, -text => 'OK', -command => sub { exit };

arrange $form -fill => 'xy', -bottom => [ $ok, $hello ];

handle $toplevel;

# ----------------------------------------------------------------------
# -- Example #2: The function call style (i.e. "traditional" Motif)

use X11::Motif qw(:Xt :Xm);

my $toplevel = X::Toolkit::initialize("Example");

my $form = XtCreateManagedWidget("form", xmFormWidgetClass, $toplevel);

my $hello = XtCreateManagedWidget("hello", xmLabelWidgetClass, $form,
                                   XmNlabelString, "Hello, world!",
                                   XmNlabelType, XmSTRING);

my $ok = XtCreateManagedWidget("ok", xmPushButtonWidgetClass, $form,
                                   XmNlabelString, "OK",
                                   XmNlabelType, XmSTRING);

XtAddCallback($ok, XmNactivateCallback, sub { exit }, 0);

XtSetValues($hello,
               XmNrightAttachment, XmATTACH_FORM,
               XmNleftAttachment, XmATTACH_FORM,
               XmNtopAttachment, XmATTACH_FORM,
               XmNbottomAttachment, XmATTACH_WIDGET,
               XmNbottomWidget, $ok);

XtSetValues($ok,
               XmNrightAttachment, XmATTACH_FORM,
               XmNleftAttachment, XmATTACH_FORM,
               XmNtopAttachment, XmATTACH_NONE,
               XmNbottomAttachment, XmATTACH_FORM);

XtRealizeWidget($toplevel);
XtAppMainLoop(XtWidgetToApplicationContext($toplevel));