示例#1
0
 virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event) {
     if (event->type == GDK_KEY_PRESS && shortcut_key(event->key) == GDK_Escape &&
         sp_canvas_item_is_visible(_rubber))
     {
         _cancel = true;
         sp_canvas_item_hide(_rubber);
         return true;
     }
     return ControlPoint::_eventHandler(event_context, event);
 }
示例#2
0
/****************************************************************
*																*
*			Met en place les raccourcis clavier					*
*																*
****************************************************************/
void set_shortcuts(void)
{
	int dropdowns, title, entree, bar, delta;
	int menu_idx, entree_idx;
	char key[SHORTCUT_SIZE];
	int size;

	dropdowns = Menu[0].ob_tail;
	bar = Menu[0].ob_head;	/* bar */
	bar = Menu[bar].ob_head;	/* active */
	bar = Menu[bar].ob_head;	/* 1Šre G_BOX */

	menu_idx = 0;
	for (title = Menu[dropdowns].ob_head; title != dropdowns; title = Menu[title].ob_next, menu_idx++)
	{
		/* son fils est un G_BOX contenant les entr‚es */
		entree_idx = 0;
		size = 0;

		if (menu_idx == 0)
			/* calcul le d‚calage sur le 1er menu */
			delta = Menu[title].ob_x - Menu[bar+menu_idx].ob_x;
		else
			/* on met le menu juste au dessous de l'entr‚e */
			Menu[title].ob_x = Menu[bar+menu_idx].ob_x + delta;

		for (entree = Menu[title].ob_head; entree != title; entree = Menu[entree].ob_next, entree_idx++)
			if (MenuShortCuts[menu_idx].menu[entree_idx].itemid == entree)
			{
				if (MenuShortCuts[menu_idx].menu[entree_idx].state == FAIL)
				{
					if (MenuShortCuts[menu_idx].menu[entree_idx].text[0] == '-')	/* ‡a n'est pas raccourcissable */
						continue;

					if (menu_idx != 5 || entree_idx > 3)	/* cas des entr‚es de d‚placement */
						MenuShortCuts[menu_idx].menu[entree_idx].text[MenuShortCuts[menu_idx].offset] = '\0';	/* pas de raccourcis */

					size = MAX(size, (int)strlen(MenuShortCuts[menu_idx].menu[entree_idx].text) +1);
					continue;
				}

				shortcut_key(MenuShortCuts[menu_idx].menu[entree_idx].key, MenuShortCuts[menu_idx].menu[entree_idx].state, key, FALSE);

				strcpy(MenuShortCuts[menu_idx].menu[entree_idx].text + MenuShortCuts[menu_idx].offset, key);

				size = MAX(size, (int)strlen(MenuShortCuts[menu_idx].menu[entree_idx].text) +1);
			}

		size *= gr_cw;
		Menu[title].ob_width = size;

		if (Menu[title].ob_x + Menu[title].ob_width > max_w - 5)
			Menu[title].ob_x = max_w - 5 - Menu[title].ob_width;

		entree_idx = 0;
		for (entree = Menu[title].ob_head; entree != title; entree = Menu[entree].ob_next, entree_idx++)
		{
			Menu[entree].ob_width = size;
			if (Menu[entree].ob_spec.free_string[0] == '-')
			{
				int i;

				for (i=(int)strlen(Menu[entree].ob_spec.free_string); i<size/8; i++)
					Menu[entree].ob_spec.free_string[i] = '-';
				Menu[entree].ob_spec.free_string[size/8] = '\0';
			}
		}
	}
} /* set_shortcuts */