/** * @(#) $RCSfile: ScrollBarLoop.as,v $ $Revision: 1.5 $ $Date: 2003/03/21 07:10:06 $ * * Copyright 2003 Orgdot AS. All Rights Reserved. * http://dev.swfit.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * This loop controls the object that is to be scrolled. * * @author Olaf Havnes * @version $Revision: 1.5 $ $Date: 2003/03/21 07:10:06 $ * @since SWFIT1.0 */ // We measure the delay every run - it might be user controlled: dl = /:delay ne "" ? /:delay : DEFAULT_DELAY; if (drag) { if (scroll_horz) { if (/:change_mouse_x + pos_x < min_x) pos_x = min_x; else if (/:change_mouse_x + pos_x > max_x) pos_x = max_x; else pos_x += /:change_mouse_x; } else { if (/:change_mouse_y + pos_y < min_y) pos_y = min_y; else if (/:change_mouse_y + pos_y > max_y) pos_y = max_y; else pos_y += /:change_mouse_y; } } else { pos_x = x0 - dl * (pos_x - x0) / (dl + 1); pos_y = y0 - dl * (pos_y - y0) / (dl + 1); } button._x = pxl ? int (pos_x) : pos_x; button._y = pxl ? int (pos_y) : pos_y; // Compute the leverage: scroll_leverage = 0; if (max_press) scroll_leverage = - lvrg; else if (min_press) scroll_leverage = lvrg; else if (drag && int (pos_x) != int (x0)) scroll_leverage = lvrg * scroll_spd * (x0 - pos_x) / background._width ; else if (drag && int (pos_y) != int (y0)) scroll_leverage = lvrg * scroll_spd * (y0 - pos_y) / background._height; // TODO: if (txt_scroll) { scroll_max = eval (scroll_object add ".maxscroll"); // Do we hide the scrollbar if it is not needed ? if (hde_scroll) _visible = scroll_max > 1; if (scroll_leverage != 0) { // do this once if (scroll_nmb eq "") scroll_nmb = eval (scroll_object add ".scroll"); // What is the largest possible step to take ? scroll_step_max = background._height / 100.0; // Implement the number from the buttons scroll_step = - scroll_max * scroll_leverage; if (scroll_step < 0) { if (scroll_step < - scroll_step_max) scroll_step = - scroll_step_max; } else if (scroll_step > scroll_step_max) scroll_step = scroll_step_max; // Check the bounding box if (scroll_nmb + scroll_step > scroll_max) scroll_nmb = scroll_max; else if (scroll_nmb + scroll_step < scroll_min) scroll_nmb = scroll_min; else scroll_nmb += scroll_step; set ( scroll_object add ".scroll", int (scroll_nmb) ); } } else { // TODO - symmetrical of the paragraph below. Leave it empty to all functions are resolved. if (scroll_horz) { } else if (scroll_leverage != 0) { // We measure the size of the scroll_object every run - the size might change // during the lifetime of the scrollbar. scroll_height = _parent.scroll_height ne "" ? _parent.scroll_height : getProperty (scroll_object, _height); scroll_y = getProperty (scroll_object, _y); // Note the "no_scroll_size", that might be programmatically plotted from inside // the scrollable object. It defaults to the size of the scroll background. no_scroll_size = _parent.no_scroll_size ne "" ? _parent.no_scroll_size : background._height; scroll_max = scroll_y0; scroll_min = scroll_y0 - scroll_height + no_scroll_size; // Do we hide the scrollbar if it is not needed ? if (hde_scroll) _visible = scroll_min <= 0; // What is the largest possible step to take ? scroll_step_max = background._height / 4; // We implement the number from the buttons scroll_step = scroll_leverage * scroll_height; if (scroll_step < 0) { if (scroll_step < - scroll_step_max) scroll_step = - scroll_step_max; } else if (scroll_step > scroll_step_max) scroll_step = scroll_step_max; // Check the bounding box if (scroll_y + scroll_step > scroll_max) scroll_y = scroll_max; else if (scroll_y + scroll_step < scroll_min) scroll_y = scroll_min; else scroll_y += scroll_step; // We round off no matter what flag is set on the scroll button: if (scroll_step * scroll_step > snp ) setProperty (scroll_object, _y, int (scroll_y) ); } } // Have we been told globally to reset the scrollbar ? if (/:reset_scroll) { if (txt_scroll) set ( scroll_object add ".scroll", 1 ); else setProperty (scroll_object, _y, scroll_y0 ); }