int main( int argc, char* argv[] ) { std::cout << "Tegan Language Compiler v.0.1" << std::endl<< std::endl << std::endl; FILE* file = fopen( argv[ 1 ], "r" ); if ( file == 0 ) { std::cout << "Can't open file " << argv[ 1 ] << "\n"; return 1; } if ( argv[ 2 ] == NULL ) { std::cout << "Specify output file" << std::endl; return 1; } char* output = argv[ 2 ]; auto parser = Parser(); Node* root = parser.parse( file ); std::cout << std::endl; Printer printer = Printer(); Codegen codegen = Codegen(); for ( int i = 3; i < argc; ++i ) { addOpt( argv[ i ], codegen ); } if ( root != NULL ) { std::cout << std::endl; root->accept( printer ); if ( !parser.isFailed() ) { std::cout << std::endl; root->accept( codegen ); codegen.dump(); codegen.save( output ); } } else { std::cout << "EXIT" << std::endl; } std::cout << std::endl << std::endl << std::endl; }
void __fastcall TPrintList::PrintF121Click(TObject *Sender) { if(Memo1->Lines->Strings[0].Length()>=153) { int lenleft=Memo1->Lines->Strings[0].Length()-152; AnsiString mess; mess="Line width exceeds printer width by "+IntToStr(lenleft)+" charactors.\n"; mess=mess+"Do you still want to print it ??\n"; int messbox=Application->MessageBox(mess.c_str(),"Possible problem with print job...",MB_YESNO); if(messbox==IDNO) return; } if (PrintDialog1->Execute()) { int ln=0; TPrinter *Prn=Printer(); Prn->Canvas->Font->Name="Lucida Console"; Prn->Canvas->Font->Style=TFontStyles()<<fsBold; Prn->Canvas->Font->Size=8;// read up on this one // int chrsize=Prn->Canvas->Font->PixelsPerInch; int maxlines=91; if(Memo1->Lines->Strings[0].Length()>=114) { Prn->Orientation=poLandscape; maxlines=70; } Prn->BeginDoc(); for( int i=0;i<Memo1->Lines->Count;i++) { Prn->Canvas->TextOut(200,200+(ln*Prn->Canvas->TextHeight(Memo1->Lines->Strings[i])), Memo1->Lines->Strings[i]); ln++; if(ln>=maxlines) { Prn->NewPage(); ln=0; } } Prn->EndDoc(); } }
void my_CHANGE_PRIORITY(SYSTEM_CALL_DATA *SystemCallData){ INT32 PID = (INT32)(SystemCallData->Argument[0]); INT32 newPri = (INT32)(SystemCallData->Argument[1]); if (newPri <= 0 || newPri >= 100){ *(SystemCallData->Argument[2]) = ERR_BAD_PARAM; return; } ReadyQueue_Lock("Change Priority"); PCB *pcb = PCB_Get_By_PID(PID); if (pcb == NULL || pcb->status == PROCESS_Terminated){ *(SystemCallData->Argument[2]) = ERR_BAD_PARAM; }else{ pcb->priority = newPri; if (ReadyQueue_Remove(PID)){ ReadyQueue_Add(PCB_Get_By_PID(PID)); } *(SystemCallData->Argument[2]) = ERR_SUCCESS; } Printer("Priority", PID, FALSE); ReadyQueue_Unlock("Change Priority"); }
int main() { MapData md = {4, "hello"}; boost::fusion::for_each(md, Printer()); typedef boost::mpl::range_c<int, 0, boost::fusion::result_of::size<MapData>::value> md_range; //boost::mpl::for_each<md_range>(); boost::mpl::for_each<md_range>(PrintIndex(md)); std::vector<int> v(10, 10); //std::reference_wrapper<int> ri(v[5]); auto ri = std::ref(v[5]); ri.get() = 45; boost::copy(v, std::ostream_iterator<int>(std::cout, ", ")); std::cout << std::endl; return 0; }
void my_SUSPEND_PROCESS(SYSTEM_CALL_DATA *SystemCallData){ INT32 PID = (INT32)(SystemCallData->Argument[0]); if ((PID==-1)||(PID==my_GET_PROCESS_ID_SYS(""))){ //you cannot suspend yourself *(SystemCallData->Argument[1]) = ERR_BAD_PARAM; return; } PCB *target = PCB_Get_By_PID(PID); if (target == NULL || target->status == PROCESS_Terminated || target->status == PROCESS_Suspended){ *(SystemCallData->Argument[1]) = ERR_BAD_PARAM; return; } ReadyQueue_Lock("SUSPEND PROCESS"); target->status = PROCESS_Suspended; if (ReadyQueue_Remove(PID)){ SuspendQueue_Add(target); } *(SystemCallData->Argument[1]) = ERR_SUCCESS; Printer("Suspend", PID, FALSE); ReadyQueue_Unlock("SUSPEND PROCESS"); }
//--------------------------------------------------------------------------- bool __fastcall TRawPrint::SelecionarImpressora(unsigned short int &Indice)//Indice apontando para Variável no Buffer, Valor pode ser aterado diretamente no Corpo do Método { bool Retorno = false; TPrintDialog *PrtDlg; PrtDlg = new TPrintDialog(NULL); if(Evolucao1->Interrompe()) { return(false); } try { TPrinter *Prntr = Printer(); if(Prntr->Printers->Count == 0)//Se não existe Impressora instalada { throw Exception("Nenhuma Impressora Instalada"); } if(Prntr->Printers->Count - 1 < Indice)//Se existe Impressora instalada e o Indice gravado for mair do existente, então seleciona a Primeira Impressora { Indice = 0; } Prntr->PrinterIndex = Indice; if (PrtDlg->Execute()) { PNomeDispositivo = Prntr->Printers->Strings[Prntr->PrinterIndex]; Indice = Prntr->PrinterIndex;//Guarda o Indice da Impressora para próxima Impressão vir selecionada como Padrão Retorno = true; } } __finally { delete PrtDlg; } return(Retorno); };
void my_RESUME_PROCESS(SYSTEM_CALL_DATA *SystemCallData){ INT32 PID = (INT32)(SystemCallData->Argument[0]); if (PID==-1){ //you can never resume yourself because you need to be suspended *(SystemCallData->Argument[1]) = ERR_BAD_PARAM; return; } ReadyQueue_Lock("RESUME PROCESS"); SuspendQueue_Lock("RESUME PROCESS"); PCB *target = SuspendQueue_GetAndRemove(PID); if (target == NULL || target->status!=PROCESS_Suspended){ // the process is not in suspend queue // or its status is not suspended thus error *(SystemCallData->Argument[1]) = ERR_BAD_PARAM; }else{ //put it back to the ready queue target->status = PROCESS_READY; *(SystemCallData->Argument[1]) = ERR_SUCCESS; ReadyQueue_Add(target); Printer("Resume", PID, FALSE); } SuspendQueue_Unlock("RESUME PROCESS"); ReadyQueue_Unlock("RESUME_PROCESS"); }
/** constructor @return an object or a null pointer if the object couldn't be created */ struct Spool *Spool(const int jobs_size, const int printers_size, const int clients_size) { struct Spool *s; int i; if(jobs_size < 1 || printers_size < 1 || clients_size < 1) { fprintf(stderr, "Spool: invalid parameters.\n"); return 0; } if(!(s = malloc(sizeof(struct Spool) + sizeof(struct Job *) * jobs_size + sizeof(struct Printer *) * printers_size + sizeof(struct Client *) * clients_size))) { perror("Spool constructor"); Spool_(&s); return 0; } s->job = (struct Job **)(s + 1); s->jobs_size = jobs_size; s->head = s->tail = 0; s->empty = -1; s->printer = (struct Printer **)&s->job[jobs_size]; s->printers_size = printers_size; s->client = (struct Client **)&s->printer[printers_size]; s->clients_size = clients_size; for(i = 0; i < jobs_size; i++) s->job[i] = 0; for(i = 0; i < printers_size; i++) s->printer[i] = 0; for(i = 0; i < clients_size; i++) s->client[i] = 0; for(i = 0; i < printers_size; i++) s->printer[i] = Printer(); for(i = 0; i < clients_size; i++) s->client[i] = Client(); fprintf(stderr, "Spool: new, jobs %d, printers %d, clients %d, #%p.\n", jobs_size, printers_size, clients_size, (void *)s); return s; }
/*-----------------------------------------------------------------*/ void __fastcall PrPrinter::PrPaintCell (DARSTELLUNG _darstellung, int _x, int _y, int _xx, int _yy, TColor _col/*=clBlack*/, int _number/*=-1*/) { int width = canvas->Pen->Width; int penwidth = 0; if (_darstellung!=AUSGEFUELLT) { penwidth = GetDeviceCaps (Printer()->Handle, LOGPIXELSX)*5/254; // 0.5 mm Strichstärke penwidth = penwidth*mainfrm->zoom[mainfrm->currentzoom]/mainfrm->zoom[3]; // Skalieren canvas->Pen->Width = XSCALE(penwidth); } canvas->Pen->Color = _col; canvas->Brush->Color = _col; int dx = penwidth; int dy = penwidth; switch (_darstellung) { case AUSGEFUELLT: canvas->Rectangle (XSCALE(_x+dx), YSCALE(_y+dy), XSCALE(_xx-dx+1), YSCALE(_yy-dy+1)); break; case STRICH: canvas->MoveTo (XSCALE((_x+_xx)/2), YSCALE(_yy-dy)); canvas->LineTo (XSCALE((_x+_xx)/2), YSCALE(_y+dy+1)); canvas->MoveTo (XSCALE((_x+_xx)/2+1), YSCALE(_yy-dy)); canvas->LineTo (XSCALE((_x+_xx)/2+1), YSCALE(_y+dy+1)); break; case KREUZ: canvas->MoveTo (XSCALE(_x+dx), YSCALE(_yy-dy)); canvas->LineTo (XSCALE(_xx-dx), YSCALE(_y+dy)); canvas->MoveTo (XSCALE(_x+dx), YSCALE(_y+dy)); canvas->LineTo (XSCALE(_xx-dx), YSCALE(_yy-dy)); break; case PUNKT: { int x = (_x+_xx)/2; int y = (_y+_yy)/2; canvas->MoveTo (XSCALE(x), YSCALE(y)); canvas->LineTo (XSCALE(x+1), YSCALE(y)); canvas->MoveTo (XSCALE(x), YSCALE(y+1)); canvas->LineTo (XSCALE(x+1), YSCALE(y+1)); break; } case KREIS: canvas->Arc (XSCALE(_x+dx), YSCALE(_y+dy), XSCALE(_xx-dx+1), YSCALE(_yy-dy+1), XSCALE(_x), YSCALE(_y), XSCALE(_x), YSCALE(_y)); break; case STEIGEND: canvas->MoveTo (XSCALE(_x+dx), YSCALE(_yy-dy)); canvas->LineTo (XSCALE(_xx-dx), YSCALE(_y+dy)); break; case FALLEND: canvas->MoveTo (XSCALE(_x+dx), YSCALE(_y+dy)); canvas->LineTo (XSCALE(_xx-dx), YSCALE(_yy-dy)); break; case SMALLKREIS: if (canvas->Pen->Width>2) canvas->Pen->Width = canvas->Pen->Width/2; dx = dx + (_xx-_x)/10; dy = dy + (_yy-_y)/10; canvas->Arc (XSCALE(_x+dx), YSCALE(_y+dy), XSCALE(_xx-dx+1), YSCALE(_yy-dy+1), XSCALE(_x), YSCALE(_y), XSCALE(_x), YSCALE(_y)); break; case SMALLKREUZ: if (canvas->Pen->Width>2) canvas->Pen->Width = canvas->Pen->Width/2; dx = dx + (_xx-_x)/10; dy = dy + (_yy-_y)/10; canvas->MoveTo (XSCALE(_x+dx), YSCALE(_yy-dy)); canvas->LineTo (XSCALE(_xx-dx), YSCALE(_y+dy)); canvas->MoveTo (XSCALE(_x+dx), YSCALE(_y+dy)); canvas->LineTo (XSCALE(_xx-dx), YSCALE(_yy-dy)); break; case NUMBER: if (_number>=0) { canvas->Brush->Color = clWhite; int oldflags = canvas->TextFlags; int oldsize = canvas->Font->Height; canvas->TextFlags = canvas->TextFlags & ~ETO_OPAQUE; canvas->Font->Color = _col; canvas->Font->Height = -einzug.gh*8/10; String nr = IntToStr(_number+1); TSize sz = canvas->TextExtent(nr); int xx = 0; if (_xx-_x>sz.cx) xx = (_xx-_x-sz.cx)/2; int yy = 0; if (_yy-_y>sz.cy) yy = (_yy-_y-sz.cy)/2; canvas->TextRect (TRect(XSCALE(_x+dx), YSCALE(_y+dy), XSCALE(_xx-dx), YSCALE(_yy-dy)), XSCALE(_x+xx), YSCALE(_y+yy), nr); canvas->TextFlags = oldflags; canvas->Font->Height = oldsize; } else { canvas->Rectangle (XSCALE(_x+dx), YSCALE(_y+dy), XSCALE(_xx-dx+1), YSCALE(_yy-dy+1)); } break; } canvas->Pen->Width = width; }
int run_main (int, ACE_TCHAR *[]) { ACE_START_TEST (ACE_LIB_TEXT ("Refcounted_Auto_Ptr_Test")); // ========================================================================= // The following test uses the ACE_Refcounted_Auto_Ptr in a single // thread of control, hence we use the ACE_Null_Mutex ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%t) performing synchronous test...\n"))); Printer *printer1; ACE_NEW_RETURN (printer1, Printer ("I am printer 1"), -1); { ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r(printer1); ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r1(r); ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r2(r); ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r3(r); ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r4(r); ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r5 = r2; ACE_Refcounted_Auto_Ptr<Printer, ACE_Null_Mutex> r6 = r1; } ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%t) Printer instance count is %d, expecting 0\n"), Printer::instance_count_)); ACE_ASSERT (Printer::instance_count_ == 0); #if defined (ACE_HAS_THREADS) // ========================================================================= // The following test uses the ACE_Refcounted_Auto_Ptr in multiple // threads of control. ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%t) performing asynchronous test...\n"))); Scheduler *scheduler_ptr; // Create active objects.. ACE_NEW_RETURN (scheduler_ptr, Scheduler (), -1); auto_ptr<Scheduler> scheduler(scheduler_ptr); ACE_ASSERT (scheduler->open () != -1); { ACE_NEW_RETURN (printer1, Printer ("I am printer 2"), -1); Printer_var r (printer1); for (int i = 0; i < n_loops; i++) // Spawn off the methods, which run in a separate thread as // active object invocations. scheduler->print (r); } // Close things down. scheduler->end (); scheduler->wait (); ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(%t) Printer instance count is %d, expecting 0\n"), Printer::instance_count_)); ACE_ASSERT (Printer::instance_count_ == 0); #endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0; }
void my_Dispatcher(){ INT32 PID; TestMode("Dispatcher 0"); PID = my_GET_PROCESS_ID_SYS(""); debug(YELLOW, "Dispatcher of PID %d", 0); PrintState(); TestMode("Dispatcher 1"); int loop = TRUE; int selfStarted = FALSE; while (loop){ //usleep(1000); CALL(ReadyQueue_Lock("Dispatcher loop")); if (PCB_Get_Self()->status == PROCESS_RUNNING){ selfStarted = TRUE; loop = FALSE; }else{ if (ReadyQueueHead->Next != NULL){ loop = FALSE; }else{ CALL(ReadyQueue_Unlock("Dispatcher Loop waiting")); //nothing on ready Q, advance time } } } if (selfStarted){ ReadyQueue_Unlock("Started Dispatcher"); debug(RED, "Self started by other dispatcher, returning"); return; } TestMode("Dispatcher 2"); if (multicore == TRUE){ int flag = TRUE; //multi core mode, start all contexts on ready queue while (ReadyQueueHead->Next != NULL){ PCB *pcb = ReadyQueueHead->Next->PCB; pcb->status = PROCESS_RUNNING; ReadyQueueHead->Next = ReadyQueueHead->Next->Next; Printer("Dispatch", pcb->PID, FALSE); Start_Context(pcb); if (pcb->PID == PID){ debug(RED, "Flag set to false "); flag = FALSE; } //take it off the ready queue } ReadyQueue_Unlock("Multi Core Dispatcher over"); if (flag){ //unless self is started, suspend self debug(RED, "Suspending self"); SuspendSelf(); } }else{ //single core mode if (ReadyQueueHead->Next!=NULL){ debug(RED, "Ready Queue Item PID %d", ReadyQueueHead->Next->PCB->PID); PCB *pcb = ReadyQueueHead->Next->PCB; pcb->status = PROCESS_RUNNING; ReadyQueueHead->Next = ReadyQueueHead->Next->Next; Printer("Dispatch", pcb->PID, FALSE); ReadyQueue_Unlock("Single core dispatcher over"); debug(RED, "TEMP: %d", pcb->PID); Start_Context(pcb); debug(GREEN, "After Start Context"); }else{ debug(RED, "Ready Queue is empty"); } } PrintState(); }
void ClangDocHTML::HandleTranslationUnit(TranslationUnitDecl *D) { for(CommentsList::iterator c=commentsList.begin(); c!=commentsList.end(); ++c) { bool bInvalid = false; const char *cbegin = astConsumer->sourceManager->getCharacterData((*c).getBegin(), &bInvalid); const char *cend = astConsumer->sourceManager->getCharacterData((*c).getEnd(), &bInvalid); llvm::StringRef string = llvm::StringRef(cbegin, cend-cbegin); if(string.startswith("///< ")) { for(DeclList::reverse_iterator d=declList.rbegin(); d!=declList.rend(); ++d) { SourceLocation dl = (*d)->getLocation(); SourceLocation cl = (*c).getEnd(); if(cl < dl) { continue; } else { commentsByDecl.insert(CommentsByDeclPair((*d), string.substr(5)) ); break; } } } else if(string.startswith("/// ")) { for(DeclList::iterator d=declList.begin(); d!=declList.end(); ++d) { SourceLocation dl = (*d)->getLocation(); SourceLocation cl = (*c).getEnd(); if(dl < cl) { continue; } else { commentsByDecl.insert(CommentsByDeclPair((*d), string.substr(4)) ); break; } } } } for (DeclByType::iterator it=declByType.begin(); it!=declByType.end(); ++it) { *Out << (it->second)->getKind() << " " << (it->second)->getDeclKindName() << "\n"; } *Out << "<table border = \"1\">\n"; if(!inclusionDirectives.empty()) { *Out << "<th align=\"left\">" << "Include Directives" << "</th>\n"; *Out << "<tbody>"; for(InclusionDirectivesIt it = inclusionDirectives.begin(); it != inclusionDirectives.end(); ++it) { *Out << "<tr><td align=\"left\">\n"; *Out << *it; *Out << "</td></tr>\n"; } *Out << "</tbody>"; } /*PreprocessingRecord *PPRec = astConsumer->preprocessor->getPreprocessingRecord(); if (PPRec && PPRec->begin() != PPRec->end()) { for (PreprocessingRecord::iterator E = PPRec->begin(), EEnd = PPRec->end(); E != EEnd; ++E) { if (MacroDefinition *MD = dyn_cast<MacroDefinition>(*E)) { if (InclusionDirective *ID = dyn_cast<InclusionDirective>(*E)) { *Out << "<tr><td align=\"left\">\n"; *Out << ID->getFileName(); *Out << "</td></tr>\n"; } } } }*/ for (DeclByTypeIt it=declByType.begin(); it!=declByType.end();) { DeclByTypeItPair result = declByType.equal_range(it->first); *Out << "<th align=\"left\">" << (it->second)->getDeclKindName() << "</th>\n"; *Out << "<tbody>"; for (it=result.first; it!=result.second; ++it) { int Indentation = 0; *Out << "<tr>"; Decl *decl = it->second; { *Out << "<td align=\"right\">\n"; *Out << "<pre>\t"; PrintingPolicyHTML printingPolicy = PrintingPolicyHTML(decl->getASTContext().PrintingPolicy); printingPolicy.htmlSuppressIdentifier = 1; printingPolicy.SuppressInitializers = 1; DeclPrinterHTML Printer(*Out, decl->getASTContext(), printingPolicy, Indentation); Printer.Visit(decl); *Out << "</pre>\n"; *Out << "</td>\n"; } { *Out << "<td>\n"; *Out << "<pre>"; PrintingPolicyHTML printingPolicy = PrintingPolicyHTML(decl->getASTContext().PrintingPolicy); printingPolicy.SuppressSpecifiers = 1; DeclPrinterHTML Printer(*Out, decl->getASTContext(), printingPolicy, Indentation); Printer.Visit(decl); *Out << "</pre>\n"; *Out << "</td>\n"; } { *Out << "<td>\n"; *Out << "<pre>"; CommentsByDeclItPair comments = commentsByDecl.equal_range(decl); for (CommentsByDeclIt cit=comments.first; cit!=comments.second; ++cit) { *Out << cit->second << " "; } //SourceLocation sl = decl->getLocation(); //SourceLocation slend = astConsumer->preprocessor->getCurrentLexer() //astConsumer->sourceManager->get //const char *cbegin = astConsumer->sourceManager->getCharacterData(Comment.getBegin(), &bInvalid); *Out << "</pre>\n"; *Out << "</td>\n"; } *Out << "</tr>"; } *Out << "</tbody>"; } *Out << "</table>\n"; }
// The << operator for AST bases ostream& operator << (ostream& Out, const ASTBase& AST) { PrintVisitor Printer(Out); AST.Accept(&Printer); return Out; }
//--------------------------------------------------------------------------- void __fastcall TViewForm::Print1Click(TObject *Sender) { char Buf[1024]; TOvcViewerRange SelRange; int startLine, endLine; if (Viewer1->GetSelection(SelRange.Start.Line, SelRange.Start.Col, SelRange.Stop.Line, SelRange.Stop.Col)) PrintDialog1->Options << poSelection; else PrintDialog1->Options >> poSelection; if (PrintDialog1->Execute()) { int lineHeight = abs( MulDiv(Printer()->Canvas->Font->Size, GetDeviceCaps(Printer()->Handle, LOGPIXELSY), 72)); lineHeight *= 1.4; int linesPerPage = (Printer()->PageHeight/lineHeight) - 4; int lineCount = 4; Printer()->BeginDoc(); TRect rect; rect.Top = lineHeight; rect.Left = 20; rect.Right = Printer()->PageWidth; rect.Bottom = lineHeight * 2; DrawText(Printer()->Handle, OpenDialog1->FileName.c_str(), -1, (RECT*)&rect, DT_CENTER); // // Loop through all of the lines and print each one. // Printer()->Canvas->Font = Viewer1->FixedFont->Font; switch (PrintDialog1->PrintRange) { case prAllPages : { if (Viewer1->LineCount == 2147483647) // checking this invalid line forces reading of all lines Viewer1->CheckLine(2147483647); startLine = 0; endLine = Viewer1->LineCount; break; } case prSelection : { startLine = SelRange.Start.Line; endLine = SelRange.Stop.Line + 1; break; } } for (int i=startLine;i<endLine;i++) { // // When we get to the bottom of the page reset the // line counter, eject the page, and start a new page. // if (lineCount++ == linesPerPage) { lineCount = 4; Printer()->NewPage(); } // // Get the next string and print it using TextOut() // Viewer1->GetPrintableLine(i, Buf, sizeof(Buf)); Printer()->Canvas->TextOut (0, lineCount * lineHeight, Buf); } // // All done. // Printer()->EndDoc(); } }
/*-----------------------------------------------------------------*/ void __fastcall TOverviewForm::SBPrintClick(TObject *Sender) { // Ausdrucken der Geschichte... TCursor savecursor = Cursor; Cursor = crHourGlass; Printer()->Title = (String)APP_TITLE+" - "+ExtractFileName(frm->filename); Printer()->BeginDoc(); CalcPrintDimensions(); int mx = min(maxi, frm->kette.count()); int my = min(maxj, frm->schuesse.count()); TCanvas* canvas = Printer()->Canvas; if (frm->GewebeNormal->Checked) { for (int i=frm->kette.a; i<frm->kette.a+mx; i++) for (int j=frm->schuesse.a; j<frm->schuesse.a+my; j++) { int x; if (frm->righttoleft) x = (mx+1)*gw - (i-frm->kette.a+1)*gw; else x = (i-frm->kette.a)*gw; int y = (my+1)*gh - (j-frm->schuesse.a+1)*gh; if (frm->gewebe.feld.Get(i, j)>0) { canvas->Brush->Style = bsSolid; canvas->Pen->Color = GetRangeColor(frm->gewebe.feld.Get(i, j)); canvas->Brush->Color = GetRangeColor(frm->gewebe.feld.Get(i, j)); canvas->Rectangle (mleft+x, mtop+y, mleft+x+gw, mtop+y+gh); } if (grid) { canvas->Pen->Color = clBlack; canvas->MoveTo (mleft+x, mtop+y); canvas->LineTo (mleft+x, mtop+y+gh); canvas->LineTo (mleft+x+gw, mtop+y+gh); canvas->LineTo (mleft+x+gw, mtop+y); canvas->LineTo (mleft+x, mtop+y); } } } else if (frm->GewebeFarbeffekt->Checked || frm->GewebeSimulation->Checked) { // Nach Farben getrennt malen, schneller... for (int i=frm->kette.a; i<frm->kette.a+mx; i++) for (int j=frm->schuesse.a; j<frm->schuesse.a+my; j++) { bool drawhebung = frm->gewebe.feld.Get(i,j)>0; if (frm->sinkingshed) drawhebung = !drawhebung; canvas->Brush->Style = bsSolid; if (drawhebung) { canvas->Brush->Color = GETPALCOL(frm->kettfarben.feld.Get(i)); canvas->Pen->Color = GETPALCOL(frm->kettfarben.feld.Get(i)); } else { canvas->Brush->Color = GETPALCOL(frm->schussfarben.feld.Get(j)); canvas->Pen->Color = GETPALCOL(frm->schussfarben.feld.Get(j)); } int x; if (frm->righttoleft) x = pwidth - (i-frm->kette.a+1)*gw; else x = (i-frm->kette.a)*gw; int y = (my+1)*gh - (j-frm->schuesse.a+1)*gh; canvas->Rectangle (mleft+x, mtop+y, mleft+x+gw, mtop+y+gh); if (grid) { canvas->Pen->Color = clBlack; canvas->MoveTo (mleft+x, mtop+y); canvas->LineTo (mleft+x, mtop+y+gh); canvas->LineTo (mleft+x+gw, mtop+y+gh); canvas->LineTo (mleft+x+gw, mtop+y); canvas->LineTo (mleft+x, mtop+y); } } } Printer()->EndDoc(); Cursor = savecursor; ::MessageBeep (-1); }
int main(const int argc, const char* argv[]) { Tuple<int> i1; Tuple<int, int> i2; Tuple<int, int, int> i3; Tuple<int, int, int, int> i4; Tuple<int, int, int, int, int> i5; Tuple<int, int, int, int, int, int> i6; Tuple<int, float, double, char, std::string> tup1(1, 1.0f, 1.0, '1', "1"); Tuple<int, float, double, char, std::string> tup2(::make_tuple(2, 2.0f, 2.0, '2', std::string("2"))); std::cout << tup1.get<0>() << " " << tup1.get<1>() << " " << tup1.get<2>() << " " << tup1.get<3>() << " " << tup1.get<4>() << std::endl; std::cout << tup2.get<0>() << " " << tup2.get<1>() << " " << tup2.get<2>() << " " << tup2.get<3>() << " " << tup2.get<4>() << std::endl; tup1.set<0>(Tuple<int, int>::Element<0>::type(10)); tup1.set<4>(std::string("10")); std::cout << tup1.get<0>() << " " << tup1.get<1>() << " " << tup1.get<2>() << " " << tup1.get<3>() << " " << tup1.get<4>() << std::endl; if(tup1 == tup2) { std::cout << "WTF!?" << std::endl; } if (tup1 != tup1) { std::cout << "WTF!?" << std::endl; } if (!IsTuple<Tuple<int, float, double, char, std::string> >::value) { std::cout << "isTuple failed" << std::endl; } if (IsTuple<int>::value) { std::cout << "isTuple failed" << std::endl; } tup1 = tup2; make_tuple(1, 2, 3, 4).forEach(Printer()); std::cout << std::endl; if (make_tuple(1) != Tuple<int>(1)) { std::cout << "eq1 failed" << std::endl; } else { std::cout << make_tuple(1) << std::endl; } if (make_tuple(1,2) != Tuple<int, int>(1,2)) { std::cout << "eq2 failed" << std::endl; } else { std::cout << make_tuple(1,2) << std::endl; } if (make_tuple(1, 2, 3) != Tuple<int, int, int>(1, 2, 3)) { std::cout << "eq3 failed" << std::endl; } else { std::cout << make_tuple(1,2,3) << std::endl; } if (make_tuple(1, 2, 3, 4) != Tuple<int, int, int, int>(1, 2, 3, 4)) { std::cout << "eq4 failed" << std::endl; } else { std::cout << make_tuple(1,2,3,4) << std::endl; } if (make_tuple(1, 2, 3, 4, 5) != Tuple<int, int, int, int, int>(1, 2, 3, 4, 5)) { std::cout << "eq5 failed" << std::endl; } else { std::cout << make_tuple(1,2,3,4,5) << std::endl; } if (make_tuple(1, 2, 3, 4, 5, 6) != Tuple<int, int, int, int, int, int>(1, 2, 3, 4, 5, 6)) { std::cout << "eq6 failed" << std::endl; } else { std::cout << make_tuple(1,2,3,4,5,6) << std::endl; } return 0; }
void FilePrint ( AnsiString FileName ) { int TempHeight, w, h, str_n = 1; Graphics::TBitmap * Bitmap = new Graphics::TBitmap(); qvar->ImageEnProc1->AttachedBitmap = Bitmap; qvar->ImageEnIO1->AttachedBitmap = Bitmap; //Bitmap->LoadFromFile( FileName ); qvar->ImageEnIO1->LoadFromFile( FileName ); qvar->ImageEnIO1->Params->JPEG_Quality = 70; //w = Bitmap->Width * 6; w = -1; //h = Bitmap->Height * Printer()->PageHeight / 1100; h = Bitmap->Height * 6; /*ShowMessage( Printer()->PageHeight ); ShowMessage( h );*/ //qvar->ImageEnProc1->Resample( w, h, rfBilinear ); //qvar->ImageEnProc1->Resample( w, h, rfBSpline ); qvar->ImageEnProc1->Resample( w, h, rfFastLinear ); //qvar->ImageEnIO1->DoPrintPreviewDialog( iedtDialog, "Просмотр печати", true, "Печать" ); /*Printer()->BeginDoc(); qvar->ImageEnIO1->PrintImage( Printer()->Canvas,0,0,0,0,ievpTOP,iehpLEFT,iesNORMAL,0,0,1); Printer()->EndDoc();*/ if ( h <= Printer()->PageHeight ) { Printer()->BeginDoc(); Printer()->Canvas->Draw( 0, 0, qvar->ImageEnIO1->AttachedBitmap ); //qvar->ImageEnIO1->PrintImage( Printer()->Canvas,0,0,0,0,ievpTOP,iehpLEFT,iesNORMAL,0,0,1); //qvar->ImageEnIO1->PrintImagePos( Printer()->Canvas, 0, 0, w, h, 1 ); Printer()->EndDoc(); } else { TempHeight = 0; Printer()->BeginDoc(); while ( h - TempHeight > 0 ) { Printer()->Canvas->CopyRect( Rect( 0, 0, Printer()->PageWidth, Printer()->PageHeight ), qvar->ImageEnIO1->AttachedBitmap->Canvas, Rect( 0, TempHeight, Printer()->PageWidth, TempHeight + Printer()->PageHeight ) ); //qvar->ImageEnIO1->PrintImagePos( Printer()->Canvas, 0, TempHeight, Printer()->PageWidth, TempHeight + Printer()->PageHeight, 1 ); //qvar->ImageEnIO1->PrintImagePos( Printer()->Canvas, TempHeight, 0, qvar->ImageEnIO1->AttachedBitmap->Width, TempHeight + Printer()->PageHeight, 1 ); Printer()->Canvas->TextOut( Printer()->PageWidth / 2, 10, "Страница №" + IntToStr( Printer()->PageNumber )); //Printer()->Canvas->TextOut( Printer()->PageWidth / 2, 10, "Страница №" + IntToStr( str_n ++ )); TempHeight += Printer()->PageHeight; if ( h - TempHeight > 0 ) Printer()->NewPage(); } Printer()->EndDoc(); } delete Bitmap; unlink( FileName.c_str() ); /*int TempHeight; Graphics::TBitmap * Bitmap = new Graphics::TBitmap(); Bitmap->LoadFromFile( FileName ); if ( Bitmap->Height <= Printer()->PageHeight ) { Printer()->BeginDoc(); Printer()->Canvas->Draw( 0, 0, Bitmap ); Printer()->EndDoc(); } else { TempHeight = 0; Printer()->BeginDoc(); while ( Bitmap->Height - TempHeight > 0 ) { Printer()->Canvas->CopyRect( Rect( 0, 0, Printer()->PageWidth, Printer()->PageHeight ), Bitmap->Canvas, Rect( 0, TempHeight, Printer()->PageWidth, TempHeight + Printer()->PageHeight ) ); Printer()->Canvas->TextOut( Printer()->PageWidth / 2, 10, "Страница №" + IntToStr( Printer()->PageNumber )); TempHeight += Printer()->PageHeight; if ( Bitmap->Height - TempHeight > 0 ) Printer()->NewPage(); } Printer()->EndDoc(); } delete Bitmap;*/ }
void __fastcall TBeadForm::PrintItAll() { Printer()->BeginDoc(); String title = APP_TITLE; title += " - " + ExtractFileName(savedialog->FileName); Printer()->Title = title; TCanvas* canvas = Printer()->Canvas; int sx = GetDeviceCaps(Printer()->Handle, LOGPIXELSX); int sy = GetDeviceCaps(Printer()->Handle, LOGPIXELSY); int gx = (15+zoomidx*5)*sx/254; int gy = (15+zoomidx*5)*sy/254; int draftleft, normalleft, simulationleft, reportleft; int reportcols; int m = MM2PRx(10); if (draft->Visible) { draftleft = m; m += MM2PRx(13) + field.Width()*gx + MM2PRx(7); } if (normal->Visible) { normalleft = m; m += MM2PRx(7) + (field.Width()+1)*gx; } if (simulation->Visible) { simulationleft = m; m += MM2PRx(7) + (field.Width()/2+1)*gx; } if (report->Visible) { reportleft = m; reportcols = (Printer()->PageWidth - m - 10) / (MM2PRx(5) + MM2PRx(8)); } int h = Printer()->PageHeight - MM2PRy(10); //////////////////////////////////////// // // Draft // //////////////////////////////////////// // Grid canvas->Pen->Color = clBlack; int left = draftleft+MM2PRx(13); if (left<0) left=0; int maxj = min(field.Height(), (h-MM2PRy(10))/gy); for (int i=0; i<field.Width()+1; i++) { canvas->MoveTo(left+i*gx, h-(maxj)*gy); canvas->LineTo(left+i*gx, h-1); } for (int j=0; j<=maxj; j++) { canvas->MoveTo(left, h-1-j*gy); canvas->LineTo(left+field.Width()*gx, h-1-j*gy); } // Daten for (int i=0; i<field.Width(); i++) for (int j=0; j<maxj; j++) { char c = field.Get (i, j); assert(c>=0 && c<=9); if (c>0) { canvas->Brush->Color = coltable[c]; canvas->Pen->Color = canvas->Brush->Color; canvas->Rectangle (left+i*gx+1, h-(j+1)*gy, left+(i+1)*gx, h-1-j*gy); } } canvas->Brush->Color = clWhite; // Zehnermarkierungen canvas->Pen->Color = clBlack; for (int j=0; j<maxj; j++) { if ((j%10)==0) { canvas->MoveTo (draftleft, h - j*gy - 1); canvas->LineTo (left-MM2PRx(3), h - j*gy - 1); canvas->TextOutA (draftleft, h - j*gy + MM2PRy(1), IntToStr(j)); } } // Rapportmarkierung #if(0) if (rapport!=0) { canvas->Pen->Color = clRed; canvas->MoveTo (draftleft, h - (rapport)*gx - 1); canvas->LineTo (left-MM2PRx(3), h - (rapport)*gx - 1); } #endif //////////////////////////////////////// // // Korrigiert (normal) // //////////////////////////////////////// // Grid canvas->Pen->Color = clBlack; left = normalleft+gx/2; if (left<0) left=gx/2; maxj = min(field.Height(), (h-MM2PRy(10))/gy); for (int i=0; i<field.Width()+1; i++) { for (int jj=0; jj<maxj; jj+=2) { canvas->MoveTo(left+i*gx, h-(jj+1)*gy); canvas->LineTo(left+i*gx, h-jj*gy); } } for (int i=0; i<=field.Width()+1; i++) { for (int jj=1; jj<maxj; jj+=2) { canvas->MoveTo(left+i*gx-gx/2, h-(jj+1)*gy); canvas->LineTo(left+i*gx-gx/2, h-jj*gy); } } canvas->MoveTo(left, h-1); canvas->LineTo(left+field.Width()*gx+1, h-1); for (int jj=1; jj<=maxj; jj++) { canvas->MoveTo(left-gx/2, h-1-jj*gy); canvas->LineTo(left+field.Width()*gx+gx/2+1, h-1-jj*gy); } // Daten for (int i=0; i<field.Width(); i++) for (int jj=0; jj<maxj; jj++) { char c = field.Get (i, jj+scroll); assert(c>=0 && c<=9); if (c==0) continue; canvas->Brush->Color = coltable[c]; canvas->Pen->Color = canvas->Brush->Color; int ii = i; int j1 = jj; CorrectCoordinates (ii, j1); if (j1%2==0) { canvas->Rectangle (left+ii*gx+1, h-(j1+1)*gy, left+(ii+1)*gx, h-1-j1*gy); } else { canvas->Rectangle (left-gx/2+ii*gx+1, h-(j1+1)*gy, left-gx/2+(ii+1)*gx, h-1-j1*gy); } } canvas->Brush->Color = clWhite; //////////////////////////////////////// // // Simulation // //////////////////////////////////////// // Grid canvas->Pen->Color = clBlack; left = simulationleft+gx/2; if (left<0) left=gx/2; maxj = min(field.Height(), (h-MM2PRy(10))/gy); int w = field.Width()/2; for (int j=0; j<maxj; j+=2) { for (int i=0; i<w+1; i++) { canvas->MoveTo(left+i*gx, h-(j+1)*gy); canvas->LineTo(left+i*gx, h-j*gy); } if (j>0 || scroll>0) { canvas->MoveTo (left-gx/2, h-(j+1)*gy); canvas->LineTo (left-gx/2, h-j*gy); } } for (int j=1; j<maxj; j+=2) { for (int i=0; i<w+1; i++) { canvas->MoveTo(left+i*gx-gx/2, h-(j+1)*gy); canvas->LineTo(left+i*gx-gx/2, h-j*gy); } canvas->MoveTo(left+w*gx, h-(j+1)*gy); canvas->LineTo(left+w*gx, h-j*gy); } canvas->MoveTo(left, h-1); canvas->LineTo(left+w*gx+1, h-1); for (int j=1; j<=maxj; j++) { canvas->MoveTo(left-gx/2, h-1-j*gy); canvas->LineTo(left+w*gx+1, h-1-j*gy); } // Daten for (int i=0; i<field.Width(); i++) for (int j=0; j<maxj; j++) { char c = field.Get (i, j+scroll); assert(c>=0 && c<=9); if (c==0) continue; canvas->Brush->Color = coltable[c]; canvas->Pen->Color = canvas->Brush->Color; int ii = i; int jj = j; CorrectCoordinates (ii, jj); if (ii>w && ii!=field.Width()) continue; if (jj%2==0) { if (ii==w) continue; canvas->Rectangle (left+ii*gx+1, h-(jj+1)*gy, left+(ii+1)*gx, h-1-jj*gy); } else { if (ii!=field.Width() && ii!=w) { canvas->Rectangle (left-gx/2+ii*gx+1, h-(jj+1)*gy, left-gx/2+(ii+1)*gx, h-1-jj*gy); } else if (ii==w) { canvas->Rectangle (left-gx/2+ii*gx+1, h-(jj+1)*gy, left-gx/2+ii*gx+gx/2, h-1-jj*gy); } else { canvas->Rectangle (left-gx/2+1, h-(jj+2)*gy, left, h-1-(jj+1)*gy-1); } } } canvas->Brush->Color = clWhite; //////////////////////////////////////// // // Auswertung // //////////////////////////////////////// int x1 = reportleft; int x2 = reportleft + MM2PRx(30); int y = MM2PRy(10); int dy = MM2PRy(5); int dx = MM2PRx(5); // Mustername canvas->Pen->Color = clBlack; canvas->TextOut (x1, y, LANG_STR("Pattern:", "Muster:")); canvas->TextOut (x2, y, ExtractFileName(savedialog->FileName)); y += dy; // Umfang canvas->TextOut (x1, y, LANG_STR("Circumference:", "Umfang:")); canvas->TextOut (x2, y, IntToStr(field.Width())); y += dy; // Musterrapport #if(0) canvas->TextOut (x1, y, LANG_STR("Repeat of pattern:", "Musterrapport:")); canvas->TextOut (x2, y, IntToStr(rapport) + LANG_STR(" turns", " Umgänge")); y += dy; #endif // Farbrapport canvas->TextOut (x1, y, LANG_STR("Repeat of colors:", "Farbrapport:")); canvas->TextOut (x2, y, IntToStr(farbrapp) + LANG_STR(" beads", " Perlen")); y += dy; // Fädelliste... if (farbrapp>0) { int page = 1; int column = 0; canvas->TextOut (x1, y, LANG_STR("List of beads", "Fädelliste")); y += dy; int ystart = y; char col = field.Get(farbrapp-1); int count = 1; for (signed int i=farbrapp-2; i>=0; i--) { if (field.Get(i)==col) { count++; } else { if (col!=0) { canvas->Brush->Color = coltable[col]; canvas->Pen->Color = clWhite; } else { canvas->Brush->Color = clWhite; canvas->Pen->Color = clBlack; } canvas->Rectangle (x1, y, x1+dx-MM2PRx(1), y+dy-MM2PRy(1)); canvas->Pen->Color = clBlack; canvas->Brush->Color = clWhite; canvas->TextOut (x1+dx+3, y, IntToStr(count)); y += dy; col = field.Get(i); count = 1; } if (y>=Printer()->PageHeight-MM2PRy(10)) { x1 += dx + MM2PRx(8); y = ystart; column++; if (column>=reportcols) { // neue Seite und weiter... Printer()->NewPage(); x1 = draftleft; x2 = draftleft + MM2PRx(30); y = MM2PRy(10); reportcols = (Printer()->PageWidth - draftleft - 10) / (MM2PRx(5) + MM2PRx(8)); column = 0; page++; canvas->Pen->Color = clBlack; canvas->TextOut (x1, y, String(LANG_STR("Pattern ", "Muster "))+ExtractFileName(savedialog->FileName) + " - " + LANG_STR("page ", "Seite ") + IntToStr(page)); y += dy; ystart = y; } } } if (y<Printer()->PageHeight-MM2PRy(10)) { if (col!=0) { canvas->Brush->Color = coltable[col]; canvas->Pen->Color = clWhite; } else { canvas->Brush->Color = clWhite; canvas->Pen->Color = clBlack; } canvas->Rectangle (x1, y, x1+dx-MM2PRx(1), y+dy-MM2PRy(1)); canvas->Pen->Color = clBlack; canvas->Brush->Color = clWhite; canvas->TextOut (x1+dx+3, y, IntToStr(count)); } } g_exit: Printer()->EndDoc(); }
int run_main (int, ACE_TCHAR *[]) { ACE_START_TEST (ACE_TEXT ("Bound_Ptr_Test")); // ========================================================================= // The following test uses the ACE_Strong_Bound_Ptr in a single // thread of control, hence we use the ACE_Null_Mutex ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) performing synchronous test...\n"))); Parent *parent1 = 0; ACE_NEW_RETURN (parent1, Parent, -1); ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p8; { // Must get the pointer from the parent object's weak_self_ member. ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p(parent1->weak_self_); ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p1(p); ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p2(p); ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p3(p); ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p4(p); ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p5 = p2; ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p6 = p3; ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p7(p1); p8 = p2; p->child_->do_something (); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Parent instance count is %d, expecting 0\n"), Parent::instance_count_)); if (Parent::instance_count_ != 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) parent instance count not 0...\n")), -1); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Child instance count is %d, expecting 0\n"), Child::instance_count_)); if (Child::instance_count_ != 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) child instance count not 0...\n")), -1); } // Weak pointer should now be set to null. if(!p8.null ()) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) p8 not nill...\n")), -1); } Printer *printer1 = 0; ACE_NEW_RETURN (printer1, Printer ("I am printer 1"), -1); ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r9; { ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r(printer1); ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r1(r); ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r2(r); ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r3(r); ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r4(r); ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r5 = r2; ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r6 = r1; ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r7(r1); ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r8 = r2; r9 = r3; r9->print (); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Printer instance count is %d, expecting 0\n"), Printer::instance_count_)); if (Printer::instance_count_ != 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) Printer instance count not 0...\n")), -1); } // Weak pointer should now be set to null. if (!r9.null ()) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) r9 not nill...\n")), -1); } #if defined (ACE_HAS_THREADS) // ========================================================================= // The following test uses the ACE_Strong_Bound_Ptr in multiple // threads of control. ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) performing asynchronous test...\n"))); Scheduler *scheduler_ptr = 0; // Create active objects.. ACE_NEW_RETURN (scheduler_ptr, Scheduler (), -1); ACE_Strong_Bound_Ptr<Scheduler, ACE_Null_Mutex> scheduler(scheduler_ptr); if (scheduler->open () == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%t) Scheduler open failed...\n")), -1); } { Printer *printer2 = 0; ACE_NEW_RETURN (printer2, Printer ("I am printer 2"), -1); // Ownership is transferred from the auto_ptr to the strong pointer. auto_ptr<Printer> a (printer2); Printer_var r (a); for (int i = 0; i < n_loops; i++) // Spawn off the methods, which run in a separate thread as // active object invocations. scheduler->print (r); } // Close things down. scheduler->end (); scheduler->wait (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Printer instance count is %d, expecting 0\n"), Printer::instance_count_)); if (Printer::instance_count_ != 0) return -1; #endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0; }
//--------------------------------------------------------------------------- void __fastcall TFormMain::PrintBtnClick(TObject *Sender) { int trips; // number of times to print from first to last int dups; // number of copies of each page to print each time int firstpg; int lastpg; bool needsnewpg=false; // make sure the current page is saved before printing pages[TabSet1->TabIndex]->Text = Memo1->Text; if (!PrintDialog1->Execute()) return; // user did not press OK // if we're not collating, we only go from the first page to last page once // but each time through we print duplicates of each page. if (!PrintDialog1->Collate) { trips = 1; dups = PrintDialog1->Copies; } // if we're collating, we go from the first page to the last page // multiple times but only print one duplicate each time through. else { trips = PrintDialog1->Copies; dups = 1; } // user has selected to print all pages... if (PrintDialog1->PrintRange == prAllPages) { firstpg = 1; lastpg = 5; } // ...or a range of pages else { firstpg = PrintDialog1->FromPage; lastpg = PrintDialog1->ToPage; } // Initialize print job Printer()->BeginDoc(); // Title to appear in the print manager and network print banners Printer()->Title = "C++Builder Printer Example"; for (int x=0; x<trips; x++) // for each pass for (int y=firstpg-1; y<lastpg; y++) // for each page for (int z=0; z<dups; z++) // for each dup of the page { if (needsnewpg) // page 1 does not need a page break Printer()->NewPage(); PrintPage(y); // print the page needsnewpg = true; // subsequent pages need page breaks } Printer()->EndDoc(); }
lbl->Top = hgh; lft = lft + lbl->Width; count += 9; hgh += 15; i++; } } else{ clabel = clabel->next; } } this->Frame71->Label212->Width = 225; lft = CB->Width + 10; lft = lft + this->Frame71->Label212->Width; this->Frame71->Label213->Width = 125; this->Frame71->Label213->Left = lft; lft = lft + this->Frame71->Label212->Width; lft = lft + this->Frame71->Label213->Width; if (this->clabel == NULL){ this->Next_btn->Enabled = false; } update = true; /* */ } //--------------------------------------------------------------------------- void __fastcall TOutputFrm::Print_btnClick(TObject *Sender){ if(Sender == NULL) return; TPrinter *prntr = Printer(); TRect rect = Rect(10, 10, prntr->PageWidth - 10, prntr->PageHeight - 10); int CPH, RPH, C, R; label *lblptr; lblptr = HEAD; C = 615; R = 145; Application->CreateForm(__classid(TPrintview_frm), &Printview_frm); Printview_frm->Show(); Printview_frm->Width = 315; Printview_frm->Height = 157; Printview_frm->Frame131->Height = 157; Printview_frm->Frame131->Width = 315; prntr->BeginDoc(); prntr->Canvas->FillRect(rect); prntr->Canvas->Brush->Color = clBlack; RPH = 130; while(RPH <= (200 * 20)){ CPH = 60; while((lblptr != NULL) && (!lblptr->Is_select)) lblptr = lblptr->next; if(lblptr != NULL){ // Row Printview_frm->Frame131->Label1->Caption = lblptr->header; Printview_frm->Frame131->Label2->Caption = lblptr->Artist; Printview_frm->Frame131->Label3->Caption = lblptr->title; Printview_frm->Frame131->Label4->Caption = lblptr->PDate; Printview_frm->PaintTo(prntr->Handle, CPH, RPH); CPH += C;
//---------------------------------------------------------------------------- void printCriteriaGraph() { float minCriteriaValue=minObjectiveValue(); long maximizedLevel; float maxCriteriaValue; maxCriteriaValue=0.0; int yScale; int curXLevel; //текущий уровень оси Х int maxXLevel; //максимальная длина оси Х int maxYLevel; //массимальная высота оси Y maxYLevel=950; maxXLevel=Printer()->PageWidth-80; int minScale=maxYLevel*minCriteriaValue; int yMaxScale=0; int xCord; xCord=leftBorder; Printer()->BeginDoc(); Printer()->Canvas->Pen->Color=clBlack; for(int i=0;i<2/*((max_Value-t_Value)/250)+1*/;i++) {curXLevel=maxYLevel*(i+1); for(unsigned long currentLevel=t_Value+250*i;currentLevel<t_Value+250*(i+1)&¤tLevel<max_Value;currentLevel++) {yScale=Objective(currentLevel)*maxYLevel; if(yMaxScale<yScale) { yMaxScale=yScale; maxCriteriaValue=Objective(currentLevel); maximizedLevel=currentLevel; } if(yScale>0) Printer()->Canvas->Rectangle(xCord,curXLevel+20-yScale,xCord+2,curXLevel+20); if(!yScale) Printer()->Canvas->Rectangle(xCord,curXLevel+20,xCord+2,curXLevel+35); int contain; contain=-(yScale/maxYLevel); char str[20]; itoa(contain,str,10); if(yScale<0) { Printer()->Canvas->Rectangle(xCord,curXLevel+20,xCord+2,curXLevel+45); // Printer()->Canvas->TextOutA(xCord,maxYLevel+50,str); } xCord+=7; } Printer()->Canvas->Rectangle(leftBorder-20,curXLevel+20-yMaxScale,leftBorder-30,curXLevel+20-minScale); char maximizedString[80]; ltoa(maximizedLevel,maximizedString,10); AnsiString str; str=Objective(maximizedLevel); AnsiString interval; interval="d є ["; int lwrBorder=t_Value+250*i; int uprBorder=t_Value+250*(i+1); if(uprBorder>max_Value)uprBorder=max_Value; interval=interval+ lwrBorder; interval=interval+ ","; interval=interval+ uprBorder; interval=interval+ "]"; Printer()->Canvas->TextOutA(maxXLevel-300,curXLevel-200,"Поведінка критерія F(d)"); Printer()->Canvas->TextOutA(maxXLevel-300,curXLevel-150,interval); Printer()->Canvas->TextOutA(maxXLevel-300,curXLevel-100,"Максимальне значення :"); Printer()->Canvas->TextOutA(maxXLevel-300,curXLevel-50,"F("); Printer()->Canvas->TextOutA(maxXLevel-255,curXLevel-50,maximizedString); Printer()->Canvas->TextOutA(maxXLevel-200,curXLevel-50,")="); Printer()->Canvas->TextOutA(maxXLevel-170,curXLevel-50,FloatToStrF(Objective(maximizedLevel),ffFixed,6,6)); ltoa(maximizedLevel,maximizedString,2); Printer()->Canvas->TextOutA(maxXLevel-170,curXLevel,maximizedString); xCord=leftBorder; }// end of for() //FloatToStrF(A[i][j],ffFixed,4,4);IntToStr(mm) for(int i=0;i<varCount;i++) Printer()->Canvas->TextOutA(200*i+leftBorder,curXLevel+100,FloatToStrF(p[i],ffFixed,4,4)); for(int i=0;i<varCount;i++) Printer()->Canvas->TextOutA(150*i+leftBorder,curXLevel+150,IntToStr(J[i])); for(int j=0;j<conCount;j++) for(int i=0;i<=varCount;i++) Printer()->Canvas->TextOutA(220*i+leftBorder,50*j+curXLevel+200,FloatToStrF(C[j][i],ffFixed,4,4)); Printer()->EndDoc(); }
/*$6 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include <vcl.h> #pragma hdrstop #include "V_Imprimir.h" #include "V_Circuito.h" #include <vcl/printers.hpp> #pragma package(smart_init) #pragma resource "*.dfm" TFormI *FormI; TPrinter *Impresora = Printer(); /* ======================================================================================================================= ======================================================================================================================= */ __fastcall TFormI::TFormI(TComponent *Owner) : TForm(Owner) { } /* ======================================================================================================================= ======================================================================================================================= */ void __fastcall TFormI::AceptarClick(TObject *Sender)
/* ======================================================================================================================= ======================================================================================================================= */ void __fastcall TFormI::AceptarClick(TObject *Sender) { FormI->Aceptar->Enabled = false; Graphics::TBitmap * bmp = new Graphics::TBitmap(); bmp = FormR->Image1->Picture->Bitmap; bmp->Width = FormR->tamanioCircuito.x; bmp->Height = FormR->tamanioCircuito.y; /*~~~~~~~*/ TRect rc; /*~~~~~~~*/ rc.Left = 0; rc.Top = 0; if(FormI->Orientacion->ItemIndex == 0) { /*~~~~~~~~~~~~~~~~~~~~~~~*/ TPrinter *I = Printer(); /*~~~~~~~~~~~~~~~~~~~~~~~*/ Graphics::TBitmap * bmp = new Graphics::TBitmap(); bmp = FormR->Image1->Picture->Bitmap; // Impresion en vertical. I->Orientation = poPortrait; bmp->Width = FormR->tamanioCircuito.x; bmp->Height = FormR->tamanioCircuito.y; /*~~~~~~~*/ TRect rc; /*~~~~~~~*/ rc.Left = 0; rc.Top = 0; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ double proporcionI = (double) ((double) I->PageHeight / (double) I->PageWidth); double factor = 2.3; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if(FormI->Tamanio->ItemIndex == 0) { rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); } else { // maximizado factor = 1.0; rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); while(rc.Right < I->PageWidth - 100 && rc.Bottom < I->PageHeight - 100) { factor += 0.05; rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); } // end-while } /*~~~~~~~~~~~~~~~~~~~~*/ bool imprimir = true; /*~~~~~~~~~~~~~~~~~~~~*/ if(rc.Right >= I->PageWidth || rc.Bottom >= I->PageHeight) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString m = "Ha habido un problema con la impresora, posiblemente se deba a que:\n\n 1. el tamaño del circuito es mayor que el papel.\n 2. existen trabajos en la cola de impresora.\n\nSolución:\n\n 1. reiniciar el ordenador para eliminar los trabajos de la cola. \n 2. intentar imprimirlo con otras opciones.\n 3. copiar el circuito al portapapeles y editarlo desde otra aplicación.\n 4. imprimir un circuito más pequeño que el de la pantalla. \n\n ¿Imprimir un circuito más pequeño?"; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if(MessageDlg(m, mtError, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes) { while(rc.Right >= I->PageWidth || rc.Bottom >= I->PageHeight) { factor -= 0.1; rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); } // end-while imprimir = true; } else imprimir = false; } // end-if if(imprimir == true) { FormI->Caption = "Imprimiendo..."; I->BeginDoc(); I->Canvas->StretchDraw(rc, bmp); // int pos=I->PageHeight; if(FormR->tipoCircuito == false) // Form9->Solucion->Items->Strings[i] I->Canvas->TextOut(100, 30, FormR->ecuacion->Text); else { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ int solucionNum = FormR->solucionNum; int nLineas = FormR->Lista->Items->Count + 1; int altura = I->Canvas->TextHeight("XXX"); int pos = I->PageHeight - altura * nLineas; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ I->Canvas->TextOut(100, pos, FormR->ListaSol->Items->Strings[solucionNum]); for(int i = 0; i < nLineas - 1; i++) { pos = pos + altura; I->Canvas->TextOut(100, pos, FormR->Lista->Items->Strings[i]); } } I->EndDoc(); ProgressBar1->Min = 0; ProgressBar1->Max = 200; for(int i = ProgressBar1->Min; i <= ProgressBar1->Max; i++) ProgressBar1->Position = i; if(Impresora->Printing == false) FormI->Close(); } // end-if } // end-if Orientacion. else { /*~~~~~~~~~~~~~~~~~~~~~~~*/ // SE IMPRIME EN HORIZONTAL. TPrinter *I = Printer(); /*~~~~~~~~~~~~~~~~~~~~~~~*/ Graphics::TBitmap * bmp = new Graphics::TBitmap(); bmp = FormR->Image1->Picture->Bitmap; // Impresion en vertical. I->Orientation = poLandscape; bmp->Width = FormR->tamanioCircuito.x; bmp->Height = FormR->tamanioCircuito.y; /*~~~~~~~*/ TRect rc; /*~~~~~~~*/ rc.Left = 0; rc.Top = 0; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ double proporcionI = (double) ((double) I->PageWidth / (double) I->PageHeight); double factor = 2.3; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if(FormI->Tamanio->ItemIndex == 0) { rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); } else { // maximizado factor = 1.0; rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); while(rc.Right < I->PageWidth - 40 && rc.Bottom < I->PageHeight - 40) { factor += 0.05; rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); } // end-while } /*~~~~~~~~~~~~~~~~~~~~*/ bool imprimir = true; /*~~~~~~~~~~~~~~~~~~~~*/ if(rc.Right >= I->PageWidth || rc.Bottom >= I->PageHeight) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ AnsiString m = "Ha habido un problema con la impresora, posiblemente se deba a que:\n\n 1. el tamaño del circuito es mayor que el papel.\n 2. existen trabajos en la cola de impresora.\n\nSolución:\n\n 1. reiniciar el ordenador para eliminar los trabajos de la cola. \n 2. intentar imprimirlo con otras opciones.\n 3. copiar el circuito al portapapeles y editarlo desde otra aplicación.\n 4. imprimir un circuito más pequeño que el de la pantalla. \n\n ¿Imprimir un circuito más pequeño?"; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if(MessageDlg(m, mtError, TMsgDlgButtons() << mbYes << mbNo, 0) == mrYes) { while(rc.Right >= I->PageWidth || rc.Bottom >= I->PageHeight) { factor -= 0.1; rc.Right = (int) ((double) bmp->Width * (double) proporcionI * factor); rc.Bottom = (int) ((double) bmp->Height * (double) proporcionI * factor); } // en-while imprimir = true; } else imprimir = false; } // end-if if(imprimir == true) { FormI->Caption = "Imprimiendo..."; I->BeginDoc(); I->Canvas->StretchDraw(rc, bmp); I->EndDoc(); ProgressBar1->Min = 0; ProgressBar1->Max = 100; for(int i = ProgressBar1->Min; i <= ProgressBar1->Max; i++) { if(i >= 20) FormI->Cancelar->Enabled == false; ProgressBar1->Position = i; } if(Impresora->Printing == false) FormI->Close(); } // end-if } // end-else. FormI->Cancelar->Enabled == true; FormI->Aceptar->Enabled = true; }