tabledisplay.c

Go to the documentation of this file.
00001 
00002 /*  $Id: tabledisplay.c 1311 2006-04-19 08:28:14Z 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 "bitmaps.h"
00032 #include "cursor.h"
00033 #include "kb.h"
00034 #include "file.h"
00035 #include "font.h"
00036 #include "icon.h"
00037 #include "mouse.h"
00038 #include "ops.h"
00039 #include "quickdraw.h"
00040 #include "resources.h"
00041 #include "strings.h"
00042 #include "shell.h"
00043 #include "shellhooks.h"
00044 #include "shell.rsrc.h"
00045 #include "op.h"
00046 #include "opdisplay.h"
00047 #include "opicons.h"
00048 #include "oplineheight.h"
00049 #include "tableformats.h"
00050 #include "tableinternal.h"
00051 #include "wpengine.h"
00052 #include "tabledisplay.h"
00053 #include "claybrowserstruc.h"
00054 #include "claycallbacks.h"
00055 #include "claylinelayout.h"
00056 
00057 
00058 
00059 #define fldisplaydebug false
00060 
00061 #define mincolwidth 10
00062 #define minrowheight 10
00063 
00064 #define maxcolwidth 1000
00065 #define maxrowheight 1000
00066 
00067 #define pixelsbetweencolumns 15
00068 #define binarycharacterstomeasure 30
00069 
00070 #define drawinset 4
00071 
00072 
00073 static short opnodeindentpix (hdlheadrecord hnode) {
00074 
00075     return ((**outlinedata).lineindent * (**hnode).headlevel);
00076     } /*opnodeindentpix*/
00077 
00078 
00079 static short opiconindentpix (void) {
00080 
00081     return ((**outlinedata).iconwidth + (**outlinedata).pixelsaftericon);
00082     } /*opiconindentpix*/
00083 
00084 
00085 /*
00086 boolean tabledrawnodeicon (const Rect *r, boolean flhighlighted, hdlheadrecord hnode) {
00087     
00088     hdltableformats hc = tableformatsdata;
00089     tybrowserinfo browserinfo;  
00090     short transform;
00091     long align;
00092     
00093     transform = 0;
00094     
00095     if (flhighlighted)
00096         transform = 0x4000; 
00097             
00098     align = atVerticalCenter + atHorizontalCenter;
00099     
00100     browsergetrefcon (hnode, &browserinfo);
00101     
00102     ploticonresource (r, align, transform, opgetheadicon (hnode));
00103     
00104 #if 0
00105     transform += ttLabel [browserinfo.ixlabel]; // color it according to the file's label
00106     
00107     getgenericsystemicon (&browserinfo, &iconresnum);
00108     
00109     ploticonresource (&r, align, transform, iconresnum);
00110 #endif
00111     } /%tabledrawnodeicon%/
00112 */
00113 
00114 static void tableprepfordraw (Rect *r) {
00115     
00116     /*
00117     magic incantations that prepare for a callback to draw the text of a cell
00118     or a column title, or perhaps someday -- something else.
00119     */
00120     
00121     register short h, v;
00122     
00123     /*
00124     if ((**tableformatsdata).flgridlines) { // leave the gridlines out of the rect
00125         
00126         (*r).top++;
00127         
00128         (*r).left++;
00129         }
00130     */
00131     
00132     // display looks prettier if we leave a little whitespace
00133     
00134     h = (*r).left + texthorizinset; //pen position is independent of clipping
00135     
00136     v = (*r).top + globalfontinfo.ascent;
00137     
00138     movepento (h, v); /*position the pen for the callback routine*/
00139     } /*tableprepfordraw*/
00140 
00141 
00142 static void tablesetcolumnbounds (Rect *r, short col) {
00143     
00144     (*r).left += tablesumcolwidths (0, col);
00145     
00146     (*r).right = (*r).left + tablegetcolwidth (col);
00147     } /*tablesetcolumnbounds*/
00148 
00149     
00150 static void tablegettitlerect (short col, Rect *rtitle) {
00151     
00152     /*
00153     return the display rectangle of the title of the indicated column.  
00154     */
00155     
00156     register hdltableformats hf = tableformatsdata;
00157     
00158     *rtitle = (**hf).titlerect;
00159     
00160     tablesetcolumnbounds (rtitle, col);
00161     } /*tablegettitlerect*/
00162 
00163 
00164 static void tabledisplaytitle (short col, boolean flbitmap) {
00165     
00166     hdlhashtable ht;
00167     bigstring bs;
00168     Rect r;
00169     short fontstyle = bold;
00170     
00171     if (col == (**tableformatsdata).sorttitlecol)
00172         fontstyle |= underline;
00173     
00174     pushstyle ((**outlinedata).fontnum, (**outlinedata).fontsize, fontstyle);
00175     
00176     tablegetcursorinfo (&ht, bs, nil, nil);
00177     
00178     tablegettitlerect (col, &r); /*set left and right*/
00179     
00180     tableprepfordraw (&r); /*inset the rect, move QuickDraw's pen*/
00181     
00182     // insetrect (&r, 1, 1);
00183     
00184     if (flbitmap)
00185         flbitmap = openbitmap (r, (WindowPtr) getport ());
00186     
00187     #if TARGET_API_MAC_CARBON == 1
00188     
00189         pushpen ();
00190                 
00191         setthemepen (kThemeBrushDialogBackgroundActive, r, true);
00192         
00193         paintrect (r);
00194         
00195         poppen ();
00196     
00197     #else
00198     
00199         eraserect (r);
00200         
00201     #endif
00202     
00203     tablegetstringlist (nametitlestring+col, bs);
00204     
00205     pendrawstring (bs);
00206     
00207     if (flbitmap)
00208         closebitmap ((WindowPtr) getport ());
00209     
00210     popstyle ();
00211     } /*tabledisplaytitle*/
00212     
00213     
00214 void tableupdatecoltitles (boolean flupdating) {
00215     
00216     hdltableformats hf = tableformatsdata;
00217     Rect titlerect;
00218     register short i;
00219     
00220     if (flupdating) {
00221         
00222         titlerect = (**hf).titlerect;
00223         
00224         if (!shellrectneedsupdate (&titlerect)) /*empty intersection, nothing to do*/
00225             return;
00226         }
00227     
00228     for (i = 0; i < (**hf).ctcols; i++) 
00229         tabledisplaytitle (i, false);
00230     } /*tableupdatecoltitles*/
00231 
00232 
00233 boolean tablechecksortorder (void) {
00234     
00235     hdltableformats hf = tableformatsdata;
00236     hdlhashtable ht;
00237     bigstring bs;
00238     
00239     if (tablegetcursorinfo (&ht, bs, nil, nil)) {
00240         
00241         if ((**ht).sortorder != (**hf).sorttitlecol) {
00242             
00243             (**hf).sorttitlecol = (**ht).sortorder;
00244             
00245             return (true);
00246             }
00247         }
00248     
00249     return (false);
00250     } /*tablechecksortorder*/
00251 
00252 /*
00253 static void tableupdateseparator (void) {
00254     
00255     /%
00256     we formalized the separator rect so we could easily experiment with different
00257     ideas for showing the boundary between the titles of a table display and
00258     the content of the table.
00259     %/
00260     
00261     Rect seprect;
00262     
00263     seprect = (**tableformatsdata).seprect;
00264     
00265     if (!shellrectneedsupdate (&seprect)) /%no intersection, nothing to do%/
00266         return;
00267     
00268     if ((**tableformatsdata).flprinting)
00269         return;
00270     
00271     eraserect (seprect);
00272     } /%tableupdateseparator%/
00273 */
00274 
00275 
00276 static void tableupdategridlines (void) {
00277     
00278     /*
00279     draw the gridlines for the table, restrict drawing to the indicated rect.
00280     */
00281     
00282     register hdltableformats hf = tableformatsdata;
00283     register hdloutlinerecord ho = outlinedata;
00284     short col;
00285     short h;
00286     Rect rtable;    
00287     
00288     rtable = (**ho).outlinerect;
00289     
00290     insetrect (&rtable, -1, -1); // expand for frame
00291 
00292     if (!shellrectneedsupdate (&rtable)) /*empty intersection, nothing to do*/
00293         return;
00294     
00295     pushpen (); /*gridlines are drawn in gray*/
00296     
00297     setgraypen ();
00298         
00299     pushbackcolor (&(**outlinedata).backcolor);
00300 
00301     frame3sides (rtable);
00302     
00303     #if TARGET_API_MAC_CARBON == 1 /*the frame3sides routine drew over the scroll bar.*/
00304     
00305         drawscrollbar ((**shellwindowinfo).vertscrollbar);
00306          
00307     #endif
00308     
00309     insetrect (&rtable, 1, 1); // back to original
00310 
00311     eraserect (rtable);
00312     
00313     popbackcolor ();
00314     
00315     h = rtable.left;
00316     
00317     for (col = namecolumn; col < kindcolumn; col++) { /*draw a vertical line*/
00318         
00319         h += (**hf).colwidths [col];
00320         
00321         movepento (h, rtable.top);
00322     
00323         pendrawline (h, rtable.bottom);     
00324         }
00325     
00326     poppen (); /*finished drawing the gridlines*/
00327     } /*tableupdategridlines*/
00328 
00329 
00330 void tableupdate (void) {
00331     
00332     hdltableformats hf = tableformatsdata;
00333     
00334     if (hf == NULL)
00335         return;
00336 
00337     if (outlinedata == NULL)
00338         return;
00339     
00340     if (!isclaydisplay (hf)) {
00341         
00342         #if !TARGET_API_MAC_CARBON
00343         
00344             tableupdatecoltitles (true);
00345         
00346         #endif
00347         
00348     //  tableupdateseparator ();
00349         
00350         tableupdategridlines ();
00351         
00352         #if TARGET_API_MAC_CARBON == 1
00353         
00354             tableupdatecoltitles (true);
00355             
00356         #endif
00357         }
00358     
00359     opupdate ();
00360 
00361     //tabledrawzoombutton (false);
00362     
00363     tableupdatekindpopup ();
00364     
00365     tableupdatesortpopup ();
00366     
00367     #if TARGET_API_MAC_CARBON == 1
00368     
00369         shelldrawwindowmessage (shellwindowinfo);
00370     
00371     #endif
00372     } /* tableupdate */
00373 
00374 
00375 static short tablewidth2cols (short width) {
00376     
00377     /*
00378     return the number of cols, starting with startcol, that are required to
00379     completely span width pixels
00380     */
00381     
00382     register short *pwidth;
00383     short col;
00384     hdltableformats hf = tableformatsdata;
00385     short ctcols = (**hf).ctcols;
00386     
00387     for (col = 0, pwidth = (**hf).colwidths;  (width > 0) && (col < ctcols);  ++col)
00388         width -= *pwidth++;
00389     
00390     return (col);
00391     } /*tablewidth2cols*/
00392 
00393 
00394 static void tablegetcellrect (hdlheadrecord hnode, const Rect *rrow, short col, Rect *rcell) {
00395     
00396     /*
00397     return the display rectangle of the indicated column.  
00398     */
00399     
00400     short optextindent = opnodeindentpix (hnode) + opiconindentpix ();
00401     
00402     /*start with the row rect, which is really the textrect*/
00403     
00404     *rcell = *rrow;
00405     
00406     /*calculate the horizontal coordinates of the cell*/
00407     
00408     (*rcell).left -= optextindent; // get back to linerect, but with text insets
00409     
00410     tablesetcolumnbounds (rcell, col);
00411     
00412     (*rcell).right -= texthorizinset;
00413     
00414     if (col == 0)
00415         (*rcell).left += optextindent;
00416     } /*tablegetcellrect*/
00417 
00418 
00419 static Rect titlerect;
00420 
00421 static void tableinverttitle (boolean flinrectnow) {
00422 #pragma unused (flinrectnow)
00423 
00424     invertrect (titlerect);
00425     } /*tableinverttitle*/
00426 
00427 
00428 boolean tabletitleclick (Point pt) {
00429     
00430     /*
00431     5.0.2b20 dmb: set style when measuring title text
00432     */
00433     
00434     hdltableformats hf = tableformatsdata;
00435     hdloutlinerecord ho = outlinedata;
00436     short dh;
00437     short col;
00438     bigstring bs;
00439     
00440     dh = pt.h - (**hf).titlerect.left;
00441     
00442     col = tablewidth2cols (dh + 1) - 1;
00443     
00444     tablegettitlerect (col, &titlerect); /*set left and right*/
00445     
00446     tablegettitlestring (col, bs);
00447     
00448 //  tablesettitlestyle (col);
00449     
00450     pushstyle ((**ho).fontnum, (**ho).fontsize, bold);
00451     
00452     titlerect.right = titlerect.left + stringpixels (bs) + 4;
00453     
00454     popstyle ();
00455     
00456     insetrect (&titlerect, 1, 1);
00457     
00458     if (pointinrect (pt, titlerect))
00459         if (trackicon (titlerect, &tableinverttitle)) {
00460             
00461             hdlhashtable ht;
00462             bigstring lbs;
00463             
00464             tablegetcursorinfo (&ht, lbs, nil, nil);
00465             
00466             tablesetsortorder (ht,  col);
00467             }
00468     
00469     return (true);
00470     } /*tabletitleclick*/
00471 
00472 
00473 boolean tablefindcolumnguide (Point pt, short *col) {
00474     
00475     register hdltableformats hf = tableformatsdata;
00476     short lastcol = (**hf).ctcols - 1;
00477     short h;
00478     short c;
00479 
00480     if (outlinedata == NULL)
00481         return (false);
00482 
00483     if (isclaydisplay (hf))
00484         return (false);
00485     
00486     h = (**outlinedata).outlinerect.left + 1;
00487 
00488     for (c = 0; c < lastcol; c++) {
00489         
00490         h += tablegetcolwidth (c);
00491         
00492         if (abs (pt.h - h) <= 2) {
00493             
00494             *col = c;
00495             
00496             return (true);
00497             }
00498         } /*for*/
00499         
00500     return (false); /*not pointing inside between columns*/
00501     } /*tablefindcell*/
00502     
00503     
00504 boolean tableadjustcolwidth (Point ptstart, short col) {
00505     
00506     /*
00507     5.0.2b20 dmb: get maxwidths before resize; set editbufferrect after resize
00508     */
00509     
00510     register hdltableformats hf = tableformatsdata;
00511     register short h;
00512     Rect rtable, rcell;
00513     Point pt;
00514     short linetop, linebottom, lineh;
00515     short lasth;
00516     short ctcolsafter;
00517     short minh, maxh;
00518     short diff, colwidth, newwidth, leftoverwidth;
00519     short ctcols = (**hf).ctcols;
00520     long width, height;
00521     
00522     tablegetoutlinesize (&width, &height); // recalcs max col widths
00523     
00524     rtable = (**outlinedata).outlinerect;
00525     
00526     linetop = rtable.top + 1;
00527     
00528     linebottom = rtable.bottom - 1;
00529     
00530     rcell = rtable;
00531     
00532     tablesetcolumnbounds (&rcell, col);
00533     
00534     lineh = rcell.right; /*when mouse moves, erase line at last h position*/
00535     
00536     minh = rcell.left + mincolwidth;
00537     
00538     ctcolsafter = (**hf).ctcols - col - 1;
00539     
00540     maxh = min (rcell.left + maxcolwidth, rtable.right - ctcolsafter * mincolwidth);
00541     
00542     h = lasth = ptstart.h;
00543     
00544     if (mousedoubleclick ()) { /*move column line to optimal width*/
00545         
00546         ptstart.h = rcell.right;
00547         
00548         if (col == 0)
00549             h = rcell.left + (**hf).maxwidths [col];
00550         
00551         else  // col == 1, but we'll size according to kind width
00552             h = rtable.right - (**hf).maxwidths [2];
00553         
00554         h = min (maxh, max (minh, h));
00555         }
00556     else while (mousestilldown () || shiftkeydown ()) { /*drag the column line*/
00557         
00558         getmousepoint (&pt);
00559         
00560         if (!pointinrect (pt, (**tableformatswindowinfo).contentrect))
00561             pt = ptstart; /*snap back*/
00562         
00563         h = pt.h; /*copy into register*/
00564         
00565         h = max (h, minh);
00566         
00567         h = min (h, maxh);
00568         
00569         if (h != lasth) {
00570             
00571             movepento (lineh, linetop); /*erase the last line*/
00572             
00573             graydrawline (lineh, linebottom);
00574             
00575             lineh += (h - lasth);
00576             
00577             movepento (lineh, linetop); /*show the new line*/
00578             
00579             graydrawline (lineh, linebottom);
00580             
00581             lasth = h;
00582             }
00583         } /*while*/
00584     
00585     diff = h - ptstart.h;
00586     
00587     if (diff == 0)
00588         return (false);
00589     
00590     // actually set the new width
00591     
00592     newwidth = rcell.right - rcell.left + diff;
00593     
00594     tablesetcolwidth (col, newwidth, true);
00595     
00596     for (++col; col < ctcols; ++col) {
00597         
00598         colwidth = tablegetcolwidth (col);
00599         
00600         leftoverwidth = tableavailwidth () - tablesumcolwidths (0, ctcols);
00601         
00602         tablesetcolwidth (col, colwidth + leftoverwidth, true);
00603         }
00604     
00605     eraserect ((**hf).titlerect);
00606     
00607     tableupdatecoltitles (false);
00608     
00609     opseteditbufferrect (); /*if in edit mode, adjust display area*/
00610     
00611     opsmashdisplay ();
00612     
00613     tabledirty ();
00614     
00615     return (true);
00616     } /*tableadjustcolwidth*/
00617 
00618 
00619 boolean tablegettextrect (hdlheadrecord hnode, const Rect *linerect, Rect *textrect) {
00620     
00621     hdltableformats hf = tableformatsdata;
00622     
00623     if (isclaydisplay (hf))
00624         return (claygettextrect (hnode, linerect, textrect));
00625     
00626     if (!opdefaultgettextrect (hnode, linerect, textrect))
00627         return (false);
00628     
00629     /*
00630     offsetrect (textrect, 0, -1);
00631     
00632     (*textrect).bottom++;
00633     */
00634     
00635     return (true);
00636     } /*tablegettextrect*/
00637 
00638 
00639 boolean tablegetedittextrect (hdlheadrecord hnode, const Rect *linerect, Rect *textrect) {
00640     
00641     hdltableformats hf = tableformatsdata;
00642     short col;
00643     
00644     if (isclaydisplay (hf))
00645         return (claygetedittextrect (hnode, linerect, textrect));
00646     
00647     if ((**hf).editnode == nil) // between edits, anticipating focus
00648         col = (**hf).focuscol;
00649     else                        // currently editing
00650         col = (**hf).editcol;
00651     
00652     tablegettextrect (hnode, linerect, textrect);
00653     
00654     tablegetcellrect (hnode, textrect, col, textrect);
00655     
00656     if (col > namecolumn)
00657         (*textrect).left += texthorizinset;
00658     
00659     (*textrect).top += textvertinset;
00660     
00661     return (true);
00662     } /*tablegetedittexrect*/
00663 
00664 
00665 boolean tablegeticonrect (hdlheadrecord hnode, const Rect *linerect, Rect *iconrect) {
00666     
00667     Rect r;
00668     Rect rcontains = *linerect;
00669     
00670     if (isclaydisplay (tableformatsdata))
00671         return (claygeticonrect (hnode, linerect, iconrect));
00672     
00673     r.left = (*linerect).left + opnodeindent (hnode);
00674     
00675     r.right = r.left + (**outlinedata).iconwidth;
00676     
00677     r.top = (*linerect).top;
00678     
00679     r.bottom = r.top + (**outlinedata).iconheight;
00680     
00681     rcontains.left = r.left;
00682     
00683     rcontains.right = r.right;
00684     
00685     centerrect (&r, rcontains); /*center it vertically*/
00686     
00687     *iconrect = r;
00688     
00689     return (true);
00690     } /*tablegeticonrect*/
00691     
00692 
00693 boolean tablepushnodestyle (hdlheadrecord hnode) {
00694     
00695     hdltableformats hf = tableformatsdata;
00696     tybrowserinfo info;
00697     short style;
00698     
00699     if (isclaydisplay (hf))
00700         return (claypushnodestyle (hnode));
00701     
00702     if (false) // (**hf).filenamebold)
00703         style = bold;
00704     else
00705         style = 0;
00706     
00707     browsergetrefcon (hnode, &info);
00708 
00709     /*
00710     if (info.flalias)       
00711         style += italic;
00712     */
00713     
00714     if ((**hnode).flnodeunderlined) 
00715         style += underline;
00716     
00717     pushstyle ((**outlinedata).fontnum, (**outlinedata).fontsize, style);
00718     
00719     return (true);
00720     } /*tablepushnodestyle*/
00721 
00722 
00723 boolean tablegetlineheight (hdlheadrecord hnode, short *lh) {
00724     
00725     if (isclaydisplay (tableformatsdata))
00726         return (claygetlineheight (hnode, lh));
00727     
00728     opdefaultgetlineheight (hnode, lh);
00729     
00730     --*lh;
00731     
00732     return (true);
00733     } /*tablegetlineheight*/
00734 
00735 
00736 boolean tablegetlinewidth (hdlheadrecord hnode, short *lw) {
00737     
00738     if (isclaydisplay (tableformatsdata))
00739         return (claygetlinewidth (hnode, lw));
00740     
00741     *lw = tabletotalcolwidths ();
00742 
00743     return (true);
00744     } /*tablegetlinewidth*/
00745     
00746 
00747 boolean tablegetcellstring (hdlheadrecord hnode, short col, bigstring bs, boolean fllimitbinaries) {
00748     
00749     /*
00750     1/8/91 dmb: push/pophashtable around call to hashvaltostrings, since 
00751     we can no longer assume that the root table is always set
00752 
00753     call hashgetvaluestring, _or_ hashgettype/size string; not hashvaltostrings
00754     
00755     5.0.2b3 dmb: user tablepush/popcontext; don't just push our table as a context
00756     */
00757     
00758     bigstring bstype, bssize;
00759     tyvaluerecord val;
00760     tybrowserspec fs;
00761     hdlhashnode hhashnode;
00762     
00763 //  tablegetstringlist (questionmarksstring, bs);
00764     
00765     if (col == namecolumn) {
00766         
00767         if (!opgetheadstring (hnode, bs))
00768             return (false);
00769         
00770         //omit xml prefix
00771         if ((stringlength (bs) > 5) && getstringcharacter (bs, 4) == chtab)
00772             deletestring (bs, 1, 5);
00773         else
00774             if ((stringlength (bs) > 9) && getstringcharacter (bs, 8) == chtab)
00775                 deletestring (bs, 1, 9);
00776         
00777         return (true);
00778         }
00779     
00780     if (!claygetfilespec (hnode, &fs))
00781         return (false);
00782     
00783     if (!claylookupvalue (&fs, &val, &hhashnode))
00784         return (false);
00785     
00786     if (col == valuecolumn)  {
00787         
00788         hdlhashtable ht = fs.parID;
00789         
00790         shellpusherrorhook ((errorhookcallback) &falsenoop);
00791         
00792         tablepushcontext (ht, val.valuetype); // pushhashtable (fs.parID);
00793         
00794         hashgetvaluestring (val, bs); /*accept error values on failure*/
00795         
00796         tablepopcontext (ht, val.valuetype); // pophashtable ();
00797         
00798         shellpoperrorhook ();
00799         
00800         if (fllimitbinaries && val.valuetype == binaryvaluetype)
00801             setstringlength (bs, min (stringlength (bs), binarycharacterstomeasure));
00802         
00803         return (true); /*with bs set to the value of the variable*/
00804         }
00805     
00806     hashgettypestring (val, bstype);
00807     
00808     hashgetsizestring (&val, bssize);
00809     
00810     if (stringlength (bssize) > 0) { /*non-trivial size, show it*/
00811         
00812         pushstring (BIGSTRING ("\x02" " ["), bstype);
00813         
00814         pushstring (bssize, bstype);
00815         
00816         pushchar (']', bstype);
00817         }
00818     
00819     copystring (bstype, bs);
00820     
00821     return (true);
00822     } /*tablegetcellstring*/
00823 
00824 
00825 static boolean tablegetmaxcolwidthvisit (hdlheadrecord hnode, short col) {
00826     
00827     bigstring bs;
00828     short pix;
00829     short *pmax;
00830     
00831     if (!tablegetcellstring (hnode, col, bs, true)) /*error*/
00832         return (false);
00833     
00834     pix = stringpixels (bs);
00835     
00836     if (col == namecolumn)
00837         pix += opnodeindentpix (hnode);
00838 
00839     pmax = (**tableformatsdata).maxwidths + col;
00840     
00841     *pmax = max (pix, *pmax);
00842     
00843     return (true);
00844     } /*tablegetmaxcolwidthvisit*/
00845     
00846 
00847 static boolean tablegetmaxwidthvisit (hdlheadrecord hnode, ptrvoid refcon) {
00848 #pragma unused (refcon)
00849 
00850     short col;
00851     
00852     if ((**hnode).flexpanded) {
00853         
00854         for (col = namecolumn; col <= kindcolumn; ++col)
00855             tablegetmaxcolwidthvisit (hnode, col);
00856         
00857         return (true);
00858         }
00859     
00860     return (true);
00861     } /*tablegetmaxwidthvisit*/
00862 
00863 
00864 boolean tablegetoutlinesize (long *width, long *height) {
00865     
00866     /*
00867     6.0a11 dmb: watch for nil outline
00868     */
00869 
00870     hdloutlinerecord ho = outlinedata;
00871     hdltableformats hf = tableformatsdata;
00872     short col;
00873     long totalwidth = 0;
00874     
00875     if (ho == nil) {
00876         
00877         *width = 0;
00878 
00879         *height = 0;
00880 
00881         return (false);
00882         }
00883 
00884     *height = (**ho).outlinerect.top - (**hf).wholerect.top; /*to the top of the table...*/
00885     
00886     *height += opsumalllineheights ();
00887     
00888     for (col = namecolumn; col <= kindcolumn; ++col)
00889         (**hf).maxwidths [col] = 0;
00890     
00891     oppushstyle (ho);
00892     
00893     opsiblingvisiter ((**outlinedata).hsummit, false, &tablegetmaxwidthvisit, nil);
00894     
00895     (**hf).maxwidths [namecolumn] += opiconindentpix ();
00896     
00897     for (col = namecolumn; col <= kindcolumn; ++col)
00898         totalwidth += ((**hf).maxwidths [col] += pixelsbetweencolumns);
00899     
00900     popstyle ();
00901     
00902 //  totalwidth += opiconindentpix ();
00903     
00904     *width = totalwidth;
00905     
00906     return (true);
00907     } /*tablegetoutlinesize*/
00908 
00909 
00910 boolean tabledefaultdrawcell (hdlheadrecord hnode, short col, const Rect *rcell) {
00911     
00912     register hdltableformats hf = tableformatsdata;
00913     bigstring bs;
00914     
00915     if (opeditingtext (hnode) && ((**hf).editnode == hnode) && ((**hf).editcol == col)) {
00916         
00917         opeditupdate ();
00918         
00919         return (true);
00920         }
00921     
00922     /*
00923     if (col == valuecolumn)
00924         pushbackcolor (&lightgraycolor);
00925     
00926     eraserect (*rcell);
00927     
00928     if (col == valuecolumn)
00929         popbackcolor ();
00930     */
00931     
00932     if (!tablegetcellstring (hnode, col, bs, false))
00933         return (false);
00934     
00935     ellipsize (bs, (*rcell).right - (*rcell).left);
00936     
00937     pendrawstring (bs);
00938     
00939     return (true);
00940     } /*tabledefaultdrawcell*/
00941 
00942 
00943 static void tabledrawcell (hdlheadrecord hnode, short col, const Rect *rtext, boolean flselected, boolean flinverted) {
00944     
00945     Rect rcell;
00946     //hdloutlinerecord ho = outlinedata;
00947     //boolean fltextmode = (**ho).fltextmode;
00948     
00949     /*
00950     if (col == namecolumn) {
00951     
00952         tablepushnodestyle (hnode);
00953         
00954         if ((**tableformatsdata).editcol != namecolumn)
00955             (**ho).fltextmode = false;
00956         
00957         tablegetcellrect (hnode, rtext, col, &rcell);
00958         
00959         pushclip (rcell);
00960         
00961         opdefaultdrawtext (hnode, rtext, false, flinverted);
00962         
00963         popclip ();
00964         
00965         (**ho).fltextmode = fltextmode;
00966         
00967         popstyle ();
00968         }
00969     else {
00970     */
00971         tablegetcellrect (hnode, rtext, col, &rcell);
00972         
00973         pushclip (rcell);
00974 
00975         rcell.top += textvertinset;
00976         
00977         if (col == namecolumn)
00978             rcell.left -= texthorizinset;
00979         
00980         tableprepfordraw (&rcell);
00981 
00982         tabledefaultdrawcell (hnode, col, &rcell);
00983 
00984         popclip ();
00985     /*
00986         }
00987     */
00988 
00989     if (flselected) {
00990         short optextindent = opnodeindentpix (hnode) + opiconindentpix ();
00991         
00992         rcell = *rtext;
00993         
00994         rcell.left -= optextindent; // get back to linerect, but with text insets
00995         
00996         rcell.top += textvertinset;
00997         
00998         rcell.bottom -= textvertinset - 1;
00999         
01000         tablesetcolumnbounds (&rcell, col);
01001         
01002         if (col == namecolumn)
01003             rcell.left += opnodeindentpix (hnode);
01004         
01005         rcell.right -= 3;
01006         
01007         if (flinverted)
01008             invertrect (rcell);
01009         else
01010             grayframerect (rcell);
01011         }
01012     } /*tabledrawcell*/ 
01013 
01014 
01015 boolean tablepredrawline (hdlheadrecord hnode, const Rect *linerect, boolean flselected, boolean flinverted) {
01016     
01017     short ctcols = (**tableformatsdata).ctcols;
01018     Rect colrect = *linerect;
01019     short col;
01020     
01021 //  pushbackcolor (&(**outlinedata).backcolor);
01022     
01023     if (isclaydisplay (tableformatsdata))
01024         claypredrawline (hnode, linerect, flselected, flinverted);
01025     else
01026     
01027     for (col = 0; col < ctcols; col++) {
01028         
01029         colrect = *linerect;
01030         
01031         tablesetcolumnbounds (&colrect, col);
01032         
01033         insetrect (&colrect, 1, 0);
01034         
01035         if (!(**outlinedata).flprinting)
01036             eraserect (colrect);
01037         }
01038     
01039     #ifdef tablehorizlines
01040         movepento ((*linerect).left, (*linerect).bottom - 1);
01041         graydrawline ((*linerect).right - 1, (*linerect).bottom - 1);
01042     #endif
01043     
01044 //  popbackcolor ();
01045     
01046     return (true);
01047     } /*tablepredrawline*/
01048 
01049 boolean tablepostdrawline (hdlheadrecord hnode, const Rect *linerect, boolean flselected, boolean flinverted) {
01050 
01051     if (isclaydisplay (tableformatsdata))
01052         return (claypostdrawline (hnode, linerect, flselected, flinverted));
01053     
01054     return (true);
01055     } /*tablepostdrawline*/
01056 
01057 
01058 boolean tabledrawline (hdlheadrecord hnode, const Rect *textrect, boolean flselected, boolean flinverted) {
01059     
01060     hdltableformats hf = tableformatsdata;
01061 //  RGBColor rgb = (**hf).filenamecolor;
01062 //  hdloutlinerecord ho = outlinedata;
01063     
01064 //  tablepushnodestyle (hnode);
01065     
01066 //  pushforecolor (&rgb);
01067     
01068     if (isclaydisplay (hf))
01069         claydrawline (hnode, textrect, flselected, flinverted);
01070     else {
01071         short col;
01072         
01073         for (col = 0; col < (**hf).ctcols; col++) 
01074             tabledrawcell (hnode, col, textrect, flselected, flinverted);
01075         }
01076     
01077 //  popforecolor ();
01078 
01079 //  popstyle ();
01080     
01081     return (true);
01082     } /*tabledrawline*/
01083 
01084 
01085 void browserdrawnodeicon (const Rect *r, boolean flhighlighted, hdlheadrecord hnode) {
01086     /*
01087      This function draws the triangle icons inside tables (but not outlines).
01088      Outline triangles are in opicons.c, opdrawheadicon()
01089      */
01090     tybrowserinfo browserinfo;
01091     browsergetrefcon (hnode, &browserinfo);
01092 
01093 #ifdef MACVERSION
01094     short transform = kTransformNone;
01095     
01096     if (flhighlighted)
01097         transform = kTransformSelected;
01098     
01099     ploticonresource (r, kAlignAbsoluteCenter, transform, opgetheadicon (hnode));
01100 #endif
01101     
01102 #ifdef WIN95VERSION
01103     ploticonresource (r, 0, 0, opgetheadicon (hnode));
01104 #endif
01105 
01106     
01107 #if 0
01108     transform += ttLabel [browserinfo.ixlabel]; /*color it according to the file's label*/
01109     
01110     getgenericsystemicon (&browserinfo, &iconresnum);
01111     
01112     ploticonresource (&r, align, transform, iconresnum);
01113 #endif
01114     } /*browserdrawnodeicon*/
01115 
01116 
01117 boolean tabledrawnodeicon (hdlheadrecord hnode, const Rect *iconrect, boolean flselected, boolean flinverted) {
01118     
01119     if (fldisplaydebug) {
01120     
01121         if (optionkeydown ())
01122             return (true);
01123         }
01124     
01125     if (isclaydisplay (tableformatsdata))
01126         return (claydrawnodeicon (hnode, iconrect, flselected, flinverted));
01127     
01128     browserdrawnodeicon (iconrect, flselected, hnode);
01129     
01130     return (true);
01131     } /*tabledrawnodeicon*/
01132 
01133 
01134 static short tablefindcolumn (hdlheadrecord hnode, Point pt, const Rect *textrect) {
01135     
01136     hdltableformats hf = tableformatsdata;
01137     short *pwidth;
01138     short leftedge;
01139     short col = 0;
01140     
01141     if (pt.h < (*textrect).left - textleftslop)
01142         return (-1);
01143     
01144     leftedge = (*textrect).left - opnodeindentpix (hnode) - opiconindentpix ();
01145     
01146     /*loop through range in width array, adding values*/
01147     
01148     for (col = 0, pwidth = (**hf).colwidths;  ;  ++col, ++pwidth) {
01149     
01150         leftedge += *pwidth;
01151         
01152         if (leftedge > pt.h)
01153             break;
01154         
01155         if (col == kindcolumn)
01156             break;
01157         }
01158     
01159     return (col);
01160     } /*tablefindcolumn*/
01161 
01162 
01163 boolean tableadjustcursor (hdlheadrecord hnode, Point pt, const Rect *textrect) {
01164     
01165     short col;
01166     tycursortype cursortype = cursorisarrow;
01167     hdlhashtable htable;
01168     bigstring bs;
01169     tyvaluerecord val;
01170     hdlhashnode hhashnode;
01171     
01172     col = tablefindcolumn (hnode, pt, textrect);
01173     
01174     switch (col) {
01175         
01176         case namecolumn:
01177             cursortype = cursorisibeam;
01178             break;
01179         
01180         case valuecolumn:
01181             if (tablegetiteminfo (hnode, &htable, bs, &val, &hhashnode) && (val.valuetype != externalvaluetype))
01182                 cursortype = cursorisibeam;
01183             
01184             break;
01185         
01186         case kindcolumn:
01187             break;
01188         }
01189     
01190     setcursortype (cursortype);
01191     
01192     return (true);
01193     } /*tableadjustcursor*/
01194 
01195 
01196 boolean tablemouseinline (hdlheadrecord hnode, Point pt, const Rect *textrect, boolean *flintext) {
01197     
01198     /*
01199     5.0d19 dmb: zoom item on value column 2click
01200     */
01201     
01202     hdltableformats hf = tableformatsdata;
01203     short col;
01204     hdlhashnode hhashnode;
01205     
01206     col = tablefindcolumn (hnode, pt, textrect);
01207     
01208     switch (col) {
01209         
01210         case namecolumn:
01211             break;
01212         
01213         case valuecolumn: {
01214             hdlhashtable htable;
01215             bigstring bs;
01216             tyvaluerecord val;
01217             
01218             if (tablegetiteminfo (hnode, &htable, bs, &val, &hhashnode) && (val.valuetype == externalvaluetype)) {
01219                 
01220                 *flintext = false;
01221 
01222                 if (mousedoubleclick ()) {
01223                     
01224                     tablezoomfromhead (hnode);
01225                     
01226                     setmousedoubleclickstatus (false);
01227                     
01228                     return (false);
01229                     }
01230 
01231                 return (true);
01232                 }
01233             
01234             break;
01235             }
01236         
01237         default:
01238             *flintext = false;
01239 
01240             return (true);
01241         }
01242     
01243     (**hf).focuscol = col;
01244     
01245     if (col != (**hf).editcol)
01246         (**outlinedata).flcursorneedsdisplay = true; /*make sure opmoveto does something*/
01247     
01248     *flintext = true;
01249 
01250     return (true);
01251     } /*tablemouseinline*/
01252 
01253 
01254 /*
01255 boolean tablereturnkey (tydirection dir) {
01256     
01257     hdloutlinerecord ho = outlinedata;
01258     hdlheadrecord hpre = (**ho).hbarcursor;
01259     tybrowserspec fspre;
01260     hdlhashtable htable;
01261     
01262     if (!claygetfilespec (hpre, fspre))
01263         return (false);
01264     
01265     if (dir == right)
01266         claygetdirid (&fspre, &htable);
01267     else
01268         htable = fspre.dirid;
01269     
01270     getparent
01271     return (opinsertheadline (emptystring, dir, flcomment));
01272     } /%tablereturnkey%/
01273 */
01274 
01275 boolean tableinitdisplay (void) {
01276     
01277     return (true);
01278     } /*tableinitdisplay*/
01279 
01280 
01281 
01282 

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