/**
 * Print() prints out the complete list to stdout. Like Sort() it relies on a
 * function pointer as its second argument. In this case the passed function
 * prints an individual ListItem along with any delimiters. The passed
 * PrintItem function needs to add a two-character delimiter to the output.
 * Ths delimiters are then removed after the last item using two \b characters.
 * The entire list is surrounded by square brackets on output. An example for
 * the printout of a list of ints is "[1, 5, 2, 10, 9]". If Print() is called
 * with a NULL list or a NULL function pointer, Print() returns STANDARD_ERROR,
 * and will otherwise return SUCCESS.
 */
int Print(ListItem *list, void (*PrintItem)(const ListItem *))
{
    list = GetFirst(list);
    printf("\n[ ");
    while (list->nextItem != NULL) {
	if (list == NULL) {
	    return STANDARD_ERROR;
	}
	PrintItem(list);
	list = list->nextItem;
    }
    PrintItem(list);
    printf("\b\b]\n ");
    return TRUE;
}
Esempio n. 2
0
File: Fsanity.c Progetto: 8l/csolve
void
PrettyPrint(Heap * h)
{
  Heap * h1;

  if(h == NULL_HEAP)
  {
    printf(" nil ");
    return;
  }

  printf("(");

  h1 = h;
  do
  {
    PrintItem(ITEM(h1));
    printf("[%u] ", RANK(h1));
    PrettyPrint(CHILD(h1));
    h1 = FORWARD(h1);
  }
  while(h1 != h);

  printf(")");
}
Esempio n. 3
0
//int MYCall_Back(void *pdata,int argc,char *value[],char *name[]);
TestShow::TestShow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::TestShow)
{
    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);

    page = -1;
    //初始化显示框
    model=new QStandardItemModel(this);
    model->setColumnCount(1);//ID option name age gender  Result time,add some ,totally 11
    ui->lineEdit_Year->setValidator(new QIntValidator(0,10000,this));
    ui->lineEdit_Month->setValidator(new QIntValidator(0,12,this));
    ui->lineEdit_Day->setValidator(new QIntValidator(0,30,this));
    ui->pushButton_Exit->setFocusPolicy(Qt::NoFocus);
    connect(ui->pushButton_up,SIGNAL(clicked()),this,SLOT(page_up()));
    connect(ui->pushButton_down,SIGNAL(clicked()),this,SLOT(page_down()));
    connect(ui->pushButton_go,SIGNAL(clicked()),this,SLOT(page_go()));
    connect(ui->pushButton_Exit,SIGNAL(clicked()),this,SLOT(home()));
    connect(ui->tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(setPrintTrue(QModelIndex)));
    connect(ui->pushButton_print,SIGNAL(clicked()),this,SLOT(PrintItem()));
    connect(ui->pushButton_Search,SIGNAL(clicked()),this,SLOT(find_info()));
    connect(ui->pushButton_LogOut,SIGNAL(clicked()),this,SLOT(logout()));
    connect(ui->pushButton_Edit,SIGNAL(clicked()),this,SLOT(view_clicked()));
    QRegExp rx("^[0-9]{1,10}$");//这个10就是最大长度
    QValidator *validator = new QRegExpValidator(rx,0);
    ui->lineEdit_Page->setValidator(validator);
    dateEdit=new QDateEdit(this);
    dateEdit->setDisplayFormat("yyyy-MM-dd");
    dateEdit->setGeometry(QRect(413,90,163,29));
    dateEdit->setAlignment(Qt::AlignCenter);
    dateEdit->setDate(QDateTime::currentDateTime().date());

    ui->pushButton->setVisible(false);
}
Esempio n. 4
0
File: io.c Progetto: MrAlone/logic
void PrintItem(struct Item* item)
{
	if (item == NULL) return;

	if (item->type == PREDICAT)	PrintPredicat((Predicat*)item->obj);
	if (item->type == OPERATION) PrintOperation((Predicat*)item->obj);

	PrintItem(item->next);
}
Esempio n. 5
0
// display the contents of an item set
void PrintItemSet(LR_ITEM_SET* I, GRAMMAR_TABLE* G)
{
    while (I) 
    {
        LR_ITEM item = I->item;
        PrintItem(item, G);
        I = I->next;
    }
}
Esempio n. 6
0
File: io.c Progetto: MrAlone/logic
void PrintList(char* path, List* list)
{
	of = fopen(path,"at");

	fprintf(of,"\n=================================== List ===================================\n");

	PrintItem(list->head);

	fclose(of);
}
//prints whole list using printItem extern function
void print_list(Tlist list) {
    //extern void PrintItem(Titem c);
    Tpointer aux1, aux2;

    aux1 = list;
    while (aux1 != NULL) {
        PrintItem(aux1->item);
        aux2 = aux1->next;
        aux1 = aux2;
    }
}
Esempio n. 8
0
void printNode( struct node* node ) { // Print the node
  if ( node != NULL ) {
    println(">>NODE:: numChildren: %d, isLeafNode: %d", node->numChildren, node->isLeafNode);
    int i;
    for ( i = 0; i < node->numChildren; i++ ) {
      println(">>Node->keys[%d]=%d, \t", i, node->keys[i]);
      if ( node->isLeafNode ) { // then has linkedList  
        PrintItem( node->courseList[i] );
      }
    }
    if ( node->isLeafNode && node->nextLeaf != NULL ) {
      println(">>Node's rightmost child points to new node, with key[0] = %d", node->nextLeaf->keys[0]);
    }
  } else {
    println("Node is null." );
  }
} // printNode
Esempio n. 9
0
/*************
 * DESCRIPTION:	make formular and put it to printer/file/window
 * INPUT:			-
 * OUTPUT:			-
 *************/
