Ejemplo n.º 1
0
static gboolean on_configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
	FskGtkWindow win = (FskGtkWindow)data;

	// TODO: win->menuStatus && 
	gdk_threads_enter();
	if(((event->width != win->width) || (event->height != win->height))) {
		win->width = event->width;
		win->height = event->height;

		FskEvent fskEvent;
		if(kFskErrNone == FskEventNew(&fskEvent, kFskEventWindowBeforeResize, NULL, kFskEventModifierNotSet)) {
			FskWindowEventQueue(win->owner, fskEvent);
			FskWindowCheckEvents();
		}
	}
	gdk_threads_leave();

	return TRUE;
}
Ejemplo n.º 2
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.º 3
0
// TODO: here are one issue, for example, input: SHIFT+A in KPR app
//  So the event handler should be modified
static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
	FskEvent fskEvent;
	FskGtkWindow win = (FskGtkWindow)data;
	if(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);
		} 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);
	}

	return FALSE;
}
Ejemplo n.º 4
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;
}