smallicon.c

Go to the documentation of this file.
00001 
00002 /*  $Id: smallicon.c 1201 2006-04-05 22:31:38Z 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 "quickdraw.h"
00032 #include "icon.h"
00033 #include "memory.h"
00034 #include "mouse.h"
00035 #include "ops.h"
00036 #include "dialogs.h"
00037 #include "quickdraw.h"
00038 #include "smallicon.h"
00039 #include "frontierwindows.h"
00040 
00041 
00042 
00043 static hdlsmalliconbits hmiscbits;
00044 //static hdlsmalliconbits hleaderbits;
00045 
00046 #ifndef version42orgreater
00047     #define trianglepolyheight 9 /*for popup icons*/
00048     #define trianglepolywidth 5
00049 
00050     hdlsmalliconbits hfinderbits, hdraggingbits, hcirclebits, htablebits;
00051 #endif
00052 
00053 
00054 
00055 
00056 boolean plotsmallicon (tysmalliconspec spec) {
00057 
00058 #ifdef MACVERSION
00059     register hdlsmalliconbits hbits;
00060     short mode;
00061     BitMap iconbitmap;
00062     
00063     hbits = spec.hbits;
00064     
00065     if (hbits == nil) {
00066     
00067         switch (spec.iconlist) {
00068             
00069             case miscsmalliconlist:
00070                 hbits = hmiscbits;
00071                 
00072                 break;
00073             
00074             /*
00075             case leadersmalliconlist:
00076                 hbits = hleaderbits;
00077                 
00078                 break;
00079             
00080             case draggingsmalliconlist:
00081                 hbits = hdraggingbits;
00082                 
00083                 break;
00084                 
00085             case tablesmalliconlist:
00086                 hbits = htablebits;
00087                 
00088                 break;
00089             
00090             case circlesmalliconlist:
00091                 hbits = hcirclebits;
00092                 
00093                 break;
00094             
00095             case findersmalliconlist:
00096                 hbits = hfinderbits;
00097                 
00098                 break;
00099             */
00100             
00101             } /*switch*/
00102         } /*nil bits*/
00103         
00104     if (hbits == nil)
00105         return (false);
00106         
00107     iconbitmap.baseAddr = (Ptr) &(*hbits) [spec.iconnum];
00108     
00109     iconbitmap.rowBytes = 2;
00110     
00111     iconbitmap.bounds.top = iconbitmap.bounds.left = 0; 
00112     
00113     iconbitmap.bounds.bottom = spec.iconrect.bottom - spec.iconrect.top; 
00114     
00115     iconbitmap.bounds.right = spec.iconrect.right - spec.iconrect.left;
00116     
00117     if (spec.flinverted)
00118         mode = notSrcCopy;
00119         
00120     else {
00121         if (spec.flclearwhatsthere)
00122             mode = srcCopy;
00123         else
00124             mode = srcOr;
00125         }
00126     //Code change by Timothy Paustian Friday, May 5, 2000 10:26:38 PM
00127     //Changed to Opaque call for Carbon
00128     #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00129     {//added the bracket to save on code spread
00130     CGrafPtr windPort = GetWindowPort(spec.iconwindow);
00131     CopyBits (
00132         &iconbitmap, GetPortBitMapForCopyBits(windPort), 
00133         
00134         &iconbitmap.bounds, &spec.iconrect, mode, nil);
00135     }
00136     #else
00137     CopyBits (
00138         &iconbitmap, &(*spec.iconwindow).portBits, 
00139         
00140         &iconbitmap.bounds, &spec.iconrect, mode, nil);
00141     #endif
00142     
00143     return (true);
00144 #endif
00145 
00146 #ifdef WIN95VERSION
00147     if (!ploticon (&spec.iconrect, spec.iconlist * 10 + spec.iconnum))
00148         return (false);
00149 
00150     if (spec.flinverted)
00151         invertrect (spec.iconrect);
00152 
00153     return (true);
00154 #endif
00155     } /*plotsmallicon*/
00156     
00157     
00158 boolean displaypopupicon (Rect r, boolean flenabled) {
00159     
00160     #if TARGET_API_MAC_CARBON == 1
00161     
00162         short themestate = kThemeStateActive;
00163         
00164         if (!flenabled)
00165             themestate = kThemeStateUnavailable;
00166             
00167         /*It's always too high.*/
00168             
00169         r.top = r.top + 4;
00170         
00171         r.bottom = r.bottom + 4;
00172     
00173         DrawThemePopupArrow (&r, kThemeArrowDown, kThemeArrow9pt, themestate, NULL, 0);
00174 
00175         return (true);
00176     
00177     #else
00178     
00179         tysmalliconspec spec;
00180         
00181         spec.hbits = nil;
00182         
00183         spec.iconlist = miscsmalliconlist;
00184         
00185         if (flenabled)
00186             spec.iconnum = blackpopupicon;
00187         else
00188             spec.iconnum = graypopupicon;
00189         
00190         spec.iconwindow = getport (); // quickdrawglobal (thePort);
00191         
00192         spec.iconrect = r;
00193         
00194         spec.flinverted = false;
00195         
00196         spec.flclearwhatsthere = true;
00197         
00198         return (plotsmallicon (spec));
00199         
00200     #endif
00201     } /*displaypopupicon*/
00202     
00203     
00204 boolean loadsmallicon (short resnum, hdlsmalliconbits *hbits) {
00205     
00206 #ifdef MACVERSION
00207     Handle h;
00208     boolean fl;
00209     SInt8 hState;
00210     
00211     h = GetResource ('SICN', resnum);
00212     
00213     LoadResource(h); /*in case resource was purged*/
00214     hState = HGetState(h);
00215     HNoPurge(h); /*in case resource is purgeable*/
00216     fl = copyhandle (h, (Handle *) hbits);
00217     HSetState(h, hState);
00218     
00219     return (fl);
00220 #endif
00221 
00222 #ifdef WIN95VERSION
00223     *hbits = NULL;  // we map to individual icons
00224 
00225     return (true);
00226 #endif
00227     } /*loadsmallicon*/
00228 
00229 
00230 boolean myMoof (short ticksbetweenframes, long howlong) {
00231     
00232     /*
00233     Meet myMoof, our tip o the hat to Mac DTS. 
00234     
00235     Lest anyone think that UserLand Software doesn't REALLY understand multimedia!
00236     
00237     3/17/93 dmb: added howlong parameter so user interaction isn't required
00238     */
00239     
00240     WindowPtr w;
00241     tysmalliconspec sicn;   
00242     short i;
00243     Rect rport;
00244     long tc;
00245     CGrafPtr    thePort;
00246     
00247     tc = gettickcount ();
00248     
00249     if (!loadsmallicon (moofsmalliconlist, &sicn.hbits))
00250         goto error;
00251     
00252     setrect (&rport, 0, 0, 32, 32);
00253 
00254     centerrectondesktop (&rport);
00255     
00256     w = getnewwindow (132, false, &rport);
00257     
00258     if (w == nil) 
00259         goto error;
00260     
00261     if (abs (howlong) < 0x2222222) /*convert to ticks, avoiding overflow*/
00262         howlong *= 60;
00263     
00264 #ifdef MACVERSION
00265     //you cannot call this with a window ptr, the function needs a dialog ptr
00266     //its really not needed anyway, but I will leave it in for the non-carbon version
00267     #if TARGET_API_MAC_CARBON == 0
00268     positiondialogwindow (w);
00269     #endif
00270 #endif
00271 
00272     showwindow (w); 
00273     
00274     //Code change by Timothy Paustian Monday, August 21, 2000 4:31:49 PM
00275     //Must pass a CGrafPtr to pushport on OS X to avoid a crash
00276     {
00277     #if TARGET_API_MAC_CARBON == 1
00278     thePort = GetWindowPort(w);
00279     #else
00280     thePort = (CGrafPtr)w;
00281     #endif
00282         
00283     pushport (thePort);
00284     }
00285     setrect (&rport, 0, 0, 32, 32); // rport = (*w).portRect;
00286     
00287     sicn.iconlist = moofsmalliconlist;
00288         
00289     sicn.iconwindow = w;
00290     
00291     sicn.flinverted = false;
00292     
00293     sicn.flclearwhatsthere = true;
00294     
00295     sicn.iconrect = rport;
00296     
00297     insetrect (&sicn.iconrect, 8, 8);
00298     
00299     while (true) {
00300     
00301         for (i = 0; i < 7; i++) {
00302         
00303             sicn.iconnum = i;
00304             
00305             plotsmallicon (sicn);
00306             #if TARGET_API_MAC_CARBON
00307             QDFlushPortBuffer(thePort, nil);
00308             #endif
00309             if (mousebuttondown ()) {
00310                 
00311                 while (mousebuttondown ()) {}
00312                 
00313                 /*
00314                 pushstyle (geneva, 9, 0);
00315                 
00316                 eraserect (rport);
00317                 
00318                 centerstring (rport, "\pPOOF!");
00319                 
00320                 popstyle ();
00321                 
00322                 delayticks (30);
00323                 */
00324                 
00325                 goto endloop;
00326                 }
00327             
00328             if (howlong != 0) {
00329                 
00330                 if (gettickcount () - tc > (unsigned long) howlong)
00331                     goto endloop;
00332                 }
00333             
00334             delayticks (ticksbetweenframes);
00335             } /*for*/
00336         } /*while*/
00337     
00338     endloop:
00339     
00340     popport ();
00341     
00342     disposewindow (w);
00343     
00344     disposehandle ((Handle) sicn.hbits);
00345     
00346     return (true);
00347 
00348     error:
00349         
00350     sysbeep ();
00351     
00352     return (false);
00353     } /*myMoof*/
00354 
00355 
00356 boolean initsmallicons (void) {
00357     
00358     loadsmallicon (miscsmalliconlist, &hmiscbits);
00359     
00360     /*
00361     loadsmallicon (leadersmalliconlist, &hleaderbits);
00362 
00363     loadsmallicon (draggingsmalliconlist, &hdraggingbits);
00364 
00365     loadsmallicon (findersmalliconlist, &hfinderbits);
00366     
00367     loadsmallicon (circlesmalliconlist, &hcirclebits);
00368     
00369     loadsmallicon (tablesmalliconlist, &htablebits);
00370     */
00371     
00372     return (true);
00373     } /*initsmallicons*/
00374 
00375 

Generated on Wed May 31 18:20:02 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6