Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

23
cde/examples/README Normal file
View File

@@ -0,0 +1,23 @@
/* $XConsortium: README /main/2 1996/07/15 13:58:13 drk $ */
This directory contains example source for the Dt development
environment components:
dtaction - DtAction action invocation.
dtbuilder - Application builder examples.
dtcalendar - xcsa calendar interface.
dtdnd - DtDnd drag and drop.
dtdts - DtDts datatyping.
dthelp - DtHelp help display and navigation.
dtscreen - DtSaver screen saver.
dtsession - DtSession session management.
dtterm - DtTerm terminal emulator widgets.
dtwidget - libDtWidget additional Motif widgets.
dtwsm - DtWsm workspace management.
motif - Motif user interface toolkit.
template - Template application.
tt - ToolTalk messaging.
The template application is a complete example of a fully
integrated Dt desktop application. The other directories contain
simple code examples of individual development environment components.

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:42:21 drk $
##########################################################################
#
# Makefile for dtdts examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = actions
SOURCES = actions.c
OBJECTS = actions.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:42:36 drk $
##########################################################################
#
# Makefile for dtdts examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = actions
SOURCES = actions.c
OBJECTS = actions.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:42:53 drk $
##########################################################################
#
# Makefile for dtdts examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = actions
SOURCES = actions.c
OBJECTS = actions.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:43:10 drk $
##########################################################################
#
# Makefile for dtwidget examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = actions
SOURCES = actions.c
OBJECTS = actions.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,46 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:43:31 drk $
##########################################################################
#
# Makefile for dtdts examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = actions
SOURCES = actions.c
OBJECTS = actions.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,14 @@
/* $XConsortium: README /main/2 1996/07/15 13:58:52 drk $ */
This directory contains demonstrations of the Action API
actions - Example of using the Action API to invoke actions on a file.
The application displays two text entry fields. Enter an
action name in the first field. To apply the action to a file,
move focus to the next text field and enter a file name.
Press <Return> to invoke the action. The front panel indicator
will flash as the action is being processed.
Use the dtdts/datatyping demo to display the supported actions
for a file or group of files.

View File

@@ -0,0 +1,155 @@
/* $XConsortium: actions.c /main/3 1995/10/27 10:37:37 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
#include <Xm/XmAll.h>
#include <Dt/Dt.h>
#include <Dt/Action.h>
#define ApplicationClass "Dtaction"
static Widget shell;
static XtAppContext appContext;
static Widget actionText;
static Widget fileText;
static void CreateWidgets(Widget);
static void InvokeActionCb(Widget, XtPointer, XtPointer);
static void InvokeAction(char*, char*);
static void DbReloadProc(XtPointer);
void main(int argc, char **argv)
{
Arg args[20];
int n=0;
int numArgs = 0;
shell = XtAppInitialize(&appContext , ApplicationClass, NULL, 0,
&argc, argv, NULL, args, n);
CreateWidgets(shell);
if (DtInitialize(XtDisplay(shell), shell, argv[0], ApplicationClass)==False) {
/* DtInitialize() has already logged an appropriate error msg */
exit(-1);
}
/* Load the filetype/action databases */
DtDbLoad();
/* Notice changes to the database without needing to restart application */
DtDbReloadNotify(DbReloadProc, NULL);
XtRealizeWidget(shell);
XmProcessTraversal(actionText, XmTRAVERSE_CURRENT);
XtAppMainLoop(appContext);
}
static void CreateWidgets(Widget shell)
{
Widget messageBox, workArea, w;
Arg args[20];
int n;
XmString labelString;
labelString = XmStringCreateLocalized("Invoke");
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_TEMPLATE); n++;
XtSetArg(args[n], XmNokLabelString, labelString); n++;
messageBox = XmCreateMessageBox(shell, "messageBox", args, n);
XtManageChild(messageBox);
XmStringFree(labelString);
XtAddCallback(messageBox, XmNokCallback, InvokeActionCb, NULL);
n = 0;
XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
XtSetArg(args[n], XmNpacking, XmPACK_COLUMN); n++;
XtSetArg(args[n], XmNnumColumns, 2); n++;
XtSetArg(args[n], XmNentryAlignment, XmALIGNMENT_END); n++;
workArea = XmCreateWorkArea(messageBox, "workArea", args, n);
XtManageChild(workArea);
labelString = XmStringCreateLocalized("Invoke Action:");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
w = XmCreateLabel(workArea, "actionLabel", args, n);
XtManageChild(w);
XmStringFree(labelString);
labelString = XmStringCreateLocalized("On File:");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
w = XmCreateLabel(workArea, "fileLabel", args, n);
XtManageChild(w);
XmStringFree(labelString);
n = 0;
XtSetArg(args[n], XmNcolumns, 12); n++;
actionText = XmCreateTextField(workArea, "actionText", args, n);
XtManageChild(actionText);
n = 0;
XtSetArg(args[n], XmNcolumns, 12); n++;
fileText = XmCreateTextField(workArea, "fileText", args, n);
XtManageChild(fileText);
}
static void DbReloadProc(XtPointer cd)
{
/* Pick up any dynamic changes to the database files */
DtDbLoad();
}
static void InvokeActionCb(Widget w, XtPointer cd, XtPointer cb)
{
char *action;
char *file;
action = XmTextFieldGetString(actionText);
if (action == NULL) return;
if (strlen(action) == 0) {
XtFree(action);
return;
}
file = XmTextFieldGetString(fileText);
InvokeAction(action, file);
XtFree(action);
XtFree(file);
XmTextFieldSetString(actionText, "");
XmTextFieldSetString(fileText, "");
XmProcessTraversal(actionText, XmTRAVERSE_CURRENT);
}
static void InvokeAction(char *action, char *file)
{
DtActionArg *ap = NULL;
int nap = 0;
DtActionInvocationID actionId;
/* If a file was specified, build the file argument list */
printf("%s(%s)\n",action,file);
if (file != NULL && strlen(file) != 0) {
ap = (DtActionArg*) XtCalloc(1, sizeof(DtActionArg));
ap[0].argClass = DtACTION_FILE;
ap[0].u.file.name = file;
nap = 1;
}
/* Invoke the specified action */
actionId = DtActionInvoke(shell,action,ap,nap,NULL,NULL,NULL,True,NULL,NULL);
}

View File

@@ -0,0 +1,14 @@
/* $XConsortium: README /main/2 1996/07/15 13:59:18 drk $ */
This directory contains various examples, modules and files for use with the
Common Desktop Environment Application Builder, specifically:
README - This file
about_box.bil - A module (BIL) file that provides a standard CDE
application "About Box". (This should be connected
to the "About <Application Name>..." item in your
application's Help menu. To use this, start dtbuilder,
load your application (project), bring up the Import Module
item from the File menu, and use the file selection box
that appears to select and Import this file by copy.
(You should then modify the imported version so it matches
your application. See the CDE Style Guide for more details.)

View File

@@ -0,0 +1,289 @@
// $XConsortium: about_box.bil /main/2 1996/11/11 12:00:18 drk $
//
//
// (c) Copyright 1993, 1994 Hewlett-Packard Company
// (c) Copyright 1993, 1994 International Business Machines Corp.
// (c) Copyright 1993, 1994 Sun Microsystems, Inc.
// (c) Copyright 1993, 1994 Novell, Inc.
//
// about_box.bil - Application Builder module file for CDE application
// 'About Box'.
//
:bil-version 1 0
:module about_box
(
:element dialog
(
:type :dialog
:x 417
:y 462
:width 674
:height 333
:bg-color "white"
:label "About CDE Application Builder"
:resizable :true
:visible :false
:children (
ctrl_panel
dialog_button_panel
)
)
:element ctrl_panel
(
:type :container
:container-type :relative
:x 0
:y 0
:width 671
:height 330
:visible :true
:border-frame :etched-in
:north-attachment (:point 0 0)
:south-attachment (:obj dialog -1)
:east-attachment (:obj dialog -1)
:west-attachment (:point 0 0)
:children (
group3
more_button
group4
abbrev_name
)
)
:element group3
(
:type :container
:container-type :group
:active :true
:x 175
:y 50
:width 277
:height 161
:group-type :column
:column-alignment :left
:voffset 25
:vattach_type :obj
:border-frame :none
:north-attachment (:point 0 50)
:west-attachment (:point 0 175)
:children (
group2
os_number
group
)
)
:element group2
(
:type :container
:container-type :group
:active :true
:x 0
:y 0
:width 133
:height 69
:group-type :column
:column-alignment :left
:voffset 3
:vattach_type :obj
:border-frame :none
:north-attachment (:obj group3 0)
:west-attachment (:obj group3 0)
:children (
app_name
version
release_date
)
)
:element app_name
(
:type :label
:x 0
:y 0
:label-type :string
:label "Application Name"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:obj group2 0)
:west-attachment (:obj group2 0)
)
:element version
(
:type :label
:x 0
:y 24
:label-type :string
:label "Version name"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:obj app_name 3)
:west-attachment (:obj-edge app_name 0)
)
:element release_date
(
:type :label
:x 0
:y 48
:label-type :string
:label "Release date"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:obj version 3)
:west-attachment (:obj-edge version 0)
)
:element os_number
(
:type :label
:x 0
:y 94
:label-type :string
:label "Release/OS Number"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:obj group2 25)
:west-attachment (:obj-edge group2 0)
)
:element group
(
:type :container
:container-type :group
:active :true
:x 0
:y 140
:width 277
:height 21
:group-type :column
:column-alignment :left
:voffset 0
:vattach_type :grid-line
:border-frame :none
:north-attachment (:obj os_number 25)
:west-attachment (:obj-edge os_number 0)
:children (
copyright
)
)
:element copyright
(
:type :label
:x 0
:y 0
:label-type :string
:label "Copyright (C) 1993, 1994 My Company"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:obj group 0)
:west-attachment (:obj group 0)
)
:element more_button
(
:type :button
:button-type :push-button
:x 40
:y 245
:label-type :string
:label-alignment :center
:label "More..."
:active :true
:visible :true
:north-attachment (:point 0 245)
:west-attachment (:point 0 40)
)
:element group4
(
:type :container
:container-type :group
:active :true
:x 37
:y 47
:group-type :column
:column-alignment :vcenter
:voffset 10
:vattach_type :obj
:border-frame :etched-out
:north-attachment (:point 0 47)
:west-attachment (:point 0 37)
:children (
app_graphic
)
)
:element app_graphic
(
:type :label
:x 77
:y 0
:label-type :string
:label "Graphic\ngoes\nhere"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:point 0 0)
:west-attachment (:center-grid-line 0 0)
)
:element abbrev_name
(
:type :label
:x 46
:y 104
:label-type :string
:label "App Name"
:label-alignment :center
:active :true
:visible :true
:north-attachment (:obj group4 5)
:west-attachment (:obj-edge group4 -5)
)
:element dialog_button_panel
(
:type :container
:container-type :button-panel
:height 36
:visible :true
:border-frame :none
:children (
ok_btn
help_btn
)
)
:element ok_btn
(
:type :button
:button-type :push-button
:label-type :string
:label-alignment :center
:label "OK"
:active :true
:visible :true
:north-attachment (:grid-line 5 0)
:south-attachment (:grid-line 95 0)
:east-attachment (:grid-line 40 0)
:west-attachment (:grid-line 20 0)
)
:element help_btn
(
:type :button
:button-type :push-button
:label-type :string
:label-alignment :center
:label "Help"
:active :true
:visible :true
:north-attachment (:grid-line 5 0)
:south-attachment (:grid-line 95 0)
:east-attachment (:grid-line 80 0)
:west-attachment (:grid-line 60 0)
)
:connection
(
:from ok_btn
:to dialog
:when :activate
:action-type :builtin
:action :hide
:arg-type :void
)
)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:43:48 drk $
##########################################################################
#
# Makefile for dtcalendar examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = attributes
SOURCES = attributes.c
OBJECTS = attributes.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE =
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lcsa
X11LIBS =
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:44:05 drk $
##########################################################################
#
# Makefile for dtcalendar examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = attributes
SOURCES = attributes.c
OBJECTS = attributes.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE =
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lcsa -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:44:23 drk $
##########################################################################
#
# Makefile for dtcalendar examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = attributes
SOURCES = attributes.c
OBJECTS = attributes.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE =
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lcsa
X11LIBS =
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:44:41 drk $
##########################################################################
#
# Makefile for dtcalendar examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = attributes
SOURCES = attributes.c
OBJECTS = attributes.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE =
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lcsa
X11LIBS =
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,46 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:44:58 drk $
##########################################################################
#
# Makefile for dtcalendar examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = attributes
SOURCES = attributes.c
OBJECTS = attributes.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lcsa
X11LIBS = -lXt -lX11
SYSLIBS = -lnsl
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,15 @@
/* $XConsortium: README /main/2 1996/07/15 13:59:40 drk $ */
This directory contains demonstrations of the csa calendar API
attributes - Examples of using the csa API to inquire about the
attributes of a remote calendar.
The usage for attributes is:
Usage: attributes user@host
example:
attributes al@sanani

View File

@@ -0,0 +1,61 @@
/* $XConsortium: attributes.c /main/3 1995/10/27 10:37:52 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/*
* attributes.c - retrieve calendar attributes
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <sys/param.h>
#include <sys/types.h>
#include <csa/csa.h>
void main(int argc, char **argv)
{
CSA_session_handle cal;
CSA_calendar_user user;
CSA_uint32 num_names;
CSA_attribute_reference *names;
CSA_return_code stat;
int i;
if (argc < 2) {
printf("usage: %s user@host\n", argv[0]);
return;
}
memset((void *)&user, NULL, sizeof(CSA_calendar_user));
user.calendar_address = argv[1];
if ((stat = csa_logon(NULL, &user, NULL, NULL, NULL, &cal, NULL))
!= CSA_SUCCESS)
{
printf("Logon to %s failed, stat = %d\n", argv[1],
stat);
return;
}
if ((stat = csa_list_calendar_attributes(cal, &num_names, &names,
NULL)) == CSA_SUCCESS) {
printf("List calendar attributes:\n");
for (i = 0; i < num_names; i++)
printf("%s\n", names[i]);
csa_free(names);
} else
printf("csa_list_calendar_attributes failed, stat = %d\n",
stat);
(void)csa_logoff(cal, NULL);
}

View File

@@ -0,0 +1,42 @@
!##########################################################################
!# (c) Copyright 1993, 1994 Hewlett-Packard Company
!# (c) Copyright 1993, 1994 International Business Machines Corp.
!# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
!# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
!# Novell, Inc.
!##########################################################################
! DnDDemo app-defaults file
*Dtdnddemo.title: CDE Drag & Drop Demo
*Dtdnddemo*outerRowColumn.orientation: VERTICAL
*Dtdnddemo*outerRowColumn.spacing: 15
*Dtdnddemo*outerRowColumn.marginHeight: 15
*Dtdnddemo*outerRowColumn.marginWidth: 15
*Dtdnddemo*upperRowColumn.orientation: HORIZONTAL
*Dtdnddemo*upperRowColumn.packing: PACK_COLUMN
*Dtdnddemo*upperRowColumn.spacing: 15
*Dtdnddemo*upperRowColumn.marginHeight: 0
*Dtdnddemo*upperRowColumn.marginWidth: 0
*Dtdnddemo*fileDraw.height: 175
*Dtdnddemo*fileDraw.resizePolicy: RESIZE_NONE
*Dtdnddemo*fruitList.listSizePolicy: CONSTANT
*Dtdnddemo*fruitList.scrollBarDisplayPolicy: STATIC
*Dtdnddemo*apptList.listSizePolicy: CONSTANT
*Dtdnddemo*apptList.scrollBarDisplayPolicy: STATIC
*Dtdnddemo*apptList.selectionPolicy: MULTIPLE_SELECT
*Dtdnddemo*textRowColumn.orientation: HORIZONTAL
*Dtdnddemo*textRowColumn.packing: PACK_TIGHT
*Dtdnddemo*textRowColumn*textLabel.labelString: Name:
*Dtdnddemo*textRowColumn*textField.width: 550
*Dtdnddemo*textRowColumn.marginWidth: 0
*Dtdnddemo*dropDraw.height: 100
*Dtdnddemo*dropDraw.resizePolicy: RESIZE_NONE

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:45:18 drk $
##########################################################################
#
# Makefile for dtdnddemo
#
# HP Platform
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
# Novell, Inc.
##########################################################################
PROGRAM = dtdnddemo
SOURCES = demo.c icon.c text.c file.c buff.c
OBJECTS = demo.o icon.o text.o file.o buff.o
APPDEFAULTS = Dtdnddemo
DEFINES = -D_HPUX_SOURCE
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS) $(APPDEFAULTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
rm -f $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:45:35 drk $
##########################################################################
#
# Makefile for dtdnddemo
#
# IBM Platform
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
# Novell, Inc.
##########################################################################
PROGRAM = dtdnddemo
SOURCES = demo.c icon.c text.c file.c buff.c
OBJECTS = demo.o icon.o text.o file.o buff.o
APPDEFAULTS = Dtdnddemo
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS) $(APPDEFAULTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
rm -f $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,65 @@
# $XConsortium: Makefile.simple /main/2 1996/05/13 11:45:52 drk $
##########################################################################
#
# Makefile for dtdnddemo
#
# SUN Platform (debug/purify/sentinel support)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
# Novell, Inc.
##########################################################################
PROGRAM = dtdnddemo
SOURCES = demo.c icon.c text.c file.c buff.c
OBJECTS = demo.o icon.o text.o file.o buff.o
APPDEFAULTS = Dtdnddemo
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xa $(DEFINES) $(CDEBUGFLAGS)
DTHOME = /usr/dt
DTINCLUDE = -I$(DTHOME)/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L$(DTHOME)/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R$(DTHOME)/lib:/usr/openwin/lib
LINKCC = ${CC}
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS) $(APPDEFAULTS)
${LINKCC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)
debug: ${PROGRAM}
debug := CDEBUGFLAGS = -g
debug := DEFINES += -DDEBUG
purify: debug
purify := PURIFY = ${PURIFYHOME}/purify
purify := LINKCC = ${PURIFY} ${CC}
sentinel: debug
sentinel := SENTINEL = ${SE_HOME}/sentinel
sentinel := LINKCC = ${SENTINEL} ${CC}
tags: ${SOURCES} ${HEADERS}
ctags -tw ${SOURCES} ${HEADERS}
.KEEP_STATE:

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:46:10 drk $
##########################################################################
#
# Makefile for dtdnddemo
#
# SUN Platform
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
# Novell, Inc.
##########################################################################
PROGRAM = dtdnddemo
SOURCES = demo.c icon.c text.c file.c buff.c
OBJECTS = demo.o icon.o text.o file.o buff.o
APPDEFAULTS = Dtdnddemo
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xa $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS) $(APPDEFAULTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.usl /main/2 1996/05/13 11:46:28 drk $
##########################################################################
#
# Makefile for dtdnddemo
#
# USL Platform
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
# Novell, Inc.
##########################################################################
PROGRAM = dtdnddemo
SOURCES = demo.c icon.c text.c file.c buff.c
OBJECTS = demo.o icon.o text.o file.o buff.o
APPDEFAULTS = Dtdnddemo
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS) $(APPDEFAULTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
rm -f $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,46 @@
# $XConsortium: Makefile.uxp /main/3 1996/05/13 11:46:45 drk $
##########################################################################
#
# Makefile for dtdnddemo
#
# UXP Platform
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
# Novell, Inc.
##########################################################################
PROGRAM = dtdnddemo
SOURCES = demo.c icon.c text.c file.c buff.c
OBJECTS = demo.o icon.o text.o file.o buff.o
APPDEFAULTS = Dtdnddemo
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS) $(APPDEFAULTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
rm -f $(PROGRAM) $(OBJECTS)

17
cde/examples/dtdnd/README Normal file
View File

@@ -0,0 +1,17 @@
/* $XConsortium: README /main/2 1996/07/15 14:00:00 drk $ */
This directory contains demonstrations of the Dnd Drag and Drop API
dtdnddemo - The Drag-n-Drop Demo program demonstrates the
Dt DnD functions in the Desktop Services library:
DtDndDragStart.3x
DtDndDropRegister.3x
The demo consists of a row of three different
sources for text, filename and app-named data drags.
It also has a type-in field that can accept either
text or filename drops. Finally there is a data
area that accepts filename or data drops.

633
cde/examples/dtdnd/buff.c Normal file
View File

@@ -0,0 +1,633 @@
/* $TOG: buff.c /main/5 1999/07/20 14:48:23 mgreess $ */
/*****************************************************************************
*****************************************************************************
**
** File: buff.c
**
** Description: Buffer transfer functions for the CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#include <time.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/List.h>
#include <Dt/Dt.h>
#include <Dt/Dnd.h>
#include "icon.h"
#include "file.h"
#include "demo.h"
#include "buff.h"
extern Widget topLevel;
/*************************************************************************
*
* Data Structures & Private Declarations For Appointment Buffers
*
**************************************************************************/
/*
* Appointment structure used to store appointments internally.
*/
typedef struct _Appointment {
char *date;
char *start;
char *end;
char *what;
} Appointment;
/*
* List of appointments which always appear to be for the current date.
*/
char today[9]; /* initialized in apptCreateList() */
Appointment todaysApptList[] = {
#ifdef TEST_APPT_NAMES
{ today, "", "", "Staff Meeting" }, /* no name */
{ today, " 9:30am", "10:00am", "Will's Party1" }, /* duplicate names */
{ today, " 9:30am", "10:00am", "Will's Party2" },
#else
{ today, " 9:00am", " 9:30am", "Staff Meeting" },
{ today, " 9:30am", "10:00am", "Will's Party" },
#endif
{ today, "10:00am", "10:30am", "Conference Call" },
{ today, "10:30am", "11:30am", "Work on Mail" },
{ today, "11:00am", "11:30pm", "B'fast w/ Robert" },
{ today, " 1:30pm", " 2:30pm", "Design Meeting" },
{ today, " 3:00pm", " 4:00pm", "Communications" },
{ today, " 4:00pm", " 4:30pm", "Pick up Dogs" },
{ today, " 5:00pm", " 6:30pm", "Beer Bust" },
{ today, " 7:00pm", " 9:00pm", "Dinner - Stuart" },
{ NULL, NULL, NULL, NULL }
};
/*
* CDE appointment format used to transfer the appointments via drag & drop.
*/
char *apptFormat =
" ** Calendar Appointment **\n\
\n\
Date: %s\n\
Start: %s\n\
End: %s\n\
What: %s\n";
/*
* Private Appointment Buffer Function Declarations
*/
static void apptConvertCallback(Widget, XtPointer, XtPointer);
static int apptCreateList(XmString**);
static void apptDestroyList(XmString*,int);
static Appointment* apptFromListEntry(XmString);
static char* apptGetLabel(char*);
/*************************************************************************
*
* Appointment Drag & Drop
*
**************************************************************************/
/*
* apptConvertCallback
*
* Fills in buffer structure with calendar appointment string based on which
* appointments are selected in the scrolled list when the drag is started.
* ihen no appointments are selected, the appointment under the pointer is
* used. Supply a label for the calendar appointment based on the contents
* of the appointment.
*/
static void
apptConvertCallback(
Widget dragContext,
XtPointer clientData,
XtPointer callData)
{
DtDndConvertCallbackStruct *convertInfo =
(DtDndConvertCallbackStruct *) callData;
DtDndBuffer *buffers = convertInfo->dragData->data.buffers;
Widget apptList = (Widget)clientData;
int selectedPos, ii,
selectedItemCount;
XmStringTable selectedItems;
char apptString[1024];
String labelString;
Appointment *appt;
if (convertInfo == NULL) {
return;
}
/*
* Verify the validity of the callback reason
*/
if (convertInfo->dragData->protocol != DtDND_BUFFER_TRANSFER ||
(convertInfo->reason != DtCR_DND_CONVERT_DATA &&
convertInfo->reason != DtCR_DND_CONVERT_DELETE)) {
return;
}
/*
* Get selected items from the list
*/
XtVaGetValues(apptList,
XmNuserData, &selectedPos,
XmNselectedItemCount, &selectedItemCount,
XmNselectedItems, &selectedItems,
NULL);
for (ii = 0; ii < convertInfo->dragData->numItems; ii++) {
/*
* Get the actual appointment(s)
*/
if (selectedItemCount == 0) {
appt = &todaysApptList[selectedPos-1+ii];
} else {
appt = apptFromListEntry(selectedItems[ii]);
}
sprintf(apptString, apptFormat,
appt->date, appt->start, appt->end, appt->what);
/*
* Supply the appointment(s) for transfer
*/
if (convertInfo->reason == DtCR_DND_CONVERT_DATA) {
/* Copy the appointment into the buffer for transfer */
buffers[ii].bp = XtNewString(apptString);
buffers[ii].size = strlen(buffers[ii].bp);
/* Supply the name for the appointment */
labelString = apptGetLabel(apptString);
if (labelString == NULL) {
buffers[ii].name = (char *)NULL;
} else {
buffers[ii].name = XtNewString(labelString);
XtFree(labelString);
}
/*
* Delete the moved appointment(s)
*/
} else if (convertInfo->reason == DtCR_DND_CONVERT_DELETE) {
printf("Delete appointment for %s\n", appt->what);
}
}
}
/*
* apptDragFinishCallback
*
* Free buffer data/names allocated in apptConvertCallback()
*/
void
apptDragFinishCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
DtDndDragFinishCallbackStruct *dropFinishInfo =
(DtDndDragFinishCallbackStruct *)callData;
DtDndContext *dragData = dropFinishInfo->dragData;
int ii;
for (ii = 0; ii < dragData->numItems; ii++) {
XtFree(dragData->data.buffers[ii].bp);
if (dragData->data.buffers[ii].name != NULL)
XtFree(dragData->data.buffers[ii].name);
}
}
/*
* apptTransferCallback
*
* Handles the transfer of an appointment to the draw area drop site.
* Adds the appropriate icon to the list of icons on the draw area.
*/
void
apptTransferCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
DtDndTransferCallbackStruct *transferInfo =
(DtDndTransferCallbackStruct*) callData;
DtDndBuffer *buffers;
IconInfo *iconList, *iconPtr;
char *name;
char *filename;
int ii;
if (transferInfo == NULL) {
return;
}
/*
* Verify the validity of the callback reason.
*/
if (transferInfo->dropData->protocol != DtDND_BUFFER_TRANSFER ||
transferInfo->reason != DtCR_DND_TRANSFER_DATA) {
return;
}
/*
* Use abbreviated method of refering to the data buffers.
*/
if (transferInfo != NULL && transferInfo->dropData != NULL) {
buffers = transferInfo->dropData->data.buffers;
} else {
return;
}
/*
* Process each item being transfered.
*/
XtVaGetValues(widget, XmNuserData, &iconList, NULL);
for (ii = 0; ii < transferInfo->dropData->numItems; ii++) {
/*
* Check format of buffer
*/
/*
* Transfer the buffer data. Here there is no actual transfer
* taking place. Only the icons representing the appointments
* are created to indicate the transfer.
*/
name = buffers[ii].name;
if (name == NULL)
name = "unnamed";
/* Create file from buffer */
filename = fileStoreBuffer(buffers[ii].name,
buffers[ii].bp, buffers[ii].size);
printf("Stored buffer into '%s'\n", filename);
XtFree(filename);
/* Create icon */
iconPtr = IconNew();
IconInitialize(widget, iconPtr,
transferInfo->x + ii * 10,
transferInfo->y + ii * 10,
buffers[ii].bp, buffers[ii].size, name, IconByData);
/* Add to icon list on drop site */
iconPtr->next = iconList;
if (iconList != NULL) {
iconList->prev = iconPtr;
}
iconList = iconPtr;
XtVaSetValues(widget, XmNuserData, iconList, NULL);
}
}
/*
* apptDragSetup
*
* Prepares the appointment list to source drags of appointments with button 1.
*/
void apptDragSetup(Widget apptDragSource)
{
static char translations[] = "\
~c ~s ~m ~a <Btn1Down>:\
demoProcessPress(ListBeginSelect,apptDragStart)\n\
c ~s ~m ~a <Btn1Down>:\
demoProcessPress(ListBeginToggle,apptDragStart)";
static char btn2_translations[] = "\
~c ~s ~m ~a <Btn2Down>:\
demoProcessPress(ListBeginSelect,apptDragStart)\n\
c ~s ~m ~a <Btn2Down>:\
demoProcessPress(ListBeginToggle,apptDragStart)\n\
<Btn2Motion>:ListButtonMotion()\n\
~c ~s ~m ~a <Btn2Up>:ListEndSelect()\n\
c ~s ~m ~a <Btn2Up>:ListEndToggle()";
static XtActionsRec actionTable[] =
{
{"apptDragStart", (XtActionProc) &apptDragStart},
{"demoProcessPress", (XtActionProc) &demoProcessPress}
};
int btn1_transfer = 0;
XtTranslations new_translations;
XtAppAddActions(
demoAppContext,
actionTable,
sizeof(actionTable)/sizeof(actionTable[0]));
new_translations = XtParseTranslationTable(translations);
XtOverrideTranslations(apptDragSource, new_translations);
XtVaGetValues(
(Widget) XmGetXmDisplay(XtDisplayOfObject(apptDragSource)),
"enableBtn1Transfer", &btn1_transfer,
NULL);
if (btn1_transfer != True)
{
new_translations = XtParseTranslationTable(btn2_translations);
XtOverrideTranslations(apptDragSource, new_translations);
}
#if 0
XtAddEventHandler(apptDragSource, Button1MotionMask, False,
(XtEventHandler)demoDragMotionHandler,
(XtPointer)DtDND_BUFFER_TRANSFER);
#endif
}
/*
* apptDropSetup
*
* Such a function is not needed since the demoDropSetup in demo.c registers
* the draw area as a drop site for drops of buffers such as appointments.
*/
/*
* apptDragStart
*
* Initiates a drag of an appointment from the appointment list provided
* the pointer is over an appointment in the list.
*/
void
apptDragStart(
Widget widget,
XEvent *event)
{
static XtCallbackRec convertCBRec[] = { {apptConvertCallback, NULL},
{NULL, NULL} };
static XtCallbackRec dragFinishCBRec[] =
{ {demoDragFinishCallback, NULL},
{apptDragFinishCallback, NULL},
{NULL, NULL} };
static IconInfo *iconPtr = NULL;
Widget dragIcon;
Display *display = XtDisplay(widget);
int itemCount,
selectedPos,
selectedItemCount;
char apptString[1024];
convertCBRec[0].closure = (XtPointer)widget;
/*
* Get list of selected items from the scrolled list of appointments
*/
XtVaGetValues(widget,
XmNitemCount, &itemCount,
XmNselectedItemCount, &selectedItemCount,
NULL);
/*
* Find out which item the pointer was over when the drag began
*/
selectedPos = XmListYToPos(widget, event->xmotion.y);
if (selectedPos == 0 || selectedPos > itemCount) {
return;
}
XtVaSetValues(widget, XmNuserData, selectedPos, NULL);
/*
* Copy the appointment information into an appointment string
*/
sprintf(apptString, apptFormat,
todaysApptList[1].date, todaysApptList[1].start,
todaysApptList[1].end, todaysApptList[1].what);
/*
* Create drag icon for appointment buffer drag
*/
if (iconPtr == NULL) {
iconPtr = IconNew();
IconInitialize(widget, iconPtr, 0, 0,
apptString, strlen(apptString), NULL, IconByData);
}
if (iconPtr->dragIcon == NULL) {
iconPtr->dragIcon = DtDndCreateSourceIcon(widget,
iconPtr->bitmap, iconPtr->mask);
}
if (selectedItemCount > 1) {
dragIcon = NULL;
itemCount = selectedItemCount;
} else {
dragIcon = iconPtr->dragIcon;
itemCount = 1;
}
/*
* Start the drag
*/
if (DtDndVaDragStart(widget, event, DtDND_BUFFER_TRANSFER, itemCount,
XmDROP_COPY,
convertCBRec, dragFinishCBRec,
DtNsourceIcon, dragIcon,
DtNbufferIsText, True,
NULL)
== NULL) {
printf("DragStart returned NULL.\n");
}
}
/*************************************************************************
*
* Appointment Creation, Initialization & Destruction
*
*************************************************************************/
/*
* apptCreateDragSource
*
* Create a scrolling list filled with appointments.
*/
Widget
apptCreateDragSource(
Widget parent)
{
Widget apptList;
XmString *apptListItems;
int apptCount;
apptCount = apptCreateList(&apptListItems);
apptList = XtVaCreateManagedWidget("apptList",
xmListWidgetClass, parent,
/*
* Uncomment the line specifying the selection policy to
* enable multiple buffer transfers from the scrolled list
* of appointments. WARNING: There is a bug in the interaction
* of the scrolled list and Drag and Drop which causes items
* in the scrolled list which are selected to appear unselected
* and vice versa.
*/
/* XmNselectionPolicy, XmMULTIPLE_SELECT, */
XmNitems, apptListItems,
XmNitemCount, apptCount,
NULL);
apptDestroyList(apptListItems, apptCount);
return apptList;
}
/*
* apptCreateDropSite
*
* Such a function is not needed since the drop site is the draw area which
* is created in demoCreateDropSite() in demo.c
*/
/*
* apptCreateList
*
* Creates a list of XmStrings with appointment data in them.
*/
static int
apptCreateList(
XmString **appts)
{
int ii, apptCount;
char tmpStr[256];
time_t now;
struct tm *tm;
now = time(&now);
tm = localtime(&now);
sprintf(today, "%2d/%2d/%2d", tm->tm_mon+1, tm->tm_mday, tm->tm_year);
for (ii = 0; todaysApptList[ii].date; ii++);
apptCount = ii;
*appts = (XmString *) XtMalloc(sizeof(XmString) * apptCount);
for (ii = 0; todaysApptList[ii].date; ii++) {
sprintf(tmpStr, "%s %s", todaysApptList[ii].start,
todaysApptList[ii].what);
(*appts)[ii] = XmStringCreate(tmpStr, XmFONTLIST_DEFAULT_TAG);
}
return apptCount;
}
/*
* apptDestroyList
*
* Destroys a list of XmStrings with appointment data in them.
*/
static void
apptDestroyList(
XmString *appts,
int apptCount)
{
int ii;
for (ii = 0; ii < apptCount; ii++) {
XmStringFree(appts[ii]);
}
XtFree((char *)appts);
}
/*************************************************************************
*
* Appointment Utility Functions
*
*************************************************************************/
/*
* apptFromListEntry
*
* Returns the full appointment based on the text of the appointment as
* given in the text entry from the scrolled list of appointments.
*/
static Appointment*
apptFromListEntry(
XmString listEntry)
{
int ii;
char *entryText,
*string;
/*
* Get text string from XmString for use in comparisons
*/
entryText = XmStringUnparse(listEntry, NULL, XmCHARSET_TEXT,
XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
for (ii = 0; todaysApptList[ii].what != NULL; ii++) {
string = strstr(entryText, todaysApptList[ii].what);
if (string != NULL) {
XtFree(entryText);
return(&todaysApptList[ii]);
}
}
XtFree(entryText);
return NULL;
}
/*
* apptGetLabel
*
* Creates a label for an appointment icon given an appointment.
*/
static char*
apptGetLabel(
char *appt)
{
char start[128];
int count;
if (appt == NULL) {
return NULL;
}
appt = strstr(appt, "Start:");
count = sscanf(appt, "Start:%*[ \t]%[^\n]", start);
if (count != 1) {
return NULL;
}
return XtNewString(start);
}

26
cde/examples/dtdnd/buff.h Normal file
View File

@@ -0,0 +1,26 @@
/* $XConsortium: buff.h /main/3 1995/10/27 10:38:22 rswiston $ */
/*****************************************************************************
*****************************************************************************
**
** File: buff.h
**
** Description: Header for buffer transfer portion of CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
/*
* Public Appointment Buffer Transfer Function Declarations
*/
Widget apptCreateDragSource(Widget);
void apptDragSetup(Widget);
void apptDragStart(Widget, XEvent*);
void apptTransferCallback(Widget, XtPointer, XtPointer);

577
cde/examples/dtdnd/demo.c Normal file
View File

@@ -0,0 +1,577 @@
/* $TOG: demo.c /main/5 1999/07/20 14:48:53 mgreess $ */
/*****************************************************************************
*****************************************************************************
**
** File: demo.c
**
** Description: The Drag & Drop Demo program demonstrates the
** CDE DnD functions in the Desktop Services library:
**
** DtDndDragStart.3x
** DtDndDropRegister.3x
** DtDndCreateSourceIcon.3x
**
** The demo consists of a row of three different sources
** for text, filename and appointment buffer drags.
** It also has a text field that can accept either
** text or filename drops. Finally there is a data
** area that accepts filename or buffer drops.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/DrawingA.h>
#include <Xm/Frame.h>
#include <Xm/List.h>
#include <Xm/MainW.h>
#include <Xm/MwmUtil.h>
#include <Xm/RowColumn.h>
#include <Xm/Separator.h>
#include <Xm/DragDrop.h>
#include <Xm/Screen.h>
#include <Dt/Dt.h>
#include <Dt/Dnd.h>
#include "icon.h"
#include "text.h"
#include "file.h"
#include "buff.h"
/*************************************************************************
*
* Data Structures & Declarations For Drag & Drop Demo
*
*************************************************************************/
/*
* The Drag Threshold is the distance, measured in pixels, over which the
* pointer must travel while the BSelect button (first mouse button) is held
* down in order to start a drag. CDE defines this to be 10 pixels.
*/
#define DRAG_THRESHOLD 10
/*
* Absolute value macro
*/
#ifndef ABS
#define ABS(x) (((x) > 0) ? (x) : (-(x)))
#endif
/*
* Global variables
*/
Widget demoTopLevel;
XtAppContext demoAppContext;
Boolean demoDoingDrag = False;
/*
* Private Drag & Drop Demo Function Declarations
*/
void demoTransferCallback(Widget, XtPointer, XtPointer);
/*************************************************************************
*
* General-Purpose Drag & Drop Functions
*
*************************************************************************/
/*
* demoDragFinishCallback
*
* Resets drag state to indicate the drag is over.
*/
void
demoDragFinishCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
demoDoingDrag = False;
}
/*
* demoDragMotionHandler
*
* Determine if the pointer has moved beyond the drag threshold while button 1
* was being held down.
*/
void
demoDragMotionHandler(
Widget dragInitiator,
XtPointer clientData,
XEvent *event)
{
static int initialX = -1;
static int initialY = -1;
int diffX, diffY;
long dragProtocol = (long)clientData;
if (!demoDoingDrag) {
/*
* If the drag is just starting, set initial button down coords
*/
if (initialX == -1 && initialY == -1) {
initialX = event->xmotion.x;
initialY = event->xmotion.y;
}
/*
* Find out how far pointer has moved since button press
*/
diffX = initialX - event->xmotion.x;
diffY = initialY - event->xmotion.y;
if ((ABS(diffX) >= DRAG_THRESHOLD) ||
(ABS(diffY) >= DRAG_THRESHOLD)) {
demoDoingDrag = True;
switch (dragProtocol) {
case DtDND_TEXT_TRANSFER:
textDragStart(dragInitiator, event);
break;
case DtDND_FILENAME_TRANSFER:
fileCheckForDrag(dragInitiator, event,
initialX, initialY);
break;
case DtDND_BUFFER_TRANSFER:
apptDragStart(dragInitiator, event);
break;
}
initialX = -1;
initialY = -1;
}
}
}
/*
* demoLookForButton
*/
/* ARGSUSED */
static Bool demoLookForButton(Display *d, XEvent *event, XPointer arg)
{
#define DAMPING 5
#define ABS_DELTA(x1, x2) (x1 < x2 ? x2 - x1 : x1 - x2)
if( event->type == MotionNotify)
{
XEvent * press = (XEvent *) arg;
if (ABS_DELTA(press->xbutton.x_root, event->xmotion.x_root) > DAMPING ||
ABS_DELTA(press->xbutton.y_root, event->xmotion.y_root) > DAMPING)
return(True);
}
else if (event->type == ButtonRelease) return(True);
return(False);
}
/*
* demoProcessPress
*/
void demoProcessPress(Widget w, XEvent *event, String *parms, Cardinal *nparms)
{
#define SELECTION_ACTION 0
#define TRANSFER_ACTION 1
int i, action, cur_item;
int *selected_positions, nselected_positions;
/*
* This action happens when Button1 is pressed and the Selection
* and Transfer are integrated on Button1. It is passed two
* parameters: the action to call when the event is a selection,
* and the action to call when the event is a transfer.
*/
if (*nparms != 2 || !XmIsList(w)) return;
action = SELECTION_ACTION;
cur_item = XmListYToPos(w, event->xbutton.y);
if (cur_item > 0)
{
XtVaGetValues(w,
XmNselectedPositions, &selected_positions,
XmNselectedPositionCount, &nselected_positions,
NULL);
for (i=0; i<nselected_positions; i++)
{
if (cur_item == selected_positions[i])
{
/*
* The determination of whether this is a transfer drag
* cannot be made until a Motion event comes in. It is
* not a drag as soon as a ButtonUp event happens.
*/
XEvent new_event;
XPeekIfEvent(
XtDisplay(w),
&new_event,
&demoLookForButton,
(XPointer) event);
switch (new_event.type)
{
case MotionNotify:
action = TRANSFER_ACTION;
break;
case ButtonRelease:
action = SELECTION_ACTION;
break;
}
break;
}
}
}
XtCallActionProc(w, parms[action], event, parms, *nparms);
}
/*
* demoDrawAnimateCallback
*
* Expands the icon melted into the draw area by Motif.
*/
void
demoDrawAnimateCallback(
Widget dragContext, /* WARNING: This is being destroyed. */
XtPointer clientData,
XtPointer callData)
{
DtDndDropAnimateCallbackStruct *animateInfo =
(DtDndDropAnimateCallbackStruct *) callData;
Widget dropDraw = (Widget)clientData;
Display *display = XtDisplayOfObject(dropDraw);
Screen *screen = XtScreen(dropDraw);
Window window = XtWindow(dropDraw);
int expandWidth, expandHeight,
sourceX, sourceY;
static GC graphicsContext = NULL;
XGCValues gcValues;
IconInfo *iconPtr;
/*
* Create graphics context if it doesn't yet exist
*/
if (graphicsContext == NULL) {
gcValues.foreground = BlackPixelOfScreen(screen);
gcValues.background = WhitePixelOfScreen(screen);
graphicsContext = XCreateGC(display, window,
GCForeground | GCBackground, &gcValues);
}
/*
* Get the dragged icon from the dropDraw area
*/
XtVaGetValues(dropDraw, XmNuserData, &iconPtr, NULL);
if (iconPtr == NULL) {
return;
}
/*
* Set clip mask and coordinates for this icon in the graphics context
*/
gcValues.clip_mask = iconPtr->mask;
gcValues.clip_x_origin = iconPtr->icon.x;
gcValues.clip_y_origin = iconPtr->icon.y;
XChangeGC(display, graphicsContext,
GCClipMask | GCClipXOrigin | GCClipYOrigin,
&gcValues);
/*
* Reconstitute the icon after Motif melts it
*/
for (expandWidth = expandHeight = 0;
expandWidth < (int)iconPtr->icon.width &&
expandHeight < (int)iconPtr->icon.height;
expandWidth += 2, expandHeight += 2) {
sourceX = ((int)iconPtr->icon.width - expandWidth)/2;
sourceY = ((int)iconPtr->icon.height - expandHeight)/2;
XCopyPlane(display, iconPtr->bitmap, window, graphicsContext,
sourceX, sourceY, expandWidth, expandHeight,
iconPtr->icon.x + sourceX, iconPtr->icon.y + sourceY,
1L);
XmeMicroSleep(25000L);
XFlush(display);
}
}
/*
* demoDrawExposeCallback
*
* Draws all the icons associated with the drawing area.
*/
void
demoDrawExposeCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
IconInfo *iconPtr;
XtVaGetValues(widget, XmNuserData, &iconPtr, NULL);
while (iconPtr != NULL) {
IconDraw(widget, iconPtr);
iconPtr = iconPtr->next;
}
}
/*
* demoDropSetup
*
* Registers draw area to accept drops of files or buffers such as appointments.
*/
void
demoDropSetup(
Widget dropDraw)
{
static XtCallbackRec transferCBRec[] = { {demoTransferCallback, NULL},
{NULL, NULL} };
static XtCallbackRec animateCBRec[] = { {demoDrawAnimateCallback, NULL},
{NULL, NULL} };
animateCBRec[0].closure = (XtPointer)dropDraw;
DtDndVaDropRegister(dropDraw,
DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER,
XmDROP_COPY | XmDROP_MOVE, transferCBRec,
DtNdropAnimateCallback, animateCBRec,
DtNtextIsBuffer, True,
DtNpreserveRegistration, False,
NULL);
}
/*
* demoTransferCallback
*
* Called when something is dropped on the drawing area drop site. If the
* transfer protocol is DtDND_FILENAME_TRANSFER or DtDND_BUFFER_TRANSFER
* the fileTransferCallback and apptTransferCallback are called respectively.
*/
void
demoTransferCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
DtDndTransferCallbackStruct *transferInfo =
(DtDndTransferCallbackStruct *) callData;
if (transferInfo == NULL) {
return;
}
switch (transferInfo->dropData->protocol) {
case DtDND_FILENAME_TRANSFER:
fileTransferCallback(widget, clientData, callData);
break;
case DtDND_BUFFER_TRANSFER:
apptTransferCallback(widget, clientData, callData);
break;
}
}
/*************************************************************************
*
* Demo Client Creation
*
*************************************************************************/
/*
* Fallback resources are used if app-defaults file is not found
*/
String fallbackResources[] = {
"title: CDE Drag & Drop Demo",
"*outerRowColumn.orientation: VERTICAL",
"*outerRowColumn.spacing: 15",
"*outerRowColumn.marginHeight: 15",
"*outerRowColumn.marginWidth: 15",
"*upperRowColumn.orientation: HORIZONTAL",
"*upperRowColumn.packing: PACK_COLUMN",
"*upperRowColumn.spacing: 15",
"*upperRowColumn.marginHeight: 0",
"*upperRowColumn.marginWidth: 0",
"*fileDraw.height: 175",
"*fileDraw.resizePolicy: RESIZE_NONE",
"*fruitList.listSizePolicy: CONSTANT",
"*fruitList.scrollBarDisplayPolicy: STATIC",
"*fruitList.selectionPolicy: MULTIPLE_SELECT",
"*apptList.listSizePolicy: CONSTANT",
"*apptList.scrollBarDisplayPolicy: STATIC",
"*apptList.selectionPolicy: MULTIPLE_SELECT",
"*textRowColumn.orientation: HORIZONTAL",
"*textRowColumn.packing: PACK_TIGHT",
"*textRowColumn*textLabel.labelString: Name:",
"*textRowColumn*textField.width: 550",
"*textRowColumn.marginWidth: 0",
"*dropDraw.height: 100",
"*dropDraw.resizePolicy: RESIZE_NONE",
NULL
};
/*
* demoCreateDropSite
*
* Creates the drawing area at the bottom of the demo which is used as a drop
* site for files and appointments.
*/
Widget
demoCreateDropSite(
Widget parent)
{
Widget dropFrame,
dropDraw;
dropFrame = XtVaCreateManagedWidget("dropFrame",
xmFrameWidgetClass, parent,
NULL);
dropDraw = XtVaCreateManagedWidget("dropDraw",
xmDrawingAreaWidgetClass, dropFrame,
NULL);
XtAddCallback(dropDraw,
XmNexposeCallback, demoDrawExposeCallback,
NULL);
return dropDraw;
}
/*
* main
*
* Create widgets for the demo program. Call protocol-specific functions
* to initialize the drag sources and drop sites.
*/
void
main(
int argc,
String *argv)
{
Widget outerRowColumn,
upperRowColumn,
textDragSource,
fileDragSource,
apptDragSource,
separator,
textDropSite,
drawDropSite;
/*
* Create basic widgets and layout widgets
*/
XtSetLanguageProc(NULL, NULL, NULL);
demoTopLevel = XtAppInitialize(&demoAppContext, "Dtdnddemo",
(XrmOptionDescList)NULL, 0, &argc, argv,
fallbackResources, (ArgList)NULL, 0);
DtAppInitialize(demoAppContext, XtDisplay(demoTopLevel),
demoTopLevel, argv[0], "Dtdnddemo");
outerRowColumn = XtVaCreateManagedWidget("outerRowColumn",
xmRowColumnWidgetClass, demoTopLevel,
NULL);
upperRowColumn = XtVaCreateManagedWidget("upperRowColumn",
xmRowColumnWidgetClass, outerRowColumn,
NULL);
/*
* Create the drag sources
*/
textDragSource = textCreateDragSource(upperRowColumn);
fileDragSource = fileCreateDragSource(upperRowColumn);
apptDragSource = apptCreateDragSource(upperRowColumn);
/*
* Create a line separating the drag sources from the drop sites
*/
separator = XtVaCreateManagedWidget("separator",
xmSeparatorWidgetClass, outerRowColumn,
NULL);
/*
* Create the drop sites
*/
textDropSite = textCreateDropSite(outerRowColumn);
drawDropSite = demoCreateDropSite(outerRowColumn);
/*
* Realize the widget tree
*/
XtRealizeWidget(demoTopLevel);
/*
* Load the data typing database which is used to get icons
*/
DtDtsLoadDataTypes();
/*
* Set up the drag sources
*/
textDragSetup(textDragSource);
fileDragSetup(fileDragSource);
apptDragSetup(apptDragSource);
/*
* Set up the drop sites
*/
textDropSetup(textDropSite);
demoDropSetup(drawDropSite);
/*
* Start the event processing loop
*/
XtAppMainLoop(demoAppContext);
}

28
cde/examples/dtdnd/demo.h Normal file
View File

@@ -0,0 +1,28 @@
/* $TOG: demo.h /main/4 1999/07/20 14:49:21 mgreess $ */
/*****************************************************************************
*****************************************************************************
**
** File: demo.h
**
** Description: Header for foundation of CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
/*
* Public General-Purpose Demo Function Declarations
*/
extern void demoDragFinishCallback(Widget, XtPointer, XtPointer);
extern void demoDragMotionHandler(Widget, XtPointer, XtPointer, XEvent*);
extern void demoProcessPress(Widget, XEvent*, String*, Cardinal*);
extern void demoDrawExposeCallback(Widget, XtPointer, XtPointer);
extern XtAppContext demoAppContext;
extern Widget demoTopLevel;

759
cde/examples/dtdnd/file.c Normal file
View File

@@ -0,0 +1,759 @@
/* $TOG: file.c /main/4 1999/07/20 14:49:49 mgreess $ */
/*****************************************************************************
*****************************************************************************
**
** File: file.c
**
** Description: File transfer functions for the CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/DrawingA.h>
#include <Xm/Frame.h>
#include <Xm/Protocols.h>
#include <Dt/Dt.h>
#include <Dt/Dnd.h>
#include "icon.h"
#include "demo.h"
#include "file.h"
/*************************************************************************
*
* Data Structures & Private Declarations For Appointment Buffers
*
**************************************************************************/
/*
* Specification of drag or drop directory
*/
typedef enum {
DragDirectory,
DropDirectory
} DragOrDrop;
/*
* File names and contents. The contents are the minimal required by the
* data typing service to correctly type the file via content-based typing.
* The file names are appropriate to the type of the contents as well. This
* demo uses content-based typing to get the appropriate icons for these files.
*/
#define FILE_NAME_CSH "runit"
#define FILE_DATA_CSH "#! /bin/csh"
#define FILE_NAME_PS "map.ps"
#define FILE_DATA_PS "%!PS-Adobe-2.0"
#define FILE_NAME_TEXT "tasks"
#define FILE_DATA_TEXT "Nothing"
/*
* Private file function declarations
*/
static XtActionProc fileCheckForDragProc(Widget, XEvent*, String*,
Cardinal*);
static void fileConvertCallback(Widget, XtPointer, XtPointer);
static void fileCreateDirectory(char*);
static void fileCreateFile(char*, char*, char*);
static void fileCreateFiles(Widget);
static void fileDragStart(Widget, XEvent*, IconInfo*, int);
static char* fileGetContents(char*);
static char* fileGetDemoDirectory();
static char* fileGetDirectoryName(DragOrDrop);
static void fileRemoveDirectory(char*);
static void fileShutdown(Widget, XtPointer, XtPointer);
/*************************************************************************
*
* File Name Drag & Drop
*
**************************************************************************/
/*
* fileConvertCallback
*
* When converting the data, fills in the file structure with the name(s) of
* the file(s). When converting DELETE, removes the given file(s) and icon(s)
* from the filesystem and drawing area respectively.
*/
static void
fileConvertCallback(
Widget dragContext,
XtPointer clientData,
XtPointer callData)
{
DtDndConvertCallbackStruct *convertInfo =
(DtDndConvertCallbackStruct *) callData;
IconInfo *iconArray = (IconInfo *) clientData;
char filePath[MAXPATHLEN + 1],
command[MAXPATHLEN + 4];
int ii;
Widget fileDraw;
if (convertInfo == NULL) {
return;
}
/*
* Verify the protocol and callback reason
*/
if (convertInfo->dragData->protocol != DtDND_FILENAME_TRANSFER ||
(convertInfo->reason != DtCR_DND_CONVERT_DATA &&
convertInfo->reason != DtCR_DND_CONVERT_DELETE)) {
return;
}
switch (convertInfo->reason) {
case DtCR_DND_CONVERT_DATA:
/*
* Supply the file names of the dragged files
*/
for (ii = 0; ii < convertInfo->dragData->numItems; ii++) {
sprintf(filePath, "%s/%s",
fileGetDirectoryName(DragDirectory),
iconArray[ii].name);
convertInfo->dragData->data.files[ii] =
XtNewString(filePath);
}
break;
case DtCR_DND_CONVERT_DELETE:
/*
* Delete dragged files as second part of a move operation
*/
fileDraw = XtNameToWidget(demoTopLevel, "*fileDraw");
for (ii = 0; ii < convertInfo->dragData->numItems; ii++) {
/* Remove file(s) */
sprintf(filePath, "%s/%s",
fileGetDirectoryName(DragDirectory),
iconArray[ii].name);
sprintf(command, "rm %s", filePath);
if (system(command) != 0) {
printf("Unable to remove file \"%s\".\n",
filePath);
}
/* Remove icon(s) */
if (fileDraw != NULL) {
IconDelete(fileDraw, &iconArray[ii]);
XClearWindow(XtDisplayOfObject(fileDraw),
(XtWindow(fileDraw)));
XtCallCallbacks(fileDraw, XmNexposeCallback,
NULL);
}
}
break;
}
}
/*
* fileDragFinishCallback
*
* Free the file names allocated in fileConvertCallback()
*/
void
fileDragFinishCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
DtDndDragFinishCallbackStruct *dragFinishInfo =
(DtDndDragFinishCallbackStruct *)callData;
DtDndContext *dragData = dragFinishInfo->dragData;
int ii;
for (ii = 0; ii < dragData->numItems; ii++) {
XtFree(dragData->data.files[ii]);
}
}
/*
* fileTransferCallback
*
* Handles the transfer of a file or appointment to the draw area.
* Adds the appropriate icon to the list of icons on the draw area.
*/
void
fileTransferCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
DtDndTransferCallbackStruct *transferInfo =
(DtDndTransferCallbackStruct *) callData;
IconInfo *iconList = NULL, *iconPtr;
char *filePath, *name, *contents,
command[2*MAXPATHLEN + 5];
int ii;
if (transferInfo == NULL) {
return;
}
/*
* Verify the protocol and callback reasons
*/
if (transferInfo->dropData->protocol != DtDND_FILENAME_TRANSFER ||
transferInfo->reason != DtCR_DND_TRANSFER_DATA) {
return;
}
if (widget != NULL) {
XtVaGetValues(widget, XmNuserData, &iconList, NULL);
}
/*
* Copy the dropped file(s) to the drop directory
*/
for (ii = 0; ii < transferInfo->dropData->numItems; ii++) {
/* Copy the file(s) */
filePath = transferInfo->dropData->data.files[ii];
contents = fileGetContents(filePath);
if ((name = strrchr(filePath,'/')) == NULL) {
name = filePath;
} else {
name++;
}
sprintf(command, "cp %s %s", filePath,
fileGetDirectoryName(DropDirectory));
if (system(command) != 0) {
printf("Could not copy file \"%s\" to \"%s\".\n",
filePath, fileGetDirectoryName(DropDirectory));
transferInfo->status = DtDND_FAILURE;
return;
}
/* Create icon(s) for new file(s) at the drop site */
iconPtr = IconNew();
IconInitialize(widget, iconPtr,
transferInfo->x + ii * 10,
transferInfo->y + ii * 10,
contents, strlen(contents), name, IconByData);
iconPtr->next = iconList;
if (iconList != NULL) {
iconList->prev = iconPtr;
}
iconList = iconPtr;
XtVaSetValues(widget, XmNuserData, iconList, NULL);
XtFree(contents);
}
}
/*
* fileDragSetup
*
* Prepares the file draw area to be a drag source.
*/
void
fileDragSetup(
Widget fileDraw)
{
char translations[] = "<Btn2Down>: fileCheckForDragProc()";
XtTranslations newTranslations;
XtActionsRec actionTable[] = {
{"fileCheckForDragProc", (XtActionProc)fileCheckForDragProc},
};
XtAppAddActions(demoAppContext, actionTable, 1);
newTranslations = XtParseTranslationTable(translations);
XtVaSetValues(fileDraw, XmNtranslations, newTranslations, NULL);
XtAddEventHandler(fileDraw, Button1MotionMask, False,
(XtEventHandler)demoDragMotionHandler,
(XtPointer)DtDND_FILENAME_TRANSFER);
fileCreateFiles(fileDraw);
}
/*
* fileDropSetup
*
* Such a function is not needed since the demoDropSetup() in demo.c registers
* the draw area as a drop site for drops of file names.
*/
/*
* fileDragStart
*
* Initiates a file drag. The function fileCheckForDrag() first determines
* if the pointer is over a file icon before calling this function.
*/
static void
fileDragStart(
Widget widget,
XEvent *event,
IconInfo *iconArray,
int numFiles)
{
static XtCallbackRec convertCBRec[] = { {fileConvertCallback, NULL},
{NULL, NULL} };
static XtCallbackRec dragFinishCBRec[] =
{ {demoDragFinishCallback, NULL},
{fileDragFinishCallback, NULL},
{NULL, NULL} };
Widget dragIcon;
Arg arg[1];
convertCBRec[0].closure = (XtPointer) iconArray;
/*
* Set up drag icon
*/
if (numFiles == 1) {
if (iconArray[0].dragIcon == NULL) {
iconArray[0].dragIcon = DtDndCreateSourceIcon(widget,
iconArray[0].bitmap, iconArray[0].mask);
}
dragIcon = iconArray[0].dragIcon;
} else {
dragIcon = NULL; /* Use default multiple provided by library */
}
XtSetArg(arg[0], DtNsourceIcon, (XtArgVal)dragIcon);
/*
* Start the drag
*/
if (DtDndDragStart(widget, event, DtDND_FILENAME_TRANSFER, numFiles,
XmDROP_COPY | XmDROP_MOVE,
convertCBRec, dragFinishCBRec, arg, 1)
== NULL) {
printf("DragStart returned NULL.\n");
}
}
/*
* fileCheckForDragProc
*
* Called when button 2 is pressed in the file drag area. Calls
* fileCheckForDrag() to determine if the button was pressed over a file
* icon in which case a drag is started.
*/
static XtActionProc
fileCheckForDragProc(
Widget widget,
XEvent *event,
String *params,
Cardinal *numParams)
{
fileCheckForDrag(widget, event, event->xbutton.x, event->xbutton.y);
}
/*
* fileCheckForDrag
*
* Determine if the pointer is over a file icon (within the drag threshold)
* when button 2 is pressed or when button 1 was pressed and the drag
* threshold has been exceeded.
*/
void
fileCheckForDrag(
Widget widget,
XEvent *event,
int initialX,
int initialY)
{
IconInfo *iconList, *iconPtr, *iconArray;
XtVaGetValues(widget, XmNuserData, &iconList, NULL);
if (iconList == NULL) {
printf("Unable to locate icon list.\n");
}
for (iconPtr = iconList; iconPtr != NULL; iconPtr = iconPtr->next) {
if ((initialX > (int)iconPtr->icon.x &&
initialX < (int)(iconPtr->icon.x + iconPtr->icon.width)) &&
(initialY > (int)iconPtr->icon.y &&
initialY < (int)(iconPtr->icon.y + iconPtr->icon.height))){
/*
* This starts a single file drag. To start a multiple
* file drag add elements to the icon array here. The
* convert and transfer callbacks are already written
* to handle multiple file transfers.
*/
iconArray = (IconInfo *)XtCalloc(1,sizeof(IconInfo));
iconArray[0] = *iconPtr;
fileDragStart(widget, event, iconArray, 1);
}
}
}
/*************************************************************************
*
* File Creation, Initialization & Destruction
*
*************************************************************************/
/*
* fileCreateDragSource
*
* Create draw area with a frame to serve as the drag source for files.
*/
Widget
fileCreateDragSource(
Widget parent)
{
Widget fileFrame,
fileDraw;
fileFrame = XtVaCreateManagedWidget("fileFrame",
xmFrameWidgetClass, parent,
NULL);
fileDraw = XtVaCreateManagedWidget("fileDraw",
xmDrawingAreaWidgetClass, fileFrame,
NULL);
XtAddCallback(fileDraw, XmNexposeCallback, demoDrawExposeCallback,NULL);
return fileDraw;
}
/*
* fileCreateDropSite
*
* Such a function is not needed since the drop site is the draw area which
* is created in demoCreateDropSite() in demo.c
*/
/*
* fileCreateDirectory
*
* Create the given directory.
*/
static void
fileCreateDirectory(
char *directory)
{
char command[MAXPATHLEN + 8];
sprintf(command, "mkdir %s", directory);
if (system(command) != 0) {
printf("Unable to create directory \"%s\"\n", directory);
exit(1);
}
}
/*
* fileCreateFile
*
* Given a path (partial or absolute), a file name and data create a file
* containing the given data using the given path.
*/
static void
fileCreateFile(
char *filePath,
char *fileName,
char *fileData)
{
FILE *fp;
char filePathAndName[MAXPATHLEN];
sprintf(filePathAndName, "%s/%s", filePath, fileName);
if ((fp = fopen(filePathAndName, "w")) == NULL) {
printf("Cannot create file \"%s\" in current directory.\n"
"Exiting...\n", filePathAndName);
exit(1);
}
if (fwrite(fileData, strlen(fileData), 1, fp) != 1) {
printf("Cannot write file \"%s\" in current directory.\n"
"Exiting...\n", filePathAndName);
exit(1);
}
fclose(fp);
}
/*
* fileCreateFiles
*
* Create drag and drop directories and the files to drag.
*/
static void
fileCreateFiles(
Widget fileDraw)
{
IconInfo *iconList,
*iconPtr;
char *dragDirectory,
*dropDirectory;
Atom WM_DELETE_WINDOW;
WM_DELETE_WINDOW =
XmInternAtom(XtDisplay(demoTopLevel), "WM_DELETE_WINDOW", False);
XmAddWMProtocolCallback(demoTopLevel, WM_DELETE_WINDOW, fileShutdown,
(XtPointer)NULL);
dragDirectory = fileGetDirectoryName(DragDirectory);
dropDirectory = fileGetDirectoryName(DropDirectory);
fileRemoveDirectory(dragDirectory);
fileCreateDirectory(dragDirectory);
fileRemoveDirectory(dropDirectory);
fileCreateDirectory(dropDirectory);
fileCreateFile(dragDirectory, FILE_NAME_TEXT, FILE_DATA_TEXT);
fileCreateFile(dragDirectory, FILE_NAME_CSH, FILE_DATA_CSH);
fileCreateFile(dragDirectory, FILE_NAME_PS, FILE_DATA_PS);
iconPtr = IconNew();
IconInitialize(fileDraw, iconPtr, 40, 25,
FILE_DATA_TEXT, strlen(FILE_DATA_TEXT),
FILE_NAME_TEXT, IconByData);
iconList = iconPtr;
iconPtr = IconNew();
iconPtr->next = iconList;
iconList->prev = iconPtr;
IconInitialize(fileDraw, iconPtr, 105, 25,
FILE_DATA_CSH, strlen(FILE_DATA_CSH),
FILE_NAME_CSH, IconByData);
iconList = iconPtr;
iconPtr = IconNew();
iconPtr->next = iconList;
iconList->prev = iconPtr;
IconInitialize(fileDraw, iconPtr, 75, 95,
FILE_DATA_PS, strlen(FILE_DATA_PS),
FILE_NAME_PS, IconByData);
iconList = iconPtr;
XtVaSetValues(fileDraw, XmNuserData, iconList, NULL);
}
/*
* fileRemoveDirectory
*
* Remove the given directory and its contents if the directory exists.
*/
static void
fileRemoveDirectory(
char *directory)
{
struct stat fileStatus;
char command[MAXPATHLEN + 8];
if (stat(directory, &fileStatus) == 0) { /* directory exists */
sprintf(command, "rm -rf %s", directory);
if (system(command) != 0) {
printf("Unable to remove directory \"%s\"\n"
"Please remove this directory by hand "
"and try again.\n", directory);
exit(1);
}
}
}
/*
* fileShutdown
*
* Remove the temporary file
*/
static void
fileShutdown(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
fileRemoveDirectory(fileGetDirectoryName(DragDirectory));
fileRemoveDirectory(fileGetDirectoryName(DropDirectory));
}
/*************************************************************************
*
* File Utility Functions
*
*************************************************************************/
/*
* fileGetContents
*
* Open the specified file and read the contents into a buffer which is
* returned.
*/
static char*
fileGetContents(
char *filePath)
{
char *contents = NULL;
struct stat fileStatus;
FILE *fp;
if (stat(filePath, &fileStatus) == 0) { /* file exists */
contents = (char *) XtMalloc(fileStatus.st_size + 1);
if ((fp = fopen(filePath, "r")) == NULL) {
printf("Cannot open file \"%s\" for reading.\n",
filePath);
XtFree(contents);
contents = NULL;
} else if (fread(contents, fileStatus.st_size, 1, fp) != 1) {
printf("Cannot read file \"%s\".\n", filePath);
XtFree(contents);
contents = NULL;
}
if (contents != NULL) {
contents[fileStatus.st_size] = NULL;
}
fclose(fp);
}
return contents;
}
/*
* fileGetDemoDirectory
*
* Return the directory where the demo directories reside.
*/
static char*
fileGetDemoDirectory()
{
static char *demoDirectory = NULL;
char currentDirectory[MAXPATHLEN];
int status;
if (demoDirectory == NULL) {
demoDirectory = (char *) getenv("DNDDEMODIR");
if (demoDirectory == NULL) {
demoDirectory = (char *) getcwd(NULL, MAXPATHLEN);
if (demoDirectory == NULL) {
sprintf(
"getcwd() could not get current directory.\n"
"\tUsing \".\" instead.\n",
NULL);
demoDirectory = ".";
} else {
/* strip off the /tmp_mnt */
if (strncmp(demoDirectory, "/tmp_mnt/", 9) == 0) {
demoDirectory += 8;
}
}
}
}
return demoDirectory;
}
/*
* fileGetDirectoryName
*
* Gets the name of the directory where the files are dragged from or dropped
* to depending on which is requested.
*/
static char*
fileGetDirectoryName(
DragOrDrop dragOrDrop)
{
static char *dragDirectory = NULL;
static char *dropDirectory = NULL;
switch (dragOrDrop) {
case DragDirectory:
if (dragDirectory == NULL) {
dragDirectory = (char *) XtMalloc(MAXPATHLEN + 1);
sprintf(dragDirectory, "%s/FileDragDir",
fileGetDemoDirectory());
}
return dragDirectory;
break;
case DropDirectory:
if (dropDirectory == NULL) {
dropDirectory = (char *) XtMalloc(MAXPATHLEN + 1);
sprintf(dropDirectory, "%s/FileDropDir",
fileGetDemoDirectory());
}
return dropDirectory;
break;
default:
return NULL;
}
}
/*
* fileStoreBuffer
*
* Store a buffer into a file in the drop directory.
* A temporary file may be created if required.
*/
char *
fileStoreBuffer(
char *name,
void *buf,
int len)
{
char path[MAXPATHLEN];
char *dir = fileGetDirectoryName(DropDirectory);
struct stat statInfo;
FILE *fp;
if (name == NULL)
name = "unnamed";
sprintf(path, "%s/%s", dir, name);
if (stat(path, &statInfo) == 0) {
char *tPath;
if ((tPath = tempnam(dir, name)) == NULL)
return (char *)NULL;
strcpy(path, tPath);
free(tPath);
}
if ((fp = fopen(path, "w")) == NULL) {
printf("Cannot create file \"%s\"\n", path);
return (char *)NULL;
}
if (fwrite(buf, len, 1, fp) != 1) {
printf("Cannot write to file \"%s\".\n", path);
return (char *)NULL;
}
fclose(fp);
return XtNewString(path);
}

