19295cd64SMichael Pfeiffer /* 29295cd64SMichael Pfeiffer * Copyright 2010, Haiku. All rights reserved. 39295cd64SMichael Pfeiffer * Distributed under the terms of the MIT License. 49295cd64SMichael Pfeiffer * 59295cd64SMichael Pfeiffer * Authors: 69295cd64SMichael Pfeiffer * Michael Pfeiffer 79295cd64SMichael Pfeiffer */ 89295cd64SMichael Pfeiffer #ifndef GP_JOB_H 99295cd64SMichael Pfeiffer #define GP_JOB_H 109295cd64SMichael Pfeiffer 119295cd64SMichael Pfeiffer #include<gutenprint/gutenprint.h> 129295cd64SMichael Pfeiffer 139295cd64SMichael Pfeiffer #include<list> 149295cd64SMichael Pfeiffer 159295cd64SMichael Pfeiffer #include<String.h> 169295cd64SMichael Pfeiffer 179295cd64SMichael Pfeiffer #include "GPBand.h" 189295cd64SMichael Pfeiffer #include "GPJobConfiguration.h" 199295cd64SMichael Pfeiffer #include "OutputStream.h" 209295cd64SMichael Pfeiffer 219295cd64SMichael Pfeiffer 229295cd64SMichael Pfeiffer class GPJob 239295cd64SMichael Pfeiffer { 249295cd64SMichael Pfeiffer public: 259295cd64SMichael Pfeiffer GPJob(); 269295cd64SMichael Pfeiffer ~GPJob(); 279295cd64SMichael Pfeiffer 289295cd64SMichael Pfeiffer void SetApplicationName(const BString& applicationName); 299295cd64SMichael Pfeiffer void SetConfiguration(GPJobConfiguration* configuration); 309295cd64SMichael Pfeiffer void SetOutputStream(OutputStream* outputStream); 319295cd64SMichael Pfeiffer 329295cd64SMichael Pfeiffer status_t Begin(); 339295cd64SMichael Pfeiffer void End(); 349295cd64SMichael Pfeiffer 359295cd64SMichael Pfeiffer status_t PrintPage(list<GPBand*>& bands); 369295cd64SMichael Pfeiffer 379295cd64SMichael Pfeiffer private: 389295cd64SMichael Pfeiffer BRect GetPrintRectangle(list<GPBand*>& bands); 399295cd64SMichael Pfeiffer GPBand* FindBand(int line); 409295cd64SMichael Pfeiffer void FillRow(GPBand* band, unsigned char* data, size_t size, 419295cd64SMichael Pfeiffer int line); 429295cd64SMichael Pfeiffer void FillWhite(unsigned char* data, size_t size); 439295cd64SMichael Pfeiffer 449295cd64SMichael Pfeiffer void Init(); 459295cd64SMichael Pfeiffer void Reset(); 469295cd64SMichael Pfeiffer int Width(); 479295cd64SMichael Pfeiffer int Height(); 489295cd64SMichael Pfeiffer stp_image_status_t GetRow(unsigned char* data, size_t size, int row); 499295cd64SMichael Pfeiffer const char* GetAppname(); 509295cd64SMichael Pfeiffer void Conclude(); 519295cd64SMichael Pfeiffer void Write(const char* data, size_t size); 529295cd64SMichael Pfeiffer void ReportError(const char* data, size_t size); 539295cd64SMichael Pfeiffer 549295cd64SMichael Pfeiffer static void ImageInit(stp_image_t* image); 559295cd64SMichael Pfeiffer static void ImageReset(stp_image_t* image); 569295cd64SMichael Pfeiffer static int ImageWidth(stp_image_t* image); 579295cd64SMichael Pfeiffer static int ImageHeight(stp_image_t *image); 589295cd64SMichael Pfeiffer static stp_image_status_t ImageGetRow(stp_image_t* image, 599295cd64SMichael Pfeiffer unsigned char* data, size_t size, int row); 609295cd64SMichael Pfeiffer static const char* ImageGetAppname(stp_image_t* image); 619295cd64SMichael Pfeiffer static void ImageConclude(stp_image_t *image); 629295cd64SMichael Pfeiffer static void OutputFunction(void *cookie, const char *data, 639295cd64SMichael Pfeiffer size_t size); 649295cd64SMichael Pfeiffer static void ErrorFunction(void *cookie, const char *data, 659295cd64SMichael Pfeiffer size_t size); 669295cd64SMichael Pfeiffer 679295cd64SMichael Pfeiffer BString fApplicationName; 689295cd64SMichael Pfeiffer OutputStream* fOutputStream; 699295cd64SMichael Pfeiffer GPJobConfiguration* fConfiguration; 709295cd64SMichael Pfeiffer 71*fad05958SMichael Pfeiffer bool fHasPages; 729295cd64SMichael Pfeiffer stp_image_t fImage; 739295cd64SMichael Pfeiffer stp_vars_t* fVariables; 749295cd64SMichael Pfeiffer const stp_printer_t* fPrinter; 759295cd64SMichael Pfeiffer BRect fPrintRect; 769295cd64SMichael Pfeiffer list<GPBand*>* fBands; 779295cd64SMichael Pfeiffer GPBand* fCachedBand; 789295cd64SMichael Pfeiffer status_t fWriteError; 799295cd64SMichael Pfeiffer }; 809295cd64SMichael Pfeiffer #endif 81