ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
Revision: 1.21
Committed: Tue Feb 19 17:49:16 2008 UTC (16 years, 3 months ago) by ayin
Content type: text/plain
Branch: MAIN
Changes since 1.20: +0 -1 lines
Log Message:
Remove 'len' member of scrollBar_t and compute it on demand.

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.16 #define R_SB_ALIGN_CENTRE 0
14     #define R_SB_ALIGN_TOP 1
15     #define R_SB_ALIGN_BOTTOM 2
16    
17     #define SB_WIDTH_NEXT 19
18     #define SB_WIDTH_XTERM 15
19     #define SB_WIDTH_PLAIN 7
20     #ifndef SB_WIDTH_RXVT
21     # define SB_WIDTH_RXVT 10
22     #endif
23    
24     /*
25     * NeXT scrollbar defines
26     */
27     #define SB_PADDING 1
28     #define SB_BORDER_WIDTH 1
29     #define SB_BEVEL_WIDTH_UPPER_LEFT 1
30     #define SB_BEVEL_WIDTH_LOWER_RIGHT 2
31     #define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH)
32     #define SB_MARGIN_SPACE (SB_PADDING * 2)
33     #define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH)
34     #define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH)
35     #define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING)
36     #define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
37     #define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
38     #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
39     #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT)
40     #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2))
41    
42 ayin 1.13 enum sb_state {
43     STATE_IDLE = 1,
44     STATE_MOTION,
45     STATE_UP,
46     STATE_DOWN,
47     };
48    
49 ayin 1.11 struct scrollBar_t {
50 ayin 1.14 rxvt_term *term;
51 ayin 1.1 char state; /* scrollbar state */
52     char init; /* scrollbar has been initialised */
53     unsigned int beg; /* slider sub-window begin height */
54     unsigned int end; /* slider sub-window end height */
55     unsigned int top; /* slider top position */
56     unsigned int bot; /* slider bottom position */
57     unsigned int style; /* style: rxvt, xterm, next */
58     unsigned int width; /* scrollbar width */
59 ayin 1.3 int shadow; /* scrollbar shadow width */
60 ayin 1.7 int last_bot; /* scrollbar last bottom position */
61     int last_top; /* scrollbar last top position */
62     int last_state; /* scrollbar last state */
63 ayin 1.6 unsigned char align;
64 ayin 1.1 Window win;
65 ayin 1.10 Cursor leftptr_cursor;
66 ayin 1.20 int (scrollBar_t::*update)(int);
67 ayin 1.14 void setup (rxvt_term *);
68 ayin 1.18 // update style dependent data
69     void update_data ();
70 ayin 1.19 void resize ();
71     int map (int);
72     int show (int);
73 ayin 1.20 void destroy ();
74 ayin 1.1
75 ayin 1.12 bool upButton (int y)
76     {
77     if (style == R_SB_NEXT)
78     return y > end && y <= end + width + 1;
79     if (style == R_SB_RXVT)
80     return y < beg;
81     return false;
82     }
83     bool dnButton (int y)
84     {
85     if (style == R_SB_NEXT)
86     return y > end + width + 1;
87     if (style == R_SB_RXVT)
88     return y > end;
89     return false;
90     }
91 ayin 1.17 unsigned min_height ()
92     {
93     return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
94     }
95     unsigned size ()
96     {
97     return end - beg - min_height ();
98     }
99 ayin 1.15 unsigned total_width ()
100     {
101     return width + shadow * 2;
102     }
103 ayin 1.20
104     #if defined(NEXT_SCROLLBAR)
105     GC blackGC,
106     whiteGC,
107     grayGC,
108     darkGC,
109     stippleGC;
110     Pixmap dimple,
111     upArrow,
112     downArrow,
113     upArrowHi,
114     downArrowHi;
115     #endif
116    
117     #if defined(RXVT_SCROLLBAR)
118     GC scrollbarGC,
119     topShadowGC,
120     botShadowGC;
121     #endif
122    
123     #if defined(XTERM_SCROLLBAR)
124     GC xscrollbarGC,
125     ShadowGC;
126     #endif
127    
128     #if defined(PLAIN_SCROLLBAR)
129     GC pscrollbarGC;
130     #endif
131    
132     // scrollbar-next.C
133     int show_next (int);
134     // scrollbar-rxvt.C
135     int show_rxvt (int);
136     // scrollbar-xterm.C
137     int show_xterm (int);
138     // scrollbar-plain.C
139     int show_plain (int);
140    
141     private:
142     void init_next ();
143 ayin 1.11 };
144 ayin 1.1
145     #define scrollbar_above_slider(y) ((y) < scrollBar.top)
146     #define scrollbar_below_slider(y) ((y) > scrollBar.bot)
147     #define scrollbar_position(y) ((y) - scrollBar.beg)
148    
149     /*
150     * +-------------+
151     * | | <---< SB_PADDING
152     * | ::::::::::: |
153     * | ::::::::::: |
154     * '''''''''''''''''
155     * ,,,,,,,,,,,,,,,,,
156     * | ::::::::::: |
157     * | ::::::::::: |
158     * | +---------------< SB_BEVEL_WIDTH_UPPER_LEFT
159     * | | :::::::: |
160     * | V :::: vv-------< SB_BEVEL_WIDTH_LOWER_RIGHT
161     * | +---------+ |
162     * | | ......%%| |
163     * | | ......%%| |
164     * | | .. ()..%%| |
165     * | | ......%%| |
166     * | | %%%%%%%%| |
167     * | +---------+ | <.........................
168     * | | <---< SB_PADDING :
169     * | +---------+ | <-+.......... :---< SB_BUTTON_TOTAL_HEIGHT
170     * | | ......%%| | | : :
171     * | | ../\..%%| | |---< SB_BUTTON_HEIGHT :
172     * | | %%%%%%%%| | | : :
173     * | +---------+ | <-+ : :
174     * | | : :
175     * | +---------+ | <-+ :---< SB_BUTTON_BOTH_HEIGHT
176     * | | ......%%| | | : :
177     * | | ..\/..%%| | | : :
178     * | | %%%%%%%%| | |---< SB_BUTTON_SINGLE_HEIGHT
179     * | +---------+ | | : :
180     * | | | : :
181     * +-------------+ <-+.........:............:
182     * ^^|_________| :
183     * || | :
184     * || +---< SB_BUTTON_WIDTH
185     * || :
186     * |+------< SB_PADDING
187     * |: :
188     * +----< SB_BORDER_WIDTH
189     * : :
190     * :............:
191     * |
192     * +---< SB_WIDTH_NEXT
193     */
194    
195     #endif