icon.c

Go to the documentation of this file.
00001 
00002 /*  $Id: icon.c 1315 2006-04-20 08:42:08Z hasseily $    */
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 "font.h"
00033 #include "cursor.h"
00034 #include "mouse.h"
00035 #include "ops.h"
00036 #include "icon.h"
00037 
00038 #include "shellprint.h"
00039 #include "strings.h" /*7.0b9 PBS*/
00040 #include "file.h" /*7.0b9 PBS*/
00041 #include "resources.h" /*7.0b9 PBS*/
00042 #include "launch.h" /*7.0b9 PBS*/
00043 
00044 #include "byteorder.h"
00045 
00046 /*
00047 #define macicon 128
00048 #define bugicon 129
00049 #define diskicon 130
00050 #define mruserlandicon 131
00051 #define depressedmruserlandicon 132
00052 #define invertedmenubaricon 136
00053 
00054 #define firsthandicon 140
00055 #define lasthandicon 147
00056 
00057 #define systemerroricon macicon
00058 #define langerroricon mruserlandicon
00059 #define fileerroricon diskicon
00060 */
00061 
00062 #define shrunkenwindoidicon 133
00063 #define menubaricon 134
00064 #define depressedshrunkenwindoidicon 135
00065 #define windoidwithtexticon 137
00066 #define windoidwithnotexticon 138
00067 
00068 
00069 
00070 boolean ploticonresource (const Rect *r, short align, short transform, short resid) {
00071     
00072     /*
00073     1.0b20 dmb: try plotting cicn if icon family isn't found. This 
00074     allows all of the stand system icons to be used.
00075     
00076     1.0b21 dmb: try geting normal b&w icon if all else fails
00077 
00078     5.0a8 dmb: use srccopy, not srcand for win blits
00079      
00080     Note that the Windows version does NOT use the transform parameter
00081     */
00082     
00083 #ifdef MACVERSION
00084     OSErr ec;
00085     CIconHandle hcicon;
00086     Handle hicon;
00087     Rect rlocal = *r;
00088     
00089 #ifdef SWAP_BYTE_ORDER
00090     /* For some unknown reason the Intel OS X builds shift the icon displays */
00091     rlocal.top      += 3;
00092     rlocal.bottom   += 3;
00093     rlocal.left += 6;
00094     rlocal.right += 6;
00095 #endif
00096     
00097     ec = PlotIconID (&rlocal, align, transform, resid);
00098     
00099     if (ec == noErr)
00100         return (true);
00101     
00102     hcicon = GetCIcon (resid);
00103     
00104     if (hcicon != nil) {
00105         
00106         PlotCIcon (&rlocal, hcicon);
00107         
00108         DisposeCIcon (hcicon);
00109         
00110         return (true);
00111         }
00112     
00113     hicon = GetIcon (resid);
00114     
00115     if (hicon != nil) {
00116         
00117         PlotIcon (&rlocal, hicon);
00118         
00119         /*ReleaseResource (hicon);*/ /*dmb 1.0b21 - don't need to*/
00120         
00121         return (true);
00122         }
00123     
00124     return (false);
00125 #endif
00126 
00127 #ifdef WIN95VERSION
00128     HBITMAP hbm, oldbm;
00129     BITMAP bm;
00130     HDC hdcsrc, hdc;
00131     boolean flprinting;
00132     HDC hdcmask;
00133     HBITMAP hbmmask, oldmaskbm;
00134     COLORREF oldclr, oldclr2;
00135 
00136 
00137     hbm = LoadBitmap (shellinstance, MAKEINTRESOURCE (resid));
00138 
00139     if (hbm)
00140         {
00141         hdc = getcurrentDC();
00142 
00143         flprinting = iscurrentportprintport ();
00144 
00145         if (hdc)
00146             {
00147             hdcsrc = CreateCompatibleDC (hdc);
00148 
00149             if (hdcsrc)
00150                 {
00151                 GetObject (hbm, sizeof (BITMAP), &bm);
00152 
00153                 oldbm = (HBITMAP) SelectObject (hdcsrc, hbm);
00154                 
00155                 if (flprinting) {
00156                 //  StretchBlt (hdc, r->left, r->top, r->right-r->left, r->bottom - r->top, hdcsrc, 0,0, bm.bmWidth, bm.bmHeight, SRCCOPY);
00157                     }
00158                 else {
00159                     hdcmask = CreateCompatibleDC (hdc);
00160                     hbmmask = CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL);
00161 
00162                     if (hdcmask && hbmmask) {
00163                         oldmaskbm = (HBITMAP) SelectObject (hdcmask, hbmmask);
00164 
00165                         oldclr = SetBkColor (hdcsrc, RGB(255,255,255));
00166 
00167                         BitBlt (hdcmask, 0,0,bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCCOPY);
00168 
00169                         SetBkColor (hdcsrc,oldclr);
00170 
00171                         eraserect (*r);
00172 
00173                         oldclr = SetBkColor (hdc, RGB(255,255,255));
00174                         oldclr2 = SetTextColor (hdc, RGB(0,0,0));
00175 
00176                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
00177                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcmask, 0,0, SRCAND);
00178                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
00179 
00180                         SetBkColor (hdc,oldclr);
00181                         SetTextColor (hdc,oldclr2);
00182 
00183                         SelectObject (hdcmask, oldmaskbm);
00184 
00185     //                  BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCAND);
00186                         }
00187 
00188                     DeleteObject (hbmmask);
00189                     DeleteDC (hdcmask);
00190                     }
00191 
00192                 SelectObject (hdcsrc, oldbm);
00193                 DeleteDC (hdcsrc);
00194                 }
00195             }
00196 
00197         DeleteObject (hbm);
00198         }
00199     
00200     return (true);  
00201 #endif
00202     } /*ploticonresource*/
00203 
00204 
00205 #ifdef MACVERSION
00206 
00207 
00208 struct tycustomicontypeinfo icontypes [maxcustomicontypes]; /*array*/
00209 
00210 static short ixnexticon = 0; /*keep track of which is next to load*/
00211 
00212 
00213 boolean customicongetrnum (bigstring bstype, short *rnum) {
00214     
00215     /*
00216     7.0b9 PBS: get the rnum of a file containing custom icon.
00217     */
00218     
00219     short i = 0;
00220     
00221     alllower (bstype);
00222     
00223     while (i < ixnexticon) {
00224         
00225         if (equalstrings (bstype, icontypes [i].bstype)) {
00226         
00227             *rnum = icontypes [i].rnum;
00228             
00229             return (true);
00230             } /*if*/
00231         
00232         i++;
00233         
00234         if (i == maxcustomicontypes)
00235         
00236             break;      
00237         } /*while*/
00238     
00239     return (false); 
00240     } /*customicongetresid*/
00241 
00242 
00243 static boolean customiconload (bigstring bsiconname, short *rnum) {
00244     
00245     /*
00246     7.0b9 PBS: Open a resource file just once, store info about it,
00247     so it doesn't have to be opened for each rendering.
00248     */
00249     
00250     bigstring bsappearancefolder = "\pAppearance";
00251     bigstring bsiconsfolder = "\pIcons";
00252     OSErr err;
00253     CInfoPBRec pb;
00254     long dirid;
00255     FSSpec programfilespec;
00256     FSSpec appearancefolder, iconsfolder, iconfilespec;
00257     short r, ixcurricon;
00258     
00259     if (ixnexticon >= maxcustomicontypes)
00260     
00261         return (false); /*limit reached*/
00262     
00263     /*Get app file spec*/
00264     
00265     getapplicationfilespec (nil, &programfilespec);
00266     
00267     dirid = programfilespec.parID;
00268     
00269     /*Get Appearances folder*/
00270     
00271     err = FSMakeFSSpec (programfilespec.vRefNum, dirid, bsappearancefolder, &appearancefolder);
00272     
00273     if (!getmacfileinfo (&appearancefolder, &pb))
00274     
00275         return (false);
00276 
00277     dirid = pb.dirInfo.ioDrDirID;
00278     
00279     /*Get Icons folder*/
00280     
00281     err = FSMakeFSSpec (appearancefolder.vRefNum, dirid, bsiconsfolder, &iconsfolder);
00282     
00283     if (err != noErr)
00284     
00285         return (false);
00286     
00287     if (!getmacfileinfo (&iconsfolder, &pb))
00288     
00289         return (false);
00290         
00291     dirid = pb.dirInfo.ioDrDirID;
00292 
00293     /*Get icon file*/
00294     
00295     err = FSMakeFSSpec (iconsfolder.vRefNum, dirid, bsiconname, &iconfilespec);
00296     
00297     if (err != noErr)
00298     
00299         return (false);
00300     
00301     r = FSpOpenResFile (&iconfilespec, fsRdPerm);
00302     
00303     if (r == -1)
00304     
00305         return (false);
00306     
00307     *rnum = r;
00308     
00309     ixcurricon = ixnexticon;
00310     
00311     ixnexticon++;
00312     
00313     alllower (bsiconname);
00314     
00315     copystring (bsiconname, icontypes [ixcurricon].bstype);
00316     
00317     icontypes [ixcurricon].rnum = r;
00318     
00319     return (true);  
00320     } /*customiconload*/
00321 
00322 #endif
00323 
00324 
00325 boolean ploticoncustom (const Rect *r, short align, short transform, bigstring bsiconname) {
00326     
00327     /*
00328     7.0b9 PBS: plot a custom icon.
00329     */
00330     
00331 #ifdef MACVERSION
00332 
00333     short rnum;
00334     short resid = 128; /*Always 128 for custom icons*/
00335     short saveresfile;
00336 
00337     /*Get the resource reference for the file containing this icon.*/
00338     
00339     if (!customicongetrnum (bsiconname, &rnum)) { /*Already loaded?*/
00340     
00341         if (!customiconload (bsiconname, &rnum)) { /*Try to load it.*/
00342         
00343             return (false);
00344             } /*if*/
00345         } /*if*/
00346     
00347     saveresfile = CurResFile ();
00348     
00349     UseResFile (rnum);
00350     
00351     ploticonresource (r, align, transform, resid);
00352     
00353     UseResFile (saveresfile);
00354     
00355     return (true);
00356 
00357 #endif
00358 
00359 #ifdef WIN95VERSION
00360     HBITMAP hbm, oldbm;
00361     BITMAP bm;
00362     HDC hdcsrc, hdc;
00363     boolean flprinting;
00364     HDC hdcmask;
00365     HBITMAP hbmmask, oldmaskbm;
00366     COLORREF oldclr, oldclr2;
00367     bigstring bsfilepath;
00368     char cfilepath [256];
00369     
00370     copystring (BIGSTRING ("\x11" "Appearance\\Icons\\"), bsfilepath);
00371     
00372     pushstring (bsiconname, bsfilepath); /*add file name to folder path*/
00373 
00374     pushstring (BIGSTRING ("\x04" ".bmp"), bsfilepath); /*add .bmp file extension*/
00375 
00376     copyptocstring (bsfilepath, cfilepath);
00377 
00378     /*Load the image from a file.*/
00379 
00380     hbm = LoadImage (shellinstance, cfilepath, IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE);
00381 
00382     if (hbm == NULL) /*Load failed, return false, use default icon.*/
00383 
00384         return (false);
00385 
00386     if (hbm)
00387         {
00388         hdc = getcurrentDC();
00389 
00390         flprinting = iscurrentportprintport ();
00391 
00392         if (hdc)
00393             {
00394             hdcsrc = CreateCompatibleDC (hdc);
00395 
00396             if (hdcsrc)
00397                 {
00398                 GetObject (hbm, sizeof (BITMAP), &bm);
00399 
00400                 oldbm = (HBITMAP) SelectObject (hdcsrc, hbm);
00401                 
00402                 if (flprinting) {
00403                 //  StretchBlt (hdc, r->left, r->top, r->right-r->left, r->bottom - r->top, hdcsrc, 0,0, bm.bmWidth, bm.bmHeight, SRCCOPY);
00404                     }
00405                 else {
00406                     hdcmask = CreateCompatibleDC (hdc);
00407                     hbmmask = CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL);
00408 
00409                     if (hdcmask && hbmmask) {
00410                         oldmaskbm = (HBITMAP) SelectObject (hdcmask, hbmmask);
00411 
00412                         oldclr = SetBkColor (hdcsrc, RGB(255,255,255));
00413 
00414                         BitBlt (hdcmask, 0,0,bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCCOPY);
00415 
00416                         SetBkColor (hdcsrc,oldclr);
00417 
00418                         eraserect (*r);
00419 
00420                         oldclr = SetBkColor (hdc, RGB(255,255,255));
00421                         oldclr2 = SetTextColor (hdc, RGB(0,0,0));
00422 
00423                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
00424                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcmask, 0,0, SRCAND);
00425                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
00426 
00427                         SetBkColor (hdc,oldclr);
00428                         SetTextColor (hdc,oldclr2);
00429 
00430                         SelectObject (hdcmask, oldmaskbm);
00431 
00432     //                  BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCAND);
00433                         }
00434 
00435                     DeleteObject (hbmmask);
00436                     DeleteDC (hdcmask);
00437                     }
00438 
00439                 SelectObject (hdcsrc, oldbm);
00440                 DeleteDC (hdcsrc);
00441                 }
00442             }
00443 
00444         DeleteObject (hbm);
00445         }
00446 
00447     return (true);  
00448 #endif
00449     } /*ploticoncustom*/
00450 
00451 
00452 #if 0
00453 
00454 /*7.0b9 PBS: saved version that had test code for getting a bitmap from the odb.*/
00455 
00456 boolean ploticoncustom (const Rect *r, short align, short transform) {
00457     
00458     /*
00459     7.0b9 PBS: plot a custom icon.
00460     */
00461     
00462 
00463 #ifdef WIN95VERSION
00464     HBITMAP hbm, oldbm;
00465     BITMAP bm;
00466     HDC hdcsrc, hdc;
00467     boolean flprinting;
00468     HDC hdcmask;
00469     HBITMAP hbmmask, oldmaskbm;
00470     COLORREF oldclr, oldclr2;
00471 
00472     bigstring bsadricon = BIGSTRING ("\x18" "user.playlist.icons.face");
00473     bigstring bsname;
00474     hdlhashtable ht;
00475     hdlhashnode hn;
00476     tyvaluerecord iconvalue;
00477     bigstring bsiconname = BIGSTRING ("\x04" "face");
00478     boolean flexpanded = false;
00479     boolean fllookup = false;
00480     Handle hicon;
00481 
00482     pushhashtable (roottable);
00483 
00484     disablelangerror ();
00485 
00486     flexpanded = langexpandtodotparams (bsadricon, &ht, bsname);
00487     enablelangerror ();
00488     pophashtable ();
00489 
00490 
00491     fllookup = hashtablelookup (ht, bsiconname, &iconvalue, &hn);
00492     copyhandle (iconvalue.data.binaryvalue, &hicon);
00493     stripbinarytypeid (hicon);
00494 
00495     hbm = CreateBitmap (16, 16, 1, 32, hicon);
00496 
00497 //  hbm = LoadImage (shellinstance, "face.bmp", IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE);
00498 
00499     if (hbm)
00500         {
00501         hdc = getcurrentDC();
00502 
00503         flprinting = iscurrentportprintport ();
00504 
00505         if (hdc)
00506             {
00507             hdcsrc = CreateCompatibleDC (hdc);
00508 
00509             if (hdcsrc)
00510                 {
00511                 //GetObject (hbm, sizeof (BITMAP), &bm);
00512 
00513                 bm.bmType = 0;
00514                 bm.bmWidth = 16;
00515                 bm.bmHeight = 16;
00516                 bm.bmWidthBytes = 32;
00517                 bm.bmPlanes = 1;
00518                 bm.bmBitsPixel = 16;
00519                 bm.bmBits = hicon;
00520 
00521                 oldbm = (HBITMAP) SelectObject (hdcsrc, hbm);
00522                 
00523                 if (flprinting) {
00524                 //  StretchBlt (hdc, r->left, r->top, r->right-r->left, r->bottom - r->top, hdcsrc, 0,0, bm.bmWidth, bm.bmHeight, SRCCOPY);
00525                     }
00526                 else {
00527                     hdcmask = CreateCompatibleDC (hdc);
00528                     hbmmask = CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL);
00529 
00530                     if (hdcmask && hbmmask) {
00531                         oldmaskbm = (HBITMAP) SelectObject (hdcmask, hbmmask);
00532 
00533                         oldclr = SetBkColor (hdcsrc, RGB(255,255,255));
00534 
00535                         BitBlt (hdcmask, 0,0,bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCCOPY);
00536 
00537                         SetBkColor (hdcsrc,oldclr);
00538 
00539                         eraserect (*r);
00540 
00541                         oldclr = SetBkColor (hdc, RGB(255,255,255));
00542                         oldclr2 = SetTextColor (hdc, RGB(0,0,0));
00543 
00544                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
00545                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcmask, 0,0, SRCAND);
00546                         BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
00547 
00548                         SetBkColor (hdc,oldclr);
00549                         SetTextColor (hdc,oldclr2);
00550 
00551                         SelectObject (hdcmask, oldmaskbm);
00552 
00553     //                  BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCAND);
00554                         }
00555 
00556                     DeleteObject (hbmmask);
00557                     DeleteDC (hdcmask);
00558                     }
00559 
00560                 SelectObject (hdcsrc, oldbm);
00561                 DeleteDC (hdcsrc);
00562                 }
00563             }
00564 
00565         DeleteObject (hbm);
00566         }
00567     disposehandle (hicon);
00568     return (true);  
00569 #endif
00570     } /*ploticoncustom*/
00571 
00572 #endif
00573 
00574 
00575 boolean ploticon (const Rect *r, short id) {
00576     
00577     /*
00578     plot the icon with the given id in rect r.  if a color icon is available, 
00579     and the machine supports color, use the color version
00580     */
00581     
00582 #ifdef MACVERSION
00583     Handle hicon;
00584     CIconHandle hcicn;
00585     
00586     if (systemhascolor ()) {
00587         
00588         hcicn = GetCIcon (id);
00589         
00590         if (hcicn != nil) {
00591             
00592             PlotCIcon (r, hcicn);
00593             
00594             DisposeCIcon (hcicn);
00595             
00596             return (true);
00597             }
00598         }
00599     
00600     hicon = GetResource ('ICON', id);
00601     
00602     if (hicon != nil) {
00603         
00604         PlotIcon (r, hicon);
00605         
00606         return (true);
00607         }
00608     
00609     return (false);
00610 #endif
00611 
00612 #ifdef WIN95VERSION
00613     return (ploticonresource (r, 0, 0, id));
00614 #endif
00615     } /*ploticon*/
00616 
00617 
00618 #if !flruntime
00619 
00620 void drawlabeledicon (const Rect *r, short resnum, bigstring bslabel, boolean flinverted) {
00621     
00622     /*
00623     draw the indicated icon resource with the label below it.
00624     
00625     the label is horizontally centered flush with the bottom of the rectangle.
00626     
00627     the icon is vertically and horizontally centered in the rectangle minus the
00628     area where the label is drawn.
00629     
00630     if flinverted is true, the icon is drawn and then inverted.
00631     
00632     4/3/91 dmb: not safe to do a validrect here, unless we're willing to 
00633     calculate the intersection of the rect and the clip region.
00634     */
00635     
00636     Rect rlabel, ricon, rcenter;
00637     
00638     /*
00639     validrect (r);
00640     */
00641     
00642     pushstyle (geneva, 9, 0);
00643     
00644     rlabel = *r;
00645     
00646     rlabel.top = (*r).bottom - globalfontinfo.ascent - globalfontinfo.descent;
00647     
00648     centerstring (rlabel, bslabel);
00649     
00650     popstyle ();
00651     
00652     rcenter = *r;
00653     
00654     rcenter.bottom = rlabel.top; /*confine icon to area above the label*/
00655     
00656     ricon.top = ricon.left = 0;
00657     
00658     ricon.bottom = ricon.right = 32;
00659     
00660     centerrect (&ricon, rcenter);
00661     
00662     if (ploticon (&ricon, resnum)) {
00663             
00664         if (flinverted)
00665             invertrect (ricon);
00666         }
00667     } /*drawlabeledicon*/
00668     
00669 /*
00670 drawiconsequence (Rect r, short firsticon, short lasticon, bigstring bs) {
00671     
00672     register short i;
00673     
00674     for (i = firsticon; i <= lasticon; i++) {
00675         
00676         drawlabeledicon (r, i, bs, false);
00677         
00678         delayticks (1);
00679         }
00680     } /%drawiconsequence%/
00681 */
00682 
00683 
00684 #if TARGET_API_MAC_CARBON == 1
00685 
00686 static void
00687 MyThemeButtonDrawCallback (
00688         const Rect                  *bounds,
00689         ThemeButtonKind              kind,
00690         const ThemeButtonDrawInfo   *info,
00691         UInt32                       refcon,
00692         SInt16                       depth,
00693         Boolean                      isColorDev)
00694 {
00695 #pragma unused (kind, info, refcon, depth, isColorDev)
00696 
00697         /*
00698         7.0b48 PBS: draw the arrow for a pushbutton. It will be centered.
00699         */
00700         
00701         Rect rarrow;
00702         //ptrstring bsptr = (ptrstring) refcon;
00703         
00704         setrect (&rarrow, 0, 0, 9, 9);
00705         
00706         centerrect (&rarrow, *bounds);
00707         
00708         rarrow.left++; /*it appears to need it*/
00709                 
00710         DrawThemePopupArrow (&rarrow, kThemeArrowRight, kThemeArrow9pt, kThemeStateActive, NULL, 0);
00711 
00712     } /*MyThemeButtonDrawCallback*/
00713 
00714 #endif
00715 
00716 void drawlabeledwindoidicon (Rect r, bigstring bslabel, boolean flhastext, boolean flpressed) {
00717     
00718     /*
00719     draw the labeled windoid icon in the appropriate state
00720     */
00721     
00722     #if TARGET_API_MAC_CARBON == 1
00723     
00724         ThemeButtonDrawInfo drawinfo;
00725         ThemeButtonDrawUPP drawupp;
00726         Rect rbutton;
00727         
00728         drawupp = NewThemeButtonDrawUPP (MyThemeButtonDrawCallback);
00729 
00730         drawinfo.state = kThemeButtonOn;
00731         
00732         drawinfo.value = kThemeStateActive;
00733 
00734         if (flpressed)
00735             drawinfo.value = kThemeStatePressed;
00736         
00737         drawinfo.adornment = 0;
00738         
00739         rbutton = r;
00740         
00741         rbutton.bottom = rbutton.bottom - 12; /*leave room for label*/
00742         
00743         DrawThemeButton (&rbutton, kThemeLargeBevelButton, &drawinfo, nil, nil, drawupp, (unsigned long) bslabel); 
00744         
00745         //DisposeThemeButtonDrawUPP (MyThemeButtonDrawCallback);
00746         DisposeThemeButtonDrawUPP (drawupp);
00747         if (flhastext) {
00748             
00749             Rect rlabel;
00750             
00751             pushstyle (geneva, 9, 0);
00752     
00753             rlabel = r;
00754     
00755             rlabel.top = r.bottom - globalfontinfo.ascent - globalfontinfo.descent;
00756     
00757             centerstring (rlabel, bslabel);
00758     
00759             popstyle ();
00760             } /*if*/            
00761             
00762     #else
00763 
00764         register short resnum;
00765         
00766         if (flpressed)
00767             resnum = depressedshrunkenwindoidicon;
00768             
00769         else {
00770             if (flhastext)
00771                 resnum = windoidwithtexticon;
00772             else
00773                 resnum = windoidwithnotexticon;
00774             }
00775         
00776         drawlabeledicon (&r, resnum, bslabel, false);
00777     
00778     #endif
00779         
00780     } /*drawlabeledwindoidicon*/
00781 
00782 
00783 boolean trackicon (Rect r, void (*displayiconcallback) (boolean)) {
00784     
00785     /*
00786     this is really more general than its name implies, but for now 
00787     it covers the common calling mousetracking conventions use by 
00788     all the windoid icons, and belongs here.
00789     
00790     12/12/90 dmb: if mousetrack returns false, icon has already been displayed 
00791     in off state, and shouldn't be redisplayed (in case callback uses simple 
00792     inversion)
00793     */
00794     
00795     setcursortype (cursorisarrow); /*get rid of funny appendage*/
00796     
00797     (*displayiconcallback) (true); /*show icon in depressed state*/
00798     
00799     if (!mousetrack (r, displayiconcallback)) /*if false, mouse didn't stay in rectangle*/
00800         return (false);
00801     
00802     (*displayiconcallback) (false); /*show icon in un-depressed state*/
00803     
00804     return (true);
00805     } /*trackicon*/
00806 
00807 #endif
00808 
00809 
00810 
00811 

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