~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Frontier Kernel
Frontier/Common/source/claylinelayout.c

Version: ~ [ 10.0 ] ~

** Warning: Cannot open xref database.

1 2 /* $Id: claylinelayout.c,v 1.4 2005/01/11 22:48:05 andreradke Exp $ */ 3 4 /****************************************************************************** 5 6 UserLand Frontier(tm) -- High performance Web content management, 7 object database, system-level and Internet scripting environment, 8 including source code editing and debugging. 9 10 Copyright (C) 1992-2004 UserLand Software, Inc. 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 26 ******************************************************************************/ 27 28 #include "frontier.h" 29 #include "standard.h" 30 31 #include "font.h" 32 #include "icon.h" 33 #include "ops.h" 34 #include "quickdraw.h" 35 #include "strings.h" 36 #include "timedate.h" 37 #include "op.h" 38 #include "opdisplay.h" 39 #include "opicons.h" 40 #include "opinternal.h" 41 #include "langinternal.h" 42 #include "tableformats.h" 43 #include "tableinternal.h" 44 #include "tablestructure.h" 45 #include "claybrowser.h" 46 //#include "clayicons.h" 47 48 49 typedef struct tydisklinelayout { 50 51 short recordsize; 52 53 byte claydisplay; //if true, we're actually displaying in clay mode 54 55 byte realicons; /*if true, we go into the desktop db for icons, otherwise use generic ones*/ 56 57 byte filenamebold; /*if true, the file name is drawn in bold*/ 58 59 byte includeline2; /*if true we include the 2nd line of the display*/ 60 61 byte includedate; /*if true, we include the modification date*/ 62 63 byte includeframe; /*if true, each line has a frame, if false it's just like an outliner*/ 64 65 byte iconsize; /*full-size, small or very small icons*/ 66 67 RGBColor fillcolor, framecolor, cursorcolor, filenamecolor, othertextcolor; 68 69 RGBColor backcolor, statuscolor; 70 71 diskfontstring filenamefont, othertextfont; 72 73 short filenamefontsize, othertextfontsize; 74 } tydisklinelayout; 75 76 77 #define fldisplaydebug false 78 79 #define drawinset 4 80 81 #define spacebetweenlines 1 82 83 #define vertspacebetweenframes 5 84 85 #ifdef claydialoginclude 86 static hdlappwindow targetwindow = nil; 87 88 static hdlcard layoutcard = nil; 89 90 static void resetfilefontobjects (tylinelayout *); /*forward declaration*/ 91 #endif 92 93 94 #define disktomemcolor(rgb) do {disktomemshort (rgb.red); \ 95 disktomemshort (rgb.green); \ 96 disktomemshort (rgb.blue); } while (0) 97 98 #define memtodiskcolor(rgb) do {memtodiskshort (rgb.red); \ 99 memtodiskshort (rgb.green); \ 100 memtodiskshort (rgb.blue); } while (0) 101 102 #if 0 103 104 static boolean midcolorof (Rect r, RGBColor *rgb1, RGBColor *rgb2, RGBColor *rgbmid) { 105 106 #ifdef MACVERSION 107 GDHandle hgd; 108 109 *rgbmid = *rgb2; 110 111 hgd = GetMaxDevice (&r); 112 113 return (GetGray (hgd, rgb1, rgbmid)); 114 #endif 115 116 #ifdef WIN95VERSION 117 (*rgbmid).red = ((long) (*rgb1).red + (*rgb2).red) / 2; 118 (*rgbmid).green = ((long) (*rgb1).green + (*rgb2).green) / 2; 119 (*rgbmid).blue = ((long) (*rgb1).blue + (*rgb2).blue) / 2; 120 121 return (true); 122 #endif 123 } /*midcolorof*/ 124 125 126 static void lightcolorof (RGBColor *rgb) { 127 128 (*rgb).red += (65535 - (*rgb).red) / 3; 129 130 (*rgb).green += (65535 - (*rgb).green) / 3; 131 132 (*rgb).blue += (65535 - (*rgb).blue) / 3; 133 } /*lightcolorof*/ 134 135 #endif 136 137 138 static void darkcolorof (RGBColor *rgb) { 139 140 (*rgb).red -= (*rgb).red / 4; 141 142 (*rgb).green -= (*rgb).green / 4; 143 144 (*rgb).blue -= (*rgb).blue / 4; 145 } /*darkcolorof*/ 146 147 148 /*static boolean claypushtextstyle (diskfontstring fontname, short fontsize) { 149 150 bigstring bs; 151 short fontnum; 152 153 copystring (fontname, bs); 154 155 fontgetnumber (bs, &fontnum); 156 157 return (pushstyle (fontnum, fontsize, 0)); 158 } /%claypushtextstyle%/ 159 */ 160 161 162 void claysmashoutlinefields (hdlwindowinfo appwindow, hdltableformats hf) { 163 164 /* 165 bind the outline's font and size to the font/size from the 166 layout record. 167 168 10/14/93 DW: set outline backcolor too. 169 */ 170 171 hdloutlinerecord ho = (**hf).houtline; 172 173 if (ho != nil) { /*has an outline linked in*/ 174 175 //bigstring bs; 176 //short fontnum; 177 //copystring ((**hf).linelayout.filenamefont, bs); 178 //fontgetnumber (bs, &fontnum); 179 //(**ho).fontnum = fontnum; 180 181 (**ho).fontnum = (**hf).linelayout.filenamefont; 182 183 (**ho).fontsize = (**hf).linelayout.filenamefontsize; 184 185 (**ho).backcolor = (**hf).linelayout.backcolor; 186 187 oppoststylechange (); 188 189 //(**appwindow).backcolor = (**hf).linelayout.backcolor; 190 } 191 } /*claysmashoutlinefields*/ 192 193 194 static void smashlayoutfields (hdltableformats hf) { 195 196 /* 197 bind the layout's font and size to the font/size from the 198 outline record. 199 200 10/14/93 DW: set outline backcolor too. 201 202 10/9/5 DW: Yuck! Made a mistake -- instead of "ho" it was 203 "outlinedata". Skanky hard to trace in debugger. Gotcha! 204 */ 205 206 hdloutlinerecord ho = (**hf).houtline; 207 208 /* 209 bigstring bs; 210 211 fontgetname ((**ho).fontnum, bs); 212 213 copystring (bs, (**hf).linelayout.filenamefont); 214 */ 215 216 (**hf).linelayout.filenamefont = (**ho).fontnum; 217 218 (**hf).linelayout.filenamefontsize = (**ho).fontsize; 219 220 (**hf).linelayout.backcolor = (**ho).backcolor; 221 } /*smashlayoutfields*/ 222 223 224 static void setcomputedfields (hdltableformats hf) { 225 226 hdloutlinerecord ho = (**hf).houtline; 227 228 smashlayoutfields (hf); /*make the layout agree with the outline*/ 229 230 #ifdef claydialoginclude 231 if (layoutcard != nil) { /*the card is open*/ 232 233 tylinelayout layout = (**hf).linelayout; 234 235 #ifdef claydialoginclude 236 resetfilefontobjects (&layout); 237 #endif 238 } 239 #endif 240 241 switch ((**hf).linelayout.iconsize) { 242 243 case fullsizeicon: 244 (**ho).iconwidth = 32; 245 246 (**ho).iconheight = 32; 247 248 break; 249 250 case smallsizeicon: 251 (**ho).iconwidth = 16; 252 253 (**ho).iconheight = 16; 254 255 break; 256 257 case verysmallsizeicon: 258 (**ho).iconwidth = 12; 259 260 (**ho).iconheight = 12; 261 262 break; 263 } /*switch*/ 264 265 (**ho).lineindent = (**ho).iconwidth + drawinset; 266 267 /*compute display info for file names*/ { 268 269 short style = 0; 270 271 if ((**hf).linelayout.filenamebold) 272 style = bold; 273 274 pushstyle ((**outlinedata).fontnum, (**outlinedata).fontsize, style); 275 276 (**hf).computedlineinfo.filenamelineheight = globalfontinfo.ascent + globalfontinfo.descent; 277 278 #ifdef MACVERSION 279 (**hf).computedlineinfo.filenamewidth = (globalfontinfo.widMax * 31) / 2; 280 #endif 281 #ifdef WIN95VERSION 282 (**hf).computedlineinfo.filenamewidth = stringpixels ("\x02" "Wi") * 16; 283 #endif 284 285 popstyle (); 286 } 287 288 /*compute display info for other text*/ { 289 290 pushstyle ((**hf).linelayout.othertextfont, (**hf).linelayout.othertextfontsize, normal); 291 292 (**hf).computedlineinfo.othertextlineheight = globalfontinfo.ascent + globalfontinfo.descent; 293 294 (**hf).computedlineinfo.datewidth = stringpixels ("\x08" "11:59 AM"); 295 296 (**hf).computedlineinfo.datewidth += (**hf).computedlineinfo.datewidth / 3; 297 298 popstyle (); 299 } 300 } /*setcomputedfields*/ 301 302 303 void claybrowserinitdraw (void) { 304 305 setcomputedfields (tableformatsdata); 306 } /*claybrowserinitdraw*/ 307 308 309 static boolean hasframe (void) { 310 311 hdltableformats hf = tableformatsdata; 312 313 return ((**hf).linelayout.includeframe); 314 } /*hasframe*/ 315 316 317 static short getframeheight (void) { 318 319 hdltableformats hf = tableformatsdata; 320 short height, minheight; 321 322 height = (**outlinedata).iconheight; 323 324 if (hasframe ()) 325 height += (2 * drawinset); 326 else 327 height += drawinset; /*a little extra space between lines*/ 328 329 minheight = (**hf).computedlineinfo.filenamelineheight; 330 331 if ((**hf).linelayout.includeline2) { 332 333 minheight += (**hf).computedlineinfo.othertextlineheight + spacebetweenlines; 334 335 minheight += (2 * drawinset); 336 } 337 338 if (height < minheight) 339 height = minheight; 340 341 return (height); 342 } /*getframeheight*/ 343 344 345 static short getframewidth (void) { 346 347 hdltableformats hf = tableformatsdata; 348 short width; 349 350 width = drawinset + (**outlinedata).iconwidth + (2 * drawinset) + 351 352 (**hf).computedlineinfo.filenamewidth; 353 354 if ((**hf).linelayout.includedate) 355 width += (**hf).computedlineinfo.datewidth; 356 357 return (width); 358 } /*getframewidth*/ 359 360 361 static boolean simpleoutlinerdisplay (void) { /*DW 4/7/95*/ 362 363 hdltableformats hf = tableformatsdata; 364 tylinelayout lo = (**hf).linelayout; 365 366 if ((!lo.includeline2) && (!lo.includedate) && (!lo.includeframe)) 367 return (true); 368 369 return (false); 370 } /*simpleoutlinerdisplay*/ 371 372 373 boolean claygettextrect (hdlheadrecord hnode, const Rect *linerect, Rect *textrect) { 374 375 hdltableformats hf = tableformatsdata; 376 Rect r; 377 378 r.left = (*linerect).left + opnodeindent (hnode) + drawinset + (**outlinedata).iconwidth + drawinset; 379 380 if (simpleoutlinerdisplay ()) 381 r.right = (*linerect).right - texthorizinset; 382 else { 383 if (hasframe ()) /*it looks better with a little more space separating the icon and the name*/ 384 r.left += drawinset; 385 386 r.right = r.left + (**hf).computedlineinfo.filenamewidth; 387 } 388 389 r.top = (*linerect).top; 390 391 r.bottom = r.top + (**hf).computedlineinfo.filenamelineheight; 392 393 /*center the text vertically*/ { 394 395 short dv; 396 397 if ((**hf).linelayout.includeline2) { 398 399 short combinedlineheight = (**hf).computedlineinfo.filenamelineheight + (**hf).computedlineinfo.othertextlineheight; 400 401 dv = (getframeheight () - combinedlineheight - spacebetweenlines); 402 } 403 else 404 dv = (getframeheight () - (**hf).computedlineinfo.filenamelineheight); 405 406 dv /= 2; 407 408 if ((dv % 2) == 1) /*prefer to add extra pixel at top, not bottom*/ 409 dv++; 410 411 if (dv > 0) 412 offsetrect (&r, 0, dv); 413 } 414 415 *textrect = r; 416 417 return (true); 418 } /*claygettextrect*/ 419 420 421 boolean claygetedittextrect (hdlheadrecord hnode, const Rect *linerect, Rect *textrect) { 422 423 //claypushnodestyle (hnode); 424 425 claygettextrect (hnode, linerect, textrect); 426 427 //popstyle (); 428 429 return (true); 430 } /*claygetedittextrect*/ 431 432 433 boolean claygeticonrect (hdlheadrecord hnode, const Rect *linerect, Rect *iconrect) { 434 435 Rect r; 436 437 r.left = (*linerect).left + opnodeindent (hnode); 438 439 r.right = r.left + (**outlinedata).iconwidth; 440 441 r.top = (*linerect).top; 442 443 r.bottom = r.top + (**outlinedata).iconheight; 444 445 if (hasframe ()) 446 offsetrect (&r, drawinset, drawinset); 447 else { 448 Rect rcontains = *linerect; 449 450 rcontains.left = r.left; 451 452 rcontains.right = r.right; 453 454 centerrect (&r, rcontains); /*center it vertically*/ 455 } 456 457 *iconrect = r; 458 459 return (true); 460 } /*claygeticonrect*/ 461 462 463 boolean claypushnodestyle (hdlheadrecord hnode) { 464 465 hdltableformats hf = tableformatsdata; 466 tybrowserinfo info; 467 468 short style; 469 470 if ((**hf).linelayout.filenamebold) 471 style = bold; 472 else 473 style = 0; 474 475 browsergetrefcon (hnode, &info); 476 477 #if filebrowser 478 if (info.flalias) 479 style += italic; 480 #endif 481 482 if ((**hnode).flnodeunderlined) 483 style += underline; 484 485 pushstyle ((**outlinedata).fontnum, (**outlinedata).fontsize, style); 486 487 return (true); 488 } /*claypushnodestyle*/ 489 490 491 boolean claygetlineheight (hdlheadrecord hnode, short *lh) { 492 493 *lh = getframeheight (); 494 495 if (hasframe ()) 496 *lh += vertspacebetweenframes; 497 498 return (true); 499 } /*claygetlineheight*/ 500 501 502 boolean claygetlinewidth (hdlheadrecord hnode, short *lw) { 503 504 //claypushnodestyle (hnode); 505 506 boolean fl = opdefaultgetlinewidth (hnode, lw); 507 508 //popstyle (); 509 510 return (fl); 511 } /*claygetlinewidth*/ 512 513 514 boolean claygetnodeframe (hdlheadrecord hnode, Rect *r) { 515 516 (*r).left += opnodeindent (hnode); 517 518 if (simpleoutlinerdisplay ()) { 519 520 short lw; 521 522 claygetlinewidth (hnode, &lw); 523 524 (*r).right = (*r).left + drawinset + (**outlinedata).iconwidth + drawinset + lw; 525 } 526 else 527 (*r).right = (*r).left + getframewidth (); 528 529 (*r).bottom = (*r).top + getframeheight (); 530 531 return (true); 532 } /*claygetnodeframe*/ 533 534 535 static void getfatdatestring (long modtime, bigstring bs) { 536 537 /* 538 actually we get a very slim date string. 539 */ 540 541 timetodatestring (modtime, bs, false); /*9/8/93*/ 542 } /*getfatdatestring*/ 543 544 545 static void getfattimestring (long modtime, bigstring bs) { 546 547 /* 548 actually we get a very slim time string. 549 */ 550 551 timetotimestring (modtime, bs, false); /*9/8/93*/ 552 } /*getfattimestring*/ 553 554 555 #if 0 556 557 static void getfatsizestring (tybrowserinfo *browserinfo, bigstring bs) { 558 559 setemptystring (bs); 560 561 if ((*browserinfo).flfolder) { 562 563 short ctfiles = (*browserinfo).filesize; 564 565 shorttostring (ctfiles, bs); 566 567 pushstring ("\x05" " item", bs); 568 569 if (ctfiles != 1) 570 pushchar ('s', bs); 571 572 return; 573 } 574 575 getsizestring ((*browserinfo).filesize, bs); 576 } /*getfatsizestring*/ 577 578 #endif 579 580 581 static Rect rfilename, rframe, rdate; 582 583 584 boolean claypredrawline (hdlheadrecord hnode, const Rect *linerect, boolean flselected, boolean flinverted) { 585 586 hdltableformats hf = tableformatsdata; 587 Rect r; 588 589 rframe = *linerect; 590 591 claygetnodeframe (hnode, &rframe); /*set global*/ 592 593 if (hasframe ()) { 594 595 /*erase the rect in the fill color or cursor color*/ { 596 597 if (flselected) 598 pushbackcolor (&(**hf).linelayout.cursorcolor); 599 else 600 pushbackcolor (&(**hf).linelayout.fillcolor); 601 602 r = rframe; 603 604 eraserect (r); 605 606 popbackcolor (); 607 } 608 609 /* 610 /%an experiment -- try to give the files "depth" or 3D indentation%/ { 611 612 /%top and left edges are framed in dark color%/ { 613 614 RGBColor rgb = (**hf).linelayout.backcolor; 615 616 darkcolorof (&rgb); 617 618 pushforecolor (&rgb); 619 620 r = rframe; 621 622 MoveTo (r.left, r.top); 623 624 LineTo (r.right, r.top); 625 626 MoveTo (r.left, r.top + 1); 627 628 LineTo (r.right - 1, r.top + 1); 629 630 MoveTo (r.left, r.top); 631 632 LineTo (r.left, r.bottom); 633 634 MoveTo (r.left + 1, r.top); 635 636 LineTo (r.left + 1, r.bottom - 1); 637 638 popforecolor (); 639 } 640 641 /%bottom and right edges are framed in light color%/ { 642 643 RGBColor rgb = (**hf).linelayout.backcolor; 644 645 lightcolorof (&rgb); 646 647 pushforecolor (&rgb); 648 649 r = rframe; 650 651 MoveTo (r.right, r.bottom); 652 653 LineTo (r.right, r.top + 1); 654 655 MoveTo (r.right - 1, r.bottom); 656 657 LineTo (r.right - 1, r.top + 2); 658 659 MoveTo (r.right, r.bottom); 660 661 LineTo (r.left + 1, r.bottom); 662 663 MoveTo (r.right, r.bottom - 1); 664 665 LineTo (r.left + 2, r.bottom - 1); 666 667 popforecolor (); 668 } 669 } 670 */ 671 672 /*draw the node's frame*/ { 673 674 r = rframe; 675 676 pushforecolor (&(**hf).linelayout.framecolor); 677 678 framerect (r); 679 680 popforecolor (); 681 } 682 683 /*drop shadow*/ { 684 685 RGBColor rgb = (**hf).linelayout.backcolor; 686 687 r = rframe; 688 689 darkcolorof (&rgb); 690 691 pushforecolor (&rgb); 692 693 dropshadowrect (r, 2, false); 694 695 popforecolor (); 696 } 697 698 /*anti-aliasing%/ { 699 700 RGBColor rgb; 701 702 r = rframe; 703 704 InsetRect (&r, 1, 1); 705 706 midcolorof (r, &(**hf).linelayout.fillcolor, &(**hf).linelayout.framecolor, &rgb); 707 708 pushforecolor (&rgb); 709 710 FrameRect (&r); 711 712 popforecolor (); 713 } 714 */ 715 } 716 717 return (true); 718 } /*claypredrawline*/ 719 720 721 static boolean claydrawtext (hdlheadrecord hnode, const Rect *rtext, boolean flselected, boolean flinverted) { 722 723 /* 724 the normal text drawing routine, used for script editor and 725 menu editor in Frontier. 726 */ 727 728 bigstring bshead; 729 730 if (opeditingtext (hnode)) { 731 732 opeditupdate (); 733 734 return (true); 735 } 736 737 getheadstring (hnode, bshead); 738 739 if (!hasframe ()) 740 ellipsize (bshead, (*rtext).right - (*rtext).left); 741 742 movepento ((*rtext).left, (*rtext).top + globalfontinfo.ascent); 743 744 if (!flselected) { 745 746 pendrawstring (bshead); 747 748 return (true); 749 } 750 751 /*special tweaked-up code for drawing the selected line*/ { 752 753 Rect rframe = *rtext; 754 755 rframe.right = rframe.left + stringpixels (bshead); 756 757 if (rframe.right > (*rtext).right) 758 rframe.right = (*rtext).right; 759 760 rframe.bottom = rframe.top + globalfontinfo.ascent + globalfontinfo.descent; 761 762 if (flinverted) { 763 764 Rect r = rframe; 765 766 insetrect (&r, -1, -1); 767 768 pushbackcolor (&blackcolor); 769 770 eraserect (r); 771 772 popbackcolor (); 773 774 pushforecolor (&whitecolor); 775 776 pendrawstring (bshead); 777 778 popforecolor (); 779 } 780 else 781 pendrawstring (bshead); 782 783 /*frame the cursor*/ { 784 785 insetrect (&rframe, -texthorizinset, -textvertinset); 786 787 grayframerect (rframe); 788 } 789 } 790 791 return (true); 792 } /*claydrawtext*/ 793 794 795 boolean claydrawline (hdlheadrecord hnode, const Rect *textrect, boolean flselected, boolean flinverted) { 796 797 hdltableformats hf = tableformatsdata; 798 RGBColor rgb = (**hf).linelayout.filenamecolor; 799 800 claypushnodestyle (hnode); 801 802 pushforecolor (&rgb); 803 804 claydrawtext (hnode, textrect, flselected, flinverted); 805 806 popforecolor (); 807 808 popstyle (); 809 810 return (true); 811 } /*claydrawline*/ 812 813 814 boolean claypostdrawline (hdlheadrecord hnode, const Rect *linerect, boolean flselected, boolean flinverted) { 815 816 /* 817 we draw everything but the icon and the filename, if we're in fatview mode. 818 819 9/26/94 DW: hack it up to display messages in the Trade Secrets BBS. 820 */ 821 822 hdltableformats hf = tableformatsdata; 823 bigstring bsname; 824 tybrowserinfo browserinfo; 825 unsigned long nodetime = 0; 826 hdlhashnode hhashnode; 827 828 pushforecolor (&(**hf).linelayout.othertextcolor); 829 830 pushstyle ((**hf).linelayout.othertextfont, (**hf).linelayout.othertextfontsize, normal); 831 832 browsergetrefcon (hnode, &browserinfo); 833 834 opgetheadstring (hnode, bsname); 835 836 claygettextrect (hnode, linerect, &rfilename); 837 838 if ((**hf).linelayout.includeline2) { /*draw the file kind/size string*/ 839 840 Rect r = rfilename; 841 bigstring bs, bstype; 842 tyvaluerecord val; 843 844 r.top = r.bottom + spacebetweenlines; 845 846 r.bottom = r.top + (**hf).computedlineinfo.othertextlineheight; 847 848 if (hashtablelookup (browserinfo.dirid, bsname, &val, &hhashnode)) { 849 850 tablegetcellstring (hnode, valuecolumn, bs, true); 851 852 if (val.valuetype == externalvaluetype) { 853 854 hashgettypestring (val, bstype); 855 856 pushstring ("\x02" ", ", bstype); 857 858 insertstring (bstype, bs); 859 } 860 861 ellipsize (bs, r.right - r.left); 862 863 movepento (r.left, r.top + globalfontinfo.ascent); 864 865 pendrawstring (bs); 866 } 867 } 868 869 nodetime = browserinfo.timemodified; 870 871 if ((**hf).linelayout.includedate && (nodetime != 0)) { /*draw the modification date string*/ 872 873 Rect r = rfilename; 874 bigstring bs; 875 876 r.right = rframe.right - drawinset; 877 878 r.left = r.right - (**hf).computedlineinfo.datewidth; 879 880 getfatdatestring (nodetime, bs); 881 882 ellipsize (bs, r.right - r.left); 883 884 movepento (r.right - stringpixels (bs), r.top + globalfontinfo.ascent); 885 886 pendrawstring (bs); 887 888 rdate = r; 889 } 890 891 if ((**hf).linelayout.includeline2 && (**hf).linelayout.includedate) { /*draw the mod time string*/ 892 893 Rect r = rdate; 894 bigstring bs; 895 896 r.top = r.bottom + spacebetweenlines; 897 898 r.bottom = r.top + (**hf).computedlineinfo.othertextlineheight; 899 900 getfattimestring (nodetime, bs); 901 902 ellipsize (bs, r.right - r.left); 903 904 movepento (r.right - stringpixels (bs), r.top + globalfontinfo.ascent); 905 906 pendrawstring (bs); 907 } 908 909 popstyle (); 910 911 popforecolor (); 912 913 return (true); 914 } /*claypostdrawline*/ 915 916 917 boolean claydrawnodeicon (hdlheadrecord hnode, const Rect *iconrect, boolean flselected, boolean flinverted) { 918 919 short iconnum; 920 short transform = 0; 921 922 iconnum = opgetheadicon (hnode); 923 924 if (flselected) 925 transform = 0x4000; 926 927 #ifdef MACVERSION 928 ploticonresource ((Rect *) iconrect, atVerticalCenter + atHorizontalCenter, transform, iconnum); 929 #endif 930 931 #ifdef WIN95VERSION 932 ploticonresource (iconrect, 0, transform, iconnum); 933 #endif 934 // opdrawheadicon (iconnum, iconrect, false); 935 936 /* 937 if (flselected) { 938 939 Rect r = *iconrect; 940 941 insetrect (&r, 1, 1); 942 943 invertrect (r); 944 } 945 */ 946 947 return (true); 948 } /*claydrawnodeicon*/ 949 950 951 void claysetlinelayout (hdlwindowinfo targetwindow, tylinelayout *newlayout) { 952 953 hdltableformats hf = (hdltableformats) (**targetwindow).hdata; 954 955 (**hf).linelayout = *newlayout; 956 957 claysmashoutlinefields (targetwindow, hf); 958 959 setcomputedfields (hf); 960 961 shellwindowinval (targetwindow); 962 963 (**targetwindow).selectioninfo.fldirty = true; /*force update of font/size submenus of the Edit menu*/ 964 965 #ifdef claydialoginclude 966 if ((layoutcard != nil) && ((**hf).houtline != nil)) { 967 968 currentcard = layoutcard; 969 970 copytodialog (); 971 } 972 #endif 973 } /*claysetlinelayout*/ 974 975 976 #ifdef claydialoginclude 977 978 static void initdialog (void) { 979 980 setcardpopupfrommenu ("\pfilefont", hdlfontmenu, 1); 981 982 setcardpopupfrommenu ("\potherfont", hdlfontmenu, 1); 983 } /*initdialog*/ 984 985 986 static void resetfilefontobjects (tylinelayout *layout) { 987 988 currentcard = layoutcard; 989 990 setfontsizepopup ("\pfilesize", (*layout).filenamefontsize); 991 992 setfontpopup ("\pfilefont", (*layout).filenamefont); 993 } /*resetfilefontobjects*/ 994 995 996 boolean claywindowuseslayout (hdlappwindow appwindow) { 997 998 hdltableformats hf; 999 1000 if (appwindow == nil) 1001 return (false); 1002 1003 hf = (hdltableformats) (**appwindow).appdata; 1004 1005 return ((**hf).fluseslinelayout); 1006 } /*claywindowuseslayout*/ 1007 1008 1009 static void copytodialog (void) { 1010 1011 tylinelayout layout; 1012 1013 if (!claywindowuseslayout (targetwindow)) { 1014 1015 enableallcardobjects (false); 1016 1017 return; 1018 } 1019 1020 layout = (**(hdltableformats) (**targetwindow).appdata).linelayout; 1021 1022 enableallcardobjects (true); /*also invals all objects*/ 1023 1024 setcardenable ("\preal", false); /*DW 10/19/95 -- wired off*/ 1025 1026 setcardenable ("\pgeneric", false); /*DW 10/19/95 -- wired off*/ 1027 1028 setcardflag ("\preal", layout.realicons); 1029 1030 setcardflag ("\pgeneric", !layout.realicons); 1031 1032 setcardflag ("\pfullsize", layout.iconsize == fullsizeicon); 1033 1034 setcardflag ("\psmall", layout.iconsize == smallsizeicon); 1035 1036 setcardflag ("\pverysmall", layout.iconsize == verysmallsizeicon); 1037 1038 setcardflag ("\pline2", layout.includeline2); 1039 1040 setcardflag ("\pdate", layout.includedate); 1041 1042 setcardflag ("\pbold", layout.filenamebold); 1043 1044 setcardflag ("\phasframe", layout.includeframe); 1045 1046 setcardcolorpopup ("\pfill", &layout.fillcolor); 1047 1048 setcardcolorpopup ("\pframe", &layout.framecolor); 1049 1050 setcardcolorpopup ("\pcursor", &layout.cursorcolor); 1051 1052 setcardcolorpopup ("\pfilecolor", &layout.filenamecolor); 1053 1054 setcardcolorpopup ("\pothercolor", &layout.othertextcolor); 1055 1056 setcardcolorpopup ("\pbackcolor", &layout.backcolor); 1057 1058 setcardcolorpopup ("\pstatuscolor", &layout.statuscolor); 1059 1060 resetfilefontobjects (&layout); 1061 1062 setfontsizepopup ("\pothersize", layout.othertextfontsize); 1063 1064 setfontpopup ("\potherfont", layout.othertextfont); 1065 } /*copytodialog*/ 1066 1067 1068 static void copyfromdialog (tylinelayout *layout) { 1069 1070 clearbytes (layout, longsizeof (tylinelayout)); 1071 1072 (*layout).realicons = getcardbit ("\preal"); 1073 1074 if (getcardbit ("\pfullsize")) 1075 (*layout).iconsize = fullsizeicon; 1076 1077 if (getcardbit ("\psmall")) 1078 (*layout).iconsize = smallsizeicon; 1079 1080 if (getcardbit ("\pverysmall")) 1081 (*layout).iconsize = verysmallsizeicon; 1082 1083 (*layout).includeline2 = getcardbit ("\pline2"); 1084 1085 (*layout).includedate = getcardbit ("\pdate"); 1086 1087 (*layout).filenamebold = getcardbit ("\pbold"); 1088 1089 (*layout).includeframe = getcardbit ("\phasframe"); 1090 1091 getcardcolorpopup ("\pfill", &(*layout).fillcolor); 1092 1093 getcardcolorpopup ("\pframe", &(*layout).framecolor); 1094 1095 getcardcolorpopup ("\pcursor", &(*layout).cursorcolor); 1096 1097 getcardcolorpopup ("\pfilecolor", &(*layout).filenamecolor); 1098 1099 getcardcolorpopup ("\pothercolor", &(*layout).othertextcolor); 1100 1101 getcardcolorpopup ("\pbackcolor", &(*layout).backcolor); 1102 1103 getcardcolorpopup ("\pstatuscolor", &(*layout).statuscolor); 1104 1105 (*layout).filenamefontsize = getfontsizepopup ("\pfilesize"); 1106 1107 (*layout).othertextfontsize = getfontsizepopup ("\pothersize"); 1108 1109 getfontpopup ("\pfilefont", (*layout).filenamefont); 1110 1111 getfontpopup ("\potherfont", (*layout).othertextfont); 1112 } /*copyfromdialog*/ 1113 1114 1115 static boolean gettargetwindow (void) { 1116 1117 /* 1118 return true if the target window was changed 1119 */ 1120 1121 hdlappwindow newtarget; 1122 1123 claygetfrontwindow (&newtarget); 1124 1125 if (newtarget != targetwindow) { 1126 1127 targetwindow = newtarget; 1128 1129 copytodialog (); 1130 1131 return (true); /*changed*/ 1132 } 1133 1134 return (false); /*didn't change*/ 1135 } /*gettargetwindow*/ 1136 1137 1138 static void linelayoutprefsfilter (EventRecord *ev) { 1139 1140 switch ((*ev).what) { 1141 1142 case iowaInitEvent: 1143 currentcard = (hdlcard) (*ev).message; 1144 1145 layoutcard = currentcard; 1146 1147 claygetfrontwindow (&targetwindow); 1148 1149 initdialog (); 1150 1151 copytodialog (); 1152 1153 break; 1154 1155 case activateEvt: 1156 if ((*ev).modifiers & activeFlag) { 1157 1158 currentcard = layoutcard; /*DW 4/11/95: added*/ 1159 1160 gettargetwindow (); 1161 } 1162 1163 break; 1164 1165 case iowaCloseEvent: 1166 currentcard = (hdlcard) (*ev).message; 1167 1168 appsavedialoginfo (137); /*remember window position*/ 1169 1170 layoutcard = nil; /*we always forget to do this!!! DW 9/13/93*/ 1171 1172 break; 1173 1174 case nullEvent: 1175 currentcard = layoutcard; 1176 1177 iowavalidate (true); /*DW 4/11/95: added*/ 1178 1179 if (gettargetwindow ()) /*target window changed, card already updated*/ 1180 break; 1181 1182 if (!claywindowuseslayout (targetwindow)) /*it's an outline or process window, for e.g.*/ 1183 break; 1184 1185 /*check for changes to card objects*/ { 1186 1187 if ((**currentcard).runmodechanges) { 1188 1189 tylinelayout newlayout; 1190 1191 copyfromdialog (&newlayout); 1192 1193 setappwindowmadechanges (targetwindow); 1194 1195 claysetlinelayout (targetwindow, &newlayout); 1196 1197 (**currentcard).runmodechanges = false; 1198 } 1199 1200 /* 1201 hdltableformats hf = (hdltableformats) (**targetwindow).appdata; 1202 tylinelayout oldlayout, newlayout; 1203 1204 oldlayout = (**hf).linelayout; 1205 1206 copyfromdialog (&newlayout); 1207 1208 if (!equalmemory (&newlayout, &oldlayout, longsizeof (oldlayout))) { 1209 1210 setappwindowmadechanges (targetwindow); 1211 1212 claysetlinelayout (&newlayout); 1213 } 1214 */ 1215 } 1216 1217 break; 1218 } /*switch*/ 1219 } /*linelayoutprefsfilter*/ 1220 1221 1222 void linelayoutprefsdialog (void) { 1223 1224 if (layoutcard == nil) 1225 appopencardresource (137, &linelayoutprefsfilter); 1226 else 1227 appcardtofront (layoutcard); 1228 } /*linelayoutprefsdialog*/ 1229 1230 1231 void linelayoutbeforeclosewindow (void) { 1232 1233 if (targetwindow == app.appwindow) 1234 targetwindow = nil; 1235 } /*linelayoutbeforeclosewindow*/ 1236 1237 #endif 1238 1239 static boolean hashlookupboolean (bigstring bslookup) { 1240 1241 /* 1242 look up a boolean value, defaulting to false if any errors occur 1243 */ 1244 1245 tyvaluerecord val; 1246 hdlhashnode hnode; 1247 1248 if (!hashlookup (bslookup, &val, &hnode)) 1249 return (false); 1250 1251 if (!copyvaluerecord (val, &val) || !coercetoboolean (&val)) 1252 return (false); 1253 1254 return (val.data.flvalue); 1255 } /*hashlookupboolean*/ 1256 1257 1258 static short hashlookupshort (bigstring bslookup, short defaultval) { 1259 1260 /* 1261 look up a short value, defaulting to defaultval if any errors occur 1262 */ 1263 1264 tyvaluerecord val; 1265 hdlhashnode hnode; 1266 1267 if (!hashlookup (bslookup, &val, &hnode)) 1268 return (defaultval); 1269 1270 if (!copyvaluerecord (val, &val) || !coercetoint (&val)) 1271 return (defaultval); 1272 1273 return (val.data.intvalue); 1274 } /*hashlookupshort*/ 1275 1276 1277 static RGBColor hashlookupcolor (bigstring bslookup, const RGBColor *defaultrgb) { 1278 1279 /* 1280 look up a rgb color value, defaulting to defaultrgb if any errors occur 1281 */ 1282 1283 tyvaluerecord val; 1284 hdlhashnode hnode; 1285 1286 if (!hashlookup (bslookup, &val, &hnode)) 1287 return (*defaultrgb); 1288 1289 if (!copyvaluerecord (val, &val) || !coercetorgb (&val)) 1290 return (*defaultrgb); 1291 1292 return (**val.data.rgbvalue); 1293 } /*hashlookupcolor*/ 1294 1295 1296 static boolean hashlookupstring (bigstring bslookup, bigstring bs) { 1297 1298 /* 1299 look up a font value, returning false if any errors occur 1300 */ 1301 1302 tyvaluerecord val; 1303 hdlhashnode hnode; 1304 1305 if (!hashlookup (bslookup, &val, &hnode)) 1306 return (false); 1307 1308 if (!copyvaluerecord (val, &val) || !coercetostring (&val)) 1309 return (false); 1310 1311 pullstringvalue (&val, bs); 1312 1313 return (true); 1314 } /*hashlookupstring*/ 1315 1316 1317 static boolean langassigncolorvalue (hdlhashtable ht, const bigstring bs, const RGBColor *color) { 1318 1319 /* 1320 could be useful... 1321 */ 1322 1323 tyvaluerecord val; 1324 1325 if (!newheapvalue ((void *) color, sizeof (*color), rgbvaluetype, &val)) 1326 return (false); 1327 1328 if (!hashtableassign (ht, bs, val)) { 1329 1330 disposevaluerecord (val, false); 1331 1332 return (false); 1333 } 1334 1335 exemptfromtmpstack (&val); 1336 1337 return (true); 1338 } /*langassignbooleanvalue*/ 1339 1340 1341 boolean claytabletolayout (hdlhashtable ht, tylinelayout *layout) { 1342 1343 bigstring bsfont; 1344 1345 clearbytes (layout, sizeof (tylinelayout)); // clears flinitted, everything else 1346 1347 pushhashtable (ht); 1348 1349 (*layout).claydisplay = hashlookupboolean (str_claydisplay); 1350 (*layout).realicons = hashlookupboolean (str_realicons); 1351 (*layout).filenamebold = hashlookupboolean (str_filenamebold); 1352 (*layout).includeline2 = hashlookupboolean (str_includeline2); 1353 (*layout).includedate = hashlookupboolean (str_includedate); 1354 (*layout).includeframe = hashlookupboolean (str_includeframe); 1355 1356 (*layout).fillcolor = hashlookupcolor (str_fillcolor, &whitecolor); 1357 (*layout).framecolor = hashlookupcolor (str_framecolor, &blackcolor); 1358 (*layout).cursorcolor = hashlookupcolor (str_cursorcolor, &blackcolor); 1359 (*layout).filenamecolor = hashlookupcolor (str_filenamecolor, &blackcolor); 1360 (*layout).othertextcolor = hashlookupcolor (str_othertextcolor, &blackcolor); 1361 (*layout).backcolor = hashlookupcolor (str_backcolor, &whitecolor); 1362 (*layout).statuscolor = hashlookupcolor (str_statuscolor, &blackcolor); 1363 1364 if (hashlookupstring (str_filenamefont, bsfont)) 1365 fontgetnumber (bsfont, &(*layout).filenamefont); 1366 else 1367 (*layout).filenamefont = config.defaultfont; 1368 1369 if (hashlookupstring (str_othertextfont, bsfont)) 1370 fontgetnumber (bsfont, &(*layout).othertextfont); 1371 else 1372 (*layout).othertextfont = config.defaultfont; 1373 1374 (*layout).iconsize = (tyiconsize) hashlookupshort (str_iconsize, 1); 1375 (*layout).filenamefontsize = hashlookupshort (str_filenamefontsize, 12); 1376 (*layout).othertextfontsize = hashlookupshort (str_othertextfontsize, 9); 1377 1378 pophashtable (); 1379 1380 (*layout).flinitted = true; 1381 1382 return (true); 1383 } /*claytabletolayout*/ 1384 1385 1386 boolean claylayouttotable (const tylinelayout *layout, hdlhashtable ht) { 1387 1388 bigstring bs; 1389 1390 if (!(*layout).flinitted) 1391 return (false); 1392 1393 langassignbooleanvalue (ht, str_claydisplay, (*layout).claydisplay); 1394 langassignbooleanvalue (ht, str_realicons, (*layout).realicons); 1395 langassignbooleanvalue (ht, str_filenamebold, (*layout).filenamebold); 1396 langassignbooleanvalue (ht, str_includeline2, (*layout).includeline2); 1397 langassignbooleanvalue (ht, str_includedate, (*layout).includedate); 1398 langassignbooleanvalue (ht, str_includeframe, (*layout).includeframe); 1399 1400 langassigncolorvalue (ht, str_fillcolor, &(*layout).fillcolor); 1401 langassigncolorvalue (ht, str_framecolor, &(*layout).framecolor); 1402 langassigncolorvalue (ht, str_cursorcolor, &(*layout).cursorcolor); 1403 langassigncolorvalue (ht, str_filenamecolor, &(*layout).filenamecolor); 1404 langassigncolorvalue (ht, str_othertextcolor, &(*layout).othertextcolor); 1405 langassigncolorvalue (ht, str_backcolor, &(*layout).backcolor); 1406 langassigncolorvalue (ht, str_statuscolor, &(*layout).statuscolor); 1407 1408 fontgetname ((*layout).filenamefont, bs); 1409 langassignstringvalue (ht, str_filenamefont, bs); 1410 1411 fontgetname ((*layout).othertextfont, bs); 1412 langassignstringvalue (ht, str_othertextfont, bs); 1413 1414 langassignlongvalue (ht, str_iconsize, (*layout).iconsize); 1415 langassignlongvalue (ht, str_filenamefontsize, (*layout).filenamefontsize); 1416 langassignlongvalue (ht, str_othertextfontsize, (*layout).othertextfontsize); 1417 1418 return (true); 1419 } /*claylayouttotable*/ 1420 1421 1422 boolean clayinitlinelayout (tylinelayout *layout) { 1423 1424 hdlhashtable hprefs; 1425 1426 if (!langfastaddresstotable (roottable, "\x17" "user.prefs.tableDisplay", &hprefs)) 1427 return (false); 1428 1429 return (claytabletolayout (hprefs, layout)); 1430 } /*clayinitlinelayout*/ 1431 1432 1433 boolean claypacklinelayout (Handle hpacked) { 1434 1435 tylinelayout layout = (**tableformatsdata).linelayout; 1436 tydisklinelayout info; 1437 1438 info.recordsize = sizeof (info); 1439 1440 info.claydisplay = (byte) layout.claydisplay; 1441 1442 info.realicons = (byte) layout.realicons; 1443 1444 info.filenamebold = (byte) layout.filenamebold; 1445 1446 info.includeline2 = (byte) layout.includeline2; 1447 1448 info.includedate = (byte) layout.includedate; 1449 1450 info.includeframe = (byte) layout.includeframe; 1451 1452 info.iconsize = (byte) layout.iconsize; 1453 1454 info.fillcolor = layout.fillcolor; 1455 1456 info.framecolor = layout.framecolor; 1457 1458 info.cursorcolor = layout.cursorcolor; 1459 1460 info.filenamecolor = layout.filenamecolor; 1461 1462 info.othertextcolor = layout.othertextcolor; 1463 1464 info.backcolor = layout.backcolor; 1465 1466 info.statuscolor = layout.statuscolor; 1467 1468 fontgetname (layout.filenamefont, info.filenamefont); 1469 1470 fontgetname (layout.othertextfont, info.othertextfont); 1471 1472 info.filenamefontsize = layout.filenamefontsize; 1473 1474 info.othertextfontsize = layout.othertextfontsize; 1475 1476 memtodiskshort (info.recordsize); 1477 1478 memtodiskcolor (info.fillcolor); 1479 memtodiskcolor (info.framecolor); 1480 memtodiskcolor (info.cursorcolor); 1481 memtodiskcolor (info.filenamecolor); 1482 memtodiskcolor (info.othertextcolor); 1483 memtodiskcolor (info.backcolor); 1484 memtodiskcolor (info.statuscolor); 1485 1486 memtodiskshort (info.filenamefontsize); 1487 memtodiskshort (info.othertextfontsize); 1488 1489 return (enlargehandle (hpacked, sizeof (info), &info)); 1490 } /*claypacklinelayout*/ 1491 1492 1493 boolean clayunpacklinelayout (Handle hpacked, long *ixhandle, hdltableformats hf) { 1494 1495 /* 1496 2002-11-11 AR: Added assert to make sure the C compiler chose the 1497 proper byte alignment for the tydisklinelayout struct. If it did not, 1498 we would end up corrupting any database files we saved. 1499 */ 1500 1501 tylinelayout layout; 1502 tydisklinelayout info; 1503 1504 assert (sizeof(tydisklinelayout) == 124); /* one padding byte each after iconsize, filenamefont, and othertextfont */ 1505 1506 clearbytes (&info, sizeof (info)); 1507 1508 if (!loadfromhandle (hpacked, ixhandle, sizeof (info.recordsize), &info)) 1509 return (false); 1510 1511 disktomemshort (info.recordsize); 1512 1513 if (!loadfromhandle (hpacked, ixhandle, min (sizeof (info), info.recordsize) - sizeof (info.recordsize), &info.claydisplay)) 1514 return (false); 1515 1516 disktomemcolor (info.fillcolor); 1517 disktomemcolor (info.framecolor); 1518 disktomemcolor (info.cursorcolor); 1519 disktomemcolor (info.filenamecolor); 1520 disktomemcolor (info.othertextcolor); 1521 disktomemcolor (info.backcolor); 1522 disktomemcolor (info.statuscolor); 1523 1524 disktomemshort (info.filenamefontsize); 1525 disktomemshort (info.othertextfontsize); 1526 1527 layout.flinitted = true; 1528 1529 layout.claydisplay = (boolean) info.claydisplay; 1530 1531 layout.realicons = (boolean) info.realicons; 1532 1533 layout.filenamebold = (boolean) info.filenamebold; 1534 1535 layout.includeline2 = (boolean) info.includeline2; 1536 1537 layout.includedate = (boolean) info.includedate; 1538 1539 layout.includeframe = (boolean) info.includeframe; 1540 1541 layout.iconsize = (tyiconsize) info.iconsize; 1542 1543 layout.fillcolor = info.fillcolor; 1544 1545 layout.framecolor = info.framecolor; 1546 1547 layout.cursorcolor = info.cursorcolor; 1548 1549 layout.filenamecolor = info.filenamecolor; 1550 1551 layout.othertextcolor = info.othertextcolor; 1552 1553 layout.backcolor = info.backcolor; 1554 1555 layout.statuscolor = info.statuscolor; 1556 1557 fontgetnumber (info.filenamefont, &layout.filenamefont); 1558 1559 fontgetnumber (info.othertextfont, &layout.othertextfont); 1560 1561 layout.filenamefontsize = info.filenamefontsize; 1562 1563 layout.othertextfontsize = info.othertextfontsize; 1564 1565 (**hf).linelayout = layout; 1566 1567 return (true); 1568 } /*clayunpacklineinfo*/ 1569 1570 1571 1572

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.