26
cde/examples/dtdnd/file.h Normal file
View File

@@ -0,0 +1,26 @@
/* $XConsortium: file.h /main/3 1995/10/27 10:39:01 rswiston $ */
/*****************************************************************************
*****************************************************************************
**
** File: file.h
**
** Description: Header for file transfer portion of CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
/*
* Public File Transfer Function Declarations
*/
void fileCheckForDrag(Widget, XEvent*, int, int);
Widget fileCreateDragSource(Widget);
void fileDragSetup(Widget);
void fileTransferCallback(Widget, XtPointer, XtPointer);
char * fileStoreBuffer(char*, void*, int);

538
cde/examples/dtdnd/icon.c Normal file
View File

@@ -0,0 +1,538 @@
/* $XConsortium: icon.c /main/3 1995/10/27 10:39:09 rswiston $ */
/*****************************************************************************
*****************************************************************************
**
** File: icon.c
**
** Description: Icon support functions for the CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#include <stdio.h>
#include <Xm/Screen.h>
#include <Dt/Dts.h>
#include <Dt/Dnd.h>
#include "icon.h"
/*************************************************************************
*
* Data Structures & Private Declarations For Icon Handling Functions
*
**************************************************************************/
#define ICON_TEXT_YGAP 2
#define ICON_PATH "/usr/dt/appconfig/icons/C"
#define ICON_BITMAP_SUFFIX "m.bm"
#define ICON_MASK_SUFFIX "m_m.bm"
/*
* Default Generic Icon Bitmap & Mask
*/
#define iconWidth 32
#define iconHeight 32
static unsigned char iconBits[] = {
0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x0f, 0x08, 0x00, 0x00, 0x08,
0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x88, 0x9d, 0x6d, 0x08,
0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x88, 0xf9, 0xed, 0x08,
0x08, 0x00, 0x00, 0x08, 0xc8, 0x6e, 0x7d, 0x08, 0x08, 0x00, 0x00, 0x08,
0xc8, 0x9d, 0xef, 0x09, 0x08, 0x00, 0x00, 0x08, 0xc8, 0xdd, 0xb3, 0x08,
0x08, 0x00, 0x00, 0x08, 0xc8, 0xdf, 0xfd, 0x09, 0x08, 0x00, 0x00, 0x08,
0xc8, 0xf6, 0xde, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08,
0x88, 0xed, 0xd2, 0x08, 0x08, 0x00, 0x00, 0x08, 0xc8, 0xbb, 0xf3, 0x08,
0x08, 0x00, 0x00, 0x08, 0x48, 0xdf, 0x5e, 0x08, 0x08, 0x00, 0x00, 0x08,
0xc8, 0x36, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x08,
0x08, 0x00, 0x00, 0x08, 0xf8, 0xff, 0xff, 0x0f};
#define iconMaskWidth 32
#define iconMaskHeight 32
static unsigned char iconMaskBits[] = {
0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
0xf8, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f};
/*
* Blank Bitmap
*/
#define blankWidth 16
#define blankHeight 16
static unsigned char blankBits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/*
* Private Icon Handling Function Declarations
*/
static void iconClearBitmap(Display*, Window, GC, Pixmap, int, int);
static Pixmap iconDefaultBitmap(Display*, Window, IconBitmapPart,
unsigned short*, unsigned short*);
static void iconFree(IconInfo*);
static Pixmap iconGetBitmap(Widget, char*, IconBitmapPart, unsigned short*,
unsigned short*);
static char *iconGetIconPath(void*, int, IconTyping, IconBitmapPart);
static Pixmap iconMergeBitmaps(Widget, Pixmap, int, int, Pixmap, int, int,
int, int, Boolean);
/*************************************************************************
*
* Public Icon Handling Functions
*
**************************************************************************/
/*
* IconCreateDouble
*
* Create a double icon from a single icon. The double icon has a bitmap
* consisting of 2 images of the original bitmap offset from one another.
*/
void
IconCreateDouble(
Widget widget,
IconInfo *oldIcon,
int xOffset,
int yOffset,
IconInfo *newIcon,
short xx,
short yy)
{
newIcon->bitmap = iconMergeBitmaps(widget,
oldIcon->bitmap, oldIcon->icon.width, oldIcon->icon.height,
oldIcon->bitmap, oldIcon->icon.width, oldIcon->icon.height,
xOffset, yOffset, False);
newIcon->mask = iconMergeBitmaps(widget,
oldIcon->mask, oldIcon->icon.width, oldIcon->icon.height,
oldIcon->mask, oldIcon->icon.width, oldIcon->icon.height,
xOffset, yOffset, True);
newIcon->icon.width = oldIcon->icon.width + 10;
newIcon->icon.height = oldIcon->icon.height + 10;
newIcon->name = XtNewString("Multiple");
newIcon->icon.x = xx;
newIcon->icon.y = yy;
newIcon->dragIcon = DtDndCreateSourceIcon(widget,
newIcon->bitmap, newIcon->mask);
}
/*
* IconDelete
*
* Remove the icon from its list and deallocate memory used by the icon.
*/
void
IconDelete(
Widget drawArea,
IconInfo *iconPtr)
{
IconInfo *iconList;
if (iconPtr == NULL || drawArea == NULL) {
return;
}
if (iconPtr->next != NULL) { /* iconPtr is not the tail of the list */
iconPtr->next->prev = iconPtr->prev;
}
if (iconPtr->prev != NULL) { /* iconPtr is not the head of the list */
iconPtr->prev->next = iconPtr->next;
}
if (iconPtr->next == NULL) { /* iconPtr is the tail of the list */
iconList = iconPtr->prev;
} else {
iconList = iconPtr->next;
}
while (iconList != NULL && iconList->prev != NULL) {
iconList = iconList->prev;
}
iconFree(iconPtr);
XtVaSetValues(drawArea, XmNuserData, iconList, NULL);
}
/*
* IconDraw
*
* Render given icon in the window of the given widget.
*/
void
IconDraw(
Widget widget,
IconInfo *iconPtr)
{
static GC graphicsContext = NULL;
static XFontStruct *fontStruct;
Display *display = XtDisplayOfObject(widget);
Window window = XtWindow(widget);
int screen = DefaultScreen(display);
XGCValues gcValues;
if (graphicsContext == NULL) {
gcValues.foreground = BlackPixel(display, screen);
gcValues.background = WhitePixel(display, screen);
graphicsContext = XCreateGC(display, window,
GCForeground | GCBackground, &gcValues);
}
/*
* Draw icon
*/
gcValues.clip_mask = iconPtr->mask;
gcValues.clip_x_origin = iconPtr->icon.x;
gcValues.clip_y_origin = iconPtr->icon.y;
XChangeGC(display, graphicsContext,
GCClipMask | GCClipXOrigin | GCClipYOrigin, &gcValues);
XCopyPlane(display, iconPtr->bitmap, window, graphicsContext, 0, 0,
iconPtr->icon.width, iconPtr->icon.height,
iconPtr->icon.x, iconPtr->icon.y, 1L);
/*
* Draw icon name centered below icon
*/
if (iconPtr->name != NULL) {
int nameX, nameY;
int direction, ascent, decent;
XCharStruct overall;
Widget xmScreen;
if (fontStruct == NULL) {
xmScreen = XmGetXmScreen(XtScreen(widget));
XtVaGetValues(xmScreen, XmNfont, &fontStruct, NULL);
}
XTextExtents(fontStruct, iconPtr->name, strlen(iconPtr->name),
&direction, &ascent, &decent, &overall);
nameX = (iconPtr->icon.x + (iconPtr->icon.width/2)) -
(overall.width/2);
nameY = iconPtr->icon.y + iconPtr->icon.height +
ICON_TEXT_YGAP + ascent;
gcValues.font = fontStruct->fid;
gcValues.clip_mask = None;
XChangeGC(display, graphicsContext,
GCFont | GCClipMask, &gcValues);
XDrawString(display, window, graphicsContext, nameX, nameY,
iconPtr->name, strlen(iconPtr->name));
}
}
/*
* IconInitialize
*
* Initialize given icon with given data. Get icon bitmap based on data
* associated with the icon. This data may be a file name, a buffer or
* a type name. Create source icon for dragging based on the bitmap and mask.
*/
void
IconInitialize(
Widget widget,
IconInfo *iconPtr,
short x,
short y,
void *data,
int dataLen,
char *name,
IconTyping typing)
{
char *iconPath;
iconPath = iconGetIconPath(data, dataLen, typing, IconMask);
iconPtr->mask = iconGetBitmap(widget, iconPath, IconMask,
&(iconPtr->icon.width), &(iconPtr->icon.height));
XtFree(iconPath);
iconPath = iconGetIconPath(data, dataLen, typing, IconBitmap);
iconPtr->bitmap = iconGetBitmap(widget, iconPath, IconBitmap,
&(iconPtr->icon.width), &(iconPtr->icon.height));
XtFree(iconPath);
iconPtr->icon.x = x;
iconPtr->icon.y = y;
iconPtr->name = XtNewString(name);
iconPtr->dragIcon = DtDndCreateSourceIcon(widget,
iconPtr->bitmap, iconPtr->mask);
}
/*
* IconNew
*
* Allocate memory for a new icon structure and clear.
*/
IconInfo*
IconNew()
{
IconInfo *iconPtr;
iconPtr = (IconInfo*) XtMalloc(sizeof(IconInfo));
memset(iconPtr, 0x00, sizeof(IconInfo));
return iconPtr;
}
/*************************************************************************
*
* Private Icon Handling Functions
*
**************************************************************************/
/*
* iconClearBitmap
*
* Clear a bitmap by filling it with zeros.
*/
static void
iconClearBitmap(
Display *display,
Window window,
GC graphicsContext,
Pixmap bitmap,
int width,
int height)
{
int xx, yy;
static Pixmap blankBitmap = NULL;
if (blankBitmap == NULL) {
blankBitmap = XCreateBitmapFromData(display, window,
(char *)blankBits, blankWidth, blankHeight);
}
for (xx = 0; xx < width + blankWidth; xx += blankWidth) {
for (yy = 0; yy < height + blankHeight; yy += blankHeight) {
XCopyArea(display, blankBitmap, bitmap,
graphicsContext, 0, 0,
blankWidth, blankHeight, xx, yy);
}
}
}
/*
* iconDefaultBitmap
*
* Create default icon bitmap or mask and set width and height accordingly.
*/
static Pixmap
iconDefaultBitmap(
Display *display,
Window window,
IconBitmapPart iconPart,
unsigned short *width,
unsigned short *height)
{
static Pixmap bitmap;
static Pixmap mask;
if (iconPart == IconMask) { /* create default mask */
if (mask == NULL) {
mask = XCreateBitmapFromData(display, window,
(char *)iconMaskBits, iconMaskWidth, iconMaskHeight);
}
*width = iconMaskWidth;
*height = iconMaskHeight;
return mask;
} else { /* create default bitmap */
if (bitmap == NULL) {
bitmap = XCreateBitmapFromData(display, window,
(char *)iconBits, iconWidth, iconHeight);
}
*width = iconWidth;
*height = iconHeight;
return bitmap;
}
}
/*
* iconFree
*
* Deallocate the icon and associated resources.
*/
static void
iconFree(
IconInfo *iconPtr)
{
Display *display = XtDisplayOfObject(iconPtr->dragIcon);
if (iconPtr == NULL) {
return;
}
XtFree(iconPtr->name);
/*
* REMIND: This needs to free other things too...
* XFreePixmap(display, iconPtr->bitmap);
* XFreePixmap(display, iconPtr->mask);
* Free(iconPtr->dragIcon);
*/
XtFree((char *)iconPtr);
}
/*
* iconGetBitmap
*
* Get a bitmap for the icon based on the path and name of the icon.
* If no bitmap file is found use a built-in default.
*/
static Pixmap
iconGetBitmap(
Widget widget,
char *iconPath,
IconBitmapPart iconPart,
unsigned short *returnWidth,
unsigned short *returnHeight)
{
Display *display = XtDisplayOfObject(widget);
Window window = DefaultRootWindow(display);
int status;
int xHot, yHot;
Pixmap bitmap;
unsigned int width, height;
*returnWidth = *returnHeight = 0;
if (iconPath != NULL) {
status = XReadBitmapFile(display, window, iconPath,
&width, &height, &bitmap, &xHot, &yHot);
if (status == BitmapSuccess) {
*returnWidth = (unsigned short) width;
*returnHeight = (unsigned short) height;
} else {
printf(
"Unable to read icon from bitmap file \"%s\".\n"
"Using default icon bitmap.\n",
iconPath, NULL);
bitmap = iconDefaultBitmap(display, window, iconPart,
returnWidth, returnHeight);
}
} else {
bitmap = iconDefaultBitmap(display, window, iconPart,
returnWidth, returnHeight);
}
return bitmap;
}
/*
* iconGetIconPath
*
* Get the file path and name for an icon based on the given data and
* method of typing that data. This function assumes the data typing
* database has been loaded with DtDtsLoadDataTypes().
*/
static char*
iconGetIconPath(
void *data,
int dataLen,
IconTyping typing,
IconBitmapPart iconPart)
{
char iconPath[MAXPATHLEN + 1],
*iconName,
*iconSuffix;
switch (typing) {
case IconByFile:
iconName = DtDtsFileToAttributeValue(data, "ICON");
break;
case IconByData:
iconName = DtDtsBufferToAttributeValue(data, dataLen,
"ICON", NULL);
break;
case IconByType:
iconName = DtDtsDataTypeToAttributeValue(data, "ICON", NULL);
break;
default:
iconName = NULL;
}
if (iconName != NULL) {
if (iconPart == IconMask) {
iconSuffix = ICON_MASK_SUFFIX;
} else {
iconSuffix = ICON_BITMAP_SUFFIX;
}
sprintf(iconPath, "%s/%s.%s", ICON_PATH, iconName, iconSuffix);
DtDtsFreeAttributeValue(iconName);
}
return XtNewString(iconPath);
}
/*
* iconMergeBitmaps
*
* Create new bitmap consisting of the offset composition of the given bitmaps.
*/
static Pixmap
iconMergeBitmaps(
Widget widget,
Pixmap bitmap1,
int width1,
int height1,
Pixmap bitmap2,
int width2,
int height2,
int xOffset,
int yOffset,
Boolean clear)
{
Display *display = XtDisplayOfObject(widget);
Window window = DefaultRootWindow(display);
int screen = DefaultScreen(display);
Pixmap mergedBitmap, blankBitmap;
int extraX, extraY, width, height;
static GC graphicsContext = NULL;
XGCValues gcValues;
extraX = width2 - width1 + xOffset + 1;
if (extraX < 0) extraX = 0;
width = width1 + extraX;
extraY = height2 - height1 + yOffset + 1;
if (extraY < 0) extraY = 0;
height = height1 + extraY;
mergedBitmap = XCreatePixmap(display, window, width, height, 1);
if (graphicsContext == NULL) {
graphicsContext = XCreateGC(display, mergedBitmap, 0L, NULL);
}
if (clear) {
iconClearBitmap(display, window, graphicsContext, mergedBitmap,
width, height);
}
XCopyArea(display, bitmap2, mergedBitmap, graphicsContext, 0, 0,
width2, height2, xOffset, yOffset);
XCopyArea(display, bitmap1, mergedBitmap, graphicsContext, 0, 0,
width1, height1, 0, 0);
return mergedBitmap;
}

64
cde/examples/dtdnd/icon.h Normal file
View File

@@ -0,0 +1,64 @@
/* $XConsortium: icon.h /main/3 1995/10/27 10:39:18 rswiston $ */
/*****************************************************************************
*****************************************************************************
**
** File: icon.h
**
** Description: Header for icon handling portion of CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#include <sys/param.h>
#include <stdio.h>
/*
* Icon Information Structure
*/
typedef struct _IconInfo {
XRectangle icon;
char *name;
void *data;
int dataCount;
Pixmap bitmap;
Pixmap mask;
Widget dragIcon;
int type;
struct _IconInfo *next;
struct _IconInfo *prev;
} IconInfo;
/*
* Icon Typedefs
*/
typedef enum {
IconBitmap,
IconMask
} IconBitmapPart;
typedef enum {
IconByFile,
IconByData,
IconByType
} IconTyping;
/*
* Public Icon Handling Function Declarations
*/
void IconCreateDouble(Widget, IconInfo*, int, int, IconInfo*,
short, short);
void IconDelete(Widget, IconInfo*);
void IconDraw(Widget, IconInfo*);
void IconInitialize(Widget, IconInfo*, short, short, void*, int,
char*, IconTyping);
IconInfo *IconNew();

394
cde/examples/dtdnd/text.c Normal file
View File

