예제 #1
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
// Set the current position of the display within the document.
// Note that the vertical distance is always positive downwards and the
// horizontal distance is positive to the right.  This means that for a
// mapping mode where the positive Y axis points up (which includes most
// apart from MM_TEXT) then you need to reverse the sign.
void CScrView::SetScroll(CPointAp newpos, BOOL strict /*=FALSE*/)
{
	if (newpos.x < 0) newpos.x = scrollpos_.x;
	if (newpos.y < 0) newpos.y = scrollpos_.y;
	ValidateScroll(newpos, strict);
	update_bars(newpos);
}
예제 #2
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
// Set the size of the document so that we can set up scrollbar range
// Also (optionally) allow "page" and "line" scroll sizes.  If page is
// "null_size" the "page" size is calculated based on the current window
// size.  If line is "null_size" then the "line" size is calculated based
// on the current font.  Note that the "line" (and page) X value refers
// to horizontal scroll measurements (really a column not line).
// Note the top-left of the view always has coordinates (0,0) and all sizes
// and locations use a Y axis which points down and an X axis pointing right.
// These classes are mapping mode safe except for this restriction.  That is,
// you should use logical coords but if the mapping mode has an upwards
// Y axis (as MM_LOENGLISH, MM_HIMETRIC etc) (or a leftwards X axis) then
// the values must be negated.
void CScrView::SetSize(CSizeAp total, CSizeAp page, CSizeAp line)
{
	ASSERT(total.cx >= -1 && total.cy >= -1);
	ASSERT(page.cx >= 0 && page.cy >= 0);
	ASSERT(line.cx >= 0 && line.cy >= 0);

	// Store info about the total doc size.  Also calc. the scrollbar
	// range -- note that the scrollbar range is limited to 32768, plus
	// we need a bit more for when the user scrolls past the end of the
	// document -- so just use a max of 16000 to be safe.
	if (total.cx > -1) total_.cx = total.cx;
	if (total.cy > -1) total_.cy = total.cy;
	maxbar_ = total_;
	if (maxbar_.cx > 16000)
		maxbar_.cx = 16000;
	if (maxbar_.cy > 16000)
		maxbar_.cy = 16000;

	// Store values for amount of scrolling by "page" and "line"
	// -- if not specified (null_size used) then they will be calculated
	// in update_bars().  Also store whether they were specified so that
	// we remember not to recalculate them.
	page_specified_ = page != null_size;
	if (page_specified_) page_ = page;
	line_specified_ = line != null_size;
	if (line_specified_) line_ = line;

	update_bars();
}
예제 #3
0
파일: dawm.c 프로젝트: dstenb/dawm
void
eventloop(void)
{
	XEvent ev;
	struct timeval tv;
	fd_set fds;
	int n;

	tv.tv_sec = BAR_UPDATE_RATE;
	tv.tv_usec = 0;

	for (;;) {
		FD_ZERO(&fds);
		FD_SET(dpy_fd, &fds);

		if ((n = select(dpy_fd + 1, &fds, NULL, NULL, &tv)) < 0) {
			if (errno == EINTR) /* Interrupt during select() */
				continue;
			die("select(): %s\n", strerror(errno));
		} else if (n > 0) {
			while (XPending(dpy)) {
				XNextEvent(dpy, &ev);
				if (event_handler[ev.type])
					event_handler[ev.type](&ev);
			}
		} else {
			/* Bar timer event */
			update_bars();

			tv.tv_sec = BAR_UPDATE_RATE;
			tv.tv_usec = 0;
		}
	}
}
예제 #4
0
파일: event.c 프로젝트: jdarnold/xoat
void configure_notify(XEvent *e)
{
	client *c = window_build_client(e->xconfigure.window);
	if (c && c->manage)
	{
		while (XCheckTypedEvent(display, ConfigureNotify, e));
		ewmh_client_list();
		update_bars();
	}
	client_free(c);
}
예제 #5
0
파일: spot.c 프로젝트: bjauy/xoat
Window spot_try_focus_top_window(int spot, int mon, Window except)
{
	Window w = spot_focus_top_window(spot, mon, except);
	if (w == None)
	{
		current      = None;
		current_mon  = mon;
		current_spot = spot;
		update_bars();

		XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
	}
	return w;
}
예제 #6
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
BOOL CScrView::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)
{
	// Update window and scroll bars if position has changed
	if (bDoScroll)
	{
		// Update scroll bars (using logical coords)
		{
			CClientDC dc(this);
			OnPrepareDC(&dc);
			dc.DPtoLP(&sizeScroll);
		}
		update_bars(scrollpos_ + CSizeAp(sizeScroll));
	}
	return TRUE;
}
예제 #7
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
// Make sure a point (or rectangle) is visible within display (see DisplayCaret).
// If either coord of pos is -1 then no scrolling is done in that direction.
// If size is not specified (or null_size) then only the point pos is made visible.
// Else (size given) pos is made visible and the points below and to the right
// of it as given by size.  If size > display area then pos is made visible and
// as much of the rectangle specified by size as possible given the window size.
void CScrView::DisplayPart(CPointAp pos, CSizeAp size, BOOL show_end /*=false*/)
{
	// If a coord is -1 (or invalid) do not move in that direction
	if (pos.x < 0 || pos.x + size.cx > total_.cx + win_width_)
		pos.x = scrollpos_.x;
	if (pos.y < 0 || pos.y + size.cy > total_.cy + win_height_)
		pos.y = scrollpos_.y;

	CPointAp newpos = scrollpos_;
//    ASSERT(newpos.x >= 0 && newpos.x < total_.cx + win_width_);
//    ASSERT(newpos.y >= 0 && newpos.y < total_.cy + win_height_);

	if (show_end)
	{
		// Move left side then right (this ensures right side is displayed)
		if (newpos.x > pos.x)
			newpos.x = pos.x;
		if (newpos.x + win_width_ < pos.x + size.cx)
			newpos.x = pos.x + size.cx - win_width_;
		// Move top then bottom (ensures bottom of rect is displayed)
		if (newpos.y > pos.y)
			newpos.y = pos.y;
		if (newpos.y + win_height_ < pos.y + size.cy)
			newpos.y = pos.y + size.cy - win_height_;
	}
	else
	{
		// Move right side then left (this order ensures pos.x is displayed)
		if (newpos.x + win_width_ < pos.x + size.cx)
			newpos.x = pos.x + size.cx - win_width_;
		if (newpos.x > pos.x)
			newpos.x = pos.x;
		// Move bottom then top
		if (newpos.y + win_height_ < pos.y + size.cy)
			newpos.y = pos.y + size.cy - win_height_;
		if (newpos.y > pos.y)
			newpos.y = pos.y;
	}

	// If the rect was outside the display then we have to scroll
	if (newpos != scrollpos_)
	{
		ValidateScroll(newpos);
		update_bars(newpos);
	}
}
예제 #8
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
BOOL CScrView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
	CPointAp newpos = scrollpos_;

	switch (LOBYTE(nScrollCode))
	{
	case SB_TOP:
		newpos.x = 0;
		break;
	case SB_BOTTOM:
		newpos.x = total_.cx - win_width_;
		break;
	case SB_LINEUP:
		newpos.x -= line_.cx;
		break;
	case SB_LINEDOWN:
		newpos.x += line_.cx;
		break;
	case SB_PAGEUP:
		newpos.x -= page_.cx;
		break;
	case SB_PAGEDOWN:
		newpos.x += page_.cx;
		break;
	case SB_THUMBPOSITION:
		// DoInvalidate here as this event sent after mouse released after
		// all SB_THUMBTRACK events.  This removes any bits of the scroll-
		// bar left after tracking caused the scroll bar to "evaporate".
		DoInvalidate();
		// fall through
	case SB_THUMBTRACK:
		newpos.x = (int)(((__int64)nPos * total_.cx) / maxbar_.cx);
		if (total_.cx > maxbar_.cx && newpos.x > total_.cx - win_width_)
			newpos.x = total_.cx - win_width_;
		break;
	}

	switch (HIBYTE(nScrollCode))
	{
	case SB_TOP:
		newpos.y = 0;
		break;
	case SB_BOTTOM:
		newpos.y = total_.cy - win_height_;
		break;
	case SB_LINEUP:
		newpos.y -= line_.cy;
		break;
	case SB_LINEDOWN:
		newpos.y += line_.cy;
		break;
	case SB_PAGEUP:
		newpos.y -= page_.cy;
		break;
	case SB_PAGEDOWN:
		newpos.y += page_.cy;
		break;
	case SB_THUMBPOSITION:
		// Invalidate here as this event sent after mouse released after
		// SB_THUMBTRACK events finished.  This removes any bits of the
		// scrollbar left after tracking caused the scroll bar to "evaporate".
		DoInvalidate();
		// fall through
	case SB_THUMBTRACK:
		newpos.y = ((__int64)nPos * total_.cy) / maxbar_.cy;
		if (total_.cy > maxbar_.cy && newpos.y > total_.cy - win_height_)
			newpos.y = total_.cy - win_height_;
		break;
	}

#if 0
	if (bDoScroll)
		ValidateScroll(newpos);
	// Work out amount to scroll (in device coordinates)
	{
		CClientDC dc(this);
		OnPrepareDC(&dc);
		CSize amt = CSize(newpos - scrollpos_); // This won't work
		dc.LPtoDP(&amt);
	}
	BOOL retval = OnScrollBy(amt, bDoScroll);
	if (retval && bDoScroll)
		DoUpdateWindow();

	return retval;
#else
	if (bDoScroll)
	{
		ValidateScroll(newpos);
		update_bars(newpos);
		DoUpdateWindow();
	}
	return TRUE;
#endif
}
예제 #9
0
파일: ScrView.cpp 프로젝트: KB3NZQ/hexedit4
void CScrView::OnSize(UINT nType, int cx, int cy) 
{
		CView::OnSize(nType, cx, cy);
		update_bars();
}