///////////////////////////////////////////////////////////////////////////////////////////
// 
// CS     : PUBLIC void updateUISettings(ST_PrinterStatus *pPrinterStatus, ENUM_OtherMessageID otherMsg, gboolean updateCT, gboolean updateLP, gboolean updateMSG, gboolean updateCHD)
// IN     : ST_PrinterStatus *pPrinterStatus : Information of printer status.
//          ENUM_OtherMessageID otherMsg : Message ID except printer status message.
//          gboolean updateCT : Update cartridge type area or not.
//          gboolean updateLP : Update lever position area or not.
//          gboolean updateMSG : Update message area or not.
//          gboolean updateCHD : Update cartridge pictures area or not.
// OUT    : None.
// RETURN : None.
// 
PUBLIC void updateUISettings(ST_PrinterStatus *pPrinterStatus, ENUM_OtherMessageID otherMsg, gboolean updateCT, gboolean updateLP, gboolean updateMSG, gboolean updateCHD)
{
/*** Parameters start ***/
	ENUM_STSMessageID	*pMessageID;			// Pointer to array of message ID.
	gchar				tempBuf[MAX_BUF_SIZE];	// Temporary buffer.
	gint				i;						// Counter.
	gint				updtFlg;
	gint				drawFlg;
	gboolean			flag = FALSE;
	gboolean			unknownFlag = FALSE;
/*** Parameters end ***/
	
	//printf("updateUI ct:%d updateLP:%d chd:%d otherMsg:%d\n",updateCT,updateLP,updateCHD,otherMsg);

	if (updateCT == TRUE) {
		// Set cartridge type string.
		memset(tempBuf, 0, sizeof(tempBuf));
		strncpy(tempBuf, dgettext(PACKAGE, N_("Cartridge Type:")), MAX_BUF_SIZE-1);
		if (pPrinterStatus != NULL) {
			for (i = 0; i < 2; i++) {
				switch (pPrinterStatus->cartridgeClass[i].type) {
					case ID_CARTRIDGE_TYPE_SCANNER:			// Scanner cartridge.
						if (i == 0) {
							strcat(tempBuf, dgettext(PACKAGE, N_("Scanner")));
							flag = TRUE;
						}
						else if (pPrinterStatus->cartridgeClass[0].type != pPrinterStatus->cartridgeClass[1].type) {
							if (flag == TRUE) {
								strcat(tempBuf, "/");
							}
							strcat(tempBuf, dgettext(PACKAGE, N_("Scanner")));
						}
						break;
						
					case ID_CARTRIDGE_TYPE_UNSUPPORTED:		// Unsupported cartridge.
						if (i == 0) {
							strcat(tempBuf, dgettext(PACKAGE, N_("Unsupported")));
							flag = TRUE;
						}
						else if (pPrinterStatus->cartridgeClass[0].type != pPrinterStatus->cartridgeClass[1].type) {
							if (flag == TRUE) {
								strcat(tempBuf, "/");
							}
							strcat(tempBuf, dgettext(PACKAGE, N_("Unsupported")));
						}
						break;
						
					case ID_CARTRIDGE_TYPE_PHOTO:			// F850 type.
					case ID_CARTRIDGE_TYPE_PHOTO2:			// 950i type.
					case ID_CARTRIDGE_TYPE_PHOTO_990i:		// 990i type.
					case ID_CARTRIDGE_TYPE_PHOTO_ip8600i:	// ip8600i type.
					case ID_CARTRIDGE_TYPE_PHOTO_COLOR:		// F360 type (Photo).
					case ID_CARTRIDGE_TYPE_PHOTO_ip6600d:	// iP6600D type.
					case ID_CARTRIDGE_TYPE_PHOTO_ip7500:	// iP7500 type.
						if (i == 0) {
							strcat(tempBuf, dgettext(PACKAGE, N_("Photo")));
							flag = TRUE;
						}
						else if (pPrinterStatus->cartridgeClass[0].type != pPrinterStatus->cartridgeClass[1].type) {
							if (flag == TRUE) {
								strcat(tempBuf, "/");
							}
							strcat(tempBuf, dgettext(PACKAGE, N_("Photo")));
						}
						break;
						
					case ID_CARTRIDGE_TYPE_BLACK:			// F360 type (Black).
					case ID_CARTRIDGE_TYPE_BLACK_ip2200:	// iP2200 type (Black)
					case ID_CARTRIDGE_TYPE_BLACK_HC_ip2200:	// iP2200 type (Black High Capa)
					case ID_CARTRIDGE_TYPE_BLACK_MN_ip2200:	// iP2200 type (Black Mini)
						if (i == 0) {
							strcat(tempBuf, dgettext(PACKAGE, N_("Black")));
							flag = TRUE;
						}
						else if (pPrinterStatus->cartridgeClass[0].type != pPrinterStatus->cartridgeClass[1].type) {
							if (flag == TRUE) {
								strcat(tempBuf, "/");
							}
							strcat(tempBuf, dgettext(PACKAGE, N_("Black")));
						}
						break;
						
					case ID_CARTRIDGE_TYPE_COLOR_S600:		// S600 type.
					case ID_CARTRIDGE_TYPE_COLOR_860i:		// 860i type.
					case ID_CARTRIDGE_TYPE_COLOR_S300:		// S300 type (CIL:OFF).
					case ID_CARTRIDGE_TYPE_COLOR_S300_CIL:	// S300 type (CIL:ON).
					case ID_CARTRIDGE_TYPE_COLOR_ip2200:	// iP2200 type (Color)
					case ID_CARTRIDGE_TYPE_COLOR_HC_ip2200:	// iP2200 type (Color High Capa)
					case ID_CARTRIDGE_TYPE_COLOR_MN_ip2200:	// iP2200 type (Color Mini)
					case ID_CARTRIDGE_TYPE_COLOR_ip4200:	// iP4200 type 
					case ID_CARTRIDGE_TYPE_COLOR_ip3300:	// iP3300 type 
						if (i == 0) {
							strcat(tempBuf, dgettext(PACKAGE, N_("Color")));
							flag = TRUE;
						}
						else if (pPrinterStatus->cartridgeClass[0].type != pPrinterStatus->cartridgeClass[1].type) {
							if (flag == TRUE) {
								strcat(tempBuf, "/");
							}
							strcat(tempBuf, dgettext(PACKAGE, N_("Color")));
						}
						break;
						
					default:	// Another value.
						if (i == 0) {
							unknownFlag = TRUE;
						}
						else if (unknownFlag == TRUE) {
							strcat(tempBuf, dgettext(PACKAGE, N_("Unknown")));
						}
						break;
				}
			}
		}
		setLabelString(STR_MAIN_LABEL_CARTRIDGE_TYPE, tempBuf);
	}
	
	if (updateLP == TRUE) {
		// Set paper thickness position string.
		if (pPrinterStatus != NULL) {
			memset(tempBuf, 0, sizeof(tempBuf));
			
			if( pPrinterStatus->leverPosition != ID_LEVER_POSITION_INVALID 
			  && pPrinterStatus->leverPosition != ID_LEVER_POSITION_NONE ) 
				strncpy(tempBuf, dgettext(PACKAGE, N_("Paper Thickness Lever Position:")), MAX_BUF_SIZE-1);
			else
				strncpy(tempBuf, dgettext(PACKAGE, "                                                "), MAX_BUF_SIZE-1);
			switch (pPrinterStatus->leverPosition) {
				case ID_LEVER_POSITION_UP:		// Up.
					strcat(tempBuf, dgettext(PACKAGE, N_("up")));
					break;
				
				case ID_LEVER_POSITION_DOWN:	// Down.
					strcat(tempBuf, dgettext(PACKAGE, N_("down")));
					break;
				
				case ID_LEVER_POSITION_LEFT:	// Left.
					strcat(tempBuf, dgettext(PACKAGE, N_("left")));
					break;
				
				case ID_LEVER_POSITION_RIGHT:	// Right.
					strcat(tempBuf, dgettext(PACKAGE, N_("right")));
					break;
				
				default:
					break;
			}
			setLabelString(STR_MAIN_LABEL_LEVER_POSITION, tempBuf);
		}
	}
	
	if (updateMSG == TRUE) {
		// Set message string.
		freezeText(STR_MAIN_TEXT_STATUS, TRUE);
		clearTextArea(STR_MAIN_TEXT_STATUS);
		if (otherMsg != ID_OTHER_MESSAGE_NONE) {
			insertStringToText(STR_MAIN_TEXT_STATUS, gOtherMessageTable[otherMsg]);
		}
		else {
			if (pPrinterStatus != NULL) {
				pMessageID = pPrinterStatus->pMessageID;
				for (i = 0; i < pPrinterStatus->messageNum; i++) {
					if (*pMessageID == ID_STS_MESSAGE_SC_SERVICE_ERROR_PRE) {
						gchar * msgPtr = dgettext(PACKAGE, gSTSMessageTable[*pMessageID]);
						gchar * message1
							= (gchar*)g_malloc(strlen(msgPtr) + strlen(pPrinterStatus->serviceCallID) + 1);
						gchar * message2
							= (gchar*)g_malloc(strlen(msgPtr) + strlen(pPrinterStatus->serviceCallID) + 1);
						sprintf( message1, "%s", msgPtr );
						sprintf( message2, message1, pPrinterStatus->serviceCallID );
						insertStringToText_NoConv(STR_MAIN_TEXT_STATUS, message2);
						g_free(message1);
						g_free(message2);
						break;
					}
					else{
						insertStringToText(STR_MAIN_TEXT_STATUS, gSTSMessageTable[*pMessageID]);
					}
					pMessageID++;
				}
			}
		}
		freezeText(STR_MAIN_TEXT_STATUS, FALSE);
	}

	if( pPrinterStatus != NULL) {
		drawFlg = pictDrawFlg;	pictDrawFlg = TRUE;
		updtFlg = updtPictFlg;	updtPictFlg = FALSE;
		pMessageID = pPrinterStatus->pMessageID;
		for (i = 0; i < pPrinterStatus->messageNum; i++) {
			if( (*pMessageID == ID_STS_MESSAGE_OC_OTHER )
			 || (*pMessageID == ID_STS_MESSAGE_BUSY_PRINTER_USED ) ) {
				pictDrawFlg = FALSE;	// disable draw pict area
			}
			else if((*pMessageID == ID_STS_MESSAGE_OC_REFILL ) 
				 || (*pMessageID == ID_STS_MESSAGE_OC_REFILL2 )
				 || (*pMessageID == ID_STS_MESSAGE_OC_REMAIN_UNKNOWN1 )
				 || (*pMessageID == ID_STS_MESSAGE_OC_REMAIN_UNKNOWN2 ) ) {
				updtPictFlg = TRUE;
			}
			pMessageID++;
		}

		if( drawFlg != pictDrawFlg ) {
			if( pictDrawFlg == FALSE ) {
				// Clear cartridge pixmap area 
				clearCartridgePictArea();
			}
			else {
				// Draw cartridge pixmap area again forcibly
				updateCT = TRUE;
				updateCHD = TRUE;
			}
		}
		else if( updtFlg != updtPictFlg && updtPictFlg ) {
				updateCT = TRUE;
				updateCHD = TRUE;
		}
	}

	if ((updateCT == TRUE || updateCHD == TRUE) && pictDrawFlg) {
		if (pPrinterStatus != NULL) {
			// Check cartridge class is printer cartridge or not.
			if (pPrinterStatus->cartridgeClass[0].type >= ID_CARTRIDGE_TYPE_PHOTO
			||  pPrinterStatus->cartridgeClass[1].type >= ID_CARTRIDGE_TYPE_PHOTO) {
				// Printer cartridge.
				//for (i = 0; i < CARTRIDGE_COLOR_TYPE_NUM; i++) {
				//	printf("pPrinterStatus->cartridgeStatus[%d].level = %d\n",i,pPrinterStatus->cartridgeStatus[i].level);
				//	printf("pPrinterStatus->cartridgeStatus[%d].status = %d\n",i,pPrinterStatus->cartridgeStatus[i].status);
				//}
				for (i = 0; i < CARTRIDGE_COLOR_TYPE_NUM; i++) {
					if (pPrinterStatus->cartridgeStatus[i].level != ID_INK_LEVEL_NONE
					&&  pPrinterStatus->cartridgeStatus[i].status != ID_INK_STS_NONE) {
						break;
					}
				}
				if (i == CARTRIDGE_COLOR_TYPE_NUM) {
					clearCartridgePictArea();
				}
				else {
					updateCartridgePictArea(pPrinterStatus, TRUE);
				}
			}
			else {
				// Not printer cartridge. Clear cartridge pixmap area.
				clearCartridgePictArea();
			}
		}
		else {
			clearCartridgePictArea();
		}
	}
	
	return;
}// End updateUISettings
Beispiel #2
0
void PreAgiEngine::printStr(const char* szMsg) {
	clearTextArea();
	drawStr(21, 0, IDA_DEFAULT, szMsg);
	_gfx->doUpdate();
	_system->updateScreen();
}