ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
Revision: 1.12
Committed: Mon Jan 28 10:54:54 2008 UTC (16 years, 3 months ago) by ayin
Content type: text/plain
Branch: MAIN
CVS Tags: rel-9_02
Changes since 1.11: +22 -11 lines
Log Message:
Replace scrollbar {up,dn}Button macros with methods.

File Contents

# User Rev Content
1 ayin 1.1 #ifndef SCROLLBAR_H
2     #define SCROLLBAR_H
3    
4     #include <X11/Xlib.h>
5    
6     struct rxvt_term;
7    
8 ayin 1.12 #define R_SB_NEXT 1
9     #define R_SB_XTERM 2
10     #define R_SB_PLAIN 4
11     #define R_SB_RXVT 8
12    
13 ayin 1.11 struct scrollBar_t {
14 ayin 1.1 char state; /* scrollbar state */
15     char init; /* scrollbar has been initialised */
16     unsigned int beg; /* slider sub-window begin height */
17     unsigned int end; /* slider sub-window end height */
18     unsigned int top; /* slider top position */
19     unsigned int bot; /* slider bottom position */
20     unsigned int style; /* style: rxvt, xterm, next */
21     unsigned int width; /* scrollbar width */
22 ayin 1.3 int shadow; /* scrollbar shadow width */
23 ayin 1.7 int last_bot; /* scrollbar last bottom position */
24     int last_top; /* scrollbar last top position */
25     int last_state; /* scrollbar last state */
26 ayin 1.9 int len;
27 ayin 1.6 unsigned char align;
28 ayin 1.1 Window win;
29 ayin 1.10 Cursor leftptr_cursor;
30 ayin 1.1 int (rxvt_term::*update)(int, int, int, int);
31    
32     void setIdle() { state = 1 ; }
33     void setMotion() { state = 'm'; }
34     void setUp() { state = 'U'; }
35     void setDn() { state = 'D'; }
36 ayin 1.12
37     bool upButton (int y)
38     {
39     if (style == R_SB_NEXT)
40     return y > end && y <= end + width + 1;
41     if (style == R_SB_RXVT)
42     return y < beg;
43     return false;
44     }
45     bool dnButton (int y)
46     {
47     if (style == R_SB_NEXT)
48     return y > end + width + 1;
49     if (style == R_SB_RXVT)
50     return y > end;
51     return false;
52     }
53 ayin 1.11 };
54 ayin 1.1
55 ayin 1.3 #define scrollbar_TotalWidth() (scrollBar.width + scrollBar.shadow * 2)
56 ayin 1.1 #define scrollbar_isMotion() (scrollBar.state == 'm')
57     #define scrollbar_isUp() (scrollBar.state == 'U')
58     #define scrollbar_isDn() (scrollBar.state == 'D')
59 ayin 1.5 #define scrollbar_isUpDn() (scrollbar_isUp () || scrollbar_isDn ())
60 ayin 1.1
61     #define SCROLLNEXT_MINHEIGHT SB_THUMB_MIN_HEIGHT
62     #define SCROLLRXVT_MINHEIGHT 10
63    
64     #define scrollbar_minheight() (scrollBar.style == R_SB_NEXT \
65     ? SCROLLNEXT_MINHEIGHT \
66     : SCROLLRXVT_MINHEIGHT)
67     #define scrollbar_above_slider(y) ((y) < scrollBar.top)
68     #define scrollbar_below_slider(y) ((y) > scrollBar.bot)
69     #define scrollbar_position(y) ((y) - scrollBar.beg)
70     #define scrollbar_size() (scrollBar.end - scrollBar.beg \
71     - scrollbar_minheight ())
72    
73     #define R_SB_ALIGN_CENTRE 0
74     #define R_SB_ALIGN_TOP 1
75     #define R_SB_ALIGN_BOTTOM 2
76    
77     #define SB_WIDTH_NEXT 19
78     #define SB_WIDTH_XTERM 15
79     #define SB_WIDTH_PLAIN 7
80     #ifndef SB_WIDTH_RXVT
81     # define SB_WIDTH_RXVT 10
82     #endif
83    
84     /*
85     * NeXT scrollbar defines
86     */
87     #define SB_PADDING 1
88     #define SB_BORDER_WIDTH 1
89     #define SB_BEVEL_WIDTH_UPPER_LEFT 1
90     #define SB_BEVEL_WIDTH_LOWER_RIGHT 2
91     #define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH)
92     #define SB_MARGIN_SPACE (SB_PADDING * 2)
93     #define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH)
94     #define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH)
95     #define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING)
96     #define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
97     #define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
98     #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
99     #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT)
100     #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2))
101     /*
102     * +-------------+
103     * | | <---< SB_PADDING
104     * | ::::::::::: |
105     * | ::::::::::: |
106     * '''''''''''''''''
107     * ,,,,,,,,,,,,,,,,,
108     * | ::::::::::: |
109     * | ::::::::::: |
110     * | +---------------< SB_BEVEL_WIDTH_UPPER_LEFT
111     * | | :::::::: |
112     * | V :::: vv-------< SB_BEVEL_WIDTH_LOWER_RIGHT
113     * | +---------+ |
114     * | | ......%%| |
115     * | | ......%%| |
116     * | | .. ()..%%| |
117     * | | ......%%| |
118     * | | %%%%%%%%| |
119     * | +---------+ | <.........................
120     * | | <---< SB_PADDING :
121     * | +---------+ | <-+.......... :---< SB_BUTTON_TOTAL_HEIGHT
122     * | | ......%%| | | : :
123     * | | ../\..%%| | |---< SB_BUTTON_HEIGHT :
124     * | | %%%%%%%%| | | : :
125     * | +---------+ | <-+ : :
126     * | | : :
127     * | +---------+ | <-+ :---< SB_BUTTON_BOTH_HEIGHT
128     * | | ......%%| | | : :
129     * | | ..\/..%%| | | : :
130     * | | %%%%%%%%| | |---< SB_BUTTON_SINGLE_HEIGHT
131     * | +---------+ | | : :
132     * | | | : :
133     * +-------------+ <-+.........:............:
134     * ^^|_________| :
135     * || | :
136     * || +---< SB_BUTTON_WIDTH
137     * || :
138     * |+------< SB_PADDING
139     * |: :
140     * +----< SB_BORDER_WIDTH
141     * : :
142     * :............:
143     * |
144     * +---< SB_WIDTH_NEXT
145     */
146    
147     #endif