--- rxvt-unicode/src/scrollbar.h 2008/02/19 10:47:03 1.19 +++ rxvt-unicode/src/scrollbar.h 2011/08/22 17:23:56 1.25 @@ -5,15 +5,6 @@ struct rxvt_term; -#define R_SB_NEXT 1 -#define R_SB_XTERM 2 -#define R_SB_PLAIN 4 -#define R_SB_RXVT 8 - -#define R_SB_ALIGN_CENTRE 0 -#define R_SB_ALIGN_TOP 1 -#define R_SB_ALIGN_BOTTOM 2 - #define SB_WIDTH_NEXT 19 #define SB_WIDTH_XTERM 15 #define SB_WIDTH_PLAIN 7 @@ -40,37 +31,50 @@ #define SB_THUMB_MIN_HEIGHT (SB_BUTTON_WIDTH - (SB_PADDING * 2)) enum sb_state { - STATE_IDLE = 1, + STATE_OFF, + STATE_IDLE, STATE_MOTION, STATE_UP, STATE_DOWN, }; -struct scrollBar_t { +enum sb_style { + R_SB_NEXT = 1, + R_SB_XTERM = 2, + R_SB_PLAIN = 4, + R_SB_RXVT = 8, +}; + +enum sb_align { + R_SB_ALIGN_CENTRE, + R_SB_ALIGN_TOP, + R_SB_ALIGN_BOTTOM, +}; + +struct scrollBar_t +{ rxvt_term *term; - char state; /* scrollbar state */ + 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 */ - unsigned int style; /* style: rxvt, xterm, next */ + sb_style style; /* style: rxvt, xterm, next */ unsigned int width; /* scrollbar width */ int shadow; /* scrollbar shadow width */ int last_bot; /* scrollbar last bottom position */ int last_top; /* scrollbar last top position */ int last_state; /* scrollbar last state */ - int len; - unsigned char align; + sb_align align; Window win; Cursor leftptr_cursor; - int (rxvt_term::*update)(int, int, int, int); + int (scrollBar_t::*update)(int); void setup (rxvt_term *); - // update style dependent data - void update_data (); void resize (); int map (int); int show (int); + void destroy (); bool upButton (int y) { @@ -100,11 +104,63 @@ { return width + shadow * 2; } -}; + bool above_slider (int y) + { + return y < top; + } + bool below_slider (int y) + { + return y > bot; + } + int position (int y) + { + return y - beg; + } -#define scrollbar_above_slider(y) ((y) < scrollBar.top) -#define scrollbar_below_slider(y) ((y) > scrollBar.bot) -#define scrollbar_position(y) ((y) - scrollBar.beg) + +#if defined(NEXT_SCROLLBAR) + GC blackGC, + whiteGC, + grayGC, + darkGC, + stippleGC; + Pixmap dimple, + upArrow, + downArrow, + upArrowHi, + downArrowHi; +#endif + +#if defined(RXVT_SCROLLBAR) + GC scrollbarGC, + topShadowGC, + botShadowGC; +#endif + +#if defined(XTERM_SCROLLBAR) + GC xscrollbarGC, + ShadowGC; +#endif + +#if defined(PLAIN_SCROLLBAR) + GC pscrollbarGC; +#endif + +private: + // update style dependent data + void update_data (); + + // scrollbar-next.C + int show_next (int); + // scrollbar-rxvt.C + int show_rxvt (int); + // scrollbar-xterm.C + int show_xterm (int); + // scrollbar-plain.C + int show_plain (int); + + void init_next (); +}; /* * +-------------+