示例#1
0
static void
handle_motion_event(XMotionEvent *event)
{
    if (!gWindow)
        return;
    if (findButtonInList(gWindow, event->x, event->y) != NULL)
        change_cursor(gActiveCursor, gWindow);
    else
        change_cursor(gNormalCursor, gWindow);
}
示例#2
0
static void
init_cursor_state(HDWindow *window)
{
    if (window) {
        int x, y, rx, ry, but;
        Window r, c;

        XQueryPointer(gXDisplay, window->fMainWindow,
                             &r, &c, &rx, &ry, &x, &y,(unsigned int *) &but);
        if (findButtonInList(window, x, y) != NULL)
            change_cursor(gActiveCursor, window);
        else
            change_cursor(gNormalCursor, window);
    }
}
示例#3
0
BOOL HistoInit()
/************************************************************************/
    {
    LPFRAME lpFrame;
    int x, y, i;
    LPTR lpLine;
    RGBS rgb;
    
    lpFrame = frame_set(NULL);
    if (!lpFrame)
        return(FALSE);
    lpRHisto = AllocPtr(256 * sizeof(long));
    lpGHisto = AllocPtr(256 * sizeof(long));
    lpBHisto = AllocPtr(256 * sizeof(long));
    if (!lpRHisto || !lpGHisto || !lpBHisto)
        {
        HistoDone();
        return(FALSE);
        }
    clr(lpRHisto, 256 * sizeof(long));
    clr(lpGHisto, 256 * sizeof(long));
    clr(lpBHisto, 256 * sizeof(long));
    
    AstralWaitCursor();
    for (y = 0; y < lpFrame->Ysize; ++y)
        {
        AstralClockCursor(y, lpFrame->Ysize, TRUE);
        lpLine = CachePtr(0, 0, y, NO);
        for (x = 0; x < lpFrame->Xsize; ++x, lpLine += DEPTH)
            {
            frame_getRGB( lpLine, &rgb );
            ++lpRHisto[rgb.red];
            ++lpGHisto[rgb.green];
            ++lpBHisto[rgb.blue];
            }
        }
    change_cursor(0);
    TotalHisto = (long)lpFrame->Ysize * (long)lpFrame->Xsize;
    MaxHisto = 0;
    for (i = 0; i < 256; ++i)
        {
        if (lpRHisto[i] > MaxHisto)
            MaxHisto = lpRHisto[i];
        if (lpGHisto[i] > MaxHisto)
            MaxHisto = lpGHisto[i];
        if (lpBHisto[i] > MaxHisto)
            MaxHisto = lpBHisto[i];
        }
    for (i = 0; i < 8; ++i)
        grayPat[i] = (i & 1) ? 0x55 : 0xAA;
        
    for (i = 0; i < QTONEPOINTS; ++i)
        QTone.QTmoved[i] = NO;
    MapInit();
    QTone.ActiveMark = 0;
    HistoValue = PNTX(QT(QTone.ActiveMark));
    
    return(TRUE);
    }
