File: sunwindows.c

package info (click to toggle)
xlispstat 3.52.14-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,560 kB
  • ctags: 12,676
  • sloc: ansic: 91,357; lisp: 21,759; sh: 1,525; makefile: 521; csh: 1
file content (195 lines) | stat: -rw-r--r-- 5,127 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* windows - SunView window functions                                  */
/* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney                  */
/* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
/* You may give out copies of this software; for conditions see the    */
/* file COPYING included with this distribution.                       */

#include "xlisp.h"
#include "xlstat.h"
#include "xlgraph.h"

/* external variables */
extern LVAL s_true, sk_update, sk_close, sk_activate, s_title, s_size,
 s_location;
extern char buf[];

/* external functions */
extern LVAL list3(), xmsend(), integer_list_2(), slot_value(), list2();

/**************************************************************************/
/**                                                                      **/
/**                           Utility Functions                          **/
/**                                                                      **/
/**************************************************************************/

errset_applysubr(subr, args)
     int (*subr)();
     LVAL args;
{
  CONTEXT cntxt;
  int error;

  /* establish an execution context */
  xlbegin(&cntxt,CF_ERROR,s_true);

  /* check for error */
  if (setjmp(cntxt.c_jmpbuf)) error = TRUE;
  else {

    /* call the function */
    xsapplysubr(subr, args);
    error = FALSE;
  }
  xlend(&cntxt);
  return(error);
}

errset_send(object, selector)
     LVAL object, selector;
{
  LVAL args;

  xlsave1(args);
  args = list2(object, selector);
  errset_applysubr(xmsend, args);
  xlpop();
}

/**************************************************************************/
/**                                                                      **/
/**                        Window Data Functions                         **/
/**                                                                      **/
/**************************************************************************/

LVAL get_window_object(w)
	WindowPtr w;
{
  WindowData data;
  
  data = (WindowData) get_window_data(w);
  if (data == NULL || ! objectp((LVAL) data->object)) return(NIL);
  else return((LVAL) data->object);
}

set_window_object(w, object)
	WindowPtr w;
	LVAL object;
{
  WindowData data;
  
  data = (WindowData) get_window_data(w);
  if (data == NULL) return;
  else data->object = (char *) object;
}

sun_close_action(w)
     IVIEW_WINDOW w;
{
  LVAL object = get_window_object(w);
  
  if (! objectp(object)) return;
  errset_send(object, sk_close);
}

/***********************************************************************/
/**                                                                   **/
/**                  General Window Methods Functions                 **/
/**                                                                   **/
/***********************************************************************/

StShowWindow(w)
     IVIEW_WINDOW w; 
{
  window_set(w, WIN_SHOW, TRUE, 0);
}

StHideWindow(w)
     IVIEW_WINDOW w; 
{
  window_set(w, WIN_SHOW, FALSE, 0);
}

StWSetTitle(w, title)
     IVIEW_WINDOW w;
     char *title;
{
  window_set(w, FRAME_LABEL, title, 0);
}

/**************************************************************************/
/**                                                                      **/
/**                         Screen Info Functions                        **/
/**                                                                      **/
/**************************************************************************/

StScreenHasColor() { return(FALSE); }

/**************************************************************************/
/**                                                                      **/
/**                    Protected Callback Functions                      **/
/**                                                                      **/
/**************************************************************************/

errset_window_call(subr, w)
     int (*subr)();
     IVIEW_WINDOW w;
{
  CONTEXT cntxt;
  int error;

  /* establish an execution context */
  xlbegin(&cntxt,CF_ERROR,s_true);

  /* check for error */
  if (setjmp(cntxt.c_jmpbuf)) error = TRUE;
  else {

    /* call the function */
    (*subr)(w);
    error = FALSE;
  }
  xlend(&cntxt);
  return(error);
}

SunStGWObDoMouse(object, x, y, type, mods)
     LVAL object;
     int x, y;
     MouseEventType type;
     MouseClickModifier mods;
{
  CONTEXT cntxt;

  /* establish an execution context */
  xlbegin(&cntxt,CF_ERROR,s_true);

  /* check for error */
  if (! setjmp(cntxt.c_jmpbuf)) {

    /* call the function */
    StGWObDoMouse(object, x, y, type, mods);
  }
  xlend(&cntxt);
}  

sun_button_down_action(action, w, x, y)
     int (*action)(), x, y;
     IVIEW_WINDOW w;
{
  CONTEXT cntxt;
  int error;

  /* establish an execution context */
  xlbegin(&cntxt,CF_ERROR,s_true);

  /* check for error */
  if (setjmp(cntxt.c_jmpbuf)) error = TRUE;
  else {

    /* call the function */
    if (action != NULL) (*action)(w, x, y);
    error = FALSE;
  }
  xlend(&cntxt);
  return(error);
}