ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
Revision: 1.15
Committed: Sun Feb 17 11:37:21 2008 UTC (16 years, 3 months ago) by ayin
Content type: text/plain
Branch: MAIN
Changes since 1.14: +4 -2 lines
Log Message:
Make scrollbar_TotalWidth a method of scrollBar_t.

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