guistatus.c
来自「这个是boot gui的程序」· C语言 代码 · 共 361 行
C
361 行
/*
* Start of Zoran Standard Header
* Copyright (c) 2005, 2006 Zoran Corporation
*
*
* All rights reserved. Proprietary and confidential.
*
* DESCRIPTION for guistatus.c
* GUI status/state handling
*
* NEW HISTORY COMMENT (description must be followed by a blank line)
* <Enter change description here>
* ===== HISTORY of changes in //depot/imgeng/sw/se_gw/gui/guistatus.c
*
* 1/Mar/06 #8 dstrauss display "(PictBridge)" in the ready state if a
* camera is connected.
* 24/Feb/06 #7 dstrauss If we are "printing", check job types, not
* just the number of job. when we check if we
* should update the state because PictBridge
* always has a non-printing job active.
* 24/Jan/06 #6 dstrauss Added GUIGetError()
* 6/Jan/06 #5 dstrauss distinguish between "printing" and "scanning"
* 16/Dec/05 #4 dstrauss Should be "Scanner jam", not "Scanned jam".
* 14/Dec/05 #3 dstrauss Added UImode so PictBridge will work; handle
* cancelled PictBridge jobs.
* 13/Dec/05 #2 dstrauss Added status for memory cards.
* 9/Dec/05 #1 dstrauss Created.
*
*
* End of Zoran Standard Header
*/
#include "standard.h"
#include "propman.h"
#include "printdrv.h"
#include "job.h"
#include "guigraphics.h"
#include "guistatus.h"
/*
* Tags for the various status strings we can display. The first
* items mirror the major states defined in guistatus.h; the rest are
* substates of the "ready" or the "printing" states.
*/
typedef enum _eStatusString {
eStatusStringBogus, /* the 0'th value is illegal */
eStatusStringInit,
eStatusStringReady,
eStatusStringReadyPictBridge,
eStatusStringPrinting,
eStatusStringCanceling,
eStatusStringReadingCard,
eStatusStringPaperjam,
eStatusStringPaperout,
eStatusStringPaperpath,
eStatusStringInklevel,
eStatusStringScannerjam,
eStatusStringCardError,
eStatusStringTooManyCards,
eStatusStringScanning,
} eStatusString;
/* Structure to hold a status string. Each string
* is tagged with the status value it goes with.
*
*/
typedef struct _s_StatusString {
eStatusString tag;
const char *string;
} StatusString;
static const StatusString statusStrings[] = {
{ eStatusStringInit, "Initializing ..." },
{ eStatusStringReady, "Idle" },
{ eStatusStringReadyPictBridge, "Idle (PictBridge)" },
{ eStatusStringPrinting, "Printing ..." },
{ eStatusStringCanceling, "Canceling ..." },
{ eStatusStringReadingCard, "Reading Card ... " },
{ eStatusStringPaperjam, "Paper Jam" },
{ eStatusStringPaperout, "Paper Out" },
{ eStatusStringPaperpath, "Paper path blocked" },
{ eStatusStringInklevel, "Ink level low" },
{ eStatusStringScannerjam, "Scanner jam" },
{ eStatusStringCardError, "Card Error" },
{ eStatusStringTooManyCards, "Too many cards" },
{ eStatusStringScanning, "Scanning ..." },
};
/* number of items in the list */
#define NUMSTATUS (sizeof(statusStrings)/sizeof(statusStrings[0]))
/* Structure to hold a mapping from an error bit to an errorstring tag.
*/
typedef struct _s_ErrorbitMap {
const int errorBit;
const eStatusString statusString;
} ErrorbitMap;
/* mappings from error bits to error strings. These are in
* priority order (highest priority error first.
*/
static const ErrorbitMap errorbitMaps[] = {
{ OM_PAPER_JAM_ERROR, eStatusStringPaperjam },
{ OM_PAPER_OUT_ERROR, eStatusStringPaperout },
{ OM_CARRIER_PATH_OBSTRUCTED, eStatusStringPaperpath },
{ OM_INKLEVEL_LOW, eStatusStringInklevel },
{ OM_SCANNER_JAM_ERROR, eStatusStringScannerjam },
};
/* number of items in the list */
#define NUMMAPPINGS (sizeof(errorbitMaps)/sizeof(errorbitMaps[0]))
/* what we think the current status is */
static eGStatus currentStatus;
/* what we think the current status string it */
static eStatusString currentString;
/* error state as reported by the rest of the system */
static unsigned int currentError;
/* current state of the memory card (in or out) */
static e_omCARDINSERTSTATE memcardState;
/* current state of the PictBridge connection */
static e_omDPSCONNECTED DPSState;
/* Look up a status string. Return an empty string if we can't find it */
static const char *lookupStatusString( eStatusString statusString )
{
int index;
for (index = 0; index < NUMSTATUS; index++) {
if (statusStrings[index].tag == statusString) {
return (statusStrings[index].string);
}
}
return ("");
}
static eStatusString mapErrorToStatus( int errorbits )
{
int index;
for (index = 0; index < NUMMAPPINGS; index++) {
if (errorbitMaps[index].errorBit & errorbits) {
return (errorbitMaps[index].statusString);
}
}
/* couldn't find a mapping, so just 0 */
return (eStatusStringBogus);
}
static void displayStatus( eStatusString statusString )
{
const char *string;
string = lookupStatusString(currentString);
GUIStatusText(string);
}
void GUISetStatus(eGStatus newStatus)
{
currentStatus = newStatus;
}
eGStatus GUIGetStatus(void)
{
return (currentStatus);
}
unsigned int GUIGetError(void)
{
return (currentError);
}
int GUIMemcardReady(void)
{
int retval = 0;
switch (memcardState) {
case DONEREADINGMEMORYCARD:
retval = 1;
break;
case NOMEMORYCARD:
case READINGMEMORYCARD:
case MEMORYCARDINSERTED:
case MEMORYCARDERROR:
case TOOMANYMEMORYCARDS:
break;
}
return (retval);
}
/* Check the current state of the box and update the
* status display if necessary.
*/
void GUIUpdateStatus()
{
switch (currentStatus) {
case GStatusInit:
if (currentString != eStatusStringInit) {
currentString = eStatusStringInit;
displayStatus(currentString);
}
break;
case GStatusReady:
if ( GetNumberOfActiveJobs()
&& ( GetActiveJobOfType(JOB_COPY)
|| GetActiveJobOfType(JOB_SCAN)
|| GetActiveJobOfType(JOB_PRINT)
|| GetActiveJobOfType(JOB_PHOTOPRINT)) ) {
/* if there are active jobs of the right type, switch to the
* "printing" state
*/
currentStatus = GStatusPrinting;
} else {
/* No active jobs; check memory card status */
switch (memcardState) {
case DONEREADINGMEMORYCARD:
case NOMEMORYCARD:
/* no memory card, or card has been read - display ready string */
if (DPSState == DPSPICTBRIDGE) {
if (currentString != eStatusStringReadyPictBridge) {
currentString = eStatusStringReadyPictBridge;
displayStatus(currentString);
}
} else if (currentString != eStatusStringReady) {
currentString = eStatusStringReady;
displayStatus(currentString);
}
break;
case READINGMEMORYCARD:
case MEMORYCARDINSERTED:
if (currentString != eStatusStringReadingCard) {
currentString = eStatusStringReadingCard;
displayStatus(currentString);
}
break;
case MEMORYCARDERROR:
if (currentString != eStatusStringCardError) {
currentString = eStatusStringCardError;
displayStatus(currentString);
}
break;
case TOOMANYMEMORYCARDS:
if (currentString != eStatusStringTooManyCards) {
currentString = eStatusStringTooManyCards;
displayStatus(currentString);
}
}
}
break;
case GStatusPrinting:
if ( GetNumberOfActiveJobs()
&& ( GetActiveJobOfType(JOB_COPY)
|| GetActiveJobOfType(JOB_SCAN)
|| GetActiveJobOfType(JOB_PRINT)
|| GetActiveJobOfType(JOB_PHOTOPRINT)) ) {
/* If there are active jobs of the right type, check to see if
there is an error. */
eStatusString newString;
newString = mapErrorToStatus(currentError);
if (newString == eStatusStringBogus) {
/* there is no error, so display "printing" or "scanning" */
if (GetActiveJobOfType(JOB_SCAN)) {
newString = eStatusStringScanning;
} else {
newString = eStatusStringPrinting;
}
}
if (currentString != newString) {
currentString = newString;
displayStatus(currentString);
}
} else {
/* no jobs active -- switch to the "ready" state */
currentStatus = GStatusReady;
}
break;
case GStatusCanceling:
{
int numJobs;
numJobs = GetNumberOfActiveJobs();
/* As long as there are active jobs, stay in the canceling state.
* Note that in PictBridge mode there is always at least one
* job active at all times.
*/
if (((DPSState == DPSPICTBRIDGE) && numJobs > 1)
|| (DPSState != DPSPICTBRIDGE && numJobs > 0) ) {
if (currentString != eStatusStringCanceling) {
currentString = eStatusStringCanceling;
displayStatus(currentString);
}
} else {
/* no print jobs active -- switch to the "ready" state */
currentStatus = GStatusReady;
}
}
break;
}
}
static OMERROR PrinterErrorCallback(OMPROPERTY property,
OMLEVEL level,
POMVARIANT newValue)
{
currentError = newValue->value.uVal; /* update our copy of the error state */
return (OMnoError);
}
static OMERROR MemcardCallback(OMPROPERTY property,
OMLEVEL level,
POMVARIANT newValue)
{
/* update our copy of the memcard state */
memcardState = (e_omCARDINSERTSTATE)newValue->value.uVal;
return (OMnoError);
}
static OMERROR DPSCallback(OMPROPERTY property,
OMLEVEL level,
POMVARIANT newValue)
{
/* update our copy of the DPS state */
DPSState = (e_omDPSCONNECTED)newValue->value.uVal;
return (OMnoError);
}
void GUIInitStatus()
{
OMsubscribe(omPRINTERSTATUS, PrinterErrorCallback, NULL);
// memory card properties notification
OMsubscribe(omCARDINSERTSTATE, MemcardCallback, NULL);
// is a pictbridge in your future?
OMsubscribe(omDPSCONNECTED, DPSCallback, NULL);
}
e_omUIMODE UImode()
{
if ( DPSState == DPSPICTBRIDGE ) {
return (PICTBRIDGEMODE);
} else if ( GUIMemcardReady() ) {
return (PHOTOMODE);
} else {
return(COPYMODE);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?