|
DataMuseum.dkPresents historical artifacts from the history of: Regnecentalen RC-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Regnecentalen RC-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 12198 (0x2fa6) Types: TextFile Notes: UNIX file Names: »periodic.c«
└─⟦a85bd4a7c⟧ Bits:30004636/disk2.imd INTERACTIVE Motif Environment Development System └─⟦a85bd4a7c⟧ UNIX Filesystem └─⟦this⟧ »xt/new/usr/lib/X11/examples/periodic/periodic.c«
#ifdef REV_INFO #ifndef lint static char SCCSID[] = "OSF/Motif: @(#)periodic.c 1.1 - 89/08/30 - 12:06:40"; #endif /* lint */ #endif /* REV_INFO */ /****************************************************************************** ******************************************************************************* * * (c) Copyright 1989, OPEN SOFTWARE FOUNDATION, INC. * ALL RIGHTS RESERVED * * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT * NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE * FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS * * OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS, * ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS * SOFTWARE . OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE. * * Notice: Notwithstanding any other lease or license that may pertain to, * or accompany the delivery of, this computer software, the rights of the * Government regarding its use, reproduction and disclosure are as set * forth in Section 52.227-19 of the FARS Computer Software-Restricted * Rights clause. * * (c) Copyright 1989, Open Software Foundation, Inc. Unpublished - all * rights reserved under the Copyright laws of the United States. * * RESTRICTED RIGHTS NOTICE: Use, duplication, or disclosure by the * Government is subject to the restrictions as set forth in subparagraph * (c)(1)(ii) of the Rights in Technical Data and Computer Software clause * at DFARS 52.227-7013. * * Open Software Foundation, Inc. * 11 Cambridge Center * Cambridge, MA 02142 * (617)621-8700 * * RESTRICTED RIGHTS LEGEND: This computer software is submitted with * "restricted rights." Use, duplication or disclosure is subject to the * restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985) * "Commercial Computer Software- Restricted Rights (April 1985)." Open * Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA 02142. If * the contract contains the Clause at 18-52.227-74 "Rights in Data General" * then the "Alternate III" clause applies. * * (c) Copyright 1989, Open Software Foundation, Inc. * ALL RIGHTS RESERVED * * * Open Software Foundation is a trademark of The Open Software Foundation, Inc. * OSF is a trademark of Open Software Foundation, Inc. * OSF/Motif is a trademark of Open Software Foundation, Inc. * Motif is a trademark of Open Software Foundation, Inc. * DEC is a registered trademark of Digital Equipment Corporation * DIGITAL is a registered trademark of Digital Equipment Corporation * X Window System is a trademark of the Massachusetts Institute of Technology * ******************************************************************************* ******************************************************************************/ /****************************************************************************** *** defaults: periodic.c depends on these defaults: ! periodic*allowShellResize: true periodic*borderWidth: 0 periodic*highlightThickness: 2 periodic*traversalOn: true periodic*fontList: fixed #ifdef COLOR periodic*background: LightBlue #endif ! *** ******************************************************************************/ #include <stdio.h> /* Xt headers */ #include <X11/Intrinsic.h> #include <X11/Shell.h> #include <X11/AtomMgr.h> #include <X11/Protocols.h> #include <Mrm/MrmAppl.h> /* Motif Toolkit */ #include <Xm/Xm.h> #include <Xm/Label.h> #include <Xm/LabelG.h> #include <Xm/PushB.h> #include <Xm/PushBG.h> #include <Xm/ToggleB.h> #include <Xm/ToggleBG.h> #include <Xm/RowColumn.h> #include <Xm/SeparatoG.h> #include <Xm/Separator.h> #define MAX_ARGS 100 #define K_scale_widget 1 #define K_drawnbutton_widget 2 #define K_togglebutton_widget 3 #define K_vtext1_widget 4 #define K_vtext2_widget 5 #define K_popup_menu_widget 6 static Widget Scale_1,Drawnbutton_1,Togglebutton_1,VText_1,VText_2,PopMenu_1,PMenu_1; static Widget Label1, Separator1, PushBtn1, ToggleBtn1; static MrmHierarchy s_MrmHierarchy; /* MRM database hierarch id */ static char *vec[]={"periodic.uid"}; /* MRM database file list */ static MrmCode class ; static void quit_button_activate(); static void foo_activate(); static void create_callback(); static void zippy_null(); static void postmenu (); static MrmCount regnum = 4 ; static MRMRegisterArg regvec[] = { {"quit_button_activate",(caddr_t)quit_button_activate}, {"foo_activate",(caddr_t)foo_activate}, {"create_callback",(caddr_t)create_callback}, {"zippy_null",(caddr_t)zippy_null} }; static Widget CreateLabel(label, parent) char *label; Widget parent; { Widget widget; register int n; Arg args[MAX_ARGS]; XmString tcs; n = 0; tcs = XmStringLtoRCreate(label, XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, tcs); n++; widget = XmCreateLabel(parent, "label", args, n); XtManageChild(widget); XmStringFree(tcs); return(widget); } static Widget CreatePushButton(label, parent) char *label; Widget parent; { Widget widget; register int n; Arg args[MAX_ARGS]; XmString tcs; n = 0; tcs = XmStringLtoRCreate(label, XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, tcs); n++; widget = XmCreatePushButton(parent, "pushButton", args, n); XtManageChild(widget); XmStringFree(tcs); return(widget); } static Widget CreateToggle(label, parent) char *label; Widget parent; { Widget widget; register int n; Arg args[MAX_ARGS]; XmString tcs; n = 0; tcs = XmStringLtoRCreate(label, XmSTRING_DEFAULT_CHARSET); XtSetArg(args[n], XmNlabelString, tcs); n++; widget = XmCreateToggleButton(parent, "toggle", args, n); XtManageChild(widget); XmStringFree(tcs); return(widget); } /* * Main program */ int main(argc, argv) int argc; char **argv; { /* * Declare the variables to contain the two widget ids */ Widget toplevel, periodic_table_main; Arg arglist[1] ; int status; /* * Initialize the MRM */ printf("Calling MrmInitialize\n"); MrmInitialize (); printf("Returned MrmInitialize\n"); printf("Calling XtInitialize\n"); /* * Initialize the toolkit. This call returns the id of the "toplevel" * widget. The applications "main" widget must be the only child * of this widget. */ toplevel = XtInitialize( "periodic", /* application name */ "periodic", /* application class */ NULL, 0, /* options */ &argc, argv); /* command line parameters */ printf("Returned from XtInitialize\n"); printf("Calling XtSetArg and XtSetValues\n"); XtSetArg (arglist[0], XtNallowShellResize, FALSE) ; XtSetValues (toplevel, arglist, 1) ; printf("Returned from XtSetArg and XtSetValues\n"); /* * Define the Mrm.hierarchy (only 1 file) */ printf("Calling MrmOpenHierarchy\n"); if (MrmOpenHierarchy (1, /* number of files */ vec, /* files */ NULL, /* os_ext_list (null) */ &s_MrmHierarchy) /* ptr to returned id */ != MrmSUCCESS) { printf ("can't open hierarchy\n"); } printf("Returned from MrmOpenHierarchy\n"); /* * Register our callback routines so that the resource manager can * resolve them at widget-creation time. */ printf("Calling MrmRegisterNames\n"); if (MrmRegisterNames (regvec, regnum) != MrmSUCCESS) printf("can't register names\n"); printf("Returned from MrmRegisterNames\n"); /* * Call MRM to fetch and create the pushbutton and its container */ printf("Calling MrmFetchWidget\n"); if (MrmFetchWidget (s_MrmHierarchy, "periodic_table_main", toplevel, &periodic_table_main, &class) != MrmSUCCESS) printf("can't fetch interface\n"); printf("Returned from MrmFetchWidget\n"); /* * Make the toplevel widget "manage" the main window (or whatever the * the uil defines as the topmost widget). This will * cause it to be "realized" when the toplevel widget is "realized" */ printf("Calling XtManageChild\n"); XtManageChild(periodic_table_main); printf("Returned from XtManageChild\n"); /* * Realize the toplevel widget. This will cause the entire "managed" * widget hierarchy to be displayed */ printf("Calling XtRealizeWidget\n"); XtRealizeWidget(toplevel); printf("Returned from XtRealizeWidget\n"); /* ** PopupMenu1 */ PMenu_1 = XmCreatePopupMenu(PopMenu_1, "popMenu", NULL, 0); XtAddEventHandler(PopMenu_1, ButtonPressMask, False, postmenu, PMenu_1); /* ** Menu1 */ Label1 = CreateLabel("POPUP MENU", PMenu_1); XtSetArg(arglist[0], XmNseparatorType, XmDOUBLE_LINE); Separator1 = XmCreateSeparator(PMenu_1, "separator", arglist, 1); PushBtn1 = CreatePushButton("press button", PMenu_1); ToggleBtn1 = CreateToggle("boggle button", PMenu_1); /* * Loop and process events */ printf("Calling XtMainLoop\n"); XtMainLoop(); /* UNREACHABLE */ return (0); } static void zippy_null( widget, tag, callback_data ) Widget widget; char *tag; XmAnyCallbackStruct *callback_data; { } #define fatal 1 static void postmenu (w, popup, event) Widget w; Widget popup; XButtonEvent *event; { int status; if (event->button != Button3) return; XmMenuPosition(PMenu_1, event); XtManageChild (PMenu_1); } /* * All widgets that are created call back to this procedure. */ static void create_callback(w, tag, reason) Widget w; int *tag; unsigned long *reason; { /* For internationalization ease, we capture a few strings from the * widgets themselves. We could go out and fetch them as needed but * since we use these all the time, this method if more efficient. */ switch (*tag) { case K_scale_widget: Scale_1 = w; break; case K_drawnbutton_widget: Drawnbutton_1 = w; break; case K_togglebutton_widget: Togglebutton_1 = w; break; case K_vtext1_widget: VText_1 = w; break; case K_vtext2_widget: VText_2 = w; break; case K_popup_menu_widget: PopMenu_1 = w; break; default: break; } } static void foo_activate( widget, tag, callback_data ) Widget widget; char *tag; XmAnyCallbackStruct *callback_data; { Arg arglist[2]; int scale_value; Boolean toggle_state; XtSetArg( arglist[0], XmNvalue, &scale_value); XtGetValues( Scale_1, arglist, 1 ); XtSetArg( arglist[0], XmNset, &toggle_state); XtGetValues( Togglebutton_1, arglist, 1 ); if ((scale_value == 13) && (toggle_state == True)) { XtSetArg( arglist[0], XmNvalue, "OSF Motif Credits"); XtSetValues( VText_1, arglist, 1 ); XtSetArg( arglist[0], XmNvalue, "Dev: Vania, Ellis, Mike\n\ Rel: Pam\n\ Q/A: Libby, Dave\n\ Doc: Ken\n\ Int: Mitch, Peter, Alan\n\ Moral Support:\n\ Little Debbie Swiss Roll\n"); XtSetValues( VText_2, arglist, 1 ); } } static void quit_button_activate( widget, tag, callback_data ) Widget widget; char *tag; XmAnyCallbackStruct *callback_data; { Arg arglist[2]; static int call_count = 1; printf("In quit_button_activate()\n"); call_count += 1 ; switch ( call_count ) { case 1: /* XtSetArg( arglist[0], XmNlabelString, XmStringLtoRCreate("Goodbye\nWorld!","")); XtSetValues( Text_1, arglist, 1 ); */ break ; case 2: exit(1); break ; } }