ioarect.c

Go to the documentation of this file.
00001 
00002 /*  $Id: ioarect.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 <iac.h>
00032 #include <ioa.h>
00033 
00034 
00035 typedef struct tyrectdata {
00036 
00037     short versionnumber;
00038     
00039     short subtype; /*1: square corners, 2: rounded corners, 3: oval.*/
00040     
00041     short ovalwidth, ovalheight; /*if subtype is 2*/
00042     
00043     char waste [10];
00044     } tyrectdata, **hdlrectdata;
00045     
00046 
00047 
00048 static boolean newrectdata (hdlrectdata *hdata) {
00049 
00050     hdlrectdata h;
00051     
00052     h = (hdlrectdata) NewHandleClear (longsizeof (tyrectdata));
00053     
00054     if (h == nil)
00055         return (false);
00056     
00057     (**h).versionnumber = 1;
00058     
00059     (**h).subtype = 1;
00060     
00061     *hdata = h;
00062     
00063     return (true);
00064     } /*newrectdata*/
00065     
00066     
00067 static boolean cleanrect (hdlobject h, short height, short width, Rect *r) {
00068 
00069     hdlcard hc = (**h).owningcard;
00070     short gridunits = (**hc).gridunits;
00071     
00072     width = IOAmakemultiple ((*r).right - (*r).left, gridunits);
00073     
00074     height = IOAmakemultiple ((*r).bottom - (*r).top, gridunits);
00075     
00076     (*r).right = (*r).left + width;
00077 
00078     (*r).bottom = (*r).top + height;
00079     
00080     return (true);
00081     } /*cleanrect*/
00082     
00083 
00084 static boolean canreplicaterect (hdlobject h) {
00085 #pragma unused(h)
00086 
00087     return (false); /*it can't be replicated*/
00088     } /*canreplicaterect*/
00089     
00090 
00091 static boolean getrecteditrect (hdlobject h, Rect *r) {
00092 #pragma unused(h, r)
00093 
00094     return (false); /*can't be edited*/
00095     } /*getrecteditrect*/
00096     
00097 
00098 static boolean getrectvalue (hdlobject h, Handle *hvalue) {
00099     
00100     return (IOAgetstringvalue (h, hvalue));
00101     } /*getrectvalue*/
00102     
00103 
00104 static boolean debugrectobject (hdlobject h, bigstring errorstring) {
00105 #pragma unused(h)
00106 
00107     setstringlength (errorstring, 0);
00108     
00109     return (true);
00110     } /*debugrectobject*/
00111     
00112 
00113 static boolean drawrect (hdlobject h) {
00114     
00115     hdlrectdata hdata = (hdlrectdata) (**h).objectdata;
00116     boolean fltransparent = (**h).objecttransparent;
00117     Rect r;
00118     
00119     r = (**h).objectrect;
00120     
00121     IOApushforecolor (&(**h).objectframecolor);
00122     
00123     switch ((**hdata).subtype) {
00124         
00125         case 1: /*square corners*/
00126             if (!fltransparent)
00127                 EraseRect (&r);
00128     
00129             FrameRect (&r);
00130             
00131             break;
00132             
00133         case 2: { /*rounded corners*/
00134             short width = (**hdata).ovalwidth;
00135             short height = (**hdata).ovalheight;
00136             
00137             if (!fltransparent)
00138                 EraseRoundRect (&r, width, height);
00139     
00140             FrameRoundRect (&r, width, height);
00141             
00142             break;
00143             }
00144             
00145         case 3: /*oval*/
00146             if (!fltransparent)
00147                 EraseOval (&r);
00148     
00149             FrameOval (&r);
00150             
00151             break;
00152         } /*switch*/
00153         
00154     IOApopforecolor ();
00155     
00156     return (true);
00157     } /*drawrect*/
00158     
00159 
00160 static boolean initrect (tyobject *obj) {
00161     
00162     newrectdata ((hdlrectdata *) &(*obj).objectdata);
00163     
00164     return (false); /*we don't want to edit it*/
00165     } /*initrect*/
00166     
00167     
00168 static boolean unpackrectdata (hdlobject h) {
00169     
00170     hdlrectdata hdata = (hdlrectdata) (**h).objectdata;
00171     
00172     if (hdata == nil) { /*pre 1.0b15 object, no data handle*/
00173         
00174         if (!newrectdata (&hdata))
00175             return (false);
00176             
00177         (**h).objectdata = (Handle) hdata;
00178         
00179         return (true);
00180         }
00181         
00182     return (true);
00183     } /*unpackrectdata*/
00184 
00185 
00186 static boolean clickrect (hdlobject listhead, hdlobject h, Point pt, boolean flshiftkey, boolean fl2click) {
00187 #pragma unused(listhead, pt, flshiftkey, fl2click)
00188 
00189     IOArunbuttonscript (h);
00190     
00191     return (true); /*do a minor recalc*/
00192     } /*clickrect*/
00193     
00194     
00195 static boolean getrectattributes (hdlobject h, AppleEvent *event) {
00196     
00197     hdlrectdata hdata = (hdlrectdata) (**h).objectdata;
00198     
00199     IACglobals.event = event; 
00200     
00201     if (!IACpushshortparam ((**hdata).subtype, 'subt'))
00202         return (false);
00203     
00204     if (!IACpushshortparam ((**hdata).ovalwidth, 'owid'))
00205         return (false);
00206     
00207     if (!IACpushshortparam ((**hdata).ovalheight, 'ohei'))
00208         return (false);
00209     
00210     return (true);
00211     } /*getrectattributes*/
00212     
00213     
00214 static boolean setrectattributes (hdlobject h, AppleEvent *event) {
00215     
00216     hdlrectdata hdata = (hdlrectdata) (**h).objectdata;
00217     tyrectdata info = **hdata;
00218     
00219     IACglobals.event = event; 
00220     
00221     IACglobals.nextparamoptional = true;
00222     
00223     IACgetshortparam ('subt', &info.subtype); IACglobals.nextparamoptional = true;
00224     
00225     IACgetshortparam ('owid', &info.ovalwidth); IACglobals.nextparamoptional = true;
00226     
00227     IACgetshortparam ('ohei', &info.ovalheight); 
00228     
00229     **hdata = info;
00230     
00231     return (true);
00232     } /*setrectattributes*/
00233     
00234     
00235 void setuprect (tyioaconfigrecord *);
00236 
00237 
00238 void setuprect (tyioaconfigrecord *config) {
00239 
00240     IOAcopystring ("\pRectangle", (*config).objectTypeName);
00241     
00242     (*config).objectTypeID = recttype;
00243     
00244     (*config).frameWhenEditing = false; /*can't be edited*/
00245     
00246     (*config).canEditValue = false;
00247     
00248     (*config).toggleFlagWhenHit = false;
00249     
00250     (*config).mutuallyExclusive = false;
00251     
00252     (*config).speaksForGroup = false;
00253     
00254     (*config).isFontAware = false;
00255     
00256     (*config).hasSpecialCard = true;
00257 
00258     (*config).initObjectCallback = initrect;
00259     
00260     (*config).drawObjectCallback = drawrect;
00261     
00262     (*config).clickObjectCallback = clickrect;
00263     
00264     (*config).cleanupObjectCallback = cleanrect;
00265     
00266     (*config).canReplicateObjectCallback = canreplicaterect;
00267     
00268     (*config).getObjectEditRectCallback = getrecteditrect;
00269     
00270     (*config).getValueForScriptCallback = getrectvalue;
00271     
00272     (*config).debugObjectCallback = debugrectobject;
00273     
00274     (*config).unpackDataCallback = unpackrectdata;
00275     
00276     (*config).getAttributesCallback = getrectattributes;
00277     
00278     (*config).setAttributesCallback = setrectattributes;
00279     } /*setuprect*/
00280     
00281     

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