@@ -0,0 +1,394 @@
/* $TOG: text.c /main/5 1999/07/20 14:50:18 mgreess $ */
/*****************************************************************************
*****************************************************************************
**
** File: text.c
**
** Description: Text transfer functions for the CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/Label.h>
#include <Xm/List.h>
#include <Xm/RowColumn.h>
#include <Xm/Text.h>
#include <Dt/Dt.h>
#include <Dt/Dnd.h>
#include "demo.h"
#include "text.h"
/*************************************************************************
*
* Data Structures & Private Declarations For Text Transfers
*
**************************************************************************/
/*
* Data for text list of fruit
*/
char *todaysFruit[] = {
"Oranges",
"Peaches",
"Lemons",
"Watermelons",
"Apples",
"Bananas",
"Plums",
"Limes",
"Cantaloupes",
"Nectarines",
"Papayas",
"Mangos",
NULL
};
/*************************************************************************
*
* Text Drag & Drop
*
*************************************************************************/
/*
* textConvertCallback
*
* Sets the text object's text to the text in the fruit list based on where
* the pointer was when the drag started.
*/
void
textConvertCallback(
Widget dragContext,
XtPointer clientData,
XtPointer callData)
{
DtDndConvertCallbackStruct *convertInfo =
(DtDndConvertCallbackStruct *) callData;
Widget fruitList = (Widget) clientData;
int selectedPos;
XmString *items;
Cardinal itemCount;
if (convertInfo == NULL) {
return;
}
/*
* Verify protocol and callback reason
*/
if (convertInfo->dragData->protocol != DtDND_TEXT_TRANSFER ||
(convertInfo->reason != DtCR_DND_CONVERT_DATA &&
convertInfo->reason != DtCR_DND_CONVERT_DELETE) ||
fruitList == NULL) {
return;
}
switch (convertInfo->reason) {
case DtCR_DND_CONVERT_DATA:
/*
* Provide the text from the fruit list
*/
XtVaGetValues(fruitList,
XmNuserData, &selectedPos,
XmNitems, &items,
XmNitemCount, &itemCount,
NULL);
if (itemCount > 0 && selectedPos < itemCount) {
convertInfo->dragData->data.strings[0] =
items[selectedPos-1];
} else {
convertInfo->status = DtDND_FAILURE;
}
break;
DtCR_DND_CONVERT_DELETE:
/*
* Delete the text from the fruit list. If the fruit list
* were set up to be dynamic, deletion from the list would
* occur here.
*/
printf("Delete fruit item #%d\n",
convertInfo->dragData->data.strings[0]);
break;
}
}
/*
* textDragFinishCallback
*
* Normally would free any memory allocated by textConvertCallback
* but none was allocated so this is just a placeholder.
*/
void
textDragFinishCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
}
/*
* textTransferCallback
*
* Handles transfer of files or text to the text edit. Files are transfered
* by placing their name in the field, text by inserting the text into the
* field.
*/
void
textTransferCallback(
Widget widget,
XtPointer clientData,
XtPointer callData)
{
DtDndTransferCallbackStruct *transferInfo =
(DtDndTransferCallbackStruct *) callData;
String text;
/*
* Verify callback reason
*/
if (transferInfo == NULL ||
transferInfo->reason != DtCR_DND_TRANSFER_DATA) {
return;
}
switch (transferInfo->dropData->protocol) {
case DtDND_FILENAME_TRANSFER:
/*
* Copy the file name into the text field
*/
XtVaSetValues(widget,
XmNvalue, transferInfo->dropData->data.files[0],
NULL);
break;
case DtDND_TEXT_TRANSFER:
/*
* Copy the fruit name into the text field
*/
text = XmStringUnparse(transferInfo->dropData->data.strings[0],
NULL, XmCHARSET_TEXT, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
XtVaSetValues(widget, XmNvalue, text, NULL);
XtFree (text);
break;
}
}
/*
* textDragSetup
*
* Prepares the fruit list to source drags of text with button 1.
*/
void textDragSetup(Widget fruitList)
{
static char translations[] = "\
~c ~s ~m ~a <Btn1Down>:\
demoProcessPress(ListBeginSelect,textDragStart)\n\
c ~s ~m ~a <Btn1Down>:\
demoProcessPress(ListBeginToggle,textDragStart)";
static char btn2_translations[] = "\
~c ~s ~m ~a <Btn2Down>:\
demoProcessPress(ListBeginSelect,textDragStart)\n\
c ~s ~m ~a <Btn2Down>:\
demoProcessPress(ListBeginToggle,textDragStart)\n\
<Btn2Motion>:ListButtonMotion()\n\
~c ~s ~m ~a <Btn2Up>:ListEndSelect()\n\
c ~s ~m ~a <Btn2Up>:ListEndToggle()";
static XtActionsRec actionTable[] =
{
{"textDragStart", (XtActionProc) &textDragStart},
{"demoProcessPress", (XtActionProc) &demoProcessPress}
};
int btn1_transfer = 0;
XtTranslations new_translations;
XtAppAddActions(
demoAppContext,
actionTable,
sizeof(actionTable)/sizeof(actionTable[0]));
new_translations = XtParseTranslationTable(translations);
XtOverrideTranslations(fruitList, new_translations);
XtVaGetValues(
(Widget) XmGetXmDisplay(XtDisplayOfObject(fruitList)),
"enableBtn1Transfer", &btn1_transfer,
NULL);
if (btn1_transfer != True)
{
new_translations = XtParseTranslationTable(btn2_translations);
XtOverrideTranslations(fruitList, new_translations);
}
#if 0
XtAddEventHandler(fruitList, Button1MotionMask, False,
(XtEventHandler)demoDragMotionHandler,
(XtPointer)DtDND_TEXT_TRANSFER);
#endif
}
/*
* textDropSetup
*
* Registers text field to accept drops of files.
*/
void
textDropSetup(
Widget textField)
{
static XtCallbackRec transferCBRec[] = { {textTransferCallback, NULL},
{NULL, NULL} };
DtDndDropRegister(textField, DtDND_FILENAME_TRANSFER,
XmDROP_COPY, transferCBRec, NULL, 0);
}
/*
* textDragStart
*
* Initiates a drag of a text item from the fruit list provided the pointer
* is over an item in the list.
*/
void
textDragStart(
Widget widget,
XEvent *event)
{
int itemCount,
selectedPos;
static XtCallbackRec convertCBRec[] = { {textConvertCallback, NULL},
{NULL, NULL} };
static XtCallbackRec dragFinishCBRec[] =
{ {demoDragFinishCallback, NULL},
{textDragFinishCallback, NULL},
{NULL, NULL} };
/*
* Determine which item to drag from the text list
*/
XtVaGetValues(widget, XmNitemCount, &itemCount, NULL);
selectedPos = XmListYToPos(widget, event->xmotion.y);
if (selectedPos == 0 || selectedPos > itemCount) {
return;
}
XtVaSetValues(widget, XmNuserData, selectedPos, NULL);
convertCBRec[0].closure = (XtPointer)widget;
/*
* Start the drag
*/
if (DtDndDragStart(widget, event, DtDND_TEXT_TRANSFER, 1,
XmDROP_COPY, convertCBRec, dragFinishCBRec, NULL, 0)
== NULL) {
printf("DragStart returned NULL.\n");
}
}
/*************************************************************************
*
* Text Creation & Initialization
*
*************************************************************************/
/*
* textCreateDragSource
*
* Creates a scrolling list filled with fruit names.
*/
Widget
textCreateDragSource(
Widget parent)
{
Widget fruitList;
XmString *fruits;
Arg args[2];
int ii, fruitCount;
for (ii = 0; todaysFruit[ii] != NULL; ii++)
;
fruitCount = ii;
fruits = (XmString *) XtMalloc(sizeof(XmString) * fruitCount);
for (ii = 0; ii < fruitCount; ii++) {
fruits[ii] = XmStringCreate(todaysFruit[ii],
XmFONTLIST_DEFAULT_TAG);
}
ii = 0;
XtSetArg(args[ii], XmNitems, fruits); ii++;
XtSetArg(args[ii], XmNitemCount, fruitCount); ii++;
fruitList = XmCreateScrolledList(parent, "fruitList", args, ii);
XtManageChild(fruitList);
for (ii = 0; ii < fruitCount; ii++) {
XmStringFree(fruits[ii]);
}
XtFree((char *)fruits);
return fruitList;
}
/*
* textCreateDropSite
*
* Creates a text field with a label.
*/
Widget
textCreateDropSite(
Widget parent)
{
Widget textRowColumn,
textLabel,
textField;
textRowColumn = XtVaCreateManagedWidget("textRowColumn",
xmRowColumnWidgetClass, parent,
NULL);
textLabel = XtVaCreateManagedWidget("textLabel",
xmLabelWidgetClass, textRowColumn,
NULL);
textField = XtVaCreateManagedWidget("textField",
xmTextWidgetClass, textRowColumn,
NULL);
return textField;
}

27
cde/examples/dtdnd/text.h Normal file
View File

@@ -0,0 +1,27 @@
/* $XConsortium: text.h /main/3 1995/10/27 10:39:35 rswiston $ */
/*****************************************************************************
*****************************************************************************
**
** File: text.h
**
** Description: Header for text transfer portion of CDE Drag & Drop Demo.
**
** (c) Copyright 1993, 1994 Hewlett-Packard Company
** (c) Copyright 1993, 1994 International Business Machines Corp.
** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
** (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
** Novell, Inc.
**
****************************************************************************
************************************<+>*************************************/
/*
* Public Text Transfer Function Declarations
*/
void textDragSetup(Widget);
void textDropSetup(Widget);
void textDragStart(Widget, XEvent*);
Widget textCreateDragSource(Widget);
Widget textCreateDropSite(Widget);

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:47:02 drk $
##########################################################################
#
# Makefile for dtdts examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = datatyping
SOURCES = datatyping.c
OBJECTS = datatyping.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:47:20 drk $
##########################################################################
#
# Makefile for dtdts examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = datatyping
SOURCES = datatyping.c
OBJECTS = datatyping.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:47:37 drk $
##########################################################################
#
# Makefile for dtdts examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = datatyping
SOURCES = datatyping.c
OBJECTS = datatyping.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:47:54 drk $
##########################################################################
#
# Makefile for dtwidget examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = datatyping
SOURCES = datatyping.c
OBJECTS = datatyping.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,47 @@
# $XConsortium: Makefile.uxp /main/1 1996/08/23 08:21:04 barstow $
##########################################################################
#
# Makefile for dtdts examples (UXP)
#
# (c) Copyright 1996 Digital Equipment Corporation.
# (c) Copyright 1996 Hewlett-Packard Company.
# (c) Copyright 1996 International Business Machines Corp.
# (c) Copyright 1996 Sun Microsystems, Inc.
# (c) Copyright 1996 Novell, Inc.
# (c) Copyright 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = datatyping
SOURCES = datatyping.c
OBJECTS = datatyping.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

20
cde/examples/dtdts/README Normal file
View File

@@ -0,0 +1,20 @@
/* $XConsortium: README /main/2 1996/07/15 14:00:20 drk $ */
This directory contains demonstrations of the Dts data typing API
datatyping - Examples of using the Dts API to determine information about
a set of files.
This program will display the data type, icon name
and supported actions for each file passed to it.
The dtaction client can then be used to
execute a supported action on the file.
The usage for datatyping is:
Usage: datatyping file1 [ file2 ... ]
example:
datatyping *

View File

@@ -0,0 +1,115 @@
/* $XConsortium: datatyping.c /main/3 1995/10/27 10:39:52 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
#include <Xm/Form.h>
#include <Xm/Text.h>
#include <Dt/Dts.h>
#define ApplicationClass "DtDatatyping"
static Widget text;
static void DisplayTypeInfo(int, char**);
int main(int argc, char **argv)
{
XtAppContext appContext;
Widget toplevel, form;
Arg args[20];
int n;
toplevel = XtAppInitialize(&appContext, ApplicationClass, NULL, 0,
&argc, argv, NULL, NULL, 0);
if (argc == 1) {
printf("%s: No files specified.\n", argv[0]);
exit(1);
}
form = XmCreateForm(toplevel, "form", NULL, 0);
XtManageChild(form);
n = 0;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNeditable, False); n++;
XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
XtSetArg(args[n], XmNrows, 25); n++;
XtSetArg(args[n], XmNcolumns, 90); n++;
text = XmCreateScrolledText(form, "text", args, n);
XtManageChild(text);
XtRealizeWidget(toplevel);
if (DtAppInitialize(appContext, XtDisplay(toplevel), toplevel, argv[0],
ApplicationClass) == False) {
printf("%s: Couldn't initialize Dt\n", argv[0]);
exit(1);
}
DtDbLoad();
DisplayTypeInfo(argc, argv);
XtAppMainLoop(appContext);
}
static void DisplayTypeInfo(int argc, char **argv)
{
char *file;
char *datatype;
char *icon;
char *actions;
char str[100];
int i;
sprintf(str, "%-30s\t%-10s\t%-8s\t%-20s\n",
"File",
"DataType",
"Icon",
"Actions");
XmTextInsert(text, XmTextGetLastPosition(text), str);
sprintf(str, "%-30s\t%-10s\t%-8s\t%-20s\n",
"-------------------",
"--------",
"----",
"-------");
XmTextInsert(text, XmTextGetLastPosition(text), str);
for(i=1; i < argc; i++) {
char *file = argv[i];
/* find out the Dts data type */
datatype = DtDtsFileToDataType(file);
if(datatype) {
/* find the icon attribute for the data type */
icon = DtDtsDataTypeToAttributeValue(datatype, DtDTS_DA_ICON, file);
}
/* Directly find the action attribute for a file */
actions = DtDtsFileToAttributeValue(file, DtDTS_DA_ACTION_LIST);
sprintf(str, "%-30s\t%-10s\t%-8s\t%s\n",
file,
datatype?datatype:"unknown",
icon?icon:"unknown",
actions?actions:"unknown");
XmTextInsert(text, XmTextGetLastPosition(text), str);
/* Free the space allocated by Dts */
DtDtsFreeAttributeValue(icon);
DtDtsFreeAttributeValue(actions);
DtDtsFreeDataType(datatype);
}
}

View File

@@ -0,0 +1,141 @@
/* $XConsortium: AppSpecific.c /main/4 1996/05/09 03:39:11 drk $ */
#include "PrintDemo.h"
/*
* ------------------------------------------------------------------------
* Name: AppObject_new
*
* Description:
*
* Allocates a new AppObject data structure. If parent is non-NULL,
* an application-specific main window work region is created.
*
* Return value:
*
* A pointer to the new AppObject structure.
*
*/
#define LABEL_FMTSTR "Filename: %s Size: %d"
static char *
ReadFile(char * filename, int * filesize)
{
char *buffer = NULL;
FILE * file;
*filesize = 0 ;
if ((file = fopen(filename, "r")) == NULL) return NULL ;
fseek(file, 0L, SEEK_END);
*filesize = ftell(file);
rewind(file);
buffer = (char *) malloc(*filesize+1);
if (fread(buffer, 1, *filesize, file) == *filesize ) {
buffer[*filesize] = '\0';
return buffer;
}
free(buffer);
return NULL;
}
AppObject*
AppObject_new(
Widget parent,
String file_name)
{
AppObject* me = (AppObject*)XtCalloc(1, sizeof(AppObject));
int filesize ;
me->main_window = parent ;
if(file_name != (String)NULL)
me->file_name = XtNewString(file_name);
else
me->file_name = XtNewString("README.txt");
me->file_buffer = ReadFile(me->file_name, &filesize);
if (me->file_buffer == NULL) {
me->file_buffer = XtNewString("abcdefghijklmnopqrstuvwxyz");
filesize = strlen("abcdefghijklmnopqrstuvwxyz");
}
if(parent != (Widget)NULL)
{
XmString label;
String buf;
buf = XtCalloc(strlen(LABEL_FMTSTR)+strlen(me->file_name)+10,
sizeof(char));
sprintf(buf, LABEL_FMTSTR, me->file_name, filesize);
label = XmStringCreateLocalized(buf);
XtFree(buf);
me->widget =
XtVaCreateManagedWidget("AppWorkArea",
xmLabelWidgetClass,
parent,
XmNlabelString, label,
NULL);
XmStringFree(label);
}
return me;
}
/*
* ------------------------------------------------------------------------
* Name: AppObject_customizePrintSetupBox
*
* Description:
*
* Adds application specific items to the passed print setup box.
*
* The document file name is presented in the top work area.
*
* Return value:
*
* None.
*
*/
void
AppObject_customizePrintSetupBox(
AppObject* me,
Widget print_dialog)
{
Widget row;
XmString label;
Widget w;
/*
* create the app-specific top work area
*/
XtVaSetValues(print_dialog,
DtNworkAreaLocation, DtWORK_AREA_TOP,
NULL);
row = XtVaCreateManagedWidget(
"DocumentNameRow",
xmRowColumnWidgetClass,
print_dialog,
XmNorientation, XmHORIZONTAL,
NULL);
/*
* create the document name label
*/
label = XmStringCreateLocalized("Document:");
w = XtVaCreateManagedWidget("DocumentNameLabel",
xmLabelGadgetClass,
row,
XmNlabelString, label,
NULL);
XmStringFree(label);
/*
* create the document name
*/
label = XmStringCreateLocalized(me->file_name);
w = XtVaCreateManagedWidget("DocumentName",
xmLabelGadgetClass,
row,
XmNlabelString, label,
NULL);
XmStringFree(label);
}

View File

@@ -0,0 +1,27 @@
/* $XConsortium: AppSpecific.h /main/4 1996/05/09 03:39:24 drk $ */
/*
* constant definitions
*/
#define APP_CLASS "Dtprint"
/*
* Application-specific "object"
*/
typedef struct _AppObject
{
Widget main_window ;
Widget widget;
String file_name;
char * file_buffer ;
} AppObject;
/*
* public AppObject functions
*/
extern AppObject* AppObject_new(
Widget parent,
String file_name);
extern void AppObject_customizePrintSetupBox(
AppObject* me,
Widget print_dialog);

View File

@@ -0,0 +1,8 @@
Dtprint.Print*background:white
Dtprint.Print*renderTable:-dt-application-medium-r-normal-serif-0-0-0-0-m-0-*-*:
Dtprint.Print*shadowThickness:0
Dtprint.Print*highlightThickness:0
Dtprint.Print*pform.marginHeight: 1in
Dtprint.Print*pform.marginWidth: 1in
Dtprint.Print*ptext.Attachment:attach_form
Dtprint.Print*ptext.wordWrap:True

View File

@@ -0,0 +1,60 @@
XCOMM $XConsortium: Imakefile /main/7 1996/10/09 14:02:30 drk $
DESKTOP_VERSION_STRING = DesktopVersionString
/* General case INCLUDES DEFINES LOCAL_LIBRARIES
* Each individual architecture may have more or less of the above.
* USE_libraryname in LOCAL_LIBRARIES is by default empty.
* It should be set when necessary to the real library macro name.
*/
DEFINES = -DXK_MISCELLANY -DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\"
INCLUDES = -I.
/* DEPLIBS contains the list of library depencies for a client.
* LOCAL_LIBRARIES contains the list of libraries on the link line.
* Generally, the dependency form of a library has DEP as a prefix.
* e.g. put $(XLIB) in LOCAL_LIBRARIES and $(DEPXLIB) in DEPLIBS.
* NOTE: if DEPLIBS is not set here, it is by default null and there
* are no library dependencies for clients.
* You cannot put -Llibpath into DEPLIBS. You must put actual
* paths to the library.
*/
DEPLIBS = $(DEPDTPRINTLIB) $(DEPDTHELPLIB) $(DEPDTSVCLIB) \
$(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)
LOCAL_LIBRARIES = $(DTPRINTLIB) $(DTHELPLIB) $(DTSVCLIB) $(XMLIB) \
$(XTOOLLIB) $(XLIB) -L/proj/x11/xc/usrlib -lXp
SYS_LIBRARIES = -lm
#ifdef RsArchitecture
SYS_LIBRARIES = -lmsaa -liconv
#endif
#if defined (SunArchitecture)
SYS_LIBRARIES = -lintl -L/opt/SUNWspro/SC2.0.1 -lm -lgen -ldl -lC
#endif
#if defined (USLArchitecture)
SYS_LIBRARIES = -lm -lnsl -lsocket -lgen
#endif
#if defined(HPOSFArchitecture)
#endif
PROGRAMS=dtprint
OBJS = \
AppSpecific.o \
Main.o \
MainWindow.o \
Print.o
SRCS = \
AppSpecific.c \
Main.c \
MainWindow.c \
Print.c
all::
NormalLibraryObjectRule()
ComplexProgramTarget($(PROGRAMS))

222
cde/examples/dtprint/Main.c Normal file
View File

@@ -0,0 +1,222 @@
/* $XConsortium: Main.c /main/6 1996/06/07 12:04:30 daniel $ */
#include "PrintDemo.h"
/*
* VideoShell structure definition
*/
typedef struct _VideoShell
{
Widget widget;
Boolean print_only;
String file_name;
} VideoShell;
/*
* application-level resources
*/
static XrmOptionDescRec XrmOptions[] =
{
{"-print", "printOnly", XrmoptionNoArg, (caddr_t)"True"},
{"-fileName", "fileName", XrmoptionSepArg, (caddr_t)NULL},
};
static XtResource VideoResources[] =
{
{"printOnly", "PrintOnly", XmRBoolean, sizeof (Boolean),
XtOffsetOf (VideoShell, print_only), XmRImmediate, (XtPointer)False,
},
{"fileName", "FileName", XmRString, sizeof (char *),
XtOffsetOf (VideoShell, file_name), XmRImmediate, (XtPointer)NULL,
},
};
/*
* static function declarations
*/
static VideoShell* VideoShell_new(Display* display);
/*
* ------------------------------------------------------------------------
* Name: VideoShell_new
*
* Description:
*
* Allocates a new VideoShell data structure.
*
* This function creates a top level application shell on the passed
* video display.
*
* Return value:
*
* A pointer to the new VideoShell structure.
*/
static VideoShell*
VideoShell_new(Display* display)
{
VideoShell* me = (VideoShell*)XtCalloc(1, sizeof(VideoShell));
me->widget = XtVaAppCreateShell(NULL, APP_CLASS,
applicationShellWidgetClass,
display,
XmNtitle, "DtPrint Demo",
NULL);
XtGetApplicationResources(me->widget, me,
VideoResources, XtNumber(VideoResources),
NULL, 0);
return me;
}
/*
* ------------------------------------------------------------------------
* Name: CloseProgramCB
*
* Description:
*
* Exit the program.
*
* Return value:
*
* None.
*/
void
CloseProgramCB(
Widget w,
XtPointer client_data,
XtPointer call_data)
{
AppPrintData * p = (AppPrintData *) client_data ;
/* we want to wait for the current job to complete before exiting */
/* if a job is running, just unmap the windows and install itself
as endjob callback, which will be called when printed_lines is
back to zero */
if (p->printed_lines) {
/* put up a dialog saying it's waiting for the job
to complete */
XtAddCallback(p->print_shell, XmNendJobCallback, CloseProgramCB, p);
} else {
exit(0);
}
}
static String fallbacks[] = {
"Dtprint.Print*background:white",
"Dtprint.Print*renderTable:-dt-application-bold-r-normal-serif-0-0-0-0-p-0-iso8859-1",
"Dtprint.Print*shadowThickness:0",
"Dtprint.Print*highlightThickness:0",
"Dtprint.Print*pform.marginHeight: 1in",
"Dtprint.Print*pform.marginWidth: 1in",
"Dtprint.Print*ptext.Attachment:attach_form",
NULL
};
/*
* ------------------------------------------------------------------------
* Name: main
*
* Description:
*
* "main" function for the DtPrint demo program.
*
*
*/
int main(int argc, char* argv[])
{
XtAppContext app_context;
VideoShell* video_shell;
MainWindow* main_window;
Display* video_display;
AppPrintData* p;
/*
* attempt to open the X video display
*/
XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
XtToolkitInitialize();
app_context = XtCreateApplicationContext();
video_display = XtOpenDisplay(app_context, NULL, NULL, APP_CLASS,
XrmOptions, XtNumber(XrmOptions),
&argc, argv);
XtAppSetFallbackResources(app_context, fallbacks);
if(video_display == (Display*)NULL)
{
/*
* parse command line and determine if "GUI-less" printing is
* desired
*/
/*
* XXX exit for now
*/
fprintf(stderr, "unable to open display\n");
return 1;
}
/*
* Create the top level video shell
*/
video_shell = VideoShell_new(video_display);
/*
* one AppPrintData object per app
*/
p = AppPrintData_new();
p->print_only = video_shell->print_only;
/*
* check to see if we're running the app, or just printing (e.g. from
* within a print action)
*/
if(video_shell->print_only)
{
/*
* create the application-specific object, and add it to the
* AppPrintData structure.
*/
p->app_object = AppObject_new((Widget)NULL, video_shell->file_name);
/*
* create the print setup box as the child of the top level shell
*/
CreatePrintSetup(video_shell->widget, p);
/*
* set the cancel button to exit the program
*/
XtAddCallback(p->print_dialog, DtNcancelCallback, CloseProgramCB, p);
/*
* manage the print setup box
*/
XtManageChild(p->print_dialog);
}
else
{
/*
* create the main window
*/
main_window = MainWindow_new(video_shell->widget);
/*
* add callbacks to the main window
*/
XtAddCallback(main_window->print_menu_button, XmNactivateCallback,
PrintMenuCB, p);
p->pr_button = main_window->print_menu_button;
XtAddCallback(main_window->quick_print_button, XmNactivateCallback,
QuickPrintCB, p);
XtAddCallback(main_window->exit_button, XmNactivateCallback,
CloseProgramCB, p);
/*
* create the application-specific object, and add it to the
* AppPrintData structure.
*/
p->app_object =
AppObject_new(main_window->widget, video_shell->file_name);
/*
* manage the main window
*/
XtManageChild(main_window->widget);
}
/*
* main loop
*/
XtRealizeWidget(video_shell->widget);
XtAppMainLoop(app_context);
/*
* we never get here, but this makes the compiler happy
*/
return 0;
}

View File

@@ -0,0 +1,148 @@
/* $XConsortium: MainWindow.c /main/3 1996/05/09 03:39:51 drk $ */
#include "PrintDemo.h"
/*
* static function declarations
*/
static void MainWindow_createMenuBar(MainWindow* me);
static void MainWindow_createToolBar(MainWindow* me);
/*
* ------------------------------------------------------------------------
* Name: MainWindow_new
*
* Description:
*
* Creates the main window of the DtPrint demo program.
*
* Return value:
*
* A pointer to a new MainWindow structure.
*
*/
MainWindow*
MainWindow_new(Widget parent)
{
MainWindow* me = (MainWindow*)XtCalloc(1, sizeof(MainWindow));
/*
* create the main window
*/
me->widget =
XtVaCreateWidget("MainWindow",
xmMainWindowWidgetClass,
parent,
NULL);
/*
* create the menu bar and tool bar
*/
MainWindow_createMenuBar(me);
MainWindow_createToolBar(me);
/*
* return
*/
return me;
}
/*
* ------------------------------------------------------------------------
* Name: MainWindow_createMenuBar
*
* Description:
*
* Creates the menu bar for the main window of the DtPrint demo
* program.
*
*/
static void
MainWindow_createMenuBar(MainWindow* me)
{
Widget file_menu;
Widget menu_bar;
XmString label;
Widget w;
/*
* create the menu bar
*/
menu_bar = XmCreateMenuBar(me->widget, "MenuBar", NULL, 0);
/*
* create the file menu
*/
file_menu = XmCreatePulldownMenu(menu_bar, "FileMenu", NULL, 0);
/*
* create the file menu cascade button
*/
label = XmStringCreateLocalized("File");
XtVaCreateManagedWidget("FileCascade",
xmCascadeButtonGadgetClass,
menu_bar,
XmNsubMenuId, file_menu,
XmNlabelString, label,
NULL);
XmStringFree(label);
/*
* create the "Print..." file menu item
*/
label = XmStringCreateLocalized("Print...");
me->print_menu_button =
XtVaCreateManagedWidget("PrintButton",
xmPushButtonWidgetClass,
file_menu,
XmNlabelString, label,
NULL);
XmStringFree(label);
/*
* separator
*/
XtVaCreateManagedWidget("", xmSeparatorGadgetClass, file_menu, NULL);
/*
* "Exit" button
*/
label = XmStringCreateLocalized("Exit");
me->exit_button =
XtVaCreateManagedWidget("ExitButton",
xmPushButtonWidgetClass,
file_menu,
XmNlabelString, label,
NULL);
XmStringFree(label);
/*
* manage the menu bar and return it
*/
XtManageChild(menu_bar);
}
/*
* ------------------------------------------------------------------------
* Name: MainWindow_createToolBar
*
* Description:
*
* Creates a simple tool bar for the main window of the DtPrint demo
* program.
*
*/
static void
MainWindow_createToolBar(MainWindow* me)
{
Widget row;
XmString label;
row = XtVaCreateManagedWidget(
"ToolBarRow",
xmRowColumnWidgetClass,
me->widget,
XmNorientation, XmHORIZONTAL,
XmNscrolledWindowChildType, XmCOMMAND_WINDOW,
NULL);
/*
* create just the "quick print" button
*/
label = XmStringCreateLocalized("Quick Print");
me->quick_print_button =
XtVaCreateManagedWidget("QuickPrintButton",
xmPushButtonWidgetClass,
row,
XmNlabelString, label,
NULL);
XmStringFree(label);
}

View File

@@ -0,0 +1,481 @@
/* $XConsortium: Print.c /main/16 1996/11/11 10:56:18 drk $ */
#include "PrintDemo.h"
/*
* static function declarations
*/
static void PrintCB(Widget, XtPointer, XtPointer);
static void DoPrint(Widget widget, AppPrintData * p) ;
static void StartJobCB(Widget, XtPointer, XtPointer);
static void Print(AppPrintData *p);
static void PrintCloseDisplayCB(Widget, XtPointer, XtPointer);
static void PageSetupCB(Widget, XtPointer, XtPointer);
static void PdmNotifyCB(Widget, XtPointer, XtPointer);
static void PrintSetupCB(Widget, XtPointer, XtPointer);
static void FinishPrintToFile(Display*, XPContext, XPGetDocStatus, XPointer);
static void CreatePrintShell(Widget, AppPrintData*);
/*
* ------------------------------------------------------------------------
* Name: PdmNotifyCB
*
* Description:
*
* Called when the PDM is up, or down.
*
*/
static void
PdmNotifyCB(Widget pr_shell, XtPointer client_data, XtPointer call_data)
{
XmPrintShellCallbackStruct* pr_cbs =
(XmPrintShellCallbackStruct*) call_data;
AppPrintData * p = (AppPrintData *) client_data ;
if (pr_cbs->reason == XmCR_PDM_NONE) {
/* put out a real message dialog */
printf("No PDM found in the environment\n");
} else
if (pr_cbs->reason == XmCR_PDM_START_ERROR) {
/* put out a real message dialog */
printf("Cannot start the PDM\n");
} else
if (pr_cbs->reason == XmCR_PDM_START_VXAUTH) {
/* put out a real message dialog */
printf("PDM is not authorized to connect to Video display\n");
} else
if (pr_cbs->reason == XmCR_PDM_START_PXAUTH) {
/* put out a real message dialog */
printf("PDM is not authorized to connect to Print display\n");
}
}
/*
* ------------------------------------------------------------------------
* Name: PrintMenuCB
*
* Description:
*
* Called when the user selects the "Print..." menu item.
*
*/
void
PrintMenuCB(Widget pr_button, XtPointer client_data, XtPointer call_data)
{
AppPrintData* p = (AppPrintData*)client_data;
/* only propose a new print job if one is not already running
shouldn't happen since we put the button insensitive */
if (!p->printed_lines) {
CreatePrintSetup(pr_button, p);
XtManageChild(p->print_dialog); /* popup dialog each time */
} else {
/* real dialog here */
printf("Print job already running\n");
}
}
/*
* ------------------------------------------------------------------------
* Name: CreatePrintShell
*
* Description:
*
* Called when the user selects the "Print" or the "Setup..." button
* in the setupbox.
*
*/
static void CreatePrintShell(Widget widget, AppPrintData* p)
{
/*
* create a print_shell if none available. the print dialog callback
* always provides valid printer context and print display initialized:
* XpInitContext called, attributes set.
*/
if (!p->print_shell) {
p->print_shell =
XmPrintSetup(widget,
XpGetScreenOfContext(p->print_data->print_display,
p->print_data->print_context),
"Print", NULL, 0);
XtAddCallback(p->print_shell, XmNpageSetupCallback,
PageSetupCB, (XtPointer)p);
XtAddCallback(p->print_shell, XmNpdmNotificationCallback,
PdmNotifyCB, (XtPointer)p);
}
}
/*
* ------------------------------------------------------------------------
* Name: PrintSetupCB
*
* Description:
*
* Called when the user presses the setup box "Setup..." button.
*
*/
static void
PrintSetupCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
{
AppPrintData *p = (AppPrintData*)client_data;
DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
int copies ;
XtVaGetValues(print_dialog, DtNcopies, &copies, NULL);
if (copies == 3) {
String attr ;
Display * pdpy = pbs->print_data->print_display ;
XPContext pcontext = pbs->print_data->print_context ;
attr = XpGetAttributes (pdpy, pcontext, XPPageAttr);
if (attr) printf ("XPPageAttr:\n%s\n----------------------\n", attr);
attr = XpGetAttributes (pdpy, pcontext, XPDocAttr);
if (attr) printf ("XPDocAttr:\n%s\n----------------------\n", attr);
attr = XpGetAttributes (pdpy, pcontext, XPJobAttr);
if (attr) printf ("XPJobAttr:\n%s\n----------------------\n", attr);
attr = XpGetAttributes (pdpy, pcontext, XPPrinterAttr);
if (attr) printf ("XPPrinterAttr:\n%s\n----------------------\n", attr);
attr = XpGetAttributes (pdpy, pcontext, XPServerAttr);
if (attr) printf ("XPServerAttr:\n%s\n----------------------\n", attr);
return ;
}
/* copy the setup data into our space */
if (p->print_data->print_display != NULL)
DtPrintFreeSetupData(p->print_data);
DtPrintCopySetupData(p->print_data, pbs->print_data);
/* create a print shell if not already done */
CreatePrintShell(print_dialog, p);
/* pop up the PDM */
if (XmPrintPopupPDM(p->print_shell, XtParent(print_dialog))
!= XmPDM_NOTIFY_SUCCESS) {
/* post a message error dialog */
printf("XmPrintPopupPDM failed\n");
}
/* Free the setup data - use fresh data when Print button pressed. */
DtPrintFreeSetupData(p->print_data);
}
static void
CancelCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
{
AppPrintData *p = (AppPrintData*)client_data;
DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
/* mostly to try it out */
XtDestroyWidget(print_dialog); p->print_dialog = NULL ;
}
/*
* ------------------------------------------------------------------------
* Name: CreatePrintSetup
*
* Description:
*
* Creates a DtPrintSetupBox dialog.
*
*/
void
CreatePrintSetup(Widget parent, AppPrintData* p)
{
/*
* only create one PrintSetupBox
*/
if(!p->print_dialog)
{
Cardinal n = 0;
Arg args[5];
/* can be called when print_only is up, which means no need
for a dialog */
if(XtIsApplicationShell(parent))
p->print_dialog =
DtCreatePrintSetupBox(parent, "PrintSetup", NULL, 0);
else
{
XmString title = XmStringCreateLocalized("Print");
XtSetArg(args[n], XmNdialogTitle, title); n++;
p->print_dialog =
DtCreatePrintSetupDialog(parent, "PrintSetup", args, n);
XmStringFree(title);
}
/*
* allow the application to customize the print setup box
*/
AppObject_customizePrintSetupBox(p->app_object, p->print_dialog);
/*
* add typically used callbacks
*/
XtAddCallback(p->print_dialog, DtNclosePrintDisplayCallback,
PrintCloseDisplayCB, p);
XtAddCallback(p->print_dialog, DtNsetupCallback,
PrintSetupCB, p);
XtAddCallback(p->print_dialog, DtNprintCallback,
PrintCB, p);
XtAddCallback(p->print_dialog, DtNcancelCallback,
CancelCB, p);
/*
* other callbacks, for attributes management, are available
*/
}
}
/*
* ------------------------------------------------------------------------
* Name: PrintCB
*
* Description:
*
* Called when the user presses the setup box "Print" button.
*
*/
static void
PrintCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
{
AppPrintData *p = (AppPrintData*)client_data;
DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
/*
* get the new printer data from the DtPrintSetupBox, and copy it
* into our AppPrint data
*/
if (p->print_data->print_display != NULL)
DtPrintFreeSetupData(p->print_data);
DtPrintCopySetupData(p->print_data, pbs->print_data);
DoPrint(print_dialog, p);
}
/*
* ------------------------------------------------------------------------
* Name: QuickPrintCB
*
* Description:
*
* Called when the user hits "Print" quick button.
*/
void
QuickPrintCB(Widget pr_button, XtPointer client_data, XtPointer call_data)
{
AppPrintData *p = (AppPrintData*)client_data;
CreatePrintSetup(pr_button, p);
/*
* check if the DtPrintSetupBox ("Print...") has been called yet
*/
if(p->print_data->print_display == NULL)
{
/*
* first time thru print setup, so get default data
*/
if (DtPrintFillSetupData(p->print_dialog, p->print_data)
!= DtPRINT_SUCCESS) {
/* post some message error dialog */
printf("DtPrintFillSetupData failed\n");
return ;
}
}
DoPrint(pr_button, p) ;
}
/*
* ------------------------------------------------------------------------
* Name: FinishPrintToFile
*
* Description:
*
* App-specific print data holder allocate function.
*
*/
static void FinishPrintToFile(Display *display,
XPContext context,
XPGetDocStatus status,
XPointer client_data)
{
if (status != XPGetDocFinished)
/* put out a real message dialog */
printf("Something went wrong with XmPrintToFile...\n");
else
printf("XmPrintToFile completed OK\n");
}
/*
* ------------------------------------------------------------------------
* Name: DoPrint
*
* Description:
*
* Routine used from the "Print" button and from the OK button of the
* "Print..." dialog.
*
*/
static void
DoPrint(Widget widget, AppPrintData * p)
{
int save_data = XPSpool;
/* create print shell, if not done yet */
CreatePrintShell(widget, p);
if (p->print_data->destination == DtPRINT_TO_FILE)
save_data = XPGetData;
/* start job must precede XpGetDocumentData in XmPrintToFile */
XpStartJob(XtDisplay(p->print_shell), save_data);
/* setup print to file */
if (p->print_data->destination == DtPRINT_TO_FILE)
{
if (!XmPrintToFile(XtDisplay(p->print_shell),
p->print_data->dest_info, FinishPrintToFile, NULL))
{
/* Add real error message here. */
printf("XmPrintToFile: Unable to print to file %s\n",
p->print_data->dest_info);
XpCancelJob(XtDisplay(p->print_shell), False);
/* we can go back to the event loop as if we had never
printed */
return;
}
}
XtSetSensitive(p->pr_button, False);
}
/*
* ------------------------------------------------------------------------
* Name: PageSetupCB
*
* Description:
*
* Called when the print shell receives the XP events.
*
*/
static void
PageSetupCB(Widget widget, XtPointer client_data, XtPointer call_data)
{
Widget pshell = widget ;
XmPrintShellCallbackStruct* pr_cbs =
(XmPrintShellCallbackStruct*) call_data;
AppPrintData * p = (AppPrintData *) client_data ;
/* could have real indicator of progress here */
printf("Printed Lines %d\n", p->printed_lines);
/* the first time around, create a print text widget and get
line info - equivalent for testing for first page*/
if (!pr_cbs->last_page && !p->printed_lines) {
/* create the widgets once */
if (!p->pform) {
/* create a form widget with some fixed margins */
p->pform = XtVaCreateManagedWidget("pform", xmFormWidgetClass,
pshell, NULL);
/* create a text widget */
p->ptext = XtVaCreateManagedWidget("ptext", xmTextWidgetClass,
p->pform, NULL);
}
/* transfer value from file buffer to print text widget */
XmTextSetString(p->ptext, p->app_object->file_buffer );
/* get lines per page and total lines */
XtVaGetValues(p->ptext, XmNrows, &(p->lines_per_page),
XmNtotalLines, &(p->total_lines), NULL);
p->printed_lines += p->lines_per_page ;
/* If I'm already done: fit in one page, set last_page up */
if (p->printed_lines >= p->total_lines)
pr_cbs->last_page = True ;
/* that will have for effect in the shell to start a page, end it,
and then end the job */
return ;
}
/* if not the first page - see previous test, and not the last
scroll for next page */
if (!pr_cbs->last_page) {
XmTextScroll(p->ptext, p->lines_per_page);
p->printed_lines += p->lines_per_page ;
/* if last page, say it */
if (p->printed_lines >= p->total_lines) pr_cbs->last_page = True ;
} else {
/* job done. reset our counter, and keep print shell around
for next print job, just pop it down
reset the Print... button sensitive */
XtPopdown(pshell);
p->printed_lines = 0 ;
XtSetSensitive(p->pr_button, True);
}
}
/*
* ------------------------------------------------------------------------
* Name: PrintCloseDisplayCB
*
* Description:
*
* Called when the print setup box is about to close the print
* display (in response to a new printer on a different display, or
* when the setup box is destroyed, or from DtPrintResetConnection).
*/
static void
PrintCloseDisplayCB(
Widget widget,
XtPointer client_data,
XtPointer call_data)
{
DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
AppPrintData *p = (AppPrintData*)client_data;
if (p->print_shell)
{
XtDestroyWidget(p->print_shell);
p->print_shell = (Widget)NULL ;
/* must remember that the children are gone, as well */
p->ptext = p->pform = NULL;
}
DtPrintFreeSetupData(p->print_data);
/* that nulls out p->print_data->print_display */
}
/*
* ------------------------------------------------------------------------
* Name: AppPrintData_new
*
* Description:
*
* App-specific print data holder allocate function.
*
*/
AppPrintData*
AppPrintData_new()
{
AppPrintData* p = (AppPrintData*)XtCalloc(1, sizeof(AppPrintData));
p->print_data = (DtPrintSetupData*)XtCalloc(1, sizeof(DtPrintSetupData));
return p;
}