示例#4
0
void draw_scene()
{
	CHECK_GL_ERRORS();

	glClearColor(skybox_fog_color[0], skybox_fog_color[1], skybox_fog_color[2], 0.0);

	if(!shadows_on || !have_stencil)glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
	else glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);

	if (!have_display)
	{
		new_zoom_level = zoom_level;	// No scrolling when switching modes...
		if (quickbar_relocatable && quickbar_win >= 0) // Hack 
		{
			if (get_show_window (quickbar_win) && windows_list.window[quickbar_win].cur_x < window_width - hud_x && window_height - windows_list.window[quickbar_win].cur_y > hud_y)
				hide_window (quickbar_win);
		}
	}

	glLoadIdentity ();	// Reset The Matrix
	
	Enter2DMode ();
	display_windows (1);

	// Have to draw the dragged item *after* all windows
	
	glColor3f(1.0f,1.0f,1.0f);
	if (item_dragged != -1)
		drag_item (item_dragged, 0, 0);
	else if (use_item != -1 && current_cursor == CURSOR_USE_WITEM)
		drag_item (use_item, 0, 1);
	else if (storage_item_dragged != -1) 
		drag_item (storage_item_dragged, 1, 0);
	draw_special_cursors();

	Leave2DMode ();

	if(elwin_mouse >= 0)
	{
		if (current_cursor != elwin_mouse) change_cursor(elwin_mouse);
		elwin_mouse = -1;
	}
	
	SDL_GL_SwapBuffers();
	CHECK_GL_ERRORS();
	
	/* start or stop the harvesting effect depending on harvesting state */
	check_harvesting_effect();
	
	if (draw_delay > 0)
	{
		SDL_Delay (draw_delay);
		draw_delay = 0;
	}
}
示例#5
0
static void
make_busy_cursor(HDWindow *window)
{
    change_cursor(gBusyCursor, window);
}
示例#6
0
void Handle_One_Event() {
	static const long twentyTicks = time_in_ticks(20).asMilliseconds();
	static const long fortyTicks = time_in_ticks(40).asMilliseconds();
	
	through_sending();
	Handle_Update();
	
	//(cur_time - last_anim_time > 42)
	if((animTimer.getElapsedTime().asMilliseconds() >= fortyTicks) && (overall_mode != MODE_STARTUP) && (anim_onscreen) && get_bool_pref("DrawTerrainAnimation", true)
	   && (!gInBackground)) {
		animTimer.restart();
		draw_terrain();
	}
	if((animTimer.getElapsedTime().asMilliseconds() > twentyTicks) && (overall_mode == MODE_STARTUP)) {
		animTimer.restart();
		draw_startup_anim(true);
	}
	
	clear_sound_memory();
	
	if(map_visible && mini_map.pollEvent(event)){
		if(event.type == sf::Event::Closed) {
			mini_map.setVisible(false);
			map_visible = false;
		} else if(event.type == sf::Event::GainedFocus)
			makeFrontWindow(mainPtr);
	}
	if(!mainPtr.pollEvent(event)) {
		if(changed_display_mode) {
			changed_display_mode = false;
			adjust_window_mode();
		}
		flushingInput = false;
		redraw_screen(REFRESH_NONE);
		return;
	}
	switch(event.type) {
		case sf::Event::KeyPressed:
			if(flushingInput) return;
			if(!(event.key.*systemKey))
				handle_keystroke(event);
			
			break;
			
		case sf::Event::MouseButtonPressed:
			if(flushingInput) return;
			Mouse_Pressed();
			break;
			
		case sf::Event::MouseLeft:
			// Make sure we don't have an arrow cursor when it's outside the window
			make_cursor_sword();
			break;
			
		case sf::Event::GainedFocus:
			Handle_Update();
			makeFrontWindow(mainPtr);
		case sf::Event::MouseMoved:
			if(!gInBackground) {
				location where(event.mouseMove.x, event.mouseMove.y);
				change_cursor(where);
			}
			break;
			
		case sf::Event::MouseWheelMoved:
			if(flushingInput) return;
			handle_scroll(event);
			break;
			
		case sf::Event::Closed:
			if(overall_mode == MODE_STARTUP) {
				if(party_in_memory) {
					std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
					if(choice == "cancel") break;
					if(choice == "save") {
						fs::path file = nav_put_party();
						if(!file.empty()) break;
						save_party(file, univ);
					}
				}
				All_Done = true;
				break;
			}
			if(overall_mode > MODE_TOWN){
				std::string choice = cChoiceDlog("quit-confirm-nosave", {"quit", "cancel"}).show();
				if(choice == "cancel")
					break;
			}
			else {
				std::string choice = cChoiceDlog("quit-confirm-save", {"save", "quit", "cancel"}).show();
				if(choice == "cancel")
					break;
				if(choice == "save")
					save_party(univ.file, univ);
			}
			All_Done = true;
		default:
			break; // There's several events we don't need to handle at all
	}
	flushingInput = false; // TODO: Could there be a case when the key and mouse input that needs to be flushed has other events interspersed?
}
示例#7
0
int switch_to_game_map()
{
#ifdef	NEW_TEXTURES
	char buffer[1024];
#else	/* NEW_TEXTURES */
	int len;
	texture_cache_struct tex;
#endif	/* NEW_TEXTURES */
	short int cur_cont;
	static short int old_cont = -1;
	
	/* check we loaded the mapinfo data */
	if (continent_maps == NULL || continent_maps[0].name == NULL)
	{
		LOG_TO_CONSOLE(c_yellow2,err_nomap_str);
		return 0;
	}
	
#ifdef	NEW_TEXTURES
	if (check_image_name(map_file_name, sizeof(buffer), buffer) == 1)
	{
		map_text = load_texture_cached(buffer, tt_image);
	}
	else
	{
		map_text = 0;
	}
#else	/* NEW_TEXTURES */
	my_strcp(tex.file_name,map_file_name);
	len=strlen(tex.file_name);
	tex.file_name[len-3]='b';
	tex.file_name[len-2]='m';
	tex.file_name[len-1]='p';
	tex.alpha = 128;
	if (!el_file_exists(tex.file_name))
		map_text = 0;
	else
		map_text=load_bmp8_fixed_alpha(&tex, tex.alpha);
#endif	/* NEW_TEXTURES */
	if(!map_text)
	{
		LOG_TO_CONSOLE(c_yellow2,err_nomap_str);
		return 0;
	}
	
	if (cur_map < 0)
	{
		cur_cont = -1;
	}
	else
	{
		cur_cont = continent_maps[cur_map].cont;
	}
	if (cur_cont != old_cont && cur_cont >= 0 && cur_cont < nr_continents)
	{
#ifdef	NEW_TEXTURES
		cont_text = load_texture_cached (cont_map_file_names[cur_cont], tt_image);
#else	/* NEW_TEXTURES */
		cont_text = load_texture_cache (cont_map_file_names[cur_cont], 128);
#endif	/* NEW_TEXTURES */
		old_cont = cur_cont;
	}
#ifdef DEBUG_MAP_SOUND
	cur_tab_map = cur_map;
#endif // DEBUG_MAP_SOUND
	
	if(current_cursor != CURSOR_ARROW)
	{
		change_cursor(CURSOR_ARROW);
	}
	return 1;
}
示例#8
0
文件: boe.main.cpp 项目: Ircher/CBoE
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PAINTSTRUCT ps;
    POINT press;
    HMENU menu;
    RECT dlg_rect;
    RECT wind_rect;

    short handled = 0;
    short store_ulx;
    short store_uly;
    short sbar_pos;
    short which_sbar;
    short old_setting;
    short smin;
    short smax;

