~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/xsci/wf_xcommand.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This an example of how to use the Command widget.
 
3
 *
 
4
 * User events handled through callback routines.
 
5
 *
 
6
 * November 14, 1989 - Chris D. Peterson 
 
7
 */
 
8
 
 
9
/*
 
10
 * $XConsortium: xcommand.c,v 1.12 91/01/22 19:44:25 gildea Exp $
 
11
 *
 
12
 * Copyright 1989 Massachusetts Institute of Technology
 
13
 *
 
14
 * Permission to use, copy, modify, distribute, and sell this software and its
 
15
 * documentation for any purpose is hereby granted without fee, provided that
 
16
 * the above copyright notice appear in all copies and that both that
 
17
 * copyright notice and this permission notice appear in supporting
 
18
 * documentation, and that the name of M.I.T. not be used in advertising or
 
19
 * publicity pertaining to distribution of the software without specific,
 
20
 * written prior permission.  M.I.T. makes no representations about the
 
21
 * suitability of this software for any purpose.  It is provided "as is"
 
22
 * without express or implied warranty.
 
23
 *
 
24
 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
 
25
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
 
26
 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
27
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 
28
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
 
29
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
30
 */
 
31
 
 
32
#include "../machine.h"
 
33
#include <stdio.h>
 
34
#include <X11/Intrinsic.h>
 
35
#include <X11/StringDefs.h>     /* Get standard string definations. */
 
36
 
 
37
#include <X11/Xaw/Command.h>    
 
38
#include <X11/Xaw/Cardinals.h>  
 
39
 
 
40
#include "wf_resources.h"
 
41
static void Syntax();
 
42
static void Select();
 
43
 
 
44
String fallback_resources[] = { 
 
45
    "*Command.Label:    Click the left mouse button here",
 
46
    NULL,
 
47
};
 
48
 
 
49
static XrmOptionDescRec options[] = {
 
50
{"-label",      "*Command.label",       XrmoptionSepArg,        NULL}
 
51
};
 
52
 
 
53
XtAppContext app_con;
 
54
 
 
55
 
 
56
/*
 
57
 * DeleteWindow(): Action proc to implement ICCCM delete_window.
 
58
 */
 
59
/* ARGSUSED */
 
60
 
 
61
void
 
62
DeleteWindow(w, event, params, num_params)
 
63
    Widget w;
 
64
    XEvent *event;
 
65
    String *params;
 
66
    Cardinal *num_params;
 
67
{
 
68
  ClearExit(0);
 
69
}
 
70
 
 
71
XtActionsRec actionProcs[] = {
 
72
    "DeleteWindow", DeleteWindow,
 
73
};
 
74
 
 
75
Atom wm_delete_window;
 
76
Widget l_toplevel;
 
77
 
 
78
main(argc, argv)
 
79
int argc;
 
80
char **argv;
 
81
{
 
82
    Widget command;
 
83
 
 
84
    l_toplevel = XtAppInitialize(&app_con, "Xcommand",
 
85
                                 options, XtNumber(options),
 
86
                                 &argc, argv, fallback_resources,
 
87
                                 (ArgList) 0,(Cardinal) 0);
 
88
 
 
89
    if (argc != 1)              
 
90
        Syntax(app_con, argv[0]);
 
91
 
 
92
    command = XtCreateManagedWidget("command", commandWidgetClass, l_toplevel,
 
93
                                    NULL, ZERO);
 
94
 
 
95
    /*
 
96
     * Add a callback routine to the Command widget that will print
 
97
     * the message "button selected" to stdout.
 
98
     */        
 
99
    /*
 
100
     * ICCCM delete_window.
 
101
     */
 
102
    XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs));
 
103
    XtAddCallback(command, XtNcallback, Select, NULL);
 
104
    XtRealizeWidget(l_toplevel);
 
105
    XtAppMainLoop(app_con);
 
106
    (void) exit(0);
 
107
}
 
108
 
 
109
/*      Function Name: Select
 
110
 *      Description: This function prints a message to stdout.
 
111
 *      Arguments: w - ** UNUSED **
 
112
 *                 call_data - ** UNUSED **
 
113
 *                 client_data - ** UNUSED **
 
114
 *      Returns: none
 
115
 */
 
116
 
 
117
 
 
118
 
 
119
static void
 
120
Select(w, client_data, call_data)
 
121
Widget w;
 
122
XtPointer call_data, client_data;
 
123
{
 
124
    fprintf(stdout, "Button Selected.\n");
 
125
    popup_file_panel(w,"File Menu");
 
126
 
 
127
}
 
128
 
 
129
/*      Function Name: Syntax
 
130
 *      Description: Prints a the calling syntax for this function to stdout.
 
131
 *      Arguments: app_con - the application context.
 
132
 *                 call - the name of the application.
 
133
 *      Returns: none - exits tho.
 
134
 */
 
135
 
 
136
static void 
 
137
Syntax(app_con, call)
 
138
XtAppContext app_con;
 
139
char *call;
 
140
{
 
141
    XtDestroyApplicationContext(app_con);
 
142
    fprintf( stderr, "Usage: %s [-label <label name>]\n", call);
 
143
    (void) exit(1);
 
144
}
 
145
 
 
146
 
 
147
write_scilab(arg)
 
148
     char *arg;
 
149
{
 
150
  fprintf(stderr,"%s",arg);
 
151
};
 
152