Esempio n. 1
0
bool Rotateable::on_scroll(GdkEventScroll* event)
{
    double change = 0.0;

    if (event->direction == GDK_SCROLL_UP) {
        change = 1.0;
    } else if (event->direction == GDK_SCROLL_DOWN) {
        change = -1.0;
    } else {
        return FALSE;
    }

    drag_started_x = event->x;
    drag_started_y = event->y;
    modifier = get_single_modifier(modifier, event->state);
    dragging = false;
    working = false;
    scrolling = true;
    current_axis = axis;

    do_scroll(change, modifier);

    dragging = false;
    working = false;
    scrolling = false;

    return TRUE;
}
Esempio n. 2
0
void TBScrollBox::scroll_to(DimensionName d, Coord lower) {
    TBScrollBoxImpl& sb = impl();
    GlyphIndex max_end = count();
    GlyphIndex new_end = max_end - Math::round(lower);
    GlyphIndex new_start = new_end - sb.end_ + sb.start_;
    do_scroll(d, new_start, new_end);
}
Esempio n. 3
0
		bool inventory_panel::scroll_control(int delta)
		{
			update();
			if (m_hover.in_range(m_inventory.start, m_inventory.range))
			{
				do_scroll(-delta);
				return true;
			}
			return false;
		}
Esempio n. 4
0
static void scroll_down(WTimer *timer, WMenu *menu)
{
    if(menu!=NULL){
        do_scroll(menu, 0, scrolld_subs(menu, D_DOWN));
        if(scrolld_subs(menu, D_DOWN)>0){
            timer_set(timer, scroll_time, (WTimerHandler*)scroll_down,
                      (Obj*)menu);
            return;
        }
    }
}
Esempio n. 5
0
static void scroll_right(WTimer *timer, WMenu *menu)
{
    if(menu!=NULL){
        do_scroll(menu, scrolld_subs(menu, D_RIGHT), 0);
        if(scrolld_subs(menu, D_RIGHT)>0){
            timer_set(timer, scroll_time, (WTimerHandler*)scroll_right,
                      (Obj*)menu);
            return;
        }
    }
}
Esempio n. 6
0
		bool inventory_panel::key_control(key_t code)
		{
			bool result = true;
			switch (code)
			{
			case key::command_cancel:
				m_scroll = 0;
				disable();
				break;
			case key::move_south:
				do_scroll(1);
				break;
			case key::move_north:
				do_scroll(-1);
				break;
			default:
				result = false;
				break;
			}
			return result;
		}
Esempio n. 7
0
/*
 * Display a menu for choosing among a number of options
 */
