opscrollbar.c

Go to the documentation of this file.
00001 
00002 /*  $Id: opscrollbar.c 355 2005-01-11 22:48:55Z andreradke $    */
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 "ops.h"
00032 #include "shellprint.h"
00033 #include "op.h"
00034 #include "opinternal.h"
00035 #include "oplineheight.h"
00036 
00037 
00038 
00039 #if 0
00040 
00041 static long xxxgetcurrentscreenlines (void) {
00042     
00043     /*
00044     return the number of lines currently showing in the window.
00045     */
00046     
00047     hdlheadrecord nomad = (**outlinedata).hline1, nextnomad;
00048     Rect r = (**outlinedata).outlinerect;
00049     short vertpixels = r.bottom - r.top;
00050     short ctpixels = 0;
00051     long ctlines = 0;
00052     
00053     while (true) {
00054         
00055         ctpixels += opgetlineheight (nomad);
00056         
00057         if (ctpixels > vertpixels)
00058             return (ctlines);
00059             
00060         ctlines++;
00061         
00062         nextnomad = opgetnextexpanded (nomad);
00063         
00064         if (nextnomad == nomad)
00065             return (ctlines);
00066             
00067         nomad = nextnomad;
00068         } /*while*/
00069     } /*getcurrentscreenlines*/
00070 
00071 #endif
00072 
00073 
00074 boolean oprestorescrollposition (void) {
00075     
00076     register hdloutlinerecord ho = outlinedata;
00077     hdlheadrecord hline1 = (**ho).hsummit;
00078     long ctscrolllines = (**ho).vertscrollinfo.cur;
00079     
00080     while (ctscrolllines > 0) {
00081     
00082         ctscrolllines -= opgetnodelinecount (hline1);
00083         
00084         if (ctscrolllines < 0) { //this is the top line, partially above the window
00085             
00086             ctscrolllines += opgetnodelinecount (hline1);
00087             
00088             break;
00089             }
00090         
00091         hline1 = oprepeatedbump (flatdown, 1, hline1, true); //if ctscrolllines is zero, this is line1
00092         }
00093     
00094     (**ho).hline1 = hline1;
00095     
00096     (**ho).line1linesabove = ctscrolllines;
00097     
00098     return (true);
00099     } /*oprestorescrollposition*/
00100 
00101 
00102 boolean opsetscrollpositiontoline1 (void) {
00103     
00104     /*
00105     6.0b3 dmb: make the vertical scroll position agree with hline1/line1linesabove
00106     */
00107     
00108     register hdloutlinerecord ho = outlinedata;
00109     hdlheadrecord nomad = (**ho).hsummit;
00110     hdlheadrecord hline1 = (**ho).hline1;
00111     long ctscrolllines = (**ho).line1linesabove;
00112     
00113     if (!(**hline1).flexpanded) //6.0b4 dmb: should never be true, but when printing..
00114         return (false);
00115     
00116     while (nomad != hline1) {
00117         
00118         ctscrolllines += opgetnodelinecount (nomad);
00119         
00120         nomad = opgetnextexpanded (nomad);
00121         }
00122     
00123     (**ho).vertscrollinfo.cur = ctscrolllines;
00124     
00125     return (true);
00126     } /*opsetscrollpositiontoline1*/
00127 
00128 
00129 boolean opgetscrollbarinfo (boolean flpin) {
00130     
00131     /*
00132     9/11/91 dmb: added flpin parameter.  if true, limit the vertical 
00133     scroll position to the calculated vert max, instead of enlarging 
00134     vert to maintain the current position.  also, when not pinning, 
00135     make sure the vertinfo.cur isn't as large as ctexpanded
00136     
00137     9/22/92 dmb: horizinfo.max must be in scroll quanta, not pixels
00138     
00139     8/21/93 DW: add flvertscrolldisabled and flhorizscrolldisabled to 
00140     allow clay basket to have windows that don't enable their
00141     horizontal scrollbars.
00142 
00143     7.0b17 PBS: Don't subtract one from current screen lines --
00144     fixes an off-by-one bug.
00145     */
00146     
00147     register hdloutlinerecord ho = outlinedata;
00148     //register hdlheadrecord hline1;
00149     long ctexpanded;
00150     short vscrollquantum;
00151     tyscrollinfo vertinfo, horizinfo;
00152     Rect r;
00153     
00154     if (ho == NULL)
00155         return (false);
00156 
00157     ctexpanded = (**ho).ctexpanded;
00158 
00159     if ((**ho).flvertscrolldisabled)    
00160         vertinfo.min = vertinfo.cur = vertinfo.max = vertinfo.pag = 0;
00161     else {
00162         vertinfo.min = 0;
00163         
00164         vertinfo.cur = (**ho).vertscrollinfo.cur;
00165         
00166         vertinfo.cur = min (vertinfo.cur, ctexpanded - 1);
00167         
00168         r = (**ho).outlinerect;
00169         
00170         vscrollquantum = (**ho).defaultlineheight;
00171         
00172         vertinfo.pag = opgetcurrentscreenlines (true);// - 1; /*7.0b17 PBS: Don't subtract one. Off-by-one fix.*/
00173 
00174         vertinfo.max = max (vertinfo.min, ctexpanded - vertinfo.pag); /*DW 7/9/93*/
00175         
00176         if (flpin)
00177             vertinfo.cur = min (vertinfo.cur, vertinfo.max); /*bring it in range*/
00178         else
00179             vertinfo.max = max (vertinfo.max, vertinfo.cur); /*make it accomodate current pos*/
00180         
00181         /*
00182         hline1 = oprepeatedbump (flatdown, vertinfo.cur, (**ho).hsummit, true);
00183         
00184         if (hline1 != (**ho).hline1) {
00185         
00186             (**ho).hline1 = hline1;
00187             
00188             opinvaldisplay (); /%serious updating needed
00189             }
00190         */
00191         }
00192     
00193     if ((**ho).flhorizscrolldisabled)   
00194         horizinfo.min = horizinfo.cur = horizinfo.max = horizinfo.pag = 0;
00195     else {
00196         horizinfo.min = 0;
00197         
00198         horizinfo.cur = (**ho).horizscrollinfo.cur;
00199         
00200         r = shellprintinfo.paperrect; /*(**ho).outlinerect*/
00201         
00202         horizinfo.pag = (r.right - r.left);
00203         
00204         horizinfo.max = 3 * horizinfo.pag; /*three paper-widths*/
00205         
00206         horizinfo.cur = max (horizinfo.min, horizinfo.cur);
00207         
00208         horizinfo.cur = min (horizinfo.max, horizinfo.cur);
00209         }
00210     
00211     (**ho).vertscrollinfo = vertinfo;
00212     
00213     (**ho).horizscrollinfo = horizinfo;
00214     
00215     return (true);
00216     } /*opgetscrollbarinfo*/
00217 
00218 
00219 void opredrawscrollbars (void) {
00220     
00221     (*(**outlinedata).setscrollbarsroutine) ();
00222     } /*opredrawscrollbars*/
00223 
00224 
00225 void opresetscrollbars (void) {
00226     
00227     opgetscrollbarinfo (false);
00228     
00229     if (opdisplayenabled ())
00230         opredrawscrollbars ();
00231     } /*opresetscrollbars*/
00232     
00233 

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