cancoonpopup.c

Go to the documentation of this file.
00001 
00002 /*  $Id: cancoonpopup.c 1201 2006-04-05 22:31:38Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "strings.h"
00032 #include "menu.h"
00033 #include "quickdraw.h"
00034 #include "smallicon.h"
00035 #include "popup.h"
00036 #include "kb.h"
00037 #include "cursor.h"
00038 #include "windowlayout.h"
00039 #include "lang.h"
00040 #include "langexternal.h"
00041 #include "scripts.h"
00042 #include "tablestructure.h"
00043 #include "cancoon.h"
00044 #include "cancooninternal.h"
00045 
00046 
00047 
00048 typedef struct agentpopupinfo {
00049     
00050     hdlmenu hagentmenu;
00051 
00052     short checkedagentitem;
00053 
00054     short ctagentsvisited;
00055     } tyagentpopupinfo, *ptragentpopupinfo;
00056 
00057 
00058 static boolean ccagentpopupvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) {
00059 #pragma unused (hnode)
00060 
00061     hdltreenode hcode;
00062     ptragentpopupinfo info = (ptragentpopupinfo) refcon;
00063     
00064     if (!langexternalvaltocode (val, &hcode)) /*not a scipt, or no code*/
00065         return (false);
00066     
00067     ++(*info).ctagentsvisited;
00068     
00069     if (hcode == (**cancoondata).hprimaryagent)
00070         (*info).checkedagentitem = (*info).ctagentsvisited;
00071     
00072     if ((*info).hagentmenu == nil) /*not filling out a menu*/
00073         return (false);
00074     
00075     return (!pushpopupitem ((*info).hagentmenu, bsname, true, 0)); /*terminate visit on error*/
00076     } /*ccagentpopupvisit*/
00077 
00078 
00079 static boolean ccfillagentpopup (hdlmenu hmenu, short *checkeditem) {
00080     
00081     tyagentpopupinfo info;
00082     
00083     if (agentstable == nil) /*defensive driving*/
00084         return (false);
00085     
00086     info.checkedagentitem = -1; /*default*/
00087     
00088     info.hagentmenu = hmenu;
00089     
00090     info.ctagentsvisited = 0;
00091     
00092     if (hashsortedinversesearch (agentstable, &ccagentpopupvisit, &info))
00093         return (false);
00094     
00095     *checkeditem = info.checkedagentitem;
00096     
00097     return (true);
00098     } /*ccfillagentpopup*/
00099 
00100 
00101 static boolean ccagentselectvisit (bigstring bsname, hdlhashnode hnode, tyvaluerecord val, ptrvoid refcon) {
00102     
00103     /*
00104     6/28/91 dmb: never toggle agent off; selecting current agent does nothing
00105     
00106     12/28/91 dmb: when an agent is selected and it's code isn't found, install it
00107     */
00108     
00109     hdltreenode hcode;
00110     bigstring bs;
00111     ptragentpopupinfo info = (ptragentpopupinfo) refcon;
00112     
00113     if (!langexternalvaltocode (val, &hcode)) /*not a scipt*/
00114         return (false);
00115     
00116     if (++(*info).ctagentsvisited == (*info).checkedagentitem) {
00117         
00118         register hdlcancoonrecord hc = cancoondata;
00119         hdlprocessrecord hprocess;
00120         
00121         /*
00122         if ((**hc).hprimaryagent == hcode) /%already selected -- toggle to off, no selection%/
00123             (**hc).hprimaryagent = nil;
00124         else
00125         */
00126         
00127             (**hc).hprimaryagent = hcode;
00128         
00129         if ((*info).hagentmenu != nil) { /*responding to a menu click*/
00130             
00131             if (processfindcode (hcode, &hprocess))
00132                 copystring ((**hprocess).bsmsg, bs);
00133             
00134             else {
00135                 
00136                 scriptinstallagent (hnode);
00137                 
00138                 copystring ((ptrstring) "\x01" " ", bs);
00139                 }
00140             
00141             ccmsg (bs, false); /*update existing message*/
00142             
00143             ccmsg (zerostring, false); /*unblock agents*/
00144             
00145             if (keyboardstatus.floptionkey || optionkeydown ())
00146                 langexternalzoom (val, agentstable, bsname);
00147             }
00148         
00149         return (true); /*we're done, stop visiting*/
00150         }
00151     
00152     return (false); /*keep visiting*/
00153     } /*ccagentselectvisit*/
00154 
00155 
00156 static boolean ccagentpopupselect (hdlmenu hmenu, short itemselected) {
00157     
00158     tyagentpopupinfo info;
00159     
00160     info.checkedagentitem = itemselected;
00161     
00162     info.hagentmenu = hmenu;
00163     
00164     info.ctagentsvisited = 0;
00165     
00166     hashsortedinversesearch (agentstable, &ccagentselectvisit, &info);
00167     
00168     return (true);
00169     } /*ccagentpopupselect*/
00170 
00171 
00172 boolean ccagentpopuphit (Rect rpopup, Point pt) {
00173 #pragma unused (pt)
00174 
00175     return (popupmenuhit (rpopup, true, &ccfillagentpopup, &ccagentpopupselect));
00176     } /*ccagentpopuphit*/
00177 
00178 
00179 void ccupdateagentpopup (Rect rpopup) {
00180     
00181     /*
00182     bigstring bs;
00183     
00184     copystring (zerostring, bs);
00185     
00186     drawpopup (rpopup, bs, true);
00187     */
00188     
00189     short extrawidth = (rpopup.right - rpopup.left - popuparrowwidth);
00190     
00191     insetrect (&rpopup, extrawidth / 2, 0);
00192     
00193     displaypopupicon (rpopup, true);    
00194     } /*ccupdateagentpopup*/
00195 
00196 
00197 boolean ccgetprimaryagent (short *ixagent) {
00198     
00199     return (ccfillagentpopup (nil, ixagent));
00200     } /*ccgetprimaryagent*/
00201 
00202 
00203 boolean ccsetprimaryagent (short ixagent) {
00204     
00205     if (ixagent <= 0)
00206     //  return (false);
00207         ixagent = 1;
00208     
00209     return (ccagentpopupselect (nil, ixagent));
00210     } /*ccsetprimaryagent*/
00211 
00212 
00213 boolean cccodereplaced (hdltreenode holdcode, hdltreenode hnewcode)  {
00214     
00215     register hdlcancoonrecord hc = cancoonglobals;
00216     
00217     if (hc != nil) {
00218         
00219         if ((**hc).hprimaryagent == holdcode)
00220             (**hc).hprimaryagent = hnewcode;
00221         }
00222     
00223     return (true);
00224     } /*cccodereplaced*/
00225 
00226 
00227 
00228 

Generated on Wed May 31 18:19:44 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6