--- rxvt-unicode/src/scrollbar.h 2011/08/22 17:23:56 1.25 +++ rxvt-unicode/src/scrollbar.h 2012/10/02 10:29:12 1.30 @@ -2,6 +2,7 @@ #define SCROLLBAR_H #include +#include "rxvtutil.h" struct rxvt_term; @@ -31,24 +32,24 @@ #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) enum sb_state { - STATE_OFF, - STATE_IDLE, - STATE_MOTION, - STATE_UP, - STATE_DOWN, + SB_STATE_OFF, + SB_STATE_IDLE, + SB_STATE_MOTION, + SB_STATE_UP, + SB_STATE_DOWN, }; enum sb_style { - R_SB_NEXT = 1, - R_SB_XTERM = 2, - R_SB_PLAIN = 4, - R_SB_RXVT = 8, + SB_STYLE_NEXT = 1, + SB_STYLE_XTERM = 2, + SB_STYLE_PLAIN = 4, + SB_STYLE_RXVT = 8, }; enum sb_align { - R_SB_ALIGN_CENTRE, - R_SB_ALIGN_TOP, - R_SB_ALIGN_BOTTOM, + SB_ALIGN_CENTRE, + SB_ALIGN_TOP, + SB_ALIGN_BOTTOM, }; struct scrollBar_t @@ -56,12 +57,12 @@ rxvt_term *term; sb_state state; /* scrollbar state */ char init; /* scrollbar has been initialised */ - unsigned int beg; /* slider sub-window begin height */ - unsigned int end; /* slider sub-window end height */ - unsigned int top; /* slider top position */ - unsigned int bot; /* slider bottom position */ + int beg; /* slider sub-window begin height */ + int end; /* slider sub-window end height */ + int top; /* slider top position */ + int bot; /* slider bottom position */ sb_style style; /* style: rxvt, xterm, next */ - unsigned int width; /* scrollbar width */ + int width; /* scrollbar width */ int shadow; /* scrollbar shadow width */ int last_bot; /* scrollbar last bottom position */ int last_top; /* scrollbar last top position */ @@ -72,35 +73,36 @@ int (scrollBar_t::*update)(int); void setup (rxvt_term *); void resize (); - int map (int); + void map (int); int show (int); void destroy (); + int color (); bool upButton (int y) { - if (style == R_SB_NEXT) + if (style == SB_STYLE_NEXT) return y > end && y <= end + width + 1; - if (style == R_SB_RXVT) + if (style == SB_STYLE_RXVT) return y < beg; return false; } bool dnButton (int y) { - if (style == R_SB_NEXT) + if (style == SB_STYLE_NEXT) return y > end + width + 1; - if (style == R_SB_RXVT) + if (style == SB_STYLE_RXVT) return y > end; return false; } - unsigned min_height () + int min_height () { - return style == R_SB_NEXT ? SB_THUMB_MIN_HEIGHT : 10; + return style == SB_STYLE_NEXT ? SB_THUMB_MIN_HEIGHT : 10; } - unsigned size () + int size () { - return end - beg - min_height (); + return max (end - beg, 0); } - unsigned total_width () + int total_width () { return width + shadow * 2; }