~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to xless/help.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 1989 Massachusetts Institute of Technology
3
 
 *
4
 
 * Permission to use, copy, modify, and distribute this software and its
5
 
 * documentation for any purpose and without fee is hereby granted, provided
6
 
 * that the above copyright notice appear in all copies and that both that
7
 
 * copyright notice and this permission notice appear in supporting
8
 
 * documentation, and that the name of M.I.T. not be used in advertising
9
 
 * or publicity pertaining to distribution of the software without specific,
10
 
 * written prior permission.  M.I.T. makes no representations about the
11
 
 * suitability of this software for any purpose.  It is provided "as is"
12
 
 * without express or implied warranty.
13
 
 *
14
 
 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15
 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
16
 
 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
 
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18
 
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19
 
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20
 
 *
21
 
 * Author: Carlo Lisa
22
 
 *         MIT Project Athena
23
 
 *
24
 
 * $Header: /usr/sww/share/src/X11R5/local/clients/xless-1.4/RCS/help.c,v 1.11 1993/02/26 02:09:54 dglo Exp dglo $
25
 
 */
26
 
 
27
 
#include "xless.h"
28
 
#include "XLessHelp.icon"
29
 
 
30
 
static Widget createHelp ARGS((void));
31
 
static void PopdownHelp ARGS((Widget, XtPointer, XtPointer));
32
 
 
33
 
/*      Function Name: CreateHelp.
34
 
 *      Description: This function creates the help widget so that it will be
35
 
 *                   ready to be displayed.
36
 
 *      Arguments:
37
 
 *      Returns: the help widget
38
 
 */
39
 
 
40
 
static Widget
41
 
createHelp()
42
 
{
43
 
  char *env;
44
 
  extern Widget toplevel;
45
 
  FILE *help_file;
46
 
  Cardinal i;
47
 
  Arg args[4];
48
 
  const char *help_page;
49
 
  Pixmap helpicon;
50
 
  Widget base, pane, helptext, button;
51
 
  XtCallbackRec callback[2];
52
 
  XtAccelerators accel;
53
 
  const String quitstr = "#override <Key>Q: set() notify() unset()\n";
54
 
 
55
 
  /* try to open the help file */
56
 
  env = getenv("XLESSHELPFILE");
57
 
  if (env != NULL)
58
 
    help_file = fopen(env, "r");
59
 
  else
60
 
    help_file = fopen(resources.help_file, "r");
61
 
  if (help_file == NULL) {
62
 
    CouldntOpen(toplevel, resources.help_file);
63
 
    return 0;
64
 
  }
65
 
  help_page = InitData(help_file);
66
 
 
67
 
  /* create a new application shell */
68
 
  i = 0;
69
 
  helpicon = XCreateBitmapFromData(disp, XRootWindow(disp, 0), XLessHelp_bits,
70
 
                                   XLessHelp_width, XLessHelp_height);
71
 
  XtSetArg(args[i], XtNiconPixmap, helpicon); i++;
72
 
  XtSetArg(args[i], XtNiconName, "xless: help"); i++;
73
 
  XtSetArg(args[i], XtNallowShellResize, TRUE); i++;
74
 
  base = XtAppCreateShell("help", XLESS_CLASS, applicationShellWidgetClass,
75
 
                          disp, args, i);
76
 
 
77
 
  pane = XtCreateManagedWidget("help_pane", panedWidgetClass, base, NULL, 0);
78
 
 
79
 
  helptext = MakeText(pane, help_page);
80
 
 
81
 
  /* set up Done button callback array */
82
 
  callback[0].callback = PopdownHelp;
83
 
  callback[0].closure = (XtPointer)base;
84
 
  callback[1].callback = NULL;
85
 
  callback[1].closure = (XtPointer)NULL;
86
 
 
87
 
  /* set up Done button accelerator */
88
 
  accel = XtParseAcceleratorTable(quitstr);
89
 
 
90
 
  /* create Done button */
91
 
  i = 0;
92
 
  XtSetArg(args[i], XtNfont, buttonfont); i++;
93
 
  XtSetArg(args[i], XtNlabel, "Done With Help"); i++;
94
 
  XtSetArg(args[i], XtNcallback, callback); i++;
95
 
  XtSetArg(args[i], XtNaccelerators, accel); i++;
96
 
  button = XtCreateManagedWidget("help_quit", commandWidgetClass, pane,
97
 
                               args, i);
98
 
  XtInstallAccelerators(helptext, button);
99
 
 
100
 
  XtRealizeWidget(base);
101
 
 
102
 
  return(base);
103
 
}
104
 
 
105
 
/*      Function Name: PopdownHelp
106
 
 *      Description: This function pops down the help widget.
107
 
 *      Arguments: w - the widget we are calling back from.
108
 
 *                 number - (closure) the number to switch on.
109
 
 *                 junk - (call data) not used.
110
 
 *      Returns: none.
111
 
 */
112
 
 
113
 
/* ARGSUSED */
114
 
 
115
 
static void
116
 
PopdownHelp(w, help_widget, junk)
117
 
Widget w;
118
 
XtPointer help_widget, junk;
119
 
{
120
 
  XtPopdown((Widget )help_widget);
121
 
}
122
 
 
123
 
/*      Function Name: PopupHelp
124
 
 *      Description: This function pops up the help widget, unless no
125
 
 *                   help could be found.
126
 
 *      Arguments: w - the widget we are calling back from.
127
 
 *                 number - (closure) the number to switch on.
128
 
 *                 junk - (call data) not used.
129
 
 *      Returns: none.
130
 
 */
131
 
 
132
 
/* ARGSUSED */
133
 
 
134
 
void
135
 
PopupHelp(w, number, junk)
136
 
Widget w;
137
 
XtPointer number, junk;
138
 
{
139
 
  static Widget help_widget = 0;
140
 
 
141
 
  if (!help_widget)
142
 
    help_widget = createHelp();
143
 
  if (help_widget)
144
 
    XtPopup(help_widget, XtGrabNone);
145
 
}