View File

@@ -0,0 +1,65 @@
/* $XConsortium: PrintDemo.h /main/6 1996/05/09 03:40:22 drk $ */
#include <Xm/XmAll.h>
#include <Xm/Print.h>
#include <Dt/Print.h>
#include "AppSpecific.h"
/*
* ------------------------------------------------------------------------
* Module: Print
*
*/
/*
* app specific print data holder
*/
typedef struct _AppPrintData
{
Widget print_dialog;
Widget print_shell;
Widget pr_button;
Boolean print_only;
DtPrintSetupData *print_data;
AppObject* app_object;
/* used during pagesetup callback logic */
int printed_lines ;
int total_lines ;
short lines_per_page ;
Widget ptext, pform;
} AppPrintData;
extern AppPrintData* AppPrintData_new();
/*
* Print module exported functions
*/
extern void CreatePrintSetup(Widget parent, AppPrintData* p);
extern void PrintMenuCB(Widget, XtPointer, XtPointer);
extern void QuickPrintCB(Widget, XtPointer, XtPointer);
/*
* ------------------------------------------------------------------------
* Module: Main
*
*/
extern void CloseProgramCB(Widget, XtPointer, XtPointer);
/*
* ------------------------------------------------------------------------
* Module: MainWindow
*
*/
/*
* MainWindow structure
*/
typedef struct _MainWindow
{
Widget widget;
Widget print_menu_button;
Widget quick_print_button;
Widget exit_button;
} MainWindow;
extern MainWindow* MainWindow_new(Widget parent);

View File

@@ -0,0 +1,70 @@
/* $XConsortium: README.txt /main/3 1996/07/15 14:00:43 drk $ */
-*- text -*-
OVERVIEW
This directory contains example source demonstrating application
printing using the X Print Service, the Motif printing functions,
and the DtPrintSetupBox widget.
FILES
Main.c
Contains main(), etc.
Print.c
Contains printing callbacks and functions that are
conceptually application-independent.
MainWindow.c
Creates a simple top-level main window.
PrintDemo.h
Contains declarations exported by Main, Print, and MainWindow.
AppSpecific.[ch]
Contains application-specific logic.
Imakefile
For use within the CDEnext build tree.
USAGE
dtprint [-fileName <filename>] [-print]
where:
-fileName <filename> is application-specific data to print.
-print indicates that the application should perform the print
operation, then exit when printing is complete. This option is
used for "Print" actions.
STATUS (12/4/95)
What the demo currently *can* do:
The demo currently demostrates how an application that prints
using the X Print Service can incorporate the DtPrintSetupBox
to be used with a "Print..." menu button, a "Quick-Print"
toolbar button, or a "-print" option intended for use within a
"Print" action for an application-specific data type.
The demo can establish connections to X print servers.
The demo recognizes the XPRINTER environment variable and the
XpServerList and XpPrinterNameMode resources.
What the demo currently *does not* do:
The demo does not actally print at this time.
Printing where no video display is available is not
demonstrated at this time. This mode will conceivably be used
for batch printing.
Print rendering in a separate process is not implemented.
The demo currently does not recognize LPDEST, PRINTER,
PDPRINTER, or XpPrinter.

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:48:11 drk $
##########################################################################
#
# Makefile for dtsession examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = screensaver
SOURCES = screensaver.c
OBJECTS = screensaver.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS = -lm
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:48:29 drk $
##########################################################################
#
# Makefile for dtsession examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = screensaver
SOURCES = screensaver.c
OBJECTS = screensaver.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc
X11LIBS = -L/usr/lib -lX11
SYSLIBS = -lm
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:48:47 drk $
##########################################################################
#
# Makefile for dtsession examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = screensaver
SOURCES = screensaver.c
OBJECTS = screensaver.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM -lm
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:49:03 drk $
##########################################################################
#
# Makefile for dtsession examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = screensaver
SOURCES = screensaver.c
OBJECTS = screensaver.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen -lm
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,46 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:49:20 drk $
##########################################################################
#
# Makefile for dtsession examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = screensaver
SOURCES = screensaver.c
OBJECTS = screensaver.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lm
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,98 @@
/* $XConsortium: README /main/3 1996/07/15 14:01:10 drk $ */
This directory contains demonstrations of the Dt Screen Saver API
screensaver - Example of a simple screen saver that uses the DT Screen
Saver API and techniques to make that screen saver
available to all desktop users or your own session.
The desktop provides a set of screen savers for use
in desktop sessions. This set of screen savers can
be previewed and selected from the Style Manager Screen
dialog.
Each screen saver is known to the desktop by the screen
saver's action definition. The screen saver's action
definition provides the desktop with a short localizable
title for the screen saver, as well as the command line
and options required to start the screen saver. When the
desktop starts a screen saver, it is started by invoking a
screen saver action.
The set of screen saver actions available to a user's
desktop session is defined by the DTSCREENSAVERLIST
environment variable. The default DTSCREENSAVERLIST
set is defined when you start a desktop session. A
system administrator can change this set by creating
a script in directory /etc/dt/config/$LANG/Xsession.d
that modifies DTSCREENSAVERLIST. A user can do the
same in their $HOME/.dtprofile.
A desktop screen saver is a simple application that
uses the DtSaverGetWindows() API to obtain a list of
windows, and draws on those windows. The desktop handles
the starting and stopping of the screen saver application.
The 'screensaver' application is an example that shows
how the DtSaverGetWindows() API may be used, how the
screen saver action may be defined for 'screensaver' and
how the screen saver can be integrated into the desktop for
all desktop users or an individual desktop user. The screen
saver action is named SampleScreenSaver and is defined in
/usr/dt/examples/dtscreen/dt/appconfig/types/C/screensaver.dt.
Making the screen saver available to all users
----------------------------------------------
You must be root to make the screen saver available
to all users. This example assumes you are building
'screensaver' directly in /usr/dt/examples/dtscreen.
1) Build the 'screensaver' application
make -f Makefile.<platform>
2) Register the screen saver action with the desktop
dtappintegrate -s /usr/dt/examples/dtscreen
3) Add the screen saver action to the list of available savers
#create file /etc/dt/config/Xsession.d/myvars containing:
DTSCREENSAVERLIST="SampleScreenSaver $DTSCREENSAVERLIST"
4) Make the /etc/dt/config/Xsession.d/myvars file executable:
chmod 755 /etc/dt/config/Xsession.d/myvars
The next time a user starts the desktop, the example screen
saver will be available for use.
Making the screen saver to your own desktop session
---------------------------------------------------
1) Copy the screen saver example to $HOME/dtscreen
cp -r /usr/dt/examples/dtscreen $HOME/dtscreen
cd $HOME/dtscreen
2) Build the 'screensaver' application
make -f Makefile.<platform>
3) Register the screen saver action with the desktop
cp $HOME/dtscreen/dt/appconfig/types/C/screensaver.dt \
$HOME/.dt/types
4) Change the action EXEC_STRING path
vi $HOME/.dt/types/screensaver.dt
#change the EXEC_STRING to '<home>/dtscreen/screensaver',
#replacing <home> with the value of $HOME
5) Add the screen saver action to the list of available savers
#edit $HOME/.dtprofile and add:
DTSCREENSAVERLIST="SampleScreenSaver $DTSCREENSAVERLIST"
The next time a user starts the desktop, the example screen
saver will be available for use.

View File

@@ -0,0 +1,167 @@
/* $XConsortium: screensaver.c /main/3 1995/10/27 10:40:15 rswiston $ */
/************************************/
/** Sample CDE Screen Saver Client **/
/************************************/
#include <locale.h>
#include <stdio.h>
#include <sys/time.h>
#include <math.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <Dt/Saver.h>
#define SS_MAX_COLORS 6
typedef struct {
Window id;
int width;
int height;
unsigned long ssPixels[SS_MAX_COLORS];
Colormap cmap;
GC gc;
} WinDataStruct;
int
usleep(usec)
unsigned long usec;
{
poll((struct poll *) 0, (size_t) 0, usec / 1000); /* milliseconds */
return 0;
}
int main(int argc, char *argv[])
{
Display *dpy; /* Display connection */
Window *winprop = NULL; /* dtsession cover windows */
int nWindows; /* number of windows */
WinDataStruct *perWindow; /* per-window information */
int i, j; /* index variable */
XColor actual, exact; /* color structs */
int colorRotate = 0; /* color rotation counter */
setlocale(LC_ALL, "");
/*******************************/
/** open a display connection **/
/*******************************/
if (!(dpy = XOpenDisplay(NULL)) ) {
fprintf(stderr, "Unable to open the Display.\n");
exit(1);
}
/***********************************************************/
/** Get the list of screen saver windows from the desktop **/
/***********************************************************/
if (!DtSaverGetWindows(dpy, &winprop, &nWindows)) {
fprintf(stderr, "Unable to get screen saver info.\n");
XCloseDisplay(dpy);
exit(1);
}
/******************************************************/
/** allocate an array to hold per window information **/
/******************************************************/
if ( (perWindow = (WinDataStruct *)malloc(nWindows * sizeof(WinDataStruct)))
== NULL) {
fprintf(stderr, "Out of memory.\n");
XCloseDisplay(dpy);
exit(1);
}
/*****************************************************/
/** get things set up for each window we were given **/
/*****************************************************/
for (i = 0; i < nWindows; i++) {
XWindowAttributes attr;
perWindow[i].id = winprop[i];
/*************************************/
/** get information for each window **/
/*************************************/
if (! XGetWindowAttributes(dpy, perWindow[i].id, &attr)) {
fprintf(stderr, "Unable to get window %d attributes.\n",
perWindow[i].id);
free((void *)perWindow);
XCloseDisplay(dpy);
exit(1);
}
/***************************************/
/** save the window info we will need **/
/***************************************/
perWindow[i].width = attr.width;
perWindow[i].height = attr.height;
perWindow[i].cmap = DefaultColormapOfScreen(attr.screen);
perWindow[i].gc = DefaultGCOfScreen(attr.screen);
/***********************************************/
/** Allocate the colors we will use, fallback **/
/** to black and white if necessary **/
/***********************************************/
if (XAllocNamedColor(dpy,perWindow[i].cmap,"red",&actual,&exact)){
perWindow[i].ssPixels[0] = actual.pixel;
} else {
perWindow[i].ssPixels[0] = BlackPixelOfScreen(attr.screen);
}
if (XAllocNamedColor(dpy,perWindow[i].cmap,"orange",&actual,&exact)){
perWindow[i].ssPixels[1] = actual.pixel;
} else {
perWindow[i].ssPixels[1] = WhitePixelOfScreen(attr.screen);
}
if (XAllocNamedColor(dpy,perWindow[i].cmap,"yellow",&actual,&exact)){
perWindow[i].ssPixels[2] = actual.pixel;
} else {
perWindow[i].ssPixels[2] = BlackPixelOfScreen(attr.screen);
}
if (XAllocNamedColor(dpy,perWindow[i].cmap,"green",&actual,&exact)){
perWindow[i].ssPixels[3] = actual.pixel;
} else {
perWindow[i].ssPixels[3] = WhitePixelOfScreen(attr.screen);
}
if (XAllocNamedColor(dpy,perWindow[i].cmap,"blue",&actual,&exact)){
perWindow[i].ssPixels[4] = actual.pixel;
} else {
perWindow[i].ssPixels[4] = BlackPixelOfScreen(attr.screen);;
}
if (XAllocNamedColor(dpy,perWindow[i].cmap,"purple",&actual,&exact)){
perWindow[i].ssPixels[5] = actual.pixel;
} else {
perWindow[i].ssPixels[5] = WhitePixelOfScreen(attr.screen);
}
}
/************************************/
/** OK, now enter our drawing loop **/
/************************************/
while (1) {
/************************/
/** update each window **/
/************************/
for (i = 0; i < nWindows; i++) {
/***************************/
/** for each color we use **/
/***************************/
for (j = 0; j < SS_MAX_COLORS; j++) {
int x, y, width, height;
unsigned long curColor;
curColor = perWindow[i].ssPixels[
(int)fmod((j + colorRotate),SS_MAX_COLORS)];
XSetBackground(dpy, perWindow[i].gc, curColor);
XSetForeground(dpy, perWindow[i].gc, curColor);
x = j * ((perWindow[i].width/2) / (SS_MAX_COLORS));
y = j * ((perWindow[i].height/2) / (SS_MAX_COLORS));
width = perWindow[i].width - (2 * x);
height = perWindow[i].height - (2 * y);
XFillRectangle(dpy, perWindow[i].id, perWindow[i].gc,
x, y, width, height);
}
}
/**XFlush(dpy); **/
XSync(dpy, False);
colorRotate = (int) fmod ((colorRotate + 1), SS_MAX_COLORS);
usleep(200000);
}
}

View File

@@ -0,0 +1,30 @@
###############################################################################
#
# screensaver.dt
#
# Actions for defining screen savers to the Common Desktop Environment.
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
# $XConsortium: screensaver.dt /main/3 1995/10/27 10:40:23 rswiston $
#
###############################################################################
set DtDbVersion=1.0
###################################################################
#
# Actions
#
###################################################################
ACTION SampleScreenSaver
{
LABEL SampleScreenSaver
TYPE COMMAND
WINDOW_TYPE NO_STDIO
EXEC_STRING /usr/dt/examples/dtscreen/screensaver
DESCRIPTION Sample Screen Saver
}

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:49:37 drk $
##########################################################################
#
# Makefile for dtsession examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = session
SOURCES = session.c
OBJECTS = session.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:49:55 drk $
##########################################################################
#
# Makefile for dtsession examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = session
SOURCES = session.c
OBJECTS = session.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:50:10 drk $
##########################################################################
#
# Makefile for dtsession examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = session
SOURCES = session.c
OBJECTS = session.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:50:27 drk $
##########################################################################
#
# Makefile for dtsession examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = session
SOURCES = session.c
OBJECTS = session.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,46 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:50:42 drk $
##########################################################################
#
# Makefile for dtsession examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = session
SOURCES = session.c
OBJECTS = session.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,22 @@
/* $XConsortium: README /main/2 1996/07/15 14:01:36 drk $ */
This directory contains demonstrations of the Dt Session mechanism and API.
session - Example of an application which supports the Dt
session management protocol using the DtSession
API.
The application saves it's current state (the value
of a toggle button) when the session is terminated.
When the session is restarted, the toggle button
state is restored.
The application state saved and restored across sessions
is state information related to the dynamic state of
the application(e.g. current file being edited), as opposed
to static application state (e.g. user preferences.)
To allow the Session Manager to locate this application when
the session is restarted, start the application with its
full pathname as follows:
/usr/dt/examples/dtsession/session &

View File

@@ -0,0 +1,214 @@
/* $XConsortium: session.c /main/3 1995/10/27 10:40:33 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/*
* session.c
*
* Example code for Dt Session Manager conventions and API
*/
#include <stdio.h>
#include <Xm/RowColumn.h>
#include <Xm/ToggleB.h>
#include <Xm/Protocols.h>
#include <Dt/Session.h>
/*
* Define '-session' command line option
*/
typedef struct _ApplicationArgs {
String session;
} ApplicationArgs;
static XtResource applicationResources[] = {
{
"session",
"Session",
XmRString,
sizeof(String),
XtOffsetOf(ApplicationArgs,session),
XmRImmediate,
NULL
},
};
static XrmOptionDescRec commandLineOpts[] = {
{ "-session", "session", XrmoptionSepArg, NULL },
};
static ApplicationArgs applicationArgs;
/*
* Simple application state to be preserved across sessions
*/
static int lightState = False;
/*
* miscellaneous global data
*/
static XtAppContext appContext;
static Widget toplevel;
static int savedArgc;
static char **savedArgv;
static void PreserveCommandLine(int, char **);
static void SetWmCommand(char *);
static void SaveSessionCb(Widget, XtPointer, XtPointer);
static void RestoreSession(Widget, char*);
static void SaveApplicationState(char *);
static void RestoreApplicationState(char *);
main(int argc, char **argv)
{
Widget mainWindow, toggle;
XmString labelString;
Arg args[1];
/* Save the command line before Xt parses out the standard options */
PreserveCommandLine(argc, argv);
/* Create the application UI */
toplevel = XtAppInitialize(&appContext, "Session",
commandLineOpts, XtNumber(commandLineOpts),
&argc, argv,
NULL,
NULL, 0);
XtGetApplicationResources(toplevel, &applicationArgs,
applicationResources,
XtNumber(applicationResources),
NULL, 0);
mainWindow = XmCreateWorkArea(toplevel, "mainWindow", NULL, 0);
XtManageChild(mainWindow);
labelString = XmStringCreateLocalized("Lights");
XtSetArg(args[0], XmNlabelString, labelString);
toggle = XmCreateToggleButton(mainWindow, "lightsToggle", args, 1);
XtManageChild(toggle);
XmStringFree(labelString);
/* Add callback to detect session manager messages */
XmAddWMProtocolCallback(toplevel,
XInternAtom(XtDisplay(toplevel), "WM_SAVE_YOURSELF", False),
SaveSessionCb, (XtPointer)toplevel);
/* Restore state if application was restarted by session manager */
if (applicationArgs.session != NULL) {
RestoreSession(toplevel, applicationArgs.session);
}
XtRealizeWidget(toplevel);
XtAppMainLoop(appContext);
}
/*
* Save session state
*/
static void SaveSessionCb(Widget w, XtPointer cd, XtPointer cb)
{
Widget toplevel = (Widget)cd;
char *savePath = NULL;
char *saveFile = NULL;
DtSessionSavePath(toplevel, &savePath, &saveFile);
if (savePath != NULL) {
SaveApplicationState(savePath);
SetWmCommand(saveFile);
XtFree(savePath);
XtFree(saveFile);
}
}
static void SaveApplicationState(char *path)
{
Widget toggle = XtNameToWidget(toplevel, "*lightsToggle");
FILE *fp;
lightState = XmToggleButtonGetState(toggle);
if ((fp = fopen(path, "w")) != NULL) {
fprintf(fp, "%d", lightState);
fclose(fp);
}
}
static void PreserveCommandLine(int argc, char **argv)
{
int i;
savedArgv = (char **)XtMalloc(argc*sizeof(char *));
savedArgc = argc;
for (i=0; i < argc; i++) savedArgv[i] = XtNewString(argv[i]);
}
static void SetWmCommand(char *sessionId)
{
char **wm_command;
int i, j;
wm_command = (char **) XtMalloc((savedArgc+2) * sizeof(char*));
wm_command[0] = XtNewString(savedArgv[0]);
wm_command[1] = XtNewString("-session");
wm_command[2] = XtNewString(sessionId);
for (i = 1, j = 3; i < savedArgc; i++) {
if (strcmp(savedArgv[i], "-session") == 0) { i++; continue; }
wm_command[j] = XtNewString(savedArgv[i]);
j++;
}
XSetCommand(XtDisplay(toplevel), XtWindow(toplevel), wm_command, j);
for (i=0; i < j; i++) XtFree(wm_command[i]);
XtFree((char*)wm_command);
}
/*
* Restore previously saved state
*/
static void RestoreSession(Widget w, char *restoreFile)
{
char *restorePath = NULL;
DtSessionRestorePath(w, &restorePath, restoreFile);
if (restorePath != NULL) {
RestoreApplicationState(restorePath);
XtFree(restorePath);
}
}
static void RestoreApplicationState(char *path)
{
Widget toggle = XtNameToWidget(toplevel, "*lightsToggle");
FILE *fp;
if ((fp = fopen(path, "r")) != NULL) {
fscanf(fp, "%d", &lightState);
fclose(fp);
}
XmToggleButtonSetState(toggle, lightState, False);
}

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:51:00 drk $
##########################################################################
#
# Makefile for dtterm examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = term
SOURCES = term.c
OBJECTS = term.o
DEFINES = -D_HPUX_SOURCE
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtTerm -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
${CC} -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
${RM} $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.ibm /main/3 1996/05/13 11:51:14 drk $
##########################################################################
#
# Makefile for dtterm examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = term
SOURCES = term.c
OBJECTS = term.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lDtTerm -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:51:28 drk $
##########################################################################
#
# Makefile for dtterm examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = term
SOURCES = term.c
OBJECTS = term.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtTerm -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,45 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:51:45 drk $
##########################################################################
#
# Makefile for dtterm examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = term
SOURCES = term.c
OBJECTS = term.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtTerm -lDtHelp -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,46 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:52:00 drk $
##########################################################################
#
# Makefile for dtterm examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM = term
SOURCES = term.c
OBJECTS = term.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtTerm -lDtHelp -lDtSvc -ltt -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lm
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
clean::
$(RM) $(PROGRAM) $(OBJECTS)

View File

@@ -0,0 +1,8 @@
/* $XConsortium: README /main/2 1996/07/15 14:02:03 drk $ */
This directory contains demonstrations of the DtTerm library.
term - Example application using a DtTerm widget. The application
runs a shell in the terminal window and provides push
button shortcuts for several commands.

140
cde/examples/dtterm/term.c Normal file
View File

@@ -0,0 +1,140 @@
/* $XConsortium: term.c /main/3 1995/10/27 10:40:51 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/*
* term.c
*
* Example code for DtTerm widget
*
* Create a terminal widget running a shell and provide
* push button shortcuts for shell commands. Regular shell
* commands can be entered also.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <Xm/MessageB.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Dt/Term.h>
static Widget toplevel;
static void CreateTerm(Widget, char *);
static void SendCommandCb(Widget, XtPointer, XtPointer);
static void AddCommandButton(Widget, char *, char *);
main(int argc, char **argv)
{
XtAppContext appContext;
Arg args[20];
int n;
XmString labelString;
Widget mainWindow, termContainer, termTitle;
/* Initialize DtTerm widget library */
DtTermInitialize();
toplevel = XtAppInitialize(&appContext, "Term", NULL, 0, &argc, argv,
NULL, NULL, 0);
n = 0;
XtSetArg(args[n], XmNdialogType, XmDIALOG_TEMPLATE); n++;
mainWindow = XmCreateMessageBox(toplevel, "mainWindow", args, n);
XtManageChild(mainWindow);
n = 0;
XtSetArg(args[n], XmNmarginWidth, 10); n++;
XtSetArg(args[n], XmNmarginHeight, 10); n++;
termContainer = XmCreateFrame(mainWindow, "termContainer", args, n);
XtManageChild(termContainer);
labelString = XmStringCreateLocalized("DtTerm with date and time shortcuts");
n = 0;
XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
XtSetArg(args[n], XmNlabelString, labelString); n++;
termTitle = XmCreateLabel(termContainer, "termTitle", args, n);
XtManageChild(termTitle);
XmStringFree(labelString);
/* Create the terminal widget */
CreateTerm(termContainer, "/bin/sh");
/* Add shortcut buttons to the message box */
AddCommandButton(mainWindow, "Today", "date\n");
AddCommandButton(mainWindow, "Month", "cal\n");
AddCommandButton(mainWindow, "1994", "clear;cal 1994\n");
AddCommandButton(mainWindow, "1995", "clear;cal 1995\n");
AddCommandButton(mainWindow, "1996", "clear;cal 1996\n");
AddCommandButton(mainWindow, "1997", "clear;cal 1997\n");
AddCommandButton(mainWindow, "1998", "clear;cal 1998\n");
AddCommandButton(mainWindow, "1999", "clear;cal 1999\n");
AddCommandButton(mainWindow, "2000", "clear;cal 2000\n");
XtRealizeWidget(toplevel);
XtAppMainLoop(appContext);
}
/*
* Create a DtTerm
*/
static void CreateTerm(Widget parent, char *cmd)
{
Widget term;
Arg args[20];
int n;
/*
* Create a DtTerm widget.
* Pass the command to execute.
* Configure the window to fit a calendar year.
*/
n = 0;
XtSetArg(args[n], DtNsubprocessCmd, cmd); n++;
XtSetArg(args[n], DtNrows, 46); n++;
XtSetArg(args[n], DtNcolumns, 80); n++;
term = DtCreateTerm(parent, "term", args, n);
XtManageChild(term);
}
static void AddCommandButton(Widget parent, char *label, char *cmd)
{
XmString labelString;
Arg args[1];
Widget button;
/* Create a pushbutton which will send a command to the terminal */
labelString = XmStringCreateLocalized(label);
XtSetArg(args[0], XmNlabelString, labelString);
button = XmCreatePushButton(parent, label, args, 1);
XtManageChild(button);
XmStringFree(labelString);
XtAddCallback(button, XmNactivateCallback, SendCommandCb, (XtPointer)cmd);
}
static void SendCommandCb(Widget w, XtPointer cd, XtPointer cb)
{
Widget term = XtNameToWidget(toplevel, "*term");
unsigned char *cmd = (unsigned char*)cd;
/* send the pushbutton command to the terminal widget */
DtTermSubprocSend(term, cmd, strlen((char*)cmd));
}

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:52:14 drk $
##########################################################################
#
# Makefile for dtwidget examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = controls
SOURCES1 = controls.c
OBJECTS1 = controls.o
PROGRAM2 = editor
SOURCES2 = editor.c
OBJECTS2 = editor.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtWidget -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:52:29 drk $
##########################################################################
#
# Makefile for dtwidget examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = controls
SOURCES1 = controls.c
OBJECTS1 = controls.o
PROGRAM2 = editor
SOURCES2 = editor.c
OBJECTS2 = editor.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtWidget -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:52:47 drk $
##########################################################################
#
# Makefile for dtwidget examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = controls
SOURCES1 = controls.c
OBJECTS1 = controls.o
PROGRAM2 = editor
SOURCES2 = editor.c
OBJECTS2 = editor.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtWidget -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:53:03 drk $
##########################################################################
#
# Makefile for dtwidget examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = controls
SOURCES1 = controls.c
OBJECTS1 = controls.o
PROGRAM2 = editor
SOURCES2 = editor.c
OBJECTS2 = editor.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtWidget -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,54 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:53:20 drk $
##########################################################################
#
# Makefile for dtwidget examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = controls
SOURCES1 = controls.c
OBJECTS1 = controls.o
PROGRAM2 = editor
SOURCES2 = editor.c
OBJECTS2 = editor.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtWidget -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,8 @@
/* $XConsortium: README /main/2 1996/07/15 14:02:43 drk $ */
This directory contains demonstrations of the DtWidget library.
controls - Examples of DtSpinBox, DtComboBox and DtMenuButton controls.
editor - Example of the DtEditor widget.

