miniwindow.c

Go to the documentation of this file.
00001 
00002 /*  $Id: miniwindow.c 1206 2006-04-05 23:21:19Z 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 "bitmaps.h"
00032 #include "cursor.h"
00033 #include "frontierconfig.h"
00034 #include "kb.h"
00035 #include "icon.h"
00036 #include "font.h"
00037 #include "memory.h"
00038 #include "mouse.h"
00039 #include "ops.h"
00040 #include "popup.h"
00041 #include "quickdraw.h"
00042 #include "scrap.h"
00043 #include "strings.h"
00044 #include "windowlayout.h"
00045 #include "frontierwindows.h"
00046 #include "zoom.h"
00047 #include "shell.h"
00048 #include "shellundo.h"
00049 #include "cancoon.h"
00050 #include "miniwindow.h"
00051 #include "wpengine.h"
00052 
00053 
00054 
00055 #define flmsgactive flmassiveupdate
00056 
00057 WindowPtr miniwindow = nil;
00058 
00059 hdlwindowinfo miniwindowinfo = nil;
00060 
00061 hdlminirecord minidata = nil;
00062 
00063 
00064 
00065 /*
00066 5.0d14 dmb: major rewrite:
00067     use wpengine, not the Dialog Manager.
00068     text fields are now handles, not bigstrings
00069 */
00070 
00071 
00072 static boolean minisetwpglobals (short item) {
00073     
00074     /*
00075     set up the word processing engine's globals
00076     */
00077     
00078     if ((item < 0) || (item >= (**minidata).cttextitems)) {
00079         
00080         wpdata = nil;
00081         
00082         return (false);
00083         }
00084     
00085     wpdata = (**minidata).textdata [item];
00086     
00087     wpwindow = miniwindow;
00088     
00089     wpwindowinfo = miniwindowinfo;
00090     
00091     return (true);
00092     } /*minisetwpglobals*/
00093 
00094 
00095 static boolean minisetactivewpglobals (void) {
00096     
00097     if (minidata == nil)
00098         return (false);
00099     
00100     return (minisetwpglobals ((**minidata).activetextitem));
00101     } /*minisetactivewpglobals*/
00102 
00103 
00104 boolean minisetstring (short item, Handle h) {
00105     
00106     if (!minisetwpglobals (item))
00107         return (false);
00108     
00109     return (wpsettexthandle (h));
00110     } /*minisetstring*/
00111 
00112 
00113 boolean minigetstring (short item, Handle *h) {
00114     
00115     if (!minisetwpglobals (item))
00116         return (false);
00117     
00118     return (wpgettexthandle (h));
00119     } /*minigetstring*/
00120 
00121 
00122 boolean minigetselstring (short item, bigstring bs) {
00123     
00124     if (!minisetwpglobals (item))
00125         return (false);
00126     
00127     wpgetseltext (bs);
00128     
00129     return (true);
00130     } /*minigetselstring*/
00131 
00132 /*
00133 boolean minisetpopupmessage (short popupnumber, bigstring bs) {
00134     
00135     hdlstring hstring;
00136     
00137     newheapstring (bs, &hstring);
00138     
00139     (**minidata).popupmessages [popupnumber] = hstring;
00140     
00141     invalrect ((**minidata).popuprects [popupnumber]);
00142     } /%minisetpopupmessage%/
00143 */
00144 
00145 void minisetselect (short startsel, short endsel) {
00146     
00147     if (minisetactivewpglobals ())
00148         wpsetselection (startsel, endsel);
00149     
00150     (**minidata).flselectallpending = false; /*override*/
00151     } /*minisetselect*/
00152 
00153 
00154 #if 0
00155 
00156 static void minigetactivetextrect (Rect *r) {
00157     
00158     *r = (**minidata).textrects [(**minidata).activetextitem];
00159     } /*minigetactivetextrect*/
00160 
00161 
00162 static void minigetactivetextitem (short *item) {
00163     
00164     *item = (**minidata).textitems [(**minidata).activetextitem];
00165     } /*minigetactivetextitem*/
00166 
00167 #endif
00168 
00169 
00170 static boolean miniselectallandactivate (short newactiveitem) {
00171     
00172     (**minidata).activetextitem = newactiveitem;
00173     
00174     if (!minisetwpglobals (newactiveitem))
00175         return (false);
00176     
00177     wpselectall ();
00178     
00179     return (true);
00180     } /*miniselectallandactivate*/
00181 
00182 
00183 static boolean miniselectall (void) {
00184     
00185     miniselectallandactivate ((**minidata).activetextitem);
00186     
00187     return (true);
00188     } /*miniselectall*/
00189 
00190 
00191 static boolean mininextwindowvisit (WindowPtr w, ptrvoid refcon) {
00192     
00193     WindowPtr *nextwindow = (WindowPtr *) refcon;
00194     
00195     if (*nextwindow == nil) { /*we passed our target*/
00196         
00197         *nextwindow = w;
00198         
00199         return (false); /*stop visiting*/
00200         }
00201     
00202     if (w == *nextwindow) /*we're enountering our target*/
00203         *nextwindow = nil;
00204     
00205     return (true); /*keep visiting*/
00206     } /*mininextwindowvisit*/
00207 
00208 
00209 static boolean minisearch (void) {
00210     
00211     /*
00212     this routine could be called "passthebuck".  we don't want to handle search 
00213     commands, but don't want them to fail either.  instead, we'll find the window 
00214     behind us and let it handle it
00215     */
00216     
00217     boolean fl;
00218     WindowPtr nextwindow;
00219     
00220     nextwindow = miniwindow;
00221     
00222     if (shellvisitwindowlayer (&mininextwindowvisit, &nextwindow))
00223         return (false);
00224     
00225     shellpushglobals (nextwindow);
00226     
00227     fl = (*shellglobals.searchroutine) ();
00228     
00229     shellpopglobals ();
00230     
00231     return (fl);
00232     } /*minisearch*/
00233 
00234 
00235 static boolean minicheckselectall (void) {
00236 
00237     register hdlminirecord hm = minidata;
00238     
00239     if ((**hm).flactive && (**hm).flselectallpending) {
00240         
00241         (**hm).flselectallpending = false; /*must be reset every time*/
00242         
00243         miniselectall ();
00244         
00245         return (true);
00246         }
00247     
00248     return (false);
00249     } /*minicheckselectall*/
00250 
00251 
00252 static boolean minisavestrings (void) {
00253     
00254     /*
00255     5.0b17 dmb: minigetstring result is ours to consume
00256     */
00257     
00258     Handle h;
00259     register short i;
00260     
00261     for (i = 0; i < (**minidata).cttextitems; i++) {
00262         
00263         minigetstring (i, &h);
00264         
00265         (*(**minidata).savestringroutine) (i, h);
00266         
00267         disposehandle (h);
00268         } /*for*/
00269     
00270     return (true);
00271     } /*minisavestrings*/
00272 
00273 
00274 static void minidirty (void) {
00275     
00276     windowsetchanges (miniwindow, true);
00277     } /*minidirty*/
00278 
00279 
00280 static boolean miniloadstrings (void) {
00281     
00282     Handle h;
00283     Rect r;
00284     hdlwprecord wp;
00285     register short i;
00286     
00287     for (i = 0; i < (**minidata).cttextitems; i++) {
00288         
00289         h = nil; /*in case callback is a no-op*/
00290         
00291         (*(**minidata).loadstringroutine) (i, &h);
00292         
00293         r = (**minidata).textrects [i];
00294         
00295         insetrect (&r, 3, 3);
00296         
00297         minisetwpglobals (i);
00298         
00299         wp = wpnewbuffer (nil, &r, &r, wpneverscroll, true);
00300         
00301         if (wp == nil)
00302             return (false);
00303         
00304         (**wp).flwindowopen = true;
00305         
00306         assert ((**wp).flneverscroll == true);
00307         
00308         (**minidata).textdata [i] = wp;
00309         
00310         minisetstring (i, h);
00311         
00312         (**wp).dirtyroutine = &minidirty; // must do after text is initialized
00313         
00314         disposehandle (h);
00315         
00316         (**minidata).activetextitem = i;
00317         } /*for*/
00318         
00319     return (true);
00320     } /*miniloadstrings*/
00321 
00322 
00323 static boolean minisetvalue (void) {
00324     
00325     return ((*(**minidata).setvalueroutine) ());
00326     } /*minisetvalue*/
00327 
00328 
00329 static void minidrawicon (boolean flpressed) {
00330     
00331     register hdlminirecord hm = minidata;
00332     register boolean flenabled;
00333     
00334     flenabled = (**hm).fliconenabled && (**hm).flactive;
00335     
00336     drawlabeledwindoidicon ((**hm).iconrect, (**hm).iconlabel, flenabled, flpressed);
00337     } /*minidrawicon*/
00338 
00339 
00340 static void minidrawpopups (void) {
00341     
00342     register hdlminirecord hm = minidata;
00343     register short i;
00344     bigstring bs;
00345     
00346     for (i = 0; i < (**hm).ctpopups; i++) {
00347         
00348         copyheapstring ((**hm).popupmessages [i], bs);
00349         
00350         drawpopup ((**hm).popuprects [i], bs, false);
00351         } /*for*/
00352     } /*minidrawpopups*/
00353 
00354 
00355 static void minidrawtextitems (void) {
00356     
00357     register hdlminirecord hm = minidata;
00358     register short i;
00359     
00360     #ifdef gray3Dlook
00361         pushbackcolor (&whitecolor);
00362     #endif
00363 
00364     for (i = 0; i < (**hm).cttextitems; i++) {
00365         
00366         #ifdef gray3Dlook
00367             eraserect ((**hm).textrects [i]);
00368         #endif
00369         
00370         framerect ((**hm).textrects [i]);
00371         
00372         if (minisetwpglobals (i))
00373             wpupdate ();
00374         } /*for*/
00375 
00376     #ifdef gray3Dlook
00377         popbackcolor ();
00378     #endif
00379     } /*minidrawtextitems*/
00380 
00381 
00382 static boolean minidrawmsg (void) {
00383     
00384     register hdlminirecord hm = minidata;
00385     register boolean flbitmap;
00386     bigstring bs;
00387     Rect r;
00388     
00389     r = (**hm).msgrect;
00390     
00391     flbitmap = openbitmap (r, miniwindow);
00392         
00393     eraserect (r);
00394     
00395     pushstyle (msgfont, msgsize, msgstyle);
00396     
00397     copystring ((**hm).bsmsg, bs);
00398     
00399     centerstring (r, bs);
00400     
00401     popstyle ();
00402     
00403     framerect (r);
00404     
00405     if ((**hm).flactive && (**hm).flmsgactive) {
00406         
00407         insetrect (&r, 1, 1);
00408         
00409         #ifdef MACVERSION
00410         LMSetHiliteMode(LMGetHiliteMode() & ~(1 << hiliteBit));
00411         #endif
00412         
00413         invertrect (r);
00414         }
00415     
00416     if (flbitmap)
00417         closebitmap (miniwindow);
00418     
00419     return (true);
00420     } /*minidrawmsg*/
00421 
00422 
00423 static boolean minimessage (bigstring bs, boolean flbackgroundmsg) {
00424 #pragma unused (flbackgroundmsg)
00425 
00426     copystring (bs, (**minidata).bsmsg);
00427     
00428     return (minidrawmsg ());
00429     } /*minimessage*/
00430 
00431 
00432 static boolean minigettargetdata (short id) {
00433     
00434     return ((*(**minidata).gettargetdataroutine) (id));
00435     } /*minigettargetdata*/
00436 
00437 
00438 #if 0
00439 
00440 static void minizoomtexttoicon (void) {
00441     
00442     Rect rfrom, rto;
00443     
00444     minigetactivetextrect (&rfrom);
00445     
00446     zerorect (&rto);
00447     
00448     centerrect (&rto, (**minidata).iconrect);
00449     
00450     localtoglobalrect (miniwindow, &rfrom);
00451     
00452     localtoglobalrect (miniwindow, &rto);
00453     
00454     zoomrect (&rfrom, &rto, true);
00455     } /*minizoomtexttoicon*/
00456 
00457 
00458 static void minizoomicontomsg (void) {
00459     
00460     Rect rfrom, rto;
00461     
00462     rto = (**minidata).msgrect;
00463     
00464     zerorect (&rfrom);
00465     
00466     centerrect (&rfrom, (**minidata).iconrect);
00467     
00468     localtoglobalrect (miniwindow, &rfrom);
00469     
00470     localtoglobalrect (miniwindow, &rto);
00471     
00472     zoomrect (&rfrom, &rto, true);
00473     } /*minizoomicontomsg*/
00474 
00475 #endif
00476 
00477 
00478 static boolean miniiconhit (boolean flanimate) {
00479     
00480     /*
00481     7/23/90 DW: if flanimate is false, we don't bother displaying the run
00482     icon -- the caller wants the fastest-possible execution, or it's already 
00483     been tracked with the mouse
00484     
00485     2.1b11 dmb: check iconenabled flag in here, after calling enableroutine
00486     */
00487     
00488     register hdlminirecord hm = minidata;
00489     
00490     (*(**hm).iconenableroutine) (); /*make sure it's up to date*/
00491     
00492     if (!(**hm).fliconenabled)
00493         return (false);
00494     
00495     if (flanimate) {
00496         
00497         minidrawicon (true);
00498         
00499         delayticks (8); /*so you can actually see the button down*/
00500         
00501         minidrawicon (false);
00502         }
00503     
00504     (*(**hm).iconhitroutine) ();
00505     
00506     (**hm).flselectallpending = true; 
00507     
00508     minisavestrings ();
00509     
00510     return (true);
00511     } /*miniiconhit*/
00512 
00513 
00514 static short minifindpopup (Point pt){
00515     
00516     /*
00517     search the popuprects array, and return the index of the item whose rect
00518     contains the indicated point.
00519     
00520     we only look at the portion of the rect that displays the popup arrow.
00521     
00522     if the point isn't in any of the rects, return -1.
00523     */
00524 
00525     register hdlminirecord hm = minidata;
00526     register short i;
00527     Rect r;
00528     
00529     for (i = 0; i < (**hm).ctpopups; i++) {
00530         
00531         r = (**hm).popuprects [i];
00532         
00533         r.left = r.right - popuparrowwidth;
00534         
00535         if (pointinrect (pt, r))
00536             return (i);
00537         } /*for*/
00538         
00539     return (-1);
00540     } /*minifindpopup*/
00541 
00542 
00543 static boolean minipopuphit (short popupnumber) {
00544     
00545     register hdlminirecord hm = minidata;
00546     Rect r;
00547     
00548     (**hm).popupnumber = popupnumber; /*allow callback to use this*/
00549     
00550     r = (**hm).popuprects [popupnumber];
00551     
00552     r.left = r.right - popuparrowwidth;
00553     
00554     return (popupmenuhit (r, false, (**hm).fillpopuproutine, (**hm).popupselectroutine));
00555     } /*minipopuphit*/
00556 
00557 
00558 static short minifindtextobject (Point pt) {
00559     
00560     /*
00561     search the textrects array, and return the index of the item whose rect
00562     contains the indicated point.
00563     
00564     if the point isn't in any of the rects, return -1.
00565     */
00566 
00567     register hdlminirecord hm = minidata;
00568     register short i;
00569     
00570     for (i = 0; i < (**hm).cttextitems; i++) {
00571     
00572         if (pointinrect (pt, (**hm).textrects [i])) 
00573             return (i);
00574         } /*for*/
00575         
00576     return (-1);
00577     } /*minifindtextobject*/
00578     
00579 
00580 static void miniactivatemessage (boolean flactivate) {
00581     
00582     register hdlminirecord hm = minidata;
00583 
00584     if ((**hm).flmsgactive != flactivate) {
00585 
00586         (**hm).flmsgactive = flactivate;
00587 
00588         if (flactivate) {
00589             
00590             wpactivate (false);
00591             
00592             (**hm).activetextitem = -1;
00593             }
00594         else {
00595             (**hm).activetextitem = 0;
00596 
00597             minisetactivewpglobals ();
00598             
00599             wpactivate (true);
00600             }
00601 
00602         minidrawmsg ();
00603         }
00604     } /*miniactivatemessage*/
00605 
00606 
00607 static boolean minimessageisactive (void) {
00608     
00609     return ((**minidata).flmsgactive);
00610     } /*minimessageisactive*/
00611 
00612 
00613 static void miniselectnexttextitem (void) {
00614     
00615     miniactivatemessage (!minimessageisactive ());
00616     } /*miniselectnexttextitem*/
00617 
00618 
00619 static boolean minimousedown (Point pt, tyclickflags flags) {
00620     
00621     register hdlminirecord hm = minidata;
00622     short item; 
00623     Rect r; 
00624     
00625     minicheckselectall (); /*if a selectall is pending, do it now*/
00626     
00627     item = minifindtextobject (pt);
00628     
00629     if (item >= 0) {
00630         
00631         miniactivatemessage (false);
00632         
00633         (**hm).activetextitem = item;
00634         
00635         if (!minisetwpglobals (item))
00636             return (false);
00637         
00638         wpclick (pt, flags);
00639         
00640         (*(**hm).texthitroutine) (pt);
00641         
00642         shellevent.when = gettickcount ();
00643         
00644         mouseup (shellevent.when, shellevent.where.h, shellevent.where.v, shellevent.what); /*textedit may swallow the mouseup event when tracking click*/
00645         
00646         return (true);
00647         }
00648     
00649     if (pointinrect (pt, (**hm).msgrect)) {
00650         
00651         if (minisetactivewpglobals ())
00652             wpactivate (false);
00653         
00654         (**hm).activetextitem = -1;
00655 
00656         miniactivatemessage (true);
00657         }
00658 
00659     r = (**hm).iconrect;
00660     
00661     if (pointinrect (pt, r)) {
00662         
00663         if ((**hm).fliconenabled)
00664             if (trackicon (r, minidrawicon))
00665                 return (miniiconhit (false));
00666         
00667         return (true);
00668         }
00669     
00670     bundle { /*check for mousedown in a popup*/
00671         
00672         register short x;
00673         
00674         x = minifindpopup (pt);
00675         
00676         if (x >= 0) { /*mousedown was in a popup*/
00677             
00678             return (minipopuphit (x));
00679             }
00680         }
00681     
00682     /*
00683     ouch ();
00684     */
00685     
00686     return (true);
00687     } /*minimousedown*/
00688 
00689 
00690 static boolean minikeystroke (void) {
00691     
00692     /*
00693     7/23/90 DW: improve demo-ability.  if the user is still holding down the
00694     enter key, we instruct miniiconhit not to use the delay he does to improve
00695     the animation of the run icon.  this allows us to show how fast the compiler
00696     and interpreter are by holding down the enter key.
00697     */
00698     
00699     register char chkb = keyboardstatus.chkb;
00700     
00701     minicheckselectall (); /*if a selectall is pending, do it now*/
00702     
00703     if (chkb == chenter) { /*if enter key is down, don't delay*/
00704         
00705         miniiconhit (!keyboardstatus.flautokey);
00706         
00707         return (true);
00708         }
00709     
00710     if (chkb == chtab)
00711         miniselectnexttextitem ();
00712     else {
00713         
00714         if (minisetactivewpglobals ())
00715             wpkeystroke ();
00716         else
00717             sysbeep ();
00718         }
00719     
00720     return (true);
00721     } /*minikeystroke*/
00722 
00723 
00724 static boolean miniruncursor (void) {
00725     
00726     /*
00727     2.1b11: might as well allow run selection verb fire off QuickScript
00728     */
00729     
00730     return (miniiconhit (true));
00731     } /*miniruncursor*/
00732 
00733 
00734 static boolean minigetwindowrect (Rect *rwindow) {
00735     
00736     return (ccgetwindowrect ((**minidata).windowtype, rwindow));
00737     } /*minigetwindowrect*/
00738     
00739     
00740 static boolean miniclose (void) {
00741     
00742     minisavestrings ();
00743     
00744     killundo (); /*must toss undos before they're stranded*/
00745     
00746     if (!ccsubwindowclose (miniwindowinfo, (**minidata).windowtype))
00747         return (false);
00748     
00749     miniwindow = nil;
00750     
00751     return (true);
00752     } /*miniclose*/
00753 
00754 
00755 static void miniresizetextrects (Rect rtext) {
00756     
00757     /*
00758     rtext covers all the space available for text objects, we distribute the
00759     text objects inside this rect.
00760     */
00761     
00762     register hdlminirecord hm = minidata;
00763     register short ct = (**hm).cttextitems;
00764     register short objheight;
00765     register short i;
00766     register short nexttop;
00767     register short spacebetween;
00768     
00769     spacebetween = windowmargin / 2;
00770     
00771     objheight = (rtext.bottom - rtext.top - ((ct - 1) * spacebetween)) / ct;
00772     
00773     nexttop = rtext.top;
00774     
00775     for (i = 0; i < ct; i++) {
00776         
00777         Rect r = rtext;
00778         
00779         r.top = nexttop;
00780         
00781         r.bottom = r.top + objheight;
00782         
00783         (**hm).textrects [i] = r;
00784         
00785         insetrect (&r, 3, 3); /*make up for dialog manager funkiness*/
00786         
00787         minisetwpglobals (i);
00788         
00789         wpsetbufferrect (r, r);
00790         
00791         nexttop += objheight + spacebetween;
00792         } /*for*/
00793     } /*miniresizetextrects*/
00794 
00795 
00796 static boolean miniresizepopups (Rect *rmsg) {
00797     
00798     register hdlminirecord hm = minidata;
00799     Rect r = *rmsg;
00800     Rect rpopup;
00801     register short i;
00802     
00803     for (i = 0; i < (**hm).ctpopups; i++) {
00804         
00805         rpopup = r; /*set top, bottom, left*/
00806         
00807         rpopup.right = rpopup.left + popupwidth;
00808         
00809         (**hm).popuprects [i] = rpopup;
00810         
00811         r.left = rpopup.right + (windowmargin / 2);
00812         } /*for*/
00813         
00814     *rmsg = r;
00815     
00816     return (true);
00817     } /*miniresizepopups*/
00818 
00819 
00820 static void miniresize (void) {
00821     
00822     register hdlwindowinfo hw = miniwindowinfo;
00823     register hdlminirecord hm = minidata;
00824     Rect rcontent;
00825     Rect r;
00826     
00827     rcontent = (**hw).contentrect;
00828     
00829     r.top = rcontent.top + windowmargin;
00830     
00831     r.bottom = r.top + iconrectheight;
00832     
00833     r.right = rcontent.right - windowmargin;
00834     
00835     r.left = r.right - iconrectwidth;
00836     
00837     (**hm).iconrect = r; 
00838     
00839     r.bottom = rcontent.bottom - windowmargin;
00840     
00841     r.top = r.bottom - popupheight;
00842     
00843     r.left = rcontent.left + windowmargin;
00844     
00845     r.right = (**hm).iconrect.left - windowmargin;
00846     
00847     miniresizepopups (&r); /*r returns with msgrect*/
00848     
00849     (**hm).msgrect = r;
00850     
00851     r.left = rcontent.left + windowmargin;
00852     
00853     r.right = (**hm).iconrect.left - windowmargin;
00854 
00855     r.top = rcontent.top + windowmargin;
00856     
00857     r.bottom = (**hm).msgrect.top - (windowmargin / 2);
00858     
00859     miniresizetextrects (r); /*left and right are the same as for msgrect*/
00860     
00861     #if TARGET_API_MAC_CARBON == 1
00862     
00863         drawthemeborder ((**hm).textrects [0], (**hw).contentrect); /*PBS 7.0b52: draw scan-lines border*/
00864         
00865     #endif
00866     
00867     //(**hm).flmassiveupdate = true; /*it don't get much more massive than this!*/
00868     } /*miniresize*/
00869     
00870 
00871 static boolean minisetfontsize (void) {
00872     
00873     register hdlwindowinfo hw = miniwindowinfo;
00874     
00875     if (minisetactivewpglobals ()) {
00876         
00877         wpselectall ();
00878         
00879         wpsetfont ();
00880         
00881         wpsetsize ();
00882         }
00883     
00884     cccopywindowinfo (hw, (**minidata).windowtype); /*update cancoondata*/
00885     
00886     return (true);
00887     } /*minisetfontsize*/
00888 
00889     
00890 static boolean mininewwindow (callback setuproutine) {
00891     
00892     /*
00893     5.0a18 dmb: use ccfindrootwindow instead of frontrootwindow, as
00894     we do in minifindwindow. not just for about, but for guest roots
00895     */
00896 
00897     register hdlminirecord hm;
00898     bigstring bs;
00899     Rect rzoom, rwindow;
00900     hdlwindowinfo hinfo, hparent;
00901     WindowPtr w;
00902     
00903     if (!ccfindrootwindow (&hparent)) /*our parent is the active root window*/
00904         return (false);
00905     
00906     /*shellgetwindowcenter (hparent, &rzoom);*/
00907     
00908     rzoom.top = -1; /*zoom from default rect*/
00909     
00910     if (!newclearhandle (longsizeof (tyminirecord), (Handle *) &minidata))
00911         return (false);
00912         
00913     hm = minidata; /*copy into register*/
00914     
00915     (**hm).savestringroutine = (minisavestringcallback) &truenoop;
00916     
00917     (**hm).loadstringroutine = (miniloadstringcallback) &truenoop;
00918     
00919     (**hm).texthitroutine = (minitexthitcallback) &truenoop;
00920     
00921     (**hm).iconenableroutine = (shellvoidcallback) &truenoop;
00922     
00923     (**hm).iconhitroutine = &truenoop;
00924     
00925     (**hm).setvalueroutine = &truenoop;
00926     
00927     (**hm).fillpopuproutine = (fillpopupcallback) &truenoop;
00928     
00929     (**hm).popupselectroutine = (popupselectcallback) &truenoop;
00930     
00931     (**hm).gettargetdataroutine = (shellshortcallback) &falsenoop;
00932     
00933     #ifdef MACVERSION
00934         (**hm).forecolor = blackColor;
00935         
00936         (**hm).backcolor = whiteColor;
00937     #endif
00938 
00939     (**hm).activetextitem = -1;
00940     
00941     (*setuproutine) (); /*callback to fill in user-defined fields of minidata*/
00942     
00943     minigetwindowrect (&rwindow);
00944     
00945     copystring ((**hm).windowtitle, bs);
00946     
00947     if (!newchildwindow ((**hm).idconfig, hparent, &rwindow, &rzoom, bs, &w)) {
00948         
00949         disposehandle ((Handle) hm);
00950         
00951         return (false);
00952         }
00953     
00954     getwindowinfo (w, &hinfo);
00955     
00956     windowsetcolor (w, (**hm).forecolor, true);
00957     
00958     windowsetcolor (w, (**hm).backcolor, false);
00959     
00960     (**hinfo).hdata = (Handle) hm;
00961     
00962     ccnewsubwindow (hinfo, (**hm).windowtype);
00963     
00964     shellpushglobals (w); 
00965     
00966     setfontsizestyle ((**hinfo).defaultfont, (**hinfo).defaultsize, (**hinfo).defaultstyle);
00967         
00968     miniresize ();
00969     
00970     minisetfontsize ();
00971     
00972     minisetvalue ();
00973     
00974     miniloadstrings ();
00975     
00976     (**hm).flselectallpending = true; /*selectall on idle*/
00977         
00978     windowzoom (w);
00979     
00980     #if TARGET_API_MAC_CARBON == 1 /*Make sure the window is fully drawn.*/
00981         miniresize ();
00982     #endif
00983 
00984     shellpopglobals ();
00985     
00986     return (true);
00987     } /*mininewwindow*/
00988 
00989 
00990 static void miniupdate (void) {
00991     
00992     register hdlminirecord hm = minidata;
00993     
00994     (*(**hm).iconenableroutine) ();
00995     
00996     minidrawicon (false);
00997     
00998     minidrawpopups ();
00999     
01000     minidrawtextitems ();
01001     
01002     minidrawmsg ();
01003     } /*miniupdate*/
01004 
01005 
01006 static void miniactivate (boolean flactivate) {
01007     
01008     minicheckselectall (); /*if a selectall is pending, do it now*/
01009     
01010     (**minidata).flactive = flactivate;
01011     
01012     if (minimessageisactive ())
01013         ;
01014     else
01015         wpactivate (flactivate);
01016     
01017     minidrawicon (false);
01018     } /*miniactivate*/
01019 
01020 
01021 static boolean minifindvisit (WindowPtr w, ptrvoid refcon) {
01022     
01023     /*
01024     if we're called, the w is a window with the desired config, owned 
01025     the the current root.
01026     
01027     set up mini globals and return false to terminate the visit
01028     */
01029     
01030     hdlwindowinfo *hinfo = (hdlwindowinfo *) refcon;
01031      
01032     miniwindow = w;
01033     
01034     getwindowinfo (w, hinfo);
01035     
01036     return (false);
01037     } /*minifindvisit*/
01038 
01039 
01040 static boolean minifindwindow (short idconfig, hdlwindowinfo *hinfo) {
01041     
01042     /*
01043     5/22/91 dmb: use customized visit to limit search to windows belonging to the 
01044     current root.  this allows us to distinguish between the quickscript window 
01045     for each open file.
01046     
01047     5.0a2 dmb: use ccfindrootwindow instead of frontrootwindow to handle about
01048 
01049     5.0a5 dmb: take hinfo parameter; don't use globals
01050     */
01051     
01052     hdlwindowinfo hroot;
01053     
01054     // if (!frontrootwindow (&hroot))
01055     if (!ccfindrootwindow (&hroot))
01056         return (false);
01057     
01058     return (!visitownedwindows ((**hroot).macwindow, idconfig, &minifindvisit, hinfo));
01059     
01060     /*
01061     return (shellfindwindow (idconfig, &miniwindow, &miniwindowinfo, (Handle *) &minidata));
01062     */
01063     } /*minifindwindow*/
01064 
01065 
01066 boolean miniinvalicon (short idconfig) {
01067     
01068     hdlwindowinfo hinfo;
01069 
01070     if (!minifindwindow (idconfig, &hinfo))
01071         return (false);
01072     
01073     shellpushwindowglobals (hinfo);
01074 
01075     invalwindowrect (miniwindow, (**minidata).iconrect);
01076     
01077     shellpopglobals ();
01078 
01079     return (true);
01080     } /*miniinvalicon*/
01081 
01082 
01083 boolean minisetwindowmessage (short idconfig, bigstring bsmessage) {
01084     
01085     /*
01086     use this routine to set the window message when you don't know if the 
01087     window is around
01088     */
01089     
01090     hdlwindowinfo hinfo;
01091 
01092     if (!minifindwindow (idconfig, &hinfo))
01093         return (false);
01094     
01095     if (!shellpushwindowglobals (hinfo))
01096         return (false);
01097     
01098     shellwindowmessage (bsmessage);
01099     
01100     shellpopglobals ();
01101     
01102     return (true);
01103     } /*minisetwindowmessage*/
01104 
01105 
01106 boolean startminidialog (short idconfig, callback setuproutine) {
01107     
01108     hdlwindowinfo hinfo;
01109     
01110     if (minifindwindow (idconfig, &hinfo)) { /*sets minidata, miniwindow*/
01111         
01112         shellbringtofront (hinfo);
01113         
01114         /*
01115         minisetvalue ();
01116         
01117         miniloadstrings ();
01118         */
01119         
01120         shellpushwindowglobals (hinfo);
01121 
01122         (**minidata).flselectallpending = true; /*selectall on idle*/
01123         
01124         shellpopglobals ();
01125 
01126         return (true);
01127         }
01128     
01129     return (mininewwindow (setuproutine));
01130     } /*startminidialog*/
01131 
01132 
01133 static boolean minidisposerecord (void) {
01134     
01135     register hdlminirecord hm = minidata;
01136     register short i;
01137     
01138     for (i = 0; i < (**hm).ctpopups; i++)
01139         disposehandle ((Handle) (**hm).popupmessages [i]);
01140     
01141     for (i = i; i < (**hm).cttextitems; i++)
01142         wpdisposerecord ((**hm).textdata [i]);
01143     
01144     disposehandle ((Handle) hm);
01145     
01146     return (true);
01147     } /*minidisposerecord*/
01148 
01149 
01150 static boolean miniadjustcursor (Point pt){
01151     
01152     if (minifindtextobject (pt) >= 0) {
01153             
01154         setcursortype (cursorisibeam);
01155             
01156         return (true);
01157         }
01158         
01159     if (minifindpopup (pt) >= 0) {
01160         
01161         setcursortype (cursorispopup);
01162         
01163         return (true);
01164         }
01165         
01166     setcursortype (cursorisarrow);
01167     
01168     return (true);
01169     } /*miniadjustcursor*/
01170     
01171 
01172 static boolean minisetfont (void) {
01173     
01174     hdlwindowinfo hw = miniwindowinfo;
01175     
01176     (**hw).defaultfont = (**hw).selectioninfo.fontnum;
01177     
01178     (**hw).selectioninfo.fldirty = true;
01179     
01180     return (minisetfontsize ());
01181     } /*minisetfont*/
01182     
01183 
01184 static boolean minisetsize (void) {
01185     
01186     hdlwindowinfo hw = miniwindowinfo;
01187     
01188     (**hw).defaultsize = (**hw).selectioninfo.fontsize;
01189     
01190     (**hw).selectioninfo.fldirty = true;
01191     
01192     return (minisetfontsize ());
01193     } /*minisetsize*/
01194 
01195 
01196 static boolean minisetselectioninfo (void) {
01197     
01198     shelldefaultselectioninfo ();
01199     
01200     (**miniwindowinfo).selectioninfo.flcansetstyle = false;
01201     
01202     return (true);
01203     } /*minisetselectioninfo*/
01204 
01205 
01206 static void miniidle (void) {
01207     
01208     minicheckselectall ();
01209     
01210     wpidle ();
01211     } /*miniidle*/
01212 
01213 
01214 static boolean minicopy (void) {
01215     
01216     if (minimessageisactive ()) {
01217 
01218         bigstring bsmsg;
01219         Handle htext;
01220         
01221         copystring ((**minidata).bsmsg, bsmsg);
01222         
01223         if (!newtexthandle (bsmsg, &htext))
01224             return (false);
01225         
01226         return (shellsetscrap (htext, textscraptype, (shelldisposescrapcallback) disposehandle, nil));
01227         }
01228     else
01229         return (wpcopy ());
01230     } /*minicopy*/
01231 
01232 
01233 static boolean minipaste (void) {
01234     
01235     if (!minisetactivewpglobals ())
01236         return (false);
01237 
01238     return (wppaste (false));
01239     } /*minipaste*/
01240 
01241 
01242 static boolean miniclear (void) {
01243     
01244     if (!minisetactivewpglobals ())
01245         return (false);
01246 
01247     return (wpclear ());
01248     } /*miniclear*/
01249 
01250 
01251 static boolean minicut (void) {
01252     
01253     if (minimessageisactive ())
01254         return (minicopy ());
01255 
01256     if (!minisetactivewpglobals ())
01257         return (false);
01258 
01259     return (wpcut ());
01260     } /*minicut*/
01261 
01262 
01263 static boolean minigetundoglobals (long *globals) {
01264     
01265     *globals = (long) (**minidata).activetextitem;
01266     
01267     return (true);
01268     } /*opeditgetundoglobals*/
01269 
01270 
01271 static boolean minisetundoglobals (long globals, boolean flundo) {
01272     
01273     /*
01274     7/2/91 dmb: now takes flundo parameter.  since wpengine doesn't need its 
01275     globals set up to dispose an undo, we can just exit when flundo is 
01276     false.  if this weren't the case, we'd have to store the wpdata handle 
01277     in the undoglobals to avoid having to recreate the context when just 
01278     tossing an undo.
01279     */
01280     
01281     if (!flundo)
01282         return (true);
01283     
01284     miniactivatemessage (false);
01285     
01286     return (minisetwpglobals (globals));
01287     } /*opeditsetundoglobals*/
01288 
01289 
01290 boolean ministart (short idconfig) {
01291     
01292     /*
01293     set up callback routines record, and link our data into the shell's 
01294     data structure.
01295     
01296     2.1b11 dmb: hook up executeroutine
01297     */
01298     
01299     ptrcallbacks minicallbacks;
01300     register ptrcallbacks cb;
01301     
01302     shellnewcallbacks (&minicallbacks);
01303     
01304     cb = minicallbacks; /*copy into register*/
01305     
01306     loadconfigresource (idconfig, &(*cb).config);
01307         
01308     (*cb).configresnum = idconfig;
01309     
01310     (*cb).windowholder = &miniwindow;
01311     
01312     (*cb).dataholder = (Handle *) &minidata;
01313     
01314     (*cb).infoholder = &miniwindowinfo; 
01315     
01316     (*cb).setglobalsroutine = &minisetactivewpglobals;
01317     
01318     (*cb).activateroutine = &miniactivate;
01319     
01320     (*cb).updateroutine = &miniupdate;
01321     
01322     (*cb).resizeroutine = &miniresize;
01323     
01324     (*cb).mouseroutine = &minimousedown;
01325     
01326     (*cb).keystrokeroutine = &minikeystroke;
01327     
01328     (*cb).executeroutine = &miniruncursor;
01329     
01330     (*cb).disposerecordroutine = &minidisposerecord;
01331     
01332     (*cb).closeroutine = &miniclose;
01333     
01334     (*cb).presaveroutine = &minisavestrings;
01335     
01336     (*cb).adjustcursorroutine = &miniadjustcursor;
01337     
01338     (*cb).idleroutine = &miniidle;
01339     
01340     (*cb).cutroutine = &minicut;
01341     
01342     (*cb).copyroutine = &minicopy;
01343     
01344     (*cb).pasteroutine = &minipaste;
01345     
01346     (*cb).clearroutine = &miniclear;
01347     
01348     (*cb).fontroutine = &minisetfont;
01349     
01350     (*cb).sizeroutine = &minisetsize;
01351     
01352     (*cb).setselectioninforoutine = &minisetselectioninfo;
01353     
01354     (*cb).selectallroutine = &miniselectall;
01355     
01356     (*cb).searchroutine = &minisearch;
01357     
01358     (*cb).msgroutine = &minimessage;
01359     
01360     (*cb).gettargetdataroutine = &minigettargetdata;
01361     
01362     (*cb).setundoglobalsroutine = &minisetundoglobals;
01363     
01364     (*cb).getundoglobalsroutine = &minigetundoglobals;
01365     
01366     return (true);
01367     } /*ministart*/
01368 
01369 
01370 

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