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

Frontier Kernel
Frontier/Common/source/browserverbs.c

Version: ~ [ 10.0 ] ~

** Warning: Cannot open xref database.

1 2 /* $Id: browserverbs.c,v 1.2 2005/01/11 22:48:04 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 29 #include <standard.h> 30 #include "memory.h" 31 #include "file.h" 32 #include "quickdraw.h" 33 #include "strings.h" 34 #include "kb.h" 35 #include "ops.h" 36 #include "popup.h" 37 #include "resources.h" 38 #include "scrollbar.h" 39 #include "search.h" 40 #include "windows.h" 41 #include "windowlayout.h" 42 #include "zoom.h" 43 44 #include "shell.h" 45 #include "shellhooks.h" 46 #include "shellundo.h" 47 #include "lang.h" 48 #include "langexternal.h" 49 #include "tableinternal.h" 50 #include "tablestructure.h" 51 #include "cancoon.h" 52 #include "opinternal.h" 53 #include "opverbs.h" 54 #include "claybrowser.h" 55 #include "claybrowserstruc.h" 56 //#include "browserverbs.h" 57 #include "kernelverbdefs.h" 58 59 60 61 #define browserstringlist 166 62 #define browsertypestring 1 63 #define browsersizestring 2 64 65 66 #define browsererrorlist 266 67 #define nobrowsererror 1 68 #define namenotbrowsererror 2 69 70 71 typedef enum tybrowsertoken { /*verbs that are processed by browserverbs.c*/ 72 73 zoomscriptfunc, 74 75 ctbrowserverbs 76 } tybrowsertoken; 77 78 79 WindowPtr browserwindow = nil; 80 81 hdlwindowinfo browserwindowinfo = nil; 82 83 hdlclaydata browserdata = nil; 84 85 86 87 static errornum = 0; /*error number exclusively for browser routines*/ 88 89 90 static boolean browsersetglobals (void) { 91 92 outlinedata = (**browserdata).houtline; 93 94 tableformatsdata = (**browserdata).hformats; 95 96 outlinewindow = browserwindow; 97 98 outlinewindowinfo = browserwindowinfo; 99 100 return (opeditsetglobals ()); 101 } /*browsersetglobals*/ 102 103 104 #define tabletopmargin 3 105 106 107 static boolean browserresetrects (hdlwindowinfo hw) { 108 109 register short scrollbarwidth; 110 register hdlclaydata hc = browserdata; 111 Rect rcontent; 112 Rect r; 113 Rect tablerect, seprect, titlerect, wholerect; 114 short msgheight; 115 hdltableformats hformats = tableformatsdata; 116 #define seprectheight 2 /*height of rectangle separating titles from table content*/ 117 118 rcontent = (**hw).contentrect; 119 120 /*set up some values for all rect computations*/ { 121 122 scrollbarwidth = getscrollbarwidth (); 123 124 msgheight = popupheight; 125 } 126 127 /*do info.growiconrect*/ { 128 129 shellcalcgrowiconrect (rcontent, hw); 130 } 131 132 /*do wholerect*/ { 133 134 r = rcontent; 135 136 r.top += tabletopmargin; /*three pixels between titles and top of window*/ 137 138 r.bottom -= msgheight + windowmargin; 139 140 r.left += windowmargin; 141 142 r.right -= windowmargin + iconrectwidth + windowmargin + scrollbarwidth; 143 144 wholerect = r; 145 } 146 147 tablerect = wholerect; 148 149 /*do titlerect, seprect*/ { 150 151 titlerect = tablerect; /*set top, left, right*/ 152 153 titlerect.bottom = titlerect.top + (**hc).computedlineinfo.filenamelineheight; 154 155 seprect = tablerect; /*set left, right*/ 156 157 seprect.top = titlerect.bottom; 158 159 seprect.bottom = seprect.top + seprectheight; 160 161 tablerect.top = seprect.bottom; 162 } 163 164 (**hc).wholerect = wholerect; 165 166 (**hc).tablerect = tablerect; 167 168 (**hc).titlerect = titlerect; 169 170 (**hc).seprect = seprect; 171 172 /*do kindpopuprect*/ { 173 174 r.left = tablerect.left + 3; /*flush with left edge of icons*/ 175 176 r.right = r.left + popupwidth; 177 178 r.top = tablerect.bottom + ((rcontent.bottom - tablerect.bottom - msgheight) / 2); 179 180 r.bottom = r.top + msgheight; 181 182 (**hc).kindpopuprect = r; 183 } 184 185 /*do sortpopuprect*/ { 186 187 r.left = r.right + popupbetweenwidth; 188 189 r.right = r.left + popupwidth; 190 191 (**hc).sortpopuprect = r; 192 } 193 194 /*do messagerect*/ { 195 196 r.left = r.right + popupbetweenwidth; 197 198 r.right = tablerect.right + scrollbarwidth; 199 200 (**hw).messagerect = r; 201 } 202 203 /*do iconrect*/ { 204 205 r.top = tablerect.top; 206 207 r.bottom = r.top + iconrectheight; 208 209 r.right = rcontent.right - windowmargin; 210 211 r.left = r.right - iconrectwidth; 212 213 insetrect (&r, -4, 0); /*a little extra width for title*/ 214 215 (**hc).iconrect = r; 216 } 217 218 /*do vertscrollbar*/ { 219 220 r = tablerect; /*the space occupied by the grid of cells*/ 221 222 r.left = r.right; /*scrollbar is just to right of grid*/ 223 224 r.right = r.left + scrollbarwidth; 225 226 // r.bottom = r.top + (**hformats).nonblankvertpixels; 227 228 setscrollbarrect ((**hw).vertscrollbar, r); 229 230 showscrollbar ((**hw).vertscrollbar); 231 } 232 233 return (true); 234 } /*browserresetrects*/ 235 236 237 static boolean browsergetcontentsize (long *width, long *height) { 238 239 short pixels; 240 241 claygetoutlinesize (width, height); 242 243 pixels = tabletopmargin + windowmargin + popupheight + 4; 244 245 *height += pixels; 246 247 pixels = windowmargin + windowmargin + iconrectwidth + windowmargin + getscrollbarwidth (); 248 249 *width += pixels; 250 251 return (true); 252 } /*browsergetcontentsize*/ 253 254 255 static void browserresize (void) { 256 257 Rect r; 258 259 r = (**browserdata).wholerect; 260 261 eraserect (r); 262 263 // tabledirty (); 264 265 r = (**browserdata).tablerect; 266 267 insetrect (&r, 1, 1); 268 269 opresize (r); 270 271 clayrecalccolwidths (true); /*re-distribute colwidths*/ 272 } /*browserresize*/ 273 274 275 static boolean browsersetfont (void) { 276 277 return (opsetfont ((**outlinewindowinfo).selectioninfo.fontnum)); 278 } /*browsersetfont*/ 279 280 281 static boolean browsersetsize (void) { 282 283 return (opsetsize ((**outlinewindowinfo).selectioninfo.fontsize)); 284 } /*browsersetsize*/ 285 286 287 static boolean browsergettargetdata (short id) { 288 289 /* 290 a verb is about to be executed that acts on the indicated external type, or 291 on any shell window if id == -1. 292 293 return true if we can handle verbs of that type and are able to set the 294 relevant globals 295 */ 296 297 switch (id) { 298 299 case -1: 300 return (true); 301 302 case idoutlineprocessor: 303 return (true); 304 305 case idwordprocessor: 306 return (opeditsetglobals ()); 307 308 default: 309 return (false); 310 } 311 } /*browsergettargetdata*/ 312 313 314 static boolean browserclose (void) { 315 316 register hdloutlinerecord ho = outlinedata; 317 318 // opverbcheckwindowrect (ho); 319 320 killundo (); /*must toss undos before they're stranded*/ 321 322 if ((**ho).fldirty) { /*we have to keep the in-memory version around*/ 323 324 (**ho).flwindowopen = false; 325 326 opcloseoutline (); /*prepare for dormancy, not in a window anymore*/ 327 } 328 329 return (true); 330 } /*browserclose*/ 331 332 333 static void browseridle (void) { 334 335 opidle (); 336 337 browsercommitchanges (); 338 } /*browsereventloopidle*/ 339 340 341 static boolean getsystemname (bigstring systemname) { // dmb 342 343 StringHandle h; 344 345 h = GetString (-16413); 346 347 if (ResError () != noErr) 348 return (false); 349 350 copyheapstring (h, systemname); 351 352 if (stringlength (systemname) == 0) 353 copystring ("\pUntitled System", systemname); 354 355 return (true); 356 } /*getsystemname*/ 357 358 359 static boolean browsernewwindow (void) { 360 361 hdlwindowinfo ha = browserwindowinfo; 362 hdlclaydata hc = nil; 363 hdloutlinerecord ho = nil; 364 Rect rzoom, rwindow; 365 hdlwindowinfo hparent; 366 hdltableformats hformats = nil; 367 tyfilespec fs; 368 369 if (!shellgetfrontrootinfo (&hparent)) /*our parent is the frontmost root window*/ 370 return (false); 371 372 rzoom.top = -1; /*zoom from default rect*/ 373 374 if (!newclearhandle (sizeof (tyclaydata), (Handle *) &hc)) 375 return (false); 376 377 browserdata = hc; 378 379 claydefaultlinelayout (&(**hc).linelayout); 380 381 ccgetwindowrect (ixbrowserinfo, &rwindow); 382 383 if (!newoutlinerecord (&ho)) 384 goto error; 385 386 (**hc).houtline = ho; 387 388 (**ho).outlinerefcon = (long) hc; 389 390 (**ho).flusebitmaps = false; 391 392 if (!browserinitrecord (hc)) 393 goto error; 394 395 if (!newtableformats (&hformats)) 396 goto error; 397 398 (**browserdata).hformats = hformats; 399 400 pushscratchport (); 401 402 // if (!tableunpackformats (hpackedformats, hformats)) { 403 404 tablesetdimension (hformats, false, 1, fixedctcols); 405 // } 406 407 popport (); 408 409 // if (ho != nil) 410 // getoutlinerect (&(**ho).outlinerect); /*allow callback to change statuspixels, perhaps other window measures*/ 411 412 shellpushfrontrootglobals (); 413 414 windowgetfspec (shellwindow, &fs); 415 416 shellpopglobals (); 417 418 if (!newchildwindow (idbrowserconfig, hparent, rwindow, rzoom, fs.name, &browserwindow)) 419 goto error; 420 421 // windowsetcolor (browserwindow, (**hm).forecolor, true); 422 423 // windowsetcolor (browserwindow, (**hm).backcolor, false); 424 425 getwindowinfo (browserwindow, &browserwindowinfo); 426 427 (**browserwindowinfo).hdata = (Handle) hc; 428 429 ccnewsubwindow (browserwindowinfo, ixbrowserinfo); 430 431 shellpushglobals (browserwindow); 432 433 browserresize (); 434 435 // browsersetfontsize (); 436 437 windowzoom (browserwindow); 438 439 shellpopglobals (); 440 441 return (true); 442 443 error: 444 445 opdisposeoutline (ho, true); 446 447 disposehandle ((Handle) hc); 448 449 return (false); 450 } /*browsernewwindow*/ 451 452 453 static boolean browserfindvisit (WindowPtr w) { 454 455 /* 456 if we're called, the w is a window with the desired config, owned 457 the the current root. 458 459 set up browser globals and return false to terminate the visit 460 */ 461 462 browserwindow = w; 463 464 getwindowinfo (w, &browserwindowinfo); 465 466 browserdata = (hdlclaydata) (**browserwindowinfo).hdata; 467 468 return (false); 469 } /*browserfindvisit*/ 470 471 472 static boolean browserfindwindow (short idconfig) { 473 474 /* 475 5/22/91 dmb: use customized visit to limit search to windows belonging to the 476 current root. this allows us to distinguish between the quickscript window 477 for each open file. 478 */ 479 480 hdlwindowinfo hroot; 481 482 if (!frontrootwindow (&hroot)) 483 return (false); 484 485 return (!visitownedwindows ((**hroot).macwindow, idconfig, &browserfindvisit)); 486 487 /* 488 return (shellfindwindow (idconfig, &browserwindow, &browserwindowinfo, (Handle *) &browserdata)); 489 */ 490 } /*browserfindwindow*/ 491 492 493 boolean browseropenmainwindow (void) { 494 495 if (browserfindwindow (idbrowserconfig)) { /*sets browserdata, browserwindow*/ 496 497 windowbringtofront (browserwindow); 498 499 return (true); 500 } 501 502 return (browsernewwindow ()); 503 } /*browseropenmainwindow*/ 504 505 506 boolean browserstart (void) { 507 508 /* 509 set up callback routines record, and link our data into the shell's 510 data structure. 511 */ 512 513 ptrcallbacks browsercallbacks; 514 register ptrcallbacks cb; 515 516 // browserinitverbs (); 517 518 // meinit (); 519 520 shellnewcallbacks (&browsercallbacks); 521 522 cb = browsercallbacks; /*copy into register*/ 523 524 loadconfigresource (idbrowserconfig, &(*cb).config); 525 526 (*cb).configresnum = idbrowserconfig; 527 528 (*cb).windowholder = &browserwindow; 529 530 (*cb).dataholder = (Handle *) &browserdata; 531 532 (*cb).infoholder = &browserwindowinfo; 533 534 (*cb).setglobalsroutine = &browsersetglobals; 535 536 (*cb).updateroutine = &browserupdate; 537 538 (*cb).activateroutine = &opactivate; 539 540 (*cb).getcontentsizeroutine = &browsergetcontentsize; 541 542 (*cb).resetrectsroutine = &browserresetrects; 543 544 (*cb).resizeroutine = &browserresize; 545 546 (*cb).scrollroutine = &opscroll; 547 548 (*cb).setscrollbarroutine = &opresetscrollbars; 549 550 (*cb).mouseroutine = &opmousedown; 551 552 (*cb).keystrokeroutine = &opkeystroke; 553 554 // (*cb).titleclickroutine = &browsertitleclick; 555 556 (*cb).cutroutine = &opcut; 557 558 (*cb).copyroutine = &opcopy; 559 560 (*cb).pasteroutine = &oppaste; 561 562 (*cb).clearroutine = &opclear; 563 564 (*cb).selectallroutine = &opselectall; 565 566 /* 567 (*cb).disposerecordroutine = &medispose; 568 */ 569 570 (*cb).closeroutine = &browserclose; 571 572 (*cb).getundoglobalsroutine = &opeditgetundoglobals; 573 574 (*cb).setundoglobalsroutine = &opeditsetundoglobals; 575 576 // (*cb).childcloseroutine = &browserchildclose; 577 578 (*cb).idleroutine = &browseridle; 579 580 (*cb).adjustcursorroutine = &opsetcursor; 581 582 (*cb).gettargetdataroutine = &browsergettargetdata; 583 584 // (*cb).getvariableroutine = &browsergetvariable; 585 586 (*cb).settextmoderoutine = &opsettextmode; 587 588 (*cb).fontroutine = &browsersetfont; 589 590 (*cb).sizeroutine = &browsersetsize; 591 592 (*cb).setselectioninforoutine = &opsetselectioninfo; 593 594 // (*cb).searchroutine = &browsersearch; 595 596 // (*cb).executeroutine = &browserrunscript; 597 598 (*cb).setprintinfoproutine = &opsetprintinfo; 599 600 (*cb).printroutine = &opprint; 601 602 return (true); 603 } /*browserstart*/ 604 605 606 607 608

~ [ 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.