ioastatic.c

Go to the documentation of this file.
00001 
00002 /*  $Id: ioastatic.c 1197 2006-04-05 22:01:22Z 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 <ioa.h>
00032 
00033 
00034 
00035 static boolean cleanstatic (hdlobject h, short height, short width, Rect *r) {
00036 
00037     hdlcard hc = (**h).owningcard;
00038     short gridunits = (**hc).gridunits;
00039     Handle hvalue;
00040     boolean flmultiline = false;
00041     long i, ct;
00042     
00043     hvalue = (**h).objectvalue;
00044     
00045     ct = GetHandleSize (hvalue);
00046     
00047     for (i = 0; i < ct; i++) {
00048     
00049         if ((*hvalue) [i] == chreturn) { /*it has a hard return in it*/
00050         
00051             flmultiline = true;
00052             
00053             break;
00054             }
00055         } /*for*/
00056 
00057     if (flmultiline) {
00058     
00059         short origheight = height;
00060         
00061         width = IOAmakemultiple ((*r).right - (*r).left, gridunits);
00062         
00063         height = IOAclosestmultiple ((*r).bottom - (*r).top - 4, height);
00064         
00065         if (height < origheight)
00066             height = origheight;
00067         
00068         (*r).right = (*r).left + width;
00069         
00070         (*r).bottom = (*r).top + height;
00071         }
00072     else {
00073         width = IOAmakemultiple (width, gridunits);
00074         
00075         (*r).right = (*r).left + width;
00076         
00077         (*r).bottom = (*r).top + height;
00078         }
00079     
00080     return (true);
00081     } /*cleanstatic*/
00082     
00083 
00084 static boolean canreplicatestatic (hdlobject h) {
00085     
00086     hdlcard hc = (**h).owningcard;
00087     boolean flediting = (**hc).activetextobject != nil;
00088     
00089     return (!flediting); /*only replicate if we're not in edit mode*/
00090     } /*canreplicatestatic*/
00091     
00092 
00093 static boolean getstaticeditrect (hdlobject h, Rect *r) {
00094     
00095     *r = (**h).objectrect;
00096         
00097     return (true); /*can be edited, edit rect is the same as the object's rect*/
00098     } /*getstaticeditrect*/
00099     
00100 
00101 static boolean getstaticvalue (hdlobject h, Handle *hvalue) {
00102     
00103     return (IOAgetstringvalue (h, hvalue));
00104     } /*getstaticvalue*/
00105     
00106 
00107 static boolean debugstatic (hdlobject h, bigstring errorstring) {
00108 #pragma unused(h)
00109 
00110     setstringlength (errorstring, 0);
00111     
00112     return (true);
00113     } /*debugstatic*/
00114     
00115 
00116 static boolean drawstatic (hdlobject h) {
00117     
00118     hdlcard hc = (**h).owningcard;
00119     Handle htext;
00120     Rect r;
00121     
00122     htext = (**h).objectvalue;
00123     
00124     r = (**h).objectrect;
00125     
00126     if (!(**h).objecttransparent)
00127         EraseRect (&r);
00128     
00129     if (!(**hc).flskiptext)
00130         IOAeditdrawtexthandle (htext, r, (**h).objectjustification);
00131     
00132     return (true);
00133     } /*drawstatic*/
00134     
00135 
00136 static boolean initstatic (tyobject *obj) {
00137 #pragma unused(obj)
00138 
00139     return (true); /*we do want to edit it*/
00140     } /*initstatic*/
00141     
00142     
00143 static boolean recalcstatic (hdlobject h, boolean flmajorrecalc) {
00144 #pragma unused(flmajorrecalc)
00145 
00146     return (IOArecalcobjectvalue (h));
00147     } /*recalcstatic*/
00148     
00149     
00150 void setupstatic (tyioaconfigrecord *);
00151 
00152 
00153 void setupstatic (tyioaconfigrecord *config) {
00154 
00155     IOAcopystring ("\pText", (*config).objectTypeName);
00156     
00157     (*config).objectTypeID = statictexttype;
00158     
00159     (*config).frameWhenEditing = true;
00160     
00161     (*config).canEditValue = true;
00162     
00163     (*config).toggleFlagWhenHit = false;
00164     
00165     (*config).mutuallyExclusive = false;
00166     
00167     (*config).speaksForGroup = false;
00168     
00169     (*config).initObjectCallback = initstatic;
00170     
00171     (*config).drawObjectCallback = drawstatic;
00172     
00173     (*config).cleanupObjectCallback = cleanstatic;
00174     
00175     (*config).recalcObjectCallback = recalcstatic;
00176     
00177     (*config).canReplicateObjectCallback = canreplicatestatic;
00178     
00179     (*config).getObjectEditRectCallback = getstaticeditrect;
00180     
00181     (*config).getValueForScriptCallback = getstaticvalue;
00182     
00183     (*config).debugObjectCallback = debugstatic;
00184     } /*setupstatic*/
00185     
00186     

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