int dialog_menu(const char *title, const char *prompt,
                const void *selected, int *s_scroll)
{
	int i, j, x, y, box_x, box_y;
	int height, width, menu_height;
	int key = 0, button = 0, scroll = 0, choice = 0;
	int first_item =  0, max_choice;
	WINDOW *dialog, *menu;

do_resize:
	height = getmaxy(stdscr);
	width = getmaxx(stdscr);
	if (height < 15 || width < 65)
		return -ERRDISPLAYTOOSMALL;

	height -= 4;
	width  -= 5;
	menu_height = height - 10;

	max_choice = MIN(menu_height, item_count());

	/* center dialog box on screen */
	x = (COLS - width) / 2;
	y = (LINES - height) / 2;

	draw_shadow(stdscr, y, x, height, width);

	dialog = newwin(height, width, y, x);
	keypad(dialog, TRUE);

	draw_box(dialog, 0, 0, height, width,
		 dlg.dialog.atr, dlg.border.atr);
	wattrset(dialog, dlg.border.atr);
	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
	for (i = 0; i < width - 2; i++)
		waddch(dialog, ACS_HLINE);
	wattrset(dialog, dlg.dialog.atr);
	wbkgdset(dialog, dlg.dialog.atr & A_COLOR);
	waddch(dialog, ACS_RTEE);

	print_title(dialog, title, width);

	wattrset(dialog, dlg.dialog.atr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);

	menu_width = width - 6;
	box_y = height - menu_height - 5;
	box_x = (width - menu_width) / 2 - 1;

	/* create new window for the menu */
	menu = subwin(dialog, menu_height, menu_width,
		      y + box_y + 1, x + box_x + 1);
	keypad(menu, TRUE);

	/* draw a box around the menu items */
	draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
		 dlg.menubox_border.atr, dlg.menubox.atr);

	if (menu_width >= 80)
		item_x = (menu_width - 70) / 2;
	else
		item_x = 4;

	/* Set choice to default item */
	item_foreach()
		if (selected && (selected == item_data()))
			choice = item_n();
	/* get the saved scroll info */
	scroll = *s_scroll;
	if ((scroll <= choice) && (scroll + max_choice > choice) &&
	   (scroll >= 0) && (scroll + max_choice <= item_count())) {
		first_item = scroll;
		choice = choice - scroll;
	} else {
		scroll = 0;
	}
	if ((choice >= max_choice)) {
		if (choice >= item_count() - max_choice / 2)
			scroll = first_item = item_count() - max_choice;
		else
			scroll = first_item = choice - max_choice / 2;
		choice = choice - scroll;
	}

	/* Print the menu */
	for (i = 0; i < max_choice; i++) {
		print_item(first_item + i, i, i == choice);
	}

	wnoutrefresh(menu);

	print_arrows(dialog, item_count(), scroll,
		     box_y, box_x + item_x + 1, menu_height);

	print_buttons(dialog, height, width, 0);
	wmove(menu, choice, item_x + 1);
	wrefresh(menu);

	while (key != KEY_ESC) {
		key = wgetch(menu);

		if (key < 256 && isalpha(key))
			key = tolower(key);

		if (strchr("ynmh", key))
			i = max_choice;
		else {
			for (i = choice + 1; i < max_choice; i++) {
				item_set(scroll + i);
				j = first_alpha(item_str(), "YyNnMmHh");
				if (key == tolower(item_str()[j]))
					break;
			}
			if (i == max_choice)
				for (i = 0; i < max_choice; i++) {
					item_set(scroll + i);
					j = first_alpha(item_str(), "YyNnMmHh");
					if (key == tolower(item_str()[j]))
						break;
				}
		}

		if (i < max_choice ||
		    key == KEY_UP || key == KEY_DOWN ||
		    key == '-' || key == '+' ||
		    key == KEY_PPAGE || key == KEY_NPAGE) {
			/* Remove highligt of current item */
			print_item(scroll + choice, choice, FALSE);

			if (key == KEY_UP || key == '-') {
				if (choice < 2 && scroll) {
					/* Scroll menu down */
					do_scroll(menu, &scroll, -1);

					print_item(scroll, 0, FALSE);
				} else
					choice = MAX(choice - 1, 0);

			} else if (key == KEY_DOWN || key == '+') {
				print_item(scroll+choice, choice, FALSE);

				if ((choice > max_choice - 3) &&
				    (scroll + max_choice < item_count())) {
					/* Scroll menu up */
					do_scroll(menu, &scroll, 1);

					print_item(scroll+max_choice - 1,
						   max_choice - 1, FALSE);
				} else
					choice = MIN(choice + 1, max_choice - 1);

			} else if (key == KEY_PPAGE) {
				scrollok(menu, TRUE);
				for (i = 0; (i < max_choice); i++) {
					if (scroll > 0) {
						do_scroll(menu, &scroll, -1);
						print_item(scroll, 0, FALSE);
					} else {
						if (choice > 0)
							choice--;
					}
				}

			} else if (key == KEY_NPAGE) {
				for (i = 0; (i < max_choice); i++) {
					if (scroll + max_choice < item_count()) {
						do_scroll(menu, &scroll, 1);
						print_item(scroll+max_choice-1,
							   max_choice - 1, FALSE);
					} else {
						if (choice + 1 < max_choice)
							choice++;
					}
				}
			} else
				choice = i;

			print_item(scroll + choice, choice, TRUE);

			print_arrows(dialog, item_count(), scroll,
				     box_y, box_x + item_x + 1, menu_height);

			wnoutrefresh(dialog);
			wrefresh(menu);

			continue;	/* wait for another key press */
		}

		switch (key) {
		case KEY_LEFT:
		case TAB:
		case KEY_RIGHT:
			button = ((key == KEY_LEFT ? --button : ++button) < 0)
			    ? 2 : (button > 2 ? 0 : button);

			print_buttons(dialog, height, width, button);
			wrefresh(menu);
			break;
		case ' ':
		case 's':
		case 'y':
		case 'n':
		case 'm':
		case '/':
			/* save scroll info */
			*s_scroll = scroll;
			delwin(menu);
			delwin(dialog);
			item_set(scroll + choice);
			item_set_selected(1);
			switch (key) {
			case 's':
				return 3;
			case 'y':
				return 3;
			case 'n':
				return 4;
			case 'm':
				return 5;
			case ' ':
				return 6;
			case '/':
				return 7;
			}
			return 0;
		case 'h':
		case '?':
			button = 2;
		case '\n':
			*s_scroll = scroll;
			delwin(menu);
			delwin(dialog);
			item_set(scroll + choice);
			item_set_selected(1);
			return button;
		case 'e':
		case 'x':
			key = KEY_ESC;
			break;
		case KEY_ESC:
			key = on_key_esc(menu);
			break;
#ifdef NCURSES_VERSION
		case KEY_RESIZE:
			on_key_resize();
			delwin(menu);
			delwin(dialog);
			goto do_resize;
#endif
		}
	}
	delwin(menu);
	delwin(dialog);
	return key;		/* ESC pressed */
}
Esempio n. 8
0
main()
	{
	int	aa,b,c,x,y,f;

	asm	mov	ax, 3
	asm	int	10h

	init();


	while(dis_sync()<1 && !dis_exit());

	prtc(160,120,"A");
	prtc(160,160,"Future Crew");
	prtc(160,200,"Production");
	dofade(fade1,fade2); wait(300); dofade(fade2,fade1); fonapois();

	while(dis_sync()<2 && !dis_exit());

	prtc(160,160,"First Presented");
	prtc(160,200,"at Assembly 93");
	dofade(fade1,fade2); wait(300); dofade(fade2,fade1); fonapois();

	while(dis_sync()<3 && !dis_exit());

	prtc(160,120,"in");
	prtc(160,160,"�");
	prtc(160,179,"�");
	dofade(fade1,fade2); wait(300); dofade(fade2,fade1); fonapois();

	while(dis_sync()<4 && !dis_exit());

	memcpy(fadepal,fade1,768);
	cop_fadepal=picin;
	cop_dofade=128;
	for(a=1,p=1,f=0,frame_count=0;cop_dofade!=0 && !dis_exit();)
		do_scroll(2);

	for(f=60;a<320 && !dis_exit();)
		{
		if(f==0) {
			cop_fadepal=textin;
			cop_dofade=64;
			f+=20;
			}
		else if(f==50) {
			cop_fadepal=textout;
			cop_dofade=64;
			f++;
			}
		else if(f>50 && cop_dofade==0) {
			cop_pal=palette; do_pal=1; f++;
			memset(tbuf,0,186*320);
			switch(tptr++) {
			case 0:
				addtext(160,50,"Graphics");
				addtext(160,90,"Marvel");
				addtext(160,130,"Pixel");	// sucks
				ffonapois();
				break;
			case 1:
				faddtext(160,50,"Music");
				faddtext(160,90,  "Purple Motion");
				faddtext(160,130, "Skaven");
				ffonapois();
				break;
			case 2:
				faddtext(160,30,"Code");
				faddtext(160,70,  "Psi");
				faddtext(160,110, "Trug");
				faddtext(160,148, "Wildfire");
				ffonapois();
				break;
			case 3:
				faddtext(160,50,"Additional Design");
				faddtext(160,90, "Abyss");
//				faddtext(160,110,"Useless Design");
				faddtext(160,130, "Gore");
				ffonapois();
				break;
			case 4:
				ffonapois();
				break;
			default:
				faddtext(160,80, "BUG BUG BUG");
				faddtext(160,130, "Timing error");
				ffonapois();
				break;
				}
			while(((a&1) || dis_sync()<4+tptr) && !dis_exit() && a<319)
				do_scroll(0);
			aa=a;
			if(aa<320-12) fmaketext(aa+16);
			f=0;
			}
		else	f++;
		do_scroll(1);
		}
	if(f>63/SCRLF){
		dofade(palette2,palette);
		}
	fonapois();
	close_copper();
	}
