Move update of style dependent data from resize_scrollbar to a new
authorayin <ayin>
Mon, 18 Feb 2008 11:41:39 +0000 (11:41 +0000)
committerayin <ayin>
Mon, 18 Feb 2008 11:41:39 +0000 (11:41 +0000)
method.

src/scrollbar.C
src/scrollbar.h

index 117566ac2ed4a9ebbc0bd2a07d8b773b7cf40f1c..5cb4ef960497ca775ee1f7492ec75d59f3a882c6 100644 (file)
@@ -68,47 +68,7 @@ rxvt_term::resize_scrollbar ()
   if (option (Opt_scrollBar_right))
     window_sb_x = szHint.width - scrollBar.total_width ();
 
-#define R_SCROLLBEG_XTERM      0
-#define R_SCROLLEND_XTERM      szHint.height
-#define R_SCROLLBEG_NEXT       0
-#define R_SCROLLEND_NEXT       szHint.height - (SB_BUTTON_TOTAL_HEIGHT + \
-                                                    SB_PADDING)
-#define R_SCROLLBEG_RXVT       (scrollBar.width + 1) + scrollBar.shadow
-#define R_SCROLLEND_RXVT       szHint.height - R_SCROLLBEG_RXVT - \
-                                    (2 * scrollBar.shadow)
-
-#if defined(PLAIN_SCROLLBAR)
-  if (scrollBar.style == R_SB_PLAIN)
-    {
-      scrollBar.beg = R_SCROLLBEG_XTERM;
-      scrollBar.end = R_SCROLLEND_XTERM;
-      scrollBar.update = &rxvt_term::scrollbar_show_plain;
-    }
-#endif
-#if defined(XTERM_SCROLLBAR)
-  if (scrollBar.style == R_SB_XTERM)
-    {
-      scrollBar.beg = R_SCROLLBEG_XTERM;
-      scrollBar.end = R_SCROLLEND_XTERM;
-      scrollBar.update = &rxvt_term::scrollbar_show_xterm;
-    }
-#endif
-#if defined(NEXT_SCROLLBAR)
-  if (scrollBar.style == R_SB_NEXT)
-    {
-      scrollBar.beg = R_SCROLLBEG_NEXT;
-      scrollBar.end = R_SCROLLEND_NEXT;
-      scrollBar.update = &rxvt_term::scrollbar_show_next;
-    }
-#endif
-#if defined(RXVT_SCROLLBAR)
-  if (scrollBar.style == R_SB_RXVT)
-    {
-      scrollBar.beg = R_SCROLLBEG_RXVT;
-      scrollBar.end = R_SCROLLEND_RXVT;
-      scrollBar.update = &rxvt_term::scrollbar_show_rxvt;
-    }
-#endif
+  scrollBar.update_data ();
 
   if (!scrollBar.win)
     {
@@ -256,5 +216,42 @@ scrollBar_t::setup (rxvt_term *term)
   leftptr_cursor = XCreateFontCursor (term->dpy, XC_left_ptr);
 }
 
+void
+scrollBar_t::update_data ()
+{
+#if defined(PLAIN_SCROLLBAR)
+  if (style == R_SB_PLAIN)
+    {
+      beg = 0;
+      end = term->szHint.height;
+      update = &rxvt_term::scrollbar_show_plain;
+    }
+#endif
+#if defined(XTERM_SCROLLBAR)
+  if (style == R_SB_XTERM)
+    {
+      beg = 0;
+      end = term->szHint.height;
+      update = &rxvt_term::scrollbar_show_xterm;
+    }
+#endif
+#if defined(NEXT_SCROLLBAR)
+  if (style == R_SB_NEXT)
+    {
+      beg = 0;
+      end = term->szHint.height - (SB_BUTTON_TOTAL_HEIGHT + SB_PADDING);
+      update = &rxvt_term::scrollbar_show_next;
+    }
+#endif
+#if defined(RXVT_SCROLLBAR)
+  if (style == R_SB_RXVT)
+    {
+      beg = (width + 1) + shadow;
+      end = term->szHint.height - beg - (2 * shadow);
+      update = &rxvt_term::scrollbar_show_rxvt;
+    }
+#endif
+}
+
 /*----------------------- end-of-file (C source) -----------------------*/
 
index 3697da0829a23649cc081379b11f24f3f29470e5..4a2c0773454c30bb39905769a291ad129f53b33c 100644 (file)
@@ -66,6 +66,8 @@ struct scrollBar_t {
   Cursor          leftptr_cursor;
   int             (rxvt_term::*update)(int, int, int, int);
   void setup (rxvt_term *);
+  // update style dependent data
+  void update_data ();
 
   bool upButton (int y)
   {