NSRect r, v;
struct frame *f = XFRAME (WINDOW_FRAME (window));
EmacsView *view = FRAME_NS_VIEW (f);
- int window_y, window_height;
- int top, left, height, width, sb_width, sb_left;
EmacsScroller *bar;
- BOOL fringe_extended_p;
+ int window_y, window_height;
+ int top, left, height, width;
+ BOOL update_p = YES;
/* optimization; display engine sends WAY too many of these.. */
if (!NILP (window->vertical_scroll_bar))
if (FRAME_LIVE_P (f) && !NSEqualRects (oldRect, r))
{
if (oldRect.origin.x != r.origin.x)
- ns_clear_frame_area (f, sb_left, top, width, height);
+ ns_clear_frame_area (f, left, top, width, height);
+ [bar setFrame: r];
+ }
+ }
+
+ [bar setPosition: position portion: portion whole: whole];
+ unblock_input ();
+}
+
+
+static void
+ns_set_horizontal_scroll_bar (struct window *window,
+ int portion, int whole, int position)
+/* --------------------------------------------------------------------------
+ External (hook): Update or add scrollbar
+ -------------------------------------------------------------------------- */
+{
+ Lisp_Object win;
+ NSRect r, v;
+ struct frame *f = XFRAME (WINDOW_FRAME (window));
+ EmacsView *view = FRAME_NS_VIEW (f);
+ EmacsScroller *bar;
+ int top, height, left, width;
+ int window_x, window_width;
+ int pixel_width = WINDOW_PIXEL_WIDTH (window);
+
+ /* optimization; display engine sends WAY too many of these.. */
+ if (!NILP (window->horizontal_scroll_bar))
+ {
+ bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar);
+ if ([bar checkSamePosition: position portion: portion whole: whole])
+ {
+ if (view->scrollbarsNeedingUpdate == 0)
+ {
+ if (!windows_or_buffers_changed)
+ return;
+ }
+ else
+ view->scrollbarsNeedingUpdate--;
+ }
+ }
+
+ NSTRACE (ns_set_horizontal_scroll_bar);
+
+ /* Get dimensions. */
+ window_box (window, ANY_AREA, 0, &window_x, &window_width, 0);
+ left = window_x;
+ width = window_width;
+ height = WINDOW_CONFIG_SCROLL_BAR_LINES (window) * FRAME_LINE_HEIGHT (f);
+ top = WINDOW_SCROLL_BAR_AREA_Y (window);
+
+ r = NSMakeRect (left, top, width, height);
+ /* the parent view is flipped, so we need to flip y value */
+ v = [view frame];
+ /* ??????? PXW/scrollbars !!!!!!!!!!!!!!!!!!!! */
+ r.origin.y = (v.size.height - r.size.height - r.origin.y);
+
+ XSETWINDOW (win, window);
+ block_input ();
+
+ if (WINDOW_TOTAL_COLS (window) < 5)
+ {
+ if (!NILP (window->horizontal_scroll_bar))
+ {
+ bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar);
+ [bar removeFromSuperview];
+ wset_horizontal_scroll_bar (window, Qnil);
+ }
+ ns_clear_frame_area (f, left, top, width, height);
+ unblock_input ();
+ return;
+ }
+
+ if (NILP (window->horizontal_scroll_bar))
+ {
+ if (width > 0 && height > 0)
+ ns_clear_frame_area (f, left, top, width, height);
+
+ bar = [[EmacsScroller alloc] initFrame: r window: win];
+ wset_horizontal_scroll_bar (window, make_save_ptr (bar));
+ }
+ else
+ {
+ NSRect oldRect;
+ bar = XNS_SCROLL_BAR (window->horizontal_scroll_bar);
+ oldRect = [bar frame];
+ r.size.width = oldRect.size.width;
+ if (FRAME_LIVE_P (f) && !NSEqualRects (oldRect, r))
+ {
+ if (oldRect.origin.x != r.origin.x)
+ ns_clear_frame_area (f, left, top, width, height);
[bar setFrame: r];
+ update_p = YES;
}
}