예제 #1
0
void UI_WINDOW::destroy()
{
	UI_GADGET *cur;
	int idx;

	// free up any bitmaps
	release_bitmaps();

	// destroy all gadgets
	if (first_gadget) {
		cur = first_gadget;
		do {
			cur->destroy();
			cur = cur->next;

		} while (cur != first_gadget);
	}

	// free up all xstrs
	for(idx=0; idx<MAX_UI_XSTRS; idx++){
		// free up this struct
		if(xstrs[idx] != NULL){
			if(xstrs[idx]->xstr != NULL){
				// This const_cast is safe since the string was allocated by vm_strdup
				vm_free(const_cast<char*>(xstrs[idx]->xstr));
			}
			vm_free(xstrs[idx]);
			xstrs[idx] = NULL;
		}
	}
}
예제 #2
0
void UI_WINDOW::destroy()
{
	UI_GADGET* cur;
	int idx;

	// free up any bitmaps
	release_bitmaps();

	// destroy all gadgets
	if (first_gadget)
	{
		cur = first_gadget;
		do
		{
			cur->destroy();
			cur = cur->next;

		} while (cur != first_gadget);
	}

	// free up all xstrs
	for (idx = 0; idx < MAX_UI_XSTRS; idx++)
	{
		// free up this struct
		if (xstrs[idx] != NULL)
		{
			if (xstrs[idx]->xstr != NULL)
			{
				vm_free(xstrs[idx]->xstr);
			}
			vm_free(xstrs[idx]);
			xstrs[idx] = NULL;
		}
	}
}
예제 #3
0
// key_in: If not -1, this means to use this key as input, and not call game_poll()
int UI_WINDOW::process(int key_in,int process_mouse)
{
	UI_GADGET *tmp;

	// only does stuff in non THREADED mode
	os_poll();

	if (process_mouse){
		ui_mouse_process();
	}

	if (key_in == -1){
		keypress = game_check_key();
	} else {
		keypress = key_in;
	}

	last_keypress = keypress;
	do_dump_check();
	if (mouse_captured_gadget && B1_RELEASED){
		mouse_captured_gadget = NULL;
	}

	// The following code was commented out by NeilK on 4/15/99 to fix a problem we were having with
	//	the UI_SLIDER2 class not receiving the process event when the mouse was dragging the scroller
	// but outside the mask region. I checked a handful of other screens and so no adverse affects
	// of this change at the time.

/*
	if (mouse_captured_gadget) {
		mouse_captured_gadget->process();  // if a control has captured the mouse, only it gets processed
		use_hack_to_get_around_stupid_problem_flag = 0;
		return last_keypress;
	}
*/
	if (!first_gadget) {
		use_hack_to_get_around_stupid_problem_flag = 0;
		return last_keypress;
	}

	check_focus_switch_keys();

	// run through all top level gadgets and process them (they are responsible for processing
	// their children, which UI_GADGET will handle if you don't override process() or if you
	// do, you call UI_GADGET::process()).
	if ( !ignore_gadgets ) {
		tmp = first_gadget;
		do	{
			if ( !tmp->check_move() )
				tmp->process();

			tmp = tmp->next;

		} while (tmp != first_gadget);
	}

	use_hack_to_get_around_stupid_problem_flag = 0;
	return last_keypress;
}
예제 #4
0
void UI_WINDOW::draw()
{
	UI_GADGET *tmp;

	gr_reset_clip();
	font::set_font(f_id);

	if (foreground_bmap_id >= 0) {
		gr_set_bitmap(foreground_bmap_id);
		gr_bitmap(x, y, GR_RESIZE_MENU);
	}

	if (flags & WIN_FILLED)	{
		ui_draw_box_out(x, y, x+w-1, y+h-1);
	}

	if (flags & WIN_BORDER)	{
		ui_draw_frame(x-BORDER_WIDTH, y-BORDER_WIDTH, x+w+BORDER_WIDTH-1, y+h+BORDER_WIDTH-1);
	}

	if (first_gadget) {
		tmp = first_gadget;
		do	{
			if (!tmp->hidden)
				tmp->draw();

			tmp = tmp->next;

		} while (tmp != first_gadget);
	}

	if (first_gadget) {
		tmp = first_gadget;
		do	{
			if (!tmp->hidden && (tmp->kind == UI_KIND_BUTTON) && ((UI_BUTTON *) tmp)->button_down()){
				tmp->draw();
			}

			tmp = tmp->next;
		} while (tmp != first_gadget);
	}

	// draw all xstrs
	draw_xstrs();

	// draw tooltips
	draw_tooltip();

	// convenient debug code for showing mouse coords
	if(Cmdline_mouse_coords){
		int mx, my;
		mouse_get_pos(&mx, &my);
		// mprintf(("MOUSE (%d, %d)\n", mx, my));					
		gr_set_color_fast(&Color_normal);
		gr_printf_no_resize(mx, my - 12, "%d %d", mx, my);
	}	
}
예제 #5
0
void UI_GADGET::stop_drag_with_children()
{
	UI_GADGET *tmp;

	base_dragging = 0;
	tmp = children;
	if (tmp) {
		do {
			tmp->stop_drag_with_children();
			tmp = tmp->next;

		} while (tmp != children);
	}
}
예제 #6
0
void UI_GADGET::drag_with_children( int dx, int dy )
{
	UI_GADGET *tmp;

	x = dx + base_start_x;
	y = dy + base_start_y;
	
	tmp = children;
	if (tmp) {
		do {
			tmp->drag_with_children(dx, dy);
			tmp = tmp->next;

		} while (tmp != children);
	}
}
예제 #7
0
// Call process() for all children of gadget.  As a base gadget for all other gadget types,
// it doesn't actually do anything for itself.
//
void UI_GADGET::process(int focus)
{
	UI_GADGET *tmp;

	if (disabled_flag)
		return;

	tmp = children;  // process all children of gadget
	if (tmp) {
		do {
			tmp->process();
			tmp = tmp->next;

		} while (tmp != children);
	}
}
예제 #8
0
void UI_GADGET::start_drag_with_children()
{
	UI_GADGET *tmp;

	base_dragging = 1;
	base_start_x = x;
	base_start_y = y;
	
	tmp = children;
	if (tmp) {
		do {
			tmp->start_drag_with_children();
			tmp = tmp->next;

		} while (tmp != children);
	}
}
예제 #9
0
// Handle drawing of all children of the gadget.  Since this the base of all other gadgets,
// it doesn't have any look to it (kind of like a soul.  Can you see someone's soul?) and thus
// doesn't actually render itself.
//
void UI_GADGET::draw()
{
	UI_GADGET *cur;

	// if hidden, hide children as well
	if (hidden){
		return;
	}

	if (children) {
		cur = children;
		do {
			cur->draw();
			cur = cur->next;

		} while (cur != children);
	}
}
예제 #10
0
// check if mouse is over any child of this gadget
//
int UI_GADGET::is_mouse_on_children()
{
	UI_GADGET *tmp;
	
	tmp = children;
	if (tmp) {
		do {
			if (tmp->is_mouse_on())
				return 1;
			if (tmp->is_mouse_on_children())
				return 1;

			tmp = tmp->next;

		} while (tmp != children);
	}

	return 0;	
}
예제 #11
0
//	Free up bitmaps used by the gadget, and call children to destroy themselves as well.
//
void UI_GADGET::destroy()
{
	int i;
	UI_GADGET *cur;

	for ( i=0; i<m_num_frames; i++ ) {
		if (bmap_ids[i] != -1) {
			bm_release(bmap_ids[i]);
			bmap_ids[i] = -1;
		}
	}

	if (children) {
		cur = children;
		do {
			cur->destroy();
			cur = cur->next;

		} while (cur != children);
	}
}
예제 #12
0
//	Free up bitmaps used by the gadget, and call children to destroy themselves as well.
//
void UI_GADGET::destroy()
{
	int i;
	UI_GADGET *cur;

	for ( i=0; i<m_num_frames; i++ ) {
		if (bmap_ids[i] != -1) {
			// we need to unload here rather than release since some controls
			// may still need access to the bitmap slot.  if it can be released
			// then the child should do it - taylor
			bm_unload(bmap_ids[i]);
			bmap_ids[i] = -1;
		}
	}

	if (children) {
		cur = children;
		do {
			cur->destroy();
			cur = cur->next;

		} while (cur != children);
	}
}
예제 #13
0
void UI_WINDOW::draw_tooltip()
{
	// int i;
	// tooltip_group *ptr;
	int hotspot;	
	UI_GADGET *gadget;

	if (tt_group < 0)
		return;

	// ptr = &Tooltip_groups[tt_group];
	hotspot = get_current_hotspot();

//	mprintf(("HOTSPOT: %d [%d]\n",hotspot, Framecount));

	/*
	if (hotspot != last_tooltip_hotspot) {
		last_tooltip_hotspot = hotspot;
		last_tooltip_time = timer_get_milliseconds();
		ttx = tty = -1;
		return;

	} else if (timer_get_milliseconds() - last_tooltip_time < TOOLTIP_DELAY)
		return;
	*/

	if (first_gadget) {
		gadget = first_gadget;
		do	{
			if (gadget->get_hotspot() == hotspot) {
				if (gadget->hidden)  // if control is hidden, don't draw tooltip for it.
					return;
				else
					break;
			}

			gadget = gadget->next;

		} while (gadget != first_gadget);
	}

	/*
	for (i=ptr->start; i<ptr->end; i++) {
		if (Tooltips[i].hotspot == hotspot) {
			char *str;
			int w, h;

			str = Tooltips[i].text;
			if (str[0] == '@') {
				if (!tooltip_handler)
					Error(LOCATION, "No tooltip handler for screen with mask \"%s\"", ptr->mask);

				str = (*tooltip_handler)(str);  // Let the screen handle the custom tooltips
				if (!str)
					return;
			}

			if (ttx < 0 || tty < 0) {
				gr_get_string_size(&w, &h, str);
				Assert(w < 320 && h < 100);
				ttx = ui_mouse.x - w / 2;
				tty = ui_mouse.y - h;
			}

			render_tooltip(str);
		}
	}
	*/
}