static boolean browservalidatefolderpaste (hdlheadrecord hfolder, FSSpec *clipfolderspec) { /* check for collisions -- if there already is a file in the target folder with the same name as one of the items we're pasting, a dialog appears confirming the replacement. all files that need to be deleted have their tmpbits set. the caller should delete them. we don't do the deletion here so that the deletions can be undoable. */ tydraginfo; if ((**hfolder).headlinkleft == hfolder) { alertdialog (BIGSTRING ("\x32" "CanÕt paste at the top level of a browser outline.")); return (false); } draginfo.hdest = hfolder; draginfo.ctcollisions = draginfo.collisiontype = 0; opcleartmpbits (); folderloop (clipfolderspec, false, &validatepastecallback, &draginfo); return (browsercollisiondialog (hfolder, BIGSTRING ("\x07" "pasting"))); } /*browservalidatefolderpaste*/
static boolean compareforcopyvisit (hdlheadrecord hnode, ptrvoid refcon) { bigstring bs, bsnode; ptrdraginfo draginfo = (ptrdraginfo) refcon; if (hnode == (*draginfo).hcompare) return (true); opgetheadstring (hnode, bsnode); opgetheadstring ((*draginfo).hcompare, bs); if (!equalidentifiers (bsnode, bs)) return (true); copystring (BIGSTRING ("\x06" "CanÕt "), bs); pushstring (pcommand, bs); pushstring (BIGSTRING ("\x35" " because there are two or more selected items named Ò"), bs); pushstring (bsnode, bs); pushstring (BIGSTRING ("\x02" "Ó."), bs); alertdialog (bs); return (false); /*stop both traversals*/ } /*compareforcopyvisit*/
boolean claygetspecialfolder (void *foldername, boolean flcreate, tybrowserspec *fsspecialfolder) { /* a bottleneck for finding special Clay Basket folders. it actually works for files too -- it's used to locate the preferences file. if flcreate is true, and the folder doesn't exist, we create it. DW 3/12/95: Add another level, the Clay Basket folder is contained within the UserLand folder. */ #if filebrowser tybrowserspec fsuserland, fsfolder; if (!filegetprefsspec (BIGSTRING ("\x08" "UserLand"), &fsuserland)) return (false); if (!clayfileexists (&fsuserland, &flfolder)) { if (!filecreatefolder (&fsuserland)) return (false); } if (!claygetsubitemspec (&fsuserland, BIGSTRING ("\x12" "Clay Basket Folder"), &fsfolder)) return (false); if (!clayfileexists (&fsfolder, &flfolder)) { if (!filecreatefolder (&fsfolder)) return (false); } if (!claygetsubitemspec (&fsfolder, foldername, fsspecialfolder)) return (false); #endif #if odbbrowser static hdlhashtable hclaybaskettable = nil; if (hclaybaskettable == nil) { // first time called if (!newhashtable (&hclaybaskettable)) return (false); } claymakespec (nil, hclaybaskettable, foldername, fsspecialfolder); #endif if (!flcreate) return (true); if (!clayfileexists (fsspecialfolder, &flfolder)) /*doesn't exist*/ return (filecreatefolder (fsspecialfolder)); return (true); } /*claygetspecialfolder*/
boolean opattributesgetpackedtablevalue (hdlheadrecord hnode, tyvaluerecord *val) { /* 7.0b16 PBS: get the table packed as a binary in a headline's refcon. */ Handle hrefcon = (**hnode).hrefcon; tyvaluerecord linkedval; boolean fl = false; if (!ophasrefcon (hnode)) {/*if no refcon, no attributes*/ langerrormessage (BIGSTRING ("\x39""Can't get attributes because this headline has no refcon.")); goto exit1; } if (!langunpackvalue (hrefcon, &linkedval)) { /*try to unpack the refcon*/ langerrormessage (BIGSTRING ("\x3e""Can't get attributes because of an error unpacking the refcon.")); goto exit1; } if (linkedval.valuetype != binaryvaluetype) { /*must be a binary*/ langerrormessage (BIGSTRING ("\x3e""Can't get attributes because the refcon is not of binary type.")); goto exit2; } if (!langunpackvalue (linkedval.data.binaryvalue, val)) { /*it's a packed binary: unpack it.*/ langerrormessage (BIGSTRING ("\x3e""Can't get attributes because of an error unpacking the refcon.")); goto exit2; } fl = true; exit2: disposevaluerecord (linkedval, false); exit1: return (fl); } /*opattributesgetpackedtable*/
boolean tabledisposetable (hdlhashtable htable, boolean fldisk) { register hdlhashtable ht = htable; register hdltableformats hf; hdlwindowinfo hinfo; if (ht) { #ifdef fldebug if (tablefinddatawindow (ht, &hinfo)) { shellinternalerror (0, BIGSTRING ("\x1d" "table shouldn't have a window")); shellclosewindow ((**hinfo).macwindow); } #endif hf = (hdltableformats) (**ht).hashtableformats; if (hf) { disposetableformats (hf); } disposehashtable (ht, fldisk); } return (true); } /*tabledisposetable*/
static boolean mefindusedblocksvisit (hdlheadrecord hnode, ptrvoid refcon) { /* if there's a script attached to hnode, note the database usage. */ ptrstring bsparent = (ptrstring) refcon; tymenuiteminfo item; bigstring bspath; if (megetmenuiteminfo (hnode, &item)) { /*something linked*/ opgetheadstring (hnode, bspath); pushchar (']', bspath); insertstring (BIGSTRING ("\x02" " ["), bspath); insertstring (bsparent, bspath); return (statsblockinuse (item.linkedscript.adrlink, bspath)); } return (true); /*keep visiting*/ } /*mefindusedblocksvisit*/
static void dockmenuinsertsubmenu (hdlmenu hmenu, short itemnumber, hdlheadrecord hnode) { /* 7.1b23 PBS: build a sub-menu and attach it. */ hdlmenu hsubmenu; short id = defaultpopupmenuid; #ifdef MACVERSION idsubmenu++; id = idsubmenu; #endif hsubmenu = Newmenu (id, BIGSTRING ("")); #ifdef MACVERSION InsertMenu (hsubmenu, -1); #endif dockmenubuildpopupmenu (hnode, hsubmenu); dockmenuaddtomenustack (hsubmenu, id); sethierarchicalmenuitem (hmenu, itemnumber, hsubmenu, id); } /*dockmenuinsertsubmenu*/
OSStatus pathtofsref ( bigstring bspath, FSRef *ref ) { /* 2009-08-30 aradke: mac-only helper function for converting from a pascal string (path) to an FSRef */ bigstring bs; CFStringRef csref; char str[256]; copystring(bspath, bs); // convert from colon-delimited to slash-delimited path stringswapall(':', '/', bs); insertstring ( BIGSTRING ( "\x09" "/Volumes/" ), bs ); // convert from Mac Roman to UTF-8 */ csref = CFStringCreateWithPascalString(kCFAllocatorDefault, bs, kCFStringEncodingMacRoman); CFStringGetCString(csref, str, sizeof(str), kCFStringEncodingUTF8); CFRelease(csref); // finally, pass our temporary copy of the string to the underlying system function return FSPathMakeRef((UInt8*) str, ref, NULL); } /*pathtofsref*/
boolean browservalidatepaste (hdlheadrecord hscrap, hdlheadrecord hdest, tydirection dir) { /* return false to cancel the paste. assume that paste always happens in the list of the cursor's parent. */ #if filebrowser hdlheadrecord hfolder = (**hdest).headlinkleft; if (hfolder == hdest) { alertdialog (BIGSTRING ("\x32" "CanÕt paste at the top level of a browser outline.")); return (false); } #endif if (!browservalidateinsertion (hdest, hscrap, dir, validatepaste)) /*user declined to replace already-existing files*/ return (false); browserdeletenodeswithtmpbitset (); return (true); } /*browservalidatepaste*/
boolean registerFileType (bigstring extension, bigstring filetype, bigstring contenttype, bigstring filedescription, bigstring iconfile, short iconid, bigstring shellopen) { bigstring sval, skey; if ((extension == NULL) || (filetype == NULL)) return (false); if (stringlength (extension) < 2) return (false); if (stringlength (filetype) == 0) return (false); /* Register with the Registry */ setRegKeyValue (extension, NULL, filetype); if (contenttype != NULL) { setRegKeyValue (extension, BIGSTRING ("\x0c" "Content Type"), contenttype); } if (filedescription == NULL) return (true); /* nothing more to do */ setRegKeyValue (filetype, NULL, filedescription); if (iconfile != NULL) { copystring (iconfile, sval); pushchar (',', sval); pushint (iconid, sval); copystring (filetype, skey); pushstring (BIGSTRING ("\x0c" "\\DefaultIcon"), skey); setRegKeyValue (skey, NULL, sval); } if (shellopen != NULL) { copystring (filetype, skey); pushstring (BIGSTRING ("\x13" "\\shell\\open\\command"), skey); setRegKeyValue (skey, NULL, shellopen); } return (true); }
boolean opgetnodetypetableadr(bigstring bsnodetype, bigstring bsadrnodepath) { //user.tools.nodeTypes.[type] //Frontier.tools.data.nodeTypes.[type] boolean fllookup = false; copystring(BIGSTRING("\x15" "user.tools.nodeTypes."), bsadrnodepath); pushstring(bsnodetype, bsadrnodepath); fllookup = resolveHashTable(bsnodetype, bsadrnodepath); if (!fllookup) { copystring(BIGSTRING("\x1E" "Frontier.tools.data.nodeTypes."), bsadrnodepath); pushstring(bsnodetype, bsadrnodepath); fllookup = resolveHashTable(bsnodetype, bsadrnodepath); } return fllookup; }
static boolean winregpullhkeyfromtext (Handle htext, HKEY *hkey) { /* 7.0.2b1 Radio PBS: get the base key from the text string. Remove it from the text string. If a string is HKCU/foo/bar/, then htext becomes foo\bar\, and *hkey becomes HKEY_CLASSES_USER. */ short ixslash; bigstring bsbase; boolean fl = false; ixslash = textpatternmatch (*htext, gethandlesize (htext), BIGSTRING ("\x01\\"), true); if (ixslash == -1) /*didn't find?*/ return (false); pullfromhandle (htext, 0, ixslash, stringbaseaddress (bsbase)); pullfromhandle (htext, 0, 1, nil); /*remove leading /*/ setstringlength (bsbase, ixslash); allupper (bsbase); /*case insensitive*/ if ((equalstrings (bsbase, STR_P_HKCU_SHORT)) || (equalstrings (bsbase, STR_P_HKCU_LONG))) { *hkey = HKEY_CURRENT_USER; fl = true; } if ((equalstrings (bsbase, STR_P_HKLM_SHORT)) || (equalstrings (bsbase, STR_P_HKLM_LONG))) { *hkey = HKEY_LOCAL_MACHINE; fl = true; } if ((equalstrings (bsbase, STR_P_HKCR_SHORT)) || (equalstrings (bsbase, STR_P_HKCR_LONG))) { *hkey = HKEY_CLASSES_ROOT; fl = true; } if ((equalstrings (bsbase, STR_P_HKU_SHORT)) || (equalstrings (bsbase, STR_P_HKU_LONG))) { *hkey = HKEY_USERS; fl = true; } if ((equalstrings (bsbase, STR_P_HKCC_SHORT)) || (equalstrings (bsbase, STR_P_HCC_LONG))) { *hkey = HKEY_CURRENT_CONFIG; fl = true; } return (fl); } /*winregpullhkeyfromtext*/
boolean aboutsetthreadstring (hdlprocessthread hp, boolean flin) { register hdlcancoonrecord hc = cancoonglobals; hdlthreadglobals hg = (hdlthreadglobals) hp; boolean fl = false; hdlwindowinfo hinfo; if (hc == nil) return (false); if (!aboutstatsshowing ()) return (false); if (!findaboutwindow (&hinfo) || !shellpushglobals ((**hinfo).macwindow)) return (false); if (flin) { numbertostring ((long) (**hg).idthread, bstheadinfo); if ((**hg).hprocess) { pushstring (BIGSTRING ("\x02" " ["), bstheadinfo); pushstring ((**(**hg).hprocess).bsname, bstheadinfo); pushchar (']', bstheadinfo); } } else insertstring (BIGSTRING ("\x06" "(out) "), bstheadinfo); if (aboutdata != nil) ccupdatestatistics (false); shellpopglobals (); return (fl); } /*aboutsetthreadstring*/
static pascal void *cmdthreadmain (tythreadmainparams hprocess) { /* 2.1b2 dmb: use getobjectmodeldisplaystring to diplay result 2.1b4 dmb: use the debugger context, if available (i.e. a script is currently suspended). 4.0.1b1 dmb: pass name of thread to initprocessthread; call exitprocessthread */ register hdlprocessrecord hp = (hdlprocessrecord) hprocess; tyvaluerecord val; bigstring bsresult; hdlhashtable hcontext = nil; boolean fl; initprocessthread (BIGSTRING ("\x0c" "quick script")); /*must call from every thread main*/ if ((**hp).fldisposewhenidle) fl = false; else { if (scriptgetdebuggingcontext (&hcontext)) (**hp).hcontext = hcontext; fl = processruncode (hp, &val); if (hcontext != nil) scriptunlockdebuggingcontext (); } disposeprocess (hp); if (!fl) setbooleanvalue (false, &val); getobjectmodeldisplaystring (&val, bsresult); /*hashgetvaluestring (val, bsresult)*/ disposetmpvalue (&val); minisetwindowmessage (idcommandconfig, bsresult); /*can't assume miniwindow is around anymore*/ quickscriptprocess = nil; /*clear "semaphore"*/ exitprocessthread (); return (nil); } /*cmdthreadmain*/
boolean claymovefile (const tybrowserspec *fs, const tybrowserspec *fsto) { tyvaluerecord val; hdlhashtable hdest; boolean fl; hdlhashnode hnode; if (!claygetdirid (fsto, &hdest)) { langerrormessage (BIGSTRING ("\x1b" "destination must be a table")); return (false); } opstartinternalchange (); pushhashtable ((*fs).parID); fl = hashlookup ((*fs).name, &val, &hnode); if (fl) { // if ((*fs).parID == agentstable) hashdelete ((*fs).name, false, false); /*don't toss the value*/ } pophashtable (); if (fl) { fl = hashtableassign (hdest, (*fs).name, val); /* if (fl && (hdest == agentstable) { hashtablelookupnode (hdest, (*fs).name, &hnode); scriptinstallagent (hnode); } */ } opendinternalchange (); return (true); } /*claymovefile*/
static void claygetfatsizestring (const tybrowserinfo *browserinfo, bigstring bs) { setstringlength (bs, 0); if ((*browserinfo).flvolume) { tybrowserspec fs; tyfileinfo fileinfo; if (!claymakespec ((*browserinfo).vnum, 0, "\0", &fs)) return; if (!filegetinfo (&fs, &fileinfo)) return; numbertostring (fileinfo.cttotalbytes, bs); return; } if ((*browserinfo).flfolder) { short ctfiles = (*browserinfo).filesize; numbertostring (ctfiles, bs); pushstring (BIGSTRING ("\x05" " item"), bs); if (ctfiles != 1) pushstring (BIGSTRING ("\x01" "s"), bs); return; } numbertostring ((*browserinfo).filesize, bs); } /*claygetfatsizestring*/
static void pushadjective (bigstring adjective, bigstring bs) { bigstring adj; copystring (adjective, adj); /*we might modify it*/ if (stringlength (bs) > 0) { pushstring (BIGSTRING ("\x01" " "), bs); alllower (adj); } pushstring (adj, bs); } /*pushadjective*/
pascal OSStatus dockmenuhandler (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { /* 7.1b22 PBS: called from the system when the dock icon is right-clicked. Build a contextual menu and return it. */ #pragma unused(nextHandler) /*happy compiler*/ #pragma unused(theEvent) #pragma unused(userData) hdlmenu hmenu; hdlmenurecord hm; static boolean flinited = false; menuid = 0; dockmenuresetmenustack (); /*7.1b23 PBS: maintain a stack of submenus*/ if (!flinited) { /*install command handler first time*/ dockmenuinstallhandler (); flinited = true; } /*if*/ hmenu = Newmenu (defaultpopupmenuid, BIGSTRING ("")); if (!dockmenufillpopup (hmenu, &hm)) goto exit; dockmenuaddtomenustack (hmenu, defaultpopupmenuid); hcurrmenurecord = hm; SetEventParameter (theEvent, kEventParamMenuRef, typeMenuRef, sizeof (MenuRef), &hmenu); exit: return (noErr); /*all's well in dock-menu-land*/ } /*dockmenuhandler*/
static boolean closeverb (hdltreenode hparam1, tyvaluerecord *vreturned) { /* 2005-09-14 creedon: added fldialog parameter 8/26/92 dmb: don't allow the root window to be closed with this verb. (note: used to crash; need to call shellclose to handle root windows) */ register boolean fl = false; hdlwindowinfo hinfo; boolean fldialog; tyvaluerecord val; short ctconsumed = 1; short ctpositional = 1; setbooleanvalue (false, &val); /* defaults to false */ if (!getwinparam (hparam1, 1, &hinfo)) return (false); flnextparamislast = true; if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x08""fldialog"), &val)) return (false); fldialog = val.data.flvalue; if (hinfo != nil) { /* close it if it isn't a root window */ // if ((**hinfo).parentwindow != nil /*|| shellgetexternaldata (hinfo, &hdata)*/) fl = shellclose ((**hinfo).macwindow, fldialog); } setbooleanvalue (fl, vreturned); return (true); } /*closeverb*/
boolean ploticoncustom (const Rect *r, short align, short transform) { /* 7.0b9 PBS: plot a custom icon. */ #ifdef WIN95VERSION HBITMAP hbm, oldbm; BITMAP bm; HDC hdcsrc, hdc; boolean flprinting; HDC hdcmask; HBITMAP hbmmask, oldmaskbm; COLORREF oldclr, oldclr2; bigstring bsadricon = BIGSTRING ("\x18" "user.playlist.icons.face"); bigstring bsname; hdlhashtable ht; hdlhashnode hn; tyvaluerecord iconvalue; bigstring bsiconname = BIGSTRING ("\x04" "face"); boolean flexpanded = false; boolean fllookup = false; Handle hicon; pushhashtable (roottable); disablelangerror (); flexpanded = langexpandtodotparams (bsadricon, &ht, bsname); enablelangerror (); pophashtable (); fllookup = hashtablelookup (ht, bsiconname, &iconvalue, &hn); copyhandle (iconvalue.data.binaryvalue, &hicon); stripbinarytypeid (hicon); hbm = CreateBitmap (16, 16, 1, 32, hicon); // hbm = LoadImage (shellinstance, "face.bmp", IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE); if (hbm) { hdc = getcurrentDC(); flprinting = iscurrentportprintport (); if (hdc) { hdcsrc = CreateCompatibleDC (hdc); if (hdcsrc) { //GetObject (hbm, sizeof (BITMAP), &bm); bm.bmType = 0; bm.bmWidth = 16; bm.bmHeight = 16; bm.bmWidthBytes = 32; bm.bmPlanes = 1; bm.bmBitsPixel = 16; bm.bmBits = hicon; oldbm = (HBITMAP) SelectObject (hdcsrc, hbm); if (flprinting) { // StretchBlt (hdc, r->left, r->top, r->right-r->left, r->bottom - r->top, hdcsrc, 0,0, bm.bmWidth, bm.bmHeight, SRCCOPY); } else { hdcmask = CreateCompatibleDC (hdc); hbmmask = CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL); if (hdcmask && hbmmask) { oldmaskbm = (HBITMAP) SelectObject (hdcmask, hbmmask); oldclr = SetBkColor (hdcsrc, RGB(255,255,255)); BitBlt (hdcmask, 0,0,bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCCOPY); SetBkColor (hdcsrc,oldclr); eraserect (*r); oldclr = SetBkColor (hdc, RGB(255,255,255)); oldclr2 = SetTextColor (hdc, RGB(0,0,0)); BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT); BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcmask, 0,0, SRCAND); BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT); SetBkColor (hdc,oldclr); SetTextColor (hdc,oldclr2); SelectObject (hdcmask, oldmaskbm); // BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCAND); } DeleteObject (hbmmask); DeleteDC (hdcmask); } SelectObject (hdcsrc, oldbm); DeleteDC (hdcsrc); } } DeleteObject (hbm); } disposehandle (hicon); return (true); #endif } /*ploticoncustom*/
boolean ploticonfromodb (const Rect *r, short align, short transform, bigstring bsadricon) { #if defined (MACVERSION) //bigstring bsadricon = "\psystem.verbs.builtins.Frontier.tools.data.nodeTypes.link.icon.mac"; IconRef iconRef; IconFamilyHandle iconHand; SInt32 theSize; OSStatus theErr; Handle hicon; bigstring bsadriconpart; theErr = noErr; theSize = sizeof(OSType) + sizeof(OSType); newhandle(theSize, (Handle*) &iconHand); //iconHand = (IconFamilyHandle) getnewhandle(theSize, false); if (iconHand == NULL) theErr = memFullErr; if (theErr == noErr) { (*iconHand)->resourceType = EndianU32_NtoB(kIconFamilyType); (*iconHand)->resourceSize = EndianU32_NtoB(theSize); } if (theErr == noErr) { setemptystring(bsadriconpart); copystring(bsadricon, bsadriconpart); pushstring(BIGSTRING("\x05" ".ics4"), bsadriconpart); theErr = loadicondatafromodb(bsadriconpart, BIGSTRING("\x04" "ics4"), &hicon); if (theErr == noErr) { theErr = SetIconFamilyData(iconHand, kSmall4BitData, hicon); disposehandle(hicon); } } if (theErr == noErr) { setemptystring(bsadriconpart); copystring(bsadricon, bsadriconpart); pushstring(BIGSTRING("\x05" ".ics8"), bsadriconpart); theErr = loadicondatafromodb(bsadriconpart, BIGSTRING("\x04" "ics8"), &hicon); if (theErr == noErr) { theErr = SetIconFamilyData(iconHand, kSmall8BitData, hicon); disposehandle(hicon); } } if (theErr == noErr) { setemptystring(bsadriconpart); copystring(bsadricon, bsadriconpart); pushstring(BIGSTRING("\x09" ".icspound"), bsadriconpart); theErr = loadicondatafromodb(bsadriconpart, BIGSTRING("\x08" "icspound"), &hicon); if (theErr == noErr) { theErr = SetIconFamilyData(iconHand, kSmall1BitMask, hicon); disposehandle(hicon); } } if (theErr == noErr) { theErr = GetIconRefFromIconFamilyPtr(*iconHand, GetHandleSize((Handle) iconHand), &iconRef); } if (theErr == noErr) { theErr = PlotIconRef(r, align, transform, kIconServicesNormalUsageFlag, iconRef); } setemptystring(bsadriconpart); ReleaseIconRef(iconRef); disposehandle((Handle) iconHand); return theErr == noErr; #else if defined (WIN95VERSION) return FALSE; #endif }
#define aboutrowsNoStats 3 #define aboutrectheightNoStats (aboutvertinset * 2 + aboutvertstart + aboutrowsNoStats * aboutlineheight + aboutvertgap) #define abouticonsize 32 #define versionwidth 56 #define minaboutwidth (aboutlinewidth + abouthorizgap + 2 * abouthorizinset) #define agentmenuhorizgap 10 static byte * aboutstrings [] = { BIGSTRING ("\x2e" "Powerful cross-platform web content management"), /*6.1 AR*/ /*"\x25" "Powerful cross-platform web scripting",*/ BIGSTRING ("\x23" "© 1992-2000 UserLand Software, Inc."), #ifdef PIKE BIGSTRING ("\x19" "http://pike.userland.com/"), #else BIGSTRING ("\x1d" "http://frontier.userland.com/"), #endif BIGSTRING ("\x02" "^0"), BIGSTRING ("\x12" "Scripts Running: "),
boolean ploticoncustom (const Rect *r, short align, short transform, bigstring bsiconname) { /* 7.0b9 PBS: plot a custom icon. */ #ifdef MACVERSION short rnum; short resid = 128; /*Always 128 for custom icons*/ short saveresfile; /*Get the resource reference for the file containing this icon.*/ if (!customicongetrnum (bsiconname, &rnum)) { /*Already loaded?*/ if (!customiconload (bsiconname, &rnum)) { /*Try to load it.*/ return (false); } /*if*/ } /*if*/ saveresfile = CurResFile (); UseResFile (rnum); ploticonresource (r, align, transform, resid); UseResFile (saveresfile); return (true); #endif #ifdef WIN95VERSION HBITMAP hbm, oldbm; BITMAP bm; HDC hdcsrc, hdc; boolean flprinting; HDC hdcmask; HBITMAP hbmmask, oldmaskbm; COLORREF oldclr, oldclr2; bigstring bsfilepath; char cfilepath [256]; copystring (BIGSTRING ("\x11" "Appearance\\Icons\\"), bsfilepath); pushstring (bsiconname, bsfilepath); /*add file name to folder path*/ pushstring (BIGSTRING ("\x04" ".bmp"), bsfilepath); /*add .bmp file extension*/ copyptocstring (bsfilepath, cfilepath); /*Load the image from a file.*/ hbm = LoadImage (shellinstance, cfilepath, IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE); if (hbm == NULL) /*Load failed, return false, use default icon.*/ return (false); if (hbm) { hdc = getcurrentDC(); flprinting = iscurrentportprintport (); if (hdc) { hdcsrc = CreateCompatibleDC (hdc); if (hdcsrc) { GetObject (hbm, sizeof (BITMAP), &bm); oldbm = (HBITMAP) SelectObject (hdcsrc, hbm); if (flprinting) { // StretchBlt (hdc, r->left, r->top, r->right-r->left, r->bottom - r->top, hdcsrc, 0,0, bm.bmWidth, bm.bmHeight, SRCCOPY); } else { hdcmask = CreateCompatibleDC (hdc); hbmmask = CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL); if (hdcmask && hbmmask) { oldmaskbm = (HBITMAP) SelectObject (hdcmask, hbmmask); oldclr = SetBkColor (hdcsrc, RGB(255,255,255)); BitBlt (hdcmask, 0,0,bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCCOPY); SetBkColor (hdcsrc,oldclr); eraserect (*r); oldclr = SetBkColor (hdc, RGB(255,255,255)); oldclr2 = SetTextColor (hdc, RGB(0,0,0)); BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT); BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcmask, 0,0, SRCAND); BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT); SetBkColor (hdc,oldclr); SetTextColor (hdc,oldclr2); SelectObject (hdcmask, oldmaskbm); // BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCAND); } DeleteObject (hbmmask); DeleteDC (hdcmask); } SelectObject (hdcsrc, oldbm); DeleteDC (hdcsrc); } } DeleteObject (hbm); } return (true); #endif } /*ploticoncustom*/
boolean opattributesgettypestring (hdlheadrecord hnode, bigstring bstype) { /* 7.0b4 PBS: Get the node type of a headline. Unpack the refcon, look in the table for a type attribute, set bstype equal to that string. 7.0b14 PBS: Fixed memory leaks. */ Handle hrefcon = (**hnode).hrefcon; tyvaluerecord linkedval; tyvaluerecord val; hdlhashtable htable; hdlhashnode hn = nil; hdlhashnode hnheadlinetype; tyvaluerecord valheadlinetype; boolean fl = false; disablelangerror (); if (!ophasrefcon (hnode)) //if no refcon, not attributes goto exit3; if (!langunpackvalue (hrefcon, &linkedval)) //try to unpack the refcon goto exit3; if (linkedval.valuetype != binaryvaluetype) //must be a binary goto exit2; if (!langunpackvalue (linkedval.data.binaryvalue, &val)) //it's a packed binary: unpack it. goto exit2; if (val.valuetype != externalvaluetype) //it must be a table goto exit1; if (!tablevaltotable (val, &htable, hn)) goto exit1; if (hashtablelookup (htable, BIGSTRING ("\x04""type"), &valheadlinetype, &hnheadlinetype)) { pullstringvalue (&valheadlinetype, bstype); fl = true; } /*if*/ exit1: /*7.0b14 PBS: fix memory leaks*/ disposevaluerecord (val, false); exit2: disposevaluerecord (linkedval, false); exit3: enablelangerror (); return (fl); } /*opattributesgettypestring*/
static boolean listtostring (hdllistrecord hlist, tyvaluerecord *val) { /* 12/22/92 dmb: starter version: 255-char limit 4/2/93 dmb: next version: 255-char limit for individual items only. 2006-02-20 aradke: rewrite using handlestreams for efficiency. also in preparation for revoming the 255-char limit for list items. */ long i, n; bigstring key; tyvaluerecord itemval; bigstring bs; handlestream s; boolean flisrecord = opgetisrecord (hlist); n = opcountlistitems (hlist); openhandlestream (nil, &s); if (!writehandlestreamchar (&s, '{')) /* creates handle, need to dispose later */ return (false); for (i = 1; i <= n; ++i) { if (!getnthlistval (hlist, i, key, &itemval)) goto error; if (flisrecord) { if (!writehandlestreamchar (&s, chdoublequote)) goto error; langdeparsestring (key, chdoublequote); /*add needed escape sequences*/ if (!writehandlestreamstring (&s, key)) goto error; if (!writehandlestreamchar (&s, chdoublequote)) goto error; if (!writehandlestreamchar (&s, ':')) goto error; } if (!getobjectmodeldisplaystring (&itemval, bs)) /*max 253 characters*/ goto error; disposevaluerecord (itemval, true); /*don't clog temp stack*/ if (!writehandlestreamstring (&s, bs)) goto error; if (i < n) if (!writehandlestreamstring (&s, BIGSTRING ("\x02, "))) goto error; } if (!writehandlestreamchar (&s, '}')) goto error; return (setheapvalue (closehandlestream (&s), stringvaluetype, val)); error: disposehandlestream (&s); return (false); } /*listtostring*/
static void ccdrawabout (void) { /* 5.0b9 dmb: user Arial, but just for the frontier(tm) item */ Rect rabout = (**aboutdata).aboutarea; bigstring bs; /*draw the icon*/ { #ifdef WIN95VERSION short tmfont; fontgetnumber (BIGSTRING ("\x05" "Arial"), &tmfont); if (tmfont != 0) setglobalfontsizestyle (tmfont, 9, bold); else #endif setglobalfontsizestyle (geneva, 9, bold); rabout.top += max ((aboutrowsNoStats * aboutlineheight - abouticonsize) / 2, 0); rabout.left += abouticonsize; /*2005-01-12 aradke: shorter frontieritem, indent it too*/ movepento (rabout.left, rabout.top + abouticonsize + globalfontinfo.ascent); pendrawstring (aboutstrings [frontieritem]); #ifdef WIN95VERSION if (tmfont != 0) setglobalfontsizestyle (geneva, 9, bold); #endif //rabout.left += abouticonsize; /*2005-01-12 aradke*/ rabout.right = rabout.left + abouticonsize; rabout.bottom = rabout.top + abouticonsize; ccdrawfrontiericon (rabout, false); } ccdrawtextitem (copyright2item, nil, normal, leftjustified); ccdrawtextitem (copyrightitem, nil, normal, leftjustified); ccdrawurlitem (false); #if __powerc // ccdrawtextitem (isaitem, "\pPowerPC", normal); parsedialogstring (aboutstrings [isaitem], BIGSTRING ("\x07" "PowerPC"), nil, nil, nil, bs); #else parsedialogstring (aboutstrings [isaitem], BIGSTRING ("\x05" "680x0"), nil, nil, nil, bs); #endif // ccdrawmainwindowtext (isaitem, normal, bs, leftjustified); // ccdrawtextitem (frontieritem, nil, bold); ccdrawtextitem (sloganitem, nil, italic, leftjustified); filegetprogramversion (bs); #ifdef fltrialsize insertstring (BIGSTRING ("\x06" "Trial "), bs); #endif ccdrawmainwindowtext (versionitem, normal, bs, rightjustified); ccupdatestatistics (false); } /*ccdrawabout*/
static boolean newaboutwindow (boolean flbootsplash) { /* 5.0.2b20 dmb: don't reset window pos for negative values */ WindowPtr w; hdlwindowinfo hw; bigstring bstitle; Rect rzoom, rwindow; hdlaboutrecord hdata; short ixaboutconfig; if (!newclearhandle (sizeof (tyaboutrecord), (Handle *) &hdata)) return (false); shellfindcallbacks (idaboutconfig, &ixaboutconfig); if (flbootsplash) { globalsarray [ixaboutconfig].config.templateresnum = 131;//config.fldialog (**hdata).flbootsplash = true; } else globalsarray [ixaboutconfig].config.templateresnum = 129; //restore // get bigwindow setting with current root // (**hdata).flbigwindow = (cancoonglobals == nil) || (**cancoonglobals).flbigwindow; ccgetwindowrect (ixaboutinfo, &rwindow); // if (rwindow.top <= 0 || rwindow.left <= 0) // rwindow.top = -1; getsystemoriginrect (&rzoom); // getstringlist (aboutlistnumber, abouttitlestring, bstitle); copystring (aboutstrings [frontieritem], bstitle); if (!flbootsplash) insertstring (BIGSTRING ("\x06" "About "), bstitle); /* 2006-02-04 aradke: eliminated titleitem */ if (!newchildwindow (idaboutconfig, nil, &rwindow, &rzoom, bstitle, &w)) { disposehandle ((Handle) hdata); return (false); } #if TARGET_API_MAC_CARBON == 1 SetThemeWindowBackground (w, kThemeBrushModelessDialogBackgroundActive, false); #endif getwindowinfo (w, &hw); (**hw).hdata = (Handle) hdata; shellpushglobals (w); aboutwindowsetup (); aboutresetrects (hw); if (!flbootsplash) { aboutresizeafterfontchange (); aboutsetconfigminimum (); } shellpopglobals (); windowzoom (w); return (true); } /*newaboutwindow*/
#define minaboutwidth (aboutlinewidth + abouthorizgap + 2 * abouthorizinset + 4 * abouticonsize) /*2005-01-12 aradke*/ #define agentmenuhorizgap 10 static byte * aboutstrings [] = { bs_APP_SLOGAN, /* 2006-02-06 aradke: see versions.h */ bs_APP_COPYRIGHT2, /* 2006-04-08 aradke: see versions.h */ bs_APP_COPYRIGHT, /* 2006-02-06 aradke: see versions.h */ bs_APP_URL, /* 2006-02-06 aradke: see versions.h */ BIGSTRING ("\x02" "^0"), BIGSTRING ("\x12" "Scripts Running: "), BIGSTRING ("\x11" "Current Thread: "), #ifdef MACVERSION BIGSTRING ("\x13" "Available Memory: "), #endif #ifdef WIN95VERSION BIGSTRING ("\x14" "Handles Allocated: "), #endif BIGSTRING (""), BIGSTRING ("\x10" "Visible Agent: "),
boolean opdefaultdrawicon (hdlheadrecord hnode, const Rect *iconrect, boolean flselected, boolean flinverted) { #pragma unused(flselected, flinverted) /* the default icon drawing routine, for the script editor and menu editor, not for clay basket. */ register hdloutlinerecord ho = outlinedata; short iconnum; bigstring bsheadlinetype; /*7.0b9 PBS*/ boolean flcustomicondrawn = false; iconnum = opgetheadicon (hnode); //#ifdef PIKE /* 7.0b9 PBS: logic for drawing a custom icon. If the outline is an outline, and the headline has a refcon, and the refcon has a type attribute, and there's a file on disk [type.bmp], use that icon. */ if ((**ho).outlinetype == outlineisoutline) { /*is this an outline?*/ if (ophasrefcon (hnode)) { /*does it have a refcon?*/ setemptystring (bsheadlinetype); if (opattributesgettypestring (hnode, bsheadlinetype)) { /*is there a type att?*/ /* Look up a custom icon in the odb and draw it if there is one. */ #if defined (MACVERSION) bigstring bsadrnodepath; if (stringlength(bsheadlinetype) > 0 && opgetnodetypetableadr(bsheadlinetype, bsadrnodepath)) { pushstring(BIGSTRING("\x09" ".icon.mac"), bsadrnodepath); flcustomicondrawn = opdrawheadiconcustomfromodb (bsadrnodepath, iconrect, false); } #endif #if (defined(MACVERSION) && defined(__ppc__)) || defined (WIN95VERSION) /*Draw a custom icon. If it returns false, there was no custom icon.*/ if (!flcustomicondrawn) { flcustomicondrawn = opdrawheadiconcustom (bsheadlinetype, iconrect, false); } #endif } /*if*/ } /*if*/ } /*if*/ //#endif // opdrawheadicon (iconnum, iconrect, flselected); if (!flcustomicondrawn) /*Draw a normal icon only if there was no custom icon.*/ opdrawheadicon (iconnum, iconrect, false); /* if (flselected) { Rect r = *iconrect; insetrect (&r, 1, 1); invertrect (r); } */ return (true); } /*opdefaultdrawicon*/
static boolean openverb (hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) { #pragma unused (bserror) /* 7.0b6 PBS: optional flReadOnly parameter allows outline-type windows to open in read-only mode. 8.0.3b2: fixed missing scrollbar on Mac Classic. */ hdlhashtable htable, hscripttable; bigstring bsname; tyvaluerecord val; hdlhashnode hnode; hdlexternalvariable hv; hdlwindowinfo hinfo; short ctparams; boolean flreadonly = false; /*editable by default*/ boolean lflreturn = false; boolean flbuttontable = false; boolean flvisible = true; setbooleanvalue (false, vreturned); ctparams = langgetparamcount (hparam1); if (ctparams == 1) flnextparamislast = true; if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode)) return (false); if (val.valuetype != externalvaluetype) /*not a fatal error*/ return (true); if (ctparams > 1) { /*7.0b6 PBS: if flReadOnly is supplied*/ if (ctparams == 2) flnextparamislast = true; if (!getbooleanvalue (hparam1, 2, &flreadonly)) return (false); if (ctparams > 2) { /*7.1b18 PBS: get table value for buttons*/ flnextparamislast = true; if (!gettablevalue (hparam1, 3, &hscripttable)) return (false); flbuttontable = true; } /*if*/ } /*if*/ hv = (hdlexternalvariable) val.data.externalvalue; if ((flreadonly) && ((**hv).id == idwordprocessor)) { /*7.0b6 PBS: read-only wp-text is an error.*/ hdlwindowinfo lhinfo; langerrormessage (BIGSTRING ("\x5a""Can't open window as read-only because windows of type wp text don't support this feature.")); if (shellfinddatawindow ((Handle) (**hv).variabledata, &lhinfo)) { /*window may be hidden -- if so, close*/ if ((**lhinfo).flhidden) { /*if hidden, close the window*/ shellclose ((**lhinfo).macwindow, false); } /*if*/ } /*if*/ return (false); } /*if*/ if ((flbuttontable) && ((**hv).id != idoutlineprocessor)) { /*7.1b18 PBS: buttons for non-outlines is an error.*/ hdlwindowinfo lhinfo; langerrormessage (BIGSTRING ("\x52""Can't attach buttons to window because windows only outlines support this feature.")); if (shellfinddatawindow ((Handle) (**hv).variabledata, &lhinfo)) { /*window may be hidden -- if so, close*/ if ((**lhinfo).flhidden) { /*if hidden, close the window*/ shellclose ((**lhinfo).macwindow, false); } /*if*/ } /*if*/ return (false); } /*if*/ if (flbuttontable) { flvisible = false; }/*if*/ if (!langzoomvalwindow (htable, bsname, val, false)) return (false); if (shellfinddatawindow ((Handle) (**hv).variabledata, &hinfo)) { switch ((**hv).id) { case idoutlineprocessor: if (flbuttontable) { opbuttonsattach (hinfo, hscripttable); } /*if*/ else { (**hinfo).flhidebuttons = true; (**hinfo).flsyntheticbuttons = false; } /*else*/ break; case idscriptprocessor: (**hinfo).flhidebuttons = false; (**hinfo).flsyntheticbuttons = false; break; default: (**hinfo).flhidebuttons = true; (**hinfo).flsyntheticbuttons = false; } /*switch*/ #if defined(WIN95VERSION) || TARGET_API_MAC_CARBON /*8.0.3b2: Windows and OS X only. Fixes missing scrollbar on Classic.*/ shellpushglobals ((**hinfo).macwindow); shelladjustaftergrow ((**hinfo).macwindow); shellpopglobals (); #endif } /*if*/ if (!langzoomvalwindow (htable, bsname, val, true)) /*now make it visible*/ return (false); lflreturn = langexternalsetreadonly (hv, flreadonly); /*7.0b6 PBS: set the read-only flag.*/ (*vreturned).data.flvalue = lflreturn; return (lflreturn); } /*openverb*/