opicons.c

Go to the documentation of this file.
00001 
00002 /*  $Id: opicons.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 "icon.h"
00033 #include "op.h" /*7.0b16 PBS*/
00034 #include "opicons.h"
00035 #include "opdisplay.h"
00036 #include "strings.h" /*7.0b9 PBS*/
00037 
00038 
00039 #define canexpandicon 475
00040 #define cantexpandicon 476
00041 #define canexpandcommenticon 477
00042 #define cantexpandcommenticon 478
00043 #define righticon 479
00044 #define lefticon 480
00045 #define downicon 481
00046 #define upicon 482
00047 #define breakpointicon 483
00048 #define markedicon 484
00049 #define expandedicon 485
00050 #ifdef WIN95VERSION
00051     #define refconicon 43 /*7.0d7 PBS: musical note icon.*/
00052 #endif
00053 #ifdef MACVERSION
00054     #define refconicon 489 /*7.0b2 PBS: musical note icon has different id in Mac version.*/
00055 #endif
00056 #define customicon 490
00057 
00058 
00059 short opgetheadicon (hdlheadrecord hnode) {
00060     
00061     register hdloutlinerecord ho = outlinedata;
00062     boolean flcanexpand;
00063     
00064     if ((**ho).flprinting) /*show all leaders as gray when printing*/
00065         flcanexpand = false;
00066     else
00067         flcanexpand = ophassubheads (hnode) && (!opsubheadsexpanded (hnode));
00068     
00069     if (opnestedincomment (hnode)) {
00070         
00071         if (flcanexpand)
00072             return (canexpandcommenticon);
00073         else
00074             return (cantexpandcommenticon);
00075         }
00076     
00077     if ((**hnode).flbreakpoint)
00078         return (breakpointicon);
00079     
00080     #if false   //ndef onlineOutliner
00081     
00082         if ((**hnode).flmarked)
00083             return (markedicon);
00084     
00085     #endif
00086         
00087     if (flcanexpand)
00088         return (canexpandicon);
00089     else
00090         return (cantexpandicon);
00091     } /*opgetheadicon*/
00092     
00093     
00094 void opdrawheadicon (short iconnum, const Rect *r, boolean flselected) {
00095     /*
00096      This function draws the triangle icons inside outlines (but not root tables).
00097      Root table triangles are in tabledisplay.c, browserdrawnodeicon()
00098      */
00099     
00100     operaserect (*r);
00101 
00102 #ifdef MACVERSION
00103     short transform = kTransformNone;
00104     
00105     if (flselected)
00106         transform = kTransformSelected; 
00107     
00108     ploticonresource ((Rect *) r, kAlignAbsoluteCenter, transform, iconnum);
00109 #endif
00110 
00111 #ifdef WIN95VERSION
00112     ploticonresource (r, 0, 0, iconnum);
00113 #endif
00114     } /*opdrawheadicon*/
00115 
00116 
00117 boolean opdrawheadiconcustom (bigstring bsiconname, const Rect *r, boolean flselected) {
00118     
00119     short transform = 0;
00120 
00121     if (flselected)
00122         transform = kTransformSelected; 
00123     
00124     operaserect (*r);
00125 
00126     return (ploticoncustom (r, 0, transform, bsiconname));
00127     } /*opdrawheadiconcustom*/
00128 
00129 
00130 boolean opdefaultdrawicon (hdlheadrecord hnode, const Rect *iconrect, boolean flselected, boolean flinverted) {
00131 #pragma unused(flselected, flinverted)
00132 
00133     /*
00134     the default icon drawing routine, for the script editor and menu
00135     editor, not for clay basket.
00136     */
00137     
00138     register hdloutlinerecord ho = outlinedata;
00139     short iconnum;
00140     bigstring bsheadlinetype; /*7.0b9 PBS*/
00141     boolean flcustomicondrawn = false;
00142     
00143     iconnum = opgetheadicon (hnode);
00144     
00145 //#ifdef PIKE
00146 
00147     /*
00148     7.0b9 PBS: logic for drawing a custom icon.
00149     If the outline is an outline,
00150     and the headline has a refcon,
00151     and the refcon has a type attribute,
00152     and there's a file on disk [type.bmp],
00153     use that icon.
00154     */
00155 
00156     if ((**ho).outlinetype == outlineisoutline) { /*is this an outline?*/
00157 
00158         if (ophasrefcon (hnode)) { /*does it have a refcon?*/
00159         
00160             setemptystring (bsheadlinetype);
00161             
00162             if (opattributesgettypestring (hnode, bsheadlinetype)) { /*is there a type att?*/
00163 
00164                 /*Draw a custom icon. If it returns false, there was no custom icon.*/
00165 
00166                 flcustomicondrawn = opdrawheadiconcustom (bsheadlinetype, iconrect, false);
00167                 } /*if*/
00168             } /*if*/
00169         } /*if*/
00170 
00171 //#endif
00172 //  opdrawheadicon (iconnum, iconrect, flselected);
00173 
00174     if (!flcustomicondrawn) /*Draw a normal icon only if there was no custom icon.*/
00175 
00176         opdrawheadicon (iconnum, iconrect, false);
00177     
00178     /*
00179     if (flselected) {
00180         
00181         Rect r = *iconrect;
00182         
00183         insetrect (&r, 1, 1);
00184         
00185         invertrect (r);
00186         }
00187     */
00188     
00189     return (true);
00190     } /*opdefaultdrawicon*/
00191 
00192 
00193 boolean opdefaultgeticonrect (hdlheadrecord hnode, const Rect *linerect, Rect *iconrect) {
00194     
00195     hdloutlinerecord ho = outlinedata;
00196     Rect r;
00197     Rect rcontains = *linerect;
00198     
00199     rcontains.bottom = rcontains.top + (**ho).iconheight;
00200     
00201     rcontains.left += opnodeindent (hnode);
00202         
00203     rcontains.right = rcontains.left + (**ho).iconwidth;
00204     
00205     r = rcontains;
00206     
00207     if (opisfatheadlines (ho))
00208         rcontains.bottom = rcontains.top + textvertinset + (**ho).defaultlineheight + textvertinset;
00209     else
00210         rcontains.bottom = (*linerect).bottom;
00211     
00212     centerrect (&r, rcontains); /*center it vertically within the linerect*/
00213     
00214     *iconrect = r;
00215 
00216     return (true);
00217     } /*opdefaultgeticonrect*/
00218     
00219     
00220 void opgeticonrect (hdlheadrecord hnode, const Rect *linerect, Rect *iconrect) {
00221 
00222     (*(**outlinedata).geticonrectcallback) (hnode, linerect, iconrect);
00223     } /*opgeticonrect*/
00224     
00225     
00226 void opdrawarrowicon (hdlheadrecord hnode, long lnum, tydirection arrowdirection) {
00227     
00228     /*
00229     display an arrow as the icon for headline. used in dragging move. 
00230     
00231     send us "nodirection" if you want it restored to its normal icon.
00232     */
00233     
00234     Rect linerect, iconrect;
00235     short iconnum = 0;
00236     boolean flinverted, flselected;
00237     
00238     if (lnum < 0) /*defensive driving*/
00239         return;
00240     
00241     pushbackcolor (&(**outlinedata).backcolor);
00242     
00243     opgetlinerect (lnum, &linerect); 
00244     
00245     opgeticonrect (hnode, &linerect, &iconrect);
00246     
00247     opgetlineselected (hnode, &flinverted, &flselected);
00248     
00249     if (arrowdirection == nodirection) {
00250         
00251         operaserect (iconrect);
00252         
00253         (*(**outlinedata).drawiconcallback) (hnode, &iconrect, flselected, flinverted);
00254             
00255         goto exit;
00256         }
00257     
00258     switch (arrowdirection) {
00259         
00260         case up:
00261             iconnum = upicon; break;
00262             
00263         case down:
00264             iconnum = downicon; break;
00265             
00266         case left:
00267             iconnum = lefticon; break;
00268             
00269         case right:
00270             iconnum = righticon; break;
00271         
00272         default:
00273             /* do nothing*/
00274             break;
00275             
00276         } /*switch*/
00277         
00278     opdrawheadicon (iconnum, &iconrect, flselected);
00279 
00280     exit:
00281     
00282         popbackcolor ();
00283     
00284     } /*opdrawarrowicon*/
00285     
00286     
00287     
00288     
00289     
00290     
00291 

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