// First, handle window size
    GetWindowRect(mainPtr,&wind_rect);

    switch (display_mode) { //case 0 is center
    case 1:
        store_ulx = 0;
        store_uly = 0;
        break;
    case 2:
        store_ulx = wind_rect.right - 550 - 21;
        store_uly = 0;
        break;
    case 3:
        store_ulx = 0;
        store_uly = wind_rect.bottom - 422 - 24 - 21;
        break;
    case 4:
        store_ulx = wind_rect.right - 550 - 21;
        store_uly = wind_rect.bottom - 422 - 24 - 21;
        break;
    case 5:
        store_ulx = 0;
        store_uly = 0;
        break;
    default:
        store_ulx = ((wind_rect.right - wind_rect.left) - 536) / 2 - 30;
        store_uly = ((wind_rect.bottom - wind_rect.top) - 478) / 2 + 8;
        break;
    }

    store_ulx -= store_ulx % 8;
    store_uly -= store_uly % 8;

    if ((store_ulx != ulx) || (store_uly != uly))
    {
        ulx = store_ulx;
        uly = store_uly;
        adjust_window_mode();
    }

    switch (message) {
    case WM_KEYDOWN:
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            cursor_go();
            All_Done = handle_syskeystroke(wParam,lParam,&handled);
            check_game_done();
        }
        if (handled == 1)
            FlushEvents(0);

        return 0;

    case WM_CHAR:
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            cursor_go();
            All_Done = handle_keystroke(wParam,lParam);
            check_game_done();
        }
        return 0;

    case WM_LBUTTONDOWN:
        cursor_stay();
        if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam);
        else {
            SetFocus(hwnd);
            press = MAKEPOINT(lParam);
            if (in_startup_mode == false)
                All_Done = handle_action(press, wParam,lParam);
            else 	All_Done = handle_startup_press(press);
            change_cursor(press);
            check_game_done();
        }
        return 0;
        break;

    case WM_RBUTTONDOWN:
        cursor_stay();
        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            SetFocus(hwnd);
            press = MAKEPOINT(lParam);
            if (in_startup_mode == false)
                All_Done = handle_action(press, wParam,-2);
            else All_Done = handle_startup_press(press);
            change_cursor(press);
            check_game_done();
        }
        return 0;
        break;

    case WM_ACTIVATE:
        if (hwnd == mainPtr)
        {
            WORD fActive = LOWORD(wParam);

            if ((fActive == WA_ACTIVE) ||(fActive == WA_CLICKACTIVE))
            {
                window_in_front = true;
                GetClientRect(hwnd,&dlg_rect);
                InvalidateRect(hwnd,&dlg_rect,false);
            }

            if (fActive == WA_INACTIVE)
            {
                cursor_stay();
                anim_onscreen = false;
                window_in_front = false;
            }
        }
        return 0;

    case WM_ERASEBKGND:
        if (hwnd != mainPtr) break;
        block_erase = false;
        return 1;

    case WM_MOUSEMOVE:
        if (store_mouse != lParam) cursor_stay();
        store_mouse = lParam;
        press = MAKEPOINT(lParam);
        if (hwnd == mainPtr) {
            change_cursor(press);
            if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING))
                draw_targeting_line(press);
        }
        return 0;

    case WM_PAINT:
        if ((block_erase == true) && (hwnd == mainPtr)) {
            block_erase = false;
        }
        BeginPaint(hwnd,&ps);
        EndPaint(hwnd,&ps);

        if (hwnd != mainPtr)
            check_cd_event(hwnd,message,wParam,lParam);
        else {
            string_added = true;
            reset_text_bar();
            if (in_startup_mode == true) draw_startup(0);
            else if (first_update == true)
            {
                first_update = false;
                if (overall_mode == MODE_OUTDOORS) redraw_screen(0);
                if ((overall_mode > MODE_OUTDOORS) & (overall_mode < MODE_COMBAT)) redraw_screen(1);
                // 1st update never combat
            }
            else refresh_screen(overall_mode);
        }
        return 0;

    case WM_TIMER:
        switch(wParam) {
        case 1:
            if ((in_startup_mode == false) && (anim_onscreen == true)
                    && (window_in_front == true) && (give_delays == false)) {
                if(PSD[SDF_NO_TER_ANIM] != 1)
                    anim_ticks++;
                initiate_redraw();
            }
            break;
        case 2:
            if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING)) {
                GetCursorPos(&press);
                press.x -= wind_rect.left + 3;
                press.y -= wind_rect.top + 41;
                draw_targeting_line(press);
            }
            if ((in_startup_mode == true) && (window_in_front == true))
                draw_startup_anim();
            break;
        }
        return 0;

    case WM_COMMAND:    // 1006 is dummy event
        // creation events 2000 spend xp 2001 pick graphic 2002 finish up
        if (hwnd == mainPtr) {
            menu = GetMenu(mainPtr);
            All_Done = handle_menu((short) LOWORD(wParam), menu);
            check_game_done();
        }
        else check_cd_event(hwnd,message,wParam,lParam);

        return 0;

    case WM_VSCROLL:
        which_sbar = GetWindowLong((HWND) lParam, GWL_ID);
        switch (which_sbar) {// 1 text  2 items  3 shop
        case 1:
            sbar_pos = GetScrollPos(text_sbar,SB_CTL);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += 11;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= 11;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = 57;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > 58) sbar_pos = 58;
            {
//				SetScrollPos(text_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(text_sbar,SB_CTL,&lpsi,true);
            }
            string_added = true;
            print_buf();
            break;
        case 2:
            old_setting = sbar_pos = GetScrollPos(item_sbar,SB_CTL);
            GetScrollRange(item_sbar,SB_CTL,(int *) &smin,(int *) &smax);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += (stat_window == 7) ? 2 : 8;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= (stat_window == 7) ? 2 : 8;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = smax;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > smax) sbar_pos = smax;
            {
//				SetScrollPos(item_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(item_sbar,SB_CTL,&lpsi,true);
            }
            if (sbar_pos != old_setting)
                put_item_screen(stat_window,1);
            break;
        case 3:
            old_setting = sbar_pos = GetScrollPos(shop_sbar,SB_CTL);
            GetScrollRange(shop_sbar,SB_CTL,(int *) &smin,(int *) &smax);
            switch (wParam ) {
            case SB_PAGEDOWN:
                sbar_pos += 8;
                break;
            case SB_LINEDOWN:
                sbar_pos++;
                break;
            case SB_PAGEUP:
                sbar_pos -= 8;
                break;
            case SB_LINEUP:
                sbar_pos--;
                break;
            case SB_TOP:
                sbar_pos = 0;
                break;
            case SB_BOTTOM:
                sbar_pos = smax;
                break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK:
                sbar_pos = LOWORD(lParam);
                break;
            }
            if (sbar_pos < 0) sbar_pos = 0;
            if (sbar_pos > smax) sbar_pos = smax;
            {
//				SetScrollPos(shop_sbar,SB_CTL,sbar_pos,true);
                lpsi.nPos = sbar_pos;
                lpsi.fMask = SIF_POS;
                SetScrollInfo(shop_sbar,SB_CTL,&lpsi,true);
            }
            if (sbar_pos != old_setting)
                draw_shop_graphics(0,shop_sbar_rect);
            break;
        }

        SetFocus(mainPtr);
        return 0;

    case WM_DESTROY:
    case WM_CLOSE:
        if (hwnd == mainPtr)
        {
            lose_graphics();
            PostQuitMessage(0);
        }
        return 0;
    case WM_QUIT:
        if (hwnd == mainPtr)
            lose_graphics();
        break;
    }

    return DefWindowProc(hwnd,message,wParam,lParam);
}
示例#9
0
void draw_scene()
{
	CHECK_GL_ERRORS();

	glClearColor(skybox_fog_color[0], skybox_fog_color[1], skybox_fog_color[2], 0.0);

	if(!shadows_on || !have_stencil)glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
	else glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);

	if (!have_display)
	{
		// No scrolling when switching modes...
		new_zoom_level = zoom_level;
		// Hide the moveable hud windows if they are not on the bottom or side hud bar
		hide_moved_hud_windows();
	}

	glLoadIdentity ();	// Reset The Matrix
	
	Enter2DMode ();
	display_windows (1);

	// Have to draw the dragged item *after* all windows
	
	glColor3f(1.0f,1.0f,1.0f);
	if (item_dragged != -1)
		drag_item (item_dragged, 0, 0);
	else if (use_item != -1 && current_cursor == CURSOR_USE_WITEM)
		drag_item (use_item, 0, 1);
	else if (storage_item_dragged != -1) 
		drag_item (storage_item_dragged, 1, 0);
	draw_special_cursors();

	Leave2DMode ();

	if(elwin_mouse >= 0)
	{
		if (current_cursor != elwin_mouse) change_cursor(elwin_mouse);
		elwin_mouse = -1;
	}
	
	SDL_GL_SwapBuffers();
	CHECK_GL_ERRORS();

	/* stuff to do not every frame, twice a second is fine */
	{
		static Uint32 last_half_second_timer = 0;
		static int first_time = 1;
		Uint32 current_time = SDL_GetTicks();
		if (first_time)
		{
			last_half_second_timer = current_time;
			first_time = 0;
		}
		if ((current_time - last_half_second_timer) > 500u)
		{
			/* start or stop the harvesting effect depending on harvesting state */
			check_harvesting_effect();
			/* check for and possibly do auto save */
			auto_save_local_and_server();
			/* action on afk state changes */
			check_afk_state();
			/* the timer in the hud */
			update_hud_timer();
			/* check if we need to do buff duration requests */
			check_then_do_buff_duration_request();
			/* check if we are doing a server connection test */
			check_if_testing_server_connection();
			/* until next time */
			last_half_second_timer = current_time;
		}
	}

	if (draw_delay > 0)
	{
		SDL_Delay (draw_delay);
		draw_delay = 0;
	}
}
示例#10
0
void init_stuff()
{
	int seed;

	Uint32 (*my_timer_pointer) (unsigned int) = my_timer;

	//TODO: process command line options
	chdir(datadir);

	//Initialize all strings
	init_translatables();

#ifdef WRITE_XML
	load_translatables();//Write to the current working directory - hopefully we'll have write rights here...
#endif

	//read the config file
	read_config();

	//Parse command line options
	read_command_line();

	//OK, we have the video mode settings...
	setup_video_mode(full_screen,video_mode);
	//now you may set the video mode using the %<foo> in-game
	video_mode_set=1;

	//Good, we should be in the right working directory - load all translatables from their files
	load_translatables();

	init_video();
	resize_window();
	init_gl_extensions();
#ifdef CAL3D
	create_cal3d_model();
	init_cal3d_model();
#endif
	seed = time (NULL);
	srand (seed);

	cache_system_init(MAX_CACHE_SYSTEM);
	init_texture_cache();
	init_md2_cache();
	init_e3d_cache();
	init_2d_obj_cache();
	load_ignores();
	load_filters();
	load_e3d_list();
	load_e2d_list();
	load_part_list();
	load_knowledge_list();
	load_cursors();
	build_cursors();
	change_cursor(CURSOR_ARROW);
	build_glow_color_table();


	init_actors_lists();
	memset(tile_list, 0, sizeof(tile_list));
	memset(lights_list, 0, sizeof(lights_list));
	init_particles_list();
	memset(actors_defs, 0, sizeof(actors_defs));
	init_actor_defs();

	load_map_tiles();

	//lights setup
	build_global_light_table();
	build_sun_pos_table();
	reset_material();
	init_lights();
	disable_local_lights();
	init_colors();
	clear_error_log();
	clear_conn_log();
	clear_thunders();
	build_rain_table();
	read_bin_cfg();
	build_levels_table();//for some HUD stuff
	init_scale_array();

	if(!no_sound)init_sound();

	//initialize the fonts
	init_fonts();
	check_gl_errors();

	//load the necesary textures
	//font_text=load_texture_cache("./textures/font.bmp",0);
	icons_text=load_texture_cache("./textures/gamebuttons.bmp",0);
	hud_text=load_texture_cache("./textures/gamebuttons2.bmp",0);
	cons_text=load_texture_cache("./textures/console.bmp",255);
	sky_text_1=load_texture_cache("./textures/sky.bmp",70);
	particle_textures[0]=load_texture_cache("./textures/particle0.bmp",0);
	particle_textures[1]=load_texture_cache("./textures/particle1.bmp",0);
	particle_textures[2]=load_texture_cache("./textures/particle2.bmp",0);
	particle_textures[3]=load_texture_cache("./textures/particle3.bmp",0);
	particle_textures[4]=load_texture_cache("./textures/particle4.bmp",0);
	particle_textures[5]=load_texture_cache("./textures/particle5.bmp",0);
	particle_textures[6]=load_texture_cache("./textures/particle6.bmp",0);
	particle_textures[7]=load_texture_cache("./textures/particle7.bmp",0);

	items_text_1=load_texture_cache("./textures/items1.bmp",0);
	items_text_2=load_texture_cache("./textures/items2.bmp",0);
	items_text_3=load_texture_cache("./textures/items3.bmp",0);
	items_text_4=load_texture_cache("./textures/items4.bmp",0);
	items_text_5=load_texture_cache("./textures/items5.bmp",0);
	items_text_6=load_texture_cache("./textures/items6.bmp",0);
	items_text_7=load_texture_cache("./textures/items7.bmp",0);
	items_text_8=load_texture_cache("./textures/items8.bmp",0);
	items_text_9=load_texture_cache("./textures/items9.bmp",0);

	portraits1_tex=load_texture_cache("./textures/portraits1.bmp",0);
	portraits2_tex=load_texture_cache("./textures/portraits2.bmp",0);
	portraits3_tex=load_texture_cache("./textures/portraits3.bmp",0);
	portraits4_tex=load_texture_cache("./textures/portraits4.bmp",0);
	portraits5_tex=load_texture_cache("./textures/portraits5.bmp",0);
	halo_tex=load_texture_cache("./textures/halo.bmp",0);

	if(have_multitexture)ground_detail_text=load_texture_cache("./textures/ground_detail.bmp",255);
	check_gl_errors();
	create_char_error_str[0]=0;
	init_opening_interface();
	init_hud_interface();

	if(SDLNet_Init()<0)
 		{
			char str[120];
			sprintf(str,"%s: %s\n",failed_sdl_net_init,SDLNet_GetError());
			log_error(str);
			SDLNet_Quit();
			SDL_Quit();
			exit(2);
		}

	if(SDL_InitSubSystem(SDL_INIT_TIMER)<0)
		{
 			char str[120];
			sprintf(str, "%s: %s\n", failed_sdl_timer_init,SDL_GetError());
			log_error(str);
			SDL_Quit();
		 	exit(1);
		}
	SDL_SetTimer (1000/(18*4), my_timer_pointer);

	ReadXML("languages/en/Encyclopedia/index.xml");
	read_key_config();
	load_questlog();
	init_buddy();

	//initiate function pointers
	init_attribf();

	//we might want to do this later.
	connect_to_server();
}
示例#11
0
// Handle FLTK events
int Fl_Table_Copy::handle(int event) {
  PRINTEVENT;
  int ret = Fl_Group::handle(event);	// let FLTK group handle events first
  // Which row/column are we over?
  int R, C;  				// row/column being worked on
  ResizeFlag resizeflag;		// which resizing area are we over? (0=none)
  TableContext context = cursor2rowcol(R, C, resizeflag);
  if (ret) {
    if (Fl::event_inside(hscrollbar) || Fl::event_inside(vscrollbar)) return 1;
    if ( context != CONTEXT_ROW_HEADER &&		// mouse not in row header (STR#2742)
         context != CONTEXT_COL_HEADER &&		// mouse not in col header (STR#2742)
         Fl::focus() != this && 			// we don't have focus?
         contains(Fl::focus())) {			// focus is a child?
      return 1;
    }
  }
  // Make snapshots of realtime event states *before* we service user's cb,
  // which may do things like post popup menus that return with unexpected button states.
  int _event_button = Fl::event_button();
  int _event_clicks = Fl::event_clicks();
  int _event_x      = Fl::event_x();
  int _event_y      = Fl::event_y();
  int _event_key    = Fl::event_key();
#if FLTK_ABI_VERSION >= 10303
  int _event_state  = Fl::event_state();
#endif
  Fl_Widget *_focus = Fl::focus();
  switch ( event ) {
    case FL_PUSH:
      // Single left-click on table? do user's callback with CONTEXT_TABLE
      if (_event_button == 1 && !_event_clicks) {
        if (_focus == this) {
          take_focus();
          do_callback(CONTEXT_TABLE, -1, -1);
          ret = 1;
        }
        damage_zone(current_row, current_col, select_row, select_col, R, C);
        if (context == CONTEXT_CELL) {
          current_row = select_row = R;
          current_col = select_col = C;
          _selecting = CONTEXT_CELL;
        } else {
	  // Clear selection if not resizing row/col
	  if ( !resizeflag ) {
            current_row = select_row = -1;
            current_col = select_col = -1;
	  }
        }
      }
      // A click on table with user's callback defined?
      //     Need this for eg. right click to pop up a menu
      //
      if ( Fl_Widget::callback() &&		// callback defined?
          resizeflag == RESIZE_NONE ) {		// not resizing?
        do_callback(context, R, C);		// do callback with context (cell, header, etc)
      }
      // Handle selection if handling a left-click
      //    Use snapshot of _event_button we made before servicing user's cb's
      //    to avoid checking realtime state of buttons which may have changed
      //    during the user's callbacks.
      //
      switch ( context ) {
        case CONTEXT_CELL:
          // FL_PUSH on a cell?
          ret = 1;				// express interest in FL_RELEASE
          break;
          
        case CONTEXT_NONE:
          // FL_PUSH on table corner?
          if ( _event_button == 1 && _event_x < x() + row_header_width()) {
            current_col = 0;
            select_col = cols() - 1;
            current_row = 0;
            select_row = rows() - 1;				
            damage_zone(current_row, current_col, select_row, select_col);
            ret = 1;
          }
          break;
          
        case CONTEXT_COL_HEADER:
          // FL_PUSH on a column header?
          if ( _event_button == 1) {
            // Resizing? Handle it
            if ( resizeflag ) {
              // Start resize if left click on column border.
              //    "ret=1" ensures we get drag events from now on.
              //    (C-1) is used if mouse is over the left hand side 
              //    of cell, so we resize the next column on the left.
              //
              _resizing_col = ( resizeflag & RESIZE_COL_LEFT ) ? C-1 : C; 
              _resizing_row = -1;
              _dragging_x = _event_x;
              ret = 1;
            } else {
              // Not resizing? Select the column
	      if ( Fl::focus() != this && contains(Fl::focus()) ) return 0;	// STR #3018 - item 1
              current_col = select_col = C;
              current_row = 0;
              select_row = rows() - 1;
              _selecting = CONTEXT_COL_HEADER;
              damage_zone(current_row, current_col, select_row, select_col);
              ret = 1;
            }
          }
          break;
          
        case CONTEXT_ROW_HEADER:
          // FL_PUSH on a row header?
          if ( _event_button == 1 ) {
            // Resizing? Handle it
            if ( resizeflag ) {
              // Start resize if left mouse clicked on row border.
              //    "ret = 1" ensures we get drag events from now on.
              //    (R-1) is used if mouse is over the top of the cell,
              //    so that we resize the row above.
              //
              _resizing_row = ( resizeflag & RESIZE_ROW_ABOVE ) ? R-1 : R; 
              _resizing_col = -1;
              _dragging_y = _event_y; 
              ret = 1;
            } else {
              // Not resizing? Select the row
	      if ( Fl::focus() != this && contains(Fl::focus()) ) return 0;	// STR #3018 - item 1
              current_row = select_row = R;
              current_col = 0;
              select_col = cols() - 1;
              _selecting = CONTEXT_ROW_HEADER;
              damage_zone(current_row, current_col, select_row, select_col);
              ret = 1;
            }
          }
          break;
          
        default:
          ret = 0;		// express disinterest
          break;
      }
      _last_row = R;
      break;
      
    case FL_DRAG:
      if (_auto_drag == 1) {
        ret = 1;
        break;
      } 
      if ( _resizing_col > -1 ) {
        // Dragging column?
        //
        //    Let user drag even /outside/ the row/col widget.
        //    Don't allow column width smaller than 1.
        //    Continue to show FL_CURSOR_WE at all times during drag.
        //
        int offset = _dragging_x - _event_x;
        int new_w = col_width(_resizing_col) - offset;
        if ( new_w < _col_resize_min ) new_w = _col_resize_min;
        col_width(_resizing_col, new_w);
        _dragging_x = _event_x;
        table_resized();
        redraw();
        change_cursor(FL_CURSOR_WE);
        ret = 1;
        if ( Fl_Widget::callback() && when() & FL_WHEN_CHANGED ) {
          do_callback(CONTEXT_RC_RESIZE, R, C);
        }
      }
      else if ( _resizing_row > -1 ) {
        // Dragging row?
        //
        //    Let user drag even /outside/ the row/col widget.
        //    Don't allow row width smaller than 1.
        //    Continue to show FL_CURSOR_NS at all times during drag.
        //
        int offset = _dragging_y - _event_y;
        int new_h = row_height(_resizing_row) - offset;
        if ( new_h < _row_resize_min ) new_h = _row_resize_min;
        row_height(_resizing_row, new_h);
        _dragging_y = _event_y;
        table_resized();
        redraw();
        change_cursor(FL_CURSOR_NS);
        ret = 1;
        if ( Fl_Widget::callback() && when() & FL_WHEN_CHANGED ) {
          do_callback(CONTEXT_RC_RESIZE, R, C);
        }
      } else {
        if (_event_button == 1 && 
            _selecting == CONTEXT_CELL &&
            context == CONTEXT_CELL) {
          // Dragging a cell selection?
	  if ( _event_clicks ) break;			// STR #3018 - item 2
          if (select_row != R || select_col != C) {
            damage_zone(current_row, current_col, select_row, select_col, R, C);
          }
          select_row = R;
          select_col = C;
          ret = 1;
        }
        else if (_event_button == 1 && 
                 _selecting == CONTEXT_ROW_HEADER && 
                 context & (CONTEXT_ROW_HEADER|CONTEXT_COL_HEADER|CONTEXT_CELL)) {
          if (select_row != R) {
            damage_zone(current_row, current_col, select_row, select_col, R, C);
          }
          select_row = R;
          ret = 1;
        }
        else if (_event_button == 1 && 
                 _selecting == CONTEXT_COL_HEADER 
                 && context & (CONTEXT_ROW_HEADER|CONTEXT_COL_HEADER|CONTEXT_CELL)) {
          if (select_col != C) {
            damage_zone(current_row, current_col, select_row, select_col, R, C);
          }
          select_col = C;
          ret = 1;
        }
      }
      // Enable autodrag if not resizing, and mouse has moved off table edge
      if ( _resizing_row < 0 && _resizing_col < 0 && _auto_drag == 0 && 
          ( _event_x > x() + w() - 20 ||
            _event_x < x() + row_header_width() || 
            _event_y > y() + h() - 20 ||
            _event_y < y() + col_header_height()
           ) ) {
            _start_auto_drag();
          }
      break;
      
    case FL_RELEASE:
      _stop_auto_drag();
      switch ( context ) {
        case CONTEXT_ROW_HEADER:		// release on row header
        case CONTEXT_COL_HEADER:		// release on col header
        case CONTEXT_CELL:			// release on a cell
        case CONTEXT_TABLE:			// release on dead zone
          if ( _resizing_col == -1 &&		// not resizing a column
              _resizing_row == -1 &&		// not resizing a row
              Fl_Widget::callback() && 		// callback defined
              when() & FL_WHEN_RELEASE && 	// on button release
              _last_row == R ) {		// release on same row PUSHed?
            // Need this for eg. left clicking on a cell to select it
            do_callback(context, R, C);
          }
          break;
          
        default:
          break;
      }
      if ( _event_button == 1 ) {
        change_cursor(FL_CURSOR_DEFAULT);
        _resizing_col = -1;
        _resizing_row = -1;
        ret = 1;
      }
      break;
      
    case FL_MOVE:
      if ( context == CONTEXT_COL_HEADER && 		// in column header?
          resizeflag ) {				// resize + near boundary?
        change_cursor(FL_CURSOR_WE);			// show resize cursor
      }
      else if ( context == CONTEXT_ROW_HEADER && 	// in row header?
               resizeflag ) {				// resize + near boundary?
        change_cursor(FL_CURSOR_NS);			// show resize cursor
      } else {
        change_cursor(FL_CURSOR_DEFAULT);		// normal cursor
      }
      ret = 1;
      break;
      
    case FL_ENTER:		// See FLTK event docs on the FL_ENTER widget
      if (!ret) take_focus();
      ret = 1;
      //FALLTHROUGH
      
    case FL_LEAVE:		// We want to track the mouse if resizing is allowed.
      if ( resizeflag ) {
        ret = 1;
      }
      if ( event == FL_LEAVE ) {
        _stop_auto_drag();
        change_cursor(FL_CURSOR_DEFAULT);
      }
      break;
      
    case FL_FOCUS:
      Fl::focus(this);
      //FALLTHROUGH
      
    case FL_UNFOCUS:
      _stop_auto_drag();
      ret = 1;
      break;
      
    case FL_KEYBOARD: {
      ret = 0;
      int is_row = select_row;
      int is_col = select_col;
      switch(_event_key) {
        case FL_Home:
          ret = move_cursor(0, -1000000);
          break;
        case FL_End:
          ret = move_cursor(0, 1000000);
          break;
        case FL_Page_Up:
          ret = move_cursor(-(botrow - toprow - 1), 0);
          break;
        case FL_Page_Down:
          ret = move_cursor(botrow - toprow - 1 , 0);
          break;
        case FL_Left:
          ret = move_cursor(0, -1);
          break;
        case FL_Right:
          ret = move_cursor(0, 1);
          break;
        case FL_Up:
          ret = move_cursor(-1, 0);
          break;
        case FL_Down:
          ret = move_cursor(1, 0);
          break;
	case FL_Tab:
#if FLTK_ABI_VERSION >= 10303
	  if ( !tab_cell_nav() ) break;		// not navigating cells? let fltk handle it (STR#2862)
	  if ( _event_state & FL_SHIFT ) {
            ret = move_cursor(0, -1, 0);	// shift-tab -> left
	  } else {
	    ret = move_cursor(0, 1, 0);		// tab -> right
	  }
          break;
#else
          break;				// without tab_cell_nav(), Fl_Table_Copy should default to navigating widgets, not cells
#endif
      }
      if (ret && Fl::focus() != this) {
        do_callback(CONTEXT_TABLE, -1, -1);
        take_focus();
      }
      //if (!ret && Fl_Widget::callback() && when() & FL_WHEN_NOT_CHANGED  )
      if ( Fl_Widget::callback() && 
          (
           ( !ret && when() & FL_WHEN_NOT_CHANGED ) || 
           ( is_row!= select_row || is_col!= select_col ) 
           )
          ) {
        do_callback(CONTEXT_CELL, select_row, select_col); 
        //damage_zone(current_row, current_col, select_row, select_col);
        ret = 1;
      }
      break;
    }
      
    default:
      change_cursor(FL_CURSOR_DEFAULT);
      break;
  }
  return(ret);
}
示例#12
0
void set_new_video_mode(int fs,int mode)
{
	int i;
#ifndef	NEW_TEXTURES
	int alpha;
#endif	/* NEW_TEXTURES */
	
	full_screen=fs;
	video_mode=mode;

	//now, clear all the textures...
#ifdef	NEW_TEXTURES
	unload_texture_cache();
#else	/* NEW_TEXTURES */
	for(i = 0; i < TEXTURE_CACHE_MAX; i++)
	{
		if(texture_cache[i].file_name[0])
		{
			glDeleteTextures(1,(GLuint*)&texture_cache[i].texture_id);
			texture_cache[i].texture_id=0;//force a reload
			CHECK_GL_ERRORS();
		}
	}

#ifndef MAP_EDITOR2
	//do the same for the actors textures...
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->remapped_colors || actors_list[i]->is_enhanced_model)//if it is not remapable, then it is already in the cache
						{
							glDeleteTextures(1,&actors_list[i]->texture_id);
							actors_list[i]->texture_id=0;
							CHECK_GL_ERRORS();
						}
				}
		}
#endif
#endif	/* NEW_TEXTURES */

	if (use_vertex_buffers)
	{
		e3d_object * obj;

#ifdef FASTER_MAP_LOAD
		for (i = 0; i < cache_e3d->num_items; i++)
#else
		for (i = 0; i < cache_e3d->max_item; i++)
#endif
		{
			if (!cache_e3d->cached_items[i]) continue;
			obj= cache_e3d->cached_items[i]->cache_item;
			free_e3d_va(obj);
		}
		CHECK_GL_ERRORS();
	}

#ifndef	NEW_TEXTURES
	ec_clear_textures();
#endif	/* NEW_TEXTURES */

	//destroy the current context

	init_video();
#ifndef WINDOWS
	// Re-enable window manager events, since the killing of the video 
	// subsystem turns them off.
	SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
#endif	
	resize_root_window();
	init_lights();
	disable_local_lights();
	reset_material();

	//reload the cursors
	load_cursors();
	build_cursors();
	change_cursor(current_cursor);

	ec_load_textures();

	//now, reload the textures
#ifndef	NEW_TEXTURES
	for(i = 0; i < TEXTURE_CACHE_MAX; i++)
	{
		if (texture_cache[i].file_name[0] && !texture_cache[i].load_err)
		{
			alpha=texture_cache[i].alpha;
			//our texture was freed, we have to reload it
			if(alpha<=0)
				texture_cache[i].texture_id = load_bmp8_color_key (&(texture_cache[i]), alpha);
	            	else
				texture_cache[i].texture_id = load_bmp8_fixed_alpha (&(texture_cache[i]), alpha);
		}
	}
	reload_fonts();

#ifndef MAP_EDITOR2
	//do the same for the actors textures...
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->remapped_colors)//if it is not remapable, then it is already in the cache
						{
							//reload the skin
							//actors_list[i]->texture_id=load_bmp8_remapped_skin(actors_list[i]->skin_name,
							//												   150,actors_list[i]->skin,actors_list[i]->hair,actors_list[i]->shirt,
							//												   actors_list[i]->pants,actors_list[i]->boots);
						}
					if(actors_list[i]->is_enhanced_model)
						{
							actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
						}
				}
		}
#endif
#endif	/* NEW_TEXTURES */
	
	//it is dependent on the window height...
	init_hud_interface (HUD_INTERFACE_LAST);
	new_minute();

	set_all_intersect_update_needed(main_bbox_tree);
	skybox_init_gl();

	// resize the EL root windows
	resize_all_root_windows (window_width, window_height);
	check_options();
	reload_tab_map = 1;
#ifdef NEW_CURSOR
	if (!sdl_cursors)
	{
		SDL_ShowCursor(0);
		SDL_WM_GrabInput(SDL_GRAB_OFF);
	}
#endif // NEW_CURSOR
}
示例#13
0
// Handle FLTK events
int Fl_Table::handle(int event)
{
    PRINTEVENT;

    int ret = Fl_Group::handle(event);	// let FLTK group handle events first

    if (ret) {
	if (Fl::event_inside(hscrollbar) || Fl::event_inside(vscrollbar)) return 1;
	if (Fl::focus() != this && contains(Fl::focus())) return 1;
    }
 
    // Which row/column are we over?
    int R, C;  				// row/column being worked on
    ResizeFlag resizeflag;		// which resizing area are we over? (0=none)
    TableContext context = cursor2rowcol(R, C, resizeflag);

    switch ( event )
    {
	case FL_PUSH:
            if (Fl::event_button() == 1 && !Fl::event_clicks())
	    {
                if (Fl::focus() != this)
		{
		    take_focus();
		    do_callback(CONTEXT_TABLE, -1, -1);
		    ret = 1;
		}
                damage_zone(current_row, current_col, select_row, select_col, R, C);
		if (context == CONTEXT_CELL) 
		{
		    current_row = select_row = R;
		    current_col = select_col = C;
		    _selecting = CONTEXT_CELL;
		}
		else 
		{
		    current_row = select_row = -1;
		    current_col = select_col = -1;
		}
            }
	    // Need this for eg. right click to pop up a menu
	    if ( Fl_Widget::callback() &&		// callback defined?
		 resizeflag == RESIZE_NONE )		// not resizing?
		    { do_callback(context, R, C); }	// do callback

	    switch ( context )
	    {
	        case CONTEXT_CELL:
		    // FL_PUSH on a cell?
		    ret = 1; 			// express interest in FL_RELEASE
		    break;

		case CONTEXT_NONE:
		    // FL_PUSH on table corner?
		    if ( Fl::event_button() == 1 && 
		         Fl::event_x() < x() + row_header_width()) 
		    {
			current_col = 0;
			select_col = cols() - 1;
			current_row = 0;
			select_row = rows() - 1;				
			damage_zone(current_row, current_col, select_row, select_col);
			ret = 1;
		    }
		    break;

		case CONTEXT_COL_HEADER:
		    // FL_PUSH on a column header?
		    if ( Fl::event_button() == 1)
		    {
		        // Resizing? Handle it
		        if ( resizeflag )
			{
			    // Start resize if left click on column border.
			    //    "ret=1" ensures we get drag events from now on.
			    //    (C-1) is used if mouse is over the left hand side 
			    //    of cell, so we resize the next column on the left.
			    //
			    _resizing_col = ( resizeflag & RESIZE_COL_LEFT ) ? C-1 : C; 
			    _resizing_row = -1;
			    _dragging_x = Fl::event_x(); 
			    ret = 1;
			}
			else
			{
			    // Not resizing? Select the column
			    current_col = select_col = C;
			    current_row = 0;
			    select_row = rows() - 1;
			    _selecting = CONTEXT_COL_HEADER;
			    damage_zone(current_row, current_col, 
			    		select_row, select_col);
			    ret = 1;
			}
		    }
		    break;

		case CONTEXT_ROW_HEADER:
		    // FL_PUSH on a row header?
		    if ( Fl::event_button() == 1 )
		    {
		        // Resizing? Handle it
			if ( resizeflag )
			{
			    // Start resize if left mouse clicked on row border.
			    //    "ret = 1" ensures we get drag events from now on.
			    //    (R-1) is used if mouse is over the top of the cell,
			    //    so that we resize the row above.
			    //
			    _resizing_row = ( resizeflag & RESIZE_ROW_ABOVE ) ? R-1 : R; 
			    _resizing_col = -1;
			    _dragging_y = Fl::event_y(); 
			    ret = 1;
			} 
			else
			{
			    // Not resizing? Select the row
			    current_row = select_row = R;
			    current_col = 0;
			    select_col = cols() - 1;
			    _selecting = CONTEXT_ROW_HEADER;
			    damage_zone(current_row, current_col, 
			    		select_row, select_col);
			    ret = 1;
			}
		    }
		    break;

		default:
		    ret = 0;		// express disinterest
		    break;
	    }
	    _last_row = R;
	    break;

        case FL_DRAG:
            if (_auto_drag == 1) {
		ret = 1;
		break;
	    }

	    if ( _resizing_col > -1 )
	    {
		// Dragging column?
		//
		//    Let user drag even /outside/ the row/col widget.
		//    Don't allow column width smaller than 1.
		//    Continue to show FL_CURSOR_WE at all times during drag.
		//
		int offset = _dragging_x - Fl::event_x();
		int new_w = col_width(_resizing_col) - offset;
		if ( new_w < _col_resize_min ) new_w = _col_resize_min;
		col_width(_resizing_col, new_w);
		_dragging_x = Fl::event_x();
		table_resized();
		redraw();
		change_cursor(FL_CURSOR_WE);
		ret = 1;
		if ( Fl_Widget::callback() && when() & FL_WHEN_CHANGED )
		    { do_callback(CONTEXT_RC_RESIZE, R, C); }
	    }
	    else if ( _resizing_row > -1 )
	    {
		// Dragging row?
		//
		//    Let user drag even /outside/ the row/col widget.
		//    Don't allow row width smaller than 1.
		//    Continue to show FL_CURSOR_NS at all times during drag.
		//
		int offset = _dragging_y - Fl::event_y();
		int new_h = row_height(_resizing_row) - offset;
		if ( new_h < _row_resize_min ) new_h = _row_resize_min;
		row_height(_resizing_row, new_h);
		_dragging_y = Fl::event_y();
		table_resized();
		redraw();
		change_cursor(FL_CURSOR_NS);
		ret = 1;
		if ( Fl_Widget::callback() && when() & FL_WHEN_CHANGED )
		    { do_callback(CONTEXT_RC_RESIZE, R, C); }
	    } else {
                if (Fl::event_button() == 1 && _selecting == CONTEXT_CELL 
			&& context == CONTEXT_CELL) 
		{
                    if (select_row != R || select_col != C)
                        damage_zone(current_row, current_col, select_row, select_col, R, C);
                    select_row = R;
                    select_col = C;
                    ret = 1;
                } else if (Fl::event_button() == 1 && _selecting == CONTEXT_ROW_HEADER 
			&& context & (CONTEXT_ROW_HEADER|CONTEXT_COL_HEADER|CONTEXT_CELL)) 
		{
                   if (select_row != R)
                        damage_zone(current_row, current_col, select_row, select_col, R, C);
		    select_row = R;
                    ret = 1;
		} else if (Fl::event_button() == 1 && _selecting == CONTEXT_COL_HEADER 
			&& context & (CONTEXT_ROW_HEADER|CONTEXT_COL_HEADER|CONTEXT_CELL)) 
		{
                    if (select_col != C)
                        damage_zone(current_row, current_col, select_row, select_col, R, C);
		    select_col = C;
                    ret = 1;
		}
            }
	    // Enable autodrag if not resizing, and mouse has moved off table edge
	    if ( _resizing_row < 0 && _resizing_col < 0 && _auto_drag == 0 && 
	        ( Fl::event_x() > x() + w() - 20 ||
                  Fl::event_x() < x() + row_header_width() || 
		  Fl::event_y() > y() + h() - 20 ||
                  Fl::event_y() < y() + col_header_height()
		) )
            {
                _start_auto_drag();
            }
	    break;

	case FL_RELEASE:
            _stop_auto_drag();
	    switch ( context )
	    {
		case CONTEXT_ROW_HEADER:	// release on row header
		case CONTEXT_COL_HEADER:	// release on col header
		case CONTEXT_CELL:		// release on a cell
		case CONTEXT_TABLE:		// release on dead zone
		    if ( _resizing_col == -1 &&		// not resizing a column
			 _resizing_row == -1 &&		// not resizing a row
		         Fl_Widget::callback() && 	// callback defined
			 when() & FL_WHEN_RELEASE && 	// on button release
			 _last_row == R )		// release on same row PUSHed?
		    {
			// Need this for eg. left clicking on a cell to select it
			do_callback(context, R, C);
		    }
		    break;

		default:
		    break;
	    }

	    if ( Fl::event_button() == 1 )
	    {
		change_cursor(FL_CURSOR_DEFAULT);
		_resizing_col = -1;
		_resizing_row = -1;
		ret = 1;
	    }
	    break;

	case FL_MOVE:
	    if ( context == CONTEXT_COL_HEADER && 	// in column header?
	         resizeflag )				// resize + near boundary?
		{ change_cursor(FL_CURSOR_WE); }	// show resize cursor
	    else if ( context == CONTEXT_ROW_HEADER && 	// in row header?
	         resizeflag )				// resize + near boundary?
		{ change_cursor(FL_CURSOR_NS); }	// show resize cursor
	    else
		{ change_cursor(FL_CURSOR_DEFAULT); }	// normal cursor
	    ret = 1;
	    break;

	case FL_ENTER:		// See FLTK event docs on the FL_ENTER widget
	     if (!ret) take_focus();
	     ret = 1;
	     //FALLTHROUGH

	case FL_LEAVE:		// We want to track the mouse if resizing is allowed.
	    if ( resizeflag )
		{ ret = 1; }
	    if ( event == FL_LEAVE ) 
	    {
	        _stop_auto_drag();
	    	change_cursor(FL_CURSOR_DEFAULT);
	    }
	    break;

        case FL_FOCUS:
	    Fl::focus(this);
	    //FALLTHROUGH

        case FL_UNFOCUS:
	    _stop_auto_drag();
	    ret = 1;
	    break;

	case FL_KEYBOARD:
	    ret = 0;
	    switch(Fl::event_key()) {
		case FL_Home:
		    ret = move_cursor(0, -1000000); break;
		case FL_End:
		    ret = move_cursor(0, 1000000); break;
		case FL_Page_Up:
		    ret = move_cursor(-(botrow - toprow - 1), 0); break;
		case FL_Page_Down:
		    ret = move_cursor(botrow - toprow - 1 , 0); break;
		case FL_Left:
		    ret = move_cursor(0, -1); break;
		case FL_Right:
		    ret = move_cursor(0, 1); break;
		case FL_Up:
		    ret = move_cursor(-1, 0); break;
		case FL_Down:
		    ret = move_cursor(1, 0); break;
	    }
	    if (ret && Fl::focus() != this) {
		do_callback(CONTEXT_TABLE, -1, -1);
		take_focus();
	    }
	    if (!ret && Fl_Widget::callback() && when() & FL_WHEN_NOT_CHANGED  ) { 
		do_callback(CONTEXT_CELL, select_row, select_col); 
		//damage_zone(current_row, current_col, select_row, select_col);
		ret = 1;
	    }
	    break;

	default:
	    change_cursor(FL_CURSOR_DEFAULT);
	    break;
    }
    return(ret);
}