opinit.c

Go to the documentation of this file.
00001 
00002 /*  $Id: opinit.c 1199 2006-04-05 22:17:27Z 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 "shell.h"
00032 #include "ops.h"
00033 #include "quickdraw.h"
00034 #include "scrap.h"
00035 #include "op.h"
00036 #include "opinternal.h"
00037 #include "opicons.h"
00038 
00039 
00040 
00041 static void opdisposescrap (void *hnode) {
00042     
00043     /*
00044     5/23/91 dmb: preserve edit globals in case a refcon disposal disturbs 
00045     them.
00046     
00047     7/20/91 dmb: edit globals now preserved within opeditdispose
00048     */
00049     
00050     opdisposeoutline ((hdloutlinerecord) hnode, false);
00051     } /*opdisposescrap*/
00052 
00053 
00054 static boolean opexportscrap (void *houtline, tyscraptype totype, Handle *htext, boolean *fltempscrap) {
00055 
00056     /*
00057     if the requested type isn't text, return false.  otherwise, try to 
00058     convert the given scrap to text
00059     */
00060     
00061     *fltempscrap = true;
00062     
00063     if (totype == opscraptype) /*make contiguous version for system scrap*/
00064         return (oppackoutline ((hdloutlinerecord) houtline, htext));
00065     
00066     if (totype != 'TEXT')
00067         return (false);
00068     
00069     return (opoutlinetonewtextscrap (houtline, htext));
00070     } /*opexportscrap*/
00071 
00072 
00073 boolean opdefaultsetscraproutine (hdloutlinerecord houtline) {
00074     
00075     return (shellsetscrap ((Handle) houtline, opscraptype, &opdisposescrap, &opexportscrap));
00076     } /*opdefaultsetscraproutine*/
00077 
00078 
00079 static boolean opgetscraproutine (hdloutlinerecord *houtline, boolean *fltempscrap) {
00080     
00081     return (shellconvertscrap (opscraptype, (Handle *) houtline, fltempscrap));
00082     } /*opgetscraproutine*/
00083 
00084 
00085 boolean opscraphook (Handle hscrap) {
00086     
00087     /*
00088     if our private type is on the external clipboard, set the internal 
00089     scrap to it.
00090     */
00091     
00092     if (getscrap (opscraptype, hscrap)) {
00093         
00094         hdloutlinerecord houtline;
00095         
00096         if (opunpackoutline (hscrap, &houtline))
00097             opdefaultsetscraproutine (houtline);
00098         
00099         return (false); /*don't call any more hooks*/
00100         }
00101     
00102     return (true); /*keep going*/
00103     } /*opscraphook*/
00104 
00105 
00106 boolean opdefaultreleaserefconroutine (hdlheadrecord hnode, boolean fldisk) {
00107 #pragma unused (hnode, fldisk)
00108 
00109     /*
00110     default callback for releasing the refcon, does nothing.  note that the 
00111     callback is responsible for releasing the data linked into the refcon
00112     field, not for releasing the refcon handle itself.
00113     */
00114     
00115     return (true);
00116     } /*opdefaultreleaserefconroutine*/
00117     
00118     
00119 static boolean opdefaultpushstyle (hdlheadrecord hnode) {
00120 #pragma unused (hnode)
00121 
00122     oppushstyle (outlinedata);
00123     
00124     return (true);
00125     } /*opdefaultpushstyle*/
00126     
00127     
00128 static boolean opdefaultmouseinline (hdlheadrecord hnode, Point pt, const Rect *textrect, boolean *flintext) {
00129     
00130     /*
00131     2/7/97 dmb: chaning the meaning of this callback somewhat, we return
00132     true if the mouse is over text
00133     
00134     5.0a4 dmb: apparantly, the Mac's PtInRect is stricture than we want to be.
00135     also, use textslop pixels like 4.x did
00136 
00137     5.0b7 dmb: added flintext parameter; we now return false if normal 
00138     processing should stop
00139     */
00140     
00141     Rect r = *textrect;
00142     
00143     r.left -= textleftslop;
00144     
00145     if (!(**outlinedata).fltextmode)
00146         r.right = r.left + opgetlinewidth (hnode) + textrightslop;
00147     
00148     // return (pointinrect (pt, r));
00149     
00150     *flintext = (pt.h >= r.left && pt.h <= r.right) &&
00151                 (pt.v >= r.top && pt.v <= r.bottom);
00152     
00153     return (true);
00154     } /*opdefaultmouseinline*/
00155 
00156 
00157 static boolean opdefaulticon2click (hdlheadrecord hnode) {
00158 #pragma unused (hnode)
00159 
00160     return (false); /*don't consume the double-click*/
00161     } /*opdefaulticon2click*/
00162 
00163 
00164 static boolean opdefaultsetscrollbars (void) {
00165 
00166     register ptrwindowinfo pw = *outlinewindowinfo;
00167     register ptroutlinerecord po = *outlinedata;
00168     
00169     (*pw).vertscrollinfo = (*po).vertscrollinfo;
00170     
00171     (*pw).horizscrollinfo = (*po).horizscrollinfo;
00172     
00173     (*pw).fldirtyscrollbars = true; /*force a refresh of scrollbars by the shell*/
00174     
00175     return (true);
00176     } /*opdefaultsetscrollbars*/
00177 
00178 
00179 void opinitcallbacks (hdloutlinerecord houtline) {
00180     
00181     /*
00182     5.0a25 dmb: default cmdclickcallback needs to return false now
00183     
00184     5.0.2b16 dmb: default postfontchangecallback is opseteditbufferrect
00185     
00186     5.1.5 dmb: ...now, it's oppostfontchange
00187     */
00188     
00189     #if !fljustpacking
00190     
00191         register hdloutlinerecord ho = houtline;
00192         
00193         (**ho).setscrollbarsroutine = &opdefaultsetscrollbars;
00194         
00195         // (**ho).getlinedisplayinfocallback = (opgetlineinfocallback) &truenoop;
00196         
00197         (**ho).drawlinecallback = &opdefaultdrawtext; /*the normal text-drawing routine*/
00198         
00199         (**ho).gettextrectcallback = &opdefaultgettextrect;
00200         
00201         (**ho).getedittextrectcallback = &opdefaultgetedittextrect;
00202         
00203         (**ho).setwpedittextcallback = &opdefaultsetwpedittext; /*edits the node's headstring*/
00204         
00205         (**ho).getwpedittextcallback = &opdefaultgetwpedittext; /*updates the node's headstring*/
00206         
00207         (**ho).drawiconcallback = &opdefaultdrawicon; /*the normal icon-drawing routine*/
00208         
00209         (**ho).geticonrectcallback = &opdefaultgeticonrect; /*the normal icon-positioning routine*/
00210         
00211         (**ho).predrawlinecallback = &opdefaultpredrawline; /*erases to background*/
00212         
00213         (**ho).postdrawlinecallback = &opdefaultpostdrawline; /*no-op*/
00214         
00215         (**ho).copyrefconcallback = &opcopyrefconroutine; /*just copies the handle*/
00216         
00217         (**ho).textualizerefconcallback = (optextualizerefconcallback) &truenoop; /*very much like a noop*/
00218         
00219         (**ho).printrefconcallback = (opnodecallback) &truenoop; /*indistinguishable from a noop*/
00220         
00221         (**ho).releaserefconcallback = &opdefaultreleaserefconroutine; /*basically a no-op*/
00222         
00223         (**ho).searchrefconcallback = (opnodecallback) &falsenoop; /*just returns false*/
00224         
00225         (**ho).deletelinecallback = (opnodecallback) &truenoop; /*called before a line is deleted*/
00226         
00227         (**ho).insertlinecallback = (opnodecallback) &truenoop; /*called after a line is inserted*/
00228         
00229         (**ho).textchangedcallback = (optextchangedcallback) &truenoop; /*called when the text of a line has changed*/
00230         
00231         (**ho).mouseinlinecallback = &opdefaultmouseinline;
00232         
00233         (**ho).postfontchangecallback = &oppostfontchange;
00234         
00235         (**ho).hasdynamicsubscallback = (opnodecallback) &falsenoop;
00236         
00237         (**ho).haslinkedtextcallback = (opnodecallback) &falsenoop;
00238         
00239         (**ho).cmdclickcallback = (opnodecallback) &falsenoop;
00240         
00241         (**ho).doubleclickcallback = &truenoop;
00242         
00243         (**ho).getscrapcallback = (opgetscrapcallback) &opgetscraproutine;
00244         
00245         (**ho).setscrapcallback = (opsetscrapcallback) &opdefaultsetscraproutine;
00246         
00247         (**ho).texttooutlinecallback = &optextscraptooutline;
00248         
00249         (**ho).preexpandcallback = (oppreexpandcallback) &truenoop;
00250         
00251         (**ho).postcollapsecallback = (opnodecallback) &truenoop;
00252         
00253         (**ho).validatedragcallback = (opvalidatecallback) &truenoop;
00254         
00255         (**ho).predragcallback = (opdragtargetcallback) &truenoop;
00256         
00257         (**ho).dragcopycallback = (op2nodescallback) &falsenoop;
00258         
00259         (**ho).getlineheightcallback = &opdefaultgetlineheight;
00260         
00261         (**ho).getlinewidthcallback = &opdefaultgetlinewidth;
00262         
00263         (**ho).adjustcursorcallback = opdefaultadjustcursor;
00264         
00265         (**ho).pushstylecallback = &opdefaultpushstyle;
00266         
00267         (**ho).icon2clickcallback = &opdefaulticon2click;
00268         
00269         (**ho).validatepastecallback = (opvalidatecallback) &truenoop;
00270         
00271         (**ho).postpastecallback = (opnodecallback) &truenoop;
00272         
00273         (**ho).validatecopycallback = (opstringcallback) &truenoop;
00274         
00275         (**ho).caneditcallback = (opnodecallback) &truenoop;
00276         
00277         (**ho).getfullrectcallback = &opdefaultgetfullrect;
00278         
00279         (**ho).nodechangedcallback = (opnodecallback) &truenoop;
00280         
00281     //  (**ho).returnkeycallback = opdefaultreturnkey;
00282 
00283         (**ho).beforeprintpagecallback = &truenoop;
00284 
00285         (**ho).afterprintpagecallback = &truenoop;
00286 
00287     #endif
00288     } /*opinitcallbacks*/
00289 
00290 

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