View File

@@ -0,0 +1,469 @@
/* $XConsortium: controls.c /main/4 1995/10/27 10:41:00 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/*
* controls.c
*
* Example code for libDtWidget controls
* (ComboBox, SpinBox, MenuButton)
*/
#include <Xm/XmAll.h>
#include <Xm/SSpinB.h>
#include <Dt/ComboBox.h>
#include <Dt/MenuButton.h>
#define ApplicationClass "Controls"
static void CreateSpinBoxes(Widget);
static void CreateComboBoxes(Widget);
static void CreateMenuButtons(Widget);
main(int argc, char **argv)
{
XtAppContext appContext;
Arg args[20];
int n;
Widget toplevel, mainWindow, spinContainer, comboContainer, menuContainer;
toplevel = XtAppInitialize(&appContext, ApplicationClass, NULL, 0,
&argc, argv, NULL, NULL, 0);
n = 0;
XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
XtSetArg(args[n], XmNspacing, 40); n++;
mainWindow = XmCreateWorkArea(toplevel, "mainWindow", args, n);
XtManageChild(mainWindow);
n = 0;
XtSetArg(args[n], XmNspacing, 20); n++;
spinContainer = XmCreateWorkArea(mainWindow, "spinContainer", args, n);
XtManageChild(spinContainer);
CreateSpinBoxes(spinContainer);
n = 0;
XtSetArg(args[n], XmNspacing, 20); n++;
comboContainer = XmCreateWorkArea(mainWindow, "comboContainer", args, n);
XtManageChild(comboContainer);
CreateComboBoxes(comboContainer);
n = 0;
XtSetArg(args[n], XmNspacing, 20); n++;
menuContainer = XmCreateWorkArea(mainWindow, "menuContainer", args, n);
XtManageChild(menuContainer);
CreateMenuButtons(menuContainer);
XtRealizeWidget(toplevel);
XtAppMainLoop(appContext);
}
/*
* Example code for XmSimpleSpinBox
*/
static char *spinValueStrings[] = {
"alpha", "beta", "gamma", "delta",
"epsilon", "zeta", "eta", "theta",
"iota", "kappa", "lambda", "mu",
"nu", "xi", "omicron", "pi",
"rho", "sigma", "tau", "upsilon",
"phi", "chi", "psi", "omega"
};
static void ModifyVerifyCb(Widget, XtPointer, XtPointer);
static void CreateSpinBoxes(Widget parent)
{
Widget titleLabel, spinBox;
XmString *valueXmstrings;
int numValueStrings;
XmString labelString;
Arg args[20];
int i, n;
/* Create value compound strings */
numValueStrings = XtNumber(spinValueStrings);
valueXmstrings = (XmString *)XtMalloc(numValueStrings * sizeof(XmString*));
for (i = 0; i < numValueStrings; i++) {
valueXmstrings[i] = XmStringCreateLocalized(spinValueStrings[i]);
}
/* Create title label */
labelString = XmStringCreateLocalized("SpinBox Widget");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
titleLabel = XmCreateLabel(parent, "title", args, n);
XtManageChild(titleLabel);
XmStringFree(labelString);
/*
* Create a SimpleSpinBox containing string values.
*/
n = 0;
XtSetArg(args[n], XmNvalues, valueXmstrings); n++;
XtSetArg(args[n], XmNnumValues, numValueStrings); n++;
XtSetArg(args[n], XmNcolumns, 10); n++;
spinBox = XmCreateSimpleSpinBox(parent, "spinBox1", args, n);
XtManageChild(spinBox);
/*
* Create a SpinBox containing numeric values to 3 decimal places.
* Position the arrows on either side of the displayed value.
*/
n = 0;
XtSetArg(args[n], XmNspinBoxChildType, XmNUMERIC); n++;
XtSetArg(args[n], XmNminimumValue, 1000); n++;
XtSetArg(args[n], XmNmaximumValue, 100000); n++;
XtSetArg(args[n], XmNincrementValue,1000); n++;
XtSetArg(args[n], XmNdecimalPoints,3); n++;
XtSetArg(args[n], XmNposition,1000); n++;
XtSetArg(args[n], XmNarrowLayout, XmARROWS_SPLIT); n++;
XtSetArg(args[n], XmNcolumns, 10); n++;
spinBox = XmCreateSimpleSpinBox(parent, "spinBox2", args, n);
XtManageChild(spinBox);
/*
* Create a SpinBox containing numeric values to 2 decimal places.
* Position the arrows on the left of the displayed value.
* Disallow alternate user changes by adding a modify/verify callback.
*/
n = 0;
XtSetArg(args[n], XmNspinBoxChildType, XmNUMERIC); n++;
XtSetArg(args[n], XmNminimumValue, 1500); n++;
XtSetArg(args[n], XmNmaximumValue, 60500); n++;
XtSetArg(args[n], XmNincrementValue,1500); n++;
XtSetArg(args[n], XmNdecimalPoints,2); n++;
XtSetArg(args[n], XmNposition,7500); n++;
XtSetArg(args[n], XmNarrowLayout, XmARROWS_FLAT_BEGINNING); n++;
XtSetArg(args[n], XmNcolumns, 10); n++;
spinBox = XmCreateSimpleSpinBox(parent, "spinBox3", args, n);
XtManageChild(spinBox);
XtAddCallback(spinBox, XmNmodifyVerifyCallback, ModifyVerifyCb, NULL);
/*
* Create a SpinBox containing string values.
* Position the arrows on the left of the display value
*/
n = 0;
XtSetArg(args[n], XmNvalues, valueXmstrings); n++;
XtSetArg(args[n], XmNnumValues, numValueStrings); n++;
XtSetArg(args[n], XmNarrowLayout, XmARROWS_BEGINNING); n++;
XtSetArg(args[n], XmNcolumns, 10); n++;
spinBox = XmCreateSimpleSpinBox(parent, "spinBox4", args, n);
XtManageChild(spinBox);
/*
* Create a SpinBox containing numeric values to 3 decimal places.
* Position the arrows on the right of the displayed value.
*/
n = 0;
XtSetArg(args[n], XmNspinBoxChildType, XmNUMERIC); n++;
XtSetArg(args[n], XmNminimumValue, 1000); n++;
XtSetArg(args[n], XmNmaximumValue, 100000); n++;
XtSetArg(args[n], XmNincrementValue,1000); n++;
XtSetArg(args[n], XmNdecimalPoints,3); n++;
XtSetArg(args[n], XmNposition,1000); n++;
XtSetArg(args[n], XmNarrowLayout, XmARROWS_FLAT_END); n++;
XtSetArg(args[n], XmNcolumns, 10); n++;
spinBox = XmCreateSimpleSpinBox(parent, "spinBox5", args, n);
XtManageChild(spinBox);
/*
* Free value strings, SpinBox has taken a copy.
*/
for (i = 0; i < numValueStrings; i++) {
XmStringFree(valueXmstrings[i]);
}
XtFree((char*)valueXmstrings);
}
/*
* modify/verify callback.
*
* Allow/disallow alternate user changes
*/
static void ModifyVerifyCb(Widget w, XtPointer cd, XtPointer cb)
{
XmSpinBoxCallbackStruct *scb= (XmSpinBoxCallbackStruct*)cb;
static Boolean allowChange = True;
scb->doit = allowChange;
if (allowChange == False) {
printf("XmSpinBox: XmNmodifyVerifyCallback. Change disallowed.\n");
XBell(XtDisplay(w), 0);
}
allowChange = (allowChange == True) ? False : True;
}
/*
* Example code for DtComboBox
*/
static char *comboValueStrings[] = {
"alpha", "beta", "gamma", "delta",
"epsilon", "zeta", "eta", "theta",
"iota", "kappa", "lambda", "mu",
"nu", "xi", "omicron", "pi",
"rho", "sigma", "tau", "upsilon",
"phi", "chi", "psi", "omega"
};
static char *colorStrings[] = { "Red", "Yellow", "Green", "Brown", "Blue" };
static void CreateComboBoxes(Widget parent)
{
Widget titleLabel, comboBox, list;
XmString *valueXmstrings, *colorXmstrings;
int numValueStrings, numColorStrings;
XmString labelString, xmString;
Arg args[20];
int i, n;
/* Create value compound strings */
numValueStrings = XtNumber(comboValueStrings);
valueXmstrings = (XmString *)XtMalloc(numValueStrings * sizeof(XmString*));
for (i = 0; i < numValueStrings; i++) {
valueXmstrings[i] = XmStringCreateLocalized(comboValueStrings[i]);
}
/* Create color compound strings */
numColorStrings = XtNumber(colorStrings);
colorXmstrings = (XmString *)XtMalloc(numColorStrings * sizeof(XmString*));
for (i = 0; i < numColorStrings; i++) {
colorXmstrings[i] = XmStringCreateLocalized(colorStrings[i]);
}
/* Create title label */
labelString = XmStringCreateLocalized("ComboBox Widget");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
titleLabel = XmCreateLabel(parent, "title", args, n);
XtManageChild(titleLabel);
XmStringFree(labelString);
/*
* Create an editable ComboBox containing the color strings.
* Get the widget id of the drop down list, add some greek
* letter names to it, and make more items visible.
*/
n = 0;
XtSetArg(args[n], DtNcomboBoxType, DtDROP_DOWN_COMBO_BOX); n++;
XtSetArg(args[n], DtNitems, colorXmstrings); n++;
XtSetArg(args[n], DtNitemCount, numColorStrings); n++;
XtSetArg(args[n], DtNvisibleItemCount, 5); n++;
XtSetArg(args[n], DtNcolumns, 10); n++;
comboBox = DtCreateComboBox(parent, "comboBox1", args, n);
XtManageChild(comboBox);
list = XtNameToWidget(comboBox, "*List");
XmListAddItems(list, valueXmstrings, 10, 0);
XtVaSetValues(list, XmNvisibleItemCount, 10, NULL);
/*
* Create an editable ComboBox with no entries.
* Get the widget id of the drop down list, add some greek
* letter names to it and select the third item in the list.
*/
n = 0;
XtSetArg(args[n], DtNcomboBoxType, DtDROP_DOWN_COMBO_BOX); n++;
XtSetArg(args[n], DtNorientation, DtLEFT); n++;
XtSetArg(args[n], DtNcolumns, 10); n++;
comboBox = DtCreateComboBox(parent, "comboBox2", args, n);
XtManageChild(comboBox);
list = XtNameToWidget(comboBox, "*List");
XmListAddItems(list, valueXmstrings, 7, 0);
XtVaSetValues(list, XmNvisibleItemCount, 7, NULL);
XtVaSetValues(comboBox, DtNselectedPosition, 3, NULL);
/*
* Create a non-editable ComboBox containing some greek letter names.
* Position the arrow on the left.
* Select the 'gamma' item in the list.
*/
n = 0;
XtSetArg(args[n], DtNorientation, DtLEFT); n++;
XtSetArg(args[n], DtNitems, valueXmstrings); n++;
XtSetArg(args[n], DtNitemCount, numValueStrings); n++;
XtSetArg(args[n], DtNvisibleItemCount, 8); n++;
comboBox = DtCreateComboBox(parent, "comboBox3", args, n);
XtManageChild(comboBox);
xmString = XmStringCreateLocalized("gamma");
XtVaSetValues(comboBox, DtNselectedItem, xmString, NULL);
XmStringFree(xmString);
/*
* Create a non-editable ComboBox with no entries.
* Position the arrow on the right.
* Add the greek letter names to the list and select the fourth item.
*/
n = 0;
XtSetArg(args[n], DtNorientation, DtRIGHT); n++;
XtSetArg(args[n], DtNvisibleItemCount, 8); n++;
comboBox = DtCreateComboBox(parent, "comboBox4", args, n);
XtManageChild(comboBox);
for (i = 0; i < numValueStrings; i++) {
DtComboBoxAddItem(comboBox, valueXmstrings[i], 0, True);
}
XtVaSetValues(comboBox, DtNselectedPosition, 4, NULL);
/*
* Free value and color strings, ComboBox has taken a copy.
*/
for (i = 0; i < numValueStrings; i++) {
XmStringFree(valueXmstrings[i]);
}
XtFree((char*)valueXmstrings);
for (i = 0; i < numColorStrings; i++) {
XmStringFree(colorXmstrings[i]);
}
XtFree((char*)colorXmstrings);
}
/*
* Example code for DtMenuButton
*/
/* MenuButton custom glyph */
#define menu_glyph_width 16
#define menu_glyph_height 16
static unsigned char menu_glyph_bits[] = {
0xe0, 0x03, 0x98, 0x0f, 0x84, 0x1f, 0x82, 0x3f, 0x82, 0x3f, 0x81, 0x7f,
0x81, 0x7f, 0xff, 0x7f, 0xff, 0x40, 0xff, 0x40, 0xfe, 0x20, 0xfe, 0x20,
0xfc, 0x10, 0xf8, 0x0c, 0xe0, 0x03, 0x00, 0x00};
static void CreateMenuButtons(Widget parent)
{
Widget menuButton, submenu, titleLabel, button;
Pixmap cascadePixmap;
Pixel fg, bg;
Cardinal depth;
XmString labelString;
Arg args[20];
int i, n;
/* Create title label */
labelString = XmStringCreateLocalized("MenuButton Widget");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
titleLabel = XmCreateLabel(parent, "title", args, n);
XtManageChild(titleLabel);
XmStringFree(labelString);
/*
* Create a MenuButton.
* Add push buttons to the built-in popup menu.
*/
labelString = XmStringCreateLocalized("Action");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
menuButton = DtCreateMenuButton(parent, "menuButton1", args, n);
XtManageChild(menuButton);
XmStringFree(labelString);
XtVaGetValues(menuButton, DtNsubMenuId, &submenu, NULL);
button = XmCreatePushButton(submenu, "Push", NULL, 0);
XtManageChild(button);
button = XmCreatePushButton(submenu, "Pull", NULL, 0);
XtManageChild(button);
button = XmCreatePushButton(submenu, "Turn", NULL, 0);
XtManageChild(button);
/*
* Create a MenuButton.
* Replace the built-in popup menu with a tear-off menu.
* Add a custom pixmap in the colors of the MenuButton.
*/
labelString = XmStringCreateLocalized("Movement");
n = 0;
XtSetArg(args[n], XmNlabelString, labelString); n++;
menuButton = DtCreateMenuButton(parent, "menuButton1", args, n);
XtManageChild(menuButton);
XmStringFree(labelString);
/* Create a tear-off menu */
n = 0;
XtSetArg(args[0], XmNtearOffModel, XmTEAR_OFF_ENABLED); n++;
submenu = XmCreatePopupMenu(menuButton, "submenu", args, n);
button = XmCreatePushButton(submenu, "Run", NULL, 0);
XtManageChild(button);
button = XmCreatePushButton(submenu, "Jump", NULL, 0);
XtManageChild(button);
button = XmCreatePushButton(submenu, "Stop", NULL, 0);
XtManageChild(button);
XtVaSetValues(menuButton, DtNsubMenuId, submenu, NULL);
/* Create a pixmap using the menu button's colors and depth */
XtVaGetValues(menuButton,
XmNforeground, &fg,
XmNbackground, &bg,
XmNdepth, &depth,
NULL);
cascadePixmap = XCreatePixmapFromBitmapData(XtDisplay(menuButton),
DefaultRootWindow(XtDisplay(menuButton)),
(char*)menu_glyph_bits,
menu_glyph_width, menu_glyph_height,
fg, bg, depth);
XtVaSetValues(menuButton, DtNcascadePixmap, cascadePixmap, NULL);
}

View File

@@ -0,0 +1,862 @@
/* $TOG: editor.c /main/4 1998/04/02 18:18:47 rafi $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/*
* editor.c
*
* A simple editor based on the DtEditor widget.
*/
#include <stdio.h>
#include <locale.h>
#include <Xm/XmAll.h>
#include <Dt/Editor.h>
/*
* Constants
*/
#define ApplicationClass "Editor"
/*
* Types
*/
typedef struct _AppData {
XtAppContext appContext;
Display *display;
Widget top;
Widget mainWindow;
Widget menuBar;
Widget editor;
Widget messageTextF;
Widget fileSelectionBox;
Widget cutButton;
Widget copyButton;
Widget clearButton;
Widget deleteButton;
Widget deselectButton;
Widget cutPopupButton;
Widget copyPopupButton;
Boolean wordWrapOn;
Boolean statusLineOn;
Boolean overstrikeModeOn;
} AppData;
/*
* Used to specify whether data is being loaded, inserted, or saved
* from the editor. Used used by the FSB and its callbacks.
*/
typedef enum _LoadSaveType {
LOAD_DATA,
INSERT_DATA,
SAVE_DATA
} LoadSaveType;
/*
* Data
*/
static AppData ad;
/*
* Functions
*/
static void SetResizeHints(void);
static void DisplayMessage(char *);
static Widget CreateMenuBar(Widget);
static Widget CreatePopupMenu(Widget);
static Widget CreateEditor(Widget);
static Widget CreateButton(Widget, String, char, XtCallbackProc, XtPointer);
static Widget CreateToggle(Widget, String, char, XtCallbackProc, XtPointer, Boolean);
static Widget CreateCascade(Widget, String, char, Widget);
static void PopupHandler(Widget, XtPointer, XEvent*, Boolean*);
static void SetSelectionState(Boolean);
/*
* main
*/
void main(int argc, char **argv)
{
Arg al[10];
int ac;
XtSetLanguageProc( (XtAppContext)NULL, (XtLanguageProc)NULL,
(XtPointer)NULL );
/* Initialize the application's data */
ad.fileSelectionBox = (Widget) NULL;
ad.wordWrapOn = False;
ad.statusLineOn = False;
ad.overstrikeModeOn = False;
/* Initialize the toolkit and open the display */
ad.top = XtAppInitialize(&ad.appContext, ApplicationClass, NULL, 0,
&argc, argv, NULL, NULL, 0);
ad.display = XtDisplay(ad.top);
/* Create MainWindow. */
ac = 0;
ad.mainWindow = (Widget) XmCreateMainWindow (ad.top, "main", al, ac);
XtManageChild (ad.mainWindow);
/* Create MenuBar in MainWindow. */
ad.menuBar = CreateMenuBar(ad.mainWindow);
XtManageChild(ad.menuBar);
/* Create editor widget in MainWindow. */
ad.editor = CreateEditor(ad.mainWindow);
XtManageChild(ad.editor);
ad.messageTextF = DtEditorGetMessageTextFieldID(ad.editor);
/* Create the editor popup menu */
CreatePopupMenu(ad.editor);
/* Set the main window widgets. */
XmMainWindowSetAreas(ad.mainWindow, ad.menuBar, NULL, NULL, NULL, ad.editor);
/* Realize toplevel widget */
XtRealizeWidget (ad.top);
/* Set the resize increment and minimum window size properties. */
SetResizeHints();
/* Set up menu buttons dependent on selection */
SetSelectionState(False);
XtAppMainLoop(ad.appContext);
}
/************************************************************************
*
* Callbacks
*
************************************************************************/
/*
* File menu callbacks
*/
static void ResetEditorCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorReset(ad.editor);
}
static void OpenFileCb( Widget w, XtPointer cd, XtPointer cb)
{
DtEditorErrorCode error;
XmFileSelectionBoxCallbackStruct *fcb = (XmFileSelectionBoxCallbackStruct *) cb;
LoadSaveType LoadSaveFlag = (LoadSaveType)cd;
char *name = (char *) XtMalloc( sizeof(char) * fcb->length + 1 );
name[0] ='\0';
/*
* Get the name of the file & pass it to the editor widget
*/
name = XmStringUnparse(fcb->value, NULL, XmCHARSET_TEXT,
XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
/*
* Load or insert the file, as specified
*/
if ( LoadSaveFlag == LOAD_DATA )
error = DtEditorSetContentsFromFile(ad.editor, name);
else
error = DtEditorInsertFromFile(ad.editor, name);
switch (error)
{
case DtEDITOR_NO_ERRORS:
{
DisplayMessage("File loaded");
break;
}
case DtEDITOR_NULLS_REMOVED:
{
DisplayMessage( "All embedded null characters removed from the file" );
break;
}
case DtEDITOR_READ_ONLY_FILE:
{
DisplayMessage( "The file is write protected" );
break;
}
case DtEDITOR_NONEXISTENT_FILE:
{
DisplayMessage( "Could not find file" );
break;
}
case DtEDITOR_DIRECTORY:
{
DisplayMessage( "The name given is a directory" );
break;
}
case DtEDITOR_CHAR_SPECIAL_FILE:
{
DisplayMessage( "The name given is a character special device" );
break;
}
case DtEDITOR_BLOCK_MODE_FILE:
{
DisplayMessage( "The name given is a block mode device");
break;
}
case DtEDITOR_INSUFFICIENT_MEMORY:
{
DisplayMessage( "Not enough available memory to load file");
break;
}
case DtEDITOR_UNREADABLE_FILE:
default:
{
DisplayMessage( "Could not read the file" );
break;
}
}
/*
* Remove the OK callback so it can be added again with a new value for
* the LoadSaveFlag flag.
*/
XtRemoveCallback(w, XmNokCallback, OpenFileCb, cd);
/*
* Remove the FSB dialog & clean up
*/
XtUnmanageChild(w);
XtFree (name);
}
static void SaveAsFileCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorContentRec cr;
DtEditorErrorCode error;
Boolean overWrite = False,
hardCarriageReturns = True,
markContentsAsSaved = True;
XmFileSelectionBoxCallbackStruct *fcb = (XmFileSelectionBoxCallbackStruct *)cb;
LoadSaveType LoadSaveFlag = (LoadSaveType) cd;
char *name = XtMalloc(sizeof(char) * fcb->length + 1 );
name[0] ='\0';
XmStringGetLtoR(fcb->value, XmFONTLIST_DEFAULT_TAG, &name);
/*
* Ask the widget to save its contents to the named file.
*/
error = DtEditorSaveContentsToFile(ad.editor, name, overWrite,
hardCarriageReturns, markContentsAsSaved);
switch(error)
{
case DtEDITOR_NO_ERRORS:
{
DisplayMessage( "The file has been saved" );
break;
}
case DtEDITOR_UNWRITABLE_FILE:
{
DisplayMessage( "The file is read only" );
break;
}
case DtEDITOR_WRITABLE_FILE:
{
DisplayMessage( "File not saved, it already exists" );
break;
}
case DtEDITOR_DIRECTORY:
{
DisplayMessage( "The name given is a directory" );
break;
}
case DtEDITOR_CHAR_SPECIAL_FILE:
{
DisplayMessage( "The name given is a character special device" );
break;
}
case DtEDITOR_BLOCK_MODE_FILE:
{
DisplayMessage( "The name given is a block mode device");
break;
}
case DtEDITOR_SAVE_FAILED:
default:
{
DisplayMessage( "Could not save the file. Check disc space" );
break;
}
}
/*
* Remove the OK callback so it can be added again with a new value for
* the LoadSaveFlag flag.
*/
XtRemoveCallback(w, XmNokCallback, SaveAsFileCb, cd);
/*
* Remove the FSB dialog & clean up
*/
XtUnmanageChild( w );
XtFree (name);
}
static void CancelOpenCb(Widget w, XtPointer cd, XtPointer cb)
{
/* Remove the OK callback so it can be added again with a new value for
* the LoadSaveFlag flag.
*/
XtRemoveCallback(w, XmNokCallback, OpenFileCb, cd);
/* Remove the FSB dialog & clean up */
XtUnmanageChild(w);
}
static void DisplayFsbCb(Widget w, XtPointer cd, XtPointer cb)
{
Arg al[10];
int ac;
XmString tmpStr1, tmpStr2;
LoadSaveType LoadSaveFlag = (LoadSaveType) cd;
/* Create the FSB, if we need to */
if (ad.fileSelectionBox == (Widget) NULL)
{
ac = 0;
ad.fileSelectionBox = XmCreateFileSelectionDialog(ad.mainWindow,
"file_sel_dlg",
al, ac);
XtAddCallback(ad.fileSelectionBox, XmNcancelCallback, CancelOpenCb,
(XtPointer)LoadSaveFlag);
}
/*
* Set FSB title & label depending up whether loading, inserting, or
* saving a container.
*/
switch ( LoadSaveFlag )
{
case LOAD_DATA:
{
tmpStr1 = XmStringCreateLocalized("Open a File");
tmpStr2 = XmStringCreateLocalized("File to open");
/*
* Add the OK callback so the curent value of the LoadSaveFlag
* flag is passed in.
*/
XtAddCallback(ad.fileSelectionBox, XmNokCallback, OpenFileCb,
(XtPointer)LoadSaveFlag);
break;
}
case INSERT_DATA:
{
tmpStr1 = XmStringCreateLocalized("Include a File");
tmpStr2 = XmStringCreateLocalized("File to include");
/*
* Add the OK callback so the curent value of the LoadSaveFlag
* flag is passed in.
*/
XtAddCallback(ad.fileSelectionBox, XmNokCallback, OpenFileCb,
(XtPointer)LoadSaveFlag);
break;
}
case SAVE_DATA:
{
tmpStr1 = XmStringCreateLocalized("Save to File");
tmpStr2 = XmStringCreateLocalized("Save to file");
/*
* Add the OK callback so the save as callback is called.
*/
XtAddCallback(ad.fileSelectionBox, XmNokCallback, SaveAsFileCb,
(XtPointer)LoadSaveFlag);
break;
}
default:
{
break;
}
}
XtVaSetValues(ad.fileSelectionBox,
XmNdialogTitle, tmpStr1,
XmNselectionLabelString, tmpStr1,
NULL);
XmStringFree(tmpStr1);
XmStringFree(tmpStr2);
/* Display the FSB */
XtManageChild (ad.fileSelectionBox);
}
static void ExitCb(Widget w, XtPointer cd, XtPointer cb)
{
exit(0);
}
/*****************************************************
*
* Edit menu callbacks
*
*/
static void UndoCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorUndoEdit(ad.editor);
}
static void CutCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorCutToClipboard(ad.editor);
}
static void CopyCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorCopyToClipboard(ad.editor);
}
static void PasteCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorPasteFromClipboard(ad.editor);
}
static void ClearCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorClearSelection(ad.editor);
}
static void DeleteCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorDeleteSelection(ad.editor);
}
static void SelectAllCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorSelectAll(ad.editor);
}
static void DeselectCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorDeselect(ad.editor);
}
static void FindCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorInvokeFindChangeDialog(ad.editor);
}
static void SpellCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorInvokeSpellDialog(ad.editor);
}
/*****************************************************
*
* Format menu callbacks
*
*/
static void FormatAllCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorFormat(ad.editor, (DtEditorFormatSettings *) NULL,
DtEDITOR_FORMAT_ALL);
}
static void FormatParaCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorFormat(ad.editor, (DtEditorFormatSettings *) NULL,
DtEDITOR_FORMAT_PARAGRAPH);
}
static void InvokeFormatDlgCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorInvokeFormatDialog(ad.editor);
}
/*****************************************************
*
* Options menu callbacks
*
*/
static void OverstrikeCb(Widget w, XtPointer cd, XtPointer cb)
{
ad.overstrikeModeOn = ad.overstrikeModeOn ? False : True;
XtVaSetValues(ad.editor, DtNoverstrike, ad.overstrikeModeOn, NULL);
}
static void StatusLineCb(Widget w, XtPointer cd, XtPointer cb)
{
ad.statusLineOn = ad.statusLineOn ? False : True;
XtVaSetValues(ad.editor, DtNshowStatusLine, ad.statusLineOn, NULL);
/* Reset the resize increment and minimum window size properties. */
SetResizeHints();
}
static void WordWrapCb(Widget w, XtPointer cd, XtPointer cb)
{
ad.wordWrapOn = ad.wordWrapOn ? False : True;
XtVaSetValues(ad.editor, DtNwordWrap, ad.wordWrapOn, NULL);
}
/*****************************************************
*
* Editor callbacks
*
*/
static void HelpCb(Widget w, XtPointer cd, XtPointer cb)
{
DtEditorHelpCallbackStruct *ecb = (DtEditorHelpCallbackStruct *)cb;
DisplayMessage( "Received a request for help");
}
static void TextSelectedCb(Widget w, XtPointer cd, XtPointer cb)
{
SetSelectionState(True);
}
static void TextUnselectedCb(Widget w, XtPointer cd, XtPointer cb)
{
SetSelectionState(False);
}
static void SetSelectionState(Boolean state)
{
XtSetSensitive(ad.cutButton, state);
XtSetSensitive(ad.copyButton, state);
XtSetSensitive(ad.deleteButton, state);
XtSetSensitive(ad.clearButton, state);
XtSetSensitive(ad.deselectButton, state);
XtSetSensitive(ad.cutPopupButton, state);
XtSetSensitive(ad.copyPopupButton, state);
}
/************************************************************************
*
* PROCEDURES
*
************************************************************************/
/************************************************************************
*
* SetResizeHints - Set the resize increment properties
*
*/
static void SetResizeHints(void)
{
XSizeHints sh;
Dimension MBheight;
DtEditorGetSizeHints(ad.editor, &sh);
/*
* Add Menu Bar height to the height of the Editor widget
*/
XtVaGetValues( ad.menuBar, XmNheight, &MBheight, NULL);
sh.min_height += MBheight;
sh.base_height += MBheight;
XSetWMSizeHints(ad.display, XtWindow(ad.top), &sh, XA_WM_NORMAL_HINTS);
}
/************************************************************************
*
* DisplayMessage - Display message in DtEditor's message area
*
*/
static void DisplayMessage(char *message)
{
XmTextFieldSetString(ad.messageTextF, message);
}
/************************************************************************
*
* CreateFileMenu - Create the File pulldown menu
*
*/
static Widget CreateFileMenu(Widget menuBar)
{
Widget fileMenu;
fileMenu = (Widget) XmCreatePulldownMenu (menuBar, "fileMenu", NULL, 0);
CreateCascade(menuBar, "File", 'F', fileMenu);
CreateButton(fileMenu, "New", 'N', ResetEditorCb, NULL);
CreateButton(fileMenu, "Open...", 'O', DisplayFsbCb, (XtPointer)LOAD_DATA);
CreateButton(fileMenu, "Include...", 'I', DisplayFsbCb,
(XtPointer)INSERT_DATA);
XtManageChild(XmCreateSeparatorGadget(fileMenu, "sep1", NULL, 0));
CreateButton(fileMenu, "Save As...", 'A', DisplayFsbCb, (XtPointer)SAVE_DATA);
XtManageChild(XmCreateSeparatorGadget(fileMenu, "sep2", NULL, 0));
CreateButton(fileMenu, "Exit", 'x', ExitCb, NULL);
return (fileMenu);
}
/************************************************************************
*
* CreateEditMenu - Create the Edit pulldown menu
*
*/
static Widget CreateEditMenu(Widget menuBar)
{
Widget editMenu;
editMenu = XmCreatePulldownMenu (menuBar, "editMenu", NULL, 0);
CreateCascade(menuBar, "Edit", 'E', editMenu);
CreateButton(editMenu, "Undo", 'U', UndoCb, NULL);
XtManageChild(XmCreateSeparatorGadget(editMenu, "sep1", NULL, 0));
ad.cutButton = CreateButton(editMenu, "Cut", 't', CutCb, NULL);
ad.copyButton = CreateButton(editMenu, "Copy", 'C', CopyCb, NULL);
CreateButton(editMenu, "Paste", 'P', PasteCb, NULL);
ad.clearButton = CreateButton(editMenu, "Clear", 'e', ClearCb, NULL);
ad.deleteButton = CreateButton(editMenu, "Delete", 't', DeleteCb, NULL);
CreateButton(editMenu, "Select All", 'S', SelectAllCb, NULL);
ad.deselectButton = CreateButton(editMenu, "Deselect", 'D', DeselectCb, NULL);
XtManageChild(XmCreateSeparatorGadget(editMenu, "sep2", NULL, 0));
CreateButton(editMenu, "Find/Change...", 'F', FindCb, (XtPointer)ad.editor);
CreateButton(editMenu, "Check Spelling...", 'p', SpellCb, (XtPointer)ad.editor);
return (editMenu);
}
/************************************************************************
*
* CreateFormatMenu - Create the FormatEdit pulldown menu
*
*/
static Widget CreateFormatMenu(Widget menuBar)
{
Widget formatMenu;
formatMenu = XmCreatePulldownMenu (menuBar, "formatMenu", NULL, 0);
CreateCascade(menuBar, "Format", 'r', formatMenu);
CreateButton(formatMenu, "Settings...", 'S', InvokeFormatDlgCb, NULL);
CreateButton(formatMenu, "All", 'A', FormatAllCb, NULL);
CreateButton(formatMenu, "Paragraph", 'P', FormatParaCb, NULL);
return (formatMenu);
}
/************************************************************************
*
* CreateOptionsMenu - Create the Options pulldown menu
*
*/
static Widget CreateOptionsMenu(Widget menuBar)
{
Widget optionsMenu;
optionsMenu = XmCreatePulldownMenu (menuBar, "optionsMenu", NULL, 0);
CreateCascade(menuBar, "Options", 'O', optionsMenu);
CreateToggle(optionsMenu, "Overstrike", 'O', OverstrikeCb, NULL, ad.overstrikeModeOn);
CreateToggle(optionsMenu, "Word Wrap", 'W', WordWrapCb, NULL,ad.wordWrapOn);
XtManageChild(XmCreateSeparatorGadget(optionsMenu, "sep1", NULL, 0));
CreateToggle(optionsMenu, "Status Line", 'S', StatusLineCb, NULL, ad.statusLineOn);
return (optionsMenu);
}
/*
* CreatePopupMenu - Create popup menu in editor window
*/
static Widget CreatePopupMenu(Widget parent)
{
Widget popupMenu;
Widget fileMenu;
Widget editMenu;
popupMenu = XmCreatePopupMenu(parent, "popupMenu", NULL, 0);
XtAddEventHandler(parent, ButtonPressMask, False, PopupHandler,
(XtPointer)popupMenu);
fileMenu = XmCreatePulldownMenu (popupMenu, "fileMenu", NULL, 0);
CreateCascade(popupMenu, "File", 'F', fileMenu);
CreateButton(fileMenu, "Open...", 'O', DisplayFsbCb, (XtPointer)LOAD_DATA);
CreateButton(fileMenu, "Include...", 'I', DisplayFsbCb,
(XtPointer)INSERT_DATA);
CreateButton(fileMenu, "Save As...", 'A', DisplayFsbCb, (XtPointer)SAVE_DATA);
CreateButton(fileMenu, "New", 'N', ResetEditorCb, NULL);
editMenu = XmCreatePulldownMenu (popupMenu, "editMenu", NULL, 0);
CreateCascade(popupMenu, "Edit", 'E', editMenu);
CreateButton(editMenu, "Undo", 'U', UndoCb, (XtPointer)LOAD_DATA);
ad.cutPopupButton = CreateButton(editMenu, "Cut", 't', CutCb, NULL);
ad.copyPopupButton = CreateButton(editMenu, "Copy", 'C', CopyCb, NULL);
CreateButton(editMenu, "Paste", 'P', PasteCb, NULL);
CreateButton(popupMenu, "Find/Change...", 'F', FindCb, (XtPointer)ad.editor);
return (popupMenu);
}
static void PopupHandler(Widget w, XtPointer cd, XEvent *event, Boolean *ctd)
{
if (((XButtonEvent *)event)->button != Button3) return;
XmMenuPosition((Widget)cd, (XButtonEvent *)event);
XtManageChild ((Widget)cd);
}
/*
* CreateMenuBar - Create MenuBar in MainWindow
*/
static Widget CreateMenuBar(Widget parent)
{
Widget menuBar;
menuBar = XmCreateMenuBar(parent, "menuBar", NULL, 0);
CreateFileMenu(menuBar);
CreateEditMenu(menuBar);
CreateFormatMenu(menuBar);
CreateOptionsMenu(menuBar);
return (menuBar);
}
/*
* CreateEditor - Create the editor widget
*/
static Widget CreateEditor(Widget parent)
{
Widget w;
Arg al[10];
int ac;
/* create editor widget */
ac = 0;
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], DtNrows, 40); ac++;
XtSetArg(al[ac], DtNcolumns, 80); ac++;
w = DtCreateEditor(parent, "editor", al, ac);
/* Add callbacks */
XtAddCallback(w, DtNtextSelectCallback, TextSelectedCb, (XtPointer) w);
XtAddCallback(w, DtNtextDeselectCallback, TextUnselectedCb, (XtPointer) w);
XtAddCallback(w, XmNhelpCallback, HelpCb, NULL);
return(w);
}
static Widget CreateButton(Widget parent, String label, char mnemonic, XtCallbackProc callback, XtPointer callData)
{
Widget button;
XmString labelString;
Arg al[10];
int ac;
labelString = XmStringCreateLocalized(label);
ac = 0;
XtSetArg(al[ac], XmNlabelString, labelString); ac++;
XtSetArg(al[ac], XmNmnemonic, mnemonic); ac++;
button = XmCreatePushButtonGadget(parent, label, al, ac);
XtAddCallback(button, XmNactivateCallback, callback, callData);
XtManageChild(button);
XmStringFree(labelString);
return(button);
}
static Widget CreateToggle(Widget parent, String label, char mnemonic, XtCallbackProc callback, XtPointer callData, Boolean value)
{
Widget button;
XmString labelString;
Arg al[10];
int ac;
labelString = XmStringCreateLocalized(label);
ac = 0;
XtSetArg(al[ac], XmNlabelString, labelString); ac++;
XtSetArg(al[ac], XmNmnemonic, mnemonic); ac++;
XtSetArg(al[ac], XmNvisibleWhenOff, True); ac++;
XtSetArg(al[ac], XmNset, value); ac++;
button = XmCreateToggleButtonGadget(parent, label, al, ac);
XtAddCallback(button, XmNvalueChangedCallback, callback, callData);
XtManageChild(button);
XmStringFree(labelString);
return(button);
}
static Widget CreateCascade(Widget parent, String label, char mnemonic, Widget subMenu)
{
Widget button;
XmString labelString;
Arg al[10];
int ac;
labelString = XmStringCreateLocalized(label);
ac = 0;
XtSetArg(al[ac], XmNlabelString, labelString); ac++;
XtSetArg(al[ac], XmNsubMenuId, subMenu); ac++;
XtSetArg(al[ac], XmNmnemonic, mnemonic); ac++;
button = XmCreateCascadeButtonGadget(parent, label, al, ac);
XtManageChild(button);
XmStringFree(labelString);
return(button);
}

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:53:35 drk $
##########################################################################
#
# Makefile for dtwidget examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:53:53 drk $
##########################################################################
#
# Makefile for dtwidget examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:54:13 drk $
##########################################################################
#
# Makefile for dtwidget examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:54:29 drk $
##########################################################################
#
# Makefile for dtwidget examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,54 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:54:50 drk $
##########################################################################
#
# Makefile for dtwidget examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

