Ejemplo n.º 1
0
static gboolean on_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data)
{
	FskEvent fskEvent;
	FskGtkWindow win = (FskGtkWindow)data;
	double dx, dy;
	float deltaX, deltaY;
	
	if (gdk_event_get_scroll_deltas((GdkEvent*)event, &dx, &dy)) {
		deltaX = (float)dx;
		deltaY = (float)dy;
	}
	else {
		deltaX = (float)event->delta_x;
		deltaY = (float)event->delta_y;
	}
	deltaX = 10 * deltaX;
	deltaY = -10 * deltaY;
	if(win->menuStatus && (kFskErrNone == FskEventNew(&fskEvent, kFskEventMouseWheel, NULL, kFskEventModifierNotSet))) {
		FskEventParameterAdd(fskEvent, kFskEventParameterMouseWheelDeltaX, sizeof(float), &deltaX);
		FskEventParameterAdd(fskEvent, kFskEventParameterMouseWheelDeltaY, sizeof(float), &deltaY);
		FskWindowEventQueue(win->owner, fskEvent);
		FskWindowCheckEvents();
	}

	return TRUE;
}
Ejemplo n.º 2
0
static void on_menu_select_cb(GtkWidget *widget, gpointer data)
{
	FskEvent fskEvent;
	menuItems selected = (menuItems)data;
	FskGtkWindow win;

	//Have to check firstly since radio item will emit two signals
	if (selected == NULL)
		return;
	win = selected->win;
	if (win->menuStatus == false)
		return;

	gdk_threads_enter();

	if (GTK_IS_CHECK_MENU_ITEM(selected->item) && !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(selected->item)))
		return;
	if (kFskErrNone == FskEventNew(&fskEvent, kFskEventMenuCommand, NULL, kFskEventModifierNotSet)) {
		SInt32 command = selected->id;
		FskEventParameterAdd(fskEvent, kFskEventParameterCommand, sizeof(command), &command);
		FskWindowEventQueue(selected->win->owner, fskEvent);
		FskWindowCheckEvents();
	}

	gdk_threads_leave();
}
Ejemplo n.º 3
0
void FskGtkWindowSetMenuItemCallback(FskGtkWindow win, GtkWidget* menuItem, int id)
{
	FskEvent fskEvent;
	menuItems entry = NULL;

	if(kFskErrNone == FskMemPtrNewClear(sizeof(menuItemsRecord), (FskMemPtr*)&entry)) {
		menuBars entryBar = NULL;
		entry->win = win;
		entry->id  = id;
		entry->item= menuItem;
		
		entryBar = win->menu;
		while(entryBar) {
			if(entryBar->id == (id & 0xFF00)) {
				break;
			}
			entryBar = entryBar->next;
		}
		FskListAppend(&entryBar->menulist, entry);
		
		// Update menuItem immediately (enabled? checked?)
		if(kFskErrNone == FskEventNew(&fskEvent, kFskEventMenuStatus, NULL, kFskEventModifierNotSet)) {
			FskEventParameterAdd(fskEvent, kFskEventParameterCommand, sizeof(id), &id);
			FskWindowEventSend(win->owner, fskEvent);
		}
		g_signal_connect(menuItem, "activate", G_CALLBACK(menu_select_cb), (gpointer)entry);
	}
}
Ejemplo n.º 4
0
static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
	FskEvent fskEvent;
	FskGtkWindow win = (FskGtkWindow)data;
	if (event->state & GDK_CONTROL_MASK) return FALSE;
	if(win->menuStatus && (kFskErrNone == FskEventNew(&fskEvent, kFskEventKeyDown, NULL, event->is_modifier))) {
		char key[2];

		if(event->is_modifier) {
			UInt32 funcKey = event->keyval & 0xFFFF;
			FskEventParameterAdd(fskEvent, kFskEventParameterFunctionKey, sizeof(funcKey), &funcKey);
			update_menubar(win);
		} else {
			if(event->keyval < 0xFF) {
				key[0] = (char)event->keyval;
			} else {
				switch(event->keyval) {
					case GDK_KEY_Left:
						key[0] = 28;
						break;
					case GDK_KEY_Right:
						key[0] = 29;
						break;
					case GDK_KEY_Up:
						key[0] = 30;
						break;
					case GDK_KEY_Down:
						key[0] = 31;
						break;
					default:
						key[0] = (char)event->keyval;
						break;
				}
			}

			key[1] = 0;
			FskEventParameterAdd(fskEvent, kFskEventParameterKeyUTF8, 2, key);
		}
		FskWindowEventQueue(win->owner, fskEvent);
		FskWindowCheckEvents();
	}

	return FALSE;
}
Ejemplo n.º 5
0
static void menu_select_cb(GtkWidget *widget, gpointer data)
{
	FskEvent fskEvent;
	menuItems selected = (menuItems)data;
	menuBars entryBar;
	menuItems items = NULL;
	int groupID;

	//Have to check firstly since radio item will emit two signals
	if(GTK_IS_CHECK_MENU_ITEM(selected->item) && !gtk_check_menu_item_get_active((GtkCheckMenuItem*)selected->item))
		return;

	if(kFskErrNone == FskEventNew(&fskEvent, kFskEventMenuCommand, NULL, kFskEventModifierNotSet)) {
		SInt32 command = selected->id;
		FskEventParameterAdd(fskEvent, kFskEventParameterCommand, sizeof(command), &command);
		FskWindowEventQueue(selected->win->owner, fskEvent);
	}

	// FIXME: actually, we should do this operations in event like menubar popup, but I do not find suitable event till now
	// So just put them here!!!
	FskGtkWindow win = selected->win;
	groupID = selected->id & 0xFF00;
	entryBar = win->menu;

	while(entryBar) {
		if(entryBar->id == groupID) {
			break;
		}
		
		entryBar = entryBar->next;
	}
	if(entryBar) {
		for(items = (menuItems)entryBar->menulist; items != NULL; items = items->next) {
			int id = items->id;
			if(kFskErrNone == FskEventNew(&fskEvent, kFskEventMenuStatus, NULL, kFskEventModifierNotSet)) {
				FskEventParameterAdd(fskEvent, kFskEventParameterCommand, sizeof(id), &id);
				FskWindowEventSend(win->owner, fskEvent);
			}
		}
	}
}
Ejemplo n.º 6
0
void update_menu(FskGtkWindow win, menuBars menu)
{
	FskEvent fskEvent;
	menuItems items = NULL;
	for (items = (menuItems)menu->menulist; items != NULL; items = items->next) {
		int id = items->id;
		if (kFskErrNone == FskEventNew(&fskEvent, kFskEventMenuStatus, NULL, kFskEventModifierNotSet)) {
			FskEventParameterAdd(fskEvent, kFskEventParameterCommand, sizeof(id), &id);
			FskWindowEventSend(win->owner, fskEvent);
			FskWindowCheckEvents();
		}
	}
}
Ejemplo n.º 7
0
static gboolean on_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
	FskEvent fskEvent;
	FskGtkWindow win = (FskGtkWindow)data;
	UInt32	index = 0;

	int x = (int)event->x;
	int y = (int)event->y;
	if(win->menuStatus && (kFskErrNone == FskEventNew(&fskEvent, kFskEventMouseMoved, NULL, kFskEventModifierNotSet))) {
		FskPointAndTicksRecord pat;
		pat.pt.x = x;
		pat.pt.y = y;
		pat.index = 0;
		pat.ticks = event->time;
		FskEventParameterAdd(fskEvent, kFskEventParameterMouseLocation, sizeof(pat), &pat);
		FskEventParameterAdd(fskEvent, kFskEventParameterCommand, sizeof(index), &index);
		FskWindowEventQueue(win->owner, fskEvent);
		FskWindowCheckEvents();
	}

	return TRUE;
}
Ejemplo n.º 8
0
static gboolean on_button_release(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	FskEvent fskEvent;
	int x = (int)event->x;
	int y = (int)event->y;
	FskGtkWindow win = (FskGtkWindow)data;

	if(kFskErrNone == FskEventNew(&fskEvent, kFskEventMouseUp, NULL, kFskEventModifierNotSet)) {
		FskPointAndTicksRecord pat;
		pat.pt.x = x;
		pat.pt.y = y;
		pat.index = event->button - 1;
		pat.ticks = event->time;
		FskEventParameterAdd(fskEvent, kFskEventParameterMouseLocation, sizeof(pat), &pat);
		FskWindowEventQueue(win->owner, fskEvent);
	}
	return TRUE;
}
Ejemplo n.º 9
0
static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	FskEvent fskEvent;
	int x = (int)event->x;
	int y = (int)event->y;
	FskGtkWindow win = (FskGtkWindow)data;

	if(win->menuStatus && (kFskErrNone == FskEventNew(&fskEvent, kFskEventMouseDown, NULL, kFskEventModifierNotSet))) {
		FskPointAndTicksRecord pat;
		pat.pt.x = x;
		pat.pt.y = y;
		pat.index = event->button - 1; //Different with FSK button index
		pat.ticks = event->time;
		FskEventParameterAdd(fskEvent, kFskEventParameterMouseLocation, sizeof(pat), &pat);
		FskWindowEventQueue(win->owner, fskEvent);
		FskWindowCheckEvents();
	}
	return TRUE;
}
Ejemplo n.º 10
0
static FskErr DragDropTargetProc(UInt32 message, UInt32 mouseX, UInt32 mouseY, void *dropData, void *refCon)
{
	FskErr err = kFskErrNone;
	FskWindow window = (FskWindow)refCon;
	FskDragDropFile fileList;
	UInt32 fileListSize;
	FskEvent event;
	FskPointAndTicksRecord pos;
	FskTimeRecord now;
	FskTimeGetNow(&now);

	pos.pt.x = mouseX;
	pos.pt.y = mouseY;
	pos.ticks = (((double)now.seconds) * 1000.0) + (((double)now.useconds) / 1000.0);
	
	switch(message) {
		case kFskDragDropTargetEnterWindow:
			// Calculate the size of the packed file list
			fileList = (FskDragDropFile)dropData;
			fileListSize = 0;
			while (NULL != fileList) {
				fileListSize += FskStrLen(fileList->fullPathName) + 1;
				fileList = fileList->next;
			}

			// Pack the file list into a null separated list
			// Post a "drop target enter window" event
			if (0 != fileListSize) {
				char *packedFileList = 0;
				char *packedFileListWalker;

				++fileListSize;
				FskMemPtrNewClear(fileListSize, &packedFileList);
				*packedFileList = 0;
				packedFileListWalker = packedFileList;
				fileList = (FskDragDropFile)dropData;
				while (NULL != fileList) {
					FskStrCopy(packedFileListWalker, fileList->fullPathName);
					if (NULL != fileList->next) {
						packedFileListWalker += FskStrLen(fileList->fullPathName) + 1;
					}
					fileList = fileList->next;
				}
				if ((err = FskEventNew(&event, kFskEventWindowDragEnter, NULL, kFskEventModifierNotSet)) != kFskErrNone)
					goto bail;
				FskEventParameterAdd(event, kFskEventParameterMouseLocation, sizeof(pos), &pos);
				FskEventParameterAdd(event, kFskEventParameterFileList, fileListSize, packedFileList);
				FskWindowEventSend(window, event);
				FskMemPtrDispose(packedFileList);
			}
			break;

		case kFskDragDropTargetOverWindow:
			// Windows doesn't send WM_MOUSEMOVE events when dragging over a window!!
#if TARGET_OS_WIN32 || TARGET_OS_MAC
			if ((err = FskEventNew(&event, kFskEventMouseMoved, NULL, kFskEventModifierNotSet)) != kFskErrNone)
				goto bail;
			FskEventParameterAdd(event, kFskEventParameterMouseLocation, sizeof(pos), &pos);
			FskWindowEventSend(window, event);
#endif
			break;

		case kFskDragDropTargetLeaveWindow:
			if ((err = FskEventNew(&event, kFskEventWindowDragLeave, NULL, kFskEventModifierNotSet)) != kFskErrNone)
				goto bail;
			FskWindowEventSend(window, event);
			break;

		case kFskDragDropTargetDropInWindow:
			if ((err = FskEventNew(&event, kFskEventMouseUp, NULL, kFskEventModifierNotSet)) != kFskErrNone)
				goto bail;
			FskEventParameterAdd(event, kFskEventParameterMouseLocation, sizeof(pos), &pos);
			FskWindowEventSend(window, event);
			break;
	}

bail:
	return err;
}