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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
.de F
.B
.if !"\\$1"" \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
..
.de L
.B
.if !"\\$1"" \&\\$1 \\$2 \\$3 \\$4 \\$5 \\$6
..
.de FR
.BR "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
..
.de LR
.BR "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
..
.de CW
.ft B
..
.\" This is gross but it avoids relying on internal implementation details
.\" of the -man macros.
.de TF
.IP "" \w'\fB\\$1\ \ \fP'u
.PD0
..
.de EX
.CW
.nf
..
.de EE
.fi
..
.\" delete above this point if your system has F, L, FR, LR, CW and TF macros
.TH SCROLL 3
.SH NAME
scrollalloc, scrollfree, scrollset, scrollhit, scrollupdate \- scrollbar routines
.SH SYNOPSIS
.nf
.B
#include <u.h>
.B
#include <libc.h>
.B
#include <libg.h>
.B
#include <frame.h>
.B
#include <text.h>
.ta \w'\fLScroll 'u +2c
.PP
.B
Scroll *scrollalloc(Bitmap *b , Rectangler r);
.PP
.B
void scrollfree(Scroll *s);
.PP
.B
void scrollset(Scroll *s, ulong thumb, ulong extent, ulong max);
.PP
.B
ulong scrollhit(Scroll *s, Event *e);
.PP
.B
void scrollupdate(Scroll *s, int force);
.SH DESCRIPTION
The text library provides rudimentary routines for displaying
scrollbars and handling user interaction with them similar those
used in
.IR sam (1)
and
.IR 9term (1).
The graphics library must have been initialised with the appropriate
init calls before using these routines.
.PP
The user-visible data structure, a
.BR Scroll,
is defined in
.BR <text.h> :
.IP
.EX
.ta 6n +\w'Rectangle 'u +\w'buttons; 'u
struct Scroll {
Rectangle r; /* the Rectangle for the scrolbar */
Bitmap *b; /* on which Scroll appears */
ulong thumb; /* position of thumb */
ulong extent; /* size of thumb */
ulong max; /* size of `document' */
ulong buttons; /* buttons used during a scrollhit */
ulong n; /* position of scrollbar after scrollhit */
void *data; /* user data area */
};
.EE
.PP
.I
Scrollalloc
creates a new
.B Scroll
in
.B Rectangle
.I r
on
.B Bitmap
.I b
and returns a pointer to this new structure.
.PP
.I Scrollfree
frees the resources used by
.IR s .
.PP
.I Scrollset
updates the values of
.IR thumb ,
.I extent
and
.IR max
and causes the scrollbar to be redrawn.
.I Max
represents the length of the scrollbar regardless
of the size of the scrollbar drawn on the screen, for instance,
a scrollbar used to interact with a 236 line document with
23 lines were visible on the screen starting at line 72 would have
.I max
set to 236,
.I extent
set to 23 and
.I thumb
set to 72.
.PP
The function
.I scrollhit
will process events and provides simple visual feedback during
an interaction.
.I Scrollhit
will return when the button state of the mouse changes from
the value initially pass to it in the Event structure
.IR e .
If a valid scrolling operation was performed then
.I scrollhit
will return a non-zero value. A zero will be returned
if the scrolling action was cancelled by either releasing the button
outside the scrollbar or pressing another button during the
scrolling action.
.PP
.I Scrollupdate
redraws the scrollbar
.I s
on
.B Bitmap
.IR b.
.SH SEE ALSO
.IR sam (1),
.IR 9term (1),
.IR bitblt (3),
.IR graphics (3),
.IR text (3).
|