Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

open-axiom repository from github

24005 views
1
/*
2
Copyright (C) 1991-2002, The Numerical Algorithms Group Ltd.
3
All rights reserved.
4
Copyright (C) 2007-2010, Gabriel Dos Reis.
5
All rights reserved.
6
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions are
9
met:
10
11
- Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
14
- Redistributions in binary form must reproduce the above copyright
15
notice, this list of conditions and the following disclaimer in
16
the documentation and/or other materials provided with the
17
distribution.
18
19
- Neither the name of The Numerical Algorithms Group Ltd. nor the
20
names of its contributors may be used to endorse or promote products
21
derived from this software without specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
#include "openaxiom-c-macros.h"
37
#include "debug.h"
38
#include "sockio.h"
39
#include "hyper.h"
40
41
static void clear_rbs(InputBox * list);
42
43
void
44
fill_box(Window w,ImageStruct * image)
45
{
46
XClearWindow(gXDisplay, w);
47
XPutImage(gXDisplay, w, gWindow->fControlGC,
48
image->image.xi, 0, 0, 0, 0,
49
image->width,
50
image->height);
51
}
52
53
void
54
toggle_input_box(HyperLink *link)
55
{
56
InputBox *box;
57
58
box = link->reference.box;
59
60
if (box->picked) {
61
box->picked = 0;
62
unpick_box(box);
63
}
64
else {
65
box->picked = 1;
66
pick_box(box);
67
}
68
69
}
70
void
71
toggle_radio_box(HyperLink *link)
72
{
73
InputBox *box;
74
75
box = link->reference.box;
76
77
if (box->picked) {
78
79
/*
80
* box->picked = 0; unpick_box(box);
81
*/
82
}
83
else {
84
/* the first thing I do is clear his buddies */
85
clear_rbs(box->rbs->boxes);
86
box->picked = 1;
87
pick_box(box);
88
}
89
}
90
91
static void
92
clear_rbs(InputBox *list)
93
{
94
InputBox *trace = list;
95
96
while (trace && !trace->picked)
97
trace = trace->next;
98
99
if (trace != NULL) {
100
trace->picked = 0;
101
unpick_box(trace);
102
}
103
}
104
void
105
change_input_focus(HyperLink *link)
106
{
107
InputItem *new_item = link->reference.string;
108
InputItem *old_item = gWindow->page->current_item;
109
XWindowChanges wc;
110
111
/** first thing I should do is see if the user has clicked in the same
112
window that I am in ****/
113
if (old_item == new_item)
114
return;
115
116
/** Now change the current pointer **/
117
gWindow->page->current_item = new_item;
118
119
/** Now I have to change the border width of the selected input window **/
120
wc.border_width = 1;
121
XConfigureWindow(gXDisplay, new_item->win,
122
CWBorderWidth,
123
&wc);
124
125
wc.border_width = 0;
126
XConfigureWindow(gXDisplay, new_item->win,
127
CWBorderWidth,
128
&wc);
129
update_inputsymbol(old_item);
130
update_inputsymbol(new_item);
131
}
132
void
133
next_input_focus()
134
{
135
InputItem *old_item = gWindow->page->current_item, *new_item, *trace;
136
137
if (gWindow->page->current_item == NULL ||
138
(gWindow->page->current_item->next == NULL
139
&& gWindow->page->current_item == gWindow->page->input_list)) {
140
BeepAtTheUser();
141
return;
142
}
143
144
/*
145
* Now I should find the new item
146
*/
147
new_item = NULL;
148
trace = old_item->next;
149
150
if (trace == NULL)
151
new_item = gWindow->page->input_list;
152
else
153
new_item = trace;
154
155
gWindow->page->current_item = new_item;
156
draw_inputsymbol(old_item);
157
draw_inputsymbol(new_item);
158
}
159
void
160
prev_input_focus()
161
{
162
InputItem *old_item = gWindow->page->current_item, *new_item, *trace;
163
164
if (gWindow->page->current_item == NULL) {
165
BeepAtTheUser();
166
return;
167
}
168
169
/*
170
* Now I should find the new item
171
*/
172
new_item = NULL;
173
trace = gWindow->page->input_list;
174
175
if (trace == old_item) {
176
177
/*
178
* I started at the front of the list, so move forward until I hit
179
* the end
180
*/
181
while (trace->next != NULL)
182
trace = trace->next;
183
new_item = trace;
184
}
185
else {
186
while (trace->next != old_item)
187
trace = trace->next;
188
new_item = trace;
189
}
190
191
gWindow->page->current_item = new_item;
192
draw_inputsymbol(old_item);
193
draw_inputsymbol(new_item);
194
195
}
196
197
InputItem *
198
return_item(char *name)
199
{
200
InputItem *list;
201
202
list = gWindow->page->input_list;
203
while (list != NULL) {
204
if (!strcmp(name, list->name))
205
return list;
206
list = list->next;
207
}
208
return NULL;
209
}
210
int
211
delete_item(char *name)
212
{
213
InputItem *list;
214
InputItem *prev = NULL;
215
216
list = gWindow->page->input_list;
217
while (list != NULL) {
218
if (!strcmp(name, list->name)) {
219
if (prev)
220
prev->next = list->next;
221
else
222
gWindow->page->input_list = list->next;
223
if (gWindow->page->current_item == list)
224
gWindow->page->current_item = gWindow->page->input_list;
225
free_input_item(list, 1);
226
free(list);
227
return 1;
228
}
229
prev = list;
230
list = list->next;
231
}
232
fprintf(stderr, "Can't delete input item %s\n", name);
233
return 0;
234
}
235
236
237