Пример #1
0
/*************************************************
Function: SearchMoulde()
Description:搜索模块,调用查找函数,如果返回值为空则提示是否退出,否则按设置朗读单词
Calls: 	SearchWord(),YesOrNo(),SpeakWord()
Called By: main()
Input:  存有26个字母表头信息的数组,存有设置信息的结点地址
Output: // 对输出参数的说明。
Return: // 函数返回值的说明
Others: 
*************************************************/
void SearchMoulde(WorData *alphabet[],SetUp *setinfo)
{
	char *tip={" Use = to backspace, @ to clear the line, ` to exit"};
	WorData *result=NULL;
	
	system("cls");
	INTERFACE_COLOR_1;
	
	system("cls");
	printf("\n%s\n",tip);
	#ifdef MSVC
		Sleep(1000);
	#else
		sleep(1000);
	#endif
	while (1)
	{
		//display the interface
		system("cls");
		
		result=SearchWord(alphabet);
		if (result!=NULL)
		{
			PrintResult(result);
			if (setinfo->autospeak==YES)
			{
				SpeakWord(result,setinfo);
			}
			else
			{
				printf("\n\nDo you want to speak the word?:[ ]\b\b");
				if (YesOrNo() == YES)
				{
					SpeakWord(result,setinfo);
				}
				else
				{
					break;
				}
			}
		}
		else
		{
			system("cls");
			printf("\nDo you want to exit?:[ ]\b\b");
			if (YesOrNo()==YES)
			{
				return;
			}
			else
			{
				//break; //出错
				continue;
			}
		}
	}//end of while(1)
}
Пример #2
0
gboolean CheckMediaSizeCombination(LPBJFLTDEVICE bjdev, gboolean* change_item)
{
	MediaSizeTable* table = GetMediaSizeTable(bjdev->bjfltModelID);
	char* media = ValueToKey(CNCL_MEDIATYPE, bjdev->bjfltMediaType);
	char* size = ValueToKey(CNCL_PAPERSIZE, bjdev->bjfltPaperSize);
	int change;
	gboolean exec_print;
	int result = TRUE;
	gchar* applied = NULL;
	gchar* applied_title = NULL;
	GtkWidget *window = UI_DIALOG(g_main_window)->window;

	*change_item = FALSE;

	if( table == NULL )
		return TRUE;


	while( table->base != NULL )
	{
		if( !strcmp(media, table->base) )
		{
			// Get available media size.
			applied = GetAvailableSize(table->applied);

			if( SearchWord(size, applied) == NULL )
			{
				applied_title = GetAvailableSize(table->applied_title);
				change = UI_MEDIASIZE_CHANGE_SIZE;
				break;
			}
		}
		else if( !strcmp(size, table->base) )
		{
			// Get available media type.
			applied = GetAvailableMedia(table->applied);

			if( SearchWord(media, applied) == NULL )
			{
				applied_title = GetAvailableMedia(table->applied_title);
				change = UI_MEDIASIZE_CHANGE_MEDIA;
				break;
			}
		}
		table++;
	}


	if( table->base )
	{
		UIMediaSizeDialog* dialog = NULL;
		int (*show_dialog)(UIMediaSizeDialog*, gchar*) = NULL;

		switch( table->type )
		{
			case UI_MEDIASIZE_ILLEGAL:
				if( 1 >= CountWords(applied) )
				{
					dialog = g_mediasize_illegal_dialog;
					show_dialog = ShowMediaSizeIllegalDialog;
				}
				else
				{
					dialog = g_mediasize_illegal_select_dialog;
					show_dialog = ShowMediaSizeIllegalSelectDialog;
				}
				break;

			case UI_MEDIASIZE_RECOMMEND:
				dialog = g_mediasize_recommend_dialog;
				show_dialog = ShowMediaSizeRecommendDialog;
				break;
		}

		// Show the dialog when the number of applied item is more than 1.
		if( dialog && strlen(applied) > 0 )
		{
			dialog->media = media;
			dialog->size = size;
			dialog->table = (void*)table;
			dialog->change = change;

			// Show dialog.
			exec_print = show_dialog(dialog, applied_title);

			if( dialog->apply )
			{
				GtkWidget*	analyzer_combo = NULL;
				char 		*change_to_value_str = NULL;
				short		change_to_id;

				if( dialog->item_count > 1 )		/* multiple items -> get value id of chenge item */
				{
					/* Ver.3.20 */
					if( table->type == UI_MEDIASIZE_RECOMMEND )			/* recommend */
						analyzer_combo = LookupWidget(UI_DIALOG(dialog)->window,  "mediasize_recommend_combo");
					else												/* illegal   */
						analyzer_combo = LookupWidget(UI_DIALOG(dialog)->window,  "mediasize_illegal_combo");

					change_to_value_str = (char*)gtk_combo_box_get_active_text(GTK_COMBO_BOX(analyzer_combo));
					
					if( dialog->change == UI_MEDIASIZE_CHANGE_SIZE )	/* change size */
						change_to_id = NameToValue( CNCL_PAPERSIZE , change_to_value_str );
					else												/* change media */
						change_to_id = NameToValue( CNCL_MEDIATYPE , change_to_value_str );
					
					dialog->current_change_to_id = change_to_id;
					
					if(change_to_value_str){
						free(change_to_value_str);
						change_to_value_str = NULL;
					}
				}

				if( dialog->change == UI_MEDIASIZE_CHANGE_SIZE )
				{
					UpdateMenuLink(CNCL_PAPERSIZE, dialog->current_change_to_id);
					DisableSignal();
					UpdateWidgets(window, NULL);
					EnableSignal();
				}
				else
				{
					// Save current supply value.
					short supply_value = GetCurrentnValue(CNCL_MEDIASUPPLY);

					// Change the media type.
					UpdateMenuLink(CNCL_MEDIATYPE, dialog->current_change_to_id);
					DisableSignal();
					UpdateWidgets(window, NULL);
					EnableSignal();

					if( supply_value != GetCurrentnValue(CNCL_MEDIASUPPLY) )
					{
						// If no supply value for the current media type,
						// Some alert should be shown.

						// Only restore the saved supply value in this version.
						//UpdateMenuLink(CNCL_MEDIASUPPLY, supply_value);
					}
				}

				*change_item = TRUE;
			}
			result = exec_print;
		}
	}

	if( applied )
		g_free(applied);

	if( applied_title )
		g_free(applied_title);	/* Ver.3.00 */

	return result;
}