ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
Revision: 1.31
Committed: Fri May 30 19:44:11 2014 UTC (10 years ago) by sf-exg
Content type: text/plain
Branch: MAIN
CVS Tags: rxvt-unicode-rel-9_29, rxvt-unicode-rel-9_26, rxvt-unicode-rel-9_25, rxvt-unicode-rel-9_22, rxvt-unicode-rel-9_21, rxvt-unicode-rel-9_30, HEAD
Changes since 1.30: +1 -0 lines
Log Message:
Fix height and position of the stippled area in next scrollbar, patch by totto.

File Contents

# User Rev Content
1 ayin 1.1 #ifndef SCROLLBAR_H
2     #define SCROLLBAR_H
3    
4     #include <X11/Xlib.h>
5 sf-exg 1.26 #include "rxvtutil.h"
6 ayin 1.1
7     struct rxvt_term;
8    
9 ayin 1.16 #define SB_WIDTH_NEXT 19
10     #define SB_WIDTH_XTERM 15
11     #define SB_WIDTH_PLAIN 7
12     #ifndef SB_WIDTH_RXVT
13     # define SB_WIDTH_RXVT 10
14     #endif
15    
16     /*
17     * NeXT scrollbar defines
18     */
19     #define SB_PADDING 1
20     #define SB_BORDER_WIDTH 1
21     #define SB_BEVEL_WIDTH_UPPER_LEFT 1
22     #define SB_BEVEL_WIDTH_LOWER_RIGHT 2
23     #define SB_LEFT_PADDING (SB_PADDING + SB_BORDER_WIDTH)
24     #define SB_MARGIN_SPACE (SB_PADDING * 2)
25     #define SB_BUTTON_WIDTH (SB_WIDTH_NEXT - SB_MARGIN_SPACE - SB_BORDER_WIDTH)
26     #define SB_BUTTON_HEIGHT (SB_BUTTON_WIDTH)
27     #define SB_BUTTON_SINGLE_HEIGHT (SB_BUTTON_HEIGHT + SB_PADDING)
28     #define SB_BUTTON_BOTH_HEIGHT (SB_BUTTON_SINGLE_HEIGHT * 2)
29     #define SB_BUTTON_TOTAL_HEIGHT (SB_BUTTON_BOTH_HEIGHT + SB_PADDING)
30     #define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
31     #define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT)
32     #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2))
33    
34 ayin 1.13 enum sb_state {
35 sf-exg 1.28 SB_STATE_OFF,
36     SB_STATE_IDLE,
37     SB_STATE_MOTION,
38     SB_STATE_UP,
39     SB_STATE_DOWN,
40 ayin 1.13 };
41    
42 sf-exg 1.24 enum sb_style {
43 sf-exg 1.28 SB_STYLE_NEXT = 1,
44     SB_STYLE_XTERM = 2,
45     SB_STYLE_PLAIN = 4,
46     SB_STYLE_RXVT = 8,
47 sf-exg 1.24 };
48    
49     enum sb_align {
50 sf-exg 1.28 SB_ALIGN_CENTRE,
51     SB_ALIGN_TOP,
52     SB_ALIGN_BOTTOM,
53 sf-exg 1.24 };
54    
55 root 1.23 struct scrollBar_t
56     {
57 ayin 1.14 rxvt_term *term;
58 sf-exg 1.24 sb_state state; /* scrollbar state */
59 ayin 1.1 char init; /* scrollbar has been initialised */
60 sf-exg 1.26 int beg; /* slider sub-window begin height */
61     int end; /* slider sub-window end height */
62     int top; /* slider top position */
63     int bot; /* slider bottom position */
64 sf-exg 1.24 sb_style style; /* style: rxvt, xterm, next */
65 sf-exg 1.26 int width; /* scrollbar width */
66 ayin 1.3 int shadow; /* scrollbar shadow width */
67 ayin 1.7 int last_bot; /* scrollbar last bottom position */
68     int last_top; /* scrollbar last top position */
69     int last_state; /* scrollbar last state */
70 sf-exg 1.24 sb_align align;
71 ayin 1.1 Window win;
72 ayin 1.10 Cursor leftptr_cursor;
73 ayin 1.20 int (scrollBar_t::*update)(int);
74 ayin 1.14 void setup (rxvt_term *);
75 ayin 1.19 void resize ();
76 sf-exg 1.27 void map (int);
77 ayin 1.19 int show (int);
78 ayin 1.20 void destroy ();
79 sf-exg 1.30 int color ();
80 ayin 1.1
81 ayin 1.12 bool upButton (int y)
82     {
83 sf-exg 1.28 if (style == SB_STYLE_NEXT)
84 ayin 1.12 return y > end && y <= end + width + 1;
85 sf-exg 1.28 if (style == SB_STYLE_RXVT)
86 ayin 1.12 return y < beg;
87     return false;
88     }
89     bool dnButton (int y)
90     {
91 sf-exg 1.28 if (style == SB_STYLE_NEXT)
92 ayin 1.12 return y > end + width + 1;
93 sf-exg 1.28 if (style == SB_STYLE_RXVT)
94 ayin 1.12 return y > end;
95     return false;
96     }
97 sf-exg 1.26 int min_height ()
98 ayin 1.17 {
99 sf-exg 1.28 return style == SB_STYLE_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
100 ayin 1.17 }
101 sf-exg 1.26 int size ()
102 ayin 1.17 {
103 sf-exg 1.29 return max (end - beg, 0);
104 ayin 1.17 }
105 sf-exg 1.26 int total_width ()
106 ayin 1.15 {
107     return width + shadow * 2;
108     }
109 sf-exg 1.25 bool above_slider (int y)
110     {
111     return y < top;
112     }
113     bool below_slider (int y)
114     {
115     return y > bot;
116     }
117     int position (int y)
118     {
119     return y - beg;
120     }
121    
122 ayin 1.20
123     #if defined(NEXT_SCROLLBAR)
124     GC blackGC,
125     whiteGC,
126     grayGC,
127     darkGC,
128     stippleGC;
129     Pixmap dimple,
130     upArrow,
131     downArrow,
132     upArrowHi,
133     downArrowHi;
134 sf-exg 1.31 bool last_has_sb;
135 ayin 1.20 #endif
136    
137     #if defined(RXVT_SCROLLBAR)
138     GC scrollbarGC,
139     topShadowGC,
140     botShadowGC;
141     #endif
142    
143     #if defined(XTERM_SCROLLBAR)
144     GC xscrollbarGC,
145     ShadowGC;
146     #endif
147    
148     #if defined(PLAIN_SCROLLBAR)
149     GC pscrollbarGC;
150     #endif
151    
152 ayin 1.22 private:
153     // update style dependent data
154     void update_data ();
155    
156 ayin 1.20 // scrollbar-next.C
157     int show_next (int);
158     // scrollbar-rxvt.C
159     int show_rxvt (int);
160     // scrollbar-xterm.C
161     int show_xterm (int);
162     // scrollbar-plain.C
163     int show_plain (int);
164    
165     void init_next ();
166 ayin 1.11 };
167 ayin 1.1
168     /*
169     * +-------------+
170     * | | <---< SB_PADDING
171     * | ::::::::::: |
172     * | ::::::::::: |
173     * '''''''''''''''''
174     * ,,,,,,,,,,,,,,,,,
175     * | ::::::::::: |
176     * | ::::::::::: |
177     * | +---------------< SB_BEVEL_WIDTH_UPPER_LEFT
178     * | | :::::::: |
179     * | V :::: vv-------< SB_BEVEL_WIDTH_LOWER_RIGHT
180     * | +---------+ |
181     * | | ......%%| |
182     * | | ......%%| |
183     * | | .. ()..%%| |
184     * | | ......%%| |
185     * | | %%%%%%%%| |
186     * | +---------+ | <.........................
187     * | | <---< SB_PADDING :
188     * | +---------+ | <-+.......... :---< SB_BUTTON_TOTAL_HEIGHT
189     * | | ......%%| | | : :
190     * | | ../\..%%| | |---< SB_BUTTON_HEIGHT :
191     * | | %%%%%%%%| | | : :
192     * | +---------+ | <-+ : :
193     * | | : :
194     * | +---------+ | <-+ :---< SB_BUTTON_BOTH_HEIGHT
195     * | | ......%%| | | : :
196     * | | ..\/..%%| | | : :
197     * | | %%%%%%%%| | |---< SB_BUTTON_SINGLE_HEIGHT
198     * | +---------+ | | : :
199     * | | | : :
200     * +-------------+ <-+.........:............:
201     * ^^|_________| :
202     * || | :
203     * || +---< SB_BUTTON_WIDTH
204     * || :
205     * |+------< SB_PADDING
206     * |: :
207     * +----< SB_BORDER_WIDTH
208     * : :
209     * :............:
210     * |
211     * +---< SB_WIDTH_NEXT
212     */
213    
214     #endif