File: scroll.h

package info (click to toggle)
vfu 5.09-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,552 kB
  • sloc: cpp: 16,739; ansic: 2,605; perl: 678; makefile: 349; sh: 75
file content (84 lines) | stat: -rw-r--r-- 2,155 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/****************************************************************************
 *
 *  Copyright (c) 1996-2022 Vladi Belperchinov-Shabanski "Cade" 
 *  http://cade.noxrun.com/  <cade@noxrun.com> <cade@bis.bg> <cade@cpan.org>
 *
 *  SEE `README',`LICENSE' OR `COPYING' FILE FOR LICENSE AND OTHER DETAILS!
 *
 ****************************************************************************/

#ifndef _SCROLL_H_
#define _SCROLL_H_

class ScrollPos
{
    int _min;
    int _max;
    int _pos;
    int _page;
    int _pagesize;
    
    
    /* 
    _pagestep -- step to change page on up/down out of the current page
    if _pagestep is between 0 and 1 it is considered percentage of _pagesize
    (with minimum step of 1)
    if _pagestep is 1 or above it is considered integer fixed step
    (limited to size of _pagesize)
    */
    double _pagestep; 
          

    int _size;

    void fix();
    int check();

  public:

    int wrap; // 0 -- none, else -- wrap end/begin; NOTE: works only on up/down

    ScrollPos()
      {
      wrap = _min = _max = _pos = _page = _pagesize = _size = 0;
      _pagestep = 1;
      };

    void set_min_max( int a_min, int a_max )
      { _min = a_min; _max = a_max; _size = _max - _min + 1; }
    void set_pos( int a_pos )
      { _pos = a_pos; }
    void set_page( int a_page )
      { _page = a_page; }
    void set_pagesize( int a_pagesize )
      { _pagesize = a_pagesize;
        if( _pagesize < 0 ) _pagesize = 0; 
        if( _pagestep >= 1 and _pagestep > _pagesize ) _pagestep = _pagesize; }
    void set_pagestep( double a_pagestep )
      { _pagestep = a_pagestep;
        if( _pagestep <= 0 ) _pagestep = 1; }

    int min() { return _min; }
    int max() { return _max; }
    int pos() { if ( ! _size ) return 0; return _pos; }
    int page() { if ( ! _size ) return 0; return _page; }
    int pagesize() { return _pagesize; }
    int step() { return _pagestep; }

    void home();
    void end();
    void up();
    void down();

    void pageup();
    void pagedown();

    void ppage() { pageup(); }
    void npage() { pagedown(); }

    void go( int new_pos );
};

#endif //_SCROLL_H_

 // eof scroll.h