Version:
~ [ 10.0 ] ~
** Warning: Cannot open xref database.
1
2 /* $Id: cancoonpopup.c,v 1.4 2005/01/11 22:48:04 andreradke Exp $ */
3
4 /******************************************************************************
5
6 UserLand Frontier(tm) -- High performance Web content management,
7 object database, system-level and Internet scripting environment,
8 including source code editing and debugging.
9
10 Copyright (C) 1992-2004 UserLand Software, Inc.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
26 ******************************************************************************/
27
28 #include "frontier.h"
29 #include "standard.h"
30
31 #include "strings.h"
32 #include "menu.h"
33 #include "quickdraw.h"
34 #include "smallicon.h"
35 #include "popup.h"
36 #include "kb.h"
37 #include "cursor.h"
38 #include "windowlayout.h"
39 #include "lang.h"
40 #include "langexternal.h"
41 #include "scripts.h"
42 #include "tablestructure.h"
43 #include "cancoon.h"
44 #include "cancooninternal.h"
45
46
47
48 typedef struct agentpopupinfo {
49
50 hdlmenu hagentmenu;
51
52 short checkedagentitem;
53
54 short ctagentsvisited;
55 } tyagentpopupinfo, *ptragentpopupinfo;
56
57
58 static boolean ccagentpopupvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) {
59
60 hdltreenode hcode;
61 ptragentpopupinfo info = (ptragentpopupinfo) refcon;
62
63 if (!langexternalvaltocode (val, &hcode)) /*not a scipt, or no code*/
64 return (false);
65
66 ++(*info).ctagentsvisited;
67
68 if (hcode == (**cancoondata).hprimaryagent)
69 (*info).checkedagentitem = (*info).ctagentsvisited;
70
71 if ((*info).hagentmenu == nil) /*not filling out a menu*/
72 return (false);
73
74 return (!pushpopupitem ((*info).hagentmenu, bsname, true, 0)); /*terminate visit on error*/
75 } /*ccagentpopupvisit*/
76
77
78 static boolean ccfillagentpopup (hdlmenu hmenu, short *checkeditem) {
79
80 tyagentpopupinfo info;
81
82 if (agentstable == nil) /*defensive driving*/
83 return (false);
84
85 info.checkedagentitem = -1; /*default*/
86
87 info.hagentmenu = hmenu;
88
89 info.ctagentsvisited = 0;
90
91 if (hashsortedinversesearch (agentstable, &ccagentpopupvisit, &info))
92 return (false);
93
94 *checkeditem = info.checkedagentitem;
95
96 return (true);
97 } /*ccfillagentpopup*/
98
99
100 static boolean ccagentselectvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) {
101
102 /*
103 6/28/91 dmb: never toggle agent off; selecting current agent does nothing
104
105 12/28/91 dmb: when an agent is selected and it's code isn't found, install it
106 */
107
108 hdltreenode hcode;
109 bigstring bs;
110 ptragentpopupinfo info = (ptragentpopupinfo) refcon;
111
112 if (!langexternalvaltocode (val, &hcode)) /*not a scipt*/
113 return (false);
114
115 if (++(*info).ctagentsvisited == (*info).checkedagentitem) {
116
117 register hdlcancoonrecord hc = cancoondata;
118 hdlprocessrecord hprocess;
119
120 /*
121 if ((**hc).hprimaryagent == hcode) /%already selected -- toggle to off, no selection%/
122 (**hc).hprimaryagent = nil;
123 else
124 */
125
126 (**hc).hprimaryagent = hcode;
127
128 if ((*info).hagentmenu != nil) { /*responding to a menu click*/
129
130 if (processfindcode (hcode, &hprocess))
131 copystring ((**hprocess).bsmsg, bs);
132
133 else {
134
135 scriptinstallagent (hnode);
136
137 copystring ((ptrstring) "\x01" " ", bs);
138 }
139
140 ccmsg (bs, false); /*update existing message*/
141
142 ccmsg (zerostring, false); /*unblock agents*/
143
144 if (keyboardstatus.floptionkey || optionkeydown ())
145 langexternalzoom (val, agentstable, bsname);
146 }
147
148 return (true); /*we're done, stop visiting*/
149 }
150
151 return (false); /*keep visiting*/
152 } /*ccagentselectvisit*/
153
154
155 static boolean ccagentpopupselect (hdlmenu hmenu, short itemselected) {
156
157 tyagentpopupinfo info;
158
159 info.checkedagentitem = itemselected;
160
161 info.hagentmenu = hmenu;
162
163 info.ctagentsvisited = 0;
164
165 hashsortedinversesearch (agentstable, &ccagentselectvisit, &info);
166
167 return (true);
168 } /*ccagentpopupselect*/
169
170
171 boolean ccagentpopuphit (Rect rpopup, Point pt) {
172
173 return (popupmenuhit (rpopup, true, &ccfillagentpopup, &ccagentpopupselect));
174 } /*ccagentpopuphit*/
175
176
177 void ccupdateagentpopup (Rect rpopup) {
178
179 /*
180 bigstring bs;
181
182 copystring (zerostring, bs);
183
184 drawpopup (rpopup, bs, true);
185 */
186
187 short extrawidth = (rpopup.right - rpopup.left - popuparrowwidth);
188
189 insetrect (&rpopup, extrawidth / 2, 0);
190
191 displaypopupicon (rpopup, true);
192 } /*ccupdateagentpopup*/
193
194
195 boolean ccgetprimaryagent (short *ixagent) {
196
197 return (ccfillagentpopup (nil, ixagent));
198 } /*ccgetprimaryagent*/
199
200
201 boolean ccsetprimaryagent (short ixagent) {
202
203 if (ixagent <= 0)
204 // return (false);
205 ixagent = 1;
206
207 return (ccagentpopupselect (nil, ixagent));
208 } /*ccsetprimaryagent*/
209
210
211 boolean cccodereplaced (hdltreenode holdcode, hdltreenode hnewcode) {
212
213 register hdlcancoonrecord hc = cancoonglobals;
214
215 if (hc != nil) {
216
217 if ((**hc).hprimaryagent == holdcode)
218 (**hc).hprimaryagent = hnewcode;
219 }
220
221 return (true);
222 } /*cccodereplaced*/
223
224
225
226
227
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.