BOOL CRegisterBox::MakeFormular()
{
	TEXTMETRIC tm;
	POINT PhysPageSize;
	CDC *pDC;
	HDC hPr;
	int nLinesPerPage, no;
	char szBuf[128];
	float sum;

	CPrintDialog PrintDlg(FALSE);
	
	GetDlgItemText(ID_REGISTER_FNAME,  fname,   STRMAX);
	GetDlgItemText(ID_REGISTER_LNAME,  lname,   STRMAX);
	GetDlgItemText(ID_REGISTER_STREET, street,  STRMAX);
	GetDlgItemText(ID_REGISTER_CITY,	  city,    STRMAX);
	GetDlgItemText(ID_REGISTER_COUNTRY,country, STRMAX);
	GetDlgItemText(ID_REGISTER_EMAILIT,email,   STRMAX);
					 
	if (!(fname[0] && lname[0] && street[0] && city[0] && country[0]))
	{
		MessageBox("You didn't fill out enough items!", NULL, MB_OK|MB_ICONHAND);
		return FALSE;
	}

	if (form == 1 && !email[0])
	{
		MessageBox("You have to specify an E-Mail address\nif you want to order via E-Mail!", NULL, MB_OK|MB_ICONHAND);
		return FALSE;
	}

	if (device == PRINTER)
	{
		PrintDlg.DoModal();
		if (AfxGetApp()->GetPrinterDeviceDefaults(&PrintDlg.m_pd))
		{
			hPr = PrintDlg.GetPrinterDC();
			if (!hPr)
			{
				MessageBox("Printer error", NULL, MB_OK|MB_ICONHAND);
				return FALSE;
			}
		}
		else
		{
			MessageBox("Printer error", NULL, MB_OK|MB_ICONHAND);
			return FALSE;
		}

		pDC = CDC::FromHandle(hPr);

		if (pDC->Escape(STARTDOC, 14, (LPSTR)"PrntFile text", NULL) < 0)
		{
			MessageBox("Unable to start print job", NULL, MB_OK|MB_ICONHAND);
			DeleteDC(hPr);
			return FALSE;
		}

		pDC->GetTextMetrics(&tm);
		LineSpace = tm.tmHeight + tm.tmExternalLeading;
		pDC->Escape(GETPHYSPAGESIZE, NULL, (LPSTR) NULL, (LPSTR) &PhysPageSize);
		nLinesPerPage = PhysPageSize.y / LineSpace;
	}

	nLineLength = 10;
	nCurrentLine = 0;

	no = 1;
	while (lines[nCurrentLine])
		Print(hPr, lines[nCurrentLine]);

	sum = 0.0f;

	PrintItem(hPr, "     First   :", fname);
	PrintItem(hPr, "     Name    :", lname);
	PrintItem(hPr, "     Street  :", street);
	PrintItem(hPr, "     ZIP,City:", city);
	PrintItem(hPr, "     Country :", country);
	Print(hPr, "");
	PrintItem(hPr, "     E-Mail  :", email);
	Print(hPr, "");
	Print(hPr, "");
	Print(hPr, "");
	Print(hPr, "");
	Print(hPr, "No.    Article                                      Price  Sum");
	Print(hPr, "--------------------------------------------------------------------");

	sprintf(szBuf, " 1     RayStorm for %s via %s           %4.2f  %4.2f %s", version[ver], forms[form], prices[ix], prices[ix] * no, currencies[curr]);
	Print(hPr, szBuf);
	sum+= prices[ix]*no;

	Print(hPr, "====================================================================");
	sprintf(szBuf, "TOTAL                                                      %4.2f %s", sum, currencies[curr]);
	Print(hPr, szBuf);
										 
	while (lines[nCurrentLine])
	 	Print(hPr, lines[nCurrentLine]);

	if (device == PRINTER)
	{
		pDC->Escape(NEWFRAME, 0, 0L, 0L);
		pDC->Escape(ENDDOC, 0, 0L, 0L);
		DeleteDC(hPr);
	}

	return TRUE;
}