ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/scrollbar.h
(Generate patch)

Comparing rxvt-unicode/src/scrollbar.h (file contents):
Revision 1.25 by sf-exg, Mon Aug 22 17:23:56 2011 UTC vs.
Revision 1.30 by sf-exg, Tue Oct 2 10:29:12 2012 UTC

1#ifndef SCROLLBAR_H 1#ifndef SCROLLBAR_H
2#define SCROLLBAR_H 2#define SCROLLBAR_H
3 3
4#include <X11/Xlib.h> 4#include <X11/Xlib.h>
5#include "rxvtutil.h"
5 6
6struct rxvt_term; 7struct rxvt_term;
7 8
8#define SB_WIDTH_NEXT 19 9#define SB_WIDTH_NEXT 19
9#define SB_WIDTH_XTERM 15 10#define SB_WIDTH_XTERM 15
29#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING) 30#define SB_BUTTON_BEVEL_X (SB_LEFT_PADDING)
30#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT) 31#define SB_BUTTON_FACE_X (SB_BUTTON_BEVEL_X + SB_BEVEL_WIDTH_UPPER_LEFT)
31#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) 32#define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2))
32 33
33enum sb_state { 34enum sb_state {
34 STATE_OFF, 35 SB_STATE_OFF,
35 STATE_IDLE, 36 SB_STATE_IDLE,
36 STATE_MOTION, 37 SB_STATE_MOTION,
37 STATE_UP, 38 SB_STATE_UP,
38 STATE_DOWN, 39 SB_STATE_DOWN,
39}; 40};
40 41
41enum sb_style { 42enum sb_style {
42 R_SB_NEXT = 1, 43 SB_STYLE_NEXT = 1,
43 R_SB_XTERM = 2, 44 SB_STYLE_XTERM = 2,
44 R_SB_PLAIN = 4, 45 SB_STYLE_PLAIN = 4,
45 R_SB_RXVT = 8, 46 SB_STYLE_RXVT = 8,
46}; 47};
47 48
48enum sb_align { 49enum sb_align {
49 R_SB_ALIGN_CENTRE, 50 SB_ALIGN_CENTRE,
50 R_SB_ALIGN_TOP, 51 SB_ALIGN_TOP,
51 R_SB_ALIGN_BOTTOM, 52 SB_ALIGN_BOTTOM,
52}; 53};
53 54
54struct scrollBar_t 55struct scrollBar_t
55{ 56{
56 rxvt_term *term; 57 rxvt_term *term;
57 sb_state state; /* scrollbar state */ 58 sb_state state; /* scrollbar state */
58 char init; /* scrollbar has been initialised */ 59 char init; /* scrollbar has been initialised */
59 unsigned int beg; /* slider sub-window begin height */ 60 int beg; /* slider sub-window begin height */
60 unsigned int end; /* slider sub-window end height */ 61 int end; /* slider sub-window end height */
61 unsigned int top; /* slider top position */ 62 int top; /* slider top position */
62 unsigned int bot; /* slider bottom position */ 63 int bot; /* slider bottom position */
63 sb_style style; /* style: rxvt, xterm, next */ 64 sb_style style; /* style: rxvt, xterm, next */
64 unsigned int width; /* scrollbar width */ 65 int width; /* scrollbar width */
65 int shadow; /* scrollbar shadow width */ 66 int shadow; /* scrollbar shadow width */
66 int last_bot; /* scrollbar last bottom position */ 67 int last_bot; /* scrollbar last bottom position */
67 int last_top; /* scrollbar last top position */ 68 int last_top; /* scrollbar last top position */
68 int last_state; /* scrollbar last state */ 69 int last_state; /* scrollbar last state */
69 sb_align align; 70 sb_align align;
70 Window win; 71 Window win;
71 Cursor leftptr_cursor; 72 Cursor leftptr_cursor;
72 int (scrollBar_t::*update)(int); 73 int (scrollBar_t::*update)(int);
73 void setup (rxvt_term *); 74 void setup (rxvt_term *);
74 void resize (); 75 void resize ();
75 int map (int); 76 void map (int);
76 int show (int); 77 int show (int);
77 void destroy (); 78 void destroy ();
79 int color ();
78 80
79 bool upButton (int y) 81 bool upButton (int y)
80 { 82 {
81 if (style == R_SB_NEXT) 83 if (style == SB_STYLE_NEXT)
82 return y > end && y <= end + width + 1; 84 return y > end && y <= end + width + 1;
83 if (style == R_SB_RXVT) 85 if (style == SB_STYLE_RXVT)
84 return y < beg; 86 return y < beg;
85 return false; 87 return false;
86 } 88 }
87 bool dnButton (int y) 89 bool dnButton (int y)
88 { 90 {
89 if (style == R_SB_NEXT) 91 if (style == SB_STYLE_NEXT)
90 return y > end + width + 1; 92 return y > end + width + 1;
91 if (style == R_SB_RXVT) 93 if (style == SB_STYLE_RXVT)
92 return y > end; 94 return y > end;
93 return false; 95 return false;
94 } 96 }
95 unsigned min_height () 97 int min_height ()
96 { 98 {
97 return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10; 99 return style == SB_STYLE_NEXT ? SB_THUMB_MIN_HEIGHT : 10;
98 } 100 }
99 unsigned size () 101 int size ()
100 { 102 {
101 return end - beg - min_height (); 103 return max (end - beg, 0);
102 } 104 }
103 unsigned total_width () 105 int total_width ()
104 { 106 {
105 return width + shadow * 2; 107 return width + shadow * 2;
106 } 108 }
107 bool above_slider (int y) 109 bool above_slider (int y)
108 { 110 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines