コード例 #1
0
ファイル: monitor.c プロジェクト: Tyboon/PFE
void copyArchiveSelected()
{
    int *id = NULL;

    move_sel();
    id = move_arc();    
    state2_user(id);

    free(id);
}
コード例 #2
0
ファイル: hello.cpp プロジェクト: ashmew2/kolibriosSVN
void process_key()
{
	Dword mouse_btn, ckeys, shift, ctrl;
	int mouse_x, mouse_y, dx = 0, dy = 0;

	// key pressed, read it 
	Byte keyCode;
	ckeys = kos_GetSpecialKeyState();
	shift = ckeys & 0x3;
	ctrl = ckeys & 0x0c;
	//if (ctrl)
	//	rtlDebugOutString("control pressed!");
	dx = 0, dy = 0;
	sel_moved = 0;
	sel_end_move = 0;
	kos_GetKey(keyCode);

	__asm
	{
		mov ah, keyCode
	}
	edit_box_key((dword)&cell_box);
	edit_box_key((dword)&file_box);


	switch (keyCode)
	{
		case 178:			// стрелки
			//dx = 0;
			dy = -1;
			break;
		case 176:
			dx = -1;
			//dy = 0;
			break;
		case 179:
			dx = 1;
			//dy = 0;
			break;
		case 177:
			//dx = 0;
			dy = 1;
			break;
		/*
		case 183:
			if (sel_y < row_count-(ny - scroll_y))	// page down
				dy = ny - scroll_y;
			else
				dy = row_count-(ny - scroll_y) - sel_y;
			dx = 0;
			redraw = 1;
			break;
		case 184:
			if (sel_y > ny - scroll_y)		// page up
				dy= - (ny - scroll_y);
			else
				dy = - (ny - scroll_y) + sel_y;
			dx = 0;
			redraw = 1;
			break;
		*/
		case 180: //home
			dx = -sel_x + 1;
			dy = 0;
			draw_grid(); //draw_window(); 
			break;
		case 181: //end
			dx = col_count - (nx - scroll_x) - 1 - sel_x;
			dy = 0;
			draw_grid(); //draw_window();
			break;
		case 27:		// escape
			cancel_edit();
			break;
		case 182:			// delete
			{
				int i,j,n0,n1,k0,k1;
				n0 = min(sel_x, sel_end_x);
				n1 = max(sel_x, sel_end_x);
				k0 = min(sel_y, sel_end_y);
				k1 = max(sel_y, sel_end_y);

				for (i = n0; i <= n1; i++)
					for (j = k0; j <= k1; j++)
					{
						if (cells[i][j])
						{
							freemem(cells[i][j]);
							cells[i][j] = NULL;
						}
					}
				calculate_values();
				draw_grid();
				break;
			}
		case 0x0D:			// enter
			if (is_edit)
			{
				stop_edit();
				draw_window();
			}
			break;
		case 22:	// contol-v
			{
				if (ctrl)
				{
					//rtlDebugOutString("control-v!");
					int i, j, x0, y0;
					x0 = min(sel_x, sel_end_x);
					y0 = min(sel_y, sel_end_y);
					int delta_x = x0 - buf_old_x;
					int delta_y = y0 - buf_old_y;

					for (i = 0; i < buf_col; i++)
						for (j = 0; j < buf_row; j++)
						{
							if (i + x0 >= col_count || j + y0 >= row_count)
								continue;
							if (cells[i + x0][j + y0])
								freemem(cells[i + x0][j + y0]);
							if (buffer[i][j])
							{
								cf_x0 = buf_old_x; cf_y0 = buf_old_y;
								cf_x1 = buf_old_x + buf_col;
								cf_y1 = buf_old_y + buf_row;
								cells[i + x0][j + y0] = change_formula(buffer[i][j], delta_x, delta_y);
								//cells[i + x0][j + y0] = (char*)allocmem(strlen(buffer[i][j]));
								//strcpy(cells[i + x0][j + y0], buffer[i][j]);
							}
							else
								cells[i + x0][j + y0] = NULL;
						}

					calculate_values();
					draw_window();
					break;
				}
			}
			case 24:	// control-x
			case 03:	// control-c
			{
				if (ctrl)
				{
					//rtlDebugOutString("control-c!");
					int i, j, x0, y0;

					freeBuffer();

					buf_col = abs(sel_end_x - sel_x) + 1;
					buf_row = abs(sel_end_y - sel_y) + 1;
					x0 = min(sel_x, sel_end_x);
					y0 = min(sel_y, sel_end_y);
					buf_old_x = x0;
					buf_old_y = y0;

					//sprintf(debuf, "%U %U %U %U", buf_col, buf_row, x0, y0);
					//rtlDebugOutString(debuf);
				
					buffer = (char***)allocmem(buf_col * sizeof(char**));
					for (i = 0; i < buf_col; i++)
					{
						buffer[i] = (char**)allocmem(buf_row * sizeof(char*));
						for (j = 0; j < buf_row; j++)
						{
							if (cells[i + x0][j + y0])
							{
								if (keyCode == 03)	// ctrl-c
								{
									buffer[i][j] = (char*)allocmem(strlen(cells[i + x0][j + y0]));
									strcpy(buffer[i][j], cells[i + x0][j + y0]);
								}
								else
								{
									buffer[i][j] = cells[i + x0][j + y0];
									cells[i + x0][j + y0] = NULL;
								}
							}
							else
								buffer[i][j] = NULL;
						}
					}
					if (keyCode == 24) 
						calculate_values();
					draw_window();
					break;
				}
			}
		case 06:		// control-f
			{
				display_formulas = !display_formulas;
				draw_grid(); //draw_window();
				break;
			}
		default:
			
			if (!is_edit && !(file_box.flags & ed_focus))
			{
				start_edit(sel_x, sel_y);
				if (keyCode == 8)
				{
					cell_box.pos = strlen(edit_text);
				}
				else
				{
					__asm
					{
						mov ah, keyCode
					}
					edit_box_key((dword)&cell_box);
				}
			}
			if (is_edit)
				edit_box_draw((dword)&cell_box);
			break;
	}
	if (dx != 0)
	{
		if (shift)
		{
			sel_end_x += dx;
			if (sel_end_x <= 1)
				sel_end_x = 1;
			else if (sel_end_x >= col_count)
				sel_end_x = col_count - 1;
		//	sprintf(debuf,"sel end x change. sel end %U %U",sel_end_x,sel_end_y);
		//	rtlDebugOutString(debuf);
			sel_moved = sel_end_move = 1;
			//stop_edit();
			//draw_grid();
		}
		else
		{
		}
	}
	if (dy != 0)
	{
		if (shift)
		{
			sel_end_y += dy;
			if (sel_end_y <= 1)
				sel_end_y = 1;
			else if (sel_end_y >= row_count)
				sel_end_y = row_count - 1;
		//	sprintf(debuf,"sel end y change. sel end %U %U",sel_end_x,sel_end_y);
		//	rtlDebugOutString(debuf);
			sel_moved = sel_end_move = 1;
			//stop_edit();
			//draw_grid();
		}
	}
	/*
	if (sel_end_x < sel_x)
	{
		Dword tmp = sel_end_x; sel_end_x = sel_x; sel_x = tmp;
	}
	if (sel_end_y < sel_y)
	{
		Dword tmp = sel_end_y; sel_end_y = sel_y; sel_y = tmp;
	}
	*/
	if ((dx || dy))
	{
		if (!shift)
		{
			if ((sel_end_x + dx) >= (col_count-1)) {dx=0;} //заглушка
			else if ((sel_end_y + dy) >= (row_count-1)) {dy=0;}
			else {
			move_sel(sel_x + dx, sel_y + dy);
			}
		}
		else
		{
			sel_moved = 0;
			stop_edit();
			draw_grid();
		}
	}
}
コード例 #3
0
ファイル: hello.cpp プロジェクト: ashmew2/kolibriosSVN
void process_mouse()
{
	Dword mouse_btn, ckeys, shift, ctrl;
	int mouse_x, mouse_y, i, dx = 0, dy = 0;
	int redraw = 0;
	
	Dword mySlot = kos_GetSlotByPID(myPID);
	if (kos_GetActiveSlot() != mySlot)
		return;

	edit_box_mouse((dword)&cell_box);
	edit_box_mouse((dword)&file_box);

	int vert, hor;
	kos_GetScrollInfo(vert, hor);

	//sprintf(debuf, "scroll %U %U", vert, hor);
	//rtlDebugOutString(debuf);

		
	if (vert != 0) //труъ перерисовка!
	{
		if (!((sel_end_y + vert) >= (row_count-1))) //заглушка
		move_sel(sel_x, sel_y + vert);
		return;
	}
	
	kos_GetMouseState(mouse_btn, mouse_x, mouse_y);
	mouse_x -= 5;
	mouse_y -= kos_GetSkinHeight();

	mouse_btn &= 0x0001;

	ckeys = kos_GetSpecialKeyState();
	shift = ckeys & 0x3;


	if (mouse_y < 0 && mouse_btn)	// т.к. мышка на заголовке окна
	{
		window_is_dragged = 1;
		return;
	}
	if (window_is_dragged)
	{
		if (mouse_btn)
			return;
		else
			window_is_dragged = 0;
	}

	if (!size_state && !mouse_btn)
		return;
	if (mouse_btn && !size_state)		// LMB down				
	{
		//rtlDebugOutString("lmb down and not resize");

		if (mouse_x >= drag_x && mouse_x <= drag_x + 4 && mouse_y >= drag_y && mouse_y <= drag_y + 4)
		{
			size_state = SIZE_DRAG;
			old_end_x = sel_end_x;
			old_end_y = sel_end_y;
		}
		else if (mouse_y <= row_height[0])
		{
			//rtlDebugOutString("can resize cols");
			int kx = -1, i;
			for (i = 0; i < col_count - 1; i++)
			if (mouse_x >= col_left[i] + col_width[i] - 5 &&
				mouse_x <= col_left[i + 1] + 5)
			{
				kx = i; break;
			}
			if (kx != -1)
			{
				//sprintf(debuf,"size x %U",k);
				//rtlDebugOutString(debuf);
				size_id = kx;
				size_state = SIZE_X;
			}
		}
		else if (mouse_x <= col_width[0])
		{
			int ky = -1;
			for (i = 0; i < row_count - 1; i++)
			if (mouse_y >= row_top[i] + row_height[i] - 5 &&
				mouse_y <= row_top[i + 1] + 5)
			{
				ky = i; break;
			}
			if (ky != -1)
			{
				size_id = ky;
				size_state = SIZE_Y;
			}
		}
		else		// кликнута ячейка
		if (mouse_x <= col_left[nx - 1] &&  mouse_y <= row_top[ny - 1])
		{
			was_single_selection = sel_x == sel_end_x && sel_y == sel_end_y;
			int kx = -1, i;
			for (i = 0; i < col_count - 1; i++)
			if (mouse_x >= col_left[i] &&
				mouse_x <= col_left[i] + col_width[i])
			{
				kx = i; break;
			}
			int ky = -1;
			for (i = 0; i < row_count - 1; i++)
			if (mouse_y >= row_top[i] &&
				mouse_y <= row_top[i] + row_height[i])
			{
				ky = i; break;
			}
			if (kx != -1 && ky != -1)
			{
				if (!shift) 
				{
					move_sel(kx, ky);
					//return;
				}
				else
				{
					sel_end_x = kx;
					sel_end_y = ky;
				}
				size_state = SIZE_SELECT;
			}
		}
		if (size_state)
		{
			size_mouse_x = mouse_x;
			size_mouse_y = mouse_y;
		}
		return;
	}
	else if (!mouse_btn && size_state)
	{
		sel_moved = 0;		// чтобы была тру перерисовка
		//rtlDebugOutString("resize end");

		if (size_state == SIZE_DRAG)
		{
			fill_cells(sel_x, sel_y, sel_end_x, sel_end_y, old_end_x, old_end_y);
		}

		//sel_moved = (size_state == SIZE_SELECT && sel_x == sel_end_x && sel_y == sel_end_y && was_single_selection);
		size_state = 0;
		draw_window();		// все сдвинулось - надо обновиться
		return;
	}
	if (size_state == SIZE_X && mouse_x != size_mouse_x)
	{
		draw_size_grid();
		col_width[size_id] += mouse_x - size_mouse_x;
		if (col_width[size_id] < 15)
			col_width[size_id] = 15;
		else if (col_width[size_id] > wi / 2)
			col_width[size_id] = wi / 2;
		draw_size_grid();
	}
	if (size_state == SIZE_Y && mouse_y != size_mouse_y)
	{
		draw_size_grid();
		row_height[size_id] += mouse_y - size_mouse_y;
		if (row_height[size_id] < 15)
			row_height[size_id] = 15;
		else if (row_height[size_id] > he / 2)
			row_height[size_id] = he / 2;
		draw_size_grid();
	}
	if ((size_state == SIZE_SELECT || size_state == SIZE_DRAG) && (mouse_x != size_mouse_x || mouse_y != size_mouse_y))
	{
		draw_drag();
		int kx = -1, i;
		for (i = 0; i < col_count - 1; i++)
			if (mouse_x >= col_left[i] &&
				mouse_x <= col_left[i + 1])
			{
				//sprintf(debuf, "yyy %U",col_left[i+1]);
				//rtlDebugOutString(debuf);
				kx = i; break;
			}
		int ky = -1;
		for (i = 0; i < row_count - 1; i++)
			if (mouse_y >= row_top[i] &&
				mouse_y <= row_top[i + 1])
			{
				ky = i; break;
			}
		if (kx != -1) sel_end_x = kx;
		if (kx != -1) sel_end_y = ky;
		if (size_state == SIZE_DRAG)
		{
			if (abs(sel_end_x - sel_x) > 0)
			{
				sel_end_y = old_end_y;
			}
			else if (abs(sel_end_y - sel_y) > 0)
			{
				sel_end_x = old_end_x;
			}
		}
		draw_drag();
	}         
	size_mouse_x = mouse_x;
	size_mouse_y = mouse_y; 
}