11
cde/examples/dtwsm/README Normal file
View File

@@ -0,0 +1,11 @@
/* $XConsortium: README /main/2 1996/07/15 14:03:12 drk $ */
This directory contains demonstrations of the DtWsm API.
occupy - Examples of setting and querying an application's presence
in CDE workspaces.
wsinfo - Examples of querying information about the attributes of the
applications current workspace.

463
cde/examples/dtwsm/occupy.c Normal file
View File

@@ -0,0 +1,463 @@
/* $XConsortium: occupy.c /main/3 1995/10/27 10:41:19 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/* Demonstrate the DtWsm Workspace API. */
/*
* include files
*/
#include <stdio.h>
#include <Xm/XmAll.h>
#include <Dt/Wsm.h>
/*
* functions
*/
void main();
static void quitCB();
static void setCB();
static void showCB();
static void wsCB();
static void allWsCB();
static void SetupWorkspaceButtons ();
static void ShowWorkspaceOccupancy();
static void SetWorkspaceOccupancy();
/*
* global variables
*/
static XmString xms;
static Widget toplevel;
static Widget wChildren [20];
static Widget *wWs;
static Atom *paWsSet = NULL;
static Boolean *pbOccupy;
static unsigned long numWorkspaces;
static Atom *paWs;
/*
* button assignments
*/
#define QUIT_BUTTON (wChildren[0])
#define SEPARATOR (wChildren[1])
#define SET_BUTTON (wChildren[2])
#define SHOW_BUTTON (wChildren[3])
#define ALL_WS_BUTTON (wChildren[4])
#define NUM_CHILDREN 5
/*
* main - main logic for program
*/
void main (argc,argv)
int argc;
char **argv;
{
Widget frame;
Widget form;
Widget top;
XtAppContext app_context;
Arg args[10];
int n;
int i;
/*
* initialize toolkit
*/
n = 0;
XtSetArg (args[n], XmNallowShellResize, True); n++;
toplevel = XtAppInitialize (&app_context, "Dtoccupy", NULL, 0, &argc, argv,
NULL, args, n);
n = 0;
XtSetArg (args[n], XmNmarginWidth, 10); n++;
XtSetArg (args[n], XmNmarginHeight, 10); n++;
frame = XmCreateFrame (toplevel, "frame", args, n);
XtManageChild (frame);
/*
* manager widget
*/
n = 0;
form = XmCreateForm (frame, "form", args, n);
XtManageChild (form);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Quit");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
/*
* create button
*/
top = QUIT_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (QUIT_BUTTON, XmNactivateCallback, quitCB, NULL);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Set Occupancy");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = SET_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (SET_BUTTON, XmNactivateCallback, setCB, NULL);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Occupy All Workspaces");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = ALL_WS_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (ALL_WS_BUTTON, XmNactivateCallback, allWsCB, NULL);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Show Occupancy");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = SHOW_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (SHOW_BUTTON, XmNactivateCallback, showCB, NULL);
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create separator
*/
top = SEPARATOR = (Widget)
XmCreateSeparatorGadget (form, "separator", args, n);
/*
* set up workspace buttons
*/
SetupWorkspaceButtons (form, top);
/*
* manage children
*/
XtManageChildren (wChildren, NUM_CHILDREN);
XtManageChildren (wWs, numWorkspaces);
/*
* realize widgets
*/
XtRealizeWidget (toplevel);
/*
* set up initial workspace occupancy info
*/
pbOccupy = (Boolean *) XtMalloc (numWorkspaces * sizeof (Boolean));
for (i=0; i<numWorkspaces; i++)
{
pbOccupy[i] = False;
}
ShowWorkspaceOccupancy ();
/*
* process events
*/
XtAppMainLoop (app_context);
}
/*-------------------------------------------------------------
* Create a set of buttons for the current set of workspaces
*/
static void SetupWorkspaceButtons (form, top)
Widget form;
Widget top;
{
Window root;
Arg args[10]; /* arg list */
register int n; /* arg count */
register int i;
DtWsmWorkspaceInfo *pWsInfo;
char *pchWs;
Widget left = None;
Widget *pWid;
/*
* get workspace information
*/
root = XRootWindowOfScreen(XtScreen(form));
if (DtWsmGetWorkspaceList (XtDisplay(form), root,
&paWs, (int *)&numWorkspaces) == Success)
{
wWs = (Widget *) XtMalloc (numWorkspaces * sizeof (Widget));
pWid = wWs;
for (i=0; i<numWorkspaces; i++, pWid++)
{
DtWsmGetWorkspaceInfo (XtDisplay(form), root, paWs[i],
&pWsInfo);
pchWs = (char *) XmGetAtomName (XtDisplay(form),
pWsInfo->workspace);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized(pchWs);
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNindicatorOn, True); n++;
XtSetArg (args[n], XmNindicatorType, XmN_OF_MANY); n++;
if (left == None)
{
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
}
else
{
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, left); n++;
}
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
*pWid = XtCreateWidget ("button", xmToggleButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (*pWid, XmNvalueChangedCallback, wsCB,
(XtPointer) i);
left = *pWid;
}
}
else
{
fprintf(stderr, "Failed to get workspace info -- dtwm not running!\n");
exit (1);
}
}
/*-------------------------------------------------------------
* Update the workspace buttons with where we are now.
*/
static void ShowWorkspaceOccupancy ()
{
Arg args[10]; /* arg list */
register int n; /* arg count */
int i,j;
Atom *paWsIn = NULL;
unsigned long numWsIn;
int rval;
rval = DtWsmGetWorkspacesOccupied(XtDisplay(toplevel),
XtWindow(toplevel), &paWsIn, &numWsIn );
if (rval == Success)
{
for (i = 0; i<numWorkspaces; i++)
{
pbOccupy[i] = False;
for (j=0; j<numWsIn; j++)
{
if (paWs[i] == paWsIn[j])
{
pbOccupy[i] = True;
break;
}
}
}
for (i = 0; i<numWorkspaces; i++)
{
n = 0;
if (pbOccupy[i])
{
XtSetArg (args[n], XmNset, True); n++;
}
else
{
XtSetArg (args[n], XmNset, False); n++;
}
XtSetValues (wWs[i], args, n);
}
if (paWsIn) XFree ((char *) paWsIn);
}
}
/*-------------------------------------------------------------
* quitCB - callback for button
*/
static void quitCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
exit (0);
}
/*-------------------------------------------------------------
* showCB - callback for show occupancy button
*/
static void showCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
ShowWorkspaceOccupancy();
}
/*-------------------------------------------------------------
* setCB - callback for set occupancy button
*/
static void setCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
int numSet;
int i;
if (!paWsSet)
{
paWsSet = (Atom *) XtMalloc (numWorkspaces * sizeof(Atom));
}
for (i=0, numSet=0; i<numWorkspaces; i++)
{
if (pbOccupy[i])
{
paWsSet[numSet++] = paWs[i];
}
}
DtWsmSetWorkspacesOccupied (XtDisplay(toplevel),
XtWindow(toplevel), paWsSet, numSet);
}
/*-------------------------------------------------------------
* wsCB - callback for set occupancy button
*/
static void wsCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
int i = (Atom) client_data; /* ws array index */
XmToggleButtonCallbackStruct *ptb =
(XmToggleButtonCallbackStruct *) call_data;
if (ptb->reason == XmCR_VALUE_CHANGED)
{
if (ptb->set)
{
pbOccupy[i] = True;
}
else
{
pbOccupy[i] = False;
}
}
}
/*-------------------------------------------------------------
* allWsCB - callback for occupy all button
*/
static void allWsCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
DtWsmOccupyAllWorkspaces (XtDisplay(toplevel), XtWindow(toplevel));
}

618
cde/examples/dtwsm/wsinfo.c Normal file
View File

@@ -0,0 +1,618 @@
/* $XConsortium: wsinfo.c /main/3 1995/10/27 10:41:27 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/* Demonstrate the CDE Workspace API. */
/*
* include files
*/
#include <stdio.h>
#include <Xm/XmAll.h>
#include <Dt/Wsm.h>
/*
* functions
*/
void main();
static void quitCB();
static void updateCB();
static void ShowCurrentWorkspaceInfo();
static DtWsmWsChangeProc wschangecb();
static void InstallXErrorHandler();
/*
* global variables
*/
static Widget toplevel;
static Widget wChildren[20];
/*
* button assignments
*/
#define QUIT_BUTTON (wChildren[0])
#define UPDATE_BUTTON (wChildren[1])
#define SEPARATOR (wChildren[2])
#define WS_LABEL (wChildren[3])
#define WS_VALUE (wChildren[4])
#define TITLE_LABEL (wChildren[5])
#define TITLE_VALUE (wChildren[6])
#define BACKDROP_LABEL (wChildren[7])
#define BACKDROP_VALUE (wChildren[8])
#define COLORSET_LABEL (wChildren[9])
#define COLORSET_VALUE (wChildren[10])
#define SEPARATOR2 (wChildren[11])
#define NUM_CHILDREN 12
/*
* main - main logic for program
*/
void main (argc,argv)
int argc;
char **argv;
{
Widget frame;
Widget form;
Widget top;
XtAppContext app_context;
Arg args[10];
register int n;
register int i;
XmString xms, xmsBlank;
/*
* initialize toolkit
*/
n = 0;
XtSetArg (args[n], XmNallowShellResize, True); n++;
toplevel = XtAppInitialize (&app_context, "Dtwsinfo", NULL, 0, &argc, argv,
NULL, args, n);
/*
* Set up X error handling
*/
InstallXErrorHandler ();
n = 0;
XtSetArg (args[n], XmNmarginWidth, 10); n++;
XtSetArg (args[n], XmNmarginHeight, 10); n++;
frame = XmCreateFrame (toplevel, "frame", args, n);
XtManageChild (frame);
/*
* manager widget
*/
n = 0;
form = XmCreateForm (frame, "form", args, n);
XtManageChild (form);
/*
* create compound string for blank labels
*/
xmsBlank = XmStringCreateLocalized(" ");
/*******************************************
* QUIT BUTTON
******************************************/
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Quit");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
/*
* create button
*/
top = QUIT_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (QUIT_BUTTON, XmNactivateCallback, quitCB, NULL);
/*******************************************
* UPDATE WORKSPACE INFO BUTTON
******************************************/
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Get workspace info");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = UPDATE_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (UPDATE_BUTTON, XmNactivateCallback, updateCB, NULL);
/*******************************************
* SEPARATOR
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create separator
*/
top = SEPARATOR = (Widget)
XmCreateSeparatorGadget (form, "separator", args, n);
/*******************************************
* LABEL FOR CURRENT WORKSPACE
******************************************/
/*
* NOTE: We assume this is the longest label and lay out the
* other fields based on this assumption.
*/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized("Current workspace: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
WS_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree (xms);
/*******************************************
* VALUE FOR CURRENT WORKSPACE
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = WS_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* LABEL FOR WORKSPACE TITLE
******************************************/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized(" title: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
TITLE_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree(xms);
/*******************************************
* VALUE FOR WORKSPACE TITLE
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, TITLE_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = TITLE_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* LABEL FOR WORKSPACE BACKDROP
******************************************/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized(" backdrop: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
BACKDROP_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree (xms);
/*******************************************
* VALUE FOR WORKSPACE BACKDROP
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, BACKDROP_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = BACKDROP_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* LABEL FOR WORKSPACE COLORSET ID
******************************************/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized(" color set id: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
COLORSET_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree (xms);
/*******************************************
* VALUE FOR WORKSPACE COLORSET ID
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, COLORSET_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = COLORSET_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* SEPARATOR
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create separator
*/
top = SEPARATOR2 = (Widget)
XmCreateSeparatorGadget (form, "separator", args, n);
/*
* manage children
*/
XtManageChildren (wChildren, NUM_CHILDREN);
/*
* Show info on current workspace
*/
ShowCurrentWorkspaceInfo ();
/*
* realize widgets
*/
XtRealizeWidget (toplevel);
/*
* Do these calls after the shell is realized.
* They need a window created for the top level shell.
*
* HINT: See XtSetMappedWhenManaged(1) if you want to
* realize a widget to get a window, but need to
* control when the map of the window occurs.
*/
(void) DtWsmAddCurrentWorkspaceCallback (toplevel,
(DtWsmWsChangeProc) wschangecb, NULL);
DtWsmOccupyAllWorkspaces (XtDisplay(toplevel), XtWindow(toplevel));
/*
* process events
*/
XtAppMainLoop (app_context);
}
/*-------------------------------------------------------------
* Update the information for the current workspace
*/
static void ShowCurrentWorkspaceInfo ()
{
Arg args[10]; /* arg list */
register int n; /* arg count */
Atom aWs;
int rval;
Display *dpy;
Window root;
DtWsmWorkspaceInfo *pWsInfo;
XmString xms;
char pch[512];
char *pchName;
dpy = XtDisplay(toplevel);
root = XDefaultRootWindow(dpy);
rval = DtWsmGetCurrentWorkspace(dpy, root, &aWs);
if (rval == Success)
{
rval = DtWsmGetWorkspaceInfo (dpy, root, aWs, &pWsInfo);
if (rval == Success)
{
/* workspace name */
pchName = XmGetAtomName (dpy, pWsInfo->workspace);
xms = XmStringCreateLocalized(pchName);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (WS_VALUE, args, n);
XmStringFree (xms);
XtFree (pchName);
/* workspace title */
xms = XmStringCreateLocalized(pWsInfo->pchTitle);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (TITLE_VALUE, args, n);
XmStringFree (xms);
/* workspace backdrop name */
if (pWsInfo->backdropName != None)
pchName = XmGetAtomName (dpy, pWsInfo->backdropName);
else
pchName = "<failed to load!>";
xms = XmStringCreateLocalized(pchName);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (BACKDROP_VALUE, args, n);
XmStringFree (xms);
if (pWsInfo->backdropName != None)
XtFree (pchName);
/* workspace colorset id */
sprintf (pch, "%d", pWsInfo->colorSetId);
xms = XmStringCreateLocalized(pch);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (COLORSET_VALUE, args, n);
XmStringFree (xms);
DtWsmFreeWorkspaceInfo (pWsInfo);
}
}
if (rval != Success)
{
fprintf (stderr, "Failed to get workspace information.\n");
fprintf (stderr, "Is dtwm running?\n");
exit (1);
}
}
/*-------------------------------------------------------------
* quitCB - callback for button
*/
static void quitCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
exit (0);
}
/*-------------------------------------------------------------
* updateCB - callback for show current workspace info
*/
static void updateCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
ShowCurrentWorkspaceInfo ();
}
/*-------------------------------------------------------------
** wschangecb - callback for workspace switch
*/
static DtWsmWsChangeProc
wschangecb (w, atom, client_data)
Widget w;
Atom atom;
XtPointer client_data;
{
ShowCurrentWorkspaceInfo ();
}
/*-------------------------------------------------------------
** data for X error handler
*/
#define E_MAJOR_CODE 0
#define E_MINOR_CODE 1
#define E_RESOURCE_ID 2
#define E_ERROR_SERIAL 3
#define E_CURRENT_SERIAL 4
#define NUM_E_STRINGS 5
static char *pchErrorFormatNames [NUM_E_STRINGS] = {
"MajorCode",
"MinorCode",
"ResourceID",
"ErrorSerial",
"CurrentSerial"
};
static char *pchErrorFormat [NUM_E_STRINGS];
/*-------------------------------------------------------------
** HandleXErrors - catch X protocol errors
*/
static int
_HandleXErrors (display, errorEvent)
Display *display;
XErrorEvent *errorEvent;
{
char buffer[BUFSIZ];
char message[BUFSIZ];
XGetErrorText (display, errorEvent->error_code, buffer, BUFSIZ);
fprintf (stderr, "\n*** X error occurred ***\n");
fprintf (stderr, "Description = '%s'\n ", buffer);
fprintf (stderr, pchErrorFormat[E_MAJOR_CODE], errorEvent->request_code);
sprintf(message, "%d", errorEvent->request_code);
XGetErrorDatabaseText (display, "XRequest", message, " ", buffer, BUFSIZ);
fprintf (stderr, " (%s)\n ", buffer);
fprintf (stderr, pchErrorFormat[E_MINOR_CODE], errorEvent->minor_code);
fprintf (stderr, "\n ");
fprintf (stderr, pchErrorFormat[E_RESOURCE_ID], errorEvent->resourceid);
fprintf (stderr, "\n ");
fprintf (stderr, pchErrorFormat[E_ERROR_SERIAL], errorEvent->serial);
fprintf (stderr, "\n ");
fprintf (stderr, pchErrorFormat[E_CURRENT_SERIAL],
LastKnownRequestProcessed(display));
fprintf (stderr, "\n");
return (0);
}
/*-------------------------------------------------------------
** Setup the X error handler
*/
static void
InstallXErrorHandler ( display )
Display *display;
{
char buffer[BUFSIZ];
int i;
/*
* Fetch the X error format strings from XErrorDB
*/
for (i = 0; i< NUM_E_STRINGS; i++)
{
XGetErrorDatabaseText (display, "XlibMessage",
pchErrorFormatNames[i], " %d ", buffer, BUFSIZ);
pchErrorFormat[i] = (char *) XtMalloc (1+strlen(buffer));
strcpy(pchErrorFormat[i], buffer);
}
XSetErrorHandler (_HandleXErrors);
}

View File

@@ -0,0 +1,52 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:55:06 drk $
##########################################################################
#
# Makefile for Motif clipboard examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
UIL = /usr/dt/bin/uil
PROGRAM = cutpaste
SOURCES = cutpaste.c
OBJECTS = cutpaste.o
UID = cutpaste.uid
UILSOURCE = cutpaste.uil
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lMrm -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM) $(UID)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
$(UID):: $(UILSOURCE)
$(UIL) -o $(UID) $(UILSOURCE)
clean::
$(RM) $(PROGRAM) $(OBJECTS) $(UID)

View File

@@ -0,0 +1,51 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:55:26 drk $
##########################################################################
#
# Makefile for Motif clipboard examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
UIL = /usr/dt/bin/uil
PROGRAM = cutpaste
SOURCES = cutpaste.c
OBJECTS = cutpaste.o
UID = cutpaste.uid
UILSOURCE = cutpaste.uil
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lMrm -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM) $(UID)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
$(UID):: $(UILSOURCE)
$(UIL) -o $(UID) $(UILSOURCE)
clean::
$(RM) $(PROGRAM) $(OBJECTS) $(UID)

View File

@@ -0,0 +1,52 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:55:41 drk $
##########################################################################
#
# Makefile for Motif clipboard examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
UIL = /usr/dt/bin/uil
PROGRAM = cutpaste
SOURCES = cutpaste.c
OBJECTS = cutpaste.o
UID = cutpaste.uid
UILSOURCE = cutpaste.uil
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lMrm -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM) $(UID)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
$(UID):: $(UILSOURCE)
$(UIL) -o $(UID) $(UILSOURCE)
clean::
$(RM) $(PROGRAM) $(OBJECTS) $(UID)

View File

@@ -0,0 +1,51 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:55:58 drk $
##########################################################################
#
# Makefile for Motif clipboard examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
UIL = /usr/dt/bin/uil
PROGRAM = cutpaste
SOURCES = cutpaste.c
OBJECTS = cutpaste.o
UID = cutpaste.uid
UILSOURCE = cutpaste.uil
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lMrm -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM) $(UID)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
$(UID):: $(UILSOURCE)
$(UIL) -o $(UID) $(UILSOURCE)
clean::
$(RM) $(PROGRAM) $(OBJECTS) $(UID)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:56:16 drk $
##########################################################################
#
# Makefile for Motif clipboard examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
UIL = /usr/dt/bin/uil
PROGRAM = cutpaste
SOURCES = cutpaste.c
OBJECTS = cutpaste.o
UID = cutpaste.uid
UILSOURCE = cutpaste.uil
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lMrm -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM) $(UID)
$(PROGRAM):: $(OBJECTS)
$(CC) -o $(PROGRAM) $(LDFLAGS) $(OBJECTS) $(LIBRARIES)
$(UID):: $(UILSOURCE)
$(UIL) -o $(UID) $(UILSOURCE)
clean::
$(RM) $(PROGRAM) $(OBJECTS) $(UID)

View File

@@ -0,0 +1,9 @@
/* $XConsortium: README /main/2 1996/07/15 14:03:37 drk $ */
This directory contains demonstrations of the Motif Clipboard.
cutpaste - Examples of cutting and pasting application defined
data formats using the XmClipboard API.
Run two cutpaste clients, and transfer graph values
using the pulldown and popup menus.

View File