Esempio n. 9
0
void TBScrollBox::scroll_by(DimensionName d, long offset) {
    TBScrollBoxImpl& sb = impl();
    do_scroll(d, sb.start_ + offset, sb.end_ + offset);
}
Esempio n. 10
0
/*
 * Display a menu for choosing among a number of options
 */
int dialog_menu(const char *title, const char *prompt, int height, int width,
		int menu_height, const char *current, int item_no,
		const char *const *items)
{
	int i, j, x, y, box_x, box_y;
	int key = 0, button = 0, scroll = 0, choice = 0;
	int first_item =  0, max_choice;
	WINDOW *dialog, *menu;
	FILE *f;

	max_choice = MIN(menu_height, item_no);

	/* center dialog box on screen */
	x = (COLS - width) / 2;
	y = (LINES - height) / 2;

	draw_shadow(stdscr, y, x, height, width);

	dialog = newwin(height, width, y, x);
	keypad(dialog, TRUE);

	draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
	wattrset(dialog, border_attr);
	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
	for (i = 0; i < width - 2; i++)
		waddch(dialog, ACS_HLINE);
	wattrset(dialog, dialog_attr);
	wbkgdset(dialog, dialog_attr & A_COLOR);
	waddch(dialog, ACS_RTEE);

	print_title(dialog, title, width);

	wattrset(dialog, dialog_attr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);

	menu_width = width - 6;
	box_y = height - menu_height - 5;
	box_x = (width - menu_width) / 2 - 1;

	/* create new window for the menu */
	menu = subwin(dialog, menu_height, menu_width,
		      y + box_y + 1, x + box_x + 1);
	keypad(menu, TRUE);

	/* draw a box around the menu items */
	draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
		 menubox_border_attr, menubox_attr);

	item_x = (menu_width - 70) / 2;

	/* Set choice to default item */
	for (i = 0; i < item_no; i++)
		if (strcmp(current, items[i * 2]) == 0)
			choice = i;

	/* get the scroll info from the temp file */
	if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) {
		if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) &&
		    (scroll + max_choice > choice) && (scroll >= 0) &&
		    (scroll + max_choice <= item_no)) {
			first_item = scroll;
			choice = choice - scroll;
			fclose(f);
		} else {
			scroll = 0;
			remove("lxdialog.scrltmp");
			fclose(f);
			f = NULL;
		}
	}
	if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) {
		if (choice >= item_no - max_choice / 2)
			scroll = first_item = item_no - max_choice;
		else
			scroll = first_item = choice - max_choice / 2;
		choice = choice - scroll;
	}

	/* Print the menu */
	for (i = 0; i < max_choice; i++) {
		print_item(first_item + i, i, i == choice);
	}

	wnoutrefresh(menu);

	print_arrows(dialog, item_no, scroll,
		     box_y, box_x + item_x + 1, menu_height);

	print_buttons(dialog, height, width, 0);
	wmove(menu, choice, item_x + 1);
	wrefresh(menu);

	while (key != ESC) {
		key = wgetch(menu);

		if (key < 256 && isalpha(key))
			key = tolower(key);

		if (strchr("ynmh", key))
			i = max_choice;
		else {
			for (i = choice + 1; i < max_choice; i++) {
				j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh");
				if (key == tolower(items[(scroll + i) * 2 + 1][j]))
					break;
			}
			if (i == max_choice)
				for (i = 0; i < max_choice; i++) {
					j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh");
					if (key == tolower(items[(scroll + i) * 2 + 1][j]))
						break;
				}
		}

		if (i < max_choice ||
		    key == KEY_UP || key == KEY_DOWN ||
		    key == '-' || key == '+' ||
		    key == KEY_PPAGE || key == KEY_NPAGE) {
			/* Remove highligt of current item */
			print_item(scroll + choice, choice, FALSE);

			if (key == KEY_UP || key == '-') {
				if (choice < 2 && scroll) {
					/* Scroll menu down */
					do_scroll(menu, &scroll, -1);

					print_item(scroll, 0, FALSE);
				} else
					choice = MAX(choice - 1, 0);

			} else if (key == KEY_DOWN || key == '+') {
				print_item(scroll+choice, choice, FALSE);

				if ((choice > max_choice - 3) &&
				    (scroll + max_choice < item_no)) {
					/* Scroll menu up */
					do_scroll(menu, &scroll, 1);

					print_item(scroll+max_choice - 1,
						   max_choice - 1, FALSE);
				} else
					choice = MIN(choice + 1, max_choice - 1);

			} else if (key == KEY_PPAGE) {
				scrollok(menu, TRUE);
				for (i = 0; (i < max_choice); i++) {
					if (scroll > 0) {
						do_scroll(menu, &scroll, -1);
						print_item(scroll, 0, FALSE);
					} else {
						if (choice > 0)
							choice--;
					}
				}

			} else if (key == KEY_NPAGE) {
				for (i = 0; (i < max_choice); i++) {
					if (scroll + max_choice < item_no) {
						do_scroll(menu, &scroll, 1);
						print_item(scroll+max_choice-1,
							   max_choice - 1, FALSE);
					} else {
						if (choice + 1 < max_choice)
							choice++;
					}
				}
			} else
				choice = i;

			print_item(scroll + choice, choice, TRUE);

			print_arrows(dialog, item_no, scroll,
				     box_y, box_x + item_x + 1, menu_height);

			wnoutrefresh(dialog);
			wrefresh(menu);

			continue;	/* wait for another key press */
		}

		switch (key) {
		case KEY_LEFT:
		case TAB:
		case KEY_RIGHT:
			button = ((key == KEY_LEFT ? --button : ++button) < 0)
			    ? 2 : (button > 2 ? 0 : button);

			print_buttons(dialog, height, width, button);
			wrefresh(menu);
			break;
		case ' ':
		case 's':
		case 'y':
		case 'n':
		case 'm':
		case '/':
			/* save scroll info */
			if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) {
				fprintf(f, "%d\n", scroll);
				fclose(f);
			}
			delwin(dialog);
			fprintf(stderr, "%s\n", items[(scroll + choice) * 2]);
			switch (key) {
			case 's':
				return 3;
			case 'y':
				return 3;
			case 'n':
				return 4;
			case 'm':
				return 5;
			case ' ':
				return 6;
			case '/':
				return 7;
			}
			return 0;
		case 'h':
		case '?':
			button = 2;
		case '\n':
			delwin(dialog);
			if (button == 2)
				fprintf(stderr, "%s \"%s\"\n",
					items[(scroll + choice) * 2],
					items[(scroll + choice) * 2 + 1] +
					first_alpha(items [(scroll + choice) * 2 + 1], ""));
			else
				fprintf(stderr, "%s\n",
					items[(scroll + choice) * 2]);

			remove("lxdialog.scrltmp");
			return button;
		case 'e':
		case 'x':
			key = ESC;
		case ESC:
			break;
		}
	}

	delwin(dialog);
	remove("lxdialog.scrltmp");
	return -1;		/* ESC presgsed */
}