@@ -0,0 +1,306 @@
/* $XConsortium: cutpaste.c /main/4 1995/10/27 10:41:39 rswiston $ */
/*
* (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
* ALL RIGHTS RESERVED
*/
/*
* Motif Release 1.2
*/
/******************************************************************************
* cutpaste.c
*
*
*****************************************************************************/
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/CutPaste.h>
#include <Mrm/MrmPublic.h>
static Boolean CopyToClipboard(
Time time);
static Boolean PasteClipboard(
Time time );
static void PopupHandler(
Widget w,
Widget pw,
XEvent *event,
Boolean *ctd );
static void ManageCb(
Widget w,
String id,
XtPointer cb );
static void InitPopupCb(
Widget w,
String id,
XtPointer cb );
static void CutCb(
Widget w,
XtPointer cd,
XmPushButtonCallbackStruct *cb );
static void CopyCb(
Widget w,
XtPointer cd,
XmPushButtonCallbackStruct *cb );
static void PasteCb(
Widget w,
XtPointer cd,
XmPushButtonCallbackStruct *cb );
static void ExitCb(
Widget w,
XtPointer cd,
XtPointer cb );
static MrmHierarchy mrm_id;
static char *mrm_vec[]={"cutpaste.uid"};
static MrmCode mrm_class;
static MRMRegisterArg mrm_names[] = {
{"InitPopupCb", (XtPointer)InitPopupCb },
{"ManageCb", (XtPointer)ManageCb },
{"CutCb", (XtPointer)CutCb },
{"CopyCb", (XtPointer)CopyCb },
{"PasteCb", (XtPointer)PasteCb },
{"ExitCb", (XtPointer)ExitCb }
};
#define GraphFormat "MY_GRAPH_DATA"
#define MIN(x,y) ((x) > (y) ? (y) : (x))
static XtAppContext appContext;
static Widget shell;
static Widget *bars;
static Cardinal nbars;
int
main(
int argc,
char *argv[] )
{
Widget app_main;
Display *display;
Arg args[2];
Widget *children;
XtToolkitInitialize();
MrmInitialize ();
appContext = XtCreateApplicationContext();
display = XtOpenDisplay(appContext, NULL, argv[0], "Cutpaste",
NULL, 0, &argc, argv);
if (display == NULL) {
fprintf(stderr, "%s: Can't open display\n", argv[0]);
exit(1);
}
shell = XtAppCreateShell(argv[0], NULL, applicationShellWidgetClass,
display, NULL, 0);
if (MrmOpenHierarchy (1, mrm_vec, NULL, &mrm_id) != MrmSUCCESS) exit(0);
MrmRegisterNames(mrm_names, XtNumber(mrm_names));
MrmFetchWidget (mrm_id, "appMain", shell, &app_main, &mrm_class);
XtManageChild(app_main);
/* define graph data format */
while (XmClipboardRegisterFormat (display, GraphFormat, 32) ==
XmClipboardLocked) { }
XtSetArg (args[0], XmNchildren, &children);
XtSetArg (args[1], XmNnumChildren, &nbars);
XtGetValues (XtNameToWidget (shell, "*graphForm"), args, 2);
bars = (Widget *) XtMalloc (nbars * sizeof(Widget));
memcpy (bars, children, nbars * sizeof(Widget));
XtRealizeWidget(shell);
XtAppMainLoop(appContext);
}
static void
ManageCb(
Widget w,
String id,
XtPointer cb )
{
XtManageChild (XtNameToWidget (shell, id));
}
static void
ExitCb(
Widget w,
XtPointer cd,
XtPointer cb )
{
exit(0);
}
/*****************************************************************
*
* PopupMenu support
*
*****************************************************************/
static void
InitPopupCb(
Widget w,
String id,
XtPointer cb )
{
Widget popupWindow = XtNameToWidget (shell, id);
XtAddEventHandler (popupWindow, ButtonPressMask, False,
(XtEventHandler)PopupHandler, (XtPointer) w);
}
static void
PopupHandler (
Widget w,
Widget pw,
XEvent *event,
Boolean *ctd )
{
if (((XButtonEvent *)event)->button != Button3) return;
XmMenuPosition((Widget) pw, (XButtonEvent *)event);
XtManageChild ((Widget) pw);
}
/*****************************************************************
*
* Clipboard support
*
*****************************************************************/
static void
CutCb(
Widget w,
XtPointer cd,
XmPushButtonCallbackStruct *cb )
{
XButtonEvent *be = (XButtonEvent *)cb->event;
Arg args[1];
int i;
if (CopyToClipboard(be->time) == True) {
/* clear graph data */
XtSetArg (args[0], XmNvalue, 0);
for (i=0; i < nbars; i++)
XtSetValues (bars[i], args, 1);
}
else {
XBell (XtDisplay(w), 0);
}
}
static void
CopyCb(
Widget w,
XtPointer cd,
XmPushButtonCallbackStruct *cb )
{
XButtonEvent *be = (XButtonEvent *)cb->event;
if (CopyToClipboard(be->time) != True) {
XBell (XtDisplay(w), 0);
}
}
static void
PasteCb(
Widget w,
XtPointer cd,
XmPushButtonCallbackStruct *cb )
{
XButtonEvent *be = (XButtonEvent *)cb->event;
if (PasteClipboard(be->time) != True) {
XBell (XtDisplay(w), 0);
}
}
static Boolean
CopyToClipboard(
Time time )
{
Display *dpy = XtDisplay (shell);
Window window = XtWindow (shell);
long itemId = 0;
XmString clipLabel;
long *graphData;
int value;
int i;
Arg args[1];
if (XmClipboardLock (dpy, window) == XmClipboardLocked)
return (False);
clipLabel = XmStringCreateLtoR ("cutpaste", XmFONTLIST_DEFAULT_TAG);
XmClipboardStartCopy ( dpy, window, clipLabel, time, NULL, NULL, &itemId);
/* copy graph data */
graphData = (long *)XtMalloc (nbars * sizeof (long));
XtSetArg (args[0], XmNvalue, &value);
for (i=0; i < nbars; i++) {
XtGetValues (bars[i], args, 1);
graphData[i] = (long)value;
}
XmClipboardCopy (dpy, window, itemId, GraphFormat, (XtPointer)graphData,
(nbars * sizeof(long)), 0, NULL);
XmClipboardEndCopy (dpy, window, itemId);
XmClipboardUnlock (dpy, window, False);
XtFree ((char *)clipLabel);
XtFree ((char *)graphData);
return (True);
}
static Boolean
PasteClipboard(
Time time )
{
Display *dpy = XtDisplay (shell);
Window window = XtWindow (shell);
unsigned long length = 0;
long *graphData;
int i;
int setBars;
Arg args[1];
if (XmClipboardStartRetrieve (dpy, window, time) == XmClipboardLocked)
return (False);
XmClipboardInquireLength(dpy, window, GraphFormat, &length);
if (length == 0) {
XmClipboardEndRetrieve (dpy, window);
return (False);
}
graphData = (long *)XtMalloc (length * sizeof (long));
XmClipboardRetrieve(dpy, window, GraphFormat, graphData, length,
NULL, NULL);
XmClipboardEndRetrieve(dpy, window);
setBars = MIN (nbars, length);
for (i = 0; i < setBars; i++) {
XtSetArg (args[0], XmNvalue, graphData[i]);
XtSetValues (bars[i], args, 1);
}
XtFree ((char *)graphData);
return (True);
}

View File

@@ -0,0 +1,293 @@
! (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
! ALL RIGHTS RESERVED
!
! Motif Release 1.2.2
module cutpaste
version = 'v1.2'
names = case_sensitive
character_set=iso_latin1
objects = {
XmLabel = widget;
XmPushButton = widget;
XmToggleButton = widget;
XmCascadeButton = widget;
XmSeparator = widget;
}
include file ("cutpaste_local.uil");
procedure
InitPopupCb(string);
ManageCb(string);
CutCb();
CopyCb();
PasteCb();
ExitCb();
list scrollArgs : arguments {
XmNleftAttachment = XmATTACH_POSITION;
XmNrightAttachment = XmATTACH_POSITION;
XmNtopAttachment = XmATTACH_FORM;
XmNbottomAttachment = XmATTACH_FORM;
XmNshowArrows = false;
XmNsliderSize = 5;
XmNtraversalOn = true;
XmNhighlightThickness = 1;
XmNprocessingDirection = XmMAX_ON_TOP;
};
!
! Main window
!
object appMain : XmMainWindow {
arguments {
XmNmenuBar = XmMenuBar menuBar;
};
controls {
XmMenuBar menuBar;
XmFrame workArea;
unmanaged XmInformationDialog helpDialog;
};
};
!
! Menu bar and pulldown menus
!
object menuBar : XmMenuBar {
arguments {
XmNmenuHelpWidget = XmCascadeButton helpCascade;
};
controls {
XmCascadeButton fileCascade;
XmCascadeButton editCascade;
XmCascadeButton helpCascade;
};
};
object fileCascade : XmCascadeButton {
arguments {
XmNlabelString = fileCascadeText;
XmNmnemonic = keysym(fileCascadeMnem);
};
controls { XmPulldownMenu {
! arguments { XmNtearOffModel = XmTEAR_OFF_ENABLED; };
controls {
XmPushButton exitButton;
}; };
};
};
object exitButton : XmPushButton {
arguments {
XmNlabelString = exitButtonText;
XmNmnemonic = keysym(exitButtonMnem);
};
callbacks { XmNactivateCallback = procedure ExitCb(); };
};
object editCascade : XmCascadeButton {
arguments {
XmNlabelString = editCascadeText;
XmNmnemonic = keysym(editCascadeMnem);
};
controls { XmPulldownMenu {
arguments { XmNtearOffModel = XmTEAR_OFF_ENABLED; };
controls {
XmPushButton cutButton;
XmPushButton copyButton;
XmPushButton pasteButton;
}; };
};
};
object helpCascade : XmCascadeButton {
arguments {
XmNlabelString = helpCascadeText;
XmNmnemonic = keysym(helpCascadeMnem);
};
controls { XmPulldownMenu {
arguments { XmNtearOffModel = XmTEAR_OFF_ENABLED; };
controls {
XmPushButton helpButton;
}; };
};
};
object helpButton : XmPushButton {
arguments {
XmNlabelString = helpButtonText;
XmNmnemonic = keysym(helpButtonMnem);
};
callbacks { XmNactivateCallback = procedure ManageCb("*helpDialog"); };
};
!
! Popup menu
!
object popupMenu : XmPopupMenu {
arguments { XmNtearOffModel = XmTEAR_OFF_ENABLED; };
controls {
XmLabel { arguments { XmNlabelString = popupTitleText; }; };
XmSeparator { arguments { XmNseparatorType = XmDOUBLE_LINE; }; };
XmPushButton cutButton;
XmPushButton copyButton;
XmPushButton pasteButton;
};
callbacks {
MrmNcreateCallback = procedure InitPopupCb("*displayArea");
};
};
object cutButton : XmPushButton {
arguments {
XmNlabelString = menuCutText;
XmNmnemonic = keysym(menuCutMnem);
};
callbacks { XmNactivateCallback = procedure CutCb(); };
};
object copyButton : XmPushButton {
arguments {
XmNlabelString = menuCopyText;
XmNmnemonic = keysym(menuCopyMnem);
};
callbacks { XmNactivateCallback = procedure CopyCb(); };
};
object pasteButton : XmPushButton {
arguments {
XmNlabelString = menuPasteText;
XmNmnemonic = keysym(menuPasteMnem);
};
callbacks { XmNactivateCallback = procedure PasteCb(); };
};
!
! Work area
!
object workArea : XmFrame {
arguments {
XmNmarginWidth = 20;
XmNmarginHeight = 20;
};
controls { XmFrame displayArea; };
};
object displayArea : XmFrame {
arguments {
XmNmarginWidth = 10;
XmNmarginHeight = 10;
XmNshadowType = XmSHADOW_OUT;
XmNshadowThickness = 1;
};
controls {
XmLabel graphLabel;
XmForm graphForm;
unmanaged XmPopupMenu popupMenu;
};
};
object graphLabel : XmLabel {
arguments {
XmNchildType = XmFRAME_TITLE_CHILD;
XmNchildHorizontalAlignment = XmALIGNMENT_END;
XmNlabelString = graphLabelText;
};
};
object graphForm : XmForm {
arguments {
XmNfractionBase = 15;
};
controls {
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 0; XmNrightPosition = 1;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 1; XmNrightPosition = 2;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 2; XmNrightPosition = 3;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 3; XmNrightPosition = 4;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 4; XmNrightPosition = 5;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 5; XmNrightPosition = 6;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 6; XmNrightPosition = 7;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 7; XmNrightPosition = 8;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 8; XmNrightPosition = 9;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 9; XmNrightPosition = 10;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 10; XmNrightPosition = 11;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 11; XmNrightPosition = 12;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 12; XmNrightPosition = 13;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 13; XmNrightPosition = 14;
}; };
XmScrollBar { arguments {
arguments scrollArgs;
XmNleftPosition = 14; XmNrightPosition = 15;
}; };
};
};
!
! Help dialog
!
object helpDialog : XmInformationDialog {
arguments {
XmNdialogTitle = helpTitleText;
XmNcancelLabelString = helpCancelText;
XmNmessageString = helpMessageText;
};
controls {
Xm_OK unmanaged { };
Xm_Help unmanaged { };
};
};
end module;

View File

@@ -0,0 +1,62 @@
! (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
! ALL RIGHTS RESERVED
!
! Motif Release 1.2
! Main Window
! Menu bar
value
fileCascadeText : "File";
fileCascadeMnem : "F";
exitButtonText : "Exit";
exitButtonMnem : "E";
editCascadeText : "Edit";
editCascadeMnem : "E";
menuCutText : "Cut";
menuCutMnem : "t";
menuCopyText : "Copy";
menuCopyMnem : "C";
menuPasteText : "Paste";
menuPasteMnem : "P";
helpCascadeText : "Help";
helpCascadeMnem : "H";
helpButtonText : "Overiew";
helpButtonMnem : "O";
! work area
graphLabelText : "Distribution";
! Help dialog
helpTitleText : "cutpaste";
helpCancelText : "Dismiss";
helpMessageText :
compound_string ("cutpaste", separate=true) &
compound_string ("", separate=true) &
compound_string ("Set graph slider values.", separate=true) &
compound_string ("", separate=true) &
compound_string ("Copy graph values between ") &
compound_string ("cutpaste clients", separate=true) &
compound_string ("using popup and pulldown menu commands.") &
compound_string ("", separate=true) &
compound_string ("");
! Popup menu
popupTitleText : "Edit";
popupCutText : "Cut";
popupCutMnem : "t";
popupCopyText : "Copy";
popupCopyMnem : "C";
popupPasteText : "Paste";
popupPasteMnem : "P";

View File

@@ -0,0 +1,501 @@
/*
* (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
* ALL RIGHTS RESERVED
*/
/*
* Motif Release 1.2
*/
#ifdef REV_INFO
#ifndef lint
static char rcsid[] = "$XConsortium: Dog.c /main/4 1995/10/27 10:41:52 rswiston $"
#endif
#endif
/*****************************************************************************
*
* Dog.c - Dog widget source file
*
******************************************************************************/
#include <stdio.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Mrm/MrmPublic.h>
#include "DogP.h"
#include "up.bm"
#include "down.bm"
#include "bark.bm"
#ifndef MAX
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#endif
#define WagTime(w) XmField(w,offsets,Dog,wag_time, int)
#define BarkTime(w) XmField(w,offsets,Dog,bark_time, int)
#define BarkCallback(w) XmField(w,offsets,Dog,bark_callback,XtCallbackList)
#define UpPixmap(w) XmField(w,offsets,Dog,up_pixmap,Pixmap)
#define DownPixmap(w) XmField(w,offsets,Dog,down_pixmap,Pixmap)
#define BarkPixmap(w) XmField(w,offsets,Dog,bark_pixmap,Pixmap)
#define CurrPixmap(w) XmField(w,offsets,Dog,curr_pixmap,Pixmap)
#define CurrPx(w) XmField(w,offsets,Dog,curr_px,int)
#define Wagging(w) XmField(w,offsets,Dog,wagging,Boolean)
#define Barking(w) XmField(w,offsets,Dog,barking,Boolean)
#define DrawGC(w) XmField(w,offsets,Dog,draw_GC,GC)
#define PixmapX(w) XmField(w,offsets,Dog,pixmap_x,Position)
#define PixmapY(w) XmField(w,offsets,Dog,pixmap_y,Position)
#define DrawX(w) XmField(w,offsets,Dog,draw_x,Position)
#define DrawY(w) XmField(w,offsets,Dog,draw_y,Position)
#define DrawWidth(w) XmField(w,offsets,Dog,draw_width,Dimension)
#define DrawHeight(w) XmField(w,offsets,Dog,draw_height,Dimension)
#define CurrWidth(w) XmField(w,offsets,Dog,curr_width,Dimension)
#define CurrHeight(w) XmField(w,offsets,Dog,curr_height,Dimension)
#define HighlightThickness(w) \
XmField(w,offsets,XmPrimitive,highlight_thickness,Dimension)
#define ShadowThickness(w) \
XmField(w,offsets,XmPrimitive,shadow_thickness,Dimension)
#define Foreground(w) XmField(w,offsets,XmPrimitive,foreground,Pixel)
#define Highlighted(w) XmField(w,offsets,XmPrimitive,highlighted,Boolean)
#define TopShadowGC(w) XmField(w,offsets,XmPrimitive,top_shadow_GC,GC)
#define BottomShadowGC(w) XmField(w,offsets,XmPrimitive,bottom_shadow_GC,GC)
#define BackgroundPixel(w) XmField(w,offsets,Core,background_pixel,Pixel)
#define Width(w) XmField(w,offsets,Core,width,Dimension)
#define Height(w) XmField(w,offsets,Core,height,Dimension)
#define SetPixmap(w, px, pixmap, width, height) \
CurrPx(w) = px; CurrPixmap(w) = pixmap; \
CurrWidth(w) = width; CurrHeight(w) = height
#define MakePixmap(b,wd,ht) \
XCreatePixmapFromBitmapData(XtDisplay(w),RootWindowOfScreen(XtScreen(w)), \
(char*)(b), (wd), (ht), Foreground(w), BackgroundPixel(w), \
DefaultDepthOfScreen(XtScreen(w)))
static void ClassInitialize();
static void Initialize();
static void Redisplay();
static void Resize();
static void Destroy();
static Boolean SetValues();
static XtGeometryResult QueryGeometry();
static void bark_dog();
static void end_bark();
static void start_wag();
static void stop_wag();
static void do_wag();
static char defaultTranslations[] =
"<Btn1Down>: Bark()\n\
~Shift<Btn2Down>: StartWag()\n\
Shift<Btn2Down>: StopWag()\n\
<Key>Return: Bark()\n\
Ctrl <Key>Return: Bark()\n\
<Key>osfActivate: Bark()\n\
<Key>space: Bark()\n\
Ctrl <Key>space: Bark()\n\
<Key>osfSelect: Bark()\n\
<Key>W: StartWag()\n\
<Key>S: StopWag()\n\
<Key>osfHelp: PrimitiveHelp()";
static XtActionsRec actionsList[] = {
{ "Bark", (XtActionProc) bark_dog},
{ "StartWag", (XtActionProc) start_wag},
{ "StopWag", (XtActionProc) stop_wag}
};
static XmPartResource resources[] = {
{DogNwagTime, DogCWagTime, XtRInt, sizeof(int),
XmPartOffset(Dog,wag_time), XmRImmediate, (XtPointer)100},
{DogNbarkTime, DogCBarkTime, XtRInt, sizeof(int),
XmPartOffset(Dog,bark_time), XmRImmediate, (XtPointer)1000},
{DogNbarkCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
XmPartOffset(Dog,bark_callback), XtRCallback, NULL}
};
DogClassRec dogClassRec = {
{ /* core_class fields */
(WidgetClass) &xmPrimitiveClassRec, /* superclass */
"Dog", /* class_name */
sizeof(DogPart), /* widget_size */
ClassInitialize, /* class_initialize */
NULL, /* class_part_initialize*/
False, /* class_inited */
Initialize, /* initialize */
NULL, /* initialize_notify */
XtInheritRealize, /* realize */
actionsList, /* actions */
XtNumber(actionsList), /* num_actions */
(XtResourceList)resources, /* resources */
XtNumber(resources), /* num_resources */
NULLQUARK, /* xrm_class */
True, /* compress_motion */
True, /* compress_exposure */
True, /* compress_enterleave */
False, /* visible_interest */
Destroy, /* destroy */
Resize, /* resize */
Redisplay, /* expose */
SetValues, /* set_values */
NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */
NULL, /* accept_focus */
XtVersionDontCheck, /* version */
NULL, /* callback_private */
defaultTranslations, /* tm_table */
QueryGeometry, /* query_geometry */
NULL, /* disp accelerator */
NULL /* extension */
},
{ /* primitive_class record */
XmInheritWidgetProc, /* border_highlight */
XmInheritWidgetProc, /* border_unhighlight */
XtInheritTranslations, /* translations */
bark_dog, /* arm_and_activate */
NULL, /* syn resources */
0, /* num syn_resources */
NULL, /* extension */
},
{ /* dog_class record */
NULL, /* extension */
}
};
externaldef(dogwidgetclass) WidgetClass dogWidgetClass =
(WidgetClass) &dogClassRec;
static XmOffsetPtr offsets; /* Part Offset table for XmResolvePartOffsets */
/**********************************************************************
*
* DogCreate - Convenience routine, used by Uil/Mrm.
*
*********************************************************************/
Widget DogCreate(parent, name, arglist, nargs)
Widget parent;
char *name;
Arg *arglist;
int nargs;
{
return(XtCreateWidget (name, dogWidgetClass, parent, arglist, nargs));
}
/**********************************************************************
*
* DogMrmInitialize - register Dog widget class with Mrm
*
*********************************************************************/
int DogMrmInitialize()
{
return(MrmRegisterClass (MrmwcUnknown, "Dog" , "DogCreate", DogCreate,
(WidgetClass)&dogClassRec));
}
/**********************************************************************
*
* _DogDrawPixmap - draw the current pixmap
*
*********************************************************************/
void _DogDrawPixmap(w)
DogWidget w;
{
if (XtIsRealized(w)) {
XCopyArea(XtDisplay(w),CurrPixmap(w),
XtWindow(w),DrawGC(w),
PixmapX(w), PixmapY(w),
DrawWidth(w), DrawHeight(w),
DrawX(w), DrawY(w));
}
}
/**********************************************************************
*
* _DogPosition(w) - position the current pixmap
*
*********************************************************************/
void _DogPosition(w)
DogWidget w;
{
Dimension margin = ShadowThickness(w) + HighlightThickness(w);
if (CurrWidth(w) < MAX(Width(w) - 2u * margin,0)) {
PixmapX(w) = 0;
DrawX(w) = Width(w)/2 - CurrWidth(w)/2;
DrawWidth(w) = CurrWidth(w);
}
else {
PixmapX(w) = (CurrWidth(w) - (Width(w) - 2 * margin))/2u;
DrawX(w) = margin;
DrawWidth(w) = Width(w) - 2 * margin;
}
if (CurrHeight(w) < MAX(Height(w) - 2u * margin,0)) {
PixmapY(w)= 0;
DrawY(w) = Height(w)/2 - CurrHeight(w)/2;
DrawHeight(w) = CurrHeight(w);
}
else {
PixmapY(w) = (CurrHeight(w) - (Height(w) - 2 * margin))/2u;
DrawY(w) = margin;
DrawHeight(w) = Height(w) - 2 * margin;
}
}
/**********************************************************************
*
* Class methods
*
*********************************************************************/
static void ClassInitialize()
{
XmResolvePartOffsets(dogWidgetClass, &offsets);
}
static create_GC(w)
DogWidget w;
{
XGCValues values;
XtGCMask valueMask;
valueMask = GCForeground | GCBackground | GCGraphicsExposures;
values.foreground = Foreground(w);
values.background = BackgroundPixel(w);
values.graphics_exposures = False;
DrawGC(w) = XtGetGC((Widget)w,valueMask,&values);
}
static create_pixmaps(w)
DogWidget w;
{
UpPixmap(w) = MakePixmap(up_bits, up_width, up_height);
DownPixmap(w) = MakePixmap(down_bits, down_width, down_height);
BarkPixmap(w) = MakePixmap(bark_bits, bark_width, bark_height);
}
static void Initialize(request, new)
DogWidget request;
DogWidget new;
{
if (Width(request) == 0)
Width(new) = MAX(MAX(up_width, down_width),bark_width) +
2*(ShadowThickness(new)+HighlightThickness(new));
if (Height(request) == 0)
Height(new) = MAX(MAX(up_height, down_height),bark_height) +
2*(ShadowThickness(new)+HighlightThickness(new));
create_GC(new);
create_pixmaps(new);
SetPixmap(new, DownPx, DownPixmap(new), down_width, down_height);
Wagging(new) = False;
Barking(new) = False;
Resize(new);
}
static destroy_pixmaps(w)
DogWidget w;
{
XFreePixmap (XtDisplay(w), UpPixmap(w));
XFreePixmap (XtDisplay(w), DownPixmap(w));
XFreePixmap (XtDisplay(w), BarkPixmap(w));
}
static void Destroy(w)
DogWidget w;
{
XtReleaseGC ((Widget)w, DrawGC(w));
destroy_pixmaps(w);
XtRemoveAllCallbacks ((Widget)w, DogNbarkCallback);
}
static void Resize(w)
DogWidget w;
{
_DogPosition(w);
}
static Boolean DifferentBackground(w, p)
Widget w;
Widget p;
{
if (XmIsPrimitive(w) && XmIsManager(p))
{
Pixel w_bg, p_bg;
Pixmap w_px, p_px;
XtVaGetValues(w, XmNbackground, &w_bg, XmNbackgroundPixmap, &w_px, NULL);
XtVaGetValues(p, XmNbackground, &p_bg, XmNbackgroundPixmap, &p_px, NULL);
return ((w_bg == p_bg) && (w_px == p_px));
}
return (False);
}
static void Redisplay(w, event, region)
DogWidget w;
XEvent *event;
Region region;
{
if (XtIsRealized(w)) {
XmeDrawShadows (XtDisplay (w), XtWindow (w),
TopShadowGC(w), BottomShadowGC(w),
HighlightThickness(w), HighlightThickness(w),
Width(w) - 2 * HighlightThickness(w),
Height(w) - 2 * HighlightThickness(w),
ShadowThickness(w),
XmSHADOW_OUT);
if (Highlighted(w))
(*((DogWidgetClass)XtClass(w)) ->
primitive_class.border_highlight)((Widget)w);
else if (DifferentBackground ((Widget)w, XtParent (w)))
(*((DogWidgetClass)XtClass(w)) ->
primitive_class.border_unhighlight)((Widget)w);
_DogDrawPixmap(w);
}
}
static Boolean SetValues(current, request, new)
DogWidget current;
DogWidget request;
DogWidget new;
{
Boolean redraw = False;
if (ShadowThickness(new) != ShadowThickness(current) ||
HighlightThickness(new) != HighlightThickness(current)) {
_DogPosition(new);
redraw = True;
}
if (Foreground(new) != Foreground(current) ||
BackgroundPixel(new) != BackgroundPixel(current)) {
XtReleaseGC ((Widget)current, DrawGC(current));
create_GC(new);
destroy_pixmaps(new);
create_pixmaps(new);
switch (CurrPx(new)) {
case(UpPx) :
SetPixmap(new,UpPx,UpPixmap(new),up_width,up_height);
break;
case(DownPx) :
SetPixmap(new,DownPx,DownPixmap(new),down_width,down_height);
break;
case(BarkPx) :
SetPixmap(new,BarkPx,BarkPixmap(new),bark_width,bark_height);
break;
}
redraw = True;
}
return (redraw);
}
static XtGeometryResult QueryGeometry (w, intended, reply)
DogWidget w;
XtWidgetGeometry *intended;
XtWidgetGeometry *reply;
{
reply->request_mode = 0;
if (intended->request_mode & (~(CWWidth | CWHeight)) != 0)
return (XtGeometryNo);
reply->request_mode = (CWWidth | CWHeight);
reply->width = MAX(MAX(down_width,up_width),bark_width) +
2*(ShadowThickness(w)+HighlightThickness(w));
reply->height = MAX(MAX(down_height,up_height),bark_height) +
2*(ShadowThickness(w)+HighlightThickness(w));
if (reply->width != intended->width ||
reply->height != intended->height ||
intended->request_mode != reply->request_mode)
return (XtGeometryAlmost);
else {
reply->request_mode = 0;
return (XtGeometryYes);
}
}
/**********************************************************************
*
* Widget actions
*
*********************************************************************/
static void bark_dog(w, event)
DogWidget w;
XEvent *event;
{
XmProcessTraversal((Widget)w, XmTRAVERSE_CURRENT);
XtCallCallbacks ((Widget)w, DogNbarkCallback, NULL);
if (Barking(w) == True) return;
Barking(w) = True;
SetPixmap(w,BarkPx,BarkPixmap(w),bark_width,bark_height);
_DogPosition(w);
_DogDrawPixmap(w);
XtAppAddTimeOut (XtWidgetToApplicationContext((Widget)w),
BarkTime((Widget)w), end_bark, w);
}
static void end_bark(w, t)
DogWidget w;
XtIntervalId *t;
{
SetPixmap(w,DownPx,DownPixmap(w),down_width,down_height);
_DogPosition(w);
_DogDrawPixmap(w);
Barking(w) = False;
if (Wagging(w) == True)
XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)w),
WagTime(w), do_wag, w);
}
static void start_wag(w, event)
DogWidget w;
XEvent *event;
{
XmProcessTraversal((Widget)w, XmTRAVERSE_CURRENT);
if (Wagging(w) == True) return;
Wagging(w) = True;
if (Barking(w) == True) return;
XtAppAddTimeOut (XtWidgetToApplicationContext((Widget)w),
WagTime(w), do_wag, w);
}
static void stop_wag(w, event)
DogWidget w;
XEvent *event;
{
XmProcessTraversal((Widget)w, XmTRAVERSE_CURRENT);
Wagging(w) = False;
}
static void do_wag(cd, t)
XtPointer cd;
XtIntervalId *t;
{
DogWidget w = (DogWidget)cd;
if (Barking(w) == True) return;
if (Wagging(w) == False) return;
switch(CurrPx(w)) {
case(UpPx):
SetPixmap(w,DownPx,DownPixmap(w),down_width,down_height);
break;
case(DownPx):
SetPixmap(w,UpPx,UpPixmap(w),up_width,up_height);
break;
}
_DogPosition(w);
_DogDrawPixmap(w);
XtAppAddTimeOut (XtWidgetToApplicationContext((Widget)w),
WagTime(w), do_wag, (XtPointer)w);
}

View File

@@ -0,0 +1,37 @@
/*
* (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
* ALL RIGHTS RESERVED
*/
/*
* Motif Release 1.2
*/
/* $XConsortium: Dog.h /main/3 1995/10/27 10:42:01 rswiston $ */
/*****************************************************************************
*
* Dog.h - widget public header file
*
******************************************************************************/
#ifndef _Dog_h
#define _Dog_h
externalref WidgetClass dogWidgetClass;
typedef struct _DogClassRec *DogWidgetClass;
typedef struct _DogRec *DogWidget;
#define DogNbarkCallback "barkCallback"
#define DogNwagTime "wagTime"
#define DogNbarkTime "barkTime"
#define DogCWagTime "WagTime"
#define DogCBarkTime "BarkTime"
#define IsDog(w) XtIsSubclass((w), dogWidgetClass)
extern Widget DogCreate();
extern int DogMrmInitialize();
#endif /* _Dog_h */
/* DON'T ADD ANYTHING AFTER THIS #endif */

Some files were not shown because too many files have